From c4525a61a2ac377956670abbcd92836e72def498 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 3 Mar 2023 17:30:35 -0500 Subject: [PATCH] Add results screen --- src/acs/call-funcs.cpp | 15 ++++++ src/acs/call-funcs.hpp | 1 + src/acs/environment.cpp | 1 + src/d_main.c | 6 +++ src/g_game.c | 8 ++- src/k_podium.c | 107 ++++++++++++++++++++++++++++++++++++++++ src/k_podium.h | 49 ++++++++++++++++++ 7 files changed, 186 insertions(+), 1 deletion(-) diff --git a/src/acs/call-funcs.cpp b/src/acs/call-funcs.cpp index de4e166ae..0e131a3fb 100644 --- a/src/acs/call-funcs.cpp +++ b/src/acs/call-funcs.cpp @@ -50,6 +50,7 @@ extern "C" { #include "../m_cond.h" #include "../r_skins.h" #include "../k_battle.h" +#include "../k_podium.h" } #include "call-funcs.hpp" @@ -1393,3 +1394,17 @@ bool CallFunc_PodiumPosition(ACSVM::Thread *thread, const ACSVM::Word *argV, ACS return false; } +/*-------------------------------------------------- + bool CallFunc_PodiumFinish(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) + + Ends the podium sequence. Doesn't do anything + outside of podium maps. +--------------------------------------------------*/ +bool CallFunc_PodiumFinish(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) +{ + (void)argV; + (void)argC; + + K_FinishCeremony(); + return false; +} diff --git a/src/acs/call-funcs.hpp b/src/acs/call-funcs.hpp index 5ca20e915..04e4b59b7 100644 --- a/src/acs/call-funcs.hpp +++ b/src/acs/call-funcs.hpp @@ -86,5 +86,6 @@ bool CallFunc_LowestLap(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::W bool CallFunc_EncoreMode(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_PodiumPosition(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); +bool CallFunc_PodiumFinish(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); #endif // __SRB2_ACS_CALL_FUNCS_HPP__ diff --git a/src/acs/environment.cpp b/src/acs/environment.cpp index d656a3503..470774f22 100644 --- a/src/acs/environment.cpp +++ b/src/acs/environment.cpp @@ -164,6 +164,7 @@ Environment::Environment() addFuncDataACS0( 500, addCallFunc(CallFunc_CameraWait)); addFuncDataACS0( 501, addCallFunc(CallFunc_PodiumPosition)); + addFuncDataACS0( 502, addCallFunc(CallFunc_PodiumFinish)); } ACSVM::Thread *Environment::allocThread() diff --git a/src/d_main.c b/src/d_main.c index b3cae9892..9d1eee317 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -76,6 +76,7 @@ #include "m_random.h" // P_ClearRandom #include "k_specialstage.h" #include "acs/interface.h" +#include "k_podium.h" #ifdef HWRENDER #include "hardware/hw_main.h" // 3D View Rendering @@ -580,6 +581,11 @@ static void D_Display(void) F_TitleScreenDrawer(); break; } + case GS_CEREMONY: + { + K_CeremonyDrawer(); + break; + } default: { break; diff --git a/src/g_game.c b/src/g_game.c index 2427900c0..ae049df8d 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1471,6 +1471,8 @@ void G_DoLoadLevelEx(boolean resetplayer, gamestate_t newstate) if (gamestate == GS_VOTING) Y_EndVote(); + K_ResetCeremony(); + // cleanup // Is this actually necessary? Doesn't F_StartTitleScreen already do a significantly more comprehensive check? if (newstate == GS_TITLESCREEN) @@ -1724,7 +1726,11 @@ boolean G_Responder(event_t *ev) return true; // chat ate the event } - // todo + if (K_CeremonyResponder(ev)) + { + D_StartTitle(); + return true; + } } else if (gamestate == GS_CONTINUING) { diff --git a/src/k_podium.c b/src/k_podium.c index 6edb86146..9b6f82093 100644 --- a/src/k_podium.c +++ b/src/k_podium.c @@ -46,6 +46,8 @@ #include "k_menu.h" #include "k_grandprix.h" +static boolean s_podiumDone = false; + /*-------------------------------------------------- boolean K_PodiumSequence(void) @@ -103,6 +105,31 @@ boolean K_StartCeremony(void) return false; } +/*-------------------------------------------------- + void K_FinishCeremony(void) + + See header file for description. +--------------------------------------------------*/ +void K_FinishCeremony(void) +{ + if (K_PodiumSequence() == false) + { + return; + } + + s_podiumDone = true; +} + +/*-------------------------------------------------- + void K_ResetCeremony(void) + + See header file for description. +--------------------------------------------------*/ +void K_ResetCeremony(void) +{ + s_podiumDone = false; +} + /*-------------------------------------------------- void K_CeremonyTicker(boolean run) @@ -130,3 +157,83 @@ void K_CeremonyTicker(boolean run) camera[0].subsector = titlemapcam.mobj->subsector; } } + +/*-------------------------------------------------- + boolean K_CeremonyResponder(event_t *event) + + See header file for description. +--------------------------------------------------*/ +boolean K_CeremonyResponder(event_t *event) +{ + INT32 key = event->data1; + + if (s_podiumDone == false) + { + return false; + } + + // 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; + } + + return true; +} + +/*-------------------------------------------------- + void K_CeremonyDrawer(void) + + See header file for description. +--------------------------------------------------*/ +void K_CeremonyDrawer(void) +{ + if (s_podiumDone == true) + { + V_DrawFadeScreen(0xFF00, 16); + V_DrawCenteredString(BASEVIDWIDTH / 2, 64, 0, "STUFF GOES HERE"); + } + + if (timeinmap < 16) + { + // Level fade-in + V_DrawCustomFadeScreen(((levelfadecol == 0) ? "FADEMAP1" : "FADEMAP0"), 31-(timeinmap*2)); + } +} diff --git a/src/k_podium.h b/src/k_podium.h index b11de1067..21b31f74d 100644 --- a/src/k_podium.h +++ b/src/k_podium.h @@ -54,6 +54,27 @@ boolean K_PodiumSequence(void); boolean K_StartCeremony(void); +/*-------------------------------------------------- + void K_FinishCeremony(void); + + Called at the end of the podium cutscene, + displays the ranking screen and starts + accepting input. +--------------------------------------------------*/ + +void K_FinishCeremony(void); + + +/*-------------------------------------------------- + void K_ResetCeremony(void); + + Called on level load, to reset all of the + podium variables. +--------------------------------------------------*/ + +void K_ResetCeremony(void); + + /*-------------------------------------------------- void K_CeremonyTicker(boolean run); @@ -72,6 +93,34 @@ boolean K_StartCeremony(void); void K_CeremonyTicker(boolean run); +/*-------------------------------------------------- + void K_CeremonyResponder(event_t *ev); + + Responder function to be ran during the podium + cutscene mode gamestate. Handles key presses + ending the podium scene. + + Input Arguments:- + ev - The player input event. + + Return:- + true to end the podium cutscene and return + to the title screen, otherwise false. +--------------------------------------------------*/ + +boolean K_CeremonyResponder(event_t *ev); + + +/*-------------------------------------------------- + void K_CeremonyDrawer(void); + + Handles the ranking screen and other HUD for + the podium cutscene. +--------------------------------------------------*/ + +void K_CeremonyDrawer(void); + + #ifdef __cplusplus } // extern "C" #endif