Titlecard CEcho

This commit is contained in:
Lat 2023-02-21 16:16:34 +01:00
parent c41d0dee32
commit d755d6edb9
8 changed files with 105 additions and 2 deletions

View file

@ -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)

View file

@ -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);

View file

@ -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

View file

@ -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)
{

View file

@ -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);
}

View file

@ -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;

View file

@ -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}
};

View file

@ -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);