Skip to content

Commit c5af2a7

Browse files
committed
show a notification "click a player or flag to follow it" when joining spectator
1 parent 814c762 commit c5af2a7

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

src/game/client/components/hud.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,18 @@ void CHud::RenderSpectatorHud()
662662
TextRender()->TextEx(&Cursor, aBuf, -1);
663663
}
664664

665+
void CHud::RenderSpectatorNotification()
666+
{
667+
if(m_pClient->m_aClients[m_pClient->m_LocalClientID].m_Team == TEAM_SPECTATORS &&
668+
m_pClient->m_TeamChangeTime + 5.0f >= Client()->LocalTime())
669+
{
670+
const char *pText = Localize("Click on a player or a flag to follow it");
671+
float FontSize = 16.0f;
672+
float w = TextRender()->TextWidth(0, FontSize, pText, -1);
673+
TextRender()->Text(0, 150 * Graphics()->ScreenAspect() + -w / 2, 30, FontSize, pText, -1);
674+
}
675+
}
676+
665677
void CHud::OnRender()
666678
{
667679
if(!m_pClient->m_Snap.m_pGameData)
@@ -684,6 +696,7 @@ void CHud::OnRender()
684696
if(m_pClient->m_Snap.m_SpecInfo.m_SpectatorID != -1)
685697
RenderHealthAndAmmo(&m_pClient->m_Snap.m_aCharacters[m_pClient->m_Snap.m_SpecInfo.m_SpectatorID].m_Cur);
686698
RenderSpectatorHud();
699+
RenderSpectatorNotification();
687700
}
688701

689702
RenderGameTimer();

src/game/client/components/hud.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class CHud : public CComponent
2525
void RenderSuddenDeath();
2626
void RenderScoreHud();
2727
void RenderSpectatorHud();
28+
void RenderSpectatorNotification();
2829
void RenderWarmupTimer();
2930
public:
3031
CHud();

src/game/client/gameclient.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ void CGameClient::OnReset()
367367

368368
m_LocalClientID = -1;
369369
m_TeamCooldownTick = 0;
370+
m_TeamChangeTime = 0.0f;
370371
mem_zero(&m_GameInfo, sizeof(m_GameInfo));
371372
m_DemoSpecMode = SPEC_FREEVIEW;
372373
m_DemoSpecID = -1;
@@ -623,6 +624,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
623624
return;
624625
}
625626
m_LocalClientID = pMsg->m_ClientID;
627+
m_TeamChangeTime = Client()->LocalTime();
626628
}
627629
else
628630
{
@@ -744,6 +746,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
744746

745747
if(pMsg->m_ClientID == m_LocalClientID)
746748
m_TeamCooldownTick = pMsg->m_CooldownTick;
749+
m_TeamChangeTime = Client()->LocalTime();
747750
}
748751

749752
if(pMsg->m_Silent == 0)

src/game/client/gameclient.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ class CGameClient : public IGameClient
195195
int m_LocalClientID;
196196
int m_TeamCooldownTick;
197197
bool m_MuteServerBroadcast;
198+
float m_TeamChangeTime;
198199

199200
struct CGameInfo
200201
{

0 commit comments

Comments
 (0)