3 #include <client/autocvars.qh>
4 #include <client/defs.qh>
5 #include <common/gamemodes/_mod.qh>
6 #include <client/miscfunctions.qh>
7 #include <common/mapinfo.qh>
11 void HUD_Vote_Export(int fh)
13 // allow saving cvars that aesthetically change the panel into hud skin files
14 HUD_Write_Cvar("hud_panel_vote_alreadyvoted_alpha");
19 if(autocvar_cl_allow_uid2name == -1 && (ISGAMETYPE(CTS) || ISGAMETYPE(RACE) || (serverflags & SERVERFLAG_PLAYERSTATS)))
21 // this dialog gets overriden by the uid2name menu dialog, if it exists
22 // TODO remove this client side uid2name dialog in the next release
23 if(!autocvar__menu_alpha)
27 localcmd("menu_cmd directmenu Uid2Name\n");
30 if (autocvar__hud_configure)
34 LOG_INFO(_("^1You must answer before entering hud configure mode"));
35 cvar_set("_hud_configure", "0");
37 strcpy(vote_called_vote, _("^2Name ^7instead of \"^1Anonymous player^7\" in stats"));
41 if(!autocvar__hud_configure)
43 if(!autocvar_hud_panel_vote) return;
45 if(cvar("hud_panel_vote_test")) {
46 if(vote_called_vote) strunzone(vote_called_vote); vote_called_vote = strzone("^1test the vote panel");
47 vote_active = true; vote_yescount = 3; vote_nocount = 2; vote_needed = 4;
48 } else vote_active = false;
60 if(vote_active != vote_prev) {
62 vote_prev = vote_active;
65 if(vote_active || autocvar__hud_configure)
66 vote_alpha = bound(0, (time - vote_change) * 2, 1);
68 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
70 a = vote_alpha * (vote_highlighted ? autocvar_hud_panel_vote_alreadyvoted_alpha : 1);
73 //panel_fade_alpha *= a;
74 // nothing can hide this panel, not even the menu
75 float hud_fade_alpha_save = hud_fade_alpha;
76 if(uid2name_dialog && autocvar__menu_alpha)
80 HUD_Panel_LoadCvars();
81 hud_fade_alpha = hud_fade_alpha_save;
85 panel_pos = vec2(0.3 * vid_conwidth, 0.1 * vid_conheight);
86 panel_size = vec2(0.4 * vid_conwidth, 0.3 * vid_conheight);
93 if (autocvar_hud_panel_vote_dynamichud)
101 pos += '1 1 0' * panel_bg_padding;
102 mySize -= '2 2 0' * panel_bg_padding;
105 // always force 3:1 aspect
106 vector newSize = '0 0 0';
107 if(mySize.x/mySize.y > 3)
109 newSize.x = 3 * mySize.y;
110 newSize.y = mySize.y;
112 pos.x = pos.x + (mySize.x - newSize.x) / 2;
116 newSize.y = 1/3 * mySize.x;
117 newSize.x = mySize.x;
119 pos.y = pos.y + (mySize.y - newSize.y) / 2;
123 s = _("A vote has been called for:");
125 s = _("Allow servers to store and display your name?");
126 drawstring_aspect(pos, s, vec2(mySize.x, (2/8) * mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
127 s = textShortenToWidth(ColorTranslateRGB(vote_called_vote), mySize.x, '1 1 0' * mySize.y * (1/8), stringwidth_colors);
128 if(autocvar__hud_configure)
129 s = _("^1Configure the HUD");
130 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize.y, s, vec2(mySize.x, (1.75/8) * mySize.y), panel_fg_alpha, DRAWFLAG_NORMAL);
132 // print the yes/no counts
133 s = sprintf("^2%s ^7(%d)", getcommandkey_forcename(_("Yes"), "vyes"), vote_yescount);
134 drawcolorcodedstring_aspect(pos + eY * (4/8) * mySize.y, s, vec2(0.5 * mySize.x, (1.5/8) * mySize.y), panel_fg_alpha, DRAWFLAG_NORMAL);
135 s = sprintf("^1%s ^7(%d)", getcommandkey_forcename(_("No"), "vno"), vote_nocount);
136 drawcolorcodedstring_aspect(pos + vec2(0.5 * mySize.x, (4/8) * mySize.y), s, vec2(0.5 * mySize.x, (1.5/8) * mySize.y), panel_fg_alpha, DRAWFLAG_NORMAL);
138 pos.y += (5/8) * mySize.y;
139 vector tmp_size = vec2(mySize.x, (3/8) * mySize.y);
140 // draw the progress bar backgrounds
141 drawpic_skin(pos, "voteprogress_back", tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
143 // draw the highlights
144 if(vote_highlighted == 1) {
145 drawsetcliparea(pos.x, pos.y, mySize.x * 0.5, mySize.y);
146 drawpic_skin(pos, "voteprogress_voted", tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
148 else if(vote_highlighted == -1) {
149 drawsetcliparea(pos.x + 0.5 * mySize.x, pos.y, mySize.x * 0.5, mySize.y);
150 drawpic_skin(pos, "voteprogress_voted", tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
153 // draw the progress bars
154 if(vote_yescount && vote_needed)
156 drawsetcliparea(pos.x, pos.y, mySize.x * 0.5 * (vote_yescount/vote_needed), mySize.y);
157 drawpic_skin(pos, "voteprogress_prog", tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
160 if(vote_nocount && vote_needed)
162 drawsetcliparea(pos.x + mySize.x - mySize.x * 0.5 * (vote_nocount/vote_needed), pos.y, mySize.x * 0.5, mySize.y);
163 drawpic_skin(pos, "voteprogress_prog", tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);