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)))
11 if (autocvar__hud_configure)
15 LOG_INFO(_("^1You must answer before entering hud configure mode\n"));
16 cvar_set("_hud_configure", "0");
19 strunzone(vote_called_vote);
20 vote_called_vote = strzone(_("^2Name ^7instead of \"^1Anonymous player^7\" in stats"));
24 if(!autocvar__hud_configure)
26 if(!autocvar_hud_panel_vote) return;
28 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
29 panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha;
31 if(panel_bg_alpha_str == "") {
32 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
34 panel_bg_alpha = stof(panel_bg_alpha_str);
45 if(vote_active != vote_prev) {
47 vote_prev = vote_active;
50 if(vote_active || autocvar__hud_configure)
51 vote_alpha = bound(0, (time - vote_change) * 2, 1);
53 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
58 HUD_Panel_UpdateCvars();
62 panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight;
63 panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight;
66 // these must be below above block
71 a = vote_alpha * (vote_highlighted ? autocvar_hud_panel_vote_alreadyvoted_alpha : 1);
72 if (autocvar_hud_panel_vote_dynamichud)
77 a = panel_fg_alpha * a;
81 pos += '1 1 0' * panel_bg_padding;
82 mySize -= '2 2 0' * panel_bg_padding;
85 // always force 3:1 aspect
86 vector newSize = '0 0 0';
87 if(mySize.x/mySize.y > 3)
89 newSize.x = 3 * mySize.y;
92 pos.x = pos.x + (mySize.x - newSize.x) / 2;
96 newSize.y = 1/3 * mySize.x;
99 pos.y = pos.y + (mySize.y - newSize.y) / 2;
103 s = _("A vote has been called for:");
105 s = _("Allow servers to store and display your name?");
106 drawstring_aspect(pos, s, eX * mySize.x + eY * (2/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
107 s = textShortenToWidth(vote_called_vote, mySize.x, '1 1 0' * mySize.y * (1/8), stringwidth_colors);
108 if(autocvar__hud_configure)
109 s = _("^1Configure the HUD");
110 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize.y, s, eX * mySize.x + eY * (1.75/8) * mySize.y, a, DRAWFLAG_NORMAL);
112 // print the yes/no counts
113 s = sprintf(_("Yes (%s): %d"), getcommandkey("vyes", "vyes"), vote_yescount);
114 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);
115 s = sprintf(_("No (%s): %d"), getcommandkey("vno", "vno"), vote_nocount);
116 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);
118 // draw the progress bar backgrounds
119 drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_back", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
121 // draw the highlights
122 if(vote_highlighted == 1) {
123 drawsetcliparea(pos.x, pos.y, mySize.x * 0.5, mySize.y);
124 drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_voted", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
126 else if(vote_highlighted == -1) {
127 drawsetcliparea(pos.x + 0.5 * mySize.x, pos.y, mySize.x * 0.5, mySize.y);
128 drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_voted", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
131 // draw the progress bars
132 if(vote_yescount && vote_needed)
134 drawsetcliparea(pos.x, pos.y, mySize.x * 0.5 * (vote_yescount/vote_needed), mySize.y);
135 drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_prog", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
138 if(vote_nocount && vote_needed)
140 drawsetcliparea(pos.x + mySize.x - mySize.x * 0.5 * (vote_nocount/vote_needed), pos.y, mySize.x * 0.5, mySize.y);
141 drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_prog", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);