I tried to look this up for you but I don't know where in the Renpy to see the save game code. The best I can up with is this page:Anyone can explain what to do in order to name the saves when saving in renpy games? If its not to complicated
I don't think it's what he talk about. save_name is for the physical name of the file, while OP probably think more of the logical name like in DmD.The best I can up with is this page:You must be registered to see the links. 'save_name = ' is what is used to name the save, as far as I can tell, but I don't know where to put it.
It's probably in "screens.rpy", file_slots screen.If you know what part of the RenPy code deals with save you can look at the game Dating my Daughter's code, I know that game allows you to name a save, and copy it.
Alright, so it was my "I am an idiot" day. You were right, "save_name" is what he was looking for. The documentation say about it that it's "one variable that is used by the high-level save system", and that's all my brain stored, making me wrongly remember it as the physical name.Code:init python: def name_func(newstring): store.save_name = newstring
hbox:
area (15, -15, 300, 140)
text FileSaveName(slot):
style "slot_name_text"
size 21
yalign 0.5
screen file_slots(title):
default page_name_value = FilePageNameInputValue(pattern=_("Page {}"), auto=_("Automatic saves"), quick=_("Quick saves"))
use game_menu(title):
fixed:
## This ensures the input will get the enter event before any of the
## buttons do.
order_reverse True
## The page name, which can be edited by clicking on a button.
button:
style "page_label"
key_events True
xalign 0.995
xoffset 60
yalign 0.025
action page_name_value.Toggle()
input:
style "page_label_text"
value page_name_value
## The grid of file slots.
grid 5 2:
style_prefix "slot"
xalign 0.5
yalign 0.375
spacing 12
for i in range(1, 11):
$ slot = i
button:
# the line below is the relevant code for adding a save description.
# it Replaces action FileAction(slot)
action If(renpy.get_screen("save"), true=Show("save_name_modal", accept=FileSave(i)), false=FileLoad(i))
has vbox
$ file_name = FileSlotName(i, 11)
$ file_time = FileTime(i, empty=_("Empty Slot."))
$ save_name = FileSaveName(i)
text FileTime(slot, format=_("{#file_time}%A, %B %d %Y, %H:%M"), empty=_("empty slot")):
style "slot_time_text"
xalign 0.5
yoffset 2
xoffset 24
add FileScreenshot(slot) xoffset 24 yoffset 11
# I like to have delete buttons on my load/save pages, for those people that might be using a touchscreen. As usual, you can also delete by hovering over the save slot and hitting the 'del' key. This 'if' check to see if the file slot is not empty, and if so, adds a delete button, which I've manually positioned. Ignore the next two lines if you have no need for having delete buttons on your save screen.
if FileTime(slot) != "":
imagebutton auto "gui/button/sv_delete_%s.png" action FileDelete(i) xpos 163 ypos 175
# And here is where the text you enter in the save game description popup is displayed. I've included the File Save Name in it's own hbox, so that I can control the positioning and width of the text entry. I placed this last inside of the button so that it wouldn't mess up the other alignments, but I just changed it to area so that may or may not have have fixed that issue...
hbox:
area (15, -15, 300, 140)
text FileSaveName(slot):
style "slot_name_text"
size 21
yalign 0.5
key "save_delete" action FileDelete(slot)
## Buttons to access other pages.
hbox:
style_prefix "page"
xalign 0.5
yalign 0.025
spacing gui.page_spacing
textbutton _("<") action FilePagePrevious()
if config.has_autosave:
textbutton _("{#auto_page}A") action FilePage("auto")
if config.has_quicksave:
textbutton _("{#quick_page}Q") action FilePage("quick")
## range(1, 10) gives the numbers from 1 to 9.
for page in range(1, 10):
textbutton "[page]" action FilePage(page)
textbutton _(">") action FilePageNext()
style page_label is gui_label
style page_label_text is gui_label_text
style page_button is gui_button
style page_button_text is gui_button_text
style slot_button is gui_button
style slot_button_text is gui_button_text
style slot_time_text is slot_button_text
style slot_name_text is slot_button_text
style page_label:
xpadding 75
ypadding 5
style page_label_text:
text_align 0.5
layout "subtitle"
hover_color gui.hover_color
style page_button:
properties gui.button_properties("page_button")
style page_button_text:
properties gui.button_text_properties("page_button")
style slot_button:
properties gui.button_properties("slot_button")
style slot_button_text:
properties gui.button_text_properties("slot_button")
# And here is the screen that pops up asking to name your save:
screen save_name_modal(accept=NullAction()):
modal True
add Solid("#8f72f2") alpha 0.8
style_prefix "save_name_modal"
frame:
xpadding 6
ypadding 6
has vbox:
xalign 0.5
spacing 20
label _("Please name your save: \n Max 120 characters"):
text_color "#09f"
xalign 0.5
null height 10
input size 40 color "#09f" default store.save_name changed set_save_name length 120 allow "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789?!,. -/*":
yalign 1.0
xalign 0.5
xysize (550, 40)
textbutton _("Save game"):
xalign 0.5
action [accept, Hide("save_name_modal")]
key "game_menu" action Hide("save_name_modal")
Nowadays games mostly rely on a less intrusive, and therefore less annoying, approach than a popup window:And, for the popup window that asks for a save name descrption,
screen file_slots(title):
default page_name_value = FilePageNameInputValue(pattern=_("Page {}"), auto=_("Automatic saves"), quick=_("Quick saves"))
use game_menu(title):
fixed:
[...]
input:
style "page_label_text"
value page_name_value
# <----
if title == "Save":
hbox:
text "Name : "
button:
key_events True
action VariableInputValue( "save_name" ).Toggle()
input:
value VariableInputValue('save_name')
length 120
allow "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789?!,. -/*":
#style whateverYouWant
# ---->
## The grid of file slots.
grid 5 2:
style_prefix "slot"
[...]
Since you talk about an "edit button", I guess that you want to rename an already saved file.Making the edit button is easy enough (see delete button), but I cant figure out how to change the value of FileSaveName(slot) once it's been set during the save function. Does anyone have any ideas on how to edit this variable once it's been set?
the value for FileSaveName is set ingame, and asking a user to have to exit the game and go through all of those steps just to edit the description is a VERY obtrusive and unreasonable approach. At that point, I'd just tell them to load the save, then save to the same slot (i.e. overwrite it), and re-type the save description however they want.Nowadays games mostly rely on a less intrusive, and therefore less annoying, approach than a popup window:
Python:screen file_slots(title): default page_name_value = FilePageNameInputValue(pattern=_("Page {}"), auto=_("Automatic saves"), quick=_("Quick saves")) use game_menu(title): fixed: [...] input: style "page_label_text" value page_name_value # <---- if title == "Save": hbox: text "Name : " input: value VariableInputValue('save_name') length 120 allow "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789?!,. -/*": #style whateverYouWant # ----> ## The grid of file slots. grid 5 2: style_prefix "slot" [...]
Since you talk about an "edit button", I guess that you want to rename an already saved file.
Well, for this you need to:
- Open the zip file that contain this save ;
- Edit the "json." file inside it ;
- Change the value of its "_save_name" field ;
- Save the updated "json." file in place of the old one inside the zip.
The value is extracted in real time from the json file stored inside the zip save file, period.the value for FileSaveName is set ingame,
def FileSaveName(name, empty="", page=None, slot=False):
return FileJson(name, "_save_name", empty=empty, missing=empty, page=page, slot=slot)
def FileJson(name, key=None, empty=None, missing=None, page=None, slot=False):
json = renpy.slot_json(__slotname(name, page, slot))
if json is None:
return empty
if key is None:
return json
return json.get(key, missing)
def slot_json(slotname):
return get_cache(slotname).get_json()
# A map from slotname to cache object. This is used to cache savegame scan
# data until the slot changes.
cache = { }
def get_cache(slotname):
rv = cache.get(slotname, None)
if rv is None:
rv = cache[slotname] = Cache(slotname)
return rv
Who ask the user to do this ? I explicitly wrote "you need to", this is obviously something that you have to code yourself. It need a dozen of lines, not really more.and asking a user to have to exit the game and go through all of those steps just to edit the description is a VERY obtrusive and unreasonable approach.
What you like is one thing, what you can is another.That's still more steps than I'd like to see though.
So, that process could involve... exactly what I wrote. Cool, this mean that you'll implement it then.That process could involve loading the save info in the background and then re-saving it [...]
Thanks for this code!Nowadays games mostly rely on a less intrusive, and therefore less annoying, approach than a popup window:
Python:screen file_slots(title): default page_name_value = FilePageNameInputValue(pattern=_("Page {}"), auto=_("Automatic saves"), quick=_("Quick saves")) use game_menu(title): fixed: [...] input: style "page_label_text" value page_name_value # <---- if title == "Save": hbox: text "Name : " input: value VariableInputValue('save_name') length 120 allow "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789?!,. -/*": #style whateverYouWant # ----> ## The grid of file slots. grid 5 2: style_prefix "slot" [...]
Since you talk about an "edit button", I guess that you want to rename an already saved file.
Well, for this you need to:
- Open the zip file that contain this save ;
- Edit the "json." file inside it ;
- Change the value of its "_save_name" field ;
- Save the updated "json." file in place of the old one inside the zip.
a small tip, wrap save name input into a button. because without the button, RenPy acts dumb when there's more than one input and if you decide to change the page name, you have to close the screen and open it again to move focus back into save name inputNowadays games mostly rely on a less intrusive, and therefore less annoying, approach than a popup window:
Python:screen file_slots(title): use game_menu(title): fixed: [...] input: style "page_label_text" value page_name_value # <---- if title == "Save": hbox: text "Name : " input: value VariableInputValue('save_name') length 120 allow "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789?!,. -/*": #style whateverYouWant [...]
button:
key_events True
xalign 0.5
yalign 0.0
action VariableInputValue('save_name').Toggle()
frame:
xminimum 256
yminimum 38
xmaximum 385
input:
xoffset 5
size 23
default "[save_name]"
value VariableInputValue('save_name')
length 30
Nice catch, haven't though about this issue since I usually use a modified version of the "input".a small tip, wrap save name input into a button.