Permalink
Browse files

show a notification "click a player or flag to follow it" when joinin…

…g spectator
  • Loading branch information...
oy committed Dec 2, 2018
1 parent 814c762 commit c5af2a77a5ff013f383e8975e275f421cbb65d3f
@@ -662,6 +662,18 @@ void CHud::RenderSpectatorHud()
TextRender()->TextEx(&Cursor, aBuf, -1);
}

void CHud::RenderSpectatorNotification()
{
if(m_pClient->m_aClients[m_pClient->m_LocalClientID].m_Team == TEAM_SPECTATORS &&
m_pClient->m_TeamChangeTime + 5.0f >= Client()->LocalTime())
{
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);
}
}

void CHud::OnRender()
{
if(!m_pClient->m_Snap.m_pGameData)
@@ -684,6 +696,7 @@ void CHud::OnRender()
if(m_pClient->m_Snap.m_SpecInfo.m_SpectatorID != -1)
RenderHealthAndAmmo(&m_pClient->m_Snap.m_aCharacters[m_pClient->m_Snap.m_SpecInfo.m_SpectatorID].m_Cur);
RenderSpectatorHud();
RenderSpectatorNotification();
}

RenderGameTimer();
@@ -25,6 +25,7 @@ class CHud : public CComponent
void RenderSuddenDeath();
void RenderScoreHud();
void RenderSpectatorHud();
void RenderSpectatorNotification();
void RenderWarmupTimer();
public:
CHud();
@@ -367,6 +367,7 @@ void CGameClient::OnReset()

m_LocalClientID = -1;
m_TeamCooldownTick = 0;
m_TeamChangeTime = 0.0f;
mem_zero(&m_GameInfo, sizeof(m_GameInfo));
m_DemoSpecMode = SPEC_FREEVIEW;
m_DemoSpecID = -1;
@@ -623,6 +624,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
return;
}
m_LocalClientID = pMsg->m_ClientID;
m_TeamChangeTime = Client()->LocalTime();
}
else
{
@@ -744,6 +746,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)

if(pMsg->m_ClientID == m_LocalClientID)
m_TeamCooldownTick = pMsg->m_CooldownTick;
m_TeamChangeTime = Client()->LocalTime();
}

if(pMsg->m_Silent == 0)
@@ -195,6 +195,7 @@ class CGameClient : public IGameClient
int m_LocalClientID;
int m_TeamCooldownTick;
bool m_MuteServerBroadcast;
float m_TeamChangeTime;

struct CGameInfo
{

0 comments on commit c5af2a7

Please sign in to comment.