3.优化存档页面
很多游戏的存档页是A Q 1 2 3 4 5 6 7 8 9 10,如果存档页很多,翻页会比较麻烦,替换一部分代码,让当前页面始终在页面中间。
例如当前页面是16页,A Q 12 13 14 15 16 17 18 19 20,它左边和右边各有四页,可以一次跳四页。
优化后效果:


步骤:
1.备份screen.rpy
2.打开,ctrl+F 搜索screen file
3.替换screen file_slots(title): 这一行及之后, style page_label is gui_label之前的部分。




替换内容:
screen file_slots(title):
default page_name_value = FilePageNameInputValue(pattern=_("Page {} "), auto=_("Auto"), quick=_("Quick"))
use game_menu(title):
fixed:
order_reverse True
# 页面标签
button:
style "page_label"
key_events True
xalign 0.5
action page_name_value.Toggle()
input:
style "page_label_text"
value page_name_value
# 存档槽网格
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:
if title == "Load" or title == _("Load"):
action FileLoad(slot, confirm=False)
else:
action FileAction(slot)
has vbox
add FileScreenshot(slot) xalign 0.5
text FileTime(slot, format=_("{#file_time}%Y-%m-%d %H:%M"), empty=_("空存档位")):
style "slot_time_text"
text FileSaveName(slot):
style "slot_name_text"
key "save_delete" action FileDelete(slot)
# ============ 智能分页导航(完全符合你的要求)============
# 获取当前页面信息
$ current_page_raw = page_name_value.get_page()
$ current_page = 1
# 解析当前页(安全处理)
if current_page_raw:
if str(current_page_raw) == "auto":
$ current_page = 0
elif str(current_page_raw) == "quick":
$ current_page = -1
elif str(current_page_raw).isdigit():
$ current_page = int(str(current_page_raw))
if current_page < 1:
$ current_page = 1
hbox:
style_prefix "page"
xalign 0.5
yalign 1.0
spacing gui.page_spacing
# 修复1:A和Q按钮使用正确显示
if config.has_autosave:
textbutton "A" action FilePage("auto") xsize 40
if config.has_quicksave:
textbutton "Q" action FilePage("quick") xsize 40
# 修复2:智能分页显示(当前页15的示例格式)
# 只在显示普通数字页时显示分页
if current_page > 0:
# 定义分页参数
$ pages_each_side = 4 # 当前页左右各显示4页
$ start_page = max(1, current_page - pages_each_side)
$ end_page = min(70, current_page + pages_each_side)
# 上一页按钮
if current_page > 1:
textbutton "<" action FilePage(current_page - 1)
# 显示页码范围(不显示1和70,除非在范围内)
for page in range(start_page, end_page + 1):
if page == current_page:
textbutton str(page) action FilePage(page) text_color "#ff37bb" text_bold True
else:
textbutton str(page) action FilePage(page)
# 下一页按钮
if current_page < 70:
textbutton ">" action FilePage(current_page + 1)
# 如果在auto或quick页,只显示返回按钮
elif current_page == 0 or current_page == -1:
textbutton "——PAGE——" action FilePage(1) text_size 18
