本文修改全部位于screens.rpy文件中

参考资料

  1. 环境变量
  2. Preference行为

特别感谢renpy官方交流群群友倾情相助

视频教程

查看源代码

打开screens.rpy文件,你可以在708行看到如下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
## 设置屏幕 ########################################################################
##
## 设置屏幕允许用户配置游戏,使其更适合自己。
##
## https://doc.renpy.cn/zh-CN/screen_special.html#preferences

screen preferences():

tag menu

use game_menu(_("设置"), scroll="viewport"):

vbox:

hbox:
box_wrap True

if renpy.variant("pc") or renpy.variant("web"):

vbox:
style_prefix "radio"
label _("显示")
textbutton _("窗口") action Preference("display", "window")
textbutton _("全屏") action Preference("display", "fullscreen")

vbox:
style_prefix "check"
label _("快进")
textbutton _("未读文本") action Preference("skip", "toggle")
textbutton _("选项后继续") action Preference("after choices", "toggle")
textbutton _("忽略转场") action InvertSelected(Preference("transitions", "toggle"))

## 可在此处添加 radio_pref 或 check_pref 类型的额外 vbox,以添加
## 额外的创建者定义的偏好设置。

null height (4 * gui.pref_spacing)

hbox:
style_prefix "slider"
box_wrap True

vbox:

label _("文字速度")

bar value Preference("text speed")

label _("自动前进时间")

bar value Preference("auto-forward time")

vbox:

if config.has_music:
label _("音乐音量")

hbox:
bar value Preference("music volume")

if config.has_sound:

label _("音效音量")

hbox:
bar value Preference("sound volume")

if config.sample_sound:
textbutton _("测试") action Play("sound", config.sample_sound)


if config.has_voice:
label _("语音音量")

hbox:
bar value Preference("voice volume")

if config.sample_voice:
textbutton _("测试") action Play("voice", config.sample_voice)

if config.has_music or config.has_sound or config.has_voice:
null height gui.pref_spacing

textbutton _("全部静音"):
action Preference("all mute", "toggle")
style "mute_all_button"


style pref_label is gui_label
style pref_label_text is gui_label_text
style pref_vbox is vbox

style radio_label is pref_label
style radio_label_text is pref_label_text
style radio_button is gui_button
style radio_button_text is gui_button_text
style radio_vbox is pref_vbox

style check_label is pref_label
style check_label_text is pref_label_text
style check_button is gui_button
style check_button_text is gui_button_text
style check_vbox is pref_vbox

style slider_label is pref_label
style slider_label_text is pref_label_text
style slider_slider is gui_slider
style slider_button is gui_button
style slider_button_text is gui_button_text
style slider_pref_vbox is pref_vbox

style mute_all_button is check_button
style mute_all_button_text is check_button_text

style pref_label:
top_margin gui.pref_spacing
bottom_margin 3

style pref_label_text:
yalign 1.0

style pref_vbox:
xsize 338

style radio_vbox:
spacing gui.pref_button_spacing

style radio_button:
properties gui.button_properties("radio_button")
foreground "gui/button/radio_[prefix_]foreground.png"

style radio_button_text:
properties gui.text_properties("radio_button")

style check_vbox:
spacing gui.pref_button_spacing

style check_button:
properties gui.button_properties("check_button")
foreground "gui/button/check_[prefix_]foreground.png"

style check_button_text:
properties gui.text_properties("check_button")

style slider_slider:
xsize 525

style slider_button:
properties gui.button_properties("slider_button")
yalign 0.5
left_margin 15

style slider_button_text:
properties gui.text_properties("slider_button")

style slider_vbox:
xsize 675

自定义

我们先确定系统设置界面的功能,这里我分为六部分

由于imagebutton使用效果不佳,同时为给用户提示当前设置,我们使用if语句对当前环境变量进行判断,不过有些未给出的变量需要我们自定义

全屏窗口切换

修改为如下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
vbox:
spacing 10
hbox:
spacing 10
add "label.png"
text "屏幕尺寸" color "#4e021f"
hbox:
spacing 20
## 窗口状态下
if preferences.fullscreen == False:
imagebutton:
idle "fullscreen.png"
hover "hover_fullscreen.png"
action Preference("display", "fullscreen")
imagebutton:
idle "hover_window.png"
action Preference("display", "window")
## 全屏状态下
else:
imagebutton:
idle "hover_fullscreen.png"
action Preference("display", "fullscreen")
imagebutton:
idle "window.png"
hover "hover_window.png"
action Preference("display", "window")

是否显示转场

修改为如下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
vbox:
spacing 10
hbox:
spacing 10
add "label.png"
text "转场效果" color "#4e021f"
hbox:
spacing 20
## 显示所有转场
if preferences.transitions == 2:
imagebutton:
idle "on.png"
action Preference("transitions", "all")
imagebutton:
idle "hover_off.png"
hover "off.png"
action Preference("transitions", "none")
## 忽略所有转场
if preferences.transitions == 0:
imagebutton:
idle "hover_on.png"
hover "on.png"
action Preference("transitions", "all")
imagebutton:
idle "off.png"
action Preference("transitions", "none")

忽略转场实际上忽略的是with从句的效果

鼠标自动移动

添加如下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
vbox:
spacing 10
hbox:
spacing 10
add "label.png"
text "鼠标自动移动" color "#4e021f"
hbox:
spacing 20
## 允许鼠标自动移动
if preferences.mouse_move == True:
imagebutton:
idle "on.png"
action Preference("automatic move", "enable")
imagebutton:
idle "hover_off.png"
hover "off.png"
action Preference("automatic move", "disable")
## 禁止鼠标自动移动
else:
imagebutton:
idle "hover_on.png"
hover "on.png"
action Preference("automatic move", "enable")
imagebutton:
idle "off.png"
action Preference("automatic move", "disable")

来到screens.rpy文件第1121行,你会看到如下代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
## 确认屏幕 ########################################################################
##
## 当 Ren'Py 需要询问用户有关确定或取消的问题时,会调用确认屏幕。
##
## https://doc.renpy.cn/zh-CN/screen_special.html#confirm

screen confirm(message, yes_action, no_action):

## 显示此屏幕时,确保其他屏幕无法输入。
modal True

zorder 200

style_prefix "confirm"

add "gui/overlay/confirm.png"

frame:

vbox:
xalign .5
yalign .5
spacing 45

label _(message):
style "confirm_prompt"
xalign 0.5

hbox:
xalign 0.5
spacing 150

textbutton _("确定") action yes_action
textbutton _("取消") action no_action

## 右键点击退出并答复 no(取消)。
key "game_menu" action no_action


style confirm_frame is gui_frame
style confirm_prompt is gui_prompt
style confirm_prompt_text is gui_prompt_text
style confirm_button is gui_medium_button
style confirm_button_text is gui_medium_button_text

style confirm_frame:
background Frame([ "gui/confirm_frame.png", "gui/frame.png"], gui.confirm_frame_borders, tile=gui.frame_tile)
padding gui.confirm_frame_borders.padding
xalign .5
yalign .5

style confirm_prompt_text:
textalign 0.5
layout "subtitle"

style confirm_button:
properties gui.button_properties("confirm_button")

style confirm_button_text:
properties gui.text_properties("confirm_button")

添加如下代码
1
on "show" action MouseMove(850,570)

这里添加的是没有自定义的参数,可以等自定义确认界面后再做修改

已读文本变色

添加如下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
vbox:
spacing 10
hbox:
spacing 10
add "label.png"
text "已读文本变色" color "#4e021f"
hbox:
spacing 20
## 允许已读文本变色
if text_color_changeable==True:
imagebutton:
idle "on.png"
action SetVariable("text_color_changeable", True)
imagebutton:
idle "hover_off.png"
hover "off.png"
action SetVariable("text_color_changeable", False)
## 禁止已读文本变色
else:
imagebutton:
idle "hover_on.png"
hover "on.png"
action SetVariable("text_color_changeable", True)
imagebutton:
idle "off.png"
action SetVariable("text_color_changeable", False)

自定义变量

1
2
## 已读文本变色
default text_color_changeable=True

say界面修改为如下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
## 已读文本变色
if text_color_changeable==True:

## 已被查看(不包括当前文本)
if renpy.is_seen(ever = True):
text what id "what" color "#FFFF00"
## 未被查看
else:
text what id "what" color "#fff"

## 不允许已读文本变色
else:
text what id "what" color "#fff"

已选选项变色

添加如下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
vbox:
spacing 10
hbox:
spacing 10
add "label.png"
text "已选选项变色" color "#4e021f"
hbox:
spacing 20
## 允许已选选项变色
if choice_color_changeable==True:
imagebutton:
idle "on.png"
action SetVariable("choice_color_changeable", True)
imagebutton:
idle "hover_off.png"
hover "off.png"
action SetVariable("choice_color_changeable", False)
## 禁止已选选项变色
else:
imagebutton:
idle "hover_on.png"
hover "on.png"
action SetVariable("choice_color_changeable", True)
imagebutton:
idle "off.png"
action SetVariable("choice_color_changeable", False)

自定义变量

1
2
## 已选选项变色
default choice_color_changeable=True

来到screens.rpy文件第195行,你会看到如下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
## 选择屏幕 ########################################################################
##
## 此屏幕用于显示由 menu 语句生成的游戏内选项。参数 items 是一个对象列表,每个对
## 象都有字幕和动作字段。
##
## https://doc.renpy.cn/zh-CN/screen_special.html#choice

screen choice(items):
style_prefix "choice"

vbox:
for i in items:
textbutton i.caption action i.action


style choice_vbox is vbox
style choice_button is button
style choice_button_text is button_text

style choice_vbox:
xalign 0.5
ypos 405
yanchor 0.5

spacing gui.choice_spacing

style choice_button is default:
properties gui.button_properties("choice_button")

style choice_button_text is default:
properties gui.text_properties("choice_button")

添加如下代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
vbox:
for i in items:
## 允许已选选项变色
if choice_color_changeable==True:
## 已选选项
if i.chosen:
textbutton i.caption:
text_color "#FFFF00"
action i.action
## 未选选项
else:
textbutton i.caption:
text_color "#fff"
action i.action
## 禁止已选选项变色
else:
textbutton i.caption:
text_color "#fff"
action i.action

侧边栏存档读档

添加如下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
vbox:
spacing 10
xpos 750
ypos 207
hbox:
spacing 10
add "label.png"
text "侧边存档读档栏显示" color "#4e021f"
hbox:
spacing 20
## 允许侧边栏存档读档显示
if side_save_load==True:
imagebutton:
idle "on.png"
action SetVariable("side_save_load", True)
imagebutton:
idle "hover_off.png"
hover "off.png"
action SetVariable("side_save_load", False)
## 禁止侧边栏存档读档显示
else:
imagebutton:
idle "hover_on.png"
hover "on.png"
action SetVariable("side_save_load", True)
imagebutton:
idle "off.png"
action SetVariable("side_save_load", False)

自定义变量
1
2
3
4
## 侧边栏存档读档
default side_save =True
default side_load =False
default side_save_load=True

新建界面

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
## 鼠标位于侧边栏显示侧边栏存档
init python:
config.overlay_screens.append("mini_save_show_area")

## 鼠标位置判定
screen mini_save_show_area():
zorder 250

mousearea:
area (1820, 0, 150, 1080)
hovered Show("mini_save_load")
unhovered Hide("mini_save_load")

## 侧边栏存档读档
screen mini_save_load():

zorder 200
if side_save_load==True:
if side_save ==True:
vbox:
xalign 1.0
xoffset 420
## 切换存档读档
imagebutton:
idle "load.png"
xoffset -50
hover "load_hover.png"
action [SetVariable("side_load", True),SetVariable("side_save", False)]
imagebutton:
idle "up.png"
hover "up_hover.png"
action FilePagePrevious(max=9,wrap=True,auto=False,quick=False)

# 存档槽总数
grid 1 gui.file_slot_cols*gui.file_slot_rows*9:
style_prefix "slot"
spacing -150

for i in range(gui.file_slot_cols * gui.file_slot_rows):
$ slot = i + 1

button:

action FileSave(slot)
#存档按钮背景图
background "mini_bg.png"
#存档按钮悬停图
hover_background "mini_bg_hover.png"
#存档编号
text FileSlotName(slot, gui.file_slot_cols * gui.file_slot_rows):
size 30
tooltip [FileSaveName(slot)]
hovered [SetVariable("ToolTipSlot", int(FileSlotName(slot, gui.file_slot_cols * gui.file_slot_rows)))]
unhovered [SetVariable("ToolTipSlot", None)]

imagebutton:
align (1.0,0.8)
yoffset -15
xoffset -5
idle "down.png"
hover "down_hover.png"
action FilePageNext(max=9,wrap=True,auto=False,quick=False)

if side_load ==True:
vbox:
xalign 1.0
xoffset 420
imagebutton:
xoffset -50
idle "save.png"
hover "save_hover.png"
action [SetVariable("side_load", False),SetVariable("side_save", True)]
imagebutton:
idle "up.png"
hover "up_hover.png"
action FilePagePrevious(max=9,wrap=True,auto=False,quick=False)

# 存档槽总数
grid 1 gui.file_slot_cols*gui.file_slot_rows*9:
style_prefix "slot"
spacing -150

for i in range(gui.file_slot_cols * gui.file_slot_rows):
$ slot = i + 1

button:

action FileLoad(slot)
#存档按钮背景图
background "mini_bg.png"
#存档按钮悬停图
hover_background "mini_bg_hover.png"
#存档编号
text FileSlotName(slot, gui.file_slot_cols * gui.file_slot_rows):
size 30
tooltip [FileSaveName(slot)]
hovered [SetVariable("ToolTipSlot", int(FileSlotName(slot, gui.file_slot_cols * gui.file_slot_rows)))]
unhovered [SetVariable("ToolTipSlot", None)]

imagebutton:
align (1.0,0.8)
yoffset -15
xoffset -5
idle "down.png"
hover "down_hover.png"
action FilePageNext(max=9,wrap=True,auto=False,quick=False)

$ tooltip = GetTooltip()

if tooltip:
for i in range(gui.file_slot_cols * gui.file_slot_rows):
$ slot = i + 1
frame:
xpos 1300
background "gui/button/slot_hover_background.png" at tip

add renpy.slot_screenshot(f"{1 + int((ToolTipSlot-1) / 9)}-{1 + (int(ToolTipSlot-1) % 9)}") xysize(231,130) xoffset 6 yoffset 72
frame:
background None
xysize(210,110)
xoffset 240
yoffset 65
text tooltip at tip size 25 color "#fff" outlines [(2,"#000000",0,0)]

这里的悬停提示可能会与底部菜单的悬停提示有所冲突,可修改为如下代码

1
2
3
4
5
6
7
8
9
10
11
if tooltip and side_save_load ==False:
frame:
background None
yalign 1.0
xoffset 580
yoffset -7
text "[tooltip]":
size 30
color "#fff"
outlines [(2,"#35ceff",0,0)]
at tip

必要部分

添加返回按钮,返回标题菜单和结束游戏按钮

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
hbox:
align (1.0,1.0)
xoffset -50
yoffset -50
spacing 20
if not main_menu:
imagebutton:
idle "return_title.png"
hover "return_title_hover.png"
action MainMenu()
imagebutton:
idle "end_game.png"
hover "end_game_hover.png"
action Quit()
imagebutton:
idle "return_game.png"
hover "return_game_hover.png"
action Return()

建议

新建一个rpy文件,用于存放自定义变量

新建txt文本文档,直接修改文件后缀即可