Code: Select all
#the source code of save/load archive (part)
## The grid of file slots.
grid gui.file_slot_cols gui.file_slot_rows:
style_prefix "slot"
xalign 0.5
yalign 0.5
spacing gui.slot_spacing
for i in range(gui.file_slot_cols * gui.file_slot_rows):
$ slot = i + 1
button:
action FileAction(slot)
has vbox
add FileScreenshot(slot) xalign 0.5
text FileTime(slot, format=_("{#file_time}%A, %B %d %Y, %H:%M"), empty=_("empty slot")):
style "slot_time_text"
text FileSaveName(slot):
style "slot_name_text"
key "save_delete" action FileDelete(slot)
I want to save some data when i go to archive!(the data and the archive are one-to-one correspondence)
of course ,when I want to load the archive, I would like to load the data corresponding to this archive。
So, I need the name of archive,then let the name be the key of my data
I defined an customFileAction method instead of the FileAction method
Code: Select all
# 存档读档 获取id
def coustomFileAction(name, page=None, **kwargs):
saveCustomAttributes(name)
return FileAction(name,page,**kwargs)
def saveCustomAttributes(name):
# do something with name
#slot_current_page = FileCurrentPage()
layout.yesno_screen("-------- " + str(name), None,None)
But, The question:
When I launch the game, the coustomFileAction method is called immediately
Why ??