Merge pull request #2038 from Dune-jr/fix-spectatornotif

Adjust spectator notification to show up for non-empty servers only
This commit is contained in:
oy 2019-02-21 08:29:52 +01:00 committed by GitHub
commit c3a0afe1fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -674,10 +674,19 @@ void CHud::RenderSpectatorNotification()
if(m_pClient->m_aClients[m_pClient->m_LocalClientID].m_Team == TEAM_SPECTATORS && if(m_pClient->m_aClients[m_pClient->m_LocalClientID].m_Team == TEAM_SPECTATORS &&
m_pClient->m_TeamChangeTime + 5.0f >= Client()->LocalTime()) m_pClient->m_TeamChangeTime + 5.0f >= Client()->LocalTime())
{ {
const char *pText = Localize("Click on a player or a flag to follow it"); // count non spectators
float FontSize = 16.0f; int NumPlayers = 0;
float w = TextRender()->TextWidth(0, FontSize, pText, -1); for(int i = 0; i < MAX_CLIENTS; i++)
TextRender()->Text(0, 150 * Graphics()->ScreenAspect() + -w / 2, 30, FontSize, pText, -1); if(m_pClient->m_aClients[i].m_Active && m_pClient->m_aClients[i].m_Team != TEAM_SPECTATORS)
NumPlayers++;
if(NumPlayers > 0)
{
const char *pText = Localize("Click on a player or a flag to follow it");
float FontSize = 16.0f;
float w = TextRender()->TextWidth(0, FontSize, pText, -1);
TextRender()->Text(0, 150 * Graphics()->ScreenAspect() + -w / 2, 30, FontSize, pText, -1);
}
} }
} }