From 4ad0beebb4b5bd71be4e74f4e88ada01f3f9b046 Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 1 Sep 2023 19:49:35 +0100 Subject: [PATCH] Credits and Evaluation: Replace dedicated Responder functions with Menu-style input processing The former method responded with an arbitrary approximation of standard inputs. This method benefits from the general-case stability of the Menu system to correctly parse triggers and other unique inputs. The only major consequence of this change is that ESC is no longer hardcoded to activate these. Otherwise, the game is cleaner for pure benefit. --- src/f_finale.c | 164 ++++++++++--------------------------------------- src/f_finale.h | 2 - src/g_game.c | 14 ----- 3 files changed, 33 insertions(+), 147 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index 8b920d0a1..4b4c87941 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -824,6 +824,13 @@ void F_CreditTicker(void) // Do this here rather than in the drawer you doofus! (this is why dedicated mode broke at credits) + const boolean reachedbottom = (!credits[i] && y <= 120<everfinishedcredits = true; + if (M_UpdateUnlockablesAndExtraEmblems(true, true)) + G_SaveGameData(); + } + else if (timetonext) + ; + /*else if (!(gamedata->timesBeaten) && !(netgame || multiplayer) && !cht_debug) + ;*/ + else if (!menuactive && M_MenuConfirmPressed(0)) { finalecount = TICRATE; @@ -845,79 +865,6 @@ void F_CreditTicker(void) return; } } - else if (!credits[i] && y <= 120<everfinishedcredits = true; - if (M_UpdateUnlockablesAndExtraEmblems(true, true)) - G_SaveGameData(); - } -} - -boolean F_CreditResponder(event_t *event) -{ - INT32 key = event->data1; - - // remap virtual keys (mouse & joystick buttons) - switch (key) - { - case KEY_MOUSE1: - key = KEY_ENTER; - break; - case KEY_MOUSE1 + 1: - key = KEY_BACKSPACE; - break; - case KEY_JOY1: - case KEY_JOY1 + 2: - key = KEY_ENTER; - break; - case KEY_JOY1 + 3: - key = 'n'; - break; - case KEY_JOY1 + 1: - key = KEY_BACKSPACE; - break; - case KEY_HAT1: - key = KEY_UPARROW; - break; - case KEY_HAT1 + 1: - key = KEY_DOWNARROW; - break; - case KEY_HAT1 + 2: - key = KEY_LEFTARROW; - break; - case KEY_HAT1 + 3: - key = KEY_RIGHTARROW; - break; - } - - if (event->type != ev_keydown) - return false; - - if (key == KEY_DOWNARROW || key == KEY_SPACE) - { - if (!timetonext && !finalecount) - animtimer += 7; - return false; - } - - /*if (!(gamedata->timesBeaten) && !(netgame || multiplayer) && !cht_debug) - return false;*/ - - if (key != KEY_ESCAPE && key != KEY_ENTER && key != KEY_BACKSPACE) - return false; - - if (timetonext) - return false; - - if (keypressed) - return true; - - keypressed = true; - return true; } // ============ @@ -1312,6 +1259,18 @@ void F_GameEvaluationTicker(void) return; } + if (keypressed) + ; + else if (finalecount <= EVALLEN_HALFWAY + TICRATE) + ; + else if (finalecount >= (timetonext - TICRATE)) + ; + else if (!menuactive && M_MenuConfirmPressed(0)) + { + keypressed = true; + timetonext = finalecount + TICRATE; + } + if (finalecount == EVALLEN_HALFWAY) { if (!usedCheats) @@ -1324,63 +1283,6 @@ void F_GameEvaluationTicker(void) } } -boolean F_EvaluationResponder(event_t *event) -{ - INT32 key = event->data1; - - // remap virtual keys (mouse & joystick buttons) - switch (key) - { - case KEY_MOUSE1: - key = KEY_ENTER; - break; - case KEY_MOUSE1 + 1: - key = KEY_BACKSPACE; - break; - case KEY_JOY1: - case KEY_JOY1 + 2: - key = KEY_ENTER; - break; - case KEY_JOY1 + 3: - key = 'n'; - break; - case KEY_JOY1 + 1: - key = KEY_BACKSPACE; - break; - case KEY_HAT1: - key = KEY_UPARROW; - break; - case KEY_HAT1 + 1: - key = KEY_DOWNARROW; - break; - case KEY_HAT1 + 2: - key = KEY_LEFTARROW; - break; - case KEY_HAT1 + 3: - key = KEY_RIGHTARROW; - break; - } - - if (event->type != ev_keydown) - return false; - - if (key != KEY_ESCAPE && key != KEY_ENTER && key != KEY_BACKSPACE) - return false; - - if (finalecount <= EVALLEN_HALFWAY + TICRATE) - return false; - - if (finalecount > (timetonext - TICRATE)) - return true; - - if (keypressed) - return true; - - keypressed = true; - timetonext = finalecount + TICRATE; - return true; -} - #undef EVALLEN_NORMAL #undef EVALLEN_HALFWAY #undef EVALLEN_PERFECT diff --git a/src/f_finale.h b/src/f_finale.h index f90bf567c..517b59ce3 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -30,8 +30,6 @@ extern "C" { // Called by main loop. boolean F_IntroResponder(event_t *ev); boolean F_CutsceneResponder(event_t *ev); -boolean F_CreditResponder(event_t *ev); -boolean F_EvaluationResponder(event_t *ev); // Called by main loop. void F_IntroTicker(void); diff --git a/src/g_game.c b/src/g_game.c index 2e9d47725..3d218fdc9 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1361,20 +1361,6 @@ boolean G_Responder(event_t *ev) return true; } } - else if (gamestate == GS_CREDITS) - { - if (F_CreditResponder(ev)) - { - return true; - } - } - else if (gamestate == GS_EVALUATION) - { - if (F_EvaluationResponder(ev)) - { - return true; - } - } else if (gamestate == GS_CEREMONY) { if (K_CeremonyResponder(ev))