WTS/game/scripts/gui/save_files.rpy

273 lines
9.8 KiB
Plaintext
Raw Normal View History

2022-05-16 23:48:22 +00:00
#
# Load/save screens
#
# These screens are responsible for letting the player save the game and load
# it again. Since they share nearly everything in common, both are implemented
# in terms of a third screen, file_slots.
#
# https://www.renpy.org/doc/html/screen_special.html#save
# https://www.renpy.org/doc/html/screen_special.html#load
init offset = -1
screen save():
use file_slots(_("Save"))
screen load():
use file_slots(_("Load"))
screen file_slots(title):
default page_name = FilePageNameInputValue(pattern=_("Page {}"), auto=_("Auto Saves"), quick=_("Quick Saves"))
default time_format = "{#file_time}%#d %B, %Y, %#H:%M" if renpy.windows else "{#file_time}%-d %B, %Y, %-H:%M"
2022-05-16 23:48:22 +00:00
frame style "navigation_page_left":
vbox:
2022-05-16 23:48:22 +00:00
button:
style "navigation_label"
2022-05-16 23:48:22 +00:00
action page_name.Toggle()
input:
style "navigation_label_text"
value page_name
grid 2 3:
for i in range(1, 7):
vbox style "file_vbox":
text "[i]." offset (-10, 16) size 16
text FileTime(i, format=time_format) size 10 xalign 0.5
button:
style "navigation_picture_button"
xysize (135, 75)
if FileLoadable(i):
add FileScreenshot(i) xysize (135, 75)
else:
add "#ffffff80" xysize (135, 75)
if not FileCompatible(i) and title == "Load":
action Confirm(gui.SAVE_INCOMPATIBLE_WARNING, FileAction(i))
else:
action FileAction(i)
textbutton "{unicode}✘{/unicode}" action FileDelete(i) xalign 1.0 style "file_delete"
if FileLoadable(i):
$ playtime = FileJson(i, "playtime", missing=0)
$ minutes, seconds = divmod(int(playtime), 60)
$ hours, minutes = divmod(minutes, 60)
text f"Playtime: {hours}H {minutes}M {seconds}S" size 10 xalign 0.5 yoffset 4
frame style "navigation_page_right":
vbox:
null height 38
# button:
# style "navigation_label"
# action page_name.Toggle()
# input:
# style "navigation_label_text"
# value page_name
grid 2 3:
for i in range(7, 13):
vbox style "file_vbox":
text "[i]." offset (-10, 16) size 16
text FileTime(i, format=time_format) size 10 xalign 0.5
button:
style "navigation_picture_button"
xysize (135, 75)
if FileLoadable(i):
add FileScreenshot(i) xysize (135, 75)
else:
add "#ffffff80" xysize (135, 75)
if not FileCompatible(i) and title == "Load":
action Confirm(gui.SAVE_INCOMPATIBLE_WARNING, FileAction(i))
else:
action FileAction(i)
textbutton "{unicode}✘{/unicode}" action FileDelete(i) xalign 1.0 style "file_delete"
if FileLoadable(i):
$ playtime = FileJson(i, "playtime", missing=0)
$ minutes, seconds = divmod(int(playtime), 60)
$ hours, minutes = divmod(minutes, 60)
text f"Playtime: {hours}H {minutes}M {seconds}S" size 10 xalign 0.5 yoffset 4
style file_delete
style file_delete_text:
color "#ffffff"
style file_vbox is empty:
fit_first True
xfill False
yfill False
xsize 135
spacing 0
pos (4, -16)
# 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 gui.theme("page_label")
# key_events True
# xalign 0.5
# action page_name.Toggle()
# hbox:
# spacing 9
# input:
# style gui.theme("page_label_text")
# value page_name
# if page_name.editable:
# text "{size=-4}{font=[gui.glyph_font]}✎{/font}{/size}"
# ## The grid of file slots.
# grid gui.file_slot_cols gui.file_slot_rows:
# style_prefix gui.theme("slot")
# xalign 0.5
# yalign 0.5
# spacing gui.slot_spacing
# transpose True
# for i in range(gui.file_slot_cols * gui.file_slot_rows):
# $ slot = i + 1
# button:
# if not FileCompatible(slot) and title == "Load":
# action Confirm(gui.SAVE_INCOMPATIBLE_WARNING, FileAction(slot))
# else:
# action FileAction(slot)
# has fixed
# if FileLoadable(slot):
# add FileScreenshot(slot)
2022-05-16 23:48:22 +00:00
# vbox:
# style_prefix "slot_button"
# xpos config.thumbnail_width
# xsize gui.slot_width - config.thumbnail_width - gui.slot_height
# yalign 0.5
2022-05-16 23:48:22 +00:00
# if FileCompatible(slot):
# default slot_time_format = "{#file_time}%#d %B, %Y, %#H:%M" if renpy.windows else "{#file_time}%-d %B, %Y, %-H:%M"
# $ day = FileJson(slot, "day", missing="Unknown")
# $ playtime = FileJson(slot, "playtime", missing=0)
# $ minutes, seconds = divmod(int(playtime), 60)
# $ hours, minutes = divmod(minutes, 60)
2022-05-16 23:48:22 +00:00
# text FileTime(slot, format=slot_time_format)
# text f"Day: {day}"
# text f"Playtime: {hours}H {minutes}M {seconds}S"
# else:
# text "INCOMPATIBLE VERSION" color "#f00"
2022-05-16 23:48:22 +00:00
# textbutton "{font=[gui.glyph_font]}✘{/font}":
# style "slot_delete_button"
# action FileDelete(slot)
2022-05-16 23:48:22 +00:00
# key "save_delete" action FileDelete(slot)
# else:
# text f"Empty Slot {FileSlotName(slot, gui.file_slot_cols * gui.file_slot_rows)}." style "slot_button_text"
2022-05-16 23:48:22 +00:00
# ## Buttons to access other pages.
# hbox:
# style_prefix gui.theme("page")
2022-05-16 23:48:22 +00:00
# align (0.5, 1.0)
# yoffset 8
2022-05-16 23:48:22 +00:00
# spacing gui.page_spacing
2022-05-16 23:48:22 +00:00
# textbutton _("<") action FilePagePrevious()
2022-05-16 23:48:22 +00:00
# if config.has_autosave:
# textbutton _("{#auto_page}A") action FilePage("auto") keysym "K_a"
2022-05-16 23:48:22 +00:00
# if config.has_quicksave:
# textbutton _("{#quick_page}Q") action FilePage("quick") keysym "K_q"
2022-05-16 23:48:22 +00:00
# $ page_modifier = max(0, int(FilePageName(str(page_modifier+9), str(page_modifier+9)))-9)
2022-05-16 23:48:22 +00:00
# for page in range(1+page_modifier, 10+page_modifier):
# textbutton "[page]":
# xminimum 40
# action FilePage(page)
# if page < 10:
# keysym f"K_{page}"
2022-05-16 23:48:22 +00:00
# textbutton _(">") action FilePageNext()
2022-05-16 23:48:22 +00:00
# key ["mousedown_4", "K_RIGHT", "repeat_K_RIGHT"] action FilePageNext()
# key ["mousedown_5", "K_LEFT", "repeat_K_LEFT"] action FilePagePrevious()
2022-05-16 23:48:22 +00:00
style page_label is gui_label
style page_label_text is gui_label_text:
text_align 0.5
layout "subtitle"
hover_color gui.hover_color
style dark_page_label_text is dark_label_text:
take page_label_text
style light_page_label_text is light_label_text:
take page_label_text
style page_button is gui_button:
background None
padding (9, 4, 9, 4)
style page_button_text is gui_button_text:
size 20
xalign 0.5
style slot_button is gui_button:
# background gui.muted_color
xsize gui.slot_width
ysize gui.slot_height+4
padding (2, 2, 2, 2)
style dark_slot_button:
take dark_gui_frame
insensitive_background Fixed(Transform(Frame("gui/dark_frame.png", 8, 8)), "#00000040")
style light_slot_button:
take light_gui_frame
insensitive_background Fixed(Transform(Frame("gui/light_frame.png", 8, 8)), "#00000040")
style slot_button_text is gui_button_text:
size 14
xalign 0.5
text_align 0.5
idle_color gui.idle_small_color
selected_idle_color gui.selected_color
selected_hover_color gui.hover_color
style slot_delete_button is gui_button:
background None
idle_background None
xsize gui.slot_height
ysize gui.slot_height
xalign 1.0
style slot_delete_button_text is slot_button_text:
size 24