I can't load slots on one of my load screens

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
Karrion
Regular
Posts: 74
Joined: Fri Jan 18, 2019 8:33 pm
Projects: Murder on the Marine Express
Organization: 1564 Studio
itch: 1564-studio
Contact:

I can't load slots on one of my load screens

#1 Post by Karrion »

I have to almost equal load state screens (I had to use two for layout reasons), and there are almost no changes on the two of them, however, on the normal one I can load with no problem, while on the clean one, I can't. The buttons don't respond, the text does not change to hover, etc, it's like the button is not there. Here is the code for both screens:

Code: Select all

screen save():

    tag menu

    use file_slots(_("Save"))


screen load():

    tag menu

    use file_slots(_("Load"))


screen file_slots(title):

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

    add "images/template_menu_[title].jpg"

    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.

        ## The grid of file slots.
        grid gui.file_slot_cols gui.file_slot_rows:
            style_prefix "slot"

            xpos 484
            ypos 360

            xspacing 138
            yspacing 80

            for i in range(gui.file_slot_cols * gui.file_slot_rows):

                $ slot = i + 1

                button:
                    action FileAction(slot)

                    has vbox

                    add FileScreenshot(slot) xalign 0.5

                    text FileTime(slot, format=_("{#file_time}%a %m.%d.%Y"), empty=_(" ")):
                        xpos 162
                        ypos 30
                        size 72
                        layout "nobreak"
                        style "slot_time_text"

                    text FileSaveName(slot):
                        style "slot_name_text"

                    key "save_delete" action FileDelete(slot)

        ## Buttons to access other pages.
        hbox:
            xpos 471
            ypos 959
            imagebutton idle "button_back.png" action [ShowMenu("preferences"),Hide("file_slots", dissolve)]

        hbox:
            xpos 1034
            ypos 967
            spacing 7
            imagebutton idle "button_up.png" action FilePagePrevious()
            imagebutton idle "button_down.png" 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 75
    ypadding 5

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")


##################################CLEAN LOAD###################################

screen loadclean():

    tag menu

    use file_slots_clean(_("Load"))


screen file_slots_clean(title):

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

    add "images/template_[title]_clean.jpg"

    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.

        ## The grid of file slots.
        grid gui.file_slot_cols gui.file_slot_rows:
            style_prefix "slot"

            xpos 480
            ypos 293

            xspacing 138
            yspacing 80

            for i in range(gui.file_slot_cols * gui.file_slot_rows):

                $ slot = i + 1

                button:
                    action FileAction(slot)

                    has vbox

                    add FileScreenshot(slot) xalign 0.5

                    text FileTime(slot, format=_("{#file_time}%a %m.%d.%Y"), empty=_(" ")):
                        xpos 162
                        ypos 30
                        size 72
                        layout "nobreak"
                        color Color("#ffe0de")
                        style "slot_time_text"

                    text FileSaveName(slot):
                        style "slot_name_text"

                    key "save_delete" action FileDelete(slot)

        ## Buttons to access other pages.
        hbox:
            xpos 471
            ypos 959
            imagebutton idle "button_back.png" action Return()

        hbox:
            xpos 1034
            ypos 967
            spacing 7
            imagebutton idle "button_up.png" action FilePagePrevious()
            imagebutton idle "button_down.png" 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 75
    ypadding 5

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")

The changes are mostly, the background image, the action of the "back_button", and the positioning of the grid. Any ideas why this is happening?
1564 Studio, an indie studio dedicated to developing mystery VNs!
Follow us on Twitter for updates on our projects!

Image

Check out our current project, just released on PC, Android, Switch, XBox ONE/Series S/X and PS4/5!
Also available in Spanish, English, French and Japanese!

Image

User avatar
MaydohMaydoh
Regular
Posts: 165
Joined: Mon Jul 09, 2018 5:49 am
Projects: Fuwa Fuwa Panic
Tumblr: maydohmaydoh
Location: The Satellite of Love
Contact:

Re: I can't load slots on one of my load screens

#2 Post by MaydohMaydoh »

It's because of the screen name and the FileAction action.
FileAction checks if the screen name is "load" and returns the FileLoad action else it returns the FileSave action.

Code: Select all

if renpy.current_screen().screen_name[0] == "load":
    return FileLoad(name, page=page, **kwargs)
else:
    return FileSave(name, page=page, **kwargs)
So because your screen isn't called "load", it returns the FileSave action which causes the buttons to become insensitive when in the main menu, in a replay or if the page name is "auto". Either way, the loadclean would cause renpy to save instead of load even with the buttons enabled.
So basically you need to do it yourself instead of using the default FileAction by creating a new function.

Code: Select all

init python:
    def FileActionClean(name, page=None, **kwargs):
        if renpy.current_screen().screen_name[0] == "loadclean":
            return FileLoad(name, page=page, **kwargs)
        else:
            return FileSave(name, page=page, **kwargs)
Something like that.

User avatar
Karrion
Regular
Posts: 74
Joined: Fri Jan 18, 2019 8:33 pm
Projects: Murder on the Marine Express
Organization: 1564 Studio
itch: 1564-studio
Contact:

Re: I can't load slots on one of my load screens

#3 Post by Karrion »

That worked perfectly! Thank you! :D
1564 Studio, an indie studio dedicated to developing mystery VNs!
Follow us on Twitter for updates on our projects!

Image

Check out our current project, just released on PC, Android, Switch, XBox ONE/Series S/X and PS4/5!
Also available in Spanish, English, French and Japanese!

Image

Post Reply

Who is online

Users browsing this forum: Bing [Bot]