7 // a border picture is a texture containing nine parts:
8 // 1/4 width: left part
9 // 1/2 width: middle part (stretched)
10 // 1/4 width: right part
12 // 1/4 height: top part
13 // 1/2 height: middle part (stretched)
14 // 1/4 height: bottom part
15 void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize)
17 if (theBorderSize_x <= 0 && theBorderSize_y <= 0) // no border
19 // draw only the central part
20 drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
27 //pic = draw_UseSkinFor(pic);
28 width = eX * theSize_x;
29 height = eY * theSize_y;
30 if(theSize_x <= theBorderSize_x * 2)
32 // not wide enough... draw just left and right then
33 bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
34 if(theSize_y <= theBorderSize_y * 2)
36 // not high enough... draw just corners
37 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
38 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
39 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
40 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
41 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
45 dY = theBorderSize_x * eY;
46 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
47 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
48 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
49 drawsubpic(theOrigin + width * 0.5 + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0' + eX - bW, '0 0.5 0' + bW, theColor, theAlpha, 0);
50 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
51 drawsubpic(theOrigin + width * 0.5 + height - dY, width * 0.5 + dY, pic, '0 0.75 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
56 if(theSize_y <= theBorderSize_y * 2)
58 // not high enough... draw just top and bottom then
59 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
60 dX = theBorderSize_x * eX;
61 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
62 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
63 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
64 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
65 drawsubpic(theOrigin + dX + height * 0.5, width - 2 * dX + height * 0.5, pic, '0.25 0 0' + eY - bH, '0.5 0 0' + bH, theColor, theAlpha, 0);
66 drawsubpic(theOrigin + width - dX + height * 0.5, dX + height * 0.5, pic, '0.75 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
70 dX = theBorderSize_x * eX;
71 dY = theBorderSize_x * eY;
72 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
73 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
74 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
75 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
76 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
77 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
78 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
79 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
80 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
85 vector HUD_Get_Num_Color (float x, float maxvalue)
93 else if(x > maxvalue * 0.75) {
94 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
95 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
98 else if(x > maxvalue * 0.5) {
99 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
100 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
101 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
103 else if(x > maxvalue * 0.25) {
106 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
108 else if(x > maxvalue * 0.1) {
110 color_y = (x-20)*90/27/100; // green value between 0 -> 1
111 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
121 float stringwidth_colors(string s, vector theSize)
123 return stringwidth(s, TRUE, theSize);
126 float stringwidth_nocolors(string s, vector theSize)
128 return stringwidth(s, FALSE, theSize);
131 #define CENTERPRINT_MAX_LINES 30
132 string centerprint_messages[CENTERPRINT_MAX_LINES];
133 float centerprint_width[CENTERPRINT_MAX_LINES];
134 float centerprint_time;
135 float centerprint_expire;
136 float centerprint_num;
137 float centerprint_offset_hint;
138 vector centerprint_fontsize;
140 void centerprint(string strMessage)
142 float i, j, n, hcount;
145 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
147 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
149 if(cvar("scr_centertime") <= 0)
155 // strip trailing newlines
156 j = strlen(strMessage) - 1;
157 while(substring(strMessage, j, 1) == "\n" && j >= 0)
159 strMessage = substring(strMessage, 0, j + 1);
164 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
166 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
168 strMessage = substring(strMessage, j, strlen(strMessage) - j);
169 centerprint_offset_hint = j;
174 // if we get here, we have a message. Initialize its height.
177 n = tokenizebyseparator(strMessage, "\n");
179 for(j = 0; j < n; ++j)
181 getWrappedLine_remaining = argv(j);
182 while(getWrappedLine_remaining)
184 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
185 if(centerprint_messages[i] != s) // don't fade the same message in, looks stupid
186 centerprint_time = time;
187 if(centerprint_messages[i])
188 strunzone(centerprint_messages[i]);
189 centerprint_messages[i] = strzone(s);
190 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
193 // half height for empty lines looks better
199 if(i >= CENTERPRINT_MAX_LINES)
205 h = centerprint_fontsize_y*hcount;
207 havail = vid_conheight;
208 if(cvar("con_chatpos") < 0)
209 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
210 if(havail > vid_conheight - 70)
211 havail = vid_conheight - 70; // avoid overlapping HUD
214 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
216 // here, the centerprint would cover the crosshair. REALLY BAD.
217 forbiddenmin = vid_conheight * 0.5 - h - 16;
218 forbiddenmax = vid_conheight * 0.5 + 16;
220 allowedmin = scoreboard_bottom;
221 allowedmax = havail - h;
222 preferred = (havail - h)/2;
225 // possible orderings (total: 4! / 4 = 6)
226 // allowedmin allowedmax forbiddenmin forbiddenmax
227 // forbiddenmin forbiddenmax allowedmin allowedmax
228 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
230 // forbidden doesn't matter in this case
231 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
233 // allowedmin forbiddenmin allowedmax forbiddenmax
234 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
236 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
238 // allowedmin forbiddenmin forbiddenmax allowedmax
239 else if(allowedmin < forbiddenmin)
241 // make sure the forbidden zone is not covered
242 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
243 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
245 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
247 // forbiddenmin allowedmin allowedmax forbiddenmax
248 else if(allowedmax < forbiddenmax)
250 // it's better to leave the allowed zone (overlap with scoreboard) than
251 // to cover the forbidden zone (crosshair)
252 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
253 centerprint_start_y = forbiddenmax;
255 centerprint_start_y = forbiddenmin;
257 // forbiddenmin allowedmin forbiddenmax allowedmax
260 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
267 centerprint_expire = time + cvar("scr_centertime");
270 void HUD_DrawCenterPrint (void)
277 if(time - centerprint_time < 0.25)
278 a = (time - centerprint_time) / 0.25;
280 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
287 if(centerprint_num > 1 && HUD_WouldDrawScoreboard())
289 centerprint_start_y = scoreboard_bottom + centerprint_fontsize_y;
291 pos = centerprint_start;
292 for (i=0; i<centerprint_num; i = i + 1)
294 ts = centerprint_messages[i];
295 drawfontscale = sz * '1 1 0';
296 drawfont = hud_bigfont;
297 pos_x = (vid_conwidth - stringwidth(ts, TRUE, centerprint_fontsize)) * 0.5;
300 drawcolorcodedstring(pos + '0 1 0' * (1 - sz) * 0.5 *centerprint_fontsize_y, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
301 pos_y = pos_y + centerprint_fontsize_y;
304 // half height for empty lines looks better
305 pos_y = pos_y + sz * centerprint_fontsize_y * 0.5;
306 drawfontscale = '1 1 0';
311 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
313 position_x -= 2 / 3 * strlen(text) * scale_x;
314 drawstring(position, text, scale, rgb, alpha, flag);
317 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
319 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
320 drawstring(position, text, scale, rgb, alpha, flag);
323 // return the string of the given race place
324 string race_PlaceName(float pos) {
332 return strcat(ftos(pos), "th");
335 // return the string of the onscreen race timer
336 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
344 if(histime == 0) // goal hit
348 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
358 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
364 lapstr = strcat(" (-", ftos(lapdelta), "L)");
367 else if(lapdelta < 0)
369 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
373 else if(histime > 0) // anticipation
375 if(mytime >= histime)
376 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
378 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
385 cpname = "Start line";
387 cpname = "Finish line";
389 cpname = strcat("Intermediate ", ftos(cp));
391 cpname = "Finish line";
394 return strcat(col, cpname);
395 else if(hisname == "")
396 return strcat(col, cpname, " (", timestr, ")");
398 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
401 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
402 float race_CheckName(string net_name) {
404 for (i=RANKINGS_CNT-1;i>=0;--i)
405 if(grecordholder[i] == net_name)
417 void HUD_Panel_ExportCfg(string cfgname)
420 fh = fopen(strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg"), FILE_WRITE);
423 fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
424 fputs(fh, strcat("seta hud_panel_bg \"", cvar_string("hud_panel_bg"), "\"", "\n"));
425 fputs(fh, strcat("seta hud_panel_bg_color \"", cvar_string("hud_panel_bg_color"), "\"", "\n"));
426 fputs(fh, strcat("seta hud_panel_bg_color_team \"", cvar_string("hud_panel_bg_color_team"), "\"", "\n"));
427 fputs(fh, strcat("seta hud_panel_bg_alpha \"", cvar_string("hud_panel_bg_alpha"), "\"", "\n"));
428 fputs(fh, strcat("seta hud_panel_bg_border \"", cvar_string("hud_panel_bg_border"), "\"", "\n"));
429 fputs(fh, strcat("seta hud_panel_bg_padding \"", cvar_string("hud_panel_bg_padding"), "\"", "\n"));
430 fputs(fh, strcat("seta hud_panel_fg_alpha \"", cvar_string("hud_panel_fg_alpha"), "\"", "\n"));
433 fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
434 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
435 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
436 fputs(fh, strcat("seta hud_dock_alpha \"", cvar_string("hud_dock_alpha"), "\"", "\n"));
439 fputs(fh, strcat("seta hud_progressbar_alpha \"", cvar_string("hud_progressbar_alpha"), "\"", "\n"));
440 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
441 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
442 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
443 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
444 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
445 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
448 fputs(fh, strcat("seta _hud_panelorder \"", cvar_string("_hud_panelorder"), "\"", "\n"));
451 fputs(fh, strcat("seta hud_configure_grid \"", cvar_string("hud_configure_grid"), "\"", "\n"));
452 fputs(fh, strcat("seta hud_configure_grid_xsize \"", cvar_string("hud_configure_grid_xsize"), "\"", "\n"));
453 fputs(fh, strcat("seta hud_configure_grid_ysize \"", cvar_string("hud_configure_grid_ysize"), "\"", "\n"));
456 fputs(fh, strcat("seta scr_centerpos \"", cvar_string("scr_centerpos"), "\"", "\n"));
459 // common cvars for all panels
461 for (i = 0; i < HUD_PANEL_NUM; ++i)
465 fputs(fh, strcat("seta hud_panel_", panel_name, " ", cvar_string(strcat("hud_panel_", panel_name)), "\n"));
466 fputs(fh, strcat("seta hud_panel_", panel_name, "_pos \"", cvar_string(strcat("hud_panel_", panel_name, "_pos")), "\"", "\n"));
467 fputs(fh, strcat("seta hud_panel_", panel_name, "_size \"", cvar_string(strcat("hud_panel_", panel_name, "_size")), "\"", "\n"));
468 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg \"", cvar_string(strcat("hud_panel_", panel_name, "_bg")), "\"", "\n"));
469 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_color \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_color")), "\"", "\n"));
470 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_color_team \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_color_team")), "\"", "\n"));
471 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_alpha")), "\"", "\n"));
472 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_border \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_border")), "\"", "\n"));
473 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_padding \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_padding")), "\"", "\n"));
475 case HUD_PANEL_WEAPONS:
476 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble")), "\"", "\n"));
477 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_padding \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_padding")), "\"", "\n"));
478 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_outofammo \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_outofammo")), "\"", "\n"));
479 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_donthave \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_donthave")), "\"", "\n"));
480 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_unavailable \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_unavailable")), "\"", "\n"));
481 fputs(fh, strcat("seta hud_panel_", panel_name, "_ammo_color \"", cvar_string(strcat("hud_panel_", panel_name, "_ammo_color")), "\"", "\n"));
482 fputs(fh, strcat("seta hud_panel_", panel_name, "_ammo_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_ammo_alpha")), "\"", "\n"));
483 fputs(fh, strcat("seta hud_panel_", panel_name, "_aspect \"", cvar_string(strcat("hud_panel_", panel_name, "_aspect")), "\"", "\n"));
486 fputs(fh, strcat("seta hud_panel_", panel_name, "_onlycurrent \"", cvar_string(strcat("hud_panel_", panel_name, "_onlycurrent")), "\"", "\n"));
487 fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
489 case HUD_PANEL_POWERUPS:
490 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\"", "\n"));
491 fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
492 fputs(fh, strcat("seta hud_panel_", panel_name, "_baralign \"", cvar_string(strcat("hud_panel_", panel_name, "_baralign")), "\"", "\n"));
493 fputs(fh, strcat("seta hud_panel_", panel_name, "_progressbar \"", cvar_string(strcat("hud_panel_", panel_name, "_progressbar")), "\"", "\n"));
495 case HUD_PANEL_HEALTHARMOR:
496 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\n"));
497 fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
498 fputs(fh, strcat("seta hud_panel_", panel_name, "_baralign \"", cvar_string(strcat("hud_panel_", panel_name, "_baralign")), "\"", "\n"));
499 fputs(fh, strcat("seta hud_panel_", panel_name, "_progressbar \"", cvar_string(strcat("hud_panel_", panel_name, "_progressbar")), "\"", "\n"));
501 case HUD_PANEL_NOTIFY:
502 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\"", "\n"));
503 fputs(fh, strcat("seta hud_panel_", panel_name, "_print \"", cvar_string(strcat("hud_panel_", panel_name, "_print")), "\"", "\n"));
505 case HUD_PANEL_RADAR:
506 fputs(fh, strcat("seta hud_panel_", panel_name, "_foreground_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_foreground_alpha")), "\"", "\n"));
509 fputs(fh, strcat("seta hud_panel_", panel_name, "_alreadyvoted_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_alreadyvoted_alpha")), "\"", "\n"));
511 case HUD_PANEL_PRESSEDKEYS:
512 fputs(fh, strcat("seta hud_panel_", panel_name, "_aspect \"", cvar_string(strcat("hud_panel_", panel_name, "_aspect")), "\"", "\n"));
517 fputs(fh, strcat("menu_restart", "\n")); // force a menu update when execing config, so that the dialogs are updated
519 print("^2Successfully exported to hud_", autocvar_hud_skin, "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
524 const float hlBorderSize = 4;
525 const string hlBorder = "gfx/hud/default/border_highlighted";
526 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
527 void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
529 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
530 drawpic_tiled(panel_pos - '1 1 0' * myBorder, hlBorder, '8 1 0' * hlBorderSize, eX * (panel_size_x + 2 * myBorder) + eY * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
531 drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * (panel_size_y + 2 * myBorder - hlBorderSize), hlBorder, '8 1 0' * hlBorderSize, eX * (panel_size_x + 2 * myBorder) + eY * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
532 drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * hlBorderSize, hlBorder2, '1 8 0' * hlBorderSize, eY * (panel_size_y + 2 * myBorder - 2 * hlBorderSize) + eX * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
533 drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * hlBorderSize + eX * (panel_size_x + 2 * myBorder - hlBorderSize), hlBorder2, '1 8 0' * hlBorderSize, eY * (panel_size_y + 2 * myBorder - 2 * hlBorderSize) + eX * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
536 // draw the background/borders
537 #define HUD_Panel_DrawBg(alpha)\
539 draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * alpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));\
540 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
541 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);
543 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
550 pic = strcat(hud_skin_path, "/statusbar_vertical");
551 if(precache_pic(pic) == "") {
552 pic = "gfx/hud/default/statusbar_vertical";
554 drawsubpic(pos, eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, pic, '0 0 0', '1 0.25 0', color, alpha, drawflag);
555 if(mySize_y/mySize_x > 2)
556 drawsubpic(pos + eY * mySize_x, eY * (mySize_y - 2 * mySize_x) + eX * mySize_x, pic, '0 0.25 0', '1 0.5 0', color, alpha, drawflag);
557 drawsubpic(pos + eY * mySize_y - eY * min(mySize_y * 0.5, mySize_x), eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, pic, '0 0.75 0', '1 0.25 0', color, alpha, drawflag);
559 pic = strcat(hud_skin_path, "/statusbar");
560 if(precache_pic(pic) == "") {
561 pic = "gfx/hud/default/statusbar";
563 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
564 if(mySize_x/mySize_y > 2)
565 drawsubpic(pos + eX * mySize_y, eX * (mySize_x - 2 * mySize_y) + eY * mySize_y, pic, '0.25 0 0', '0.5 1 0', color, alpha, drawflag);
566 drawsubpic(pos + eX * mySize_x - eX * min(mySize_x * 0.5, mySize_y), eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0.75 0 0', '0.25 1 0', color, alpha, drawflag);
570 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
576 pic = strcat(hud_skin_path, "/num_leading");
577 if(precache_pic(pic) == "") {
578 pic = "gfx/hud/default/num_leading";
581 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
582 if(mySize_x/mySize_y > 2)
583 drawsubpic(pos + eX * mySize_y, eX * (mySize_x - 2 * mySize_y) + eY * mySize_y, pic, '0.25 0 0', '0.5 1 0', color, alpha, drawflag);
584 drawsubpic(pos + eX * mySize_x - eX * min(mySize_x * 0.5, mySize_y), eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0.75 0 0', '0.25 1 0', color, alpha, drawflag);
587 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
588 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
599 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
600 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
602 for (i = 0; i < HUD_PANEL_NUM; ++i) {
603 if(i == highlightedPanel || !panel_enabled)
606 HUD_Panel_UpdatePosSizeForId(i)
608 panel_pos -= '1 1 0' * panel_bg_border;
609 panel_size += '2 2 0' * panel_bg_border;
611 if(myPos_y + mySize_y < panel_pos_y)
613 if(myPos_y > panel_pos_y + panel_size_y)
616 if(myPos_x + mySize_x < panel_pos_x)
618 if(myPos_x > panel_pos_x + panel_size_x)
621 // OK, there IS a collision.
623 myCenter_x = myPos_x + 0.5 * mySize_x;
624 myCenter_y = myPos_y + 0.5 * mySize_y;
626 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
627 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
629 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
631 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
632 myTarget_x = panel_pos_x - mySize_x;
633 else // push it upwards
634 myTarget_y = panel_pos_y - mySize_y;
636 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
638 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
639 myTarget_x = panel_pos_x + panel_size_x;
640 else // push it upwards
641 myTarget_y = panel_pos_y - mySize_y;
643 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
645 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
646 myTarget_x = panel_pos_x - mySize_x;
647 else // push it downwards
648 myTarget_y = panel_pos_y + panel_size_y;
650 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
652 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
653 myTarget_x = panel_pos_x + panel_size_x;
654 else // push it downwards
655 myTarget_y = panel_pos_y + panel_size_y;
657 if(cvar("hud_configure_checkcollisions_debug"))
658 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
664 void HUD_Panel_SetPos(vector pos)
666 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
670 if(cvar("hud_configure_checkcollisions_debug"))
671 drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
673 if(autocvar_hud_configure_grid)
675 pos_x = floor((pos_x/vid_conwidth)/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
676 pos_y = floor((pos_y/vid_conheight)/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
679 if(hud_configure_checkcollisions)
680 pos = HUD_Panel_CheckMove(pos, mySize);
682 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
683 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
686 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
688 HUD_Panel_GetName(highlightedPanel);
689 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
692 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
693 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
703 ratio = mySize_x/mySize_y;
705 for (i = 0; i < HUD_PANEL_NUM; ++i) {
706 if(i == highlightedPanel || !panel_enabled)
709 HUD_Panel_UpdatePosSizeForId(i)
711 panel_pos -= '1 1 0' * panel_bg_border;
712 panel_size += '2 2 0' * panel_bg_border;
714 targEndPos = panel_pos + panel_size;
716 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
717 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
720 if (resizeCorner == 1)
722 // check if this panel is on our way
723 if (resizeorigin_x <= panel_pos_x)
725 if (resizeorigin_y <= panel_pos_y)
727 if (targEndPos_x <= resizeorigin_x - mySize_x)
729 if (targEndPos_y <= resizeorigin_y - mySize_y)
732 // there is a collision:
733 // detect which side of the panel we are facing is actually limiting the resizing
734 // (which side the resize direction finds for first) and reduce the size up to there
736 // dist is the distance between resizeorigin and the "analogous" point of the panel
737 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
738 dist_x = resizeorigin_x - targEndPos_x;
739 dist_y = resizeorigin_y - targEndPos_y;
740 if (dist_y <= 0 || dist_x / dist_y > ratio)
741 mySize_x = min(mySize_x, dist_x);
743 mySize_y = min(mySize_y, dist_y);
745 else if (resizeCorner == 2)
747 if (resizeorigin_x >= targEndPos_x)
749 if (resizeorigin_y <= panel_pos_y)
751 if (panel_pos_x >= resizeorigin_x + mySize_x)
753 if (targEndPos_y <= resizeorigin_y - mySize_y)
756 dist_x = panel_pos_x - resizeorigin_x;
757 dist_y = resizeorigin_y - targEndPos_y;
758 if (dist_y <= 0 || dist_x / dist_y > ratio)
759 mySize_x = min(mySize_x, dist_x);
761 mySize_y = min(mySize_y, dist_y);
763 else if (resizeCorner == 3)
765 if (resizeorigin_x <= panel_pos_x)
767 if (resizeorigin_y >= targEndPos_y)
769 if (targEndPos_x <= resizeorigin_x - mySize_x)
771 if (panel_pos_y >= resizeorigin_y + mySize_y)
774 dist_x = resizeorigin_x - targEndPos_x;
775 dist_y = panel_pos_y - resizeorigin_y;
776 if (dist_y <= 0 || dist_x / dist_y > ratio)
777 mySize_x = min(mySize_x, dist_x);
779 mySize_y = min(mySize_y, dist_y);
781 else if (resizeCorner == 4)
783 if (resizeorigin_x >= targEndPos_x)
785 if (resizeorigin_y >= targEndPos_y)
787 if (panel_pos_x >= resizeorigin_x + mySize_x)
789 if (panel_pos_y >= resizeorigin_y + mySize_y)
792 dist_x = panel_pos_x - resizeorigin_x;
793 dist_y = panel_pos_y - resizeorigin_y;
794 if (dist_y <= 0 || dist_x / dist_y > ratio)
795 mySize_x = min(mySize_x, dist_x);
797 mySize_y = min(mySize_y, dist_y);
799 if(cvar("hud_configure_checkcollisions_debug"))
800 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
806 void HUD_Panel_SetPosSize(vector mySize)
808 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
810 resizeorigin = panel_click_resizeorigin;
813 // minimum panel size cap
814 mySize_x = max(0.025 * vid_conwidth, mySize_x);
815 mySize_y = max(0.025 * vid_conheight, mySize_y);
817 if(highlightedPanel == HUD_PANEL_CHAT) // some panels have their own restrictions, like the chat panel (which actually only moves the engine chat print around). Looks bad if it's too small.
819 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
820 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
823 // collision testing|
824 // -----------------+
826 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
827 if(resizeCorner == 1) {
828 myPos_x = resizeorigin_x - mySize_x;
829 myPos_y = resizeorigin_y - mySize_y;
830 } else if(resizeCorner == 2) {
831 myPos_x = resizeorigin_x;
832 myPos_y = resizeorigin_y - mySize_y;
833 } else if(resizeCorner == 3) {
834 myPos_x = resizeorigin_x - mySize_x;
835 myPos_y = resizeorigin_y;
836 } else { // resizeCorner == 4
837 myPos_x = resizeorigin_x;
838 myPos_y = resizeorigin_y;
841 // left/top screen edges
843 mySize_x = mySize_x + myPos_x;
845 mySize_y = mySize_y + myPos_y;
847 // bottom/right screen edges
848 if(myPos_x + mySize_x > vid_conwidth)
849 mySize_x = vid_conwidth - myPos_x;
850 if(myPos_y + mySize_y > vid_conheight)
851 mySize_y = vid_conheight - myPos_y;
853 if(cvar("hud_configure_checkcollisions_debug"))
854 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
856 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
857 if(autocvar_hud_configure_grid)
859 mySize_x = floor((mySize_x/vid_conwidth)/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
860 mySize_y = floor((mySize_y/vid_conheight)/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
863 if(hud_configure_checkcollisions)
864 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
866 // minimum panel size cap, do this once more so we NEVER EVER EVER have a panel smaller than this, JUST IN CASE above code still makes the panel eg negative (impossible to resize back without changing cvars manually then)
867 mySize_x = max(0.025 * vid_conwidth, mySize_x);
868 mySize_y = max(0.025 * vid_conheight, mySize_y);
870 // do another pos check, as size might have changed by now
871 if(resizeCorner == 1) {
872 myPos_x = resizeorigin_x - mySize_x;
873 myPos_y = resizeorigin_y - mySize_y;
874 } else if(resizeCorner == 2) {
875 myPos_x = resizeorigin_x;
876 myPos_y = resizeorigin_y - mySize_y;
877 } else if(resizeCorner == 3) {
878 myPos_x = resizeorigin_x - mySize_x;
879 myPos_y = resizeorigin_y;
880 } else { // resizeCorner == 4
881 myPos_x = resizeorigin_x;
882 myPos_y = resizeorigin_y;
885 if(cvar("hud_configure_checkcollisions_debug"))
886 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
888 HUD_Panel_GetName(highlightedPanel);
890 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
891 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
893 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
894 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
898 float prevMouseClicked; // previous state
899 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
900 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
903 float menu_enabled_time;
904 float pressed_key_time;
905 void HUD_Panel_Arrow_Action(float nPrimary)
907 if (highlightedPanel_prev == -1 || mouseClicked)
910 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
913 if(autocvar_hud_configure_grid)
915 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
917 if (hudShiftState & S_SHIFT)
918 step = bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
920 step = 2 * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
924 if (hudShiftState & S_SHIFT)
925 step = bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
927 step = 2 * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
932 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
933 step = vid_conheight;
936 if (hudShiftState & S_SHIFT)
937 step = (step / 256); // more precision
939 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
942 highlightedPanel = highlightedPanel_prev;
944 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
946 if (hudShiftState & S_ALT) // resize
948 highlightedAction = 1;
949 if(nPrimary == K_UPARROW)
951 else if(nPrimary == K_RIGHTARROW)
953 else if(nPrimary == K_LEFTARROW)
955 else // if(nPrimary == K_DOWNARROW)
958 // ctrl+arrow reduces the size, instead of increasing it
959 // Note that ctrl disables collisions check too, but it's fine
960 // since we don't collide with anything reducing the size
961 if (hudShiftState & S_CTRL) {
963 resizeCorner = 5 - resizeCorner;
968 panel_click_resizeorigin = panel_pos;
969 if(resizeCorner == 1) {
970 panel_click_resizeorigin += mySize;
972 } else if(resizeCorner == 2) {
973 panel_click_resizeorigin_y += mySize_y;
975 } else if(resizeCorner == 3) {
976 panel_click_resizeorigin_x += mySize_x;
978 } else { // resizeCorner == 4
981 HUD_Panel_SetPosSize(mySize);
985 highlightedAction = 2;
988 if(nPrimary == K_UPARROW)
990 else if(nPrimary == K_DOWNARROW)
992 else if(nPrimary == K_LEFTARROW)
994 else // if(nPrimary == K_RIGHTARROW)
997 HUD_Panel_SetPos(pos);
1001 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1003 if(!autocvar__hud_configure)
1006 // allow console bind to work
1009 con_keys = findkeysforcommand("toggleconsole");
1010 keys = tokenize(con_keys);
1012 float hit_con_bind, i;
1013 for (i = 0; i < keys; ++i)
1015 if(nPrimary == stof(argv(i)))
1019 if(bInputType == 0) {
1020 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1021 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1022 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1024 else if(bInputType == 1) {
1025 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1026 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1027 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1030 if(nPrimary == K_MOUSE1)
1032 if(bInputType == 0) { // key pressed
1036 else if(bInputType == 1) {// key released
1041 else if(nPrimary == K_ESCAPE)
1043 if (bInputType == 1)
1045 disable_menu_alphacheck = 1;
1047 menu_enabled_time = time;
1048 localcmd("menu_showhudexit\n");
1050 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1052 if (bInputType == 1)
1054 pressed_key_time = 0;
1057 else if (pressed_key_time == 0)
1058 pressed_key_time = time;
1060 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1062 else if(hit_con_bind)
1065 return true; // Suppress ALL other input
1068 float HUD_Panel_HighlightCheck()
1074 while(j <= HUD_PANEL_NUM)
1079 HUD_Panel_UpdatePosSizeForId(i)
1081 panelPos = panel_pos;
1082 panelSize = panel_size;
1083 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1086 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1090 // resize from topleft border
1091 else if(mousepos_x >= panelPos_x - border && mousepos_y >= panelPos_y - border && mousepos_x <= panelPos_x + 0.5 * panelSize_x && mousepos_y <= panelPos_y + 0.5 * panelSize_y)
1095 // resize from topright border
1096 else if(mousepos_x >= panelPos_x + 0.5 * panelSize_x && mousepos_y >= panelPos_y - border && mousepos_x <= panelPos_x + panelSize_x + border && mousepos_y <= panelPos_y + 0.5 * panelSize_y)
1100 // resize from bottomleft border
1101 else if(mousepos_x >= panelPos_x - border && mousepos_y >= panelPos_y + 0.5 * panelSize_y && mousepos_x <= panelPos_x + 0.5 * panelSize_x && mousepos_y <= panelPos_y + panelSize_y + border)
1105 // resize from bottomright border
1106 else if(mousepos_x >= panelPos_x + 0.5 * panelSize_x && mousepos_y >= panelPos_y + 0.5 * panelSize_y && mousepos_x <= panelPos_x + panelSize_x + border && mousepos_y <= panelPos_y + panelSize_y + border)
1114 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1115 void HUD_Panel_FirstInDrawQ(float id)
1118 var float place = -1;
1119 // find out where in the array our current id is, save into place
1120 for(i = 0; i < HUD_PANEL_NUM; ++i)
1122 if(panel_order[i] == id)
1128 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1130 place = HUD_PANEL_NUM - 1;
1132 // move all ids up by one step in the array until "place"
1133 for(i = place; i > 0; --i)
1135 panel_order[i] = panel_order[i-1];
1137 // now save the new top id
1138 panel_order[0] = id;
1140 // let's save them into the cvar by some strcat trickery
1142 for(i = 0; i < HUD_PANEL_NUM; ++i)
1144 s = strcat(s, ftos(panel_order[i]), " ");
1146 cvar_set("_hud_panelorder", s);
1147 if(hud_panelorder_prev)
1148 strunzone(hud_panelorder_prev);
1149 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1152 void HUD_Panel_Highlight()
1158 while(j <= HUD_PANEL_NUM)
1163 HUD_Panel_UpdatePosSizeForId(i)
1165 panelPos = panel_pos;
1166 panelSize = panel_size;
1167 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1170 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1172 highlightedPanel = i;
1173 HUD_Panel_FirstInDrawQ(i);
1174 highlightedAction = 1;
1175 panel_click_distance = mousepos - panelPos;
1178 // resize from topleft border
1179 else if(mousepos_x >= panelPos_x - border && mousepos_y >= panelPos_y - border && mousepos_x <= panelPos_x + 0.5 * panelSize_x && mousepos_y <= panelPos_y + 0.5 * panelSize_y)
1181 highlightedPanel = i;
1182 HUD_Panel_FirstInDrawQ(i);
1183 highlightedAction = 2;
1185 panel_click_distance = mousepos - panelPos;
1186 panel_click_resizeorigin = panelPos + panelSize;
1189 // resize from topright border
1190 else if(mousepos_x >= panelPos_x + 0.5 * panelSize_x && mousepos_y >= panelPos_y - border && mousepos_x <= panelPos_x + panelSize_x + border && mousepos_y <= panelPos_y + 0.5 * panelSize_y)
1192 highlightedPanel = i;
1193 HUD_Panel_FirstInDrawQ(i);
1194 highlightedAction = 2;
1196 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1197 panel_click_distance_y = mousepos_y - panelPos_y;
1198 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1201 // resize from bottomleft border
1202 else if(mousepos_x >= panelPos_x - border && mousepos_y >= panelPos_y + 0.5 * panelSize_y && mousepos_x <= panelPos_x + 0.5 * panelSize_x && mousepos_y <= panelPos_y + panelSize_y + border)
1204 highlightedPanel = i;
1205 HUD_Panel_FirstInDrawQ(i);
1206 highlightedAction = 2;
1208 panel_click_distance_x = mousepos_x - panelPos_x;
1209 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1210 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1213 // resize from bottomright border
1214 else if(mousepos_x >= panelPos_x + 0.5 * panelSize_x && mousepos_y >= panelPos_y + 0.5 * panelSize_y && mousepos_x <= panelPos_x + panelSize_x + border && mousepos_y <= panelPos_y + panelSize_y + border)
1216 highlightedPanel = i;
1217 HUD_Panel_FirstInDrawQ(i);
1218 highlightedAction = 2;
1220 panel_click_distance = panelSize - mousepos + panelPos;
1221 panel_click_resizeorigin = panelPos;
1226 highlightedPanel_prev = -1;
1231 float highlightcheck;
1232 void HUD_Panel_Mouse()
1234 // TODO: needs better check... is there any float that contains the current state of the menu? _menu_alpha isn't apparently updated the frame the menu gets enabled
1235 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1236 disable_menu_alphacheck = 0;
1237 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1241 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1242 print("Highlighted: ", ftos(highlightedPanel), "\n");
1243 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1246 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1247 highlightedPanel = -1;
1248 highlightedAction = 0;
1250 if(highlightedPanel != -1)
1251 highlightedPanel_prev = highlightedPanel;
1253 mousepos = mousepos + getmousepos() * cvar("menu_mouse_speed");
1255 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1256 mousepos_y = bound(0, mousepos_y, vid_conheight);
1260 if(prevMouseClicked == 0)
1261 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1263 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1265 if(highlightedAction == 1)
1266 HUD_Panel_SetPos(mousepos - panel_click_distance);
1267 else if(highlightedAction == 2)
1270 if(resizeCorner == 1) {
1271 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1272 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1273 } else if(resizeCorner == 2) {
1274 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1275 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1276 } else if(resizeCorner == 3) {
1277 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1278 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1279 } else { // resizeCorner == 4
1280 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1281 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1283 HUD_Panel_SetPosSize(mySize);
1286 // doubleclick check
1287 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1289 mouseClicked = 0; // to prevent spam, I guess.
1290 disable_menu_alphacheck = 2;
1292 menu_enabled_time = time;
1293 HUD_Panel_GetName(highlightedPanel)
1294 localcmd("menu_showhudoptions ", panel_name, "\n");
1297 if(prevMouseClicked == 0)
1299 prevMouseClickedTime = time;
1300 prevMouseClickedPos = mousepos;
1305 highlightcheck = HUD_Panel_HighlightCheck();
1307 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1310 cursorsize = '32 32 0';
1312 if(highlightcheck == 0)
1313 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1314 else if(highlightcheck == 1)
1315 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1316 else if(highlightcheck == 2)
1317 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1319 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1321 prevMouseClicked = mouseClicked;
1324 // Weapon icons (#0)
1326 float weaponspace[10];
1327 #define HUD_Weapons_Clear()\
1329 for(idx = 0; idx < 10; ++idx)\
1330 weaponspace[idx] = 0;
1332 entity weaponorder[WEP_MAXCOUNT];
1333 void weaponorder_swap(float i, float j, entity pass)
1337 weaponorder[i] = weaponorder[j];
1341 string weaponorder_cmp_str_save;
1342 string weaponorder_cmp_str;
1343 float weaponorder_cmp(float i, float j, entity pass)
1346 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1347 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1348 return aj - ai; // the string is in REVERSE order (higher prio at the right is what we want, but higher prio first is the string)
1351 float GetAmmoStat(float i)
1355 case 0: return STAT_SHELLS;
1356 case 1: return STAT_NAILS;
1357 case 2: return STAT_ROCKETS;
1358 case 3: return STAT_CELLS;
1359 case 4: return STAT_FUEL;
1364 float GetAmmoTypeForWep(float i)
1368 case WEP_SHOTGUN: return 0;
1369 case WEP_UZI: return 1;
1370 case WEP_CAMPINGRIFLE: return 1;
1371 case WEP_GRENADE_LAUNCHER: return 2;
1372 case WEP_ELECTRO: return 3;
1373 case WEP_CRYLINK: return 3;
1374 case WEP_HLAC: return 3;
1375 case WEP_MINSTANEX: return 3;
1376 case WEP_NEX: return 3;
1377 case WEP_HAGAR: return 2;
1378 case WEP_ROCKET_LAUNCHER: return 2;
1379 case WEP_SEEKER: return 2;
1380 case WEP_FIREBALL: return 4;
1381 case WEP_HOOK: return 3;
1386 void HUD_Weapons(void)
1388 if(!autocvar_hud_panel_weapons && !autocvar__hud_configure)
1391 active_panel = HUD_PANEL_WEAPONS;
1392 HUD_Panel_UpdateCvars(weapons);
1394 float i, weapid, fade, weapon_stats, weapon_number, weapon_cnt;
1397 mySize = panel_size;
1400 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1402 self = get_weaponinfo(i);
1403 if(self.impulse >= 0)
1407 // TODO make this configurable
1408 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1410 if(weaponorder_cmp_str != weaponorder_cmp_str_save)
1412 if(weaponorder_cmp_str_save)
1413 strunzone(weaponorder_cmp_str_save);
1414 weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
1416 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1418 self = get_weaponinfo(i);
1419 if(self.impulse >= 0)
1421 weaponorder[weapon_cnt] = self;
1425 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1428 HUD_Panel_DrawBg(1);
1429 if(panel_bg_padding)
1431 pos += '1 1 0' * panel_bg_padding;
1432 mySize -= '2 2 0' * panel_bg_padding;
1436 weapon_stats = getstati(STAT_DAMAGE_HITS);
1437 weapon_number = weapon_stats & 63;
1438 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1440 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1441 weapon_number = weapon_stats & 63;
1442 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1444 if(cvar_or("hud_panel_weapons_fade", 1))
1446 fade = 3.2 - 2 * (time - weapontime);
1447 fade = bound(0.7, fade, 1);
1452 HUD_Weapons_Clear();
1454 float rows, columns;
1455 rows = mySize_y/mySize_x;
1456 rows = bound(1, floor((sqrt(4 * autocvar_hud_panel_weapons_aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1458 columns = ceil(WEP_COUNT/rows);
1461 float a, type, fullammo;
1463 when = autocvar_hud_panel_weapons_complainbubble_time;
1465 fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
1471 for(i = 0; i < weapon_cnt; ++i)
1473 wpnpos = pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows);
1474 wpnsize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
1476 self = weaponorder[i];
1477 weapid = self.impulse;
1479 // draw background behind currently selected weapon
1480 if(self.weapon == activeweapon)
1481 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1483 // draw the weapon accuracy
1486 float weapon_hit, weapon_damage;
1487 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1490 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1491 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1494 // find the max level lower than weapon_stats
1497 while ( j && weapon_stats < acc_lev[j] )
1500 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
1502 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
1503 color = acc_color(j);
1504 color = color + factor * (acc_color(j+1) - color);
1507 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1510 // draw the weapon icon
1511 if((self.impulse >= 0) && (getstati(STAT_WEAPONS) & self.weapons))
1513 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1515 if(autocvar_hud_panel_weapons_label == 1) // weapon number
1516 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * mySize_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1517 else if(autocvar_hud_panel_weapons_label == 2) // bind
1518 drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * mySize_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1520 // draw ammo status bar
1521 if(autocvar_hud_panel_weapons_ammo && weapid != WEP_TUBA && weapid != WEP_LASER && weapid != WEP_PORTO)
1524 type = GetAmmoTypeForWep(weapid);
1526 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
1531 case 0: fullammo = autocvar_hud_panel_weapons_ammo_full_shells; break;
1532 case 1: fullammo = autocvar_hud_panel_weapons_ammo_full_nails; break;
1533 case 2: fullammo = autocvar_hud_panel_weapons_ammo_full_rockets; break;
1534 case 3: fullammo = autocvar_hud_panel_weapons_ammo_full_cells; break;
1535 case 4: fullammo = autocvar_hud_panel_weapons_ammo_full_fuel; break;
1536 default: fullammo = 60;
1541 if(wpnsize_x/wpnsize_y > autocvar_hud_panel_weapons_aspect)
1543 barsize_x = autocvar_hud_panel_weapons_aspect * wpnsize_y;
1544 barsize_y = wpnsize_y;
1546 barpos_x = wpnpos_x + (wpnsize_x - barsize_x) / 2;
1547 barpos_y = wpnpos_y;
1551 barsize_y = 1/autocvar_hud_panel_weapons_aspect * wpnsize_x;
1552 barsize_x = wpnsize_x;
1554 barpos_y = wpnpos_y + (wpnsize_y - barsize_y) / 2;
1555 barpos_x = wpnpos_x;
1561 barsize_x * bound(0, a/fullammo, 1),
1563 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, autocvar_hud_panel_weapons_ammo_color, panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha, DRAWFLAG_NORMAL);
1564 drawresetcliparea();
1569 // draw a "ghost weapon icon" if you don't have the weapon
1572 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
1575 // draw the complain message
1576 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
1580 if(complain_weapon_time + when > time)
1583 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1587 if(complain_weapon_time + when > time)
1594 if(complain_weapon_type == 0) {
1596 color = autocvar_hud_panel_weapons_complainbubble_color_outofammo;
1598 else if(complain_weapon_type == 1) {
1600 color = autocvar_hud_panel_weapons_complainbubble_color_donthave;
1604 color = autocvar_hud_panel_weapons_complainbubble_color_unavailable;
1606 drawpic_aspect_skin(wpnpos + '1 1 0' * autocvar_hud_panel_weapons_complainbubble_padding, "weapon_complainbubble", wpnsize - '2 2 0' * autocvar_hud_panel_weapons_complainbubble_padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
1607 drawstring_aspect(wpnpos + '1 1 0' * autocvar_hud_panel_weapons_complainbubble_padding, s, wpnsize - '2 2 0' * autocvar_hud_panel_weapons_complainbubble_padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
1623 float GetAmmoItemCode(float i)
1627 case 0: return IT_SHELLS;
1628 case 1: return IT_NAILS;
1629 case 2: return IT_ROCKETS;
1630 case 3: return IT_CELLS;
1631 case 4: return IT_FUEL;
1636 string GetAmmoPicture(float i)
1640 case 0: return "ammo_shells";
1641 case 1: return "ammo_bullets";
1642 case 2: return "ammo_rockets";
1643 case 3: return "ammo_cells";
1644 case 4: return "ammo_fuel";
1649 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1652 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1653 if(autocvar__hud_configure)
1663 if(currently_selected)
1668 vector newSize, newPos;
1669 if(mySize_x/mySize_y > 3)
1671 newSize_x = 3 * mySize_y;
1672 newSize_y = mySize_y;
1674 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1679 newSize_y = 1/3 * mySize_x;
1680 newSize_x = mySize_x;
1682 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1686 vector picpos, numpos;
1687 if(autocvar_hud_panel_ammo_iconalign)
1690 picpos = newPos + eX * 2 * newSize_y;
1694 numpos = newPos + eX * newSize_y;
1698 if (currently_selected)
1699 drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1701 drawfont = hud_bigfont;
1703 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1704 else // "ghost" ammo count
1705 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1706 drawfont = hud_font;
1708 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1709 else // "ghost" ammo icon
1710 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1715 if(!autocvar_hud_panel_ammo && !autocvar__hud_configure)
1718 active_panel = HUD_PANEL_AMMO;
1719 HUD_Panel_UpdateCvars(ammo);
1720 float i, currently_selected;
1724 mySize = panel_size;
1726 HUD_Panel_DrawBg(1);
1727 if(panel_bg_padding)
1729 pos += '1 1 0' * panel_bg_padding;
1730 mySize -= '2 2 0' * panel_bg_padding;
1733 float rows, columns;
1734 rows = mySize_y/mySize_x;
1735 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1736 // ^^^ ammo item aspect goes here
1738 columns = ceil(AMMO_COUNT/rows);
1742 for (i = 0; i < AMMO_COUNT; ++i) {
1743 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1744 if(autocvar_hud_panel_ammo_onlycurrent) {
1745 if(autocvar__hud_configure)
1747 if (currently_selected || autocvar__hud_configure)
1749 DrawAmmoItem(pos, mySize, i, currently_selected);
1753 DrawAmmoItem(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), i, currently_selected);
1758 column = column + 1;
1764 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float alpha)
1766 vector newSize, newPos;
1767 if(mySize_x/mySize_y > 3)
1769 newSize_x = 3 * mySize_y;
1770 newSize_y = mySize_y;
1772 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1777 newSize_y = 1/3 * mySize_x;
1778 newSize_x = mySize_x;
1780 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1784 vector picpos, numpos;
1787 if(iconalign == 1 || iconalign == 3) // right align
1790 picpos = newPos + eX * 2 * newSize_y;
1794 numpos = newPos + eX * newSize_y;
1800 if(iconalign == 0 || iconalign == 3) // left align
1802 numpos = newPos + eX * newSize_y;
1808 picpos = newPos + eX * 2 * newSize_y;
1812 drawfont = hud_bigfont;
1813 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1814 drawfont = hud_font;
1815 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1818 void DrawNumIcon_expanding(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float fadelerp)
1821 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
1823 DrawNumIcon(iconalign, myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, left, color, (1 - fadelerp));
1828 void HUD_Powerups(void) {
1829 if(!autocvar_hud_panel_powerups && !autocvar__hud_configure)
1832 active_panel = HUD_PANEL_POWERUPS;
1833 HUD_Panel_UpdateCvars(powerups);
1835 stat_items = getstati(STAT_ITEMS);
1837 if(!autocvar__hud_configure)
1839 if not(stat_items & IT_STRENGTH)
1840 if not(stat_items & IT_INVINCIBLE)
1843 if (getstati(STAT_HEALTH) <= 0)
1849 mySize = panel_size;
1851 float strength_time, shield_time;
1853 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1854 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1856 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
1857 if(panel_bg_padding)
1859 pos += '1 1 0' * panel_bg_padding;
1860 mySize -= '2 2 0' * panel_bg_padding;
1863 if(autocvar__hud_configure)
1869 vector barpos, barsize;
1873 string leftname, rightname;
1874 float leftcnt, rightcnt;
1875 float leftexact, rightexact;
1876 if (autocvar_hud_panel_powerups_flip) {
1877 leftname = "strength";
1878 leftcnt = ceil(strength_time);
1879 leftexact = strength_time;
1881 rightname = "shield";
1882 rightcnt = ceil(shield_time);
1883 rightexact = shield_time;
1885 leftname = "shield";
1886 leftcnt = ceil(shield_time);
1887 leftexact = shield_time;
1889 rightname = "strength";
1890 rightcnt = ceil(strength_time);
1891 rightexact = strength_time;
1894 drawfont = hud_bigfont;
1895 if (mySize_x/mySize_y > 4)
1899 if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // right align
1900 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1901 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1902 } else { // left align
1904 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1907 if(autocvar_hud_panel_powerups_progressbar)
1909 HUD_Panel_GetProgressBarColor(leftname)
1910 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
1913 DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
1915 DrawNumIcon_expanding(autocvar_hud_panel_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
1920 if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // left align
1921 barpos = pos + eX * 0.5 * mySize_x;
1922 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1923 } else { // right align
1924 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1925 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1928 if(autocvar_hud_panel_powerups_progressbar)
1930 HUD_Panel_GetProgressBarColor(rightname)
1931 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1) * panel_fg_alpha, DRAWFLAG_NORMAL);
1934 DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
1936 DrawNumIcon_expanding(autocvar_hud_panel_powerups_iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1));
1939 else if (mySize_x/mySize_y > 1.5)
1943 if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // right align
1944 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1945 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1946 } else { // left align
1948 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1951 if(autocvar_hud_panel_powerups_progressbar)
1953 HUD_Panel_GetProgressBarColor(leftname)
1954 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1) * panel_fg_alpha, DRAWFLAG_NORMAL);
1957 DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
1959 DrawNumIcon_expanding(autocvar_hud_panel_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
1964 if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // left align
1965 barpos = pos + eY * 0.5 * mySize_y;
1966 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1967 } else { // right align
1968 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1969 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1972 if(autocvar_hud_panel_powerups_progressbar)
1974 HUD_Panel_GetProgressBarColor(rightname)
1975 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1) * panel_fg_alpha, DRAWFLAG_NORMAL);
1978 DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
1980 DrawNumIcon_expanding(autocvar_hud_panel_powerups_iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1));
1987 if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // down align
1988 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1989 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1990 } else { // up align
1992 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1995 if(autocvar_hud_panel_powerups_iconalign == 1 || autocvar_hud_panel_powerups_iconalign == 3) { // down align
1996 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
1997 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
1998 } else { // up align
1999 picpos = pos + eX * 0.05 * mySize_x;
2000 numpos = pos + eY * 0.4 * mySize_x;
2003 if(autocvar_hud_panel_powerups_progressbar)
2005 HUD_Panel_GetProgressBarColor(leftname)
2006 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1) * panel_fg_alpha, DRAWFLAG_NORMAL);
2009 drawpic_aspect_skin_expanding(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, bound(0, (leftcnt - leftexact) / 0.5, 1));
2011 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2012 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2017 if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // up align
2018 barpos = pos + eX * 0.5 * mySize_x;
2019 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2020 } else { // down align
2021 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
2022 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2025 if(autocvar_hud_panel_powerups_iconalign == 0 || autocvar_hud_panel_powerups_iconalign == 3) { // up align
2026 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2027 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2028 } else { // down align
2029 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2030 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2033 if(autocvar_hud_panel_powerups_progressbar)
2035 HUD_Panel_GetProgressBarColor(rightname)
2036 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1) * panel_fg_alpha, DRAWFLAG_NORMAL);
2039 drawpic_aspect_skin_expanding(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, bound(0, (rightcnt - rightexact) / 0.5, 1));
2041 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2042 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2045 drawfont = hud_font;
2048 // Health/armor (#3)
2050 void HUD_HealthArmor(void)
2052 if(!autocvar_hud_panel_healtharmor && !autocvar__hud_configure)
2055 active_panel = HUD_PANEL_HEALTHARMOR;
2056 HUD_Panel_UpdateCvars(healtharmor);
2059 mySize = panel_size;
2061 HUD_Panel_DrawBg(1);
2062 if(panel_bg_padding)
2064 pos += '1 1 0' * panel_bg_padding;
2065 mySize -= '2 2 0' * panel_bg_padding;
2068 float armor, health;
2069 armor = getstati(STAT_ARMOR);
2070 health = getstati(STAT_HEALTH);
2073 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
2075 if(autocvar__hud_configure)
2085 vector barpos, barsize;
2089 drawfont = hud_bigfont;
2090 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
2093 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2098 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
2099 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2100 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2101 } else { // left align
2103 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2107 if(v_z) // NOT fully armored
2109 biggercount = "health";
2110 if(autocvar_hud_panel_healtharmor_progressbar)
2112 HUD_Panel_GetProgressBarColor("health")
2113 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2116 drawpic_aspect_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "armor", '0.5 0.5 0' * mySize_y, '1 1 1', panel_fg_alpha * armor / health, DRAWFLAG_NORMAL);
2120 biggercount = "armor";
2121 if(autocvar_hud_panel_healtharmor_progressbar)
2123 HUD_Panel_GetProgressBarColor("armor")
2124 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2127 drawpic_aspect_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "health", '0.5 0.5 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2129 DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200), 1);
2134 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2135 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2136 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2139 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2141 HUD_Panel_GetProgressBarColor("fuel")
2142 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2147 string leftname, rightname;
2148 float leftcnt, rightcnt;
2149 float leftactive, rightactive;
2150 float leftalpha, rightalpha;
2151 if (autocvar_hud_panel_healtharmor_flip) { // old style layout with armor left/top of health
2156 leftalpha = min((armor+10)/55, 1);
2158 rightname = "health";
2163 leftname = "health";
2168 rightname = "armor";
2172 rightalpha = min((armor+10)/55, 1);
2175 if (mySize_x/mySize_y > 4)
2179 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
2180 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2181 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2182 } else { // left align
2184 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2187 if(autocvar_hud_panel_healtharmor_progressbar)
2189 HUD_Panel_GetProgressBarColor(leftname)
2190 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2192 DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
2197 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2198 barpos = pos + eX * 0.5 * mySize_x;
2199 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2200 } else { // right align
2201 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2202 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2205 if(autocvar_hud_panel_healtharmor_progressbar)
2207 HUD_Panel_GetProgressBarColor(rightname)
2208 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2210 DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(rightcnt, 200), 1);
2215 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2216 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2217 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2220 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2222 HUD_Panel_GetProgressBarColor("fuel")
2223 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2226 else if (mySize_x/mySize_y > 1.5)
2230 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
2231 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2232 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2233 } else { // left align
2235 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2238 if(autocvar_hud_panel_healtharmor_progressbar)
2240 HUD_Panel_GetProgressBarColor(leftname)
2241 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2243 DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
2248 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2249 barpos = pos + eY * 0.5 * mySize_y;
2250 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2251 } else { // right align
2252 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2253 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2256 if(autocvar_hud_panel_healtharmor_progressbar)
2258 HUD_Panel_GetProgressBarColor(rightname)
2259 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2261 DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(rightcnt, 200), 1);
2266 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2267 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2268 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2271 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2273 HUD_Panel_GetProgressBarColor("fuel")
2274 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2281 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // down align
2282 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2283 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2284 } else { // up align
2286 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2289 if(autocvar_hud_panel_healtharmor_iconalign == 1 || autocvar_hud_panel_healtharmor_iconalign == 3) { // down align
2290 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2291 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2292 } else { // up align
2293 picpos = pos + eX * 0.05 * mySize_x;
2294 numpos = pos + eY * 0.4 * mySize_x;
2297 if(autocvar_hud_panel_healtharmor_progressbar)
2299 HUD_Panel_GetProgressBarColor(leftname)
2300 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2302 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2303 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, HUD_Get_Num_Color(leftcnt, 200), panel_fg_alpha, DRAWFLAG_NORMAL);
2308 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // up align
2309 barpos = pos + eX * 0.5 * mySize_x;
2310 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2311 } else { // down align
2312 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2313 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2316 if(autocvar_hud_panel_healtharmor_iconalign == 0 || autocvar_hud_panel_healtharmor_iconalign == 3) { // up align
2317 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2318 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2319 } else { // down align
2320 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2321 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2324 if(autocvar_hud_panel_healtharmor_progressbar)
2326 HUD_Panel_GetProgressBarColor(rightname)
2327 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2329 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2330 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, HUD_Get_Num_Color(rightcnt, 200), panel_fg_alpha, DRAWFLAG_NORMAL);
2335 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2337 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2339 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2340 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2342 HUD_Panel_GetProgressBarColor("fuel")
2343 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2347 drawfont = hud_font;
2350 // Notification area (#4)
2353 string Weapon_SuicideMessage(float deathtype)
2355 w_deathtype = deathtype;
2356 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2357 return w_deathtypestring;
2360 string Weapon_KillMessage(float deathtype)
2362 w_deathtype = deathtype;
2363 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2364 return w_deathtypestring;
2367 float killnotify_times[10];
2368 float killnotify_deathtype[10];
2369 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2370 string killnotify_attackers[10];
2371 string killnotify_victims[10];
2372 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2375 for (i = 9; i > 0; --i) {
2376 killnotify_times[i] = killnotify_times[i-1];
2377 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2378 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2379 if(killnotify_attackers[i])
2380 strunzone(killnotify_attackers[i]);
2381 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2382 if(killnotify_victims[i])
2383 strunzone(killnotify_victims[i]);
2384 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2386 killnotify_times[0] = time;
2387 killnotify_deathtype[0] = wpn;
2388 killnotify_actiontype[0] = actiontype;
2389 if(killnotify_attackers[0])
2390 strunzone(killnotify_attackers[0]);
2391 killnotify_attackers[0] = strzone(attacker);
2392 if(killnotify_victims[0])
2393 strunzone(killnotify_victims[0]);
2394 killnotify_victims[0] = strzone(victim);
2397 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2400 float alsoprint, gentle;
2401 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2402 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2404 if(msg == MSG_SUICIDE) {
2405 w = DEATH_WEAPONOF(type);
2407 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2409 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
2410 } else if (type == DEATH_KILL) {
2411 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2413 print ("^1",s1, "^1 couldn't take it anymore\n");
2414 } else if (type == DEATH_ROT) {
2415 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2417 print ("^1",s1, "^1 died\n");
2418 } else if (type == DEATH_NOAMMO) {
2419 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2421 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2422 } else if (type == DEATH_CAMP) {
2423 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2425 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2426 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2427 HUD_KillNotify_Push(s1, "", 0, type);
2429 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2430 } else if (type == DEATH_CHEAT) {
2431 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2433 print ("^1",s1, "^1 unfairly eliminated themself\n");
2434 } else if (type == DEATH_FIRE) {
2435 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2437 print ("^1",s1, "^1 burned to death\n");
2438 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2439 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2441 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2444 if (stof(s2) > 2) // killcount > 2
2445 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2446 } else if(msg == MSG_KILL) {
2447 w = DEATH_WEAPONOF(type);
2449 HUD_KillNotify_Push(s1, s2, 1, type);
2451 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
2453 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2454 HUD_KillNotify_Push(s1, s2, 1, type);
2458 print ("^1", s1, "^1 took action against a team mate\n");
2460 print ("^1", s1, "^1 mows down a team mate\n");
2463 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2465 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2467 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2469 else if (stof(s2) > 2) {
2471 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2473 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2476 else if(type == KILL_FIRST_BLOOD)
2477 print("^1",s1, "^1 drew first blood", "\n");
2479 else if (type == DEATH_TELEFRAG) {
2480 HUD_KillNotify_Push(s2, s1, 1, DEATH_TELEFRAG);
2482 print ("^1",s1, "^1 tried to occupy ", s2, "^1's teleport destination space\n");
2484 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2486 else if (type == DEATH_DROWN) {
2487 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2489 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2491 else if (type == DEATH_SLIME) {
2492 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2494 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2496 else if (type == DEATH_LAVA) {
2497 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2499 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2501 else if (type == DEATH_FALL) {
2502 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2504 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2506 else if (type == DEATH_SHOOTING_STAR) {
2507 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2509 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2511 else if (type == DEATH_SWAMP) {
2512 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2514 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2516 else if (type == DEATH_HURTTRIGGER)
2518 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2520 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2521 } else if(type == DEATH_SBCRUSH) {
2522 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2524 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2525 } else if(type == DEATH_SBMINIGUN) {
2526 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2528 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2529 } else if(type == DEATH_SBROCKET) {
2530 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2532 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2533 } else if(type == DEATH_SBBLOWUP) {
2534 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2536 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2537 } else if(type == DEATH_WAKIGUN) {
2538 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2540 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2541 } else if(type == DEATH_WAKIROCKET) {
2542 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2544 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2545 } else if(type == DEATH_WAKIBLOWUP) {
2546 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2548 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2549 } else if(type == DEATH_TURRET) {
2550 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2552 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2553 } else if(type == DEATH_TOUCHEXPLODE) {
2554 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2556 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2557 } else if(type == DEATH_CHEAT) {
2558 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2560 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2561 } else if (type == DEATH_FIRE) {
2562 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2564 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2565 } else if (type == DEATH_CUSTOM) {
2566 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2568 print ("^1",s1, "^1 ", s2, "\n");
2570 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2572 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2574 } else if(msg == MSG_SPREE) {
2575 if(type == KILL_END_SPREE) {
2577 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2579 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2580 } else if(type == KILL_SPREE) {
2582 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2584 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2585 } else if(type == KILL_SPREE_3) {
2587 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2589 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2590 } else if(type == KILL_SPREE_5) {
2592 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2594 print (s1,"^7 unleashes ^1RAGE\n");
2595 } else if(type == KILL_SPREE_10) {
2597 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2599 print (s1,"^7 starts the ^1MASSACRE!\n");
2600 } else if(type == KILL_SPREE_15) {
2602 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2604 print (s1,"^7 executes ^1MAYHEM!\n");
2605 } else if(type == KILL_SPREE_20) {
2607 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2609 print (s1,"^7 is a ^1BERSERKER!\n");
2610 } else if(type == KILL_SPREE_25) {
2612 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2614 print (s1,"^7 inflicts ^1CARNAGE!\n");
2615 } else if(type == KILL_SPREE_30) {
2617 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2619 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2621 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2622 if (type == DEATH_DROWN) {
2623 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2627 print ("^1",s1, "^1 was in the water for too long\n");
2629 print ("^1",s1, "^1 drowned\n");
2631 } else if (type == DEATH_SLIME) {
2632 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2634 print ("^1",s1, "^1 was slimed\n");
2635 } else if (type == DEATH_LAVA) {
2636 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2640 print ("^1",s1, "^1 found a hot place\n");
2642 print ("^1",s1, "^1 turned into hot slag\n");
2644 } else if (type == DEATH_FALL) {
2645 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2649 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2651 print ("^1",s1, "^1 hit the ground with a crunch\n");
2653 } else if (type == DEATH_SHOOTING_STAR) {
2654 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2656 print ("^1",s1, "^1 became a shooting star\n");
2657 } else if (type == DEATH_SWAMP) {
2658 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2662 print ("^1",s1, "^1 discovered a swamp\n");
2664 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2666 } else if(type == DEATH_TURRET) {
2667 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2669 print ("^1",s1, "^1 was mowed down by a turret \n");
2670 } else if (type == DEATH_CUSTOM) {
2671 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2673 print ("^1",s1, "^1 ", s2, "\n");
2674 } else if (type == DEATH_HURTTRIGGER) {
2675 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2677 print ("^1",s1, "^1 was in the wrong place\n");
2678 } else if(type == DEATH_TOUCHEXPLODE) {
2679 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2681 print ("^1",s1, "^1 died in an accident\n");
2682 } else if(type == DEATH_CHEAT) {
2683 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2685 print ("^1",s1, "^1 was unfairly eliminated\n");
2686 } else if(type == DEATH_FIRE) {
2687 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2691 print ("^1",s1, "^1 felt a little hot\n");
2693 print ("^1",s1, "^1 burnt to death\n");
2696 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2700 print ("^1",s1, "^1 needs a restart\n");
2702 print ("^1",s1, "^1 died\n");
2705 } else if(msg == MSG_KILL_ACTION_SPREE) {
2707 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2709 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2710 } else if(msg == MSG_INFO) {
2711 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2712 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2713 print(s1, "^7 got the ", s2, "\n");
2714 } else if(type == INFO_LOSTFLAG) {
2715 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2716 print(s1, "^7 lost the ", s2, "\n");
2717 } else if(type == INFO_PICKUPFLAG) {
2718 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2719 print(s1, "^7 picked up the ", s2, "\n");
2720 } else if(type == INFO_RETURNFLAG) {
2721 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2722 print(s1, "^7 returned the ", s2, "\n");
2723 } else if(type == INFO_CAPTUREFLAG) {
2724 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
2725 print(s1, "^7 captured the ", s2, s3, "\n");
2730 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2732 void HUD_Centerprint(string s1, string s2, float type, float msg)
2735 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2736 if(msg == MSG_SUICIDE) {
2737 if (type == DEATH_TEAMCHANGE) {
2738 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2739 } else if (type == DEATH_AUTOTEAMCHANGE) {
2740 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2741 } else if (type == DEATH_CAMP) {
2743 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2745 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2746 } else if (type == DEATH_NOAMMO) {
2748 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2750 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2751 } else if (type == DEATH_ROT) {
2753 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2755 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2756 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2758 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2760 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2761 } else if (type == DEATH_QUIET) {
2763 } else { // generic message
2765 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2767 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2769 } else if(msg == MSG_KILL) {
2770 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2772 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2774 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2776 } else if (type == KILL_FIRST_BLOOD) {
2778 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2780 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2782 } else if (type == KILL_FIRST_VICTIM) {
2784 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2786 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2788 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2790 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2792 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2794 } else if (type == KILL_TYPEFRAGGED) {
2796 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2798 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2800 } else if (type == KILL_FRAG) {
2802 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2804 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2806 } else { // generic message
2808 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2810 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2813 } else if(msg == MSG_KILL_ACTION) {
2814 // TODO: invent more centerprints here?
2815 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2819 void HUD_Notify (void)
2821 if(!autocvar_hud_panel_notify && !autocvar__hud_configure)
2824 active_panel = HUD_PANEL_NOTIFY;
2825 HUD_Panel_UpdateCvars(notify);
2828 mySize = panel_size;
2830 HUD_Panel_DrawBg(1);
2831 if(panel_bg_padding)
2833 pos += '1 1 0' * panel_bg_padding;
2834 mySize -= '2 2 0' * panel_bg_padding;
2837 float entries, height;
2838 entries = bound(1, floor(10 * mySize_y/mySize_x), 10);
2839 height = mySize_y/entries;
2842 fontsize = '0.5 0.5 0' * height;
2846 when = autocvar_hud_panel_notify_time;
2848 fadetime = autocvar_hud_panel_notify_fadetime;
2852 vector pos_attacker, pos_victim;
2854 float width_attacker;
2855 string attacker, victim;
2858 for(j = 0; j < entries; ++j)
2861 if(autocvar_hud_panel_notify_flip)
2863 else // rather nasty hack for ordering items from the bottom up
2864 i = entries - j - 1;
2868 if(killnotify_times[j] + when > time)
2871 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2875 if(killnotify_times[j] + when > time)
2882 w = DEATH_WEAPONOF(killnotify_deathtype[j]);
2884 // TODO: maybe print in team colors?
2887 if(killnotify_actiontype[j] == 0 && !autocvar__hud_configure)
2889 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2890 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
2891 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2893 if(killnotify_deathtype[j] == DEATH_GENERIC)
2897 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2899 s = "notify_outofammo";
2901 else if(killnotify_deathtype[j] == DEATH_KILL)
2903 s = "notify_selfkill";
2905 else if(killnotify_deathtype[j] == DEATH_CAMP)
2907 s = "notify_camping";
2909 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2911 s = "notify_teamkill_red";
2913 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2915 s = "notify_teamkill_blue";
2917 else if(killnotify_deathtype[j] == DEATH_DROWN)
2921 else if(killnotify_deathtype[j] == DEATH_SLIME)
2925 else if(killnotify_deathtype[j] == DEATH_LAVA)
2929 else if(killnotify_deathtype[j] == DEATH_FALL)
2933 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2935 s = "notify_shootingstar";
2937 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2941 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2943 if(killnotify_victims[j] == "^1RED^7 flag")
2945 s = "notify_red_taken";
2949 s = "notify_blue_taken";
2952 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2954 if(killnotify_victims[j] == "^1RED^7 flag")
2956 s = "notify_red_returned";
2960 s = "notify_blue_returned";
2963 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2965 if(killnotify_victims[j] == "^1RED^7 flag")
2967 s = "notify_red_lost";
2971 s = "notify_blue_lost";
2974 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
2976 if(killnotify_victims[j] == "^1RED^7 flag")
2978 s = "notify_red_captured";
2982 s = "notify_blue_captured";
2987 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2988 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2991 // X [did action to] Y
2994 if(autocvar__hud_configure)
2996 attacker = textShortenToWidth("Player1", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2997 victim = textShortenToWidth("Player2", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2998 a = bound(0, (when - j) / 4, 1);
3002 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3003 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3005 width_attacker = stringwidth(attacker, TRUE, fontsize);
3006 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
3007 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
3008 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
3010 if(autocvar__hud_configure) // example actions for config mode
3012 s = "weaponelectro";
3014 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
3016 s = "notify_melee_laser";
3018 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_SHOTGUN)
3020 s = "notify_melee_shotgun";
3022 else if(WEP_VALID(w))
3024 self = get_weaponinfo(w);
3025 s = strcat("weapon", self.netname);
3027 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
3029 s = "notify_teamkill_red";
3031 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
3033 s = "notify_teamkill_red";
3035 else if(killnotify_deathtype[j] == DEATH_TELEFRAG)
3037 s = "notify_telefrag";
3039 else if(killnotify_deathtype[j] == DEATH_DROWN)
3043 else if(killnotify_deathtype[j] == DEATH_SLIME)
3047 else if(killnotify_deathtype[j] == DEATH_LAVA)
3051 else if(killnotify_deathtype[j] == DEATH_FALL)
3055 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
3057 s = "notify_shootingstar";
3059 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
3065 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3066 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3067 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3076 string seconds_tostring(float sec)
3079 minutes = floor(sec / 60);
3081 sec -= minutes * 60;
3084 s = ftos(100 + sec);
3086 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3089 void HUD_Timer(void)
3091 if(!autocvar_hud_panel_timer && !autocvar__hud_configure)
3094 active_panel = HUD_PANEL_TIMER;
3095 HUD_Panel_UpdateCvars(timer);
3098 mySize = panel_size;
3100 HUD_Panel_DrawBg(1);
3101 if(panel_bg_padding)
3103 pos += '1 1 0' * panel_bg_padding;
3104 mySize -= '2 2 0' * panel_bg_padding;
3108 float timelimit, elapsedTime, timeleft, minutesLeft;
3110 timelimit = getstatf(STAT_TIMELIMIT);
3112 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3113 timeleft = ceil(timeleft);
3115 minutesLeft = floor(timeleft / 60);
3118 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3119 timer_color = '1 1 1'; //white
3120 else if(minutesLeft >= 1)
3121 timer_color = '1 1 0'; //yellow
3123 timer_color = '1 0 0'; //red
3125 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
3126 if (time < getstatf(STAT_GAMESTARTTIME)) {
3127 //while restart is still active, show 00:00
3128 timer = seconds_tostring(0);
3130 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3131 timer = seconds_tostring(elapsedTime);
3134 timer = seconds_tostring(timeleft);
3137 drawfont = hud_bigfont;
3138 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3139 drawfont = hud_font;
3144 void HUD_Radar(void)
3146 if ((autocvar_hud_panel_radar == 0 || (autocvar_hud_panel_radar != 2 && !teamplay)) && !autocvar__hud_configure)
3149 active_panel = HUD_PANEL_RADAR;
3150 HUD_Panel_UpdateCvars(radar);
3153 mySize = panel_size;
3155 HUD_Panel_DrawBg(1);
3156 if(panel_bg_padding)
3158 pos += '1 1 0' * panel_bg_padding;
3159 mySize -= '2 2 0' * panel_bg_padding;
3162 local float color1, color2; // color already declared as a global in hud.qc
3165 float scale2d, normalsize, bigsize;
3168 teamradar_origin2d = pos + 0.5 * mySize;
3169 teamradar_size2d = mySize;
3171 if(minimapname == "")
3174 teamradar_loadcvars();
3176 switch(hud_panel_radar_zoommode)
3180 f = current_zoomfraction;
3183 f = 1 - current_zoomfraction;
3193 switch(hud_panel_radar_rotation)
3196 teamradar_angle = view_angles_y - 90;
3199 teamradar_angle = 90 * hud_panel_radar_rotation;
3203 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3204 teamradar_size2d = mySize;
3206 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3208 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3209 if(hud_panel_radar_rotation == 0)
3211 // max-min distance must fit the radar in any rotation
3212 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3216 vector c0, c1, c2, c3, span;
3217 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3218 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3219 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3220 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3222 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3223 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3225 // max-min distance must fit the radar in x=x, y=y
3227 teamradar_size2d_x * scale2d / (1.05 * span_x),
3228 teamradar_size2d_y * scale2d / (1.05 * span_y)
3232 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
3233 if(bigsize > normalsize)
3234 normalsize = bigsize;
3238 + (1 - f) * normalsize;
3239 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3240 f * (mi_min + mi_max) * 0.5
3241 + (1 - f) * view_origin);
3243 color1 = GetPlayerColor(player_localentnum-1);
3244 rgb = GetTeamRGB(color1);
3253 draw_teamradar_background(hud_panel_radar_foreground_alpha);
3255 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3256 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3257 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3258 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3259 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3261 color2 = GetPlayerColor(tm.sv_entnum);
3262 //if(color == COLOR_SPECTATOR || color == color2)
3263 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3265 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3267 drawresetcliparea();
3272 void HUD_Score(void)
3274 if(!autocvar_hud_panel_score && !autocvar__hud_configure)
3277 active_panel = HUD_PANEL_SCORE;
3278 HUD_Panel_UpdateCvars(score);
3281 mySize = panel_size;
3283 HUD_Panel_DrawBg(1);
3284 if(panel_bg_padding)
3286 pos += '1 1 0' * panel_bg_padding;
3287 mySize -= '2 2 0' * panel_bg_padding;
3290 float score, distribution, leader;
3291 vector distribution_color;
3293 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3295 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3296 string timer, distrtimer;
3298 pl = players.sort_next;
3301 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3302 if(pl.scores[ps_primary] == 0)
3305 score = me.(scores[ps_primary]);
3306 timer = TIME_ENCODED_TOSTRING(score);
3308 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3309 // distribution display
3310 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3312 distrtimer = ftos(distribution/pow(10, TIME_DECIMALS));
3314 if (distribution <= 0) {
3315 distribution_color = '0 1 0';
3318 distribution_color = '1 0 0';
3320 drawstring_aspect(pos + eX * 0.75 * mySize_x, distrtimer, eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3322 // race record display
3323 if (distribution <= 0)
3324 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3325 drawfont = hud_bigfont;
3326 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3327 drawfont = hud_font;
3328 } else if (!teamplay) { // non-teamgames
3329 // me vector := [team/connected frags id]
3330 pl = players.sort_next;
3334 if(autocvar__hud_configure)
3337 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3341 score = me.(scores[ps_primary]);
3342 if(autocvar__hud_configure)
3345 if(distribution >= 5) {
3346 distribution_color = eY;
3348 } else if(distribution >= 0) {
3349 distribution_color = '1 1 1';
3351 } else if(distribution >= -5)
3352 distribution_color = '1 1 0';
3354 distribution_color = eX;
3356 drawstring_aspect(pos + eX * 0.75 * mySize_x, ftos(distribution), eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3358 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3359 drawfont = hud_bigfont;
3360 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3361 drawfont = hud_font;
3362 } else { // teamgames
3363 float max_fragcount;
3364 max_fragcount = -99;
3367 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3368 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !autocvar__hud_configure)) // no players? don't display
3370 score = tm.(teamscores[ts_primary]);
3371 if(autocvar__hud_configure)
3375 if (score > max_fragcount)
3376 max_fragcount = score;
3378 if(tm.team == myteam) {
3379 if (max_fragcount == score)
3382 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3383 drawfont = hud_bigfont;
3384 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3385 drawfont = hud_font;
3387 if (max_fragcount == score)
3390 HUD_Panel_DrawHighlight(pos + eX * 0.75 * mySize_x + eY * (1/3) * teamnum * mySize_y, eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3391 drawstring_aspect(pos + eX * 0.75 * mySize_x + eY * (1/3) * teamnum * mySize_y, ftos(score), eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3400 void HUD_RaceTimer (void) {
3401 if(!autocvar_hud_panel_racetimer && !(gametype == GAME_RACE || gametype == GAME_CTS) && !autocvar__hud_configure)
3404 active_panel = HUD_PANEL_RACETIMER;
3405 HUD_Panel_UpdateCvars(racetimer);
3408 mySize = panel_size;
3410 HUD_Panel_DrawBg(1);
3411 if(panel_bg_padding)
3413 pos += '1 1 0' * panel_bg_padding;
3414 mySize -= '2 2 0' * panel_bg_padding;
3417 // always force 4:1 aspect
3419 if(mySize_x/mySize_y > 4)
3421 newSize_x = 4 * mySize_y;
3422 newSize_y = mySize_y;
3424 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3428 newSize_y = 1/4 * mySize_x;
3429 newSize_x = mySize_x;
3431 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3435 drawfont = hud_bigfont;
3437 string s, forcetime;
3439 if(autocvar__hud_configure)
3442 drawstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, FALSE, '0.60 0.60 0' * mySize_y), s, '0.60 0.60 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3443 s = "^1Intermediate 1 (+15.42)";
3444 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.20 * mySize_y) + eY * 0.60 * mySize_y, s, '1 1 0' * 0.20 * mySize_y, panel_fg_alpha, DRAWFLAG_NORMAL);
3445 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3446 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.20 * mySize_y) + eY * 0.80 * mySize_y, s, '1 1 0' * 0.20 * mySize_y, panel_fg_alpha, DRAWFLAG_NORMAL);
3448 else if(race_checkpointtime)
3450 a = bound(0, 2 - (time - race_checkpointtime), 1);
3453 if(a > 0) // just hit a checkpoint?
3455 if(race_checkpoint != 254)
3457 if(race_time && race_previousbesttime)
3458 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3460 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3462 forcetime = TIME_ENCODED_TOSTRING(race_time);
3467 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3469 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3470 if(a > 0) // next one?
3472 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3477 if(s != "" && a > 0)
3479 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3482 if(race_penaltytime)
3484 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3487 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3488 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.8 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3494 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3495 drawstring_expanding(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(forcetime, FALSE, '1 1 0' * 0.6 * mySize_y), forcetime, '1 1 0' * 0.6 * mySize_y, '1 1 1', panel_fg_alpha, 0, a);
3500 if(race_laptime && race_checkpoint != 255)
3502 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3503 drawstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, FALSE, '0.6 0.6 0' * mySize_y), s, '0.6 0.6 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3508 if(race_mycheckpointtime)
3510 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3511 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3512 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3514 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3516 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3517 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3518 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3521 if(race_penaltytime && !race_penaltyaccumulator)
3523 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3524 a = bound(0, (1 + t - time), 1);
3528 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3530 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3531 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3536 drawfont = hud_font;
3541 float vote_yescount;
3544 float vote_highlighted; // currently selected vote
3546 float vote_active; // is there an active vote?
3547 float vote_prev; // previous state of vote_active to check for a change
3549 float vote_change; // "time" when vote_active changed
3551 void HUD_VoteWindow(void)
3553 if(!autocvar_hud_panel_vote && !autocvar__hud_configure)
3556 active_panel = HUD_PANEL_VOTE;
3557 HUD_Panel_UpdateCvars(vote);
3560 mySize = panel_size;
3564 if(vote_active != vote_prev) {
3566 vote_prev = vote_active;
3569 if(vote_active || autocvar__hud_configure)
3570 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3572 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3574 if(autocvar__hud_configure)
3584 a = vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3586 HUD_Panel_DrawBg(a);
3587 if(panel_bg_padding)
3589 pos += '1 1 0' * panel_bg_padding;
3590 mySize -= '2 2 0' * panel_bg_padding;
3593 // always force 3:1 aspect
3595 if(mySize_x/mySize_y > 3)
3597 newSize_x = 3 * mySize_y;
3598 newSize_y = mySize_y;
3600 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3604 newSize_y = 1/3 * mySize_x;
3605 newSize_x = mySize_x;
3607 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3611 s = "A vote has been called for:";
3612 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3613 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1.75/8), stringwidth_colors);
3614 if(autocvar__hud_configure)
3615 s = "^1Configure the HUD";
3616 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3618 // print the yes/no counts
3619 s = strcat("Yes (", getcommandkey("not bound", "vyes"), "): ", ftos(vote_yescount));
3620 drawstring_aspect(pos + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '0 1 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3621 s = strcat("No (", getcommandkey("not bound", "vno"), "): ", ftos(vote_nocount));
3622 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 * panel_fg_alpha, DRAWFLAG_NORMAL);
3624 // draw the progress bar backgrounds
3625 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3627 // draw the highlights
3628 if(vote_highlighted == 1) {
3629 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3630 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '0 1 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3632 else if(vote_highlighted == 2) {
3633 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3634 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '0 1 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3637 // draw the progress bars
3638 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3639 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '0 1 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3641 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3642 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 0 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3644 drawresetcliparea();
3647 vote_highlighted = 0;
3651 // Mod icons panel (#10)
3654 float mod_active; // is there any active mod icon?
3656 // CTF HUD modicon section
3657 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3658 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3659 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3661 void HUD_Mod_CTF_Reset(void)
3663 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3666 void HUD_Mod_CTF(vector pos, vector mySize)
3668 vector redflag_pos, blueflag_pos;
3670 float f; // every function should have that
3672 float redflag, blueflag; // current status
3673 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3676 stat_items = getstati(STAT_ITEMS);
3677 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3678 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3680 if(redflag || blueflag)
3685 if(autocvar__hud_configure)
3691 // when status CHANGES, set old status into prevstatus and current status into status
3692 if (redflag != redflag_prevframe)
3694 redflag_statuschange_time = time;
3695 redflag_prevstatus = redflag_prevframe;
3696 redflag_prevframe = redflag;
3699 if (blueflag != blueflag_prevframe)
3701 blueflag_statuschange_time = time;
3702 blueflag_prevstatus = blueflag_prevframe;
3703 blueflag_prevframe = blueflag;
3706 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3707 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3709 float BLINK_FACTOR = 0.15;
3710 float BLINK_BASE = 0.85;
3712 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3714 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3716 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3718 string red_icon, red_icon_prevstatus;
3719 float red_alpha, red_alpha_prevstatus;
3720 red_alpha = red_alpha_prevstatus = 1;
3722 case 1: red_icon = "flag_red_taken"; break;
3723 case 2: red_icon = "flag_red_lost"; break;
3724 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3726 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3727 red_icon = "flag_red_shielded";
3729 red_icon = string_null;
3732 switch(redflag_prevstatus) {
3733 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3734 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3735 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3738 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3739 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3740 red_icon_prevstatus = "flag_red_shielded";
3742 red_icon_prevstatus = string_null;
3746 string blue_icon, blue_icon_prevstatus;
3747 float blue_alpha, blue_alpha_prevstatus;
3748 blue_alpha = blue_alpha_prevstatus = 1;
3750 case 1: blue_icon = "flag_blue_taken"; break;
3751 case 2: blue_icon = "flag_blue_lost"; break;
3752 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3754 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3755 blue_icon = "flag_blue_shielded";
3757 blue_icon = string_null;
3760 switch(blueflag_prevstatus) {
3761 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3762 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3763 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3766 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3767 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3768 blue_icon_prevstatus = "flag_blue_shielded";
3770 blue_icon_prevstatus = string_null;
3774 if(mySize_x > mySize_y) {
3775 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3777 blueflag_pos = pos + eX * 0.5 * mySize_x;
3780 redflag_pos = pos + eX * 0.5 * mySize_x;
3782 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3784 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3786 blueflag_pos = pos + eY * 0.5 * mySize_y;
3789 redflag_pos = pos + eY * 0.5 * mySize_y;
3791 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3794 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3795 if(red_icon_prevstatus && f < 1)
3796 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3798 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3800 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3801 if(blue_icon_prevstatus && f < 1)
3802 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3804 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3807 // Keyhunt HUD modicon section
3808 float kh_runheretime;
3810 void HUD_Mod_KH_Reset(void)
3815 void HUD_Mod_KH(vector pos, vector mySize)
3817 mod_active = 1; // keyhunt should never hide the mod icons panel
3821 vector p, pa, kh_size, kh_asize;
3823 kh_keys = getstati(STAT_KH_KEYS);
3826 if(mySize_x > mySize_y)
3828 p_y = pos_y + 0.25 * mySize_y;
3829 pa = p - eY * 0.25 * mySize_y;
3831 kh_size_x = mySize_x * 0.25;
3832 kh_size_y = 0.75 * mySize_y;
3833 kh_asize_x = mySize_x * 0.25;
3834 kh_asize_y = mySize_y * 0.25;
3838 p_y = pos_y + 0.125 * mySize_y;
3839 pa = p - eY * 0.125 * mySize_y;
3841 kh_size_x = mySize_x * 0.5;
3842 kh_size_y = 0.375 * mySize_y;
3843 kh_asize_x = mySize_x * 0.5;
3844 kh_asize_y = mySize_y * 0.125;
3851 for(i = 0; i < 4; ++i)
3853 key = floor(kh_keys / pow(32, i)) & 31;
3855 if(keyteam == 30 && keycount <= 4)
3857 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3861 // this yields 8 exactly if "RUN HERE" shows
3866 kh_runheretime = time;
3867 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3872 for(i = 0; i < 4; ++i)
3874 key = floor(kh_keys / pow(32, i)) & 31;
3887 default: // owned or dropped
3892 a = a * panel_fg_alpha;
3893 aa = aa * panel_fg_alpha;
3899 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3902 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3905 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3908 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3913 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3916 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3919 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3922 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3925 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3929 if(mySize_x > mySize_y)
3931 p_x += 0.25 * mySize_x;
3932 pa_x += 0.25 * mySize_x;
3938 p_y = pos_y + 0.625 * mySize_y;
3939 pa_y = pos_y + 0.5 * mySize_y;
3945 p_x += 0.5 * mySize_x;
3946 pa_x += 0.5 * mySize_x;
3952 // Nexball HUD mod icon
3953 void HUD_Mod_NexBall(vector pos, vector mySize)
3955 float stat_items, nb_pb_starttime, dt, p;
3957 stat_items = getstati(STAT_ITEMS);
3958 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3960 if (stat_items & IT_KEY1)
3965 //Manage the progress bar if any
3966 if (nb_pb_starttime > 0)
3968 dt = mod(time - nb_pb_starttime, nb_pb_period);
3969 // one period of positive triangle
3970 p = 2 * dt / nb_pb_period;
3977 if(mySize_x > mySize_y)
3979 barsize = eX * p * mySize_x + eY * mySize_y;
3984 barsize = eX * mySize_x + eY * p * mySize_y;
3987 HUD_Panel_GetProgressBarColor("nexball")
3988 HUD_Panel_DrawProgressBar(pos, vertical, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3991 if (stat_items & IT_KEY1)
3992 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3995 // Race/CTS HUD mod icons
3996 float crecordtime_prev; // last remembered crecordtime
3997 float crecordtime_change_time; // time when crecordtime last changed
3998 float srecordtime_prev; // last remembered srecordtime
3999 float srecordtime_change_time; // time when srecordtime last changed
4001 float race_status_time;
4002 float race_status_prev;
4003 string race_status_name_prev;
4004 void HUD_Mod_Race(vector pos, vector mySize)
4006 mod_active = 1; // race should never hide the mod icons panel
4008 me = playerslots[player_localentnum - 1];
4010 float f; // yet another function has this
4011 score = me.(scores[ps_primary]);
4013 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
4014 return; // no records in the actual race
4016 drawfont = hud_bigfont;
4018 // clientside personal record
4020 if(gametype == GAME_CTS)
4024 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4026 if(score && (score < t || !t)) {
4027 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4028 if(cvar("cl_autodemo_delete_keeprecords"))
4030 f = cvar("cl_autodemo_delete");
4032 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4036 if(t != crecordtime_prev) {
4037 crecordtime_prev = t;
4038 crecordtime_change_time = time;
4040 f = time - crecordtime_change_time;
4043 drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4044 drawstring_aspect(pos + eY * 0.25 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4046 drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4047 drawstring_aspect(pos + eY * 0.25 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4048 drawstring_aspect_expanding(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4049 drawstring_aspect_expanding(pos + eY * 0.25 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4053 t = race_server_record;
4054 if(t != srecordtime_prev) {
4055 srecordtime_prev = t;
4056 srecordtime_change_time = time;
4058 f = time - srecordtime_change_time;
4061 drawstring_aspect(pos + eY * 0.5 * mySize_y, "Server best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4062 drawstring_aspect(pos + eY * 0.75 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4064 drawstring_aspect(pos + eY * 0.5 * mySize_y, "Server best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4065 drawstring_aspect(pos + eY * 0.75 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4066 drawstring_aspect_expanding(pos + eY * 0.5 * mySize_y, "Server best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4067 drawstring_aspect_expanding(pos + eY * 0.75 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4070 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4071 race_status_time = time + 5;
4072 race_status_prev = race_status;
4073 if (race_status_name_prev)
4074 strunzone(race_status_name_prev);
4075 race_status_name_prev = strzone(race_status_name);
4078 pos_x += mySize_x/2;
4081 a = bound(0, race_status_time - time, 1);
4084 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4088 rank = race_CheckName(race_status_name);
4090 rankname = race_PlaceName(rank);
4093 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4095 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4097 if(race_status == 0)
4098 drawpic_aspect_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4099 else if(race_status == 1) {
4100 drawpic_aspect_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4101 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4102 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4103 } else if(race_status == 2) {
4104 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4105 drawpic_aspect_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4107 drawpic_aspect_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4108 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4109 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4110 } else if(race_status == 3) {
4111 drawpic_aspect_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4112 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4113 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4116 if (race_status_time - time <= 0) {
4117 race_status_prev = -1;
4119 if(race_status_name)
4120 strunzone(race_status_name);
4121 race_status_name = string_null;
4122 if(race_status_name_prev)
4123 strunzone(race_status_name_prev);
4124 race_status_name_prev = string_null;
4126 drawfont = hud_font;
4129 float mod_prev; // previous state of mod_active to check for a change
4131 float mod_change; // "time" when mod_active changed
4133 void HUD_ModIcons(void)
4135 if(!autocvar_hud_panel_modicons && !autocvar__hud_configure)
4138 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !autocvar__hud_configure)
4141 active_panel = HUD_PANEL_MODICONS;
4142 HUD_Panel_UpdateCvars(modicons);
4145 mySize = panel_size;
4147 if(mod_active != mod_prev) {
4149 mod_prev = mod_active;
4152 if(mod_active || autocvar__hud_configure)
4153 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4155 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4158 HUD_Panel_DrawBg(mod_alpha);
4160 if(panel_bg_padding)
4162 pos += '1 1 0' * panel_bg_padding;
4163 mySize -= '2 2 0' * panel_bg_padding;
4166 // these MUST be ran in order to update mod_active
4167 if(gametype == GAME_KEYHUNT)
4168 HUD_Mod_KH(pos, mySize);
4169 else if(gametype == GAME_CTF || autocvar__hud_configure)
4170 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4171 else if(gametype == GAME_NEXBALL)
4172 HUD_Mod_NexBall(pos, mySize);
4173 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4174 HUD_Mod_Race(pos, mySize);
4177 // Draw pressed keys (#11)
4179 void HUD_DrawPressedKeys(void)
4181 if(!autocvar_hud_panel_pressedkeys && !autocvar__hud_configure)
4184 if(!(spectatee_status > 0 || autocvar_hud_panel_pressedkeys >= 2 || autocvar__hud_configure))
4187 active_panel = HUD_PANEL_PRESSEDKEYS;
4188 HUD_Panel_UpdateCvars(pressedkeys);
4191 mySize = panel_size;
4193 HUD_Panel_DrawBg(1);
4194 if(panel_bg_padding)
4196 pos += '1 1 0' * panel_bg_padding;
4197 mySize -= '2 2 0' * panel_bg_padding;
4200 // force custom aspect
4201 if(autocvar_hud_panel_pressedkeys_aspect)
4204 if(mySize_x/mySize_y > autocvar_hud_panel_pressedkeys_aspect)
4206 newSize_x = autocvar_hud_panel_pressedkeys_aspect * mySize_y;
4207 newSize_y = mySize_y;
4209 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4213 newSize_y = 1/autocvar_hud_panel_pressedkeys_aspect * mySize_x;
4214 newSize_x = mySize_x;
4216 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4222 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4225 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4226 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4227 drawpic_aspect_skin(pos + eX * mySize_x * (1/3), ((pressedkeys & KEY_FORWARD) ? "key_forward_inv.tga" : "key_forward.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4228 drawpic_aspect_skin(pos + eX * mySize_x * (2/3), ((pressedkeys & KEY_JUMP) ? "key_jump_inv.tga" : "key_jump.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4229 drawpic_aspect_skin(pos + eY * 0.5 * mySize_y, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4230 drawpic_aspect_skin(pos + eY * 0.5 * mySize_y + eX * mySize_x * (1/3), ((pressedkeys & KEY_BACKWARD) ? "key_backward_inv.tga" : "key_backward.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4231 drawpic_aspect_skin(pos + eY * 0.5 * mySize_y + eX * mySize_x * (2/3), ((pressedkeys & KEY_RIGHT) ? "key_right_inv.tga" : "key_right.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4234 // Handle chat as a panel (#12)
4238 if(!autocvar_hud_panel_chat && !autocvar__hud_configure)
4240 cvar_set("con_chatrect", "0");
4244 active_panel = HUD_PANEL_CHAT;
4245 HUD_Panel_UpdateCvars(chat);
4247 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
4249 panel_pos_y = panel_bg_border;
4250 panel_size_y = vid_conheight - panel_bg_border * 2;
4252 panel_bg = "border"; // force a border when maximized
4253 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an alpha of at least 0.75
4258 mySize = panel_size;
4260 HUD_Panel_DrawBg(1);
4262 if(panel_bg_padding)
4264 pos += '1 1 0' * panel_bg_padding;
4265 mySize -= '2 2 0' * panel_bg_padding;
4268 cvar_set("con_chatrect", "1");
4270 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4271 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4273 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4274 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4276 if(autocvar__hud_configure)
4279 chatsize = cvar("con_chatsize");
4280 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4282 for(i = 0; i < cvar("con_chat"); ++i)
4284 if(i == cvar("con_chat") - 1)
4287 a = panel_fg_alpha * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4288 drawcolorcodedstring(pos + eY * i * chatsize, textShortenToWidth("^3Player^7: This is the chat area.", mySize_x, '1 1 0' * chatsize, stringwidth_colors), '1 1 0' * chatsize, a, DRAWFLAG_NORMAL);
4293 // Engine info panel (#13)
4300 float frametimeavg1; // 1 frame ago
4301 float frametimeavg2; // 2 frames ago
4302 void HUD_EngineInfo(void)
4304 if(!autocvar_hud_panel_engineinfo && !autocvar__hud_configure)
4307 active_panel = HUD_PANEL_ENGINEINFO;
4308 HUD_Panel_UpdateCvars(engineinfo);
4311 mySize = panel_size;
4313 HUD_Panel_DrawBg(1);
4314 if(panel_bg_padding)
4316 pos += '1 1 0' * panel_bg_padding;
4317 mySize -= '2 2 0' * panel_bg_padding;
4320 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
4322 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4323 frametimeavg2 = frametimeavg1;
4324 frametimeavg1 = frametimeavg;
4327 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4328 if(frametime > 0.0001) // filter out insane values which sometimes seem to occur and throw off the average? If you are getting 10,000 fps or more, then you don't need a framerate counter.
4330 if(fabs(prevfps - (1/frametimeavg)) > prevfps * cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_instantupdate_change_threshold")) // if there was a big jump in fps, just force prevfps at current (1/frametime) to make big updates instant
4331 prevfps = (1/frametime);
4332 prevfps = (1 - weight) * prevfps + weight * (1/frametimeavg); // framecounter just used so there's no need for a new variable, think of it as "frametime average"
4338 if(time - prevfps_time > cvar("hud_panel_engineinfo_framecounter_time"))
4340 prevfps = framecounter/cvar("hud_panel_engineinfo_framecounter_time");
4342 prevfps_time = time;
4347 color = HUD_Get_Num_Color (prevfps, 100);
4348 drawfont = hud_bigfont;
4349 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_panel_engineinfo_framecounter_decimals"))), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4350 drawfont = hud_font;
4353 // Info messages panel (#14)
4355 void HUD_InfoMessages(void)
4357 if(!autocvar_hud_panel_infomessages && !autocvar__hud_configure)
4360 active_panel = HUD_PANEL_INFOMESSAGES;
4361 HUD_Panel_UpdateCvars(infomessages);
4364 mySize = panel_size;
4366 HUD_Panel_DrawBg(1);
4367 if(panel_bg_padding)
4369 pos += '1 1 0' * panel_bg_padding;
4370 mySize -= '2 2 0' * panel_bg_padding;
4373 // always force 5:1 aspect
4375 if(mySize_x/mySize_y > 5)
4377 newSize_x = 5 * mySize_y;
4378 newSize_y = mySize_y;
4380 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4384 newSize_y = 1/5 * mySize_x;
4385 newSize_x = mySize_x;
4387 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4396 fontsize = '0.20 0.20 0' * mySize_y;
4399 if(!autocvar__hud_configure)
4401 if(spectatee_status && !intermission)
4403 if(spectatee_status == -1)
4406 s = strcat("^1Spectating: ^7", GetPlayerName(spectatee_status - 1));
4408 if(autocvar_hud_panel_infomessages_flip)
4409 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4410 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4411 o += eY * fontsize_y;
4413 if(spectatee_status == -1)
4414 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
4416 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
4417 if(autocvar_hud_panel_infomessages_flip)
4418 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4419 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4420 o += eY * fontsize_y;
4422 if(spectatee_status == -1)
4423 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
4425 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
4426 if(autocvar_hud_panel_infomessages_flip)
4427 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4428 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4429 o += eY * fontsize_y;
4431 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
4432 if(autocvar_hud_panel_infomessages_flip)
4433 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4434 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4435 o += eY * fontsize_y;
4437 if(gametype == GAME_ARENA)
4438 s = "^1Wait for your turn to join";
4439 else if(gametype == GAME_LMS)
4442 sk = playerslots[player_localentnum - 1];
4443 if(sk.(scores[ps_primary]) >= 666)
4444 s = "^1Match has already begun";
4445 else if(sk.(scores[ps_primary]) > 0)
4446 s = "^1You have no more lives left";
4448 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4451 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4452 if(autocvar_hud_panel_infomessages_flip)
4453 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4454 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4455 o += eY * fontsize_y;
4457 //show restart countdown:
4458 if (time < getstatf(STAT_GAMESTARTTIME)) {
4460 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4461 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4462 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
4463 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4464 o += eY * fontsize_y;
4467 if(warmup_stage && !intermission)
4469 s = "^2Currently in ^1warmup^2 stage!";
4470 if(autocvar_hud_panel_infomessages_flip)
4471 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4472 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4473 o += eY * fontsize_y;
4477 if(mod(time, 1) >= 0.5)
4482 if(ready_waiting && !intermission && !spectatee_status)
4484 if(ready_waiting_for_me)
4487 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
4489 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
4494 s = strcat("^2Waiting for others to ready up to end warmup...");
4496 s = strcat("^2Waiting for others to ready up...");
4498 if(autocvar_hud_panel_infomessages_flip)
4499 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4500 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4501 o += eY * fontsize_y;
4503 else if(warmup_stage && !intermission && !spectatee_status)
4505 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
4506 if(autocvar_hud_panel_infomessages_flip)
4507 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4508 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4509 o += eY * fontsize_y;
4512 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4514 float ts_min, ts_max;
4515 tm = teams.sort_next;
4518 for(; tm.sort_next; tm = tm.sort_next)
4520 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4522 if(!ts_min) ts_min = tm.team_size;
4523 else ts_min = min(ts_min, tm.team_size);
4524 if(!ts_max) ts_max = tm.team_size;
4525 else ts_max = max(ts_max, tm.team_size);
4527 if ((ts_max - ts_min) > 1)
4529 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
4530 tm = GetTeam(myteam, false);
4532 if (tm.team != COLOR_SPECTATOR)
4533 if (tm.team_size == ts_max)
4534 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
4536 if(autocvar_hud_panel_infomessages_flip)
4537 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4538 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4539 o += eY * fontsize_y;
4546 s = "^7Press ^3ESC ^7to show HUD options.";
4547 if(autocvar_hud_panel_infomessages_flip)
4548 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4549 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4550 o += eY * fontsize_y;
4551 s = "^3Doubleclick ^7a panel for panel-specific options.";
4552 if(autocvar_hud_panel_infomessages_flip)
4553 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4554 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4555 o += eY * fontsize_y;
4556 s = "^3CTRL ^7to disable collision testing, ^3SHIFT ^7and";
4557 if(autocvar_hud_panel_infomessages_flip)
4558 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4559 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4560 o += eY * fontsize_y;
4561 s = "^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.";
4562 if(autocvar_hud_panel_infomessages_flip)
4563 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4564 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4565 o += eY * fontsize_y;
4575 void HUD_ShowSpeed(void)
4578 float pos, conversion_factor;
4579 string speed, zspeed, unit;
4581 switch(cvar("cl_showspeed_unit"))
4586 conversion_factor = 1.0;
4590 conversion_factor = 1.0;
4594 conversion_factor = 0.0254;
4598 conversion_factor = 0.0254 * 3.6;
4602 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4606 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4610 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4612 numsize_x = numsize_y = cvar("cl_showspeed_size");
4613 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4615 drawfont = hud_bigfont;
4616 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
4618 if (cvar("cl_showspeed_z") == 1) {
4619 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4620 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
4623 drawfont = hud_font;
4626 vector acc_prevspeed;
4630 void HUD_ShowAcceleration(void)
4632 float acceleration, sz, scale, alpha, f;
4633 vector pos, top, rgb;
4634 top_x = vid_conwidth/2;
4637 f = time - acc_prevtime;
4638 if(cvar("cl_showacceleration_z"))
4639 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4641 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4642 acc_prevspeed = pmove_vel;
4643 acc_prevtime = time;
4645 f = bound(0, f * 10, 1);
4646 acc_avg = acc_avg * (1 - f) + acceleration * f;
4647 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4649 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4651 sz = cvar("cl_showacceleration_size");
4652 scale = cvar("cl_showacceleration_scale");
4653 alpha = cvar("cl_showacceleration_alpha");
4654 if (cvar("cl_showacceleration_color_custom"))
4655 rgb = stov(cvar_string("cl_showacceleration_color"));
4658 if (acceleration < 0) {
4659 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4660 } else if (acceleration > 0) {
4661 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4665 if (acceleration > 0)
4666 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
4667 else if (acceleration < 0)
4668 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
4671 void HUD_Reset (void)
4673 // reset gametype specific icons
4674 if(gametype == GAME_KEYHUNT)
4676 else if(gametype == GAME_CTF)
4677 HUD_Mod_CTF_Reset();
4680 #define HUD_DrawPanel(id)\
4682 case (HUD_PANEL_RADAR):\
4683 HUD_Radar(); break;\
4684 case (HUD_PANEL_WEAPONS):\
4685 HUD_Weapons(); break;\
4686 case (HUD_PANEL_AMMO):\
4688 case (HUD_PANEL_POWERUPS):\
4689 HUD_Powerups(); break;\
4690 case (HUD_PANEL_HEALTHARMOR):\
4691 HUD_HealthArmor(); break;\
4692 case (HUD_PANEL_NOTIFY):\
4693 HUD_Notify(); break;\
4694 case (HUD_PANEL_TIMER):\
4695 HUD_Timer(); break;\
4696 case (HUD_PANEL_SCORE):\
4697 HUD_Score(); break;\
4698 case (HUD_PANEL_RACETIMER):\
4699 HUD_RaceTimer(); break;\
4700 case (HUD_PANEL_VOTE):\
4701 HUD_VoteWindow(); break;\
4702 case (HUD_PANEL_MODICONS):\
4703 HUD_ModIcons(); break;\
4704 case (HUD_PANEL_PRESSEDKEYS):\
4705 HUD_DrawPressedKeys(); break;\
4706 case (HUD_PANEL_CHAT):\
4708 case (HUD_PANEL_ENGINEINFO):\
4709 HUD_EngineInfo(); break;\
4710 case (HUD_PANEL_INFOMESSAGES):\
4711 HUD_InfoMessages(); break;\
4714 void HUD_Main (void)
4716 hud_skin_path = strcat("gfx/hud/", autocvar_hud_skin);
4718 // global hud alpha fade
4719 if(disable_menu_alphacheck == 1)
4722 hud_fade_alpha = (1 - autocvar__menu_alpha);
4724 if(scoreboard_fade_alpha)
4725 hud_fade_alpha = (1 - scoreboard_fade_alpha);
4727 if(intermission == 2) // no hud during mapvote
4729 else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
4732 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4733 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4735 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4736 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4740 // HUD configure visible grid
4741 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4745 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2); ++i)
4747 drawfill(eX * i * vid_conwidth * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2), eX + eY * vid_conheight, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4750 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2); ++i)
4752 drawfill(eY * i * vid_conheight * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2), eY + eX * vid_conwidth, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4758 if((teamplay) && autocvar_hud_dock_color_team) {
4759 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4760 color = colormapPaletteColor(mod(f, 16), 1) * autocvar_hud_dock_color_team;
4762 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && autocvar_hud_dock_color_team) {
4763 color = '1 0 0' * autocvar_hud_dock_color_team;
4765 else if(autocvar_hud_dock_color == "shirt") {
4766 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4767 color = colormapPaletteColor(floor(f / 16), 0);
4769 else if(autocvar_hud_dock_color == "pants") {
4770 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4771 color = colormapPaletteColor(mod(f, 16), 1);
4774 color = stov(autocvar_hud_dock_color);
4777 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4780 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4781 if(precache_pic(pic) == "") {
4782 pic = "gfx/hud/default/dock";
4784 drawpic('0 0 0', pic, eX * vid_conwidth + eY * vid_conheight, color, autocvar_hud_dock_alpha * hud_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
4787 // cache the panel order into the panel_order array
4788 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4789 if(hud_panelorder_prev)
4790 strunzone(hud_panelorder_prev);
4791 hud_panelorder_prev = strzone(autocvar__hud_panelorder);
4792 tokenize_console(autocvar__hud_panelorder);
4793 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4794 panel_order[i] = stof(argv(i));
4797 // draw panels in order specified by panel_order array
4798 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
4799 if(i != HUD_PANEL_CHAT || !autocvar__con_chat_maximized) // don't draw maximized chat panel twice!
4800 HUD_DrawPanel(panel_order[i]);
4803 // draw chat panel on top if it is maximized
4804 if(autocvar__con_chat_maximized)
4805 HUD_DrawPanel(HUD_PANEL_CHAT);
4807 // TODO hud_'ify these
4808 if (cvar("cl_showspeed"))
4810 if (cvar("cl_showacceleration"))
4811 HUD_ShowAcceleration();
4813 if (autocvar__hud_configure && spectatee_status && hud_configure_prev == -1) // try to join if we are in hud_configure mode, but still spectating, and in the first frame (in order to get rid of motd when launching a server via the menu "HUD Setup" button)
4814 localcmd("cmd selectteam auto; cmd join\n");
4816 hud_configure_prev = autocvar__hud_configure;
4818 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again
4819 disable_menu_alphacheck = 0;