Merge branch 'titlecard-cecho' into 'master'

Titlecard CEcho

See merge request KartKrew/Kart!952
This commit is contained in:
James R 2023-03-01 17:21:13 +00:00
commit eab22f645c
7 changed files with 117 additions and 9 deletions

View file

@ -559,10 +559,7 @@ bool CallFunc_EndPrint(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Wo
(void)argC; (void)argC;
if (ACS_ActivatorIsLocal(thread) == true) if (ACS_ActivatorIsLocal(thread) == true)
{ HU_DoTitlecardCEcho(thread->printBuf.data());
HU_SetCEchoDuration(5);
HU_DoCEcho(thread->printBuf.data());
}
thread->printBuf.drop(); thread->printBuf.drop();
return false; return false;
@ -931,13 +928,11 @@ bool CallFunc_EndPrintBold(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM
(void)argV; (void)argV;
(void)argC; (void)argC;
HU_SetCEchoDuration(5); HU_DoTitlecardCEcho(thread->printBuf.data());
HU_DoCEcho(thread->printBuf.data());
thread->printBuf.drop(); thread->printBuf.drop();
return false; return false;
} }
/*-------------------------------------------------- /*--------------------------------------------------
bool CallFunc_PlayerTeam(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) bool CallFunc_PlayerTeam(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC)

View file

@ -103,7 +103,7 @@ Environment::Environment()
addCodeDataACS0(120, {"", 0, addCallFunc(CallFunc_PlayerRings)}); addCodeDataACS0(120, {"", 0, addCallFunc(CallFunc_PlayerRings)});
addCodeDataACS0(122, {"", 0, addCallFunc(CallFunc_PlayerScore)}); addCodeDataACS0(122, {"", 0, addCallFunc(CallFunc_PlayerScore)});
// 136 to 137: Implemented by ACSVM // 136 to 137: Implemented by ACSVM
// 157: Implemented by ACSVM // 157: Implemented by ACSVM

View file

@ -3106,6 +3106,7 @@ void G_ExitLevel(void)
// Remove CEcho text on round end. // Remove CEcho text on round end.
HU_ClearCEcho(); HU_ClearCEcho();
HU_ClearTitlecardCEcho();
// Don't save demos immediately here! Let standings write first // Don't save demos immediately here! Let standings write first
} }
@ -4085,6 +4086,7 @@ void G_AfterIntermission(void)
gamecomplete = 1; gamecomplete = 1;
HU_ClearCEcho(); HU_ClearCEcho();
HU_ClearTitlecardCEcho();
if (demo.playback) if (demo.playback)
{ {

View file

@ -161,6 +161,11 @@ static tic_t cechotimer = 0;
static tic_t cechoduration = 5*TICRATE; static tic_t cechoduration = 5*TICRATE;
static INT32 cechoflags = 0; static INT32 cechoflags = 0;
static char tcechotext[1024]; // buffer for the titlecard text
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 tic_t resynch_ticker = 0;
static huddrawlist_h luahuddrawlist_scores; static huddrawlist_h luahuddrawlist_scores;
@ -1033,6 +1038,13 @@ void HU_Ticker(void)
if (cechotimer) if (cechotimer)
cechotimer--; cechotimer--;
if (tcechotimer)
{
tcechotimer++;
if (tcechotimer > tcechoduration)
tcechotimer = 0;
}
if (gamestate != GS_LEVEL) if (gamestate != GS_LEVEL)
{ {
@ -1996,6 +2008,66 @@ static void HU_DrawCEcho(void)
} }
} }
static void HU_DrawTitlecardCEcho(void)
{
if (tcechotimer)
{
INT32 i = 0;
INT32 y = (BASEVIDHEIGHT/2)-16;
INT32 pnumlines = 0;
INT32 timeroffset = 0;
char *line;
char *echoptr;
char temp[1024];
for (i = 0; tcechotext[i] != '\0'; ++i)
if (tcechotext[i] == '\\')
pnumlines++;
y -= (pnumlines-1)*16;
// Prevent crashing because I'm sick of this
if (y < 0)
{
CONS_Alert(CONS_WARNING, "CEcho contained too many lines, not displaying\n");
cechotimer = 0;
return;
}
strcpy(temp, tcechotext);
echoptr = &temp[0];
while (*echoptr != '\0')
{
INT32 w;
INT32 timer = (INT32)(tcechotimer - timeroffset);
if (timer <= 0)
return; // we don't care.
line = strchr(echoptr, '\\');
if (line == NULL)
break;
*line = '\0';
w = V_TitleCardStringWidth(echoptr);
V_DrawTitleCardString(BASEVIDWIDTH/2 -w/2, y, echoptr, 0, false, timer, TICRATE*4);
y += 32;
// offset the timer for the next line.
timeroffset += strlen(echoptr);
// set the ptr to the \0 we made and advance it because we don't want an empty string.
echoptr = line;
echoptr++;
}
}
}
// //
// demo info stuff // demo info stuff
// //
@ -2137,6 +2209,9 @@ drawontop:
if (cechotimer) if (cechotimer)
HU_DrawCEcho(); HU_DrawCEcho();
if (tcechotimer)
HU_DrawTitlecardCEcho();
} }
//====================================================================== //======================================================================
@ -2590,3 +2665,22 @@ void HU_DoCEcho(const char *msg)
cechotext[sizeof(cechotext) - 1] = '\0'; cechotext[sizeof(cechotext) - 1] = '\0';
cechotimer = cechoduration; 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));
strncat(tcechotext, "\\", sizeof(tcechotext) - strlen(tcechotext) - 1);
tcechotext[sizeof(tcechotext) - 1] = '\0';
tcechotimer = 1;
tcechoduration = TICRATE*6 + strlen(tcechotext);
}

View file

@ -154,6 +154,10 @@ void HU_SetCEchoDuration(INT32 seconds);
void HU_SetCEchoFlags(INT32 flags); void HU_SetCEchoFlags(INT32 flags);
void HU_DoCEcho(const char *msg); void HU_DoCEcho(const char *msg);
// Titlecard CECHO shite
void HU_DoTitlecardCEcho(const char *msg);
void HU_ClearTitlecardCEcho(void);
// Demo playback info // Demo playback info
extern UINT32 hu_demotime; extern UINT32 hu_demotime;
extern UINT32 hu_demolap; extern UINT32 hu_demolap;

View file

@ -35,6 +35,7 @@
#include "k_menu.h" // Player Setup menu color stuff #include "k_menu.h" // Player Setup menu color stuff
#include "p_spec.h" // P_StartQuake #include "p_spec.h" // P_StartQuake
#include "i_system.h" // I_GetPreciseTime, I_GetPrecisePrecision #include "i_system.h" // I_GetPreciseTime, I_GetPrecisePrecision
#include "hu_stuff.h" // for the cecho
#include "lua_script.h" #include "lua_script.h"
#include "lua_libs.h" #include "lua_libs.h"
@ -3879,6 +3880,14 @@ static int lib_getTimeMicros(lua_State *L)
return 1; 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[] = { static luaL_Reg lib[] = {
{"print", lib_print}, {"print", lib_print},
{"chatprint", lib_chatprint}, {"chatprint", lib_chatprint},
@ -4160,7 +4169,10 @@ static luaL_Reg lib[] = {
{"K_InitBossHealthBar", lib_kInitBossHealthBar}, {"K_InitBossHealthBar", lib_kInitBossHealthBar},
{"K_UpdateBossHealthBar", lib_kUpdateBossHealthBar}, {"K_UpdateBossHealthBar", lib_kUpdateBossHealthBar},
{"K_DeclareWeakspot", lib_kDeclareWeakspot}, {"K_DeclareWeakspot", lib_kDeclareWeakspot},
// hu_stuff technically?
{"HU_DoTitlecardCEcho", lib_startTitlecardCecho},
{NULL, NULL} {NULL, NULL}
}; };

View file

@ -7514,6 +7514,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
// Clear CECHO messages // Clear CECHO messages
HU_ClearCEcho(); HU_ClearCEcho();
HU_ClearTitlecardCEcho();
if (mapheaderinfo[gamemap-1]->runsoc[0] != '#') if (mapheaderinfo[gamemap-1]->runsoc[0] != '#')
P_RunSOC(mapheaderinfo[gamemap-1]->runsoc); P_RunSOC(mapheaderinfo[gamemap-1]->runsoc);