Add team size indicator in scoreboard and through /team

This commit is contained in:
Corantin H 2024-06-16 16:37:45 +02:00
parent 447b44d290
commit 816c64235c
2 changed files with 37 additions and 16 deletions

View file

@ -273,9 +273,9 @@ void CScoreboard::RenderScoreboard(CUIRect Scoreboard, int Team, int CountStart,
FontSize = 16.0f; FontSize = 16.0f;
} }
const float ScoreOffset = Scoreboard.x + 10.0f + 10.0f; const float ScoreOffset = Scoreboard.x + 40.0f;
const float ScoreLength = TextRender()->TextWidth(FontSize, TimeScore ? "00:00:00" : "99999"); const float ScoreLength = TextRender()->TextWidth(FontSize, TimeScore ? "00:00:00" : "99999");
const float TeeOffset = ScoreOffset + ScoreLength + 15.0f; const float TeeOffset = ScoreOffset + ScoreLength + 20.0f;
const float TeeLength = 60.0f * TeeSizeMod; const float TeeLength = 60.0f * TeeSizeMod;
const float NameOffset = TeeOffset + TeeLength; const float NameOffset = TeeOffset + TeeLength;
const float NameLength = 300.0f - TeeLength; const float NameLength = 300.0f - TeeLength;
@ -302,8 +302,12 @@ void CScoreboard::RenderScoreboard(CUIRect Scoreboard, int Team, int CountStart,
// render player entries // render player entries
int CountRendered = 0; int CountRendered = 0;
int PrevDDTeam = -1; int PrevDDTeam = -1;
int CurrentDDTeamSize = 0;
char aBuf[64]; char aBuf[64];
int MaxTeamSize = m_pClient->Config()->m_SvMaxTeamSize;
float TeamStartY = 0;
for(int i = 0; i < MAX_CLIENTS; i++) for(int i = 0; i < MAX_CLIENTS; i++)
{ {
// make sure that we render the correct team // make sure that we render the correct team
@ -350,30 +354,42 @@ void CScoreboard::RenderScoreboard(CUIRect Scoreboard, int Team, int CountStart,
const ColorRGBA Color = GameClient()->GetDDTeamColor(DDTeam).WithAlpha(0.5f); const ColorRGBA Color = GameClient()->GetDDTeamColor(DDTeam).WithAlpha(0.5f);
int TeamRectCorners = 0; int TeamRectCorners = 0;
if(PrevDDTeam != DDTeam) if(PrevDDTeam != DDTeam)
{
TeamRectCorners |= IGraphics::CORNER_T; TeamRectCorners |= IGraphics::CORNER_T;
TeamStartY = Row.y;
}
if(NextDDTeam != DDTeam) if(NextDDTeam != DDTeam)
TeamRectCorners |= IGraphics::CORNER_B; TeamRectCorners |= IGraphics::CORNER_B;
RowAndSpacing.Draw(Color, TeamRectCorners, RoundRadius); RowAndSpacing.Draw(Color, TeamRectCorners, RoundRadius);
CurrentDDTeamSize++;
if(NextDDTeam != DDTeam) if(NextDDTeam != DDTeam)
{ {
const float TeamFontSize = FontSize / 1.5f; const float TeamFontSize = FontSize / 1.5f;
if(NumPlayers > 8) if(NumPlayers > 8)
{ {
if(DDTeam == TEAM_SUPER) if(DDTeam == TEAM_SUPER)
str_copy(aBuf, Localize("Super")); str_copy(aBuf, Localize("Super"));
else else if(CurrentDDTeamSize <= 1)
str_format(aBuf, sizeof(aBuf), "%d", DDTeam); str_format(aBuf, sizeof(aBuf), "%d", DDTeam);
TextRender()->Text(Row.x, Row.y + Row.h / 2.0f - TeamFontSize / 2.0f, TeamFontSize, aBuf); else
str_format(aBuf, sizeof(aBuf), Localize("%d\n(%d/%d)", "Team and size"), DDTeam, CurrentDDTeamSize, MaxTeamSize);
TextRender()->Text(Row.x, TeamStartY + Row.h / 2.0f - TeamFontSize / 2.0f, TeamFontSize, aBuf);
} }
else else
{ {
if(DDTeam == TEAM_SUPER) if(DDTeam == TEAM_SUPER)
str_copy(aBuf, Localize("Super")); str_copy(aBuf, Localize("Super"));
else if(CurrentDDTeamSize > 1)
str_format(aBuf, sizeof(aBuf), Localize("Team %d (%d/%d)"), DDTeam, CurrentDDTeamSize, MaxTeamSize);
else else
str_format(aBuf, sizeof(aBuf), Localize("Team %d"), DDTeam); str_format(aBuf, sizeof(aBuf), Localize("Team %d"), DDTeam);
TextRender()->Text(Row.x + Row.w / 2.0f - TextRender()->TextWidth(TeamFontSize, aBuf) / 2.0f + 10.0f, Row.y + Row.h, TeamFontSize, aBuf); TextRender()->Text(Row.x + Row.w / 2.0f - TextRender()->TextWidth(TeamFontSize, aBuf) / 2.0f + 10.0f, Row.y + Row.h, TeamFontSize, aBuf);
} }
CurrentDDTeamSize = 0;
} }
} }
PrevDDTeam = DDTeam; PrevDDTeam = DDTeam;
@ -383,9 +399,7 @@ void CScoreboard::RenderScoreboard(CUIRect Scoreboard, int Team, int CountStart,
(GameClient()->m_Snap.m_SpecInfo.m_SpectatorId == SPEC_FREEVIEW && pInfo->m_Local) || (GameClient()->m_Snap.m_SpecInfo.m_SpectatorId == SPEC_FREEVIEW && pInfo->m_Local) ||
(GameClient()->m_Snap.m_SpecInfo.m_Active && pInfo->m_ClientId == GameClient()->m_Snap.m_SpecInfo.m_SpectatorId)) (GameClient()->m_Snap.m_SpecInfo.m_Active && pInfo->m_ClientId == GameClient()->m_Snap.m_SpecInfo.m_SpectatorId))
{ {
CUIRect Highlight; Row.Draw(ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f), IGraphics::CORNER_ALL, RoundRadius);
Row.VMargin(10.0f, &Highlight);
Highlight.Draw(ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f), IGraphics::CORNER_ALL, RoundRadius);
} }
// score // score

View file

@ -1241,18 +1241,25 @@ void CGameContext::ConTeam(IConsole::IResult *pResult, void *pUserData)
char aBuf[512]; char aBuf[512];
if(!pPlayer->IsPlaying()) if(!pPlayer->IsPlaying())
{ {
pSelf->Console()->Print( pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chatresp", "You can't check your team while you are dead/a spectator.");
IConsole::OUTPUT_LEVEL_STANDARD,
"chatresp",
"You can't check your team while you are dead/a spectator.");
} }
else else
{ {
str_format( int TeamSize = 0;
aBuf, const int PlayerTeam = pSelf->GetDDRaceTeam(pResult->m_ClientId);
sizeof(aBuf),
"You are in team %d", // Count players in team
pSelf->GetDDRaceTeam(pResult->m_ClientId)); for(int ClientId = 0; ClientId < MAX_CLIENTS; ClientId++)
{
const CPlayer *pOtherPlayer = pSelf->m_apPlayers[ClientId];
if(!pOtherPlayer || !pOtherPlayer->IsPlaying())
continue;
if(pSelf->GetDDRaceTeam(ClientId) == PlayerTeam)
TeamSize++;
}
str_format(aBuf, sizeof(aBuf), "You are in team %d having %d %s", PlayerTeam, TeamSize, TeamSize > 1 ? "players" : "player");
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chatresp", aBuf); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chatresp", aBuf);
} }
} }