马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
RenPy默认可以随意调整窗口大小,但是在非默认长宽比下,会有黑边,看起来不太美观。
下面这段会持续检查窗口尺寸变化,自动计算并调整缩放比例。达到在玩家手动调整窗口大小时,维持原始长宽比的效果。
算是一个...取巧的办法?
将下面这段放在script.rpy来测试效果:
[RenPy] 纯文本查看 复制代码
screen fixwindow_wd():
timer 0.5 repeat True action Function(fixwindow)
init python:
screen_width = config.screen_width
screen_height = config.screen_height
last_pw = screen_width
last_ph = screen_height
def fixwindow():
if preferences.fullscreen:
return
global last_pw, last_ph
pw, ph = renpy.get_physical_size()
dw = abs(pw - last_pw)
dh = abs(ph - last_ph)
if dw < 10 and dh < 10:
return
if dw >= dh:
size = round(pw / float(screen_width), 2)
else:
size = round(ph / float(screen_height), 2)
if ph < 255 or pw < 455:
size = 0.24
renpy.run(Preference("display", size))
last_pw, last_ph = pw, ph
init python:
config.always_shown_screens.append("fixwindow_wd")
下面是一些判断的解释:
“if dw < 10 and dh < 10”:放弃小于10px的修正,不加这段的话,窗口会自己一直变小,不知道怎么回事...
“if dw >= dh”:以变更更多的一边作为基准边,计算缩放比例。
“if ph < 255 or pw < 455”:限制了窗口的最小值,因为窗口在小于255px*255px的时候会出问题。
License: WTFPL or CC0 1.0
|