about summary refs log tree commit diff
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2011-03-26 18:43:43 +0100
committeroy <Tom_Adams@web.de>2011-03-26 18:43:43 +0100
commit6e1b6b102a623d1e9b93566491bd9dc525fdcbaa (patch)
tree71bf5b09ff90ec3eba08af9cb8ceb39fa745ceda
parentfbeace52723509604e390f0a20e9f922aa26d1d6 (diff)
downloadzcatch-6e1b6b102a623d1e9b93566491bd9dc525fdcbaa.tar.gz
zcatch-6e1b6b102a623d1e9b93566491bd9dc525fdcbaa.zip
added menu to add/remove a vote on the server
-rw-r--r--data/languages/bosnian.txt9
-rw-r--r--data/languages/czech.txt9
-rw-r--r--data/languages/dutch.txt9
-rw-r--r--data/languages/finnish.txt9
-rw-r--r--data/languages/french.txt9
-rw-r--r--data/languages/german.txt9
-rw-r--r--data/languages/italian.txt9
-rw-r--r--data/languages/polish.txt9
-rw-r--r--data/languages/portuguese.txt9
-rw-r--r--data/languages/romanian.txt9
-rw-r--r--data/languages/russian.txt9
-rw-r--r--data/languages/serbian.txt9
-rw-r--r--data/languages/spanish.txt9
-rw-r--r--data/languages/swedish.txt9
-rw-r--r--data/languages/ukrainian.txt9
-rw-r--r--src/game/client/components/menus_ingame.cpp51
-rw-r--r--src/game/client/components/voting.cpp33
-rw-r--r--src/game/client/components/voting.h4
18 files changed, 215 insertions, 8 deletions
diff --git a/data/languages/bosnian.txt b/data/languages/bosnian.txt
index e5a7819c..a38ed45a 100644
--- a/data/languages/bosnian.txt
+++ b/data/languages/bosnian.txt
@@ -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
 == 
 
diff --git a/data/languages/czech.txt b/data/languages/czech.txt
index ff4c9bf8..a0602ce6 100644
--- a/data/languages/czech.txt
+++ b/data/languages/czech.txt
@@ -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
 == 
 
diff --git a/data/languages/dutch.txt b/data/languages/dutch.txt
index d4268591..d2d4c2d0 100644
--- a/data/languages/dutch.txt
+++ b/data/languages/dutch.txt
@@ -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 #####
 
diff --git a/data/languages/finnish.txt b/data/languages/finnish.txt
index 265fc40c..7233cbca 100644
--- a/data/languages/finnish.txt
+++ b/data/languages/finnish.txt
@@ -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
 == 
 
diff --git a/data/languages/french.txt b/data/languages/french.txt
index 46c6e8e8..5f4de597 100644
--- a/data/languages/french.txt
+++ b/data/languages/french.txt
@@ -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 #####
 
diff --git a/data/languages/german.txt b/data/languages/german.txt
index ad0bb571..01daf7eb 100644
--- a/data/languages/german.txt
+++ b/data/languages/german.txt
@@ -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 #####
 
diff --git a/data/languages/italian.txt b/data/languages/italian.txt
index 05e4306b..9a510a89 100644
--- a/data/languages/italian.txt
+++ b/data/languages/italian.txt
@@ -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
 == 
 
diff --git a/data/languages/polish.txt b/data/languages/polish.txt
index a75e5836..59fff939 100644
--- a/data/languages/polish.txt
+++ b/data/languages/polish.txt
@@ -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
 == 
 
diff --git a/data/languages/portuguese.txt b/data/languages/portuguese.txt
index ec911ef0..87a717f2 100644
--- a/data/languages/portuguese.txt
+++ b/data/languages/portuguese.txt
@@ -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
 == 
 
diff --git a/data/languages/romanian.txt b/data/languages/romanian.txt
index 90e7e17c..b47cd867 100644
--- a/data/languages/romanian.txt
+++ b/data/languages/romanian.txt
@@ -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 #####
 
diff --git a/data/languages/russian.txt b/data/languages/russian.txt
index 6f33cca0..1bde3f9d 100644
--- a/data/languages/russian.txt
+++ b/data/languages/russian.txt
@@ -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
 == 
 
diff --git a/data/languages/serbian.txt b/data/languages/serbian.txt
index a3537e5a..6096e63c 100644
--- a/data/languages/serbian.txt
+++ b/data/languages/serbian.txt
@@ -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
 == 
 
diff --git a/data/languages/spanish.txt b/data/languages/spanish.txt
index 8ceb991a..12e8a675 100644
--- a/data/languages/spanish.txt
+++ b/data/languages/spanish.txt
@@ -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 #####
 
diff --git a/data/languages/swedish.txt b/data/languages/swedish.txt
index d45eda0d..96296099 100644
--- a/data/languages/swedish.txt
+++ b/data/languages/swedish.txt
@@ -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
 == 
 
diff --git a/data/languages/ukrainian.txt b/data/languages/ukrainian.txt
index 93b4742e..1dca7066 100644
--- a/data/languages/ukrainian.txt
+++ b/data/languages/ukrainian.txt
@@ -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
 == 
 
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