define whatsThisMttkMod = "MttkModSaves 1.5.4 - splitted/new part of/for mttkMod 1.5"
define mttkModStrSGDver = "1.5.4.0"

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.
    .
    ANY USAGE, READING, LEARNING FROM OR USE IN CONJUNCTION BY OR WITH
    MACHINE LEARNING, DEEP LEARNING, ARTIFICIAL INTELLIGENCE OR SIMILIAR
    IS STRICTLY FORBIDDEN."""

###TODO: debug-info e.g. in help

init 66:##renpy-ver and allowed bounderies ( tooSmall < ver < tooBig )
    define mttkModIntRPYver = 0 if ( ( int( renpy.version_tuple[ 2 ] ) < 0 ) or ( int( renpy.version_tuple[ 1 ] ) < 0 ) or ( int( renpy.version_tuple[ 0 ] ) < 0 ) ) else ( ( int( renpy.version_tuple[ 2 ] ) if ( int( renpy.version_tuple[ 2 ] ) < 100 ) else 99 ) + ( ( int( renpy.version_tuple[ 1 ] ) * 100 ) if ( int( renpy.version_tuple[ 1 ] ) < 100 ) else 9900 ) + ( int( renpy.version_tuple[ 0 ] ) * 10000 ) )
    define mttkModIntTooSmallRPYver = 69913#: 6.99.14.?(for im.data) #6.99.14.3(for selected_color), 6.99.11.?(for padding), 6.16.?.?(for json)
    define mttkModIntTooBigRPYver = 80600# e.g.8.(0)5.0.2508+nightly

init 110:##"configuration"-consts
    define mttkModIntCapDescriptionAt = 23#chars #warning more chars most likely will not "fit into" the button...
    define mttkModFloatScaleButtToOne = 4.2#th of (the smaller of) width or height of screenshot thumbnails ## keep it between 2 < Scale..To < 8 !
    define mttkModFloatYAlignOfPageButtons = 1.0#this and all following need to be adjusted for some games
    define mttkModTupDisplayedThumbnailSize = ( renpy.config.thumbnail_width, renpy.config.thumbnail_height )#thumbnails will be transformed (also for size of my delete-button)
    define mttkModStrFileScreenshotEmpty = None
    define mttkModFloatSlotGridXAlign = 0.5
    define mttkModFloatSlotGridYAlign = 0.5
    define mttkModIntLabelRPadding = int( mttkModIntSpacingFrmSmallTxt // 2 )
    define mttkModBoolActionsBefore = False
    define mttkModBoolActionsAfter = False
    define mttkModBoolMoreText = False
    define mttkModFloatSyncBTopXAlign = 0.88
    define mttkModBoolStoreSNPredefined = False#$ setMttkVar( "intStoreSNPredefined", delete = True )
    define mttkModIntYPosAdjustOf2TopLines = 0
    define mttkModFloatDelButtAlign = ( 1.0, 1.0 )
init 120:## aft 116 before 123
    define mttkModDictSlotGridSpaciProps = { "xspacing" : gui.slot_spacing, "yspacing" : ( ( gui.slot_spacing + mttkModIntStdTxtSize ) if mttkModBoolMoreText else gui.slot_spacing ) }


screen mttkModScnSavHlp():
    modal True
    zorder 166#pot.game-specific
    $ mttkModBoolIsLoadScreen = False
    if renpy.current_screen().screen_name[ 0 ] == "load":
        $ mttkModBoolIsLoadScreen = True
    key "K_SPACE" action Hide( "mttkModScnSavHlp" )
    key "dismiss" action Hide( "mttkModScnSavHlp" )
    key "game_menu" action Hide( "mttkModScnSavHlp" )
    key "x" action Hide( "mttkModScnSavHlp" )
    key "X" action Hide( "mttkModScnSavHlp" )
    key "o" action Hide( "mttkModScnSavHlp" )
    key "O" action Hide( "mttkModScnSavHlp" )
    on "hide" action Function( mttkModDefSSNonHelper )#for getMttkVar( "intStoreSNConf" ) == 2
    frame:
        style "mttkModStyMyHlpFrame"
        style_prefix "mttkModStyMyHlpFrame"
        background "#000f"
        xalign 0.66
        yalign 0.5
        xpadding int( mttkModIntSpacingFrmSmallTxt + mttkModIntStdOutlineSize )
        top_padding int( mttkModIntSpacingFrmSmallTxt - mttkModIntStdOutlineSize )
        bottom_padding 1
        vbox:
            text "{size=+4}SaveGameDescription:{/size}      (version [mttkModStrSGDver])\n-click to change, then click(or hit return) to accept\n-to take over the description of an existing savegame:"
            hbox:
                spacing ( mttkModIntStdTxtSize * 2 )
                text ""
                if ( not mttkModBoolIsLoadScreen and getMttkVar( "strSaveName" ) != getMttkVar( "strSNTemp" ) ):
                    textbutton "{size=-2}(take over description now){/size}":
                        text_color "#600"
                        text_hover_color "#0f0"
                        action Function( setMttkVar, "strSaveName", getMttkVar( "strSNTemp" ) )
                else:
                    textbutton "{size=-2}                                          {/size}":
                        action NullAction()
                if renpy.exports.variant( "touch" ):
                    text "longpress{size=-6}(alternate-action){/size} it"
                else:
                    text "middle-click on it"
            text " (then click on a save-game-slot to save the game;)\n (\"save-game-description\" and \"SGD\" will never be added to the save-game)":
                size mttkModIntSmallTxtSize
            null height mttkModIntSpacingFrmSmallTxt
            hbox:
                spacing mttkModIntSpacingFrmSmallTxt
                textbutton "{b}toggle{/b}{size=-2} SaveGameSlotDeleteButton{/size}":
                    action Function( setMttkVar, "boolShowSaveDelButton", toggle = True )
                    if getMttkVar( "boolShowSaveDelButton" ):
                        text_hover_color "#f00"
                    else:
                        text_hover_color "#0f0"
                add "mttkModImgDelButtHover" yalign 0.5
                text "{size=-2}atm:{/size}" color "#aaa"
                if getMttkVar( "boolShowSaveDelButton" ):
                    text "{b}enabled{/b}" color "#0f0"
                else:
                    text "{b}disabled{/b}" color "#f00"
            if ( mttkModIntRPYver >= 70400 and getMttkVar( "boolShowSaveDelButton" ) ):#else:not needed...
                hbox:
                    spacing mttkModIntSpacingFrmSmallTxt
                    text "{i}(debug){/i}" color "#aaa"#im.* was called deprecated 7.4.0 !
                    textbutton "{b}toggle{/b}{size=-2} config.GL2{/size}":#"matrixcolor" needs: gl2=True !
                        action Function( setMttkVar, "boolSavesGL2mode", toggle = True )
                        if getMttkVar( "boolSavesGL2mode" ):
                            text_hover_color "#f00"
                        else:
                            text_hover_color "#0f0"
                    text "{size=-2}atm:{/size}" color "#aaa"
                    if getMttkVar( "boolSavesGL2mode" ):
                        text "{b}enabled{/b}" color "#0f0"
                    else:
                        text "{b}disabled{/b}" color "#f00"
                    text "{size=-8}(needs game-restart to take effect){/size}" color "#aaa"
            null height mttkModIntSpacingFrmSmallTxt
            hbox:
                spacing mttkModIntSpacingFrmSmallTxt
                if not mttkModBoolStoreSNPredefined:
                    textbutton "{b}toggle{/b}{size=-2} store.save_name-configuration{/size}":
                        action Function( setMttkVar, "intStoreSNConf", ( 0 if getMttkVar( "intStoreSNConf" ) == 2 else ( getMttkVar( "intStoreSNConf" ) + 1 ) ) )
                else:
                    textbutton "{size=-2}{b}{color=#aaa}predefined{/color}{/b} {color=#eebb00}store.save_name-configuration{/color}{/size}":
                        action NullAction()
                text "{size=-2}atm:{/size}" color "#aaa"
                if getMttkVar( "intStoreSNConf" ) == 2:
                    text "{b}IGNORE{/b}{size=-2} and always {/size}{b}TRY{/b}{size=-2} to set to \"\"{/size}{size=" + mtkStr( mttkModIntSmallTxtSize ) + "}\n(no feedback whatsoever) (not recommended){/size}" color "#f00"
                elif getMttkVar( "intStoreSNConf" ) == 1:
                    text "{b}can edit{/b}" color "#af0"
                else:#elif getMttkVar( "intStoreSNConf" ) == 0:
                    text "{b}report only{/b}{size=-2} if not \"\" (recommended){/size}" color "#0f0"
            if getMttkVar( "intStoreSNConf" ) == 1:
                hbox:
                    spacing 0
                    text "-two new buttons available: " size mttkModIntSmallTxtSize
                    textbutton "{size=" + mtkStr( int( max( ( style.mttkModStyFsPageSelect_button_text.size * mttkModIntSmallTxtSize / mttkModIntStdTxtSize ), mttkModIntSmallTxtSize ) + 2 ) ) + "}{color=#0f0}EQUAL{/color} set to {/size}\"\"":
                        style "mttkModStyFsMyPageT_button"
                        yalign 0.5
                        text_hover_color "#fff"
                        action NullAction()
                    text " & " size mttkModIntSmallTxtSize
                    textbutton "{size=" + mtkStr( int( max( ( style.mttkModStyFsPageSelect_button_text.size * mttkModIntSmallTxtSize / mttkModIntStdTxtSize ), mttkModIntSmallTxtSize ) ) ) + "}{color=#f00}different{/color}{/size}  set":
                        style "mttkModStyFsMyPageT_button"
                        yalign 0.5
                        text_hover_color "#0f0"
                        action NullAction()
                text " state of (edited) text-input and value in store: {color=#0f0}EQUAL{/color} or {color=#f00}different{/color}\n (if {color=#f00}different{/color}, click(set) to write value of text-input to the store;\n  if {color=#0f0}EQUAL{/color} but not \"\"(the default-value), click(set to \"\") to set both(text-input and store) to \"\")" size mttkModIntSmallTxtSize
            null height mttkModIntSpacingFrmSmallTxt
            if renpy.config.name in getMttkVar( "dictGameNamesWDiffSShotVal" ):
                $ mttkModTupTmp = getMttkVar( "dictGameNamesWDiffSShotVal", renpy.config.name )[ 0 ]#default
                $ mttkModTup2Tmp = getMttkVar( "dictGameNamesWDiffSShotVal", renpy.config.name )[ 1 ]#modded
                $ mttkModTup3Tmp = ( renpy.config.thumbnail_width, renpy.config.thumbnail_height )#atm
                hbox:
                    spacing mttkModIntSpacingFrmSmallTxt
                    textbutton "{b}toggle{/b}{size=-2} \"" + mtkStr( renpy.config.name ) + "\" SaveGameScreenshotSize{/size}":
                        if mttkModTup3Tmp == mttkModTupTmp:
                            action ( SetField( renpy.config, "thumbnail_width", mttkModTup2Tmp[ 0 ] ), SetField( renpy.config, "thumbnail_height", mttkModTup2Tmp[ 1 ] ), Function( setMttkVar, "tupConfigThumbnail", mttkModTup2Tmp ), Hide( "mttkModScnSavHlp" ), Return() )
                        elif mttkModTup3Tmp == mttkModTup2Tmp:
                            action ( SetField( renpy.config, "thumbnail_width", mttkModTupTmp[ 0 ] ), SetField( renpy.config, "thumbnail_height", mttkModTupTmp[ 1 ] ), Function( setMttkVar, "tupConfigThumbnail", delete = True ), Hide( "mttkModScnSavHlp" ), Return() )
                        else:
                            text_hover_color "#f00"
                            action NullAction()
                    text "{size=-2}atm:{/size}" color "#aaa"
                    if mttkModTup3Tmp == mttkModTupTmp:
                        text "{color=#0f0}{b}default{/b}{/color}"
                    elif mttkModTup3Tmp == mttkModTup2Tmp:
                        text "{color=#af0}{b}modded{/b}{/color}"
                    else:
                        text "{color=#f00}{b}ERROR!{/b}{/color}"
                null height mttkModIntSpacingFrmSmallTxt
            if ( hasattr( renpy.config, "has_sync" ) and renpy.config.has_sync ):
                hbox:
                    spacing mttkModIntSpacingFrmSmallTxt
                    if not getMttkVar( "boolSyncShowButtons" ):
                        $ mttkModStrTextToPrint = "{color=#f00}not{/color} showing"
                        textbutton "{b}toggle:{/b}{size=-2} [mttkModStrTextToPrint] \"Sync\"-buttons{/size}":
                            action Function( setMttkVar, "boolSyncShowButtons", toggle = True )
                    else:
                        $ mttkModStrTextToPrint = "{color=#0f0}showing{/color}"
                        textbutton "{b}toggle:{/b}{size=-2} [mttkModStrTextToPrint] \"Sync\"-buttons{/size}":
                            action ( Function( setMttkVar, "boolSyncShowButtons", toggle = True ), Function( setMttkVar, "boolSyncButtonsUp", False ) )
                    if getMttkVar( "boolSyncShowButtons" ):
                        text "{size=-2}/{/size}"
                        if not getMttkVar( "boolSyncButtonsUp" ):
                            $ mttkModStrTextToPrint = "BOTTOM"
                        else:
                            $ mttkModStrTextToPrint = "TOP"
                        textbutton "{b}toggle:{/b}{size=-4} show \"Sync\"-buttons at {/size}[mttkModStrTextToPrint]{size=-4} of screen{/size}":
                            action Function( setMttkVar, "boolSyncButtonsUp", toggle = True )
                if getMttkVar( "boolSyncShowButtons" ):
                    if getMttkVar( "boolSyncButtonsUp" ):
                        text "{size=-6}   (warning! it could be possible moving to TOP result in invisibility of \"Sync\"-buttons!){/size}"# color "#aaa"
                null height mttkModIntSpacingFrmSmallTxt
            text mttkModLicense.replace( "\r", "" ).replace( "\n", "" ).replace( "    THIS", "THIS" ).replace( "    ", "\n" ):
                size mttkModIntSmallTxtSize
                color "#aaa"
            if ( renpy.version_tuple < ( 7, 4, 9 ) and renpy.version_tuple >= ( 7, 4, 8 ) ):##hmm, now changing to (Ren)Py-syntax...#lousy TB-prob
            #or...
                hbox:
                    spacing mttkModIntSpacingFrmSmallTxt
                    text "{size=-4}{i}(ignore any warnings){/i}{/size}" color "#aaa"
                    textbutton "{size=-4}{b}toggle{/b}{/size}":
                        action Function( setMttkVar, "boolSavesIgnoreWarnings", toggle = True )
                        if getMttkVar( "boolSavesIgnoreWarnings" ):
                            text_hover_color "#f00"
                        else:
                            text_hover_color "#0f0"
                    text "{size=-8}atm:{/size}" color "#aaa"
                    if getMttkVar( "boolSavesIgnoreWarnings" ):
                        text "{size=-6}{b}enabled{/b}{/size}" color "#0f0"
                    else:
                        text "{size=-6}{b}disabled{/b}{/size}" color "#f00"
            text "{size=-6}(Questions? Feedback? {a=https://f95zone.to/threads/88350/}{color=#ad4}https://f95zone.to/threads/88350/{/color}{/a} ){/size}"
            textbutton "{size=-2}{b}press space or click here to cl{u}o{/u}se{/b}{/size}":
                xalign 1.0
                action Hide( "mttkModScnSavHlp" )


screen mttkModScnSavMore():
    transclude


##more save-game-pages and possible input of description for save-games ## optional SaveGameSlotDeleteButton
##org is in: screens.rpy (at least for most of the games)
##is doubled
init 166 screen file_slots( title ):
    default page_name_value = FilePageNameInputValue( pattern = _( "Page {}" ), auto = _( "Automatic saves" ), quick = _( "Quick saves" ) )
    default mttkModObjFVarInput = MttkModClsDictInputValueWithRaiseIgnoreE( persistent.mttkModDictAllVars, "strSaveName", default = False, returnable = True )###TODO var must run through the def!
    default mttkModObjFVarIn2 = MttkModClsDictInputValueWithRaiseIgnoreE( persistent.mttkModDictAllVars, "strStoreSName", default = False, returnable = True )###i.e. looking for a "better" input in general...
    $ mttkModBoolIsLoadScreen = False
    if renpy.current_screen().screen_name[ 0 ] == "load":#this is what FileAction does
        $ mttkModBoolIsLoadScreen = True#not "safe" too of course...but way better than the string...
    on "show" action Function( mttkModDefSetVarsOnShowFileSlots )
    on "replace" action Function( mttkModDefSetVarsOnShowFileSlots )
    key "o" action ( DisableAllInputValues(), Show( "mttkModScnSavHlp" ) )
    key "O" action ( DisableAllInputValues(), Show( "mttkModScnSavHlp" ) )
    use game_menu( title ):
        fixed:
            order_reverse True
            $ mttkModStrCompatibility = "OK-default"#$ i = 2
            if mttkModIntTooSmallRPYver >= mttkModIntRPYver:
                $ mttkModStrCompatibility = "FAIL-saves"#$ i = -1
            elif mttkModIntRPYver >= mttkModIntTooBigRPYver:
                $ mttkModStrCompatibility = "FAIL-saves-TOOBIG"#$ i = -1
            if ( mttkModStrCompatibility.startswith( "OK" ) and renpy.loadable( "zMttkModFolder/zMttkModSupport.rpyc" ) ):#if ( i > 0 and renpy.loadable( "zMttkModFolder/zMttkModSupport.rpyc" ) ):
                if not mttkModDefSupportedGameVersion( treatNoneAsValid = True ):
                    $ mttkModStrCompatibility = "FAIL-zSupport"#$ i = -2
            if not mttkModBoolIsLoadScreen:
                key "mouseup_2" action ( DisableAllInputValues(), Function( setMttkVar, "strSaveName", getMttkVar( "strSNTemp" ) ) )
            vbox:
                ypos ( 0 + mttkModIntYPosAdjustOf2TopLines )
                xalign 0.5
                spacing 2
                hbox:
                    xalign 0.5
                    yalign 0.0
                    button:
                        style "mttkModStyFsPage_label"
                        key_events True
                        xalign 0.0
                        left_padding mttkModIntSpacingFrmSmallTxt#smaller than org to save space...
                        ypadding 0
                        if ( 69913 < mttkModIntRPYver < 70000 ):#"dirty shortcut" of 6.99.14 (only .3 ?)
                            action Function( renpy.exports.set_editable_input_value, page_name_value, True )
                        else:
                            action page_name_value.Toggle()
                        input:
                            style "mttkModStyFsPage_label_text"
                            value page_name_value
                    if mttkModStrCompatibility.startswith( "FAIL" ):
                        if mttkModStrCompatibility == "FAIL-zSupport":
                            text " Sorry, this is not the correct mod for this game\n -> please deinstall this mod <-":
                                style "mttkModStyFsMyPage_label_text"#style "page_label_text"
                                color "#f00"
                                text_align 0.5
                                yalign 0.0
                        elif mttkModStrCompatibility == "FAIL-saves-TOOBIG":
                            text " Sorry, this RenPy-version is TOO BIG\n -> please look for newer version of mod <-":
                                style "mttkModStyFsMyPage_label_text"
                                color "#f00"
                                text_align 0.5
                                yalign 0.0
                        else:#elif mttkModStrCompatibility.startswith( "FAIL" ):
                            text " Sorry, your RenPy-version is not supported\n -> please deinstall this mod <-":
                                style "mttkModStyFsMyPage_label_text"
                                color "#f00"
                                text_align 0.5
                                yalign 0.0
                    else:
                        if not mttkModBoolIsLoadScreen:
                            if getMttkVar( "strSaveName" ) == "":
                                label " ->":
                                    style "mttkModStyFsMyPage_label"#style "page_label"
                                    xalign 0.5
                                    xpadding 0
                                    ypadding 0
                                    text_color "#fff"
                            button:
                                style "mttkModStyFsMyPage_label"
                                key_events True
                                xalign 0.5
                                left_padding mttkModIntSpacingFrmSmallTxt#at least a (little) bit left too... (could do // 2 ?)
                                ypadding 0#right_padding makes space to button
                                if ( 69913 < mttkModIntRPYver < 70000 ):#"dirty shortcut" of 6.99.14 (only .3 ?)
                                    action Function( renpy.exports.set_editable_input_value, mttkModObjFVarInput, True )
                                else:
                                    action mttkModObjFVarInput.Toggle()
                                input:
                                    style "mttkModStyFsMyPage_label_text"
                                    value mttkModObjFVarInput
                            if getMttkVar( "strSaveName" ) == "":
                                label "<- ":
                                    style "mttkModStyFsMyPage_label"
                                    xalign 0.5
                                    left_padding 0#right_padding makes space to button
                                    ypadding 0
                                    text_color "#fff"
                        textbutton "{u}o{/u}pts{size=" + mtkStr( int( max( ( style.mttkModStyFsPageSelect_button_text.size * mttkModIntSmallTxtSize / mttkModIntStdTxtSize ), mttkModIntSmallTxtSize ) ) ) + "} (&help){/size}":
                            style "mttkModStyFsMyPageT_button"
                            xalign 1.0
                            yalign 0.5
                            ypadding 0
                            action ( DisableAllInputValues(), Show( "mttkModScnSavHlp" ) )
                ###cont of vbox
                if ( not mttkModStrCompatibility.startswith( "FAIL" ) and getMttkVar( "intStoreSNConf" ) == 1 or ( getMttkVar( "intStoreSNConf" ) == 0 and getattr( renpy.store, "save_name", "ERROR" ) != "" ) ):
                    hbox:
                        yalign 1.0
                        if getMttkVar( "intStoreSNConf" ) == 0:
                            xalign 0.0
                        else:# ==1
                            xalign 0.5
                        if getMttkVar( "intStoreSNConf" ) == 1:#start left
                            label "{size=-2}store.save_name:{/size}":
                                style "mttkModStyFsMyPage_label"
                                xalign 0.0
                                ypadding 0
                                text_color "#880"
                        else:# ==0 and != ""
                            label "{size=-2}store.save_name ={/size}":
                                style "mttkModStyFsMyPage_label"
                                xalign 0.0
                                ypadding 0
                                text_color "#880"
                        if getMttkVar( "intStoreSNConf" ) == 1:#start middle
                            if getMttkVar( "strStoreSName" ) == "":
                                label " ->":
                                    style "mttkModStyFsMyPage_label"
                                    xalign 0.5
                                    xpadding 0
                                    ypadding 0
                                    text_color "#fff"
                            button:
                                style "mttkModStyFsMyPage_label"
                                key_events True
                                xalign 0.5
                                left_padding 0#right_padding makes space to button
                                ypadding 0
                                if ( 69913 < mttkModIntRPYver < 70000 ):#"dirty shortcut" of 6.99.14 (only .3 ?)
                                    action Function( renpy.exports.set_editable_input_value, mttkModObjFVarIn2, True )
                                else:
                                    action mttkModObjFVarIn2.Toggle()
                                input:
                                    style "mttkModStyFsMyPage_label_text"
                                    value mttkModObjFVarIn2
                            if getMttkVar( "strStoreSName" ) == "":
                                label "<- ":
                                    style "mttkModStyFsMyPage_label"
                                    xalign 0.5
                                    left_padding 0
                                    ypadding 0
                                    text_color "#fff"
                        else:#elif getMttkVar( "intStoreSNConf" ) == 0 #and store != ""
                            label mtkStr( "{size=-2}" + mtkStr( getMttkVar( "strStoreSName" ) ) + "{/size}" ):
                                style "mttkModStyFsMyPage_label"
                                xalign 0.5
                                left_padding 0#right_padding makes space to button
                                ypadding 0
                                text_color "#f62"
                        if getMttkVar( "intStoreSNConf" ) == 1:#start right
                            if mtkStr( getMttkVar( "strStoreSName" ) ) != mtkStr( getattr( renpy.store, "save_name", '""' ) ):
                                textbutton "{size=" + mtkStr( int( max( ( style.mttkModStyFsPageSelect_button_text.size * mttkModIntSmallTxtSize / mttkModIntStdTxtSize ), mttkModIntSmallTxtSize ) ) ) + "}{color=#f00}different{/color}{/size}  set":
                                    style "mttkModStyFsMyPageT_button"
                                    xalign 1.0
                                    yalign 0.5
                                    text_hover_color "#0f0"
                                    action ( DisableAllInputValues(), Function( mttkModDefSetStoreSaveName, mtkStr( getMttkVar( "strStoreSName" ) ) ), Return() )
                            elif getMttkVar( "strStoreSName" ) == "":
                                label "{size=-6}store.save_name == \"\"{/size}":
                                    style "mttkModStyFsMyPage_label"
                                    xalign 1.0
                                    xpadding 0#left done by <-
                                    ypadding 0
                                    text_color "#0f0"
                            else:
                                textbutton "{size=" + mtkStr( int( max( ( style.mttkModStyFsPageSelect_button_text.size * mttkModIntSmallTxtSize / mttkModIntStdTxtSize ), mttkModIntSmallTxtSize ) + 2 ) ) + "}{color=#0f0}EQUAL{/color} set to {/size}\"\"":
                                    style "mttkModStyFsMyPageT_button"
                                    xalign 1.0
                                    yalign 0.5
                                    text_hover_color "#fff"
                                    action ( DisableAllInputValues(), Function( mttkModDefSetStoreSaveName, "" ), Return() )
            ###out of vbox
            if ( not mttkModStrCompatibility.startswith( "FAIL" ) and getMttkVar( "intStoreSNConf" ) == 0 and getattr( renpy.store, "save_name", "ERROR" ) == "" ):
                label "\n{size=-0}R{/size}":
                    style "mttkModStyFsMyPage_label"
                    xalign 1.0
                    yalign 0.0
                    left_padding 0
                    right_padding mttkModIntLabelRPadding#int( mttkModIntSpacingFrmSmallTxt // 2 )
                    ypadding 0
                    text_color "#0f0"
            elif ( not mttkModStrCompatibility.startswith( "FAIL" ) and getMttkVar( "intStoreSNConf" ) == 2 ):
                label "\n{size=-0}I{/size}":
                    style "mttkModStyFsMyPage_label"
                    xalign 1.0
                    yalign 0.0
                    left_padding 0
                    right_padding mttkModIntLabelRPadding#int( mttkModIntSpacingFrmSmallTxt // 2 )
                    ypadding 0
                    text_color "#f00"

            grid gui.file_slot_cols gui.file_slot_rows:
                style_prefix "mttkModStyFsGrid"#style_prefix "slot"
                xalign mttkModFloatSlotGridXAlign
                yalign mttkModFloatSlotGridYAlign
                properties mttkModDictSlotGridSpaciProps#spacing gui.slot_spacing for <6.99.13 or #xspacing gui.slot_spacing#yspacing ( ( gui.slot_spacing + mttkModIntStdTxtSize ) if mttkModBoolMoreText else gui.slot_spacing )
                for i in range( gui.file_slot_cols * gui.file_slot_rows ):
                    $ slot = i + 1
                    button:
                        if mttkModStrCompatibility.startswith( "FAIL" ):#if not ( mttkModIntTooSmallRPYver < mttkModIntRPYver < mttkModIntTooBigRPYver ):
                            action NullAction()
                        elif not mttkModBoolIsLoadScreen:#elif title == _( "Save" ):
                            hovered ( Function( setMttkVar, "strSNTemp", ( "SGD" if len( FileSaveName( slot ) ) == 0 else FileSaveName( slot ) ) ), Function( mttkModDefChkPVarCapAndNotifyIfNeeded, "strSaveName" ) )#not doing DisableAllInputValues() ...
                            key "save_delete" action FileDelete( slot )
                            alternate If( renpy.exports.variant( "touch" ), ( DisableAllInputValues(), Function( setMttkVar, "strSaveName", getMttkVar( "strSNTemp" ) ) ) )
                            if ( mttkModBoolActionsBefore and mttkModBoolActionsAfter ):
                                action ( Function( mttkModDefActionsBefore, i, slot ), DisableAllInputValues(), Function( setMttkVar, "boolSaveNameActive", True ), FileAction( slot ), Function( mttkModDefActionsAfter, i, slot ) )
                            elif mttkModBoolActionsBefore:
                                action ( Function( mttkModDefActionsBefore, i, slot ), DisableAllInputValues(), Function( setMttkVar, "boolSaveNameActive", True ), FileAction( slot ) )
                            elif mttkModBoolActionsAfter:
                                action ( DisableAllInputValues(), Function( setMttkVar, "boolSaveNameActive", True ), FileAction( slot ), Function( mttkModDefActionsAfter, i, slot ) )
                            else:
                                action ( DisableAllInputValues(), Function( setMttkVar, "boolSaveNameActive", True ), FileAction( slot ) )#old
                        elif mttkModBoolIsLoadScreen:#elif title == _( "Load" ):
                            key "save_delete" action FileDelete( slot )
                            if ( mttkModBoolActionsBefore and mttkModBoolActionsAfter ):
                                action ( Function( mttkModDefActionsBefore, i, slot ), FileAction( slot ), Function( mttkModDefActionsAfter, i, slot ) )
                            elif mttkModBoolActionsBefore:
                                action ( Function( mttkModDefActionsBefore, i, slot ), FileAction( slot ) )
                            elif mttkModBoolActionsAfter:
                                action ( FileAction( slot ), Function( mttkModDefActionsAfter, i, slot ) )
                            else:
                                action FileAction( slot )#old
                        else:#safety->FAIL
                            action NullAction()
                        vbox:
                            fixed:
                                xalign 0.5
                                xysize mttkModTupDisplayedThumbnailSize#xysize ( renpy.config.thumbnail_width, renpy.config.thumbnail_height )
                                add FileScreenshot( slot, empty = mttkModStrFileScreenshotEmpty ) xalign 0.5 yalign 0.5 size mttkModTupDisplayedThumbnailSize
                                if ( mttkModIntTooSmallRPYver < mttkModIntRPYver < mttkModIntTooBigRPYver ):
                                    if ( FileLoadable( slot ) and getMttkVar( "boolShowSaveDelButton" ) ):#FileLoadable() is explicitly for SaveGame-slots, so (imho) by far superior to renpy.loadable() in THIS case!
                                        imagebutton:
                                            align mttkModFloatDelButtAlign#xalign 1.0#yalign 1.0
                                            idle "mttkModImgDelButtIdle"
                                            hover "mttkModImgDelButtHover"
                                            action FileDelete( slot )
                            if FileNewest( slot ):
                                if mttkModBoolIsLoadScreen:#if title == _( "Load" ):
                                    if ( mttkModBoolMoreText and mttkModDefMoreText( i, slot ) != "" ):
                                        text mttkModDefMoreText( i, slot ):
                                            style "mttkModStyFsGrid_new_text"
                                            idle_color mttkModColFsAcc
                                            hover_color mttkModColFsHover
                                    text FileTime( slot, format = _( "{#file_time}%A, %B %d %Y, %H:%M" ), empty = _( "empty slot" ) ):
                                        style "mttkModStyFsGrid_time_text"#style "slot_time_text"
                                        idle_color mttkModColFsAcc
                                        hover_color mttkModColFsHover
                                    text FileSaveName( slot ):
                                        style "mttkModStyFsGrid_name_text"#style "slot_name_text"
                                        idle_color mttkModColFsAcc
                                        hover_color mttkModColFsHover
                                else:
                                    if ( mttkModBoolMoreText and mttkModDefMoreText( i, slot ) != "" ):
                                        text mttkModDefMoreText( i, slot ):
                                            style "mttkModStyFsGrid_new_text"
                                            idle_color mttkModColFsAcc
                                    text FileTime( slot, format = _( "{#file_time}%A, %B %d %Y, %H:%M" ), empty = _( "empty slot" ) ):
                                        style "mttkModStyFsGrid_time_text"
                                        idle_color mttkModColFsAcc
                                    text FileSaveName( slot ):
                                        style "mttkModStyFsGrid_name_text"
                                        idle_color mttkModColFsAcc
                            else:
                                if ( mttkModBoolMoreText and mttkModDefMoreText( i, slot ) != "" ):
                                    text mttkModDefMoreText( i, slot ):
                                        style "mttkModStyFsGrid_new_text"
                                text FileTime( slot, format = _( "{#file_time}%A, %B %d %Y, %H:%M" ), empty = _( "empty slot" ) ):
                                    style "mttkModStyFsGrid_time_text"
                                text FileSaveName( slot ):
                                    style "mttkModStyFsGrid_name_text"
            vbox:
                style_prefix "mttkModStyFsPageSelect"#style_prefix "page"
                xalign 0.5
                yalign mttkModFloatYAlignOfPageButtons#ex 1.0
                spacing mttkModIntStdVBoxSpacing
                hbox:
                    xalign 0.5
                    spacing gui.page_spacing
                    textbutton _( "<" ) action FilePagePrevious()
                    key "save_page_prev" action FilePagePrevious()##came with 8.4.0.nightly
                    if renpy.config.has_autosave:
                        textbutton _( "{#auto_page}A" ) action FilePage( "auto" )
                    if renpy.config.has_quicksave:
                        textbutton _( "{#quick_page}Q" ) action FilePage( "quick" )
                    if ( mttkModIntTooSmallRPYver < mttkModIntRPYver < mttkModIntTooBigRPYver ):
                        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 mtkStr( 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 "1" action FilePage( 1 )
                                textbutton mtkStr( ( ( i // 10 ) * 10 ) - 10 ) action FilePage( ( ( i // 10 ) * 10 ) - 10 )
                                textbutton mtkStr( ( i // 10 ) * 10 ) action FilePage( ( i // 10 ) * 10 )
                            else:# >= 90
                                textbutton "1" action FilePage( 1 )
                                textbutton mtkStr( ( ( i // 10 ) * 10 ) - 40 ) action FilePage( ( ( i // 10 ) * 10 ) - 40 )
                                textbutton mtkStr( ( ( i // 10 ) * 10 ) - 10 ) action FilePage( ( ( i // 10 ) * 10 ) - 10 )
                                textbutton mtkStr( ( i // 10 ) * 10 ) action FilePage( ( i // 10 ) * 10 )
                            for page in range( ( ( ( i // 10 ) * 10 ) + 1 ), ( ( ( 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 mtkStr( ( ( i // 10 ) * 10 ) + 10 ) action FilePage( ( ( i // 10 ) * 10 ) + 10 )
                        $ mttk1Int = mttkModDefGetHighestPageSavedTo()
                        if mttk1Int:
                            textbutton mtkStr( mttk1Int ) action FilePage( mttk1Int )
                    else:#(=org)
                        for page in range( 1, 10 ):## range(1, 10) gives the numbers from 1 to 9.
                            textbutton "[page]" action FilePage( page )
                    textbutton _( ">" ) action FilePageNext()
                    key "save_page_next" action FilePageNext()##see (Mttk)Keys
                #if config.has_sync:
                    #if CurrentScreenName() == "save":#CurrentScreenName can give None back, but in the end renpy.current_screen().screen_name[0]
                        #textbutton _("Upload Sync"):#is used like in FileAction...I'm not checking again...if THIS throws an exception, I deserved it...
                            #action UploadSync()#else:#textbutton _("Download Sync"):
                            #xalign 0.5#action DownloadSync()
                if ( hasattr( renpy.config, "has_sync" ) and renpy.config.has_sync and getMttkVar( "boolSyncShowButtons" ) and not getMttkVar( "boolSyncButtonsUp" ) ):
                    if not mttkModBoolIsLoadScreen:
                        textbutton _( "Upload Sync" ) xalign 0.5 action Function( mttkModDefActionRunner, "SyncUp" )#action UploadSync()
                    else:#=style mttkModStyFsPageSelect_button+_text is page_button+_text
                        textbutton _( "Download Sync" ) xalign 0.5 action Function( mttkModDefActionRunner, "SyncDown" )#action DownloadSync()
            if ( hasattr( renpy.config, "has_sync" ) and renpy.config.has_sync and getMttkVar( "boolSyncShowButtons" ) and getMttkVar( "boolSyncButtonsUp" ) ):
                $ mttk1Int = -66#risky, but most likely better than 0 (?)
                if ( hasattr( style, "game_menu_outer_frame" ) and hasattr( style.game_menu_outer_frame, "top_padding" ) ):
                    $ mttk1Int = style.game_menu_outer_frame.top_padding
                    if ( isinstance( mttk1Int, int ) and mttk1Int > 0 ):
                        $ mttk1Int = mttk1Int * -1
                    else:
                        $ mttk1Int = -66
                if not mttkModBoolIsLoadScreen:
                    textbutton _( "Upload Sync" ):
                        style "mttkModStyFsPageSelect_button"
                        xalign mttkModFloatSyncBTopXAlign
                        yanchor 0
                        ypos mttk1Int
                        action Function( mttkModDefActionRunner, "SyncUp" )
                else:
                    textbutton _( "Download Sync" ):
                        style "mttkModStyFsPageSelect_button"
                        xalign mttkModFloatSyncBTopXAlign
                        yanchor 0
                        ypos mttk1Int
                        action Function( mttkModDefActionRunner, "SyncDown" )

    use mttkModScnSavMore()



init 111 python:
    ## my (persistent) vars
    setMttkVar( "strSaveName", "save-game-description" )
    setMttkVar( "strSNTemp", "save-game-description" )
    setMttkVar( "strStoreSName", "" )
    setMttkVar( "boolSaveNameActive", False )
    if getMttkVar( "intStoreSNConf" ) is None:
        setMttkVar( "intStoreSNConf", 0 )# 0 = ignore if "" (recommended)   # 1 = can edit   # 2 = ignore(never show anything) AND always try to set to "" (not recommended)
    if getMttkVar( "boolShowSaveDelButton" ) is None:
        setMttkVar( "boolShowSaveDelButton", True )
    setMttkVar( "dictGameNamesWDiffSShotVal", mttkModPyDict() )
    if getMttkVar( "boolSyncShowButtons" ) is None:
        setMttkVar( "boolSyncShowButtons", False )
    if getMttkVar( "boolSyncButtonsUp" ) is None:
        setMttkVar( "boolSyncButtonsUp", False )
    if getMttkVar( "boolSavesGL2mode" ) is None:
        setMttkVar( "boolSavesGL2mode", True )
    if getMttkVar( "boolSavesIgnoreWarnings" ) is None:
        setMttkVar( "boolSavesIgnoreWarnings", False )


    class MttkModClsDictInputValueWithRaiseIgnoreE( InputValue, FieldEquality ):# extended input class2
        """
        copy of DictInputValue with raising an IgnoreEvent on enter
        todo: want an input where I can mark(shift-cursor), copy and paste...

        doc from DictInputValue:

        :doc: input_value
        An input value that updates `key` in `dict`.
        `default`
            If true, this input can be editable by default.
        `returnable`
            If true, the value of this input will be returned when the
            user presses enter.
        """
        identity_fields = [ "dict", "key" ]
        equality_fields = [ "returnable" ]
        def __init__(self, dict, key, default=True, returnable=False):
            self.dict = dict
            self.key = key
            self.default = default
            self.returnable = returnable
        def get_text(self):
            return self.dict[self.key]
        def set_text(self, s):
            self.dict[self.key] = s
            renpy.restart_interaction()
        def enter( self ):#copy from FilePageNameInputValue
            renpy.run( self.Disable() )
            raise renpy.IgnoreEvent()


    def mttkModDefChkPVarCapAndNotifyIfNeeded( myPersistentVar = None, doReturn = False ):
        """
        only for personal use - unchecked, unsafe - not fit for anything
        ONLY for persistent.mttkModDictAllVars[ 'strSaveName' ] and persistent.mttkModDictAllVars[ 'strStoreSName' ]

        generally returns None ( is for action Function() )
        on doReturn = True returns True if ALL was OK!
        """
        mttkModTupPVars = ( "strSaveName", "strStoreSName" )
        mttk1Str = None
        mttk1Int = 23
        try:
            doReturn = bool( doReturn )
            if myPersistentVar not in mttkModTupPVars:
                renpy.notify( "SGD-Error while checking and capping:\npassed arg NOT my var! " )
                return None
            mttk1Str = getMttkVar( myPersistentVar )
            if not isinstance( mttk1Str, mttkstrtyp ):
                renpy.notify( "SGD-Error while checking and capping:\nlinked var NOT a string! " )
                return None
            mttk1Int = int( mttkModIntCapDescriptionAt )
            if mttk1Int < 10:
                mttk1Int = 10#just doing it...(no notify)
            if mttk1Int > 200:#no sense in having a string bigger than 255 chars
                mttk1Int = 200
        except Exception as e:
            renpy.notify( "SGD-Exception while checking and capping(1):\n" + mtkStr( e ) )
            return None
        try:
            if len( mttk1Str ) > mttk1Int:
                setMttkVar( myPersistentVar, mttk1Str[ 0:mttk1Int ] )
                renpy.notify( "description too long, capped at " + mtkStr( mttk1Int ) + " chars..." )
        except Exception as e:
            setMttkVar( myPersistentVar, "" )
            renpy.notify( mtkStr( "SGD-Exception while checking and capping(2):\n" + mtkStr( e ) ) )
            return None
        if doReturn:
            return True
        return None

    def mttkModDefGetHighestPageSavedTo():
        """
        only for personal use - unchecked, unsafe - not fit for anything

        an INTeger is returned
        if saves only exist on 'auto' and 'quick' or no save at all exist
        0 is returned

        on any error or exception None is returned
        """
        rv = 0
        try:
            mttk1Lst = renpy.list_slots( regexp = None )
            for mttk3Str in mttk1Lst:
                mttk1Str = mtkStr( mttk3Str )
                if mttk1Str[ 0 ].isdigit():
                    mttk1Int = mttk3Str.index( "-" )#raises ValueError if not found
                    mttk2Str = mttk1Str[ 0 : mttk1Int ]
                    if mttk2Str.isdigit():
                        mttk2Int = int( mttk2Str )
                        if mttk2Int > rv:
                            rv = mttk2Int
        except:
            rv = None
        return rv

    def mttkModDefSetStoreSaveName( seTo = None ):
        """
        only for personal use - unchecked, unsafe - not fit for anything

        SETs renpy.store.save_name
        AND persistent.mttkModDictAllVars[ 'strStoreSName' ]

        stayin in the function...mebbe one day I'll find a way "just to set a variable have that stored"
        found...just SetVar, then jump to a before set return...
        but! StoreSaveName is a lost cause for me, plus I'm lazy, this just stays as it is!...
        """
        try:
            if not isinstance( seTo, mttkstrtyp ):
                renpy.notify( "SGD-Error while setting renpy.store.save_name:\npassed arg NOT a string! " )
                return
            setMttkVar( "strStoreSName", seTo )
        except Exception as e:
            renpy.notify( mtkStr( "SGD-Exception while setting renpy.store.save_name(1):\n" + mtkStr( e ) ) )
            return
        if not mttkModDefChkPVarCapAndNotifyIfNeeded( myPersistentVar = "strStoreSName", doReturn = True ):
            return#already notified!
        try:
            setattr( renpy.store, "save_name", getMttkVar( "strStoreSName" ) )
        except Exception as e:
            renpy.notify( mtkStr( "SGD-Exception while setting renpy.store.save_name(2):\n" + mtkStr( e ) ) )
        ###cycling does the trick!!! BUT also may cycle some (screen-)vars to "deleted" and then loading the save results in an exception stating that some (screen-)var is not existing!
        #try:##SGD 1.3.3
            #if mttkModIntRPYver > 69913:#6.99.14.3 (for get_changes(cycle)!)
                #renpy.game.log.complete( True )#True leads to cycle get_changes()
            #else:
                #renpy.game.log.complete()#69913 and smaller cycles always!
        #except Exception as e:
            #renpy.notify( mtkStr( "SGD-Exception at renpy.game.log.complete():\n" + mtkStr( e ) ) )
        return

    def mttkModDefSSNonHelper():#only used by getMttkVar( "intStoreSNConf" ) == 2
        """ only for personal use - unchecked, unsafe - not fit for anything """
        if getMttkVar( "intStoreSNConf" ) == 2:
            mttkModDefSetStoreSaveName( seTo = "" )
        return

    def mttkModDefSetVarsOnShowFileSlots():
        """ only for personal use - unchecked, unsafe - not fit for anything """
        if not hasattr( renpy.store, "save_name" ):#may throw an exception...but then there are way more SERIOUS problems
            setattr( renpy.store, "save_name", "" )# and imho it's better for the user to see the original exception
            renpy.notify( "SGD-Error: renpy.store.save_name not existing! " )# instead me catching it and notify some guesses
        if not isinstance( renpy.store.save_name, mttkstrtyp ):#see up
            setattr( renpy.store, "save_name", "" )
            renpy.notify( "SGD-Error: renpy.store.save_name was NOT a string! " )
        setMttkVar( "strSNTemp", "save-game-description" )
        setMttkVar( "strSaveName", "save-game-description" )
        if not isinstance( getMttkVar( "intStoreSNConf" ), int ):#if this fails, someone ELSE fumbled with my var
            setMttkVar( "intStoreSNConf", 0 )
        if ( getMttkVar( "intStoreSNConf" ) < 0 or getMttkVar( "intStoreSNConf" ) > 2 ):
            setMttkVar( "intStoreSNConf", 0 )
        setMttkVar( "strStoreSName", getattr( renpy.store, "save_name", "" ) )#see up
        mttkModDefSSNonHelper()#for getMttkVar( "intStoreSNConf" ) == 2
        return

    def mttkModDefActionRunner( actID = "SyncDown" ):
        """
        only for personal use - unchecked, unsafe - not fit for anything

        not really needed, but I don't want the NEW Action-Class-Names in the screen
        actID's:
        SyncDown = DownloadSync()
        SyncUp = UploadSync()

        actID must be a string and one of up told values
        !!! NO response whatsoever !!! (besides running the action)
        """
        if not isinstance( actID, mttkstrtyp ):
            return
        if actID == "SyncDown":
            renpy.run( DownloadSync() )
        elif actID == "SyncUp":
            renpy.run( UploadSync() )
        return

    def mttkModDefActionsBefore( daI, daSlot ):#to be redefined in SavesSpecials
        return
    def mttkModDefActionsAfter( daI, daSlot ):#to be redefined in SavesSpecials
        return
    def mttkModDefMoreText( daI, daSlot ):#to be redefined in SavesSpecials
        return ""


    ## callback function save_json
    def mttkModDefSetSaveName( dicToJson ):
        """ only for personal use - unchecked, unsafe - not fit for anything """
        if not getMttkVar( "boolSaveNameActive" ):#function NOT being called from "me" (e.g. Quicksave()?)
            return
        setMttkVar( "boolSaveNameActive", False )
        mttk1Str = ""
        try:
            if mttkModIsList( dicToJson ):#PYsix: PY2="<type 'dict'>" ; PY3="<class 'dict'>"
                renpy.notify( "SGD-Error: passed \"json\" is NOT a dict ! " )
                return
            if not isinstance( getMttkVar( "strSaveName" ), mttkstrtyp ):
                renpy.notify( "SGD-Error: my persistent-var is NOT a string! saving an empty string to \"json\"! " )
            elif ( getMttkVar( "strSaveName" ) == "save-game-description" or getMttkVar( "strSaveName" ) == "SGD" ):
                pass
            else:
                mttk1Str = getMttkVar( "strSaveName" )
            dicToJson[ "_save_name" ] = mttk1Str
        except Exception as e:
            renpy.notify( mtkStr( "SGD-Exception at setting json:\n" + mtkStr( e ) ) )
        mttk1Str = None
        return


init 600 python hide:
    ## adding my callback function to config /// pot. errors lead to exceptions or may be silently "repaired"
    if not renpy.loadable( "zMttkModFolder/zMttkModSupport.rpyc" ):#all checks/repairs done there at init 100
        if not hasattr( renpy.config, "save_json_callbacks" ):##extra-safety, not checking for ver coz changelog says it came RenPy 6.16 ...else you deserve an exception
            renpy.config.save_json_callbacks = [ ]#(warning?) this then is a RevertableList
        elif mttkModIsList( renpy.config.save_json_callbacks ):#elif ( type( renpy.config.save_json_callbacks ) == mttkModTypePyList or isinstance( renpy.config.save_json_callbacks, list ) ):#PYsix: PY2="<type 'list'>" ; PY3="<class 'list'>"
            pass
        elif isinstance( renpy.config.save_json_callbacks, mttkstrtyp ):
            renpy.config.save_json_callbacks = [ renpy.config.save_json_callbacks ]#=RList
        else:
            renpy.config.save_json_callbacks = [ ]#=RList
    renpy.config.save_json_callbacks.append( mttkModDefSetSaveName )
    if not renpy.loadable( "zMttkModFolder/zMttkModSupport.rpyc" ):
        setattr( renpy.store, "whatsThisMttkMod", None )#as this is for the file(s) only...
        delattr( renpy.store, "whatsThisMttkMod" )
    ## 2 delete-button images
    try:
        mttkModFloatScaleNum = float( mttkModFloatScaleButtToOne )
        if mttkModFloatScaleNum < 1.5:
            mttkModFloatScaleNum = 4.2
        elif mttkModFloatScaleNum > 9.9:
            mttkModFloatScaleNum = 4.2
    except:
        mttkModFloatScaleNum = 4.2
    xTn = int( mttkModTupDisplayedThumbnailSize[ 0 ] )
    yTn = int( mttkModTupDisplayedThumbnailSize[ 1 ] )
    xButt = int( xTn // mttkModFloatScaleNum )
    yButt = int( yTn // mttkModFloatScaleNum )
    if xButt <= yButt:
        xyIco = xButt
    else:
        xyIco = yButt
    xiPos= int( ( xButt - xyIco ) // 2 )
    yiPos = int( ( yButt - xyIco ) // 2 )
    if mttkModIntRPYver < 69914:
        iTmp = int( xyIco // 12 )
        if iTmp < 1:
            iTmp = 1
        xyIcTx = int( xyIco - ( iTmp * 2 ) )
        xtPos = xiPos + ( iTmp * 3 ) - 1
        if xtPos < 0:
            xtPos = 0
        ytPos = yiPos - iTmp
        if ytPos < -2:
            ytPos = -2
        xTxtProps = { "size" : xyIcTx, "color" : "#f00f", "outlines" : [ ( 2, "#000f", 0, 0 ) ] }
        if "font" in mttkModDictPropsStdTxtFont:#faster than: if renpy.loadable( "DejaVuSans.ttf" ): (?)
            xTxtProps[ "font" ] = mttkModDictPropsStdTxtFont[ "font" ]#xTxtProps[ "font" ] = "DejaVuSans.ttf"
        renpy.image( "mttkModImgDelButtHover", LiveComposite(
            ( xButt, yButt ),
            ( 0, 0 ), Solid( "#fffc" ),
            ( xtPos, ytPos ), Text( "X", **xTxtProps ) ) )
        xTxtProps[ "color" ] = "#f00d"
        xTxtProps[ "outlines" ] = [ ( 2, "#0008", 0, 0 ) ]
        renpy.image( "mttkModImgDelButtIdle", LiveComposite(
            ( xButt, yButt ),
            ( 0, 0 ), Solid( "#fff6" ),
            ( xtPos, ytPos ), Text( "X", **xTxtProps ) ) )
    else:# Composite() is only available with 6.99.14.3 BUT im.Composite() before 6.99.14
        if xButt == yButt:
            xButt += 2
            yButt += 2
        elif xButt < yButt:
            xButt += 2
        else:
            yButt += 2
        mttkModByaNoIco1 = bytearray( source = ( 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,64,0,0,0,64,8,2,0,0,0,37,11,230,137,0,0,0,6,116,82,78,83,0,0,0,0,0,0,110,166,7,145,0,0,0,9,112,72,89,115,0,0,13,215,0,0,13,215,1,66,40,155,120,0,0,5,123,73,68,65,84,104,222,221,218,111,104,222,213,21,192,241,79,158,104,108,154,86,90,181,45,54,101,253,19,235,159,212,164,101,42,90,59,197,73,133,86,183,249,231,133,74,95,169,8,14,198,24,234,160,147,49,80,132,57,251,90,68,197,10,14,246,170,42,178,77,177,67,50,193,182,106,135,98,146,86,161,216,166,106,83,37,41,86,108,211,150,244,79,246,162,62,79,159,154,115,159,191,191,60,137,158,151,247,223,239,247,189,231,222,115,207,57,247,242,35,151,166,108,135,203,49,143,249,204,102,26,211,192,49,142,113,144,65,134,56,53,213,0,90,232,162,139,110,22,113,110,201,198,199,217,75,31,253,244,51,58,185,0,87,114,51,215,211,86,83,247,17,182,210,195 ) )
        mttkModByaNoIco2 = bytearray( source = ( 206,6,3,52,113,13,247,178,52,163,101,48,192,235,188,83,211,234,106,170,97,214,127,203,194,9,216,142,123,121,174,122,109,84,1,112,62,15,114,83,230,27,191,72,198,232,97,35,135,50,7,184,148,245,204,109,136,101,60,192,6,62,205,16,224,118,238,167,185,178,17,15,51,200,126,70,56,6,166,209,70,59,237,21,111,247,147,108,228,95,245,3,52,113,63,119,86,160,250,94,62,160,151,47,75,182,252,25,203,185,150,238,10,38,239,85,94,102,172,102,128,38,126,207,45,229,230,251,223,108,230,64,149,235,228,34,214,240,171,114,58,249,15,207,148,100,40,181,46,30,224,182,116,237,40,155,120,154,143,56,82,253,66,63,66,31,111,114,138,203,210,255,209,65,11,31,215,0,112,7,235,210,221,118,242,56,219,56,94,223,126,61,78,31,91,232,96,78,162,77,39,135,217,85,21,64,39,143,146,75,244,249,154,63,113,48,59,179,115,136,30,206,225,138,196,154,94,78,95,98,149,54,135,246,254,73,102,164,191,55,131,14,182,113,50,211,19,160,151,33 ) )
        mttkModByaNoIco3 = bytearray( source = ( 174,137,38,46,199,10,122,34,223,41,0,248,29,203,202,125,239,98,46,97,107,214,174,229,0,3,172,138,24,218,152,197,251,101,1,150,241,96,101,167,195,124,150,102,173,7,12,242,53,43,163,127,88,76,63,67,37,0,154,248,11,179,163,113,247,51,51,210,195,68,48,236,165,133,206,200,172,47,97,115,9,128,235,249,117,194,230,172,103,17,237,141,98,216,193,242,200,46,205,102,15,251,82,0,15,115,97,100,233,30,231,32,219,88,210,40,134,49,118,178,38,218,163,237,103,43,161,185,216,79,190,59,26,107,19,91,193,169,198,50,28,162,37,50,39,23,240,49,195,227,1,238,165,35,10,154,54,20,157,86,13,102,248,140,91,105,137,92,189,255,253,0,160,133,63,68,225,236,107,124,120,118,73,35,25,142,211,26,41,225,98,254,153,255,202,247,6,183,139,233,209,66,220,28,141,123,130,167,216,30,85,253,156,63,71,115,86,179,188,21,121,114,109,69,54,234,123,128,238,168,115,111,218,199,108,24,195,48,59,162,242,238,31,0,116,69,141,62,40,57 ) )
        mttkModByaNoIco4 = bytearray( source = ( 116,195,24,222,75,120,71,103,0,114,137,32,189,183,220,208,141,97,232,143,10,23,229,231,62,135,121,209,151,70,206,62,47,38,145,225,115,70,162,108,218,156,2,192,252,168,219,190,114,177,92,195,24,198,216,31,149,183,23,0,102,69,213,95,85,243,141,137,102,8,1,102,21,0,166,39,14,66,83,134,225,112,84,216,90,0,104,141,170,143,86,255,153,137,99,8,99,238,233,197,102,52,43,105,228,25,119,198,140,30,77,43,104,138,48,76,79,171,37,151,82,208,204,169,164,135,153,233,69,158,195,183,137,168,119,234,172,165,240,103,190,45,0,12,70,213,11,234,206,66,103,197,208,20,121,190,242,231,108,14,67,81,186,162,141,5,83,99,79,47,140,246,192,104,222,209,204,157,118,241,63,47,233,48,77,46,67,119,34,1,115,170,216,140,246,69,141,174,155,26,182,117,101,73,71,51,87,194,227,235,230,162,201,102,152,147,200,178,245,143,7,24,137,118,207,218,201,62,227,214,70,182,228,112,209,85,90,174,176,39,182,69,253,111,171,245,10,53,19,134 ) )
        mttkModByaNoIco5 = bytearray( source = ( 54,110,141,26,111,41,202,51,52,23,7,0,171,35,183,251,100,98,135,212,38,85,229,4,214,177,34,26,228,133,162,88,247,12,192,233,204,240,248,196,214,229,108,229,187,134,51,180,243,112,148,216,218,205,63,82,153,185,67,220,16,121,75,29,244,84,28,223,100,194,176,157,199,152,23,245,125,182,68,106,113,31,43,163,248,102,14,231,84,16,34,103,200,112,35,139,162,94,187,121,233,236,146,230,241,1,232,234,104,227,95,193,1,246,100,205,240,30,151,68,49,237,140,68,108,249,183,162,164,98,12,48,204,60,150,68,38,245,106,6,18,142,83,61,12,91,18,122,24,47,111,243,198,184,194,224,134,102,39,55,70,214,51,199,42,134,25,104,212,90,42,150,33,158,170,240,138,105,148,93,252,50,113,87,117,45,45,236,200,122,79,111,231,134,116,16,114,130,39,18,121,134,248,150,242,0,71,184,42,225,220,118,178,156,79,170,15,252,83,178,128,199,88,156,110,240,66,34,63,167,196,61,241,46,206,139,238,121,10,118,105,13,45,236,174,239,170,184,141,117 ) )
        mttkModByaNoIco6 = bytearray( source = ( 60,82,242,25,201,43,108,74,215,150,186,169,239,229,194,232,210,160,176,156,150,177,150,86,190,170,254,178,126,46,119,241,71,86,148,204,44,108,230,197,114,225,78,153,234,251,184,171,130,228,217,14,222,167,151,47,210,219,163,137,133,116,179,146,101,21,68,124,175,240,247,122,30,123,20,228,55,60,80,241,115,155,17,246,51,200,145,188,90,90,243,207,109,230,87,236,26,158,224,197,200,104,214,8,128,165,172,79,156,237,153,75,85,15,158,42,156,86,223,240,95,102,177,120,130,159,156,189,205,95,19,201,208,186,52,80,144,78,30,138,142,234,250,101,55,207,87,60,241,181,3,200,63,187,188,135,75,51,250,245,61,249,203,220,177,154,126,166,118,233,228,102,126,81,199,195,215,119,233,169,126,214,51,3,40,68,109,167,207,230,46,150,148,123,122,60,202,0,125,244,241,201,164,63,61,14,135,155,75,123,254,241,247,233,12,241,81,142,230,31,127,15,103,234,68,253,20,228,255,147,224,133,5,87,92,191,20,0,0,0,0,73,69,78,68,174,66,96,130 ) )
        mttkModMvbNoIco = memoryview( mttkModByaNoIco1 + mttkModByaNoIco2 + mttkModByaNoIco3 + mttkModByaNoIco4 + mttkModByaNoIco5 + mttkModByaNoIco6 ).tobytes()#PYsix: was a buffer()
        if mttkModIntRPYver < 70400:#im.* was called deprecated 7.4.0 !
            renpy.image( "mttkModImgDelButtHover", im.MatrixColor(
                im.Composite(
                    ( xButt, yButt ),
                    ( 0, 0 ), im.Scale( im.MatrixColor( im.MatrixColor( im.Data( mttkModMvbNoIco, "NO.PNG" ),
                        ( 1, 1, 1, 1, 1,
                          1, 1, 1, 1, 1,
                          1, 1, 1, 1, 1,
                          1, 1, 1, 1, 1 ) ), im.matrix.opacity( 0.6 ) ), xButt, yButt ),
                    ( xiPos, yiPos ), im.Scale( im.Data( mttkModMvbNoIco, "NO.PNG" ), xyIco, xyIco ) ),
                im.matrix.contrast( 0.8 ) ) )
            renpy.image( "mttkModImgDelButtIdle", im.MatrixColor(
                im.Composite(
                    ( xButt, yButt ),
                    ( 0, 0 ), im.Scale( im.MatrixColor( im.MatrixColor( im.Data( mttkModMvbNoIco, "NO.PNG" ),
                        ( 1, 1, 1, 1, 1,
                          1, 1, 1, 1, 1,
                          1, 1, 1, 1, 1,
                          1, 1, 1, 1, 1 ) ), im.matrix.opacity( 0.75 ) ), xButt, yButt ),
                    ( xiPos, yiPos ), im.Scale( im.Data( mttkModMvbNoIco, "NO.PNG" ), xyIco, xyIco ) ),
                im.matrix.contrast( 1.6 ) ) )
        else:
            if not getMttkVar( "boolSavesGL2mode" ):
                renpy.image( "mttkModImgDelButtIdle", Composite(
                    ( xButt, yButt ),
                    ( 0, 0 ), Solid( "fff3" ),
                    ( xiPos, yiPos ), Transform( im.Data( mttkModMvbNoIco, "NO.PNG" ), **{ "xsize" : xyIco, "ysize" : xyIco } ) ) )
                renpy.image( "mttkModImgDelButtHover", Composite(
                    ( xButt, yButt ),
                    ( 0, 0 ), Solid( "fff7" ),
                    ( xiPos, yiPos ), Transform( im.Data( mttkModMvbNoIco, "NO.PNG" ), **{ "xsize" : xyIco, "ysize" : xyIco } ) ) )
            else:
                renpy.config.gl2 = True
                renpy.preferences.gl_powersave = False##needed?
                renpy.image( "mttkModImgDelButtIdle", Composite(
                    ( xButt, yButt ),
                    ( 0, 0 ), Solid( "fff3" ),
                    ( xiPos, yiPos ), Transform( im.Data( mttkModMvbNoIco, "NO.PNG" ), **{ "xsize" : xyIco, "ysize" : xyIco,
                    "matrixcolor" : ContrastMatrix( 0.8 ) } ) ) )
                renpy.image( "mttkModImgDelButtHover", Composite(
                    ( xButt, yButt ),
                    ( 0, 0 ), Solid( "fff7" ),
                    ( xiPos, yiPos ), Transform( im.Data( mttkModMvbNoIco, "NO.PNG" ), **{ "xsize" : xyIco, "ysize" : xyIco,
                    "matrixcolor" : ContrastMatrix( 1.6 ) } ) ) )



##eof

