Delete Key Won't Remove Save Files?

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
Kshimimi
Newbie
Posts: 13
Joined: Mon Nov 09, 2015 7:29 am
Tumblr: kshimimishimesh.tumblr.com
Contact:

Delete Key Won't Remove Save Files?

#1 Post by Kshimimi »

My save code is a bit of a hodgepodge between imagebutton GUI interface and the standard save code that the project starts with, so I don't know if that's where the problem lies, but key "save_delete" action FileDelete(number) doesn't allow me to hover and hit the delete key to get rid of saves like it should? I'm not sure if i have the keybinding in the wrong section or what. Any help is appreciated!

Code: Select all

## ■██▓▒░ SAVE / LOAD SLOT ░▒▓██████████████████████████████■
## This represents a load/save slot. You should customize this to ensure that the placement of the thumbnail and the slot text are as desired. Positions (x1, y1, x2 and y2) are relative to the x, y parameters, that are passed when the screen is called. To set the screenshot thumbnail size see options.rpy.
init -2 python: #we initialize x and y, so the load_save_slot screen below works at startup
    x=0
    y=0
    
screen load_save_slot:
    $ file_text = "% 2s. %s\n%s" % (
        FileSlotName(number, 4),
        FileTime(number, empty=_("Empty Slot")),
        FileSaveName(number))
    $ save_name = FileSaveName(i)
    $x1=x+321
    $y1=y+10
    add FileScreenshot(number) xpos x1 ypos y1
    $x2=x+10
    $y2=y+11
    text file_text xpos x2 ypos y2 size 25
    key "save_delete" action FileDelete(number)
    
## ■██▓▒░ SAVE SCREEN ░▒▓███████████████████████████████████■
screen save:
    tag menu 
    # This ensures that any other menu screen is replaced.
    add "GUI/save base.png" # We add the file picker background image. This image is the same for save and load screens.
    use file_picker # We include the file_picker screen

## ■██▓▒░ LOAD SCREEN ░▒▓███████████████████████████████████■
screen load:
    tag menu # This ensures that any other menu screen is replaced.
    add "GUI/save base.png"
    use file_picker

## ■██▓▒░ FILE PICKER ░▒▓███████████████████████████████████■

## Since saving and loading are so similar, we combine them into a single screen, file_picker. We then use the file_picker screen from simple load and save screens.
screen file_picker:
    
    use navigation # We include the navigation/game menu screen
    # Buttons for selecting the save/load page:
    #imagebutton auto "GUI/filepage1_%s.png" xpos 46 ypos 104 focus_mask True action FilePage(1) 
    #imagebutton auto "GUI/filepage2_%s.png" xpos 46 ypos 228 focus_mask True action FilePage(2) 
    #imagebutton auto "GUI/filepage3_%s.png" xpos 46 ypos 353 focus_mask True action FilePage(3) 
    $ y=115 # ypos for the first save slot
    frame xpos 420 ypos 30:
        hbox:
            textbutton _("Previous"):
                action FilePagePrevious()
            
            textbutton _("Auto"):
                action FilePage("auto")
                
            textbutton _("Quick"):
                action FilePage("quick")
                
            for i in range(1, 17): # This repeats the block below 3 times (counts from 0 to 2), for the 3 save slots. We could also copy/paste the block below 3 times, but we are too lazy to do that.
                textbutton str(i):
                    action FilePage(i)
            
            textbutton _("Next"):
                action FilePageNext()

    #grid 2 5:    
        #transpose True
        
        #style_group "file_picker"
        
    for i in range(1, 6): # This repeats the block below 3 times (counts from 0 to 2), for the 3 save slots. We could also copy/paste the block below 3 times, but we are too lazy to do that.
        imagebutton auto "GUI/saveslot_%s.png" xpos 423 ypos y focus_mask True action FileAction(i)
        use load_save_slot(number=i, x=423, y=y) 
        $ y+=185 # We increase the y variable so every next save slot is moved 124px lower.
        
    $y=115
    for i in range(6, 11): # This repeats the block below 3 times (counts from 0 to 2), for the 3 save slots. We could also copy/paste the block below 3 times, but we are too lazy to do that.
        imagebutton auto "GUI/saveslot_%s.png" xpos 970 ypos y focus_mask True action FileAction(i)
        use load_save_slot(number=i, x=970, y=y) # This calls the load_save_slot screen defined above. We pass variable i as the slot number and x, y coordinates.
        $ y+=185 # We increase the y variable so every next save slot is moved 124px lower.

philat
Eileen-Class Veteran
Posts: 1909
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Delete Key Won't Remove Save Files?

#2 Post by philat »

Obviously can't test it myself, but based on the default screens, it seems like the key "save_delete" line should be in the imagebuttons in the file_picker, not in the load/save slot.

Code: Select all

    for i in range(1, 6): # This repeats the block below 3 times (counts from 0 to 2), for the 3 save slots. We could also copy/paste the block below 3 times, but we are too lazy to do that.
        imagebutton:
            auto "GUI/saveslot_%s.png" 
            xpos 423 
            ypos y 
            focus_mask True 
            action FileAction(i)
            key "save_delete" action FileDelete(number)
        use load_save_slot(number=i, x=423, y=y) 
        $ y+=185 # We increase the y variable so every next save slot is moved 124px lower.


Kshimimi
Newbie
Posts: 13
Joined: Mon Nov 09, 2015 7:29 am
Tumblr: kshimimishimesh.tumblr.com
Contact:

Re: Delete Key Won't Remove Save Files?

#3 Post by Kshimimi »

Just got around to testing it, and it seems that imagebuttons won't take a key statement, so that bit of code doesn't work

Valiowk
Newbie
Posts: 22
Joined: Sat Jan 02, 2016 8:32 pm
Contact:

Re: Delete Key Won't Remove Save Files?

#4 Post by Valiowk »

Upping this thread as I thought of the same approach as philat, then discovered like Kshimimi that imagebuttons do not take a key statement. Is there a way to make the save_delete key work with an imagebutton save GUI?

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Delete Key Won't Remove Save Files?

#5 Post by PyTom »

That's probably a bug. I'll take a look at it and see if I can fix it.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
3dmasons
Newbie
Posts: 16
Joined: Mon Aug 01, 2016 6:42 pm
Skype: digitalmasons
Location: Maryland
Contact:

Re: Delete Key Won't Remove Save Files?

#6 Post by 3dmasons »

Setting a "key" to an "imagebutton" still doesn't seem to work, throws an error stating "u'key' is not a keyword argument or valid child for the imagebutton statement." Am I doing something wrong? My code is similar to the second reply of this topic and is for the file picker as well.

Code: Select all

imagebutton
    auto "IMAGE.png"
    action FileAction(i)
    focus_mask None
    key "save_delete" action FileDelete(i)
Any help would be appreciated.

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Delete Key Won't Remove Save Files?

#7 Post by PyTom »

At this point, there isn't a good way to do it. One workaround would be to use a regular button:

Code: Select all

button:
    xysize (100, 200)
    background "[prefix_]image.png"
    action FileAction(i)
    focus_mask None
    key "save_delete" action FileDelete(i)
This assumes 6.99.11.

I'll try to fix this at some point, but it's actually hard, due to the way imagebuttons work.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
3dmasons
Newbie
Posts: 16
Joined: Mon Aug 01, 2016 6:42 pm
Skype: digitalmasons
Location: Maryland
Contact:

Re: Delete Key Won't Remove Save Files?

#8 Post by 3dmasons »

I started doing that previously but I failed at learning how to get the "auto" working for buttons like imagebuttons for the "_idle," "_hover", "_selected_idle," etc., working. At least how to get hover working? Sorry, I am indeed a Ren'Py newbie.

Thank you for your reply, PyTom.

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Delete Key Won't Remove Save Files?

#9 Post by gas »

3dmasons wrote:I started doing that previously but I failed at learning how to get the "auto" working for buttons like imagebuttons for the "_idle," "_hover", "_selected_idle," etc., working. At least how to get hover working? Sorry, I am indeed a Ren'Py newbie.

Thank you for your reply, PyTom.
auto
Used to automatically define the images used by this button. This should be a string that contains %s in it. If it is, and one of the image properties is omitted, %s is replaced with the name of that property, and the value is used as the default for that property.

For example, in your given case, you can do something like:

imagebutton auto "mybutton_%s.png" action ShowMenu('save')

THEN in the image folder, create mybutton_idle.png, mybutton_hover.png, and so on.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
3dmasons
Newbie
Posts: 16
Joined: Mon Aug 01, 2016 6:42 pm
Skype: digitalmasons
Location: Maryland
Contact:

Re: Delete Key Won't Remove Save Files?

#10 Post by 3dmasons »

Thank you, gas and PyTom. Once I saw gas' reply, then read PyTom's reply again, I realized what I'm wanting to do is:

Code: Select all

background "image.png"
hover_background "hover.png"
Within the button code and I should be able to keep the input key bind to the button.

Thanks again.

Post Reply

Who is online

Users browsing this forum: Google [Bot]