diff options
| author | oy <Tom_Adams@web.de> | 2011-03-26 18:43:43 +0100 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2011-03-26 18:43:43 +0100 |
| commit | 6e1b6b102a623d1e9b93566491bd9dc525fdcbaa (patch) | |
| tree | 71bf5b09ff90ec3eba08af9cb8ceb39fa745ceda /src/game/client | |
| parent | fbeace52723509604e390f0a20e9f922aa26d1d6 (diff) | |
| download | zcatch-6e1b6b102a623d1e9b93566491bd9dc525fdcbaa.tar.gz zcatch-6e1b6b102a623d1e9b93566491bd9dc525fdcbaa.zip | |
added menu to add/remove a vote on the server
Diffstat (limited to 'src/game/client')
| -rw-r--r-- | src/game/client/components/menus_ingame.cpp | 51 | ||||
| -rw-r--r-- | src/game/client/components/voting.cpp | 33 | ||||
| -rw-r--r-- | src/game/client/components/voting.h | 4 |
3 files changed, 80 insertions, 8 deletions
diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index 01efda0a..27c2875b 100644 --- a/src/game/client/components/menus_ingame.cpp +++ b/src/game/client/components/menus_ingame.cpp @@ -414,8 +414,9 @@ void CMenus::RenderServerControl(CUIRect MainView) } } + CUIRect Bottom, Extended; + MainView.HSplitBottom(90.0f, &MainView, &Extended); MainView.Margin(10.0f, &MainView); - CUIRect Bottom; MainView.HSplitBottom(ms_ButtonHeight + 5*2, &MainView, &Bottom); Bottom.HMargin(5.0f, &Bottom); @@ -469,11 +470,17 @@ void CMenus::RenderServerControl(CUIRect MainView) static float s_Offset = 0.0f; DoEditBox(&m_aCallvoteReason, &Reason, m_aCallvoteReason, sizeof(m_aCallvoteReason), 14.0f, &s_Offset, false, CUI::CORNER_ALL); - // force vote button (only available when authed in rcon) + // extended features (only available when authed in rcon) if(Client()->RconAuthed()) { + // background + Extended.Margin(10.0f, &Extended); + Extended.HSplitTop(20.0f, &Bottom, &Extended); + Extended.HSplitTop(5.0f, 0, &Extended); + + // force vote + Bottom.VSplitLeft(5.0f, 0, &Bottom); Bottom.VSplitLeft(120.0f, &Button, &Bottom); - static int s_ForceVoteButton = 0; if(DoButton_Menu(&s_ForceVoteButton, Localize("Force vote"), 0, &Button)) { @@ -499,6 +506,44 @@ void CMenus::RenderServerControl(CUIRect MainView) } m_aCallvoteReason[0] = 0; } + + if(s_ControlPage == 0) + { + // remove vote + Bottom.VSplitRight(10.0f, &Bottom, 0); + Bottom.VSplitRight(120.0f, 0, &Button); + static int s_RemoveVoteButton = 0; + if(DoButton_Menu(&s_RemoveVoteButton, Localize("Remove"), 0, &Button)) + m_pClient->m_pVoting->RemovevoteOption(m_CallvoteSelectedOption); + + + // add vote + Extended.HSplitTop(20.0f, &Bottom, &Extended); + Bottom.VSplitLeft(5.0f, 0, &Bottom); + Bottom.VSplitLeft(250.0f, &Button, &Bottom); + UI()->DoLabelScaled(&Button, Localize("Vote description:"), 14.0f, -1); + + Bottom.VSplitLeft(20.0f, 0, &Button); + UI()->DoLabelScaled(&Button, Localize("Vote command:"), 14.0f, -1); + + static char s_aVoteDescription[64] = {0}; + static char s_aVoteCommand[512] = {0}; + Extended.HSplitTop(20.0f, &Bottom, &Extended); + Bottom.VSplitRight(10.0f, &Bottom, 0); + Bottom.VSplitRight(120.0f, &Bottom, &Button); + static int s_AddVoteButton = 0; + if(DoButton_Menu(&s_AddVoteButton, Localize("Add"), 0, &Button)) + m_pClient->m_pVoting->AddvoteOption(s_aVoteDescription, s_aVoteCommand); + + Bottom.VSplitLeft(5.0f, 0, &Bottom); + Bottom.VSplitLeft(250.0f, &Button, &Bottom); + static float s_OffsetDesc = 0.0f; + DoEditBox(&s_aVoteDescription, &Button, s_aVoteDescription, sizeof(s_aVoteDescription), 14.0f, &s_OffsetDesc, false, CUI::CORNER_ALL); + + Bottom.VMargin(20.0f, &Button); + static float s_OffsetCmd = 0.0f; + DoEditBox(&s_aVoteCommand, &Button, s_aVoteCommand, sizeof(s_aVoteCommand), 14.0f, &s_OffsetCmd, false, CUI::CORNER_ALL); + } } } } diff --git a/src/game/client/components/voting.cpp b/src/game/client/components/voting.cpp index 55343313..0eddf805 100644 --- a/src/game/client/components/voting.cpp +++ b/src/game/client/components/voting.cpp @@ -63,12 +63,12 @@ void CVoting::CallvoteKick(int ClientID, const char *pReason, bool ForceVote) } } -void CVoting::CallvoteOption(int OptionId, const char *pReason, bool ForceVote) +void CVoting::CallvoteOption(int OptionID, const char *pReason, bool ForceVote) { CVoteOptionClient *pOption = m_pFirst; - while(pOption && OptionId >= 0) + while(pOption && OptionID >= 0) { - if(OptionId == 0) + if(OptionID == 0) { if(ForceVote) { @@ -81,11 +81,36 @@ void CVoting::CallvoteOption(int OptionId, const char *pReason, bool ForceVote) break; } - OptionId--; + OptionID--; pOption = pOption->m_pNext; } } +void CVoting::RemovevoteOption(int OptionID) +{ + CVoteOptionClient *pOption = m_pFirst; + while(pOption && OptionID >= 0) + { + if(OptionID == 0) + { + char aBuf[128]; + str_format(aBuf, sizeof(aBuf), "remove_vote \"%s\"", pOption->m_aDescription); + Client()->Rcon(aBuf); + break; + } + + OptionID--; + pOption = pOption->m_pNext; + } +} + +void CVoting::AddvoteOption(const char *pDescription, const char *pCommand) +{ + char aBuf[128]; + str_format(aBuf, sizeof(aBuf), "add_vote \"%s\" %s", pDescription, pCommand); + Client()->Rcon(aBuf); +} + void CVoting::Vote(int v) { CNetMsg_Cl_Vote Msg = {v}; diff --git a/src/game/client/components/voting.h b/src/game/client/components/voting.h index d2a88883..cfba0605 100644 --- a/src/game/client/components/voting.h +++ b/src/game/client/components/voting.h @@ -43,7 +43,9 @@ public: 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); + void CallvoteOption(int OptionID, const char *pReason, bool ForceVote = false); + void RemovevoteOption(int OptionID); + void AddvoteOption(const char *pDescription, const char *pCommand); void Vote(int v); // -1 = no, 1 = yes |