From d755d6edb9d2ff2e911504732de2bef5fd6f815d Mon Sep 17 00:00:00 2001 From: Lat Date: Tue, 21 Feb 2023 16:16:34 +0100 Subject: [PATCH] Titlecard CEcho --- src/acs/call-funcs.cpp | 36 ++++++++++++++++++++++++++++++++++++ src/acs/call-funcs.hpp | 2 ++ src/acs/environment.cpp | 7 ++++++- src/g_game.c | 2 ++ src/hu_stuff.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/hu_stuff.h | 4 ++++ src/lua_baselib.c | 14 +++++++++++++- src/p_setup.c | 1 + 8 files changed, 105 insertions(+), 2 deletions(-) diff --git a/src/acs/call-funcs.cpp b/src/acs/call-funcs.cpp index 3e7ca5040..780455f07 100644 --- a/src/acs/call-funcs.cpp +++ b/src/acs/call-funcs.cpp @@ -565,6 +565,25 @@ bool CallFunc_EndPrint(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Wo return false; } +/*-------------------------------------------------- + bool CallFunc_EndPrintTitlecard(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) + + One of the ACS wrappers for Titlecard CEcho. This + version only prints if the activator is a + display player. +--------------------------------------------------*/ +bool CallFunc_EndPrintTitlecard(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) +{ + (void)argV; + (void)argC; + + if (ACS_ActivatorIsLocal(thread) == true) + HU_DoTitlecardCEcho(thread->printBuf.data()); + + thread->printBuf.drop(); + return false; +} + /*-------------------------------------------------- bool CallFunc_PlayerCount(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) @@ -935,6 +954,23 @@ bool CallFunc_EndPrintBold(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM return false; } +/*-------------------------------------------------- + bool CallFunc_EndPrintBoldTitlecard(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) + + One of the ACS wrappers for Titlecard CEcho. This + version prints for all players. +--------------------------------------------------*/ +bool CallFunc_EndPrintBoldTitlecard(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) +{ + (void)argV; + (void)argC; + + HU_DoTitlecardCEcho(thread->printBuf.data()); + + thread->printBuf.drop(); + return false; +} + /*-------------------------------------------------- bool CallFunc_PlayerTeam(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) diff --git a/src/acs/call-funcs.hpp b/src/acs/call-funcs.hpp index 4bbe3eaec..9e634c0d9 100644 --- a/src/acs/call-funcs.hpp +++ b/src/acs/call-funcs.hpp @@ -55,6 +55,7 @@ bool CallFunc_ChangeCeiling(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSV bool CallFunc_LineSide(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_ClearLineSpecial(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_EndPrint(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); +bool CallFunc_EndPrintTitlecard(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_PlayerCount(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_GameType(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_GameSpeed(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); @@ -65,6 +66,7 @@ bool CallFunc_SetLineTexture(ACSVM::Thread *thread, const ACSVM::Word *argV, ACS bool CallFunc_SetLineSpecial(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_ThingSound(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_EndPrintBold(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); +bool CallFunc_EndPrintBoldTitlecard(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_PlayerTeam(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_PlayerRings(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_PlayerScore(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); diff --git a/src/acs/environment.cpp b/src/acs/environment.cpp index ad593e74b..28078967d 100644 --- a/src/acs/environment.cpp +++ b/src/acs/environment.cpp @@ -100,7 +100,12 @@ Environment::Environment() addCodeDataACS0(120, {"", 0, addCallFunc(CallFunc_PlayerRings)}); addCodeDataACS0(122, {"", 0, addCallFunc(CallFunc_PlayerScore)}); - + + // Lat: Titlecard CEcho. I'm not sure if I should be putting it here. + // @TODO: Confirm this is fine? + addCodeDataACS0( 123, {"", 0, addCallFunc(CallFunc_EndPrintTitlecard)}); + addCodeDataACS0( 124, {"", 0, addCallFunc(CallFunc_EndPrintBoldTitlecard)}); + // 136 to 137: Implemented by ACSVM // 157: Implemented by ACSVM diff --git a/src/g_game.c b/src/g_game.c index ecf088eaf..4ff66a88c 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3145,6 +3145,7 @@ void G_ExitLevel(void) // Remove CEcho text on round end. HU_ClearCEcho(); + HU_ClearTitlecardCEcho(); // Don't save demos immediately here! Let standings write first } @@ -4124,6 +4125,7 @@ void G_AfterIntermission(void) gamecomplete = 1; HU_ClearCEcho(); + HU_ClearTitlecardCEcho(); if (demo.playback) { diff --git a/src/hu_stuff.c b/src/hu_stuff.c index a457fe774..8521049a8 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -161,6 +161,11 @@ static tic_t cechotimer = 0; static tic_t cechoduration = 5*TICRATE; static INT32 cechoflags = 0; +static char tcechotext[48]; // the text is wide so only 48 chars should do. +static tic_t tcechotimer = 0; // goes up by 1 each frame this is active +static tic_t tcechoduration = 0; // Set automatically + + static tic_t resynch_ticker = 0; static huddrawlist_h luahuddrawlist_scores; @@ -1035,6 +1040,13 @@ void HU_Ticker(void) if (cechotimer) cechotimer--; + + if (tcechotimer) + { + tcechotimer++; + if (tcechotimer > tcechoduration) + tcechotimer = 0; + } if (gamestate != GS_LEVEL) { @@ -2000,6 +2012,15 @@ static void HU_DrawCEcho(void) } } +static void HU_DrawTitlecardCEcho(void) +{ + if (tcechotimer) + { + INT32 w = V_TitleCardStringWidth(tcechotext); + V_DrawTitleCardString(160 -w/2, 90, tcechotext, 0, false, tcechotimer, TICRATE*4); + } +} + // // demo info stuff // @@ -2145,6 +2166,9 @@ drawontop: if (cechotimer) HU_DrawCEcho(); + + if (tcechotimer) + HU_DrawTitlecardCEcho(); } //====================================================================== @@ -2598,3 +2622,20 @@ void HU_DoCEcho(const char *msg) cechotext[sizeof(cechotext) - 1] = '\0'; cechotimer = cechoduration; } + +// Simply set the timer to 0 to clear it. +// No need to bother clearing the buffer or anything. +void HU_ClearTitlecardCEcho(void) +{ + tcechotimer = 0; +} + +// Similar but for titlecard CEcho and also way less convoluted because I have no clue whatever the fuck they were trying above. +void HU_DoTitlecardCEcho(const char *msg) +{ + I_OutputMsg("%s\n", msg); // print to log + + strncpy(tcechotext, msg, sizeof(tcechotext)); + tcechotimer = 1; + tcechoduration = TICRATE*6 + strlen(tcechotext); +} \ No newline at end of file diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 3e8233020..144e0e557 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -153,6 +153,10 @@ void HU_SetCEchoDuration(INT32 seconds); void HU_SetCEchoFlags(INT32 flags); void HU_DoCEcho(const char *msg); +// Titlecard CECHO shite +void HU_DoTitlecardCEcho(const char *msg); +void HU_ClearTitlecardCEcho(void); + // Demo playback info extern UINT32 hu_demotime; extern UINT32 hu_demolap; diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 4dead2615..654dc71d0 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -35,6 +35,7 @@ #include "k_menu.h" // Player Setup menu color stuff #include "p_spec.h" // P_StartQuake #include "i_system.h" // I_GetPreciseTime, I_GetPrecisePrecision +#include "hu_stuff.h" // for the cecho #include "lua_script.h" #include "lua_libs.h" @@ -3879,6 +3880,14 @@ static int lib_getTimeMicros(lua_State *L) return 1; } +static int lib_startTitlecardCecho(lua_State *L) +{ + const char *str = luaL_checkstring(L, 1); + HU_DoTitlecardCEcho(str); + + return 1; +} + static luaL_Reg lib[] = { {"print", lib_print}, {"chatprint", lib_chatprint}, @@ -4160,7 +4169,10 @@ static luaL_Reg lib[] = { {"K_InitBossHealthBar", lib_kInitBossHealthBar}, {"K_UpdateBossHealthBar", lib_kUpdateBossHealthBar}, {"K_DeclareWeakspot", lib_kDeclareWeakspot}, - + + // hu_stuff technically? + {"HU_DoTitlecardCEcho", lib_startTitlecardCecho}, + {NULL, NULL} }; diff --git a/src/p_setup.c b/src/p_setup.c index bedb39c78..ebc3a40cd 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -7515,6 +7515,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) // Clear CECHO messages HU_ClearCEcho(); + HU_ClearTitlecardCEcho(); if (mapheaderinfo[gamemap-1]->runsoc[0] != '#') P_RunSOC(mapheaderinfo[gamemap-1]->runsoc);