• Search is back up, but the index is being rebuilt, there may still be some minor problems until this is complete.

Ren'Py Can anyone "fix" this Save/load game system to not popup a box before saving?

Avalonica

Newbie
Oct 11, 2017
40
20
Hello, this great save/load system with a delete function is very nice, but the "forced" popup box as one is "saving the game" is irritating. Can anyone of you who is a master on coding disable the "save box" that ask for description of the savegame so the system will work as the "vanilla" save-game system i.e. one-click on a savebox and it's saved with no questions asked.

PHP:
################################################################################
# RUN - New Save/Load game system with delete key
################################################################################
screen load():
    tag menu
    use slots(_('Load'), _('Select a slot from above to {b}load{/b} a previous game.'))



screen save():
    tag menu
    use slots(_('Save in'), _('Select a slot from above to {b}save{/b} the current game.'))



screen slots(title, tip):
    use common_menu():
        style_prefix 'slots'

        vbox:

            textbutton _('Back') action Return()

            hbox:
                style_prefix 'pages'
                textbutton _('Previous{#page}') action FilePagePrevious()
                if config.has_autosave or config.has_quicksave:
                    hbox:
                        style_prefix 'pages_group'
                        if config.has_autosave:
                            textbutton _("A{#auto_page}") action FilePage("auto")
                        if config.has_quicksave:
                            textbutton _("Q{#quick_page}") action FilePage("quick")
                hbox:
                    style_prefix 'pages_group'
                    $ lower = max(1, int(FilePageName(0, 0)) - 2)
                    for page in xrange(lower, lower + 5):
                        textbutton str(page).zfill(2) action FilePage(page)
                textbutton _('Next{#page}') action FilePageNext()

            grid 3 2:
                style_prefix 'slot'

                for slot in xrange(1, 7):
                    $ action = FileAction(slot)
                    $ name = '{}-{}. {}'.format(FileCurrentPage(), slot, FileTime(
                    slot, format=_("{#file_time}%B %d, %H:%M"),
                    empty=_('{i}empty slot{/i}')))
                    $ shot = FileScreenshot(slot)

                    vbox:
                        text name
                        null height 5

                        frame:
                            has button:
                                action If(isinstance(action, FileSave),
                                      Show('slots_note', None, slot), action)
                                alt '{} {}'.format(title, name)
                                background shot
                                if isinstance(shot, im.ImageBase):
                                    hover_background HoverImage(shot)
                                tooltip FileSaveName(slot)

                            if FileLoadable(slot):
                                imagebutton:
                                    action FileDelete(slot)
                                    alt _('Delete {}').format(name)
                                    hover 'delete_btn_over'
                                    idle 'delete_btn_idle'
                                    tooltip FileSaveName(slot)
                                key 'save_delete' action FileDelete(slot)

            fixed:
                text tip
                label GetTooltip() or ''


screen slots_note(slot):
    modal True

# Grr, it always ask this when saving the game :(
    default note = 'Enter description'



    frame:
        style_prefix 'slot_prompt'

        has vbox

        label _('Enter a note to help recognise this save:')

        frame:
            style_prefix 'text_input'
            input:
                allow ('abcdefghijklmnopqrstuvwxyz'
                       'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
                       '0123456789 -_!()@:;?<>,.#/')
                length 32
                value ScreenVariableInputValue('note')

        hbox:
            button:
                action (SetField(store, 'save_name', note.strip()),
                        FileSave(slot, confirm=False),
                        SetField(store, 'save_name', ''),
                        Hide('slots_note'))
                keysym 'input_enter'
                selected False
                sensitive note.strip()

                if FileLoadable(slot):
                    style_suffix 'warn_button'
                    text _('Overwrite') style_suffix 'warn_button_text'
                else:
                    text _('OK') style_suffix 'button_text'

            textbutton _('Cancel'):
                action Hide('slots_note')
                keysym 'game_menu'


style pages_button is menu_button:

    xsize 150

style pages_button_text is menu_button_text


style pages_group_button is menu_button:

    xsize 60

style pages_group_button_text is menu_button_text


style pages_group_hbox is menu_hbox:

    align (.5, .5)
    spacing 10

style pages_hbox is menu_hbox:

    spacing 30
    xalign .5

style slot_button:
    xysize (config.thumbnail_width, config.thumbnail_height)

style slot_frame:
    background 'menu_frame'
    padding (4, 4, 4, 4)

style slot_grid:
    align (.5, .5)
    spacing 30

style slot_image_button:
    align (1., 0.)
    offset (-2, 2)

style slot_prompt_button is menu_button:

    xysize (150, 50)

style slot_prompt_button_text is menu_button_text:

    size 14

style slot_prompt_frame is menu_frame:

    align (.5, .5)
    background 'menu_frame_opaque'
    fit_first True
    padding (25, 35, 25, 25)
    xmaximum 650

style slot_prompt_hbox:
    spacing 50
    xalign .5

style slot_prompt_label:
    xalign .5

style slot_prompt_vbox:
    spacing 20

style slot_prompt_warn_button take slot_prompt_button


style slot_prompt_warn_button_text take slot_prompt_button_text


style slots_button is menu_button


style slots_button_text is menu_button_text


style slots_fixed:
    fit_first True
    xalign .5

style slots_label:
    xalign .5
    yoffset 25

style slots_label_text:
    bold True

style slots_text:
    color '8b94aa'

style slots_vbox:
    align (.5, .5)
    spacing 30
################################################################################
# END - New Save/Load game system with delete key
################################################################################
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
I can't begin to tell you how bad I am at screens...
But try this:

Under screen slots(title, tip): there is a grid 3 2 section. Within that is a vbox:. That in turn has a frame.

Try replacing:

Python:
                        frame:
                            has button:
                                action If(isinstance(action, FileSave),
                                      Show('slots_note', None, slot), action)
                                alt '{} {}'.format(title, name)
                                background shot
                                if isinstance(shot, im.ImageBase):
                                    hover_background HoverImage(shot)
                                tooltip FileSaveName(slot)

With...
Python:
                        frame:
                            has button:
                                # action If(isinstance(action, FileSave),
                                #       Show('slots_note', None, slot), action)

                                action (SetField(store, 'save_name', '',
                                    FileSave(slot, confirm=False),
                                    SetField(store, 'save_name', ''))

                                alt '{} {}'.format(title, name)
                                background shot
                                if isinstance(shot, im.ImageBase):
                                    hover_background HoverImage(shot)
                                tooltip FileSaveName(slot)

In effect, commenting out the lines of code which popup the box which adds a note to the save slot.
Then borrowing a couple of lines from the screen slots_note(slot): that appear to do the actual save.
"Normal" save screens tend to save the date/time and a note as part of the save file. Often the note is never used. I'm still checking... but this may not be setting the date/time.

It may not be that simple. It's possible that removing that line somehow breaks something else. But I can't see anything within screen slots_note(slot): that would be missed if it were bypassed. (I refer you back to the first line of post).

All I can suggest is try it and see what happens.
I haven't tested this change.
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,355
15,268
Can anyone of you who is a master on coding disable the "save box" that ask for description of the savegame so the system will work as the "vanilla" save-game system i.e. one-click on a savebox and it's saved with no questions asked.
Er... It is not how the vanilla system works, it ask for confirmation if the slot is already used. And not having this confirmation is what I, personally, found really annoying.
But I also understand that badly handled prompt for the name of the save can be a real pain in the ass.


Python:
                                # action If(isinstance(action, FileSave),
                                #       Show('slots_note', None, slot), action)

                                action (SetField(store, 'save_name', '',
                                    FileSave(slot, confirm=False),
                                    SetField(store, 'save_name', ''))
I haven't looked really attentively to the code, but I'm not sure at all that it would works like this.
Don't know, it feel odd since the commented part handle both save and load, while your fix will always save and never load.

A better fix seem to be this :
Python:
                                # action If(isinstance(action, FileSave),
                                #       Show('slots_note', None, slot), action)
                                action FileAction( slot )
FileAction will automatically call either FileSave or FileLoad, depending to the actual context.
And to get totally ride of the confirmation box, it should be action FileAction( slot, confirm=False ).
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
Yeah. I think I'd be tempted to leave confirm=True since as far as I'm aware the the confirmation box only appears when the save will overwrite another existing save file.

As for FileAction (slot), you're undoubtedly right it's a better option. I did look at the vanilla save code in other games - but then decided that since this script already used FileSave, it might be safer to just leave it doing that. If I'm honest, I didn't do much except look at the logic where "notes" were specifically mentioned - the rest I ignored.

I don't doubt that this is cut and paste code that could be better written. I'm sure Avalonica is much like me in so much as we only dare touch that which we recognize... and we recognize so little. Plus people rarely cut and paste code from the original author.. it's usually from some game or other written by another person who just cut and paste the code from somewhere else. I doubt that even if we could get this code to be the perfect version of itself that we could put it anywhere that future others would use the "better" version rather than the version they find in some other random game. (And by "we", I mean you obviously :whistle:).

All of which is a bit off-topic.
Avalonica ... good luck :)
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,355
15,268
[...] and we recognize so little.
I can assure you that the 79flavors who asked questions months ago is far away behind who you now are. You've a good knowledge and, probably more important, you've a better understanding of the logic used by Ren'py.