init offset = 99
default persistent.save_naming = True
style check_button:
    padding (32, 6, 6, 6)
style check_button_text:
    selected_hover_color gui.hover_color
style radio_button:
    padding (32, 6, 6, 6)
style radio_button_text:
    selected_hover_color gui.hover_color
screen screen_save_name(slot):
    modal True
    zorder 200
    style_prefix "confirm"
    add "gui/overlay/confirm.png"
    frame:
        vbox:
            spacing 25
            xsize 650
            if FileLoadable(slot):
                label _("Save name ({color=#f00}overwrite{/color}):") style "confirm_prompt"
            else:
                label _("Save name ({color=#00ff00}new{/color}):") style "confirm_prompt"
            input:
                value VariableInputValue('save_name')
                length 30
                xalign 0.5
         
            hbox:
                xfill True
                textbutton _("Yes") action FileAction(slot, confirm=False), Hide("screen_save_name") xalign 0.5
                textbutton _("No") action Hide("screen_save_name") xalign 0.5
 
    ## Right-click and escape answer "no".
    key "game_menu" action Hide("screen_save_name")
    ## Return of Enter answer "yes".
    key "K_RETURN" action FileAction(slot, confirm=False), Hide("screen_save_name")
    key "K_KP_ENTER" action FileAction(slot, confirm=False), Hide("screen_save_name")
screen file_slots(title):
    default page_name_value = FilePageNameInputValue(pattern=_("Page {}"), auto=_("Automatic saves"), quick=_("Quick saves"))
    use game_menu(title):
        frame:
            style "empty"
            style_prefix "check"
            xsize 410
            xalign 0.94
            if persistent.save_naming:
                textbutton _("Save naming enabled") action ToggleField(persistent,"save_naming")
            else:
                textbutton _("Save naming disabled") action ToggleField(persistent,"save_naming")
        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()
                input:
                    style "page_label_text"
                    value page_name_value
            ## The grid of file slots.
            grid gui.file_slot_cols gui.file_slot_rows:
                style_prefix "slot"
                xalign 0.5
                yalign 0.5
                spacing gui.slot_spacing
                for i in range(gui.file_slot_cols * gui.file_slot_rows):
                    $ slot = i + 1
                    button:
                        if renpy.current_screen().screen_name[0] == "load":
                            action FileAction(slot)
                        else:
                            # Highlight if the current save slot is the last save
                            selected (str(persistent._file_page) + "-" + str(slot) == renpy.newest_slot("[0-9]"))
                            if persistent.save_naming:
                                action SetVariable("save_name", FileSaveName(slot)), Show("screen_save_name", slot=slot)
                            else:
                                action SetVariable("save_name", FileSaveName(slot)), FileAction(slot)
                        has vbox
                        add FileScreenshot(slot) xalign 0.5
                        text FileTime(slot, format=_("{#file_time}%A, %B %d %Y, %H:%M"), empty=_("empty slot")):
                            style "slot_time_text"
                        text FileSaveName(slot):
                            style "slot_name_text"
                        key "save_delete" action FileDelete(slot)
            ## 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()