From 93f151fec92767cd0173204ce5403eba86f73165 Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 1 Mar 2023 15:27:48 +0000 Subject: [PATCH] Director HUD: Do a bit of cleanup - Add "Join" on L button. - "Becomes ". . .", "Cancel join", and has "[i/n]" appended (where n is cap and i is number of players in game) - Add colorisation when Director is active - Make an attempt at fixing splitscreen (I wasn't able to get director to ACTIVATE in splitscreen with two local clients so it's frustratingly untested) --- src/k_hud.c | 63 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 9 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index d53a39d95..683040065 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -4639,16 +4639,26 @@ K_drawMiniPing (void) } } -static void K_DrawDirectorButton(INT32 idx, const char *label, patch_t *kp[2]) +static void K_DrawDirectorButton(INT32 idx, const char *label, patch_t *kp[2], INT32 textflags) { - const INT32 flags = V_SNAPTORIGHT | V_SLIDEIN; - const INT32 textflags = flags | V_6WIDTHSPACE | V_ALLOWLOWERCASE; + INT32 flags = V_SNAPTORIGHT | V_SLIDEIN | V_SPLITSCREEN; 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); + INT32 x = (BASEVIDWIDTH/2) - 10; + INT32 y = (idx * 16); + + if (r_splitscreen <= 1) + { + x = BASEVIDWIDTH - 60; + if (r_splitscreen == 0) + { + y += BASEVIDHEIGHT - 78; + } + } + + textflags |= (flags | V_6WIDTHSPACE | V_ALLOWLOWERCASE); V_DrawScaledPatch(x, y - 4, flags, kp[anim]); V_DrawRightAlignedThinString(x - 2, y, textflags, label); @@ -4656,14 +4666,49 @@ static void K_DrawDirectorButton(INT32 idx, const char *label, patch_t *kp[2]) static void K_drawDirectorHUD(void) { + const INT32 p = (splitscreen_partied[consoleplayer] ? splitscreen_party[consoleplayer] : g_localplayers)[R_GetViewNumber()]; + const char *itemtxt = "Join"; + UINT8 offs = 0; + + UINT8 numingame = 0; + UINT8 i; + 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); + for (i = 0; i < MAXPLAYERS; i++) + if (playeringame[i] && !players[i].spectator) + numingame++; + + if (numingame > 1 && r_splitscreen == 0) // simplifies things a lot + { + K_DrawDirectorButton(1, "Next Player", kp_button_a[0], 0); + K_DrawDirectorButton(2, "Prev Player", kp_button_x[0], 0); + offs = 2; + } + else + + if (p == -1 || !playeringame[p] || players[p].spectator == false) + { + return; + } + + K_DrawDirectorButton(offs + 1, "Director", kp_button_r, + (directorinfo.active ? V_YELLOWMAP : 0)); + + if (players[p].flashing) + itemtxt = ". . ."; + else if (players[p].pflags & PF_WANTSTOJOIN) + itemtxt = "Cancel Join"; + + if (cv_maxplayers.value) + { + itemtxt = va("%s [%d/%d]", itemtxt, numingame, cv_maxplayers.value); + } + + K_DrawDirectorButton(0, itemtxt, kp_button_l, 0); } static void K_drawDistributionDebugger(void) @@ -4984,7 +5029,7 @@ void K_drawKartHUD(void) K_drawMiniPing(); } - if (displayplayers[viewnum] != g_localplayers[viewnum]) + if (displayplayers[viewnum] != g_localplayers[viewnum] && !demo.playback) { K_drawDirectorHUD(); }