mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 01:24:18 +00:00
added menu to add/remove a vote on the server
This commit is contained in:
parent
fbeace5272
commit
6e1b6b102a
|
@ -519,6 +519,9 @@ Your skin
|
|||
-Page %d-
|
||||
==
|
||||
|
||||
Add
|
||||
==
|
||||
|
||||
Add Friend
|
||||
==
|
||||
|
||||
|
@ -636,6 +639,12 @@ Unable to rename the demo
|
|||
Version:
|
||||
==
|
||||
|
||||
Vote command:
|
||||
==
|
||||
|
||||
Vote description:
|
||||
==
|
||||
|
||||
no limit
|
||||
==
|
||||
|
||||
|
|
|
@ -459,6 +459,9 @@ Your skin
|
|||
-Page %d-
|
||||
==
|
||||
|
||||
Add
|
||||
==
|
||||
|
||||
Add Friend
|
||||
==
|
||||
|
||||
|
@ -633,6 +636,12 @@ Unable to rename the demo
|
|||
Version:
|
||||
==
|
||||
|
||||
Vote command:
|
||||
==
|
||||
|
||||
Vote description:
|
||||
==
|
||||
|
||||
Warmup
|
||||
==
|
||||
|
||||
|
|
|
@ -543,6 +543,9 @@ no limit
|
|||
-Page %d-
|
||||
==
|
||||
|
||||
Add
|
||||
==
|
||||
|
||||
Add Friend
|
||||
==
|
||||
|
||||
|
@ -639,5 +642,11 @@ Unable to rename the demo
|
|||
Version:
|
||||
==
|
||||
|
||||
Vote command:
|
||||
==
|
||||
|
||||
Vote description:
|
||||
==
|
||||
|
||||
##### old translations #####
|
||||
|
||||
|
|
|
@ -483,6 +483,9 @@ Your skin
|
|||
-Page %d-
|
||||
==
|
||||
|
||||
Add
|
||||
==
|
||||
|
||||
Add Friend
|
||||
==
|
||||
|
||||
|
@ -636,6 +639,12 @@ Unable to rename the demo
|
|||
Version:
|
||||
==
|
||||
|
||||
Vote command:
|
||||
==
|
||||
|
||||
Vote description:
|
||||
==
|
||||
|
||||
no limit
|
||||
==
|
||||
|
||||
|
|
|
@ -531,6 +531,9 @@ no limit
|
|||
-Page %d-
|
||||
==
|
||||
|
||||
Add
|
||||
==
|
||||
|
||||
Add Friend
|
||||
==
|
||||
|
||||
|
@ -639,5 +642,11 @@ Unable to rename the demo
|
|||
Version:
|
||||
==
|
||||
|
||||
Vote command:
|
||||
==
|
||||
|
||||
Vote description:
|
||||
==
|
||||
|
||||
##### old translations #####
|
||||
|
||||
|
|
|
@ -543,6 +543,9 @@ no limit
|
|||
-Page %d-
|
||||
==
|
||||
|
||||
Add
|
||||
==
|
||||
|
||||
Add Friend
|
||||
==
|
||||
|
||||
|
@ -639,5 +642,11 @@ Unable to rename the demo
|
|||
Version:
|
||||
==
|
||||
|
||||
Vote command:
|
||||
==
|
||||
|
||||
Vote description:
|
||||
==
|
||||
|
||||
##### old translations #####
|
||||
|
||||
|
|
|
@ -525,6 +525,9 @@ no limit
|
|||
-Page %d-
|
||||
==
|
||||
|
||||
Add
|
||||
==
|
||||
|
||||
Add Friend
|
||||
==
|
||||
|
||||
|
@ -636,6 +639,12 @@ Unable to rename the demo
|
|||
Version:
|
||||
==
|
||||
|
||||
Vote command:
|
||||
==
|
||||
|
||||
Vote description:
|
||||
==
|
||||
|
||||
Warmup
|
||||
==
|
||||
|
||||
|
|
|
@ -486,6 +486,9 @@ Your skin
|
|||
-Page %d-
|
||||
==
|
||||
|
||||
Add
|
||||
==
|
||||
|
||||
Add Friend
|
||||
==
|
||||
|
||||
|
@ -636,6 +639,12 @@ Unable to rename the demo
|
|||
Version:
|
||||
==
|
||||
|
||||
Vote command:
|
||||
==
|
||||
|
||||
Vote description:
|
||||
==
|
||||
|
||||
no limit
|
||||
==
|
||||
|
||||
|
|
|
@ -480,6 +480,9 @@ Your skin
|
|||
-Page %d-
|
||||
==
|
||||
|
||||
Add
|
||||
==
|
||||
|
||||
Add Friend
|
||||
==
|
||||
|
||||
|
@ -636,6 +639,12 @@ Unable to rename the demo
|
|||
Version:
|
||||
==
|
||||
|
||||
Vote command:
|
||||
==
|
||||
|
||||
Vote description:
|
||||
==
|
||||
|
||||
no limit
|
||||
==
|
||||
|
||||
|
|
|
@ -543,6 +543,9 @@ no limit
|
|||
-Page %d-
|
||||
==
|
||||
|
||||
Add
|
||||
==
|
||||
|
||||
Add Friend
|
||||
==
|
||||
|
||||
|
@ -639,5 +642,11 @@ Unable to rename the demo
|
|||
Version:
|
||||
==
|
||||
|
||||
Vote command:
|
||||
==
|
||||
|
||||
Vote description:
|
||||
==
|
||||
|
||||
##### old translations #####
|
||||
|
||||
|
|
|
@ -489,6 +489,9 @@ Your skin
|
|||
-Page %d-
|
||||
==
|
||||
|
||||
Add
|
||||
==
|
||||
|
||||
Add Friend
|
||||
==
|
||||
|
||||
|
@ -636,6 +639,12 @@ Unable to rename the demo
|
|||
Version:
|
||||
==
|
||||
|
||||
Vote command:
|
||||
==
|
||||
|
||||
Vote description:
|
||||
==
|
||||
|
||||
no limit
|
||||
==
|
||||
|
||||
|
|
|
@ -483,6 +483,9 @@ Your skin
|
|||
-Page %d-
|
||||
==
|
||||
|
||||
Add
|
||||
==
|
||||
|
||||
Add Friend
|
||||
==
|
||||
|
||||
|
@ -636,6 +639,12 @@ Unable to rename the demo
|
|||
Version:
|
||||
==
|
||||
|
||||
Vote command:
|
||||
==
|
||||
|
||||
Vote description:
|
||||
==
|
||||
|
||||
no limit
|
||||
==
|
||||
|
||||
|
|
|
@ -543,6 +543,9 @@ no limit
|
|||
-Page %d-
|
||||
==
|
||||
|
||||
Add
|
||||
==
|
||||
|
||||
Add Friend
|
||||
==
|
||||
|
||||
|
@ -639,5 +642,11 @@ Unable to rename the demo
|
|||
Version:
|
||||
==
|
||||
|
||||
Vote command:
|
||||
==
|
||||
|
||||
Vote description:
|
||||
==
|
||||
|
||||
##### old translations #####
|
||||
|
||||
|
|
|
@ -453,6 +453,9 @@ You must restart the game for all settings to take effect.
|
|||
-Page %d-
|
||||
==
|
||||
|
||||
Add
|
||||
==
|
||||
|
||||
Add Friend
|
||||
==
|
||||
|
||||
|
@ -630,6 +633,12 @@ Unable to rename the demo
|
|||
Version:
|
||||
==
|
||||
|
||||
Vote command:
|
||||
==
|
||||
|
||||
Vote description:
|
||||
==
|
||||
|
||||
Warmup
|
||||
==
|
||||
|
||||
|
|
|
@ -507,6 +507,9 @@ Your skin
|
|||
-Page %d-
|
||||
==
|
||||
|
||||
Add
|
||||
==
|
||||
|
||||
Add Friend
|
||||
==
|
||||
|
||||
|
@ -636,6 +639,12 @@ Unable to rename the demo
|
|||
Version:
|
||||
==
|
||||
|
||||
Vote command:
|
||||
==
|
||||
|
||||
Vote description:
|
||||
==
|
||||
|
||||
no limit
|
||||
==
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue