I'm trying to improve my save menu. Actually, when you choose a slot, it saves your game with 50 characters of the dialogs in game.
I'm trying to put an input field that provide you to choose the name of your save. (by default, it'll be 50 characters of the dialogs in game)
This is my save menu without any input (works fine but weird code i know )
Code: Select all
init python:
config.thumbnail_width = 100
config.thumbnail_height = 75
screen save():
tag menu
key "s" action Return()
default mouse_clicked = False
if int(persistent._file_page) == 1:
add "image/ui/saveload/s_back30.png"
fixed at KeymapTransform([('mousedown_1', SetScreenVariable('mouse_clicked', True)), ('mouseup_1', SetScreenVariable('mouse_clicked', False))]):
imagebutton idle "image/ui/saveload/nextbutton_idle.png" hover("image/ui/saveload/nextbutton_clicked.png" if mouse_clicked else "image/ui/saveload/nextbutton_hover.png") xpos 738 ypos 535 focus_mask None action FilePage(2)
else:
add "image/ui/saveload/s_back60.png"
fixed at KeymapTransform([('mousedown_1', SetScreenVariable('mouse_clicked', True)), ('mouseup_1', SetScreenVariable('mouse_clicked', False))]):
imagebutton idle "image/ui/saveload/backbutton_idle.png" hover("image/ui/saveload/backbutton_clicked.png" if mouse_clicked else "image/ui/saveload/backbutton_hover.png") xpos 738 ypos 535 focus_mask None action FilePage(1)
imagebutton auto "image/ui/saveload/exit_%s.png" xpos 620 ypos 520 focus_mask None action Return()
default tt = Tooltip((Null(), "", "", "", Null()))
$ borderblack = "image/ui/saveload/borderblack.png"
hbox:
xysize (600, 550)
pos (30, 30)
spacing 0
box_wrap True
if int(persistent._file_page) == 1:
$ page_sl1 = 1
$ page_sl2 = 31
else:
$ page_sl1 = 31
$ page_sl2 = 61
for i in range(page_sl1, page_sl2):
# Each file slot is a button.
$ file_name = FileSlotName(i, 30)
$ file_time = FileTime(i, format='%d/%m/%Y %H:%M')
$ slot_foot = str(i)
if len(slot_foot) < 3:
$ slot_foot = '0' + slot_foot
if len(slot_foot) < 3:
$ slot_foot = '0' + slot_foot
$ slot_foot = "No." + slot_foot
$ save_name = FileSaveName(i)
vbox:
spacing 0
button:
left_padding 2
right_padding 2
top_padding 2
bottom_padding 2
left_margin 0
right_margin 0
top_margin 0
bottom_margin 0
xysize (104, 79)
background None
hover_background "image/ui/saveload/borderred.png"
action [SetVariable("save_name",_last_say_what[:50]), FileAction(i)]
hovered tt.Action((FileScreenshot(i), slot_foot, file_time, save_name, borderblack))
xfill True
add FileScreenshot(i)
key "save_delete" action FileDelete(i)
key "K_BACKSPACE" action FileDelete(i)
null height 11 width 106
add tt.value[0] xpos 625 ypos 155
add tt.value[4] xpos 625 ypos 155
vbox:
xsize 150
pos (600, 175)
text tt.value[1] ypos 80 size 15
text tt.value[2] ypos 80 size 15
text tt.value[3] xpos 5 ypos 83 size 12
For the input i just add this before :
Code: Select all
screen modal_input:
modal True
window style "input_window":
has vbox
text prompt style "input_prompt"
input id "input" style "input_text" default default
init -2 python:
class get_save_name(FileSave):
def __init__(self, name, confirm=False, newest=True, page=None, cycle=False):
super(get_save_name,self).__init__(name=name,confirm=confirm,newest=newest,page=page,cycle=cycle)
def __call__(self):
renpy.call_in_new_context("get_save_name")
return super(get_save_name,self).__call__()
label get_save_name:
show screen save
$ save_nameinput = renpy.call_screen("modal_input", prompt="Enter save name", default=save_nameinput, length=20)
$ renpy.retain_after_load()
return
Code: Select all
action [SetVariable("save_name",_last_say_what[:50]), FileAction(i)]
Code: Select all
action [get_save_name(i), FileAction(i)]
It works, but there's some bug...
1) It shows the Yes/No prompt with "Are you sure you want to overwrite this save ?" anytime i pick a slot... And it doesn't care if i hit the "Yes" or the "No" button . So, how to disable this prompt just in that case you picked an empty slot ?
2) As i said, i'm trying to put the dialogs in game by default. But i can't call $ save_name = FileSaveName(i) for default=save_nameinput cause it's not in the same screen...
It's just 2 little problems but i can't solve them... Thank you so much in advance !