about summary refs log tree commit diff
path: root/src/game/client/components/menus.cpp
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-09-25 12:23:44 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-09-25 12:23:44 +0000
commitaaaba4f4039f3643d1a040dfe1c9715be49371e2 (patch)
treec396f83ae65eaa4b0f7799eb3650de6b72276dd9 /src/game/client/components/menus.cpp
parent059c2ee4cb4d0860b1faf86f2f3b17511260867c (diff)
downloadzcatch-aaaba4f4039f3643d1a040dfe1c9715be49371e2.tar.gz
zcatch-aaaba4f4039f3643d1a040dfe1c9715be49371e2.zip
continued on the voting
Diffstat (limited to 'src/game/client/components/menus.cpp')
-rw-r--r--src/game/client/components/menus.cpp76
1 files changed, 73 insertions, 3 deletions
diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp
index 2c04c467..7cac8bcd 100644
--- a/src/game/client/components/menus.cpp
+++ b/src/game/client/components/menus.cpp
@@ -690,17 +690,87 @@ void MENUS::render_game(RECT main_view)
 		}
 	}
 	
+	RECT bars;
 	ui_hsplit_t(&votearea, 10.0f, 0, &votearea);
-	ui_hsplit_t(&votearea, 25.0f+10.0f*2, &votearea, 0);
+	ui_hsplit_t(&votearea, 25.0f + 10.0f*3 + 25.0f, &votearea, &bars);
 
 	ui_draw_rect(&votearea, color_tabbar_active, CORNER_ALL, 10.0f);
 
-	ui_vmargin(&votearea, 10.0f, &votearea);
+	ui_vmargin(&votearea, 20.0f, &votearea);
 	ui_hmargin(&votearea, 10.0f, &votearea);
+
+	ui_hsplit_b(&votearea, 35.0f, &votearea, &bars);
+
 	if(gameclient.voting->is_voting())
 	{
+		// do yes button
+		ui_vsplit_l(&votearea, 50.0f, &button, &votearea);
+		static int yes_button = 0;
+		if(ui_do_button(&yes_button, "Yes", 0, &button, ui_draw_menu_button, 0))
+			gameclient.voting->vote(1);
+
+		// do no button
+		ui_vsplit_l(&votearea, 5.0f, 0, &votearea);
+		ui_vsplit_l(&votearea, 50.0f, &button, &votearea);
+		static int no_button = 0;
+		if(ui_do_button(&no_button, "No", 0, &button, ui_draw_menu_button, 0))
+			gameclient.voting->vote(-1);
 		
-	}
+		// do time left
+		ui_vsplit_r(&votearea, 50.0f, &votearea, &button);
+		char buf[256];
+		str_format(buf, sizeof(buf), "%d", gameclient.voting->seconds_left());
+		ui_do_label(&button, buf, 24.0f, 0);
+
+		// do description and command
+		ui_vsplit_l(&votearea, 5.0f, 0, &votearea);
+		ui_do_label(&votearea, gameclient.voting->vote_description(), 14.0f, -1);
+		ui_hsplit_t(&votearea, 16.0f, 0, &votearea);
+		ui_do_label(&votearea, gameclient.voting->vote_command(), 10.0f, -1);
+
+		// do bars
+		ui_hsplit_t(&bars, 10.0f, 0, &bars);
+		ui_hmargin(&bars, 5.0f, &bars);
+		ui_draw_rect(&bars, vec4(0.8f,0.8f,0.8f,1), CORNER_ALL, 5.0f);
+		
+		if(gameclient.voting->total)
+		{
+			RECT pass_area = bars;
+			if(gameclient.voting->yes)
+			{
+				RECT yes_area = bars;
+				yes_area.w *= gameclient.voting->yes/(float)gameclient.voting->total;
+				ui_draw_rect(&yes_area, vec4(0.4f,0.8f,0.4f,1), CORNER_ALL, 5.0f);
+				
+				char buf[256];
+				str_format(buf, sizeof(buf), "%d", gameclient.voting->yes);
+				ui_do_label(&yes_area, buf, 12.0f, 0);
+				
+				pass_area.x += yes_area.w;
+				pass_area.w -= yes_area.w;
+			}
+			else if(gameclient.voting->no)
+			{
+				RECT no_area = bars;
+				no_area.w *= gameclient.voting->no/(float)gameclient.voting->total;
+				no_area.x = (bars.x + bars.w)-no_area.w;
+				ui_draw_rect(&no_area, vec4(0.8f,0.4f,0.4f,1), CORNER_ALL, 5.0f);
+				
+				char buf[256];
+				str_format(buf, sizeof(buf), "%d", gameclient.voting->no);
+				ui_do_label(&no_area, buf, 12.0f, 0);
+
+				pass_area.w -= no_area.w;
+			}
+
+			if(gameclient.voting->pass)
+			{
+				char buf[256];
+				str_format(buf, sizeof(buf), "%d", gameclient.voting->pass);
+				ui_do_label(&pass_area, buf, 12.0f, 0);
+			}
+		}
+	}		
 	else
 	{
 		ui_do_label(&votearea, "No vote in progress", 18.0f, -1);