本帖最后由 Lost 于 2023-5-23 18:36 编辑
这样吧,我先给个代码,这是改 `afm_delay` 的计算逻辑的那个思路,这里是劫持改写而没有去动 renpy 源码,请注意此处改后正常的 Auto 就没有了,基本按照固定时间自动播放了,但是可能会出现些特殊情况什么的,我也不知道会发生什么(
设置里的那个自动时间就变成了间隔秒数了,不过那个 bar 的调整范围有点感人,为了体验良好建议再做个数学函数映射到一个合适的等待秒数范围上
哦对,这是 renpy 8.0.2.22080705 版本的,其它版本可能不适用,请自己改一改
[RenPy] 纯文本查看 复制代码 init -999 python:
from renpy.display.behavior import map_event
import pygame_sdl2 as pygame
def event_patched(self, ev, x, y, st):
if self.afm_length and renpy.game.preferences.afm_time and renpy.game.preferences.afm_enable:
# afm_delay = (1.0 * (renpy.config.afm_bonus + self.afm_length) / renpy.config.afm_characters) * renpy.game.preferences.afm_time
# if self.text_tuple is not None:
# max_time = 0
# for t in self.text_tuple:
# max_time = max(max_time, t.get_time())
# afm_delay += max_time
afm_delay = renpy.game.preferences.afm_time
if ev.type == renpy.display.core.TIMEEVENT and ev.modal:
return None
if st > afm_delay:
if renpy.config.afm_callback:
if renpy.config.afm_callback() and not renpy.display.tts.is_active():
return True
else:
renpy.game.interface.timeout(0.1)
else:
return True
else:
renpy.game.interface.timeout(afm_delay - st)
dismiss = [ (i, True) for i in self.dismiss ] + [ (i, False) for i in self.dismiss_unfocused ] # type: ignore
for dismiss_event, check_focus in dismiss:
if map_event(ev, dismiss_event):
if check_focus and not self.is_focused():
continue
if renpy.config.skipping:
renpy.config.skipping = None
renpy.exports.restart_interaction()
raise renpy.display.core.IgnoreEvent()
if not renpy.config.enable_rollback_side:
rollback_side = "disable"
if renpy.exports.variant("mobile"):
rollback_side = renpy.game.preferences.mobile_rollback_side
else:
rollback_side = renpy.game.preferences.desktop_rollback_side
if ev.type == pygame.MOUSEBUTTONUP:
percent = 1.0 * x / renpy.config.screen_width
if rollback_side == "left":
if percent < renpy.config.rollback_side_size:
renpy.exports.rollback()
raise renpy.display.core.IgnoreEvent()
elif rollback_side == "right":
if (1.0 - percent) < renpy.config.rollback_side_size:
renpy.exports.rollback()
raise renpy.display.core.IgnoreEvent()
if renpy.game.preferences.using_afm_enable and renpy.game.preferences.afm_enable and not renpy.game.preferences.afm_after_click:
renpy.game.preferences.afm_enable = False
renpy.exports.restart_interaction()
raise renpy.display.core.IgnoreEvent()
if self.allow_dismiss:
if not self.allow_dismiss():
raise renpy.display.core.IgnoreEvent()
return True
skip_delay = renpy.config.skip_delay / 1000.0
if renpy.config.skipping and renpy.config.allow_skipping and renpy.store._skipping:
if ev.type == renpy.display.core.TIMEEVENT and st >= skip_delay:
if ev.modal:
return None
elif renpy.game.preferences.skip_unseen:
return True
elif renpy.config.skipping == "fast":
return True
elif renpy.game.context().seen_current(True):
return True
else:
renpy.config.skipping = None
renpy.exports.restart_interaction()
else:
renpy.game.interface.timeout(skip_delay - st)
return None
renpy.display.behavior.SayBehavior.event = event_patched
label start:
'[renpy.game.preferences.afm_time]'
'bar 是线性的 0.1 到 30.0'
|