From 5f1e64d6d9050dc74e42e9cf88f46c944789401d Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 26 Feb 2023 02:27:25 -0800 Subject: [PATCH] Add spectator HUD for A, X, R buttons Old spectator HUD is preserved for empty game, "flying around" mode. --- src/k_hud.c | 32 ++++++++++++++++++++++++++++++++ src/st_stuff.c | 4 +++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/k_hud.c b/src/k_hud.c index 2edb1f3d5..d53a39d95 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -4639,6 +4639,33 @@ K_drawMiniPing (void) } } +static void K_DrawDirectorButton(INT32 idx, const char *label, patch_t *kp[2]) +{ + const INT32 flags = V_SNAPTORIGHT | V_SLIDEIN; + const INT32 textflags = flags | V_6WIDTHSPACE | V_ALLOWLOWERCASE; + + const UINT8 anim_duration = 16; + const UINT8 anim = (leveltime % (anim_duration * 2)) < anim_duration; + + const INT32 x = BASEVIDWIDTH - 60; + const INT32 y = BASEVIDHEIGHT - 70 + (idx * 16); + + V_DrawScaledPatch(x, y - 4, flags, kp[anim]); + V_DrawRightAlignedThinString(x - 2, y, textflags, label); +} + +static void K_drawDirectorHUD(void) +{ + if (!LUA_HudEnabled(hud_textspectator)) + { + return; + } + + K_DrawDirectorButton(0, "Next Player", kp_button_a[0]); + K_DrawDirectorButton(1, "Prev Player", kp_button_x[0]); + K_DrawDirectorButton(2, "Director", kp_button_r); +} + static void K_drawDistributionDebugger(void) { itemroulette_t rouletteData = {0}; @@ -4957,6 +4984,11 @@ void K_drawKartHUD(void) K_drawMiniPing(); } + if (displayplayers[viewnum] != g_localplayers[viewnum]) + { + K_drawDirectorHUD(); + } + if (cv_kartdebugdistribution.value) K_drawDistributionDebugger(); diff --git a/src/st_stuff.c b/src/st_stuff.c index 01350c6ce..289a6c3a7 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -1095,6 +1095,8 @@ void ST_preLevelTitleCardDrawer(void) // static void ST_overlayDrawer(void) { + const UINT8 viewnum = R_GetViewNumber(); + // hu_showscores = auto hide score/time/rings when tab rankings are shown if (!(hu_showscores && (netgame || multiplayer))) { @@ -1135,7 +1137,7 @@ static void ST_overlayDrawer(void) if (!hu_showscores && netgame && !mapreset) { - if (stplyr->spectator && LUA_HudEnabled(hud_textspectator)) + if (stplyr->spectator && displayplayers[viewnum] == g_localplayers[viewnum] && LUA_HudEnabled(hud_textspectator)) { const char *itemtxt = M_GetText("Item - Join Game");