From 16bea0cbde0fe5a8927a0cb5a6aa16fa0938008c Mon Sep 17 00:00:00 2001 From: LoafyLemon Date: Mon, 20 Jun 2022 19:41:04 +0100 Subject: [PATCH] Skip Callbacks * Added skip start/end interaction callbacks support * Fixed Doll images not being refreshed after exiting skip interaction --- game/scripts/utility/dialogue.rpy | 3 +-- game/scripts/utility/skipping.rpy | 36 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 game/scripts/utility/skipping.rpy diff --git a/game/scripts/utility/dialogue.rpy b/game/scripts/utility/dialogue.rpy index e8f296de..410fc58c 100644 --- a/game/scripts/utility/dialogue.rpy +++ b/game/scripts/utility/dialogue.rpy @@ -22,11 +22,10 @@ define sprite_pos = { } } -init -1 python: +init python: def replace_text(s): s = s.replace('--', u'\u2014') # em dash return s config.replace_text = replace_text - diff --git a/game/scripts/utility/skipping.rpy b/game/scripts/utility/skipping.rpy new file mode 100644 index 00000000..f10dfc02 --- /dev/null +++ b/game/scripts/utility/skipping.rpy @@ -0,0 +1,36 @@ +init -1 python: + + start_skip_callbacks = [] + end_skip_callbacks = [] + + class SkipCallbacksHandler(NoRollback): + + def __init__(self): + self.was_skipping = False + + def __call__(self): + is_skipping = renpy.is_skipping() + was_skipping = self.was_skipping + + if is_skipping and not was_skipping: + self.was_skipping = True + for c in start_skip_callbacks: + c() + + elif was_skipping and not renpy.is_skipping(): + self.was_skipping = False + for c in end_skip_callbacks: + c() + + def rebuild_dolls(): + if renpy.in_rollback(): + return + + for c in renpy.store.CHARACTERS: + c = get_character_object(c) + c.rebuild_image() + + config.interact_callbacks.append(SkipCallbacksHandler()) + + end_skip_callbacks.append(rebuild_dolls) +