define persistent.whatsThisMttkMod = "mttkModSaves2special 1.3.D8-14 v1.0 /DM for - Ecchi Sensei  - D8-14 v1.0 /DM"

define mttkModLicense = """THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."""


init offset=1
##change the colors for the slot-text
##org is in: menu/gui.rpy
##is doubled
define gui.slot_button_text_idle_color = '#000099'#'#ffffff'#'#888888'
define gui.slot_button_text_selected_idle_color = '#000099'#'#ffffff'#'#555555'
define gui.slot_button_text_hover_color = '#ffffff'#'#0000ff'#gui.hover_color = '#0099ff'
define gui.slot_button_text_selected_hover_color = '#ffffff'#'#0000ff'#'#0099ff'
define gui.slot_button_text_insensitive_color = '#555555'#gui.insensitive_color = '#aaaaaa7f'

##reenable file_slots
##org is in: menu/screens.rpy
##is doubled
screen load():
    tag menu
    if ("Ecchi Sensei "==config.name and (config.version in ["D8-14 v1.0", "D8-14 v1.0 DM"])):
        imagemap:
            auto "gui/_lain/save_load_scr/load_%s.png"
            hotspot (1799, 11, 111, 110) hovered Play("sound", "etc/sfx/btn_hovered.mp3") unhovered Play("sound", "etc/sfx/btn_unhovered.mp3") activate_sound "etc/sfx/button_exit.ogg" action Return()
        use file_slots(_("Load"))
    else:
        if renpy.loadable("zMttkModFolder/MttkModESW2.rpyc"):
            $ mttkModDefTextThIsWronGameVer()
        use navigation()

##reenable file_slots
##org is in: menu/screens.rpy
##is doubled
screen save():
    tag menu
    if ("Ecchi Sensei "==config.name and (config.version in ["D8-14 v1.0", "D8-14 v1.0 DM"])):
        imagemap:
            auto "gui/_lain/save_load_scr/bg_%s.png"
            hotspot (1799, 11, 111, 110) hovered Play("sound", "etc/sfx/btn_hovered.mp3") unhovered Play("sound", "etc/sfx/btn_unhovered.mp3") activate_sound "etc/sfx/button_exit.ogg" action Return()
        use file_slots(_("Save"))
    else:
        if renpy.loadable("zMttkModFolder/MttkModESW2.rpyc"):
            $ mttkModDefTextThIsWronGameVer()
        use navigation()

##make the save-game-page-name editable again and be able to access more save-game-pages more easily
##somehow I only could it make work when used in file_slots (and not in load or save) (?)
##org is in: menu/screens.rpy (screen load & screen save)
##is doubled (screen file_slots itself is not being used by original, tho present)
screen file_slots(title=""):
    default page_name_value = FilePageNameInputValue(pattern=_("Day {}"), auto=_("Automatic saves"), quick=_("Quick saves"))
    use navigation()
    fixed pos (180, 10):
        order_reverse True
        button:
            style "page_label"
            key_events True
            xalign 0.5
            yalign 0.11
            action page_name_value.Toggle()
            input:
                style "page_label_text"
                size gui.label_text_size+8
                bold True
                outlines [(2, "#000", 0, 0)]
                value page_name_value
        grid gui.file_slot_cols gui.file_slot_rows:
            style_prefix "slot"
            xalign 0.5
            yalign 0.5
            xspacing gui.slot_spacing#was#spacing gui.slot_spacing
            yspacing gui.slot_spacing+gui.slot_button_text_size
            for i in range(gui.file_slot_cols * gui.file_slot_rows):
                $ slot = i + 1
                button:
                    if title==_("Save"):
                        action [SetField(persistent,'save_slot',str(persistent._file_page) + '-' + str(slot)), FileAction(slot), Play("sound", "etc/sfx/save_save.mp3")]#imho the persistent, is not needed when saving, but...you never know;)
                    else:
                        action [SetField(persistent,'save_slot',str(persistent._file_page) + '-' + str(slot)), FileAction(slot)]#the persistent here(set by dev), is used in the after_load to verify game-version
                    key "save_delete" action [FileDelete(slot), Play("sound", "etc/sfx/delete_save.mp3")]
                    vbox:#has vbox#can't make it work#I still don't get why anybody uses "has vbox" instead of "vbox:"
                        add FileScreenshot(slot) xalign 0.5
                        null height 5
                        hbox xalign 0.5:
                            #imagebutton:##as action NullAction() ... why show it???
                                #xalign 0.5
                                #idle Transform("menu/rename.png", zoom=0.5)
                                #hover Transform("menu/rename1.png", zoom=0.5)
                                #action NullAction()
                            #if not FileSaveName(slot) == "":
                                #null width 10
                            if FileNewest(slot):##I'm kinda sure this worked without us checking here explicitly (?) (but how?!) (but maybe I misunderstood "selected" for "newest")
                                if not FileSaveName(slot)=="":
                                    text "{size=-5}saved by:{/size} ":
                                        style "slot_name_text"
                                        color "ff8888"
                                        hover_color "#ffffff"#"#0000ff"
                                text FileSaveName(slot):
                                    style "slot_name_text"
                                    color "#ffffff"#"ff8888" #hover_color "#0000ff"
                            else:
                                if not FileSaveName(slot)=="":
                                    text "{size=-5}saved by:{/size} ":
                                        style "slot_name_text"
                                text FileSaveName(slot):
                                    style "slot_name_text"
                                    color "#ffffff"
                        if FileNewest(slot):
                            text FileTime(slot, format=_("{#file_time}%d %b %Y, %H:%M"), empty=_("empty slot")):
                                style "slot_time_text"
                                color "ff8888"
                                hover_color "#ffffff"#"#0000ff"
                        else:
                            text FileTime(slot, format=_("{#file_time}%d %b %Y, %H:%M"), empty=_("empty slot")):
                                style "slot_time_text"
        hbox:
            style_prefix "page"
            xalign 0.5
            yalign 0.93#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")
            #for page in range(1, 10):
                #textbutton "Day[page]" action FilePage(page)
            if (persistent._file_page=="auto" or persistent._file_page=="quick"):
                for page in range(1, 11):
                    textbutton "[page]" action FilePage(page)
                textbutton "20" action FilePage(20)
            else:
                $ i = -1
                $ i = int(persistent._file_page)
                if str(i)!=persistent._file_page:##safety
                    $ i = 1
                elif i < 1:##safety2
                    $ i = 1
                elif i < 10:
                    pass
                elif i < 20:
                    textbutton "1" action FilePage( 1 )
                    textbutton "10" action FilePage( 10 )
                elif i < 90:
                    textbutton str( ((abs(i) // 10)*10)-10 ) action FilePage( ((abs(i) // 10)*10)-10 )
                    textbutton str( (abs(i) // 10)*10 ) action FilePage( (abs(i) // 10)*10 )
                else:# >=90
                    textbutton str( ((abs(i) // 10)*10)-40 ) action FilePage( ((abs(i) // 10)*10)-40 )
                    textbutton str( ((abs(i) // 10)*10)-10 ) action FilePage( ((abs(i) // 10)*10)-10 )
                    textbutton str( (abs(i) // 10)*10 ) action FilePage( (abs(i) // 10)*10 )
                for page in range( ( ((abs(i) // 10)*10)+1 ), ( ((abs(i) // 10)*10)+10  ) ):
                    textbutton "[page]" action FilePage(page)
                if i < 10:
                    textbutton "10" action FilePage( 10 )
                    textbutton "20" action FilePage( 20 )
                elif i < 90:
                    textbutton str( ((abs(i) // 10)*10)+10 ) action FilePage( ((abs(i) // 10)*10)+10 )
            textbutton _(">") action FilePageNext()

init offset=0



##eof

