Skip to content

Commit

Permalink
Add team size indicator in scoreboard
Browse files Browse the repository at this point in the history
  • Loading branch information
archimede67 committed Jun 16, 2024
1 parent 4b08c8c commit 30b7659
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/game/client/components/scoreboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
rendered = -24;

int OldDDTeam = -1;
int CurrentDDTeamSize = 0;

for(int i = 0; i < MAX_CLIENTS; i++)
{
Expand Down Expand Up @@ -363,6 +364,8 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
Corners |= IGraphics::CORNER_BL | IGraphics::CORNER_BR;
Graphics()->DrawRect(x - 10.0f, y, w, LineHeight + Spacing, Color, Corners, RoundRadius);

CurrentDDTeamSize++;

if(NextDDTeam != DDTeam)
{
if(m_pClient->m_Snap.m_aTeamSize[0] > 8)
Expand All @@ -385,6 +388,21 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
Cursor.m_LineWidth = NameLength + 3;
}
TextRender()->TextEx(&Cursor, aBuf, -1);

// Render team size number when team contains more than 1 player
// Number is rendered at the beginning of the team in the scoreboard, while team number
// is rendered at the end of the team
if(CurrentDDTeamSize > 1)
{
str_format(aBuf, sizeof(aBuf), "%d", CurrentDDTeamSize);
CTextCursor TeamSizeCursor = Cursor;
TeamSizeCursor.m_LineWidth = 2;
float Offset = m_pClient->m_Snap.m_aTeamSize[0] > 8 ? FontSize - FontSize / 1.5f : FontSize;
TextRender()->SetCursor(&TeamSizeCursor, x - 10.0f, y - (LineHeight + Spacing) * (CurrentDDTeamSize - 1) + Offset, FontSize / 1.5f, TEXTFLAG_RENDER);
TextRender()->TextEx(&TeamSizeCursor, aBuf, -1);
}

CurrentDDTeamSize = 0;
}
}

Expand Down Expand Up @@ -635,7 +653,7 @@ void CScoreboard::OnRender()
TextRender()->Text(Width / 2 - TextWidth / 2, 39, 86.0f, aText, -1.0f);
}

//decrease width, because team games use additional offsets
// decrease width, because team games use additional offsets
w -= 10.0f;

int NumPlayers = maximum(m_pClient->m_Snap.m_aTeamSize[TEAM_RED], m_pClient->m_Snap.m_aTeamSize[TEAM_BLUE]);
Expand Down

0 comments on commit 30b7659

Please sign in to comment.