From aaaba4f4039f3643d1a040dfe1c9715be49371e2 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Thu, 25 Sep 2008 12:23:44 +0000 Subject: continued on the voting --- src/game/client/components/menus.cpp | 76 ++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 3 deletions(-) (limited to 'src/game/client/components/menus.cpp') 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); -- cgit 1.4.1