[SOLVED!] Getting FilePage action to work

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
sasquatchii
Miko-Class Veteran
Posts: 552
Joined: Fri Jul 04, 2014 7:48 am
Completed: A Day in the Life of a Slice of Bread
Deviantart: sasquatchix
Soundcloud: sasquatchii
itch: sasquatchii
Location: South Carolina
Contact:

[SOLVED!] Getting FilePage action to work

#1 Post by sasquatchii »

I am working on coding the save screen for my game. Here's what it currently looks like:

Image

I am using an imagemap for the file save slots/screenshots & for the file page numbers. However, when I put in the imagemap for the file save slots, the original file page numbers from the default renpy UI stopped working, and I'm having trouble getting it to work with the new image map.

It should be noted that the numbers on the top and the numbers on the bottom are the same type of menus - the ones on the top are my image map design & the ones on the bottom are the default from the RenPy standard UI interface. I left the default one to try to figure out the best way to code the new one & to copy code from it. I will delete it once I can figure out how to get the new one working.

Here is the bit of code I'm using for the file page numbers:

Code: Select all

        hotspot (273, 1135, 38, 21) action FilePagePrevious()
        hotspot (977, 1135, 38, 21) action FilePageNext()
            
            
        hotspot (358, 1135, 65, 32) action FilePage(1)
        hotspot (463, 1135, 65, 32) action FilePage(2)
        hotspot (566, 1135, 65, 32) action FilePage(3)
        hotspot (671, 1135, 65, 32) action FilePage(4)
        hotspot (777, 1135, 65, 32) action FilePage(5)
        hotspot (883, 1135, 65, 32) action FilePage(6)
And here is all of the code in its entirety for the save / load screens:

Code: Select all

screen save():

    tag menu

    use file_slots(_("Save"))
    add "gui/save-menu-title.png"
    
    imagemap:
        ground "gui/saveload-boxes-idle.png"
        hover "gui/saveload-boxes-hover.png"
        selected_idle "gui/saveload-boxes-hover.png"
          
        hotspot (137, 234, 315, 192) clicked FileSave(1):
            use load_save_slot(number=1)

        hotspot (495, 234, 315, 192) clicked FileSave(2):
            use load_save_slot(number=2)

        hotspot (851, 234, 315, 192) clicked FileSave(3):
            use load_save_slot(number=3)
            
        hotspot (136, 456, 315, 192) clicked FileSave(4):
            use load_save_slot(number=4)

        hotspot (494, 456, 315, 192) clicked FileSave(5):
            use load_save_slot(number=5)

        hotspot (851, 456, 315, 192) clicked FileSave(6):
            use load_save_slot(number=6)
            
        
        
        hotspot (273, 1135, 38, 21) action FilePagePrevious()
        hotspot (977, 1135, 38, 21) action FilePageNext()
            
            
        hotspot (358, 1135, 65, 32) action FilePage(1)
        hotspot (463, 1135, 65, 32) action FilePage(2)
        hotspot (566, 1135, 65, 32) action FilePage(3)
        hotspot (671, 1135, 65, 32) action FilePage(4)
        hotspot (777, 1135, 65, 32) action FilePage(5)
        hotspot (883, 1135, 65, 32) action FilePage(6)




            


screen load():

    tag menu

    use file_slots(_("Load"))
    add "gui/load-menu-title.png"


screen file_slots(title):

    default page_name_value = FilePageNameInputValue(pattern=_("Page {}"), auto=_("Automatic saves"), quick=_("Quick saves"))

    use game_menu(title):

        fixed:

            ## This ensures the input will get the enter event before any of the
            ## buttons do.
            order_reverse True

            ## The page name, which can be edited by clicking on a button.
            button:
                style "page_label"

                key_events True
                xalign 0.5
                action page_name_value.Toggle()


            ## Buttons to access other pages.
            hbox:
                style_prefix "page"

                xalign 0.5
                yalign 1.0

                spacing gui.page_spacing

                textbutton _("<") action FilePagePrevious()

                if config.has_autosave:
                    textbutton _("{#auto_page}A") action FilePage("auto")

                if config.has_quicksave:
                    textbutton _("{#quick_page}Q") action FilePage("quick")

                ## range(1, 10) gives the numbers from 1 to 9.
                for page in range(1, 10):
                    textbutton "[page]" action FilePage(page)

                textbutton _(">") action FilePageNext()


style page_label is gui_label
style page_label_text is gui_label_text
style page_button is gui_button
style page_button_text is gui_button_text

style slot_button is gui_button
style slot_button_text is gui_button_text
style slot_time_text is slot_button_text
style slot_name_text is slot_button_text

style page_label:
    xpadding 50
    ypadding 3

style page_label_text:
    text_align 0.5
    layout "subtitle"
    hover_color gui.hover_color

style page_button:
    properties gui.button_properties("page_button")

style page_button_text:
    properties gui.button_text_properties("page_button")

style slot_button:
    properties gui.button_properties("slot_button")

style slot_button_text:
    properties gui.button_text_properties("slot_button")
    
screen load_save_slot:
    $ file_text = "% 2s. %s\n%s" % (
                        FileSlotName(number, 3),
                        FileTime(number, empty=_("Empty Slot")),
                        FileSaveName(number))


    add FileScreenshot(number) xpos 20 ypos 13
    
init -2 python:
    config.thumbnail_width = 261
    config.thumbnail_height = 147
I'm not sure where I've gone wrong or what I should be doing differently. Any help or insight would be much appreciated!
Last edited by sasquatchii on Tue Aug 22, 2017 8:02 am, edited 1 time in total.
ImageImage

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Getting FilePage action to work

#2 Post by PyTom »

What seems weird her is that you have both a call to file_slots, and then the imagemap. You really only need one or the other. Maybe that has something to do with the problem?
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
sasquatchii
Miko-Class Veteran
Posts: 552
Joined: Fri Jul 04, 2014 7:48 am
Completed: A Day in the Life of a Slice of Bread
Deviantart: sasquatchix
Soundcloud: sasquatchii
itch: sasquatchii
Location: South Carolina
Contact:

Re: [SOLVED!] Getting FilePage action to work

#3 Post by sasquatchii »

Thanks, PyTom! I took out the call to file_slots.

I also realized that my imagemap was wrong with the vertical positioning, fixed that and now it's all working nicely! :)
ImageImage

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], bonnie_641