优化renpy游戏体验
renpy吧
全部回复
仅看楼主
level 1
口包口孝 楼主
目录
1.取消加载确认提示
2.增加快捷键
3.优化存档页面
2025年12月26日 10点12分 1
level 1
口包口孝 楼主
1.取消加载确认提示。
在加载存档时,会弹出“加载会丢失目前进度,是否确认”的窗口,如何取消这个窗口?
打开Game/screens.rpy(先复制screens.rpy到桌面作为备份)
搜索action FileAction(slot)
替换
button:
action FileAction(slot)
为:
button:
if title == "Load" or title == _("Load"):
action FileLoad(slot, confirm=False)
else:
action FileAction(slot)
注意:renpy对格式要求严格,缩进要求四个空格(即按一次TAB键),替换前后button和上文的相对位置要不变,button后面的内容格式要和我给的一致,否则需要手动调整。
2025年12月26日 11点12分 3
@口包口孝 嗄哈啊~
2025年12月26日 17点12分
@口包口孝 silentYou know me. You know me.
2025年12月26日 17点12分
@金牌暖男874 你刚的撒,我听不下
2025年12月27日 12点12分
level 1
口包口孝 楼主
2.增加快捷键
每次打开菜单都是存档界面,这在游玩游戏时很方便,但已经探索完剧情,且剧情都是碎片化的,从头开始依次加载每次都要打开菜单,选择加载,再点存档文件,太麻烦了。
增加一些快捷键可以一键打开加载界面。
在game目录下创建一个rpy文件,可以取名为quick_keys.rpy
文件内容:
init python:
config.underlay.append(
renpy.Keymap(
K_1 = ShowMenu("load"),
mouseup_3 = ToggleScreen("load")
)
)
# K_1 = ShowMenu("load")即把数字键1设置为打开加载菜单,
# mouseup_3 = ToggleScreen("load") 即把鼠标右键替换为加载菜单。(建议重玩游戏时再这样修改,初次玩右键打开存档菜单更方便),可以根据需要增减快捷键。
还是要注意对齐
2025年12月26日 11点12分 4
贴吧发出来格式有问题,对照我图片中的格式修改
2025年12月26日 11点12分
@口包口孝 改_game_menu不就得了
2025年12月26日 15点12分
@孟徽杭 我是小白,跟着 deepseek 改的,求大佬指教[花心]
2025年12月27日 07点12分
level 1
口包口孝 楼主
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
2025年12月26日 11点12分 5
level 1
口包口孝 楼主
贴吧真难用,无语了。用CTRL+SHIFT+V粘贴,格式是对的,发出来,缩进的空格全没了。
没招了╮(╯▽╰)╭
2025年12月26日 11点12分 7
level 1
口包口孝 楼主
【有道云笔记】Renpy 优化
https://share.note.youdao.com/s/I9eTroWy
在这里面复制吧。
2025年12月26日 11点12分 8
level 7
[真棒]
2025年12月26日 17点12分 9
1