From f8d4de397adc25aea3b9606463e7378ae4401a70 Mon Sep 17 00:00:00 2001 From: Andrei Alexeyev <0x416b617269@gmail.com> Date: Sat, 4 May 2024 19:14:32 +0200 Subject: [PATCH] cutscene: allow interrupting already seen cutscenes --- src/cutscenes/cutscene.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cutscenes/cutscene.c b/src/cutscenes/cutscene.c index 6cf70db626..1484d28682 100644 --- a/src/cutscenes/cutscene.c +++ b/src/cutscenes/cutscene.c @@ -67,6 +67,8 @@ typedef struct CutsceneState { int skip_timer; int advance_timer; int fadeout_timer; + + bool interruptible; } CutsceneState; static void clear_text(CutsceneState *st) { @@ -185,6 +187,10 @@ static bool cutscene_event(SDL_Event *evt, void *ctx) { cutscene_advance(st); } + if(evt->type == MAKE_TAISEI_EVENT(TE_MENU_ABORT) && st->interruptible) { + cutscene_interrupt(st); + } + return false; } @@ -477,6 +483,7 @@ static CutsceneState *cutscene_state_new(const CutscenePhase phases[]) { void cutscene_enter(CallChain next, CutsceneID id) { assert((uint)id < NUM_CUTSCENE_IDS); + bool interruptible = progress_is_cutscene_unlocked(id); progress_unlock_cutscene(id); const Cutscene *cs = g_cutscenes + id; @@ -490,6 +497,7 @@ void cutscene_enter(CallChain next, CutsceneID id) { CutsceneState *st = cutscene_state_new(cs->phases); st->cc = next; st->bg_state.transition_rate = 1/80.0f; + st->interruptible = interruptible; progress_unlock_bgm(cs->bgm); audio_bgm_play(res_bgm(cs->bgm), true, 0, 1); demoplayer_suspend();