Merge branch 'director-bugs' into 'master'

Director spectator bugfixes

See merge request KartKrew/Kart!993
This commit is contained in:
toaster 2023-03-01 16:16:51 +00:00
commit 2e55d35ead
3 changed files with 69 additions and 16 deletions

View file

@ -1179,9 +1179,18 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
K_ToggleDirector(false);
}
if (M_MenuButtonPressed(forplayer, MBT_R))
if (player->spectator == true)
{
K_ToggleDirector(true);
// duplication of fire
if (G_PlayerInputDown(forplayer, gc_item, 0))
{
cmd->buttons |= BT_ATTACK;
}
if (M_MenuButtonPressed(forplayer, MBT_R))
{
K_ToggleDirector(true);
}
}
goto aftercmdinput;

View file

@ -110,16 +110,16 @@ static boolean K_CanSwitchDirector(void)
return false;
}
if (!directorinfo.active)
{
return false;
}
return true;
}
static void K_DirectorSwitch(INT32 player, boolean force)
{
if (!directorinfo.active)
{
return;
}
if (P_IsDisplayPlayer(&players[player]))
{
return;

View file

@ -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,48 @@ 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;
}
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 +5028,7 @@ void K_drawKartHUD(void)
K_drawMiniPing();
}
if (displayplayers[viewnum] != g_localplayers[viewnum])
if (displayplayers[viewnum] != g_localplayers[viewnum] && !demo.playback)
{
K_drawDirectorHUD();
}