Skip to content

Commit ea2b467

Browse files
committed
refactor
1 parent 01f44c7 commit ea2b467

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

cue_lib/cue_z.rpy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,6 @@ init 999 python:
400400
the patches: reload_all() restores renpy.* modules to their
401401
post-import state, wiping the config callback lists too."""
402402

403-
# Register 8 dedicated SFX channels on the "sfx" mixer
404403
for i in range(1, CUE_SFX_CHANNEL_COUNT + 1):
405404
ch_name = _cue_sfx_channel_name(i)
406405
if not renpy.music.channel_defined(ch_name):
@@ -430,7 +429,6 @@ init 999 python:
430429

431430
config.all_character_callbacks.append(_cue_char_callback)
432431

433-
# start_interact callback — detects context changes at interaction
434432
def _cue_start_interact_callback(*args, **kwargs):
435433
# Ensure the runtime driver is always active.
436434
if not renpy.get_screen("cue_runtime_driver", layer="cue_layer"):

cue_lib/markers.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,14 @@ def target_active_label(self):
659659
# ---------------------------------------------------------------------------
660660

661661

662+
def _cue_coalesce_bool(value, default):
663+
# type: (object, bool) -> bool
664+
"""None means *default*, else bool(value). A dict key holding None (e.g. a
665+
partially-nulled persistent._cue) must not silently flip these scalars to
666+
falsy -- remove_audio=None would keep audio on every encode."""
667+
return default if value is None else bool(value)
668+
669+
662670
def _cue_load_scalars_from_persistent():
663671
# type: () -> None
664672
"""Fan out per-game scalars from persistent/shared config into the
@@ -687,22 +695,16 @@ def _cue_load_scalars_from_persistent():
687695
_cue_dict.pop("disabled_files", None)
688696

689697
_cue.sfx.library.disabled_files = set(shared.get("disabled_files", []))
690-
# Coalesce None to the default: a dict whose keys hold None (e.g. a
691-
# partially-nulled persistent._cue) must not silently flip these to
692-
# falsy -- remove_audio=None would keep audio on every encode.
693-
_triggers = _cue_dict.get("triggers_active")
694-
_cue.trigger.active = True if _triggers is None else bool(_triggers)
698+
699+
# Coalesce None to the default: see _cue_coalesce_bool.
700+
_cue.trigger.active = _cue_coalesce_bool(_cue_dict.get("triggers_active"), True)
695701
_mode = _cue_dict.get("encode_mode")
696-
if _mode is None:
697-
_mode = _cue.video_editor.MODE_INTERPOLATE
698-
_cue.video_editor.encode_mode = _mode
699-
_ra = _cue_dict.get("remove_audio")
700-
_cue.video_editor.remove_audio = True if _ra is None else bool(_ra)
701-
_st = _cue_dict.get("seamless_transition")
702-
_cue.speed_resolver.seamless_transition = False if _st is None else bool(_st)
703-
_sfm = _cue_dict.get(CUE_PERSIST_SIDEBAR_MODE)
704-
_cue.sfx.library.is_sidebar_mode = False if _sfm is None else bool(_sfm)
702+
_cue.video_editor.encode_mode = _mode if _mode is not None else _cue.video_editor.MODE_INTERPOLATE
703+
_cue.video_editor.remove_audio = _cue_coalesce_bool(_cue_dict.get("remove_audio"), True)
704+
_cue.speed_resolver.seamless_transition = _cue_coalesce_bool(_cue_dict.get("seamless_transition"), False)
705+
_cue.sfx.library.is_sidebar_mode = _cue_coalesce_bool(_cue_dict.get(CUE_PERSIST_SIDEBAR_MODE), False)
705706
_sw = _cue_dict.get(CUE_PERSIST_SIDEBAR_WIDTH)
707+
706708
if isinstance(_sw, int):
707709
_cue.sfx.library.set_sidebar_width(_sw)
708710
else:

0 commit comments

Comments
 (0)