diff options
Diffstat (limited to 'src/game/client')
| -rw-r--r-- | src/game/client/components/menus.h | 2 | ||||
| -rw-r--r-- | src/game/client/components/menus_ingame.cpp | 30 | ||||
| -rw-r--r-- | src/game/client/components/voting.cpp | 16 | ||||
| -rw-r--r-- | src/game/client/components/voting.h | 1 |
4 files changed, 44 insertions, 5 deletions
diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 3cdfe3f0..a9921655 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -217,7 +217,7 @@ class CMenus : public CComponent void RenderGame(CUIRect MainView); void RenderServerInfo(CUIRect MainView); void RenderServerControl(CUIRect MainView); - void RenderServerControlKick(CUIRect MainView); + void RenderServerControlKick(CUIRect MainView, bool FilterSpectators); void RenderServerControlServer(CUIRect MainView); // found in menus_browser.cpp diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index 06da001a..4b593989 100644 --- a/src/game/client/components/menus_ingame.cpp +++ b/src/game/client/components/menus_ingame.cpp @@ -345,7 +345,7 @@ void CMenus::RenderServerControlServer(CUIRect MainView) m_CallvoteSelectedOption = UiDoListboxEnd(&s_ScrollValue, 0); } -void CMenus::RenderServerControlKick(CUIRect MainView) +void CMenus::RenderServerControlKick(CUIRect MainView, bool FilterSpectators) { int NumOptions = 0; int Selected = -1; @@ -354,6 +354,8 @@ void CMenus::RenderServerControlKick(CUIRect MainView) { if(!m_pClient->m_Snap.m_paPlayerInfos[i] || i == m_pClient->m_Snap.m_LocalClientID) continue; + if(FilterSpectators && m_pClient->m_Snap.m_paPlayerInfos[i]->m_Team == TEAM_SPECTATORS) + continue; if(m_CallvoteSelectedPlayer == i) Selected = NumOptions; aPlayerIDs[NumOptions++] = i; @@ -400,7 +402,8 @@ void CMenus::RenderServerControl(CUIRect MainView) const char *paTabs[] = { Localize("Settings"), - Localize("Kick")}; + Localize("Kick"), + Localize("Spectate")}; int aNumTabs = (int)(sizeof(paTabs)/sizeof(*paTabs)); for(int i = 0; i < aNumTabs; i++) @@ -424,8 +427,9 @@ void CMenus::RenderServerControl(CUIRect MainView) if(s_ControlPage == 0) RenderServerControlServer(MainView); else if(s_ControlPage == 1) - RenderServerControlKick(MainView); - + RenderServerControlKick(MainView, false); + else if(s_ControlPage == 2) + RenderServerControlKick(MainView, true); { CUIRect Button; @@ -445,6 +449,15 @@ void CMenus::RenderServerControl(CUIRect MainView) SetActive(false); } } + else if(s_ControlPage == 2) + { + if(m_CallvoteSelectedPlayer >= 0 && m_CallvoteSelectedPlayer < MAX_CLIENTS && + m_pClient->m_Snap.m_paPlayerInfos[m_CallvoteSelectedPlayer]) + { + m_pClient->m_pVoting->CallvoteSpectate(m_CallvoteSelectedPlayer, m_aCallvoteReason); + SetActive(false); + } + } m_aCallvoteReason[0] = 0; } @@ -479,6 +492,15 @@ void CMenus::RenderServerControl(CUIRect MainView) SetActive(false); } } + else if(s_ControlPage == 2) + { + if(m_CallvoteSelectedPlayer >= 0 && m_CallvoteSelectedPlayer < MAX_CLIENTS && + m_pClient->m_Snap.m_paPlayerInfos[m_CallvoteSelectedPlayer]) + { + m_pClient->m_pVoting->CallvoteSpectate(m_CallvoteSelectedPlayer, m_aCallvoteReason, true); + SetActive(false); + } + } m_aCallvoteReason[0] = 0; } } diff --git a/src/game/client/components/voting.cpp b/src/game/client/components/voting.cpp index 6e00a5d5..d8c87855 100644 --- a/src/game/client/components/voting.cpp +++ b/src/game/client/components/voting.cpp @@ -31,6 +31,22 @@ void CVoting::Callvote(const char *pType, const char *pValue, const char *pReaso Client()->SendPackMsg(&Msg, MSGFLAG_VITAL); } +void CVoting::CallvoteSpectate(int ClientID, const char *pReason, bool ForceVote) +{ + if(ForceVote) + { + char aBuf[128]; + str_format(aBuf, sizeof(aBuf), "set_team %d -1", ClientID); + Client()->Rcon(aBuf); + } + else + { + char aBuf[32]; + str_format(aBuf, sizeof(aBuf), "%d", ClientID); + Callvote("spectate", aBuf, pReason); + } +} + void CVoting::CallvoteKick(int ClientID, const char *pReason, bool ForceVote) { if(ForceVote) diff --git a/src/game/client/components/voting.h b/src/game/client/components/voting.h index 92e4b395..9e7da2dc 100644 --- a/src/game/client/components/voting.h +++ b/src/game/client/components/voting.h @@ -45,6 +45,7 @@ public: void RenderBars(CUIRect Bars, bool Text); + void CallvoteSpectate(int ClientID, const char *pReason, bool ForceVote = false); void CallvoteKick(int ClientID, const char *pReason, bool ForceVote = false); void CallvoteOption(int Option, const char *pReason, bool ForceVote = false); |