3 #include <common/mapinfo.qh>
5 /** Vote window (#9) */
8 if(autocvar_cl_allow_uid2name == -1 && (gametype == MAPINFO_TYPE_CTS || gametype == MAPINFO_TYPE_RACE || (serverflags & SERVERFLAG_PLAYERSTATS)))
10 // this dialog gets overriden by the uid2name menu dialog, if it exists
11 // TODO remove this client side uid2name dialog in the next release
12 if(autocvar__menu_alpha)
17 localcmd("menu_cmd directmenu Uid2Name\n");
20 if (autocvar__hud_configure)
24 LOG_INFO(_("^1You must answer before entering hud configure mode\n"));
25 cvar_set("_hud_configure", "0");
28 strunzone(vote_called_vote);
29 vote_called_vote = strzone(_("^2Name ^7instead of \"^1Anonymous player^7\" in stats"));
33 if(!autocvar__hud_configure)
35 if(!autocvar_hud_panel_vote) return;
37 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
38 panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha;
40 if(panel_bg_alpha_str == "") {
41 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
43 panel_bg_alpha = stof(panel_bg_alpha_str);
54 if(vote_active != vote_prev) {
56 vote_prev = vote_active;
59 if(vote_active || autocvar__hud_configure)
60 vote_alpha = bound(0, (time - vote_change) * 2, 1);
62 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
67 HUD_Panel_UpdateCvars();
71 panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight;
72 panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight;
75 // these must be below above block
80 a = vote_alpha * (vote_highlighted ? autocvar_hud_panel_vote_alreadyvoted_alpha : 1);
81 if (autocvar_hud_panel_vote_dynamichud)
86 a = panel_fg_alpha * a;
90 pos += '1 1 0' * panel_bg_padding;
91 mySize -= '2 2 0' * panel_bg_padding;
94 // always force 3:1 aspect
95 vector newSize = '0 0 0';
96 if(mySize.x/mySize.y > 3)
98 newSize.x = 3 * mySize.y;
101 pos.x = pos.x + (mySize.x - newSize.x) / 2;
105 newSize.y = 1/3 * mySize.x;
106 newSize.x = mySize.x;
108 pos.y = pos.y + (mySize.y - newSize.y) / 2;
112 s = _("A vote has been called for:");
114 s = _("Allow servers to store and display your name?");
115 drawstring_aspect(pos, s, eX * mySize.x + eY * (2/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
116 s = textShortenToWidth(vote_called_vote, mySize.x, '1 1 0' * mySize.y * (1/8), stringwidth_colors);
117 if(autocvar__hud_configure)
118 s = _("^1Configure the HUD");
119 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize.y, s, eX * mySize.x + eY * (1.75/8) * mySize.y, a, DRAWFLAG_NORMAL);
121 // print the yes/no counts
122 s = sprintf(_("Yes (%s): %d"), getcommandkey("vyes", "vyes"), vote_yescount);
123 drawstring_aspect(pos + eY * (4/8) * mySize.y, s, eX * 0.5 * mySize.x + eY * (1.5/8) * mySize.y, '0 1 0', a, DRAWFLAG_NORMAL);
124 s = sprintf(_("No (%s): %d"), getcommandkey("vno", "vno"), vote_nocount);
125 drawstring_aspect(pos + eX * 0.5 * mySize.x + eY * (4/8) * mySize.y, s, eX * 0.5 * mySize.x + eY * (1.5/8) * mySize.y, '1 0 0', a, DRAWFLAG_NORMAL);
127 // draw the progress bar backgrounds
128 drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_back", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
130 // draw the highlights
131 if(vote_highlighted == 1) {
132 drawsetcliparea(pos.x, pos.y, mySize.x * 0.5, mySize.y);
133 drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_voted", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
135 else if(vote_highlighted == -1) {
136 drawsetcliparea(pos.x + 0.5 * mySize.x, pos.y, mySize.x * 0.5, mySize.y);
137 drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_voted", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
140 // draw the progress bars
141 if(vote_yescount && vote_needed)
143 drawsetcliparea(pos.x, pos.y, mySize.x * 0.5 * (vote_yescount/vote_needed), mySize.y);
144 drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_prog", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
147 if(vote_nocount && vote_needed)
149 drawsetcliparea(pos.x + mySize.x - mySize.x * 0.5 * (vote_nocount/vote_needed), pos.y, mySize.x * 0.5, mySize.y);
150 drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_prog", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);