Improve handling of team lives labels

The lives counter check is now always run, and team name is displayed in its place when its false.
This commit is contained in:
Sally Coolatta 2023-07-24 06:09:50 -04:00
parent a9d0630b15
commit 84e448eb63

View file

@ -815,7 +815,7 @@ static inline void ST_drawRings(void)
static void ST_drawLivesArea(void)
{
INT32 v_colmap = V_YELLOWMAP, livescount;
boolean notgreyedout;
boolean notgreyedout = false;
if (!stplyr->skincolor)
return; // Just joined a server, skin isn't loaded yet!
@ -868,39 +868,36 @@ static void ST_drawLivesArea(void)
if (metalrecording)
{
if (((2*leveltime)/TICRATE) & 1)
{
V_DrawRightAlignedString(hudinfo[HUD_LIVES].x+58, hudinfo[HUD_LIVES].y+8,
hudinfo[HUD_LIVES].f|V_PERPLAYER|V_REDMAP|V_HUDTRANS, "REC");
}
}
// Spectator
else if (stplyr->spectator)
{
v_colmap = V_GRAYMAP;
// Tag
else if (gametyperules & GTR_TAG)
{
if (stplyr->pflags & PF_TAGIT)
{
V_DrawRightAlignedString(hudinfo[HUD_LIVES].x+58, hudinfo[HUD_LIVES].y+8, V_HUDTRANS|hudinfo[HUD_LIVES].f|V_PERPLAYER, "IT!");
v_colmap = V_ORANGEMAP;
}
}
// Team name
else if (G_GametypeHasTeams() && !(gametyperules & GTR_LIVES))
{
if (stplyr->ctfteam == 1)
{
V_DrawRightAlignedString(hudinfo[HUD_LIVES].x+58, hudinfo[HUD_LIVES].y+8, V_HUDTRANS|hudinfo[HUD_LIVES].f|V_PERPLAYER, "RED");
v_colmap = V_REDMAP;
}
else if (stplyr->ctfteam == 2)
{
V_DrawRightAlignedString(hudinfo[HUD_LIVES].x+58, hudinfo[HUD_LIVES].y+8, V_HUDTRANS|hudinfo[HUD_LIVES].f|V_PERPLAYER, "BLUE");
v_colmap = V_BLUEMAP;
}
}
// Lives number
else
{
boolean candrawlives = true;
boolean candrawlives = false;
// Set the player's name color.
if (G_TagGametype() && (stplyr->pflags & PF_TAGIT))
{
v_colmap = V_ORANGEMAP;
}
else if (G_GametypeHasTeams())
{
if (stplyr->ctfteam == 1)
{
v_colmap = V_REDMAP;
}
else if (stplyr->ctfteam == 2)
{
v_colmap = V_BLUEMAP;
}
}
// Co-op and Competition, normal life counter
if (G_GametypeUsesLives())
@ -936,12 +933,15 @@ static void ST_drawLivesArea(void)
livescount = (((netgame || multiplayer) && G_GametypeUsesCoopLives() && cv_cooplives.value == 0) ? INFLIVES : stplyr->lives);
notgreyedout = true;
}
candrawlives = true;
}
// Infinity symbol (Race)
else if (G_PlatformGametype() && !(gametyperules & GTR_LIVES))
{
livescount = INFLIVES;
notgreyedout = true;
candrawlives = true;
}
// Otherwise nothing, sorry.
// Special Stages keep not showing lives,
@ -950,8 +950,6 @@ static void ST_drawLivesArea(void)
// cannot show up because Special Stages
// still have the GTR_LIVES gametype rule
// by default.
else
candrawlives = false;
// Draw the lives counter here.
if (candrawlives)
@ -959,8 +957,10 @@ static void ST_drawLivesArea(void)
// x
V_DrawScaledPatch(hudinfo[HUD_LIVES].x+22, hudinfo[HUD_LIVES].y+10, hudinfo[HUD_LIVES].f|V_PERPLAYER|V_HUDTRANS, stlivex);
if (livescount == INFLIVES)
{
V_DrawCharacter(hudinfo[HUD_LIVES].x+50, hudinfo[HUD_LIVES].y+8,
'\x16' | 0x80 | hudinfo[HUD_LIVES].f|V_PERPLAYER|V_HUDTRANS, false);
}
else
{
if (stplyr->playerstate == PST_DEAD && !(stplyr->spectator) && (livescount || stplyr->deadtimer < (TICRATE<<1)) && !(stplyr->pflags & PF_FINISHED))
@ -971,6 +971,25 @@ static void ST_drawLivesArea(void)
hudinfo[HUD_LIVES].f|V_PERPLAYER|(notgreyedout ? V_HUDTRANS : V_HUDTRANSHALF), va("%d",livescount));
}
}
else
{
// Draw team name instead of lives, if possible.
if (G_TagGametype() && (stplyr->pflags & PF_TAGIT))
{
V_DrawRightAlignedString(hudinfo[HUD_LIVES].x+58, hudinfo[HUD_LIVES].y+8, V_HUDTRANS|hudinfo[HUD_LIVES].f|V_PERPLAYER, "IT!");
}
else if (G_GametypeHasTeams())
{
if (stplyr->ctfteam == 1)
{
V_DrawRightAlignedString(hudinfo[HUD_LIVES].x+58, hudinfo[HUD_LIVES].y+8, V_HUDTRANS|hudinfo[HUD_LIVES].f|V_PERPLAYER, "RED");
}
else if (stplyr->ctfteam == 2)
{
V_DrawRightAlignedString(hudinfo[HUD_LIVES].x+58, hudinfo[HUD_LIVES].y+8, V_HUDTRANS|hudinfo[HUD_LIVES].f|V_PERPLAYER, "BLUE");
}
}
}
#undef ST_drawLivesX
}