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 vector centerprint_start;
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])
186 strunzone(centerprint_messages[i]);
187 centerprint_messages[i] = strzone(s);
188 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
191 // half height for empty lines looks better
197 if(i >= CENTERPRINT_MAX_LINES)
203 h = centerprint_fontsize_y*hcount;
205 havail = vid_conheight;
206 if(cvar("con_chatpos") < 0)
207 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
208 if(havail > vid_conheight - 70)
209 havail = vid_conheight - 70; // avoid overlapping HUD
211 centerprint_start_x = 0;
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);
263 centerprint_start_y =
266 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
274 centerprint_expire = time + cvar("scr_centertime");
277 void HUD_DrawCenterPrint (void)
284 //if(time > centerprint_expire)
287 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
288 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
289 //sz = 1.2 / (a + 0.2);
294 pos = centerprint_start;
295 for (i=0; i<centerprint_num; i = i + 1)
297 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
298 ts = centerprint_messages[i];
301 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
302 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
303 pos_y = pos_y + centerprint_fontsize_y;
306 // half height for empty lines looks better
307 pos_y = pos_y + centerprint_fontsize_y * 0.5;
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 // common cvars for all panels
458 for (i = 0; i < HUD_PANEL_NUM; ++i)
462 fputs(fh, strcat("seta hud_panel_", panel_name, " ", cvar_string(strcat("hud_panel_", panel_name)), "\n"));
463 fputs(fh, strcat("seta hud_panel_", panel_name, "_pos \"", cvar_string(strcat("hud_panel_", panel_name, "_pos")), "\"", "\n"));
464 fputs(fh, strcat("seta hud_panel_", panel_name, "_size \"", cvar_string(strcat("hud_panel_", panel_name, "_size")), "\"", "\n"));
465 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg \"", cvar_string(strcat("hud_panel_", panel_name, "_bg")), "\"", "\n"));
466 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_color \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_color")), "\"", "\n"));
467 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_color_team \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_color_team")), "\"", "\n"));
468 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_alpha")), "\"", "\n"));
469 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_border \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_border")), "\"", "\n"));
470 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_padding \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_padding")), "\"", "\n"));
472 case HUD_PANEL_WEAPONS:
473 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble")), "\"", "\n"));
474 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_padding \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_padding")), "\"", "\n"));
475 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_outofammo \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_outofammo")), "\"", "\n"));
476 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_donthave \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_donthave")), "\"", "\n"));
477 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_unavailable \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_unavailable")), "\"", "\n"));
478 fputs(fh, strcat("seta hud_panel_", panel_name, "_ammo_color \"", cvar_string(strcat("hud_panel_", panel_name, "_ammo_color")), "\"", "\n"));
479 fputs(fh, strcat("seta hud_panel_", panel_name, "_ammo_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_ammo_alpha")), "\"", "\n"));
480 fputs(fh, strcat("seta hud_panel_", panel_name, "_aspect \"", cvar_string(strcat("hud_panel_", panel_name, "_aspect")), "\"", "\n"));
483 fputs(fh, strcat("seta hud_panel_", panel_name, "_onlycurrent \"", cvar_string(strcat("hud_panel_", panel_name, "_onlycurrent")), "\"", "\n"));
484 fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
486 case HUD_PANEL_POWERUPS:
487 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\"", "\n"));
488 fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
489 fputs(fh, strcat("seta hud_panel_", panel_name, "_baralign \"", cvar_string(strcat("hud_panel_", panel_name, "_baralign")), "\"", "\n"));
490 fputs(fh, strcat("seta hud_panel_", panel_name, "_progressbar \"", cvar_string(strcat("hud_panel_", panel_name, "_progressbar")), "\"", "\n"));
492 case HUD_PANEL_HEALTHARMOR:
493 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\n"));
494 fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
495 fputs(fh, strcat("seta hud_panel_", panel_name, "_baralign \"", cvar_string(strcat("hud_panel_", panel_name, "_baralign")), "\"", "\n"));
496 fputs(fh, strcat("seta hud_panel_", panel_name, "_progressbar \"", cvar_string(strcat("hud_panel_", panel_name, "_progressbar")), "\"", "\n"));
498 case HUD_PANEL_NOTIFY:
499 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\"", "\n"));
500 fputs(fh, strcat("seta hud_panel_", panel_name, "_print \"", cvar_string(strcat("hud_panel_", panel_name, "_print")), "\"", "\n"));
502 case HUD_PANEL_RADAR:
503 fputs(fh, strcat("seta hud_panel_", panel_name, "_foreground_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_foreground_alpha")), "\"", "\n"));
506 fputs(fh, strcat("seta hud_panel_", panel_name, "_alreadyvoted_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_alreadyvoted_alpha")), "\"", "\n"));
508 case HUD_PANEL_PRESSEDKEYS:
509 fputs(fh, strcat("seta hud_panel_", panel_name, "_aspect \"", cvar_string(strcat("hud_panel_", panel_name, "_aspect")), "\"", "\n"));
514 fputs(fh, strcat("menu_restart", "\n")); // force a menu update when execing config, so that the dialogs are updated
516 print("^2Successfully exported to hud_", autocvar_hud_skin, "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
521 const float hlBorderSize = 4;
522 const string hlBorder = "gfx/hud/default/border_highlighted";
523 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
524 void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
526 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
527 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);
528 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);
529 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);
530 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);
533 // draw the background/borders
534 #define HUD_Panel_DrawBg(alpha)\
536 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));\
537 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
538 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);
540 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
547 pic = strcat(hud_skin_path, "/statusbar_vertical");
548 if(precache_pic(pic) == "") {
549 pic = "gfx/hud/default/statusbar_vertical";
551 drawsubpic(pos, eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, pic, '0 0 0', '1 0.25 0', color, alpha, drawflag);
552 if(mySize_y/mySize_x > 2)
553 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);
554 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);
556 pic = strcat(hud_skin_path, "/statusbar");
557 if(precache_pic(pic) == "") {
558 pic = "gfx/hud/default/statusbar";
560 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
561 if(mySize_x/mySize_y > 2)
562 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);
563 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);
567 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
573 pic = strcat(hud_skin_path, "/num_leading");
574 if(precache_pic(pic) == "") {
575 pic = "gfx/hud/default/num_leading";
578 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
579 if(mySize_x/mySize_y > 2)
580 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);
581 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);
584 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
585 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
596 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
597 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
599 for (i = 0; i < HUD_PANEL_NUM; ++i) {
600 if(i == highlightedPanel || !panel_enabled)
603 HUD_Panel_UpdatePosSizeForId(i)
605 panel_pos -= '1 1 0' * panel_bg_border;
606 panel_size += '2 2 0' * panel_bg_border;
608 if(myPos_y + mySize_y < panel_pos_y)
610 if(myPos_y > panel_pos_y + panel_size_y)
613 if(myPos_x + mySize_x < panel_pos_x)
615 if(myPos_x > panel_pos_x + panel_size_x)
618 // OK, there IS a collision.
620 myCenter_x = myPos_x + 0.5 * mySize_x;
621 myCenter_y = myPos_y + 0.5 * mySize_y;
623 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
624 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
626 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
628 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
629 myTarget_x = panel_pos_x - mySize_x;
630 else // push it upwards
631 myTarget_y = panel_pos_y - mySize_y;
633 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
635 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
636 myTarget_x = panel_pos_x + panel_size_x;
637 else // push it upwards
638 myTarget_y = panel_pos_y - mySize_y;
640 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
642 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
643 myTarget_x = panel_pos_x - mySize_x;
644 else // push it downwards
645 myTarget_y = panel_pos_y + panel_size_y;
647 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
649 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
650 myTarget_x = panel_pos_x + panel_size_x;
651 else // push it downwards
652 myTarget_y = panel_pos_y + panel_size_y;
654 if(cvar("hud_configure_checkcollisions_debug"))
655 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
661 void HUD_Panel_SetPos(vector pos)
663 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
667 if(cvar("hud_configure_checkcollisions_debug"))
668 drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
670 if(autocvar_hud_configure_grid)
672 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;
673 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;
676 if(hud_configure_checkcollisions)
677 pos = HUD_Panel_CheckMove(pos, mySize);
679 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
680 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
683 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
685 HUD_Panel_GetName(highlightedPanel);
686 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
689 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
690 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
700 ratio = mySize_x/mySize_y;
702 for (i = 0; i < HUD_PANEL_NUM; ++i) {
703 if(i == highlightedPanel || !panel_enabled)
706 HUD_Panel_UpdatePosSizeForId(i)
708 panel_pos -= '1 1 0' * panel_bg_border;
709 panel_size += '2 2 0' * panel_bg_border;
711 targEndPos = panel_pos + panel_size;
713 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
714 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
717 if (resizeCorner == 1)
719 // check if this panel is on our way
720 if (resizeorigin_x <= panel_pos_x)
722 if (resizeorigin_y <= panel_pos_y)
724 if (targEndPos_x <= resizeorigin_x - mySize_x)
726 if (targEndPos_y <= resizeorigin_y - mySize_y)
729 // there is a collision:
730 // detect which side of the panel we are facing is actually limiting the resizing
731 // (which side the resize direction finds for first) and reduce the size up to there
733 // dist is the distance between resizeorigin and the "analogous" point of the panel
734 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
735 dist_x = resizeorigin_x - targEndPos_x;
736 dist_y = resizeorigin_y - targEndPos_y;
737 if (dist_y <= 0 || dist_x / dist_y > ratio)
738 mySize_x = min(mySize_x, dist_x);
740 mySize_y = min(mySize_y, dist_y);
742 else if (resizeCorner == 2)
744 if (resizeorigin_x >= targEndPos_x)
746 if (resizeorigin_y <= panel_pos_y)
748 if (panel_pos_x >= resizeorigin_x + mySize_x)
750 if (targEndPos_y <= resizeorigin_y - mySize_y)
753 dist_x = panel_pos_x - resizeorigin_x;
754 dist_y = resizeorigin_y - targEndPos_y;
755 if (dist_y <= 0 || dist_x / dist_y > ratio)
756 mySize_x = min(mySize_x, dist_x);
758 mySize_y = min(mySize_y, dist_y);
760 else if (resizeCorner == 3)
762 if (resizeorigin_x <= panel_pos_x)
764 if (resizeorigin_y >= targEndPos_y)
766 if (targEndPos_x <= resizeorigin_x - mySize_x)
768 if (panel_pos_y >= resizeorigin_y + mySize_y)
771 dist_x = resizeorigin_x - targEndPos_x;
772 dist_y = panel_pos_y - resizeorigin_y;
773 if (dist_y <= 0 || dist_x / dist_y > ratio)
774 mySize_x = min(mySize_x, dist_x);
776 mySize_y = min(mySize_y, dist_y);
778 else if (resizeCorner == 4)
780 if (resizeorigin_x >= targEndPos_x)
782 if (resizeorigin_y >= targEndPos_y)
784 if (panel_pos_x >= resizeorigin_x + mySize_x)
786 if (panel_pos_y >= resizeorigin_y + mySize_y)
789 dist_x = panel_pos_x - resizeorigin_x;
790 dist_y = panel_pos_y - resizeorigin_y;
791 if (dist_y <= 0 || dist_x / dist_y > ratio)
792 mySize_x = min(mySize_x, dist_x);
794 mySize_y = min(mySize_y, dist_y);
796 if(cvar("hud_configure_checkcollisions_debug"))
797 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
803 void HUD_Panel_SetPosSize(vector mySize)
805 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
807 resizeorigin = panel_click_resizeorigin;
810 // minimum panel size cap
811 mySize_x = max(0.025 * vid_conwidth, mySize_x);
812 mySize_y = max(0.025 * vid_conheight, mySize_y);
814 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.
816 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
817 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
820 // collision testing|
821 // -----------------+
823 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
824 if(resizeCorner == 1) {
825 myPos_x = resizeorigin_x - mySize_x;
826 myPos_y = resizeorigin_y - mySize_y;
827 } else if(resizeCorner == 2) {
828 myPos_x = resizeorigin_x;
829 myPos_y = resizeorigin_y - mySize_y;
830 } else if(resizeCorner == 3) {
831 myPos_x = resizeorigin_x - mySize_x;
832 myPos_y = resizeorigin_y;
833 } else { // resizeCorner == 4
834 myPos_x = resizeorigin_x;
835 myPos_y = resizeorigin_y;
838 // left/top screen edges
840 mySize_x = mySize_x + myPos_x;
842 mySize_y = mySize_y + myPos_y;
844 // bottom/right screen edges
845 if(myPos_x + mySize_x > vid_conwidth)
846 mySize_x = vid_conwidth - myPos_x;
847 if(myPos_y + mySize_y > vid_conheight)
848 mySize_y = vid_conheight - myPos_y;
850 if(cvar("hud_configure_checkcollisions_debug"))
851 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
853 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
854 if(autocvar_hud_configure_grid)
856 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;
857 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;
860 if(hud_configure_checkcollisions)
861 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
863 // 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)
864 mySize_x = max(0.025 * vid_conwidth, mySize_x);
865 mySize_y = max(0.025 * vid_conheight, mySize_y);
867 // do another pos check, as size might have changed by now
868 if(resizeCorner == 1) {
869 myPos_x = resizeorigin_x - mySize_x;
870 myPos_y = resizeorigin_y - mySize_y;
871 } else if(resizeCorner == 2) {
872 myPos_x = resizeorigin_x;
873 myPos_y = resizeorigin_y - mySize_y;
874 } else if(resizeCorner == 3) {
875 myPos_x = resizeorigin_x - mySize_x;
876 myPos_y = resizeorigin_y;
877 } else { // resizeCorner == 4
878 myPos_x = resizeorigin_x;
879 myPos_y = resizeorigin_y;
882 if(cvar("hud_configure_checkcollisions_debug"))
883 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
885 HUD_Panel_GetName(highlightedPanel);
887 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
888 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
890 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
891 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
895 float prevMouseClicked; // previous state
896 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
897 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
900 float menu_enabled_time;
901 float pressed_key_time;
902 void HUD_Panel_Arrow_Action(float nPrimary)
904 if (highlightedPanel_prev == -1 || mouseClicked)
907 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
910 if(autocvar_hud_configure_grid)
912 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
914 if (hudShiftState & S_SHIFT)
915 step = bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
917 step = 2 * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
921 if (hudShiftState & S_SHIFT)
922 step = bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
924 step = 2 * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
929 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
930 step = vid_conheight;
933 if (hudShiftState & S_SHIFT)
934 step = (step / 256); // more precision
936 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
939 highlightedPanel = highlightedPanel_prev;
941 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
943 if (hudShiftState & S_ALT) // resize
945 highlightedAction = 1;
946 if(nPrimary == K_UPARROW)
948 else if(nPrimary == K_RIGHTARROW)
950 else if(nPrimary == K_LEFTARROW)
952 else // if(nPrimary == K_DOWNARROW)
955 // ctrl+arrow reduces the size, instead of increasing it
956 // Note that ctrl disables collisions check too, but it's fine
957 // since we don't collide with anything reducing the size
958 if (hudShiftState & S_CTRL) {
960 resizeCorner = 5 - resizeCorner;
965 panel_click_resizeorigin = panel_pos;
966 if(resizeCorner == 1) {
967 panel_click_resizeorigin += mySize;
969 } else if(resizeCorner == 2) {
970 panel_click_resizeorigin_y += mySize_y;
972 } else if(resizeCorner == 3) {
973 panel_click_resizeorigin_x += mySize_x;
975 } else { // resizeCorner == 4
978 HUD_Panel_SetPosSize(mySize);
982 highlightedAction = 2;
985 if(nPrimary == K_UPARROW)
987 else if(nPrimary == K_DOWNARROW)
989 else if(nPrimary == K_LEFTARROW)
991 else // if(nPrimary == K_RIGHTARROW)
994 HUD_Panel_SetPos(pos);
998 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1000 if(!autocvar__hud_configure)
1003 // allow console bind to work
1006 con_keys = findkeysforcommand("toggleconsole");
1007 keys = tokenize(con_keys);
1009 float hit_con_bind, i;
1010 for (i = 0; i < keys; ++i)
1012 if(nPrimary == stof(argv(i)))
1016 if(bInputType == 0) {
1017 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1018 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1019 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1021 else if(bInputType == 1) {
1022 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1023 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1024 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1027 if(nPrimary == K_MOUSE1)
1029 if(bInputType == 0) { // key pressed
1033 else if(bInputType == 1) {// key released
1038 else if(nPrimary == K_ESCAPE)
1040 if (bInputType == 1)
1042 disable_menu_alphacheck = 1;
1044 menu_enabled_time = time;
1045 localcmd("menu_showhudexit\n");
1047 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1049 if (bInputType == 1)
1051 pressed_key_time = 0;
1054 else if (pressed_key_time == 0)
1055 pressed_key_time = time;
1057 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1059 else if(hit_con_bind)
1062 return true; // Suppress ALL other input
1065 float HUD_Panel_HighlightCheck()
1071 while(j <= HUD_PANEL_NUM)
1076 HUD_Panel_UpdatePosSizeForId(i)
1078 panelPos = panel_pos;
1079 panelSize = panel_size;
1080 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1083 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1087 // resize from topleft border
1088 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)
1092 // resize from topright border
1093 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)
1097 // resize from bottomleft border
1098 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)
1102 // resize from bottomright border
1103 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)
1111 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1112 void HUD_Panel_FirstInDrawQ(float id)
1115 var float place = -1;
1116 // find out where in the array our current id is, save into place
1117 for(i = 0; i < HUD_PANEL_NUM; ++i)
1119 if(panel_order[i] == id)
1125 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1127 place = HUD_PANEL_NUM - 1;
1129 // move all ids up by one step in the array until "place"
1130 for(i = place; i > 0; --i)
1132 panel_order[i] = panel_order[i-1];
1134 // now save the new top id
1135 panel_order[0] = id;
1137 // let's save them into the cvar by some strcat trickery
1139 for(i = 0; i < HUD_PANEL_NUM; ++i)
1141 s = strcat(s, ftos(panel_order[i]), " ");
1143 cvar_set("_hud_panelorder", s);
1144 if(hud_panelorder_prev)
1145 strunzone(hud_panelorder_prev);
1146 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1149 void HUD_Panel_Highlight()
1155 while(j <= HUD_PANEL_NUM)
1160 HUD_Panel_UpdatePosSizeForId(i)
1162 panelPos = panel_pos;
1163 panelSize = panel_size;
1164 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1167 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1169 highlightedPanel = i;
1170 HUD_Panel_FirstInDrawQ(i);
1171 highlightedAction = 1;
1172 panel_click_distance = mousepos - panelPos;
1175 // resize from topleft border
1176 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)
1178 highlightedPanel = i;
1179 HUD_Panel_FirstInDrawQ(i);
1180 highlightedAction = 2;
1182 panel_click_distance = mousepos - panelPos;
1183 panel_click_resizeorigin = panelPos + panelSize;
1186 // resize from topright border
1187 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)
1189 highlightedPanel = i;
1190 HUD_Panel_FirstInDrawQ(i);
1191 highlightedAction = 2;
1193 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1194 panel_click_distance_y = mousepos_y - panelPos_y;
1195 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1198 // resize from bottomleft border
1199 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)
1201 highlightedPanel = i;
1202 HUD_Panel_FirstInDrawQ(i);
1203 highlightedAction = 2;
1205 panel_click_distance_x = mousepos_x - panelPos_x;
1206 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1207 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1210 // resize from bottomright border
1211 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)
1213 highlightedPanel = i;
1214 HUD_Panel_FirstInDrawQ(i);
1215 highlightedAction = 2;
1217 panel_click_distance = panelSize - mousepos + panelPos;
1218 panel_click_resizeorigin = panelPos;
1223 highlightedPanel_prev = -1;
1228 float highlightcheck;
1229 void HUD_Panel_Mouse()
1231 // 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
1232 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1233 disable_menu_alphacheck = 0;
1234 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1238 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1239 print("Highlighted: ", ftos(highlightedPanel), "\n");
1240 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1243 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1244 highlightedPanel = -1;
1245 highlightedAction = 0;
1247 if(highlightedPanel != -1)
1248 highlightedPanel_prev = highlightedPanel;
1250 mousepos = mousepos + getmousepos() * cvar("menu_mouse_speed");
1252 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1253 mousepos_y = bound(0, mousepos_y, vid_conheight);
1257 if(prevMouseClicked == 0)
1258 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1260 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1262 if(highlightedAction == 1)
1263 HUD_Panel_SetPos(mousepos - panel_click_distance);
1264 else if(highlightedAction == 2)
1267 if(resizeCorner == 1) {
1268 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1269 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1270 } else if(resizeCorner == 2) {
1271 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1272 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1273 } else if(resizeCorner == 3) {
1274 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1275 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1276 } else { // resizeCorner == 4
1277 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1278 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1280 HUD_Panel_SetPosSize(mySize);
1283 // doubleclick check
1284 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1286 mouseClicked = 0; // to prevent spam, I guess.
1287 disable_menu_alphacheck = 2;
1289 menu_enabled_time = time;
1290 HUD_Panel_GetName(highlightedPanel)
1291 localcmd("menu_showhudoptions ", panel_name, "\n");
1294 if(prevMouseClicked == 0)
1296 prevMouseClickedTime = time;
1297 prevMouseClickedPos = mousepos;
1302 highlightcheck = HUD_Panel_HighlightCheck();
1304 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1307 cursorsize = '32 32 0';
1309 if(highlightcheck == 0)
1310 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1311 else if(highlightcheck == 1)
1312 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1313 else if(highlightcheck == 2)
1314 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1316 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1318 prevMouseClicked = mouseClicked;
1321 // Weapon icons (#0)
1323 float weaponspace[10];
1324 #define HUD_Weapons_Clear()\
1326 for(idx = 0; idx < 10; ++idx)\
1327 weaponspace[idx] = 0;
1329 entity weaponorder[WEP_MAXCOUNT];
1330 void weaponorder_swap(float i, float j, entity pass)
1334 weaponorder[i] = weaponorder[j];
1338 string weaponorder_cmp_str_save;
1339 string weaponorder_cmp_str;
1340 float weaponorder_cmp(float i, float j, entity pass)
1343 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1344 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1345 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)
1348 float GetAmmoStat(float i)
1352 case 0: return STAT_SHELLS;
1353 case 1: return STAT_NAILS;
1354 case 2: return STAT_ROCKETS;
1355 case 3: return STAT_CELLS;
1356 case 4: return STAT_FUEL;
1361 float GetAmmoTypeForWep(float i)
1365 case WEP_SHOTGUN: return 0;
1366 case WEP_UZI: return 1;
1367 case WEP_CAMPINGRIFLE: return 1;
1368 case WEP_GRENADE_LAUNCHER: return 2;
1369 case WEP_ELECTRO: return 3;
1370 case WEP_CRYLINK: return 3;
1371 case WEP_HLAC: return 3;
1372 case WEP_MINSTANEX: return 3;
1373 case WEP_NEX: return 3;
1374 case WEP_HAGAR: return 2;
1375 case WEP_ROCKET_LAUNCHER: return 2;
1376 case WEP_SEEKER: return 2;
1377 case WEP_FIREBALL: return 4;
1378 case WEP_HOOK: return 3;
1383 void HUD_Weapons(void)
1385 if(!autocvar_hud_panel_weapons && !autocvar__hud_configure)
1388 active_panel = HUD_PANEL_WEAPONS;
1389 HUD_Panel_UpdateCvars(weapons);
1391 float i, weapid, fade, weapon_stats, weapon_number, weapon_cnt;
1394 mySize = panel_size;
1397 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1399 self = get_weaponinfo(i);
1400 if(self.impulse >= 0)
1404 // TODO make this configurable
1405 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1407 if(weaponorder_cmp_str != weaponorder_cmp_str_save)
1409 if(weaponorder_cmp_str_save)
1410 strunzone(weaponorder_cmp_str_save);
1411 weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
1413 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1415 self = get_weaponinfo(i);
1416 if(self.impulse >= 0)
1418 weaponorder[weapon_cnt] = self;
1422 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1425 HUD_Panel_DrawBg(1);
1426 if(panel_bg_padding)
1428 pos += '1 1 0' * panel_bg_padding;
1429 mySize -= '2 2 0' * panel_bg_padding;
1433 weapon_stats = getstati(STAT_DAMAGE_HITS);
1434 weapon_number = weapon_stats & 63;
1435 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1437 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1438 weapon_number = weapon_stats & 63;
1439 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1441 if(cvar_or("hud_panel_weapons_fade", 1))
1443 fade = 3.2 - 2 * (time - weapontime);
1444 fade = bound(0.7, fade, 1);
1449 HUD_Weapons_Clear();
1451 float rows, columns;
1452 rows = mySize_y/mySize_x;
1453 rows = bound(1, floor((sqrt(4 * autocvar_hud_panel_weapons_aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1455 columns = ceil(WEP_COUNT/rows);
1458 float a, type, fullammo;
1460 when = autocvar_hud_panel_weapons_complainbubble_time;
1462 fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
1468 for(i = 0; i < weapon_cnt; ++i)
1470 wpnpos = pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows);
1471 wpnsize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
1473 self = weaponorder[i];
1474 weapid = self.impulse;
1476 // draw background behind currently selected weapon
1477 if(self.weapon == activeweapon)
1478 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1480 // draw the weapon accuracy
1483 float weapon_hit, weapon_damage;
1484 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1487 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1488 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1491 // find the max level lower than weapon_stats
1494 while ( j && weapon_stats < acc_lev[j] )
1497 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
1499 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
1500 color = acc_color(j);
1501 color = color + factor * (acc_color(j+1) - color);
1504 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1507 // draw the weapon icon
1508 if((self.impulse >= 0) && (getstati(STAT_WEAPONS) & self.weapons))
1510 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1512 if(autocvar_hud_panel_weapons_label == 1) // weapon number
1513 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * mySize_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1514 else if(autocvar_hud_panel_weapons_label == 2) // bind
1515 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);
1517 // draw ammo status bar
1518 if(autocvar_hud_panel_weapons_ammo && weapid != WEP_TUBA && weapid != WEP_LASER && weapid != WEP_PORTO)
1521 type = GetAmmoTypeForWep(weapid);
1523 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
1528 case 0: fullammo = autocvar_hud_panel_weapons_ammo_full_shells; break;
1529 case 1: fullammo = autocvar_hud_panel_weapons_ammo_full_nails; break;
1530 case 2: fullammo = autocvar_hud_panel_weapons_ammo_full_rockets; break;
1531 case 3: fullammo = autocvar_hud_panel_weapons_ammo_full_cells; break;
1532 case 4: fullammo = autocvar_hud_panel_weapons_ammo_full_fuel; break;
1533 default: fullammo = 60;
1538 if(wpnsize_x/wpnsize_y > autocvar_hud_panel_weapons_aspect)
1540 barsize_x = autocvar_hud_panel_weapons_aspect * wpnsize_y;
1541 barsize_y = wpnsize_y;
1543 barpos_x = wpnpos_x + (wpnsize_x - barsize_x) / 2;
1544 barpos_y = wpnpos_y;
1548 barsize_y = 1/autocvar_hud_panel_weapons_aspect * wpnsize_x;
1549 barsize_x = wpnsize_x;
1551 barpos_y = wpnpos_y + (wpnsize_y - barsize_y) / 2;
1552 barpos_x = wpnpos_x;
1558 barsize_x * bound(0, a/fullammo, 1),
1560 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, autocvar_hud_panel_weapons_ammo_color, panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha, DRAWFLAG_NORMAL);
1561 drawresetcliparea();
1566 // draw a "ghost weapon icon" if you don't have the weapon
1569 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
1572 // draw the complain message
1573 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
1577 if(complain_weapon_time + when > time)
1580 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1584 if(complain_weapon_time + when > time)
1591 if(complain_weapon_type == 0) {
1593 color = autocvar_hud_panel_weapons_complainbubble_color_outofammo;
1595 else if(complain_weapon_type == 1) {
1597 color = autocvar_hud_panel_weapons_complainbubble_color_donthave;
1601 color = autocvar_hud_panel_weapons_complainbubble_color_unavailable;
1603 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);
1604 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);
1620 float GetAmmoItemCode(float i)
1624 case 0: return IT_SHELLS;
1625 case 1: return IT_NAILS;
1626 case 2: return IT_ROCKETS;
1627 case 3: return IT_CELLS;
1628 case 4: return IT_FUEL;
1633 string GetAmmoPicture(float i)
1637 case 0: return "ammo_shells";
1638 case 1: return "ammo_bullets";
1639 case 2: return "ammo_rockets";
1640 case 3: return "ammo_cells";
1641 case 4: return "ammo_fuel";
1646 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1649 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1650 if(autocvar__hud_configure)
1660 if(currently_selected)
1665 vector newSize, newPos;
1666 if(mySize_x/mySize_y > 3)
1668 newSize_x = 3 * mySize_y;
1669 newSize_y = mySize_y;
1671 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1676 newSize_y = 1/3 * mySize_x;
1677 newSize_x = mySize_x;
1679 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1683 vector picpos, numpos;
1684 if(autocvar_hud_panel_ammo_iconalign)
1687 picpos = newPos + eX * 2 * newSize_y;
1691 numpos = newPos + eX * newSize_y;
1695 if (currently_selected)
1696 drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1698 drawfont = hud_bigfont;
1699 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1700 drawfont = hud_font;
1701 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1706 if(!autocvar_hud_panel_ammo && !autocvar__hud_configure)
1709 active_panel = HUD_PANEL_AMMO;
1710 HUD_Panel_UpdateCvars(ammo);
1711 float i, currently_selected;
1715 mySize = panel_size;
1717 HUD_Panel_DrawBg(1);
1718 if(panel_bg_padding)
1720 pos += '1 1 0' * panel_bg_padding;
1721 mySize -= '2 2 0' * panel_bg_padding;
1724 float rows, columns;
1725 rows = mySize_y/mySize_x;
1726 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1727 // ^^^ ammo item aspect goes here
1729 columns = ceil(AMMO_COUNT/rows);
1733 for (i = 0; i < AMMO_COUNT; ++i) {
1734 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1735 if(autocvar_hud_panel_ammo_onlycurrent) {
1736 if(autocvar__hud_configure)
1738 if (currently_selected || autocvar__hud_configure)
1740 DrawAmmoItem(pos, mySize, i, currently_selected);
1744 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);
1749 column = column + 1;
1755 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float alpha)
1757 vector newSize, newPos;
1758 if(mySize_x/mySize_y > 3)
1760 newSize_x = 3 * mySize_y;
1761 newSize_y = mySize_y;
1763 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1768 newSize_y = 1/3 * mySize_x;
1769 newSize_x = mySize_x;
1771 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1775 vector picpos, numpos;
1778 if(iconalign == 1 || iconalign == 3) // right align
1781 picpos = newPos + eX * 2 * newSize_y;
1785 numpos = newPos + eX * newSize_y;
1791 if(iconalign == 0 || iconalign == 3) // left align
1793 numpos = newPos + eX * newSize_y;
1799 picpos = newPos + eX * 2 * newSize_y;
1803 drawfont = hud_bigfont;
1804 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1805 drawfont = hud_font;
1806 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1809 void DrawNumIcon_expanding(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float fadelerp)
1812 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
1814 DrawNumIcon(iconalign, myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, left, color, (1 - fadelerp));
1819 void HUD_Powerups(void) {
1820 if(!autocvar_hud_panel_powerups && !autocvar__hud_configure)
1823 active_panel = HUD_PANEL_POWERUPS;
1824 HUD_Panel_UpdateCvars(powerups);
1826 stat_items = getstati(STAT_ITEMS);
1828 if(!autocvar__hud_configure)
1830 if not(stat_items & IT_STRENGTH)
1831 if not(stat_items & IT_INVINCIBLE)
1834 if (getstati(STAT_HEALTH) <= 0)
1840 mySize = panel_size;
1842 float strength_time, shield_time;
1844 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1845 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1847 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
1848 if(panel_bg_padding)
1850 pos += '1 1 0' * panel_bg_padding;
1851 mySize -= '2 2 0' * panel_bg_padding;
1854 if(autocvar__hud_configure)
1860 vector barpos, barsize;
1864 string leftname, rightname;
1865 float leftcnt, rightcnt;
1866 float leftexact, rightexact;
1867 if (autocvar_hud_panel_powerups_flip) {
1868 leftname = "strength";
1869 leftcnt = ceil(strength_time);
1870 leftexact = strength_time;
1872 rightname = "shield";
1873 rightcnt = ceil(shield_time);
1874 rightexact = shield_time;
1876 leftname = "shield";
1877 leftcnt = ceil(shield_time);
1878 leftexact = shield_time;
1880 rightname = "strength";
1881 rightcnt = ceil(strength_time);
1882 rightexact = strength_time;
1885 drawfont = hud_bigfont;
1886 if (mySize_x/mySize_y > 4)
1890 if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // right align
1891 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1892 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1893 } else { // left align
1895 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1898 if(autocvar_hud_panel_powerups_progressbar)
1900 HUD_Panel_GetProgressBarColor(leftname)
1901 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);
1904 DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
1906 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));
1911 if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // left align
1912 barpos = pos + eX * 0.5 * mySize_x;
1913 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1914 } else { // right align
1915 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1916 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1919 if(autocvar_hud_panel_powerups_progressbar)
1921 HUD_Panel_GetProgressBarColor(rightname)
1922 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);
1925 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);
1927 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));
1930 else if (mySize_x/mySize_y > 1.5)
1934 if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // right align
1935 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1936 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1937 } else { // left align
1939 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1942 if(autocvar_hud_panel_powerups_progressbar)
1944 HUD_Panel_GetProgressBarColor(leftname)
1945 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);
1948 DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
1950 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));
1955 if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // left align
1956 barpos = pos + eY * 0.5 * mySize_y;
1957 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1958 } else { // right align
1959 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1960 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1963 if(autocvar_hud_panel_powerups_progressbar)
1965 HUD_Panel_GetProgressBarColor(rightname)
1966 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);
1969 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);
1971 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));
1978 if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // down align
1979 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1980 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1981 } else { // up align
1983 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1986 if(autocvar_hud_panel_powerups_iconalign == 1 || autocvar_hud_panel_powerups_iconalign == 3) { // down align
1987 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
1988 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
1989 } else { // up align
1990 picpos = pos + eX * 0.05 * mySize_x;
1991 numpos = pos + eY * 0.4 * mySize_x;
1994 if(autocvar_hud_panel_powerups_progressbar)
1996 HUD_Panel_GetProgressBarColor(leftname)
1997 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);
2000 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));
2002 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2003 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2008 if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // up align
2009 barpos = pos + eX * 0.5 * mySize_x;
2010 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2011 } else { // down align
2012 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
2013 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2016 if(autocvar_hud_panel_powerups_iconalign == 0 || autocvar_hud_panel_powerups_iconalign == 3) { // up align
2017 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2018 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2019 } else { // down align
2020 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2021 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2024 if(autocvar_hud_panel_powerups_progressbar)
2026 HUD_Panel_GetProgressBarColor(rightname)
2027 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);
2030 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));
2032 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2033 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2036 drawfont = hud_font;
2039 // Health/armor (#3)
2041 void HUD_HealthArmor(void)
2043 if(!autocvar_hud_panel_healtharmor && !autocvar__hud_configure)
2046 active_panel = HUD_PANEL_HEALTHARMOR;
2047 HUD_Panel_UpdateCvars(healtharmor);
2050 mySize = panel_size;
2052 HUD_Panel_DrawBg(1);
2053 if(panel_bg_padding)
2055 pos += '1 1 0' * panel_bg_padding;
2056 mySize -= '2 2 0' * panel_bg_padding;
2059 float armor, health;
2060 armor = getstati(STAT_ARMOR);
2061 health = getstati(STAT_HEALTH);
2064 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
2066 if(autocvar__hud_configure)
2076 vector barpos, barsize;
2080 drawfont = hud_bigfont;
2081 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
2084 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2089 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
2090 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2091 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2092 } else { // left align
2094 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2098 if(v_z) // NOT fully armored
2100 biggercount = "health";
2101 if(autocvar_hud_panel_healtharmor_progressbar)
2103 HUD_Panel_GetProgressBarColor("health")
2104 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2107 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);
2111 biggercount = "armor";
2112 if(autocvar_hud_panel_healtharmor_progressbar)
2114 HUD_Panel_GetProgressBarColor("armor")
2115 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2118 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);
2120 DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200), 1);
2125 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2126 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2127 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2130 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2132 HUD_Panel_GetProgressBarColor("fuel")
2133 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2138 string leftname, rightname;
2139 float leftcnt, rightcnt;
2140 float leftactive, rightactive;
2141 float leftalpha, rightalpha;
2142 if (autocvar_hud_panel_healtharmor_flip) { // old style layout with armor left/top of health
2147 leftalpha = min((armor+10)/55, 1);
2149 rightname = "health";
2154 leftname = "health";
2159 rightname = "armor";
2163 rightalpha = min((armor+10)/55, 1);
2166 if (mySize_x/mySize_y > 4)
2170 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
2171 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2172 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2173 } else { // left align
2175 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2178 if(autocvar_hud_panel_healtharmor_progressbar)
2180 HUD_Panel_GetProgressBarColor(leftname)
2181 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2183 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);
2188 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2189 barpos = pos + eX * 0.5 * mySize_x;
2190 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2191 } else { // right align
2192 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2193 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2196 if(autocvar_hud_panel_healtharmor_progressbar)
2198 HUD_Panel_GetProgressBarColor(rightname)
2199 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2201 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);
2206 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2207 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2208 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2211 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2213 HUD_Panel_GetProgressBarColor("fuel")
2214 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2217 else if (mySize_x/mySize_y > 1.5)
2221 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
2222 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2223 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2224 } else { // left align
2226 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2229 if(autocvar_hud_panel_healtharmor_progressbar)
2231 HUD_Panel_GetProgressBarColor(leftname)
2232 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2234 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);
2239 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2240 barpos = pos + eY * 0.5 * mySize_y;
2241 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2242 } else { // right align
2243 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2244 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2247 if(autocvar_hud_panel_healtharmor_progressbar)
2249 HUD_Panel_GetProgressBarColor(rightname)
2250 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2252 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);
2257 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2258 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2259 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2262 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2264 HUD_Panel_GetProgressBarColor("fuel")
2265 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2272 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // down align
2273 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2274 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2275 } else { // up align
2277 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2280 if(autocvar_hud_panel_healtharmor_iconalign == 1 || autocvar_hud_panel_healtharmor_iconalign == 3) { // down align
2281 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2282 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2283 } else { // up align
2284 picpos = pos + eX * 0.05 * mySize_x;
2285 numpos = pos + eY * 0.4 * mySize_x;
2288 if(autocvar_hud_panel_healtharmor_progressbar)
2290 HUD_Panel_GetProgressBarColor(leftname)
2291 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2293 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2294 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);
2299 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // up align
2300 barpos = pos + eX * 0.5 * mySize_x;
2301 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2302 } else { // down align
2303 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2304 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2307 if(autocvar_hud_panel_healtharmor_iconalign == 0 || autocvar_hud_panel_healtharmor_iconalign == 3) { // up align
2308 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2309 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2310 } else { // down align
2311 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2312 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2315 if(autocvar_hud_panel_healtharmor_progressbar)
2317 HUD_Panel_GetProgressBarColor(rightname)
2318 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2320 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2321 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);
2326 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2328 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2330 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2331 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2333 HUD_Panel_GetProgressBarColor("fuel")
2334 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2338 drawfont = hud_font;
2341 // Notification area (#4)
2344 string Weapon_SuicideMessage(float deathtype)
2346 w_deathtype = deathtype;
2347 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2348 return w_deathtypestring;
2351 string Weapon_KillMessage(float deathtype)
2353 w_deathtype = deathtype;
2354 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2355 return w_deathtypestring;
2358 float killnotify_times[10];
2359 float killnotify_deathtype[10];
2360 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2361 string killnotify_attackers[10];
2362 string killnotify_victims[10];
2363 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2366 for (i = 9; i > 0; --i) {
2367 killnotify_times[i] = killnotify_times[i-1];
2368 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2369 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2370 if(killnotify_attackers[i])
2371 strunzone(killnotify_attackers[i]);
2372 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2373 if(killnotify_victims[i])
2374 strunzone(killnotify_victims[i]);
2375 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2377 killnotify_times[0] = time;
2378 killnotify_deathtype[0] = wpn;
2379 killnotify_actiontype[0] = actiontype;
2380 if(killnotify_attackers[0])
2381 strunzone(killnotify_attackers[0]);
2382 killnotify_attackers[0] = strzone(attacker);
2383 if(killnotify_victims[0])
2384 strunzone(killnotify_victims[0]);
2385 killnotify_victims[0] = strzone(victim);
2388 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2391 float alsoprint, gentle;
2392 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2393 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2395 if(msg == MSG_SUICIDE) {
2396 w = DEATH_WEAPONOF(type);
2398 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2400 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
2401 } else if (type == DEATH_KILL) {
2402 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2404 print ("^1",s1, "^1 couldn't take it anymore\n");
2405 } else if (type == DEATH_ROT) {
2406 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2408 print ("^1",s1, "^1 died\n");
2409 } else if (type == DEATH_NOAMMO) {
2410 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2412 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2413 } else if (type == DEATH_CAMP) {
2414 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2416 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2417 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2418 HUD_KillNotify_Push(s1, "", 0, type);
2420 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2421 } else if (type == DEATH_CHEAT) {
2422 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2424 print ("^1",s1, "^1 unfairly eliminated themself\n");
2425 } else if (type == DEATH_FIRE) {
2426 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2428 print ("^1",s1, "^1 burned to death\n");
2429 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2430 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2432 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2435 if (stof(s2) > 2) // killcount > 2
2436 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2437 } else if(msg == MSG_KILL) {
2438 w = DEATH_WEAPONOF(type);
2440 HUD_KillNotify_Push(s1, s2, 1, type);
2442 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
2444 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2445 HUD_KillNotify_Push(s1, s2, 1, type);
2449 print ("^1", s1, "^1 took action against a team mate\n");
2451 print ("^1", s1, "^1 mows down a team mate\n");
2454 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2456 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2458 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2460 else if (stof(s2) > 2) {
2462 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2464 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2467 else if(type == KILL_FIRST_BLOOD)
2468 print("^1",s1, "^1 drew first blood", "\n");
2470 else if (type == DEATH_TELEFRAG)
2471 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2472 else if (type == DEATH_DROWN) {
2473 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2475 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2477 else if (type == DEATH_SLIME) {
2478 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2480 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2482 else if (type == DEATH_LAVA) {
2483 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2485 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2487 else if (type == DEATH_FALL) {
2488 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2490 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2492 else if (type == DEATH_SHOOTING_STAR) {
2493 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2495 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2497 else if (type == DEATH_SWAMP) {
2498 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2500 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2502 else if (type == DEATH_HURTTRIGGER)
2504 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2506 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2507 } else if(type == DEATH_SBCRUSH) {
2508 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2510 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2511 } else if(type == DEATH_SBMINIGUN) {
2512 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2514 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2515 } else if(type == DEATH_SBROCKET) {
2516 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2518 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2519 } else if(type == DEATH_SBBLOWUP) {
2520 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2522 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2523 } else if(type == DEATH_WAKIGUN) {
2524 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2526 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2527 } else if(type == DEATH_WAKIROCKET) {
2528 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2530 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2531 } else if(type == DEATH_WAKIBLOWUP) {
2532 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2534 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2535 } else if(type == DEATH_TURRET) {
2536 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2538 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2539 } else if(type == DEATH_TOUCHEXPLODE) {
2540 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2542 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2543 } else if(type == DEATH_CHEAT) {
2544 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2546 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2547 } else if (type == DEATH_FIRE) {
2548 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2550 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2551 } else if (type == DEATH_CUSTOM) {
2552 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2554 print ("^1",s1, "^1 ", s2, "\n");
2556 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2558 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2560 } else if(msg == MSG_SPREE) {
2561 if(type == KILL_END_SPREE) {
2563 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2565 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2566 } else if(type == KILL_SPREE) {
2568 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2570 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2571 } else if(type == KILL_SPREE_3) {
2573 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2575 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2576 } else if(type == KILL_SPREE_5) {
2578 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2580 print (s1,"^7 unleashes ^1RAGE\n");
2581 } else if(type == KILL_SPREE_10) {
2583 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2585 print (s1,"^7 starts the ^1MASSACRE!\n");
2586 } else if(type == KILL_SPREE_15) {
2588 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2590 print (s1,"^7 executes ^1MAYHEM!\n");
2591 } else if(type == KILL_SPREE_20) {
2593 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2595 print (s1,"^7 is a ^1BERSERKER!\n");
2596 } else if(type == KILL_SPREE_25) {
2598 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2600 print (s1,"^7 inflicts ^1CARNAGE!\n");
2601 } else if(type == KILL_SPREE_30) {
2603 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2605 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2607 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2608 if (type == DEATH_DROWN) {
2609 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2613 print ("^1",s1, "^1 was in the water for too long\n");
2615 print ("^1",s1, "^1 drowned\n");
2617 } else if (type == DEATH_SLIME) {
2618 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2620 print ("^1",s1, "^1 was slimed\n");
2621 } else if (type == DEATH_LAVA) {
2622 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2626 print ("^1",s1, "^1 found a hot place\n");
2628 print ("^1",s1, "^1 turned into hot slag\n");
2630 } else if (type == DEATH_FALL) {
2631 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2635 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2637 print ("^1",s1, "^1 hit the ground with a crunch\n");
2639 } else if (type == DEATH_SHOOTING_STAR) {
2640 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2642 print ("^1",s1, "^1 became a shooting star\n");
2643 } else if (type == DEATH_SWAMP) {
2644 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2648 print ("^1",s1, "^1 discovered a swamp\n");
2650 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2652 } else if(type == DEATH_TURRET) {
2653 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2655 print ("^1",s1, "^1 was mowed down by a turret \n");
2656 } else if (type == DEATH_CUSTOM) {
2657 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2659 print ("^1",s1, "^1 ", s2, "\n");
2660 } else if (type == DEATH_HURTTRIGGER) {
2661 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2663 print ("^1",s1, "^1 was in the wrong place\n");
2664 } else if(type == DEATH_TOUCHEXPLODE) {
2665 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2667 print ("^1",s1, "^1 died in an accident\n");
2668 } else if(type == DEATH_CHEAT) {
2669 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2671 print ("^1",s1, "^1 was unfairly eliminated\n");
2672 } else if(type == DEATH_FIRE) {
2673 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2677 print ("^1",s1, "^1 felt a little hot\n");
2679 print ("^1",s1, "^1 burnt to death\n");
2682 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2686 print ("^1",s1, "^1 needs a restart\n");
2688 print ("^1",s1, "^1 died\n");
2691 } else if(msg == MSG_KILL_ACTION_SPREE) {
2693 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2695 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2696 } else if(msg == MSG_INFO) {
2697 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2698 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2699 print(s1, "^7 got the ", s2, "\n");
2700 } else if(type == INFO_LOSTFLAG) {
2701 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2702 print(s1, "^7 lost the ", s2, "\n");
2703 } else if(type == INFO_PICKUPFLAG) {
2704 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2705 print(s1, "^7 picked up the ", s2, "\n");
2706 } else if(type == INFO_RETURNFLAG) {
2707 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2708 print(s1, "^7 returned the ", s2, "\n");
2709 } else if(type == INFO_CAPTUREFLAG) {
2710 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
2711 print(s1, "^7 captured the ", s2, s3, "\n");
2716 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2718 void HUD_Centerprint(string s1, string s2, float type, float msg)
2721 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2722 if(msg == MSG_SUICIDE) {
2723 if (type == DEATH_TEAMCHANGE) {
2724 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2725 } else if (type == DEATH_AUTOTEAMCHANGE) {
2726 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2727 } else if (type == DEATH_CAMP) {
2729 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2731 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2732 } else if (type == DEATH_NOAMMO) {
2734 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2736 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2737 } else if (type == DEATH_ROT) {
2739 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2741 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2742 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2744 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2746 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2747 } else if (type == DEATH_QUIET) {
2749 } else if (type == DEATH_KILL) {
2751 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2753 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2755 } else if(msg == MSG_KILL) {
2756 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2758 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2760 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2762 } else if (type == KILL_FIRST_BLOOD) {
2764 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2766 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2768 } else if (type == KILL_FIRST_VICTIM) {
2770 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2772 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2774 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2776 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2778 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2780 } else if (type == KILL_TYPEFRAGGED) {
2782 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2784 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2786 } else if (type == KILL_FRAG) {
2788 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2790 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2792 } else if (type == KILL_FRAGGED) {
2794 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2796 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2799 } else if(msg == MSG_KILL_ACTION) {
2800 // TODO: invent more centerprints here?
2801 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2805 void HUD_Notify (void)
2807 if(!autocvar_hud_panel_notify && !autocvar__hud_configure)
2810 active_panel = HUD_PANEL_NOTIFY;
2811 HUD_Panel_UpdateCvars(notify);
2814 mySize = panel_size;
2816 HUD_Panel_DrawBg(1);
2817 if(panel_bg_padding)
2819 pos += '1 1 0' * panel_bg_padding;
2820 mySize -= '2 2 0' * panel_bg_padding;
2823 float entries, height;
2824 entries = bound(1, floor(10 * mySize_y/mySize_x), 10);
2825 height = mySize_y/entries;
2828 fontsize = '0.5 0.5 0' * height;
2832 when = autocvar_hud_panel_notify_time;
2834 fadetime = autocvar_hud_panel_notify_fadetime;
2838 vector pos_attacker, pos_victim;
2840 float width_attacker;
2841 string attacker, victim;
2844 for(j = 0; j < entries; ++j)
2847 if(autocvar_hud_panel_notify_flip)
2849 else // rather nasty hack for ordering items from the bottom up
2850 i = entries - j - 1;
2854 if(killnotify_times[j] + when > time)
2857 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2861 if(killnotify_times[j] + when > time)
2868 w = DEATH_WEAPONOF(killnotify_deathtype[j]);
2870 // TODO: maybe print in team colors?
2873 if(killnotify_actiontype[j] == 0 && !autocvar__hud_configure)
2875 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2876 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
2877 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2879 if(killnotify_deathtype[j] == DEATH_GENERIC)
2883 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2885 s = "notify_outofammo";
2887 else if(killnotify_deathtype[j] == DEATH_KILL)
2889 s = "notify_selfkill";
2891 else if(killnotify_deathtype[j] == DEATH_CAMP)
2893 s = "notify_camping";
2895 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2897 s = "notify_teamkill_red";
2899 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2901 s = "notify_teamkill_blue";
2903 else if(killnotify_deathtype[j] == DEATH_DROWN)
2907 else if(killnotify_deathtype[j] == DEATH_SLIME)
2911 else if(killnotify_deathtype[j] == DEATH_LAVA)
2915 else if(killnotify_deathtype[j] == DEATH_FALL)
2919 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2921 s = "notify_shootingstar";
2923 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2927 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2929 if(killnotify_victims[j] == "^1RED^7 flag")
2931 s = "notify_red_taken";
2935 s = "notify_blue_taken";
2938 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2940 if(killnotify_victims[j] == "^1RED^7 flag")
2942 s = "notify_red_returned";
2946 s = "notify_blue_returned";
2949 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2951 if(killnotify_victims[j] == "^1RED^7 flag")
2953 s = "notify_red_lost";
2957 s = "notify_blue_lost";
2960 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
2962 if(killnotify_victims[j] == "^1RED^7 flag")
2964 s = "notify_red_captured";
2968 s = "notify_blue_captured";
2973 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2974 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2977 // X [did action to] Y
2980 if(autocvar__hud_configure)
2982 attacker = textShortenToWidth("Player1", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2983 victim = textShortenToWidth("Player2", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2984 a = bound(0, (when - j) / 4, 1);
2988 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2989 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2991 width_attacker = stringwidth(attacker, TRUE, fontsize);
2992 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
2993 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
2994 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2996 if(autocvar__hud_configure) // example actions for config mode
2998 s = "weaponelectro";
3000 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
3002 s = "notify_melee_laser";
3004 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_SHOTGUN)
3006 s = "notify_melee_shotgun";
3008 else if(WEP_VALID(w))
3010 self = get_weaponinfo(w);
3011 s = strcat("weapon", self.netname);
3013 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
3015 s = "notify_teamkill_red";
3017 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
3019 s = "notify_teamkill_red";
3021 else if(killnotify_deathtype[j] == DEATH_DROWN)
3025 else if(killnotify_deathtype[j] == DEATH_SLIME)
3029 else if(killnotify_deathtype[j] == DEATH_LAVA)
3033 else if(killnotify_deathtype[j] == DEATH_FALL)
3037 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
3039 s = "notify_shootingstar";
3041 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
3047 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3048 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3049 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3058 string seconds_tostring(float sec)
3061 minutes = floor(sec / 60);
3063 sec -= minutes * 60;
3066 s = ftos(100 + sec);
3068 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3071 void HUD_Timer(void)
3073 if(!autocvar_hud_panel_timer && !autocvar__hud_configure)
3076 active_panel = HUD_PANEL_TIMER;
3077 HUD_Panel_UpdateCvars(timer);
3080 mySize = panel_size;
3082 HUD_Panel_DrawBg(1);
3083 if(panel_bg_padding)
3085 pos += '1 1 0' * panel_bg_padding;
3086 mySize -= '2 2 0' * panel_bg_padding;
3090 float timelimit, elapsedTime, timeleft, minutesLeft;
3092 timelimit = getstatf(STAT_TIMELIMIT);
3094 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3095 timeleft = ceil(timeleft);
3097 minutesLeft = floor(timeleft / 60);
3100 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3101 timer_color = '1 1 1'; //white
3102 else if(minutesLeft >= 1)
3103 timer_color = '1 1 0'; //yellow
3105 timer_color = '1 0 0'; //red
3107 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
3108 if (time < getstatf(STAT_GAMESTARTTIME)) {
3109 //while restart is still active, show 00:00
3110 timer = seconds_tostring(0);
3112 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3113 timer = seconds_tostring(elapsedTime);
3116 timer = seconds_tostring(timeleft);
3119 drawfont = hud_bigfont;
3120 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3121 drawfont = hud_font;
3126 void HUD_Radar(void)
3128 if ((autocvar_hud_panel_radar == 0 || (autocvar_hud_panel_radar != 2 && !teamplay)) && !autocvar__hud_configure)
3131 active_panel = HUD_PANEL_RADAR;
3132 HUD_Panel_UpdateCvars(radar);
3135 mySize = panel_size;
3137 HUD_Panel_DrawBg(1);
3138 if(panel_bg_padding)
3140 pos += '1 1 0' * panel_bg_padding;
3141 mySize -= '2 2 0' * panel_bg_padding;
3144 local float color1, color2; // color already declared as a global in hud.qc
3147 float scale2d, normalsize, bigsize;
3150 teamradar_origin2d = pos + 0.5 * mySize;
3151 teamradar_size2d = mySize;
3153 if(minimapname == "")
3156 teamradar_loadcvars();
3158 switch(hud_panel_radar_zoommode)
3162 f = current_zoomfraction;
3165 f = 1 - current_zoomfraction;
3175 switch(hud_panel_radar_rotation)
3178 teamradar_angle = view_angles_y - 90;
3181 teamradar_angle = 90 * hud_panel_radar_rotation;
3185 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3186 teamradar_size2d = mySize;
3188 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3190 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3191 if(hud_panel_radar_rotation == 0)
3193 // max-min distance must fit the radar in any rotation
3194 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3198 vector c0, c1, c2, c3, span;
3199 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3200 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3201 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3202 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3204 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3205 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3207 // max-min distance must fit the radar in x=x, y=y
3209 teamradar_size2d_x * scale2d / (1.05 * span_x),
3210 teamradar_size2d_y * scale2d / (1.05 * span_y)
3214 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
3215 if(bigsize > normalsize)
3216 normalsize = bigsize;
3220 + (1 - f) * normalsize;
3221 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3222 f * (mi_min + mi_max) * 0.5
3223 + (1 - f) * view_origin);
3225 color1 = GetPlayerColor(player_localentnum-1);
3226 rgb = GetTeamRGB(color1);
3235 draw_teamradar_background(hud_panel_radar_foreground_alpha);
3237 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3238 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3239 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3240 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3241 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3243 color2 = GetPlayerColor(tm.sv_entnum);
3244 //if(color == COLOR_SPECTATOR || color == color2)
3245 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3247 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3249 drawresetcliparea();
3254 void HUD_Score(void)
3256 if(!autocvar_hud_panel_score && !autocvar__hud_configure)
3259 active_panel = HUD_PANEL_SCORE;
3260 HUD_Panel_UpdateCvars(score);
3263 mySize = panel_size;
3265 HUD_Panel_DrawBg(1);
3266 if(panel_bg_padding)
3268 pos += '1 1 0' * panel_bg_padding;
3269 mySize -= '2 2 0' * panel_bg_padding;
3272 float score, distribution, leader;
3273 vector distribution_color;
3275 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3277 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3278 string timer, distrtimer;
3280 pl = players.sort_next;
3283 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3284 if(pl.scores[ps_primary] == 0)
3287 score = me.(scores[ps_primary]);
3288 timer = TIME_ENCODED_TOSTRING(score);
3290 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3291 // distribution display
3292 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3294 distrtimer = ftos(distribution/pow(10, TIME_DECIMALS));
3296 if (distribution <= 0) {
3297 distribution_color = '0 1 0';
3300 distribution_color = '1 0 0';
3302 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);
3304 // race record display
3305 if (distribution <= 0)
3306 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3307 drawfont = hud_bigfont;
3308 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3309 drawfont = hud_font;
3310 } else if (!teamplay) { // non-teamgames
3311 // me vector := [team/connected frags id]
3312 pl = players.sort_next;
3316 if(autocvar__hud_configure)
3319 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3323 score = me.(scores[ps_primary]);
3324 if(autocvar__hud_configure)
3327 if(distribution >= 5) {
3328 distribution_color = eY;
3330 } else if(distribution >= 0) {
3331 distribution_color = '1 1 1';
3333 } else if(distribution >= -5)
3334 distribution_color = '1 1 0';
3336 distribution_color = eX;
3338 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);
3340 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3341 drawfont = hud_bigfont;
3342 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3343 drawfont = hud_font;
3344 } else { // teamgames
3345 float max_fragcount;
3346 max_fragcount = -99;
3349 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3350 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !autocvar__hud_configure)) // no players? don't display
3352 score = tm.(teamscores[ts_primary]);
3353 if(autocvar__hud_configure)
3357 if (score > max_fragcount)
3358 max_fragcount = score;
3360 if(tm.team == myteam) {
3361 if (max_fragcount == score)
3364 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3365 drawfont = hud_bigfont;
3366 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3367 drawfont = hud_font;
3369 if (max_fragcount == score)
3372 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);
3373 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);
3382 void HUD_RaceTimer (void) {
3383 if(!autocvar_hud_panel_racetimer && !(gametype == GAME_RACE || gametype == GAME_CTS) && !autocvar__hud_configure)
3386 active_panel = HUD_PANEL_RACETIMER;
3387 HUD_Panel_UpdateCvars(racetimer);
3390 mySize = panel_size;
3392 HUD_Panel_DrawBg(1);
3393 if(panel_bg_padding)
3395 pos += '1 1 0' * panel_bg_padding;
3396 mySize -= '2 2 0' * panel_bg_padding;
3399 // always force 4:1 aspect
3401 if(mySize_x/mySize_y > 4)
3403 newSize_x = 4 * mySize_y;
3404 newSize_y = mySize_y;
3406 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3410 newSize_y = 1/4 * mySize_x;
3411 newSize_x = mySize_x;
3413 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3417 drawfont = hud_bigfont;
3419 string s, forcetime;
3421 if(autocvar__hud_configure)
3424 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);
3425 s = "^1Intermediate 1 (+15.42)";
3426 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);
3427 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3428 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);
3430 else if(race_checkpointtime)
3432 a = bound(0, 2 - (time - race_checkpointtime), 1);
3435 if(a > 0) // just hit a checkpoint?
3437 if(race_checkpoint != 254)
3439 if(race_time && race_previousbesttime)
3440 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3442 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3444 forcetime = TIME_ENCODED_TOSTRING(race_time);
3449 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3451 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3452 if(a > 0) // next one?
3454 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3459 if(s != "" && a > 0)
3461 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);
3464 if(race_penaltytime)
3466 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3469 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3470 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);
3476 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3477 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);
3482 if(race_laptime && race_checkpoint != 255)
3484 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3485 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);
3490 if(race_mycheckpointtime)
3492 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3493 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3494 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);
3496 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3498 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3499 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3500 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);
3503 if(race_penaltytime && !race_penaltyaccumulator)
3505 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3506 a = bound(0, (1 + t - time), 1);
3510 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3512 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3513 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);
3518 drawfont = hud_font;
3523 float vote_yescount;
3526 float vote_highlighted; // currently selected vote
3528 float vote_active; // is there an active vote?
3529 float vote_prev; // previous state of vote_active to check for a change
3531 float vote_change; // "time" when vote_active changed
3533 void HUD_VoteWindow(void)
3535 if(!autocvar_hud_panel_vote && !autocvar__hud_configure)
3538 active_panel = HUD_PANEL_VOTE;
3539 HUD_Panel_UpdateCvars(vote);
3542 mySize = panel_size;
3546 if(vote_active != vote_prev) {
3548 vote_prev = vote_active;
3551 if(vote_active || autocvar__hud_configure)
3552 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3554 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3556 if(autocvar__hud_configure)
3566 a = vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3568 HUD_Panel_DrawBg(a);
3569 if(panel_bg_padding)
3571 pos += '1 1 0' * panel_bg_padding;
3572 mySize -= '2 2 0' * panel_bg_padding;
3575 // always force 3:1 aspect
3577 if(mySize_x/mySize_y > 3)
3579 newSize_x = 3 * mySize_y;
3580 newSize_y = mySize_y;
3582 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3586 newSize_y = 1/3 * mySize_x;
3587 newSize_x = mySize_x;
3589 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3593 s = "A vote has been called for:";
3594 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3595 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1.75/8), stringwidth_colors);
3596 if(autocvar__hud_configure)
3597 s = "^1Configure the HUD";
3598 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3600 // print the yes/no counts
3601 s = strcat("Yes (", getcommandkey("not bound", "vyes"), "): ", ftos(vote_yescount));
3602 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);
3603 s = strcat("No (", getcommandkey("not bound", "vno"), "): ", ftos(vote_nocount));
3604 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);
3606 // draw the progress bar backgrounds
3607 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);
3609 // draw the highlights
3610 if(vote_highlighted == 1) {
3611 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3612 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);
3614 else if(vote_highlighted == 2) {
3615 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3616 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);
3619 // draw the progress bars
3620 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3621 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);
3623 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3624 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);
3626 drawresetcliparea();
3629 vote_highlighted = 0;
3633 // Mod icons panel (#10)
3636 float mod_active; // is there any active mod icon?
3638 // CTF HUD modicon section
3639 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3640 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3641 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3643 void HUD_Mod_CTF_Reset(void)
3645 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3648 void HUD_Mod_CTF(vector pos, vector mySize)
3650 vector redflag_pos, blueflag_pos;
3652 float f; // every function should have that
3654 float redflag, blueflag; // current status
3655 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3658 stat_items = getstati(STAT_ITEMS);
3659 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3660 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3662 if(redflag || blueflag)
3667 if(autocvar__hud_configure)
3673 // when status CHANGES, set old status into prevstatus and current status into status
3674 if (redflag != redflag_prevframe)
3676 redflag_statuschange_time = time;
3677 redflag_prevstatus = redflag_prevframe;
3678 redflag_prevframe = redflag;
3681 if (blueflag != blueflag_prevframe)
3683 blueflag_statuschange_time = time;
3684 blueflag_prevstatus = blueflag_prevframe;
3685 blueflag_prevframe = blueflag;
3688 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3689 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3691 float BLINK_FACTOR = 0.15;
3692 float BLINK_BASE = 0.85;
3694 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3696 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3698 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3700 string red_icon, red_icon_prevstatus;
3701 float red_alpha, red_alpha_prevstatus;
3702 red_alpha = red_alpha_prevstatus = 1;
3704 case 1: red_icon = "flag_red_taken"; break;
3705 case 2: red_icon = "flag_red_lost"; break;
3706 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3708 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3709 red_icon = "flag_red_shielded";
3711 red_icon = string_null;
3714 switch(redflag_prevstatus) {
3715 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3716 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3717 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3720 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3721 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3722 red_icon_prevstatus = "flag_red_shielded";
3724 red_icon_prevstatus = string_null;
3728 string blue_icon, blue_icon_prevstatus;
3729 float blue_alpha, blue_alpha_prevstatus;
3730 blue_alpha = blue_alpha_prevstatus = 1;
3732 case 1: blue_icon = "flag_blue_taken"; break;
3733 case 2: blue_icon = "flag_blue_lost"; break;
3734 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3736 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3737 blue_icon = "flag_blue_shielded";
3739 blue_icon = string_null;
3742 switch(blueflag_prevstatus) {
3743 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3744 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3745 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3748 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3749 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3750 blue_icon_prevstatus = "flag_blue_shielded";
3752 blue_icon_prevstatus = string_null;
3756 if(mySize_x > mySize_y) {
3757 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3759 blueflag_pos = pos + eX * 0.5 * mySize_x;
3762 redflag_pos = pos + eX * 0.5 * mySize_x;
3764 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3766 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3768 blueflag_pos = pos + eY * 0.5 * mySize_y;
3771 redflag_pos = pos + eY * 0.5 * mySize_y;
3773 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3776 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3777 if(red_icon_prevstatus && f < 1)
3778 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3780 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3782 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3783 if(blue_icon_prevstatus && f < 1)
3784 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3786 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3789 // Keyhunt HUD modicon section
3790 float kh_runheretime;
3792 void HUD_Mod_KH_Reset(void)
3797 void HUD_Mod_KH(vector pos, vector mySize)
3799 mod_active = 1; // keyhunt should never hide the mod icons panel
3803 vector p, pa, kh_size, kh_asize;
3805 kh_keys = getstati(STAT_KH_KEYS);
3808 if(mySize_x > mySize_y)
3810 p_y = pos_y + 0.25 * mySize_y;
3811 pa = p - eY * 0.25 * mySize_y;
3813 kh_size_x = mySize_x * 0.25;
3814 kh_size_y = 0.75 * mySize_y;
3815 kh_asize_x = mySize_x * 0.25;
3816 kh_asize_y = mySize_y * 0.25;
3820 p_y = pos_y + 0.125 * mySize_y;
3821 pa = p - eY * 0.125 * mySize_y;
3823 kh_size_x = mySize_x * 0.5;
3824 kh_size_y = 0.375 * mySize_y;
3825 kh_asize_x = mySize_x * 0.5;
3826 kh_asize_y = mySize_y * 0.125;
3833 for(i = 0; i < 4; ++i)
3835 key = floor(kh_keys / pow(32, i)) & 31;
3837 if(keyteam == 30 && keycount <= 4)
3839 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3843 // this yields 8 exactly if "RUN HERE" shows
3848 kh_runheretime = time;
3849 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3854 for(i = 0; i < 4; ++i)
3856 key = floor(kh_keys / pow(32, i)) & 31;
3869 default: // owned or dropped
3874 a = a * panel_fg_alpha;
3875 aa = aa * panel_fg_alpha;
3881 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3884 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3887 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3890 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3895 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3898 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3901 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3904 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3907 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3911 if(mySize_x > mySize_y)
3913 p_x += 0.25 * mySize_x;
3914 pa_x += 0.25 * mySize_x;
3920 p_y = pos_y + 0.625 * mySize_y;
3921 pa_y = pos_y + 0.5 * mySize_y;
3927 p_x += 0.5 * mySize_x;
3928 pa_x += 0.5 * mySize_x;
3934 // Nexball HUD mod icon
3935 void HUD_Mod_NexBall(vector pos, vector mySize)
3937 float stat_items, nb_pb_starttime, dt, p;
3939 stat_items = getstati(STAT_ITEMS);
3940 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3942 if (stat_items & IT_KEY1)
3947 //Manage the progress bar if any
3948 if (nb_pb_starttime > 0)
3950 dt = mod(time - nb_pb_starttime, nb_pb_period);
3951 // one period of positive triangle
3952 p = 2 * dt / nb_pb_period;
3959 if(mySize_x > mySize_y)
3961 barsize = eX * p * mySize_x + eY * mySize_y;
3966 barsize = eX * mySize_x + eY * p * mySize_y;
3969 HUD_Panel_GetProgressBarColor("nexball")
3970 HUD_Panel_DrawProgressBar(pos, vertical, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3973 if (stat_items & IT_KEY1)
3974 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3977 // Race/CTS HUD mod icons
3978 float crecordtime_prev; // last remembered crecordtime
3979 float crecordtime_change_time; // time when crecordtime last changed
3980 float srecordtime_prev; // last remembered srecordtime
3981 float srecordtime_change_time; // time when srecordtime last changed
3983 float race_status_time;
3984 float race_status_prev;
3985 string race_status_name_prev;
3986 void HUD_Mod_Race(vector pos, vector mySize)
3988 mod_active = 1; // race should never hide the mod icons panel
3990 me = playerslots[player_localentnum - 1];
3992 float f; // yet another function has this
3993 score = me.(scores[ps_primary]);
3995 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3996 return; // no records in the actual race
3998 drawfont = hud_bigfont;
4000 // clientside personal record
4002 if(gametype == GAME_CTS)
4006 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4008 if(score && (score < t || !t)) {
4009 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4010 if(cvar("cl_autodemo_delete_keeprecords"))
4012 f = cvar("cl_autodemo_delete");
4014 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4018 if(t != crecordtime_prev) {
4019 crecordtime_prev = t;
4020 crecordtime_change_time = time;
4022 f = time - crecordtime_change_time;
4025 drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4026 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);
4028 drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4029 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);
4030 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);
4031 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);
4035 t = race_server_record;
4036 if(t != srecordtime_prev) {
4037 srecordtime_prev = t;
4038 srecordtime_change_time = time;
4040 f = time - srecordtime_change_time;
4043 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);
4044 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);
4046 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);
4047 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);
4048 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);
4049 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);
4052 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4053 race_status_time = time + 5;
4054 race_status_prev = race_status;
4055 if (race_status_name_prev)
4056 strunzone(race_status_name_prev);
4057 race_status_name_prev = strzone(race_status_name);
4060 pos_x += mySize_x/2;
4063 a = bound(0, race_status_time - time, 1);
4066 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4070 rank = race_CheckName(race_status_name);
4072 rankname = race_PlaceName(rank);
4075 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4077 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4079 if(race_status == 0)
4080 drawpic_aspect_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4081 else if(race_status == 1) {
4082 drawpic_aspect_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4083 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4084 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4085 } else if(race_status == 2) {
4086 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4087 drawpic_aspect_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4089 drawpic_aspect_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4090 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4091 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4092 } else if(race_status == 3) {
4093 drawpic_aspect_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4094 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4095 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4098 if (race_status_time - time <= 0) {
4099 race_status_prev = -1;
4101 if(race_status_name)
4102 strunzone(race_status_name);
4103 race_status_name = string_null;
4104 if(race_status_name_prev)
4105 strunzone(race_status_name_prev);
4106 race_status_name_prev = string_null;
4108 drawfont = hud_font;
4111 float mod_prev; // previous state of mod_active to check for a change
4113 float mod_change; // "time" when mod_active changed
4115 void HUD_ModIcons(void)
4117 if(!autocvar_hud_panel_modicons && !autocvar__hud_configure)
4120 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !autocvar__hud_configure)
4123 active_panel = HUD_PANEL_MODICONS;
4124 HUD_Panel_UpdateCvars(modicons);
4127 mySize = panel_size;
4129 if(mod_active != mod_prev) {
4131 mod_prev = mod_active;
4134 if(mod_active || autocvar__hud_configure)
4135 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4137 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4140 HUD_Panel_DrawBg(mod_alpha);
4142 if(panel_bg_padding)
4144 pos += '1 1 0' * panel_bg_padding;
4145 mySize -= '2 2 0' * panel_bg_padding;
4148 // these MUST be ran in order to update mod_active
4149 if(gametype == GAME_KEYHUNT)
4150 HUD_Mod_KH(pos, mySize);
4151 else if(gametype == GAME_CTF || autocvar__hud_configure)
4152 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4153 else if(gametype == GAME_NEXBALL)
4154 HUD_Mod_NexBall(pos, mySize);
4155 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4156 HUD_Mod_Race(pos, mySize);
4159 // Draw pressed keys (#11)
4161 void HUD_DrawPressedKeys(void)
4163 if(!autocvar_hud_panel_pressedkeys && !autocvar__hud_configure)
4166 if(!(spectatee_status > 0 || autocvar_hud_panel_pressedkeys >= 2 || autocvar__hud_configure))
4169 active_panel = HUD_PANEL_PRESSEDKEYS;
4170 HUD_Panel_UpdateCvars(pressedkeys);
4173 mySize = panel_size;
4175 HUD_Panel_DrawBg(1);
4176 if(panel_bg_padding)
4178 pos += '1 1 0' * panel_bg_padding;
4179 mySize -= '2 2 0' * panel_bg_padding;
4182 // force custom aspect
4183 if(autocvar_hud_panel_pressedkeys_aspect)
4186 if(mySize_x/mySize_y > autocvar_hud_panel_pressedkeys_aspect)
4188 newSize_x = autocvar_hud_panel_pressedkeys_aspect * mySize_y;
4189 newSize_y = mySize_y;
4191 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4195 newSize_y = 1/autocvar_hud_panel_pressedkeys_aspect * mySize_x;
4196 newSize_x = mySize_x;
4198 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4204 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4207 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4208 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4209 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);
4210 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);
4211 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);
4212 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);
4213 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);
4216 // Handle chat as a panel (#12)
4220 if(!autocvar_hud_panel_chat && !autocvar__hud_configure)
4222 cvar_set("con_chatrect", "0");
4226 active_panel = HUD_PANEL_CHAT;
4227 HUD_Panel_UpdateCvars(chat);
4229 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
4231 panel_pos_y = panel_bg_border;
4232 panel_size_y = vid_conheight - panel_bg_border * 2;
4234 panel_bg = "border"; // force a border when maximized
4235 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an alpha of at least 0.75
4240 mySize = panel_size;
4242 HUD_Panel_DrawBg(1);
4244 if(panel_bg_padding)
4246 pos += '1 1 0' * panel_bg_padding;
4247 mySize -= '2 2 0' * panel_bg_padding;
4250 cvar_set("con_chatrect", "1");
4252 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4253 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4255 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4256 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4258 if(autocvar__hud_configure)
4261 chatsize = cvar("con_chatsize");
4262 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4264 for(i = 0; i < cvar("con_chat"); ++i)
4266 if(i == cvar("con_chat") - 1)
4269 a = panel_fg_alpha * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4270 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);
4275 // Engine info panel (#13)
4282 float frametimeavg1; // 1 frame ago
4283 float frametimeavg2; // 2 frames ago
4284 void HUD_EngineInfo(void)
4286 if(!autocvar_hud_panel_engineinfo && !autocvar__hud_configure)
4289 active_panel = HUD_PANEL_ENGINEINFO;
4290 HUD_Panel_UpdateCvars(engineinfo);
4293 mySize = panel_size;
4295 HUD_Panel_DrawBg(1);
4296 if(panel_bg_padding)
4298 pos += '1 1 0' * panel_bg_padding;
4299 mySize -= '2 2 0' * panel_bg_padding;
4302 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
4304 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4305 frametimeavg2 = frametimeavg1;
4306 frametimeavg1 = frametimeavg;
4309 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4310 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.
4312 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
4313 prevfps = (1/frametime);
4314 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"
4320 if(time - prevfps_time > cvar("hud_panel_engineinfo_framecounter_time"))
4322 prevfps = framecounter/cvar("hud_panel_engineinfo_framecounter_time");
4324 prevfps_time = time;
4329 color = HUD_Get_Num_Color (prevfps, 100);
4330 drawfont = hud_bigfont;
4331 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_panel_engineinfo_framecounter_decimals"))), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4332 drawfont = hud_font;
4335 // Info messages panel (#14)
4337 void HUD_InfoMessages(void)
4339 if(!autocvar_hud_panel_infomessages && !autocvar__hud_configure)
4342 active_panel = HUD_PANEL_INFOMESSAGES;
4343 HUD_Panel_UpdateCvars(infomessages);
4346 mySize = panel_size;
4348 HUD_Panel_DrawBg(1);
4349 if(panel_bg_padding)
4351 pos += '1 1 0' * panel_bg_padding;
4352 mySize -= '2 2 0' * panel_bg_padding;
4355 // always force 5:1 aspect
4357 if(mySize_x/mySize_y > 5)
4359 newSize_x = 5 * mySize_y;
4360 newSize_y = mySize_y;
4362 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4366 newSize_y = 1/5 * mySize_x;
4367 newSize_x = mySize_x;
4369 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4378 fontsize = '0.20 0.20 0' * mySize_y;
4381 if(!autocvar__hud_configure)
4383 if(spectatee_status && !intermission)
4385 if(spectatee_status == -1)
4388 s = strcat("^1Spectating: ^7", GetPlayerName(spectatee_status - 1));
4390 if(autocvar_hud_panel_infomessages_flip)
4391 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4392 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4393 o += eY * fontsize_y;
4395 if(spectatee_status == -1)
4396 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
4398 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
4399 if(autocvar_hud_panel_infomessages_flip)
4400 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4401 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4402 o += eY * fontsize_y;
4404 if(spectatee_status == -1)
4405 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
4407 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
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 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
4414 if(autocvar_hud_panel_infomessages_flip)
4415 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4416 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4417 o += eY * fontsize_y;
4419 if(gametype == GAME_ARENA)
4420 s = "^1Wait for your turn to join";
4421 else if(gametype == GAME_LMS)
4424 sk = playerslots[player_localentnum - 1];
4425 if(sk.(scores[ps_primary]) >= 666)
4426 s = "^1Match has already begun";
4427 else if(sk.(scores[ps_primary]) > 0)
4428 s = "^1You have no more lives left";
4430 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4433 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4434 if(autocvar_hud_panel_infomessages_flip)
4435 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4436 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4437 o += eY * fontsize_y;
4439 //show restart countdown:
4440 if (time < getstatf(STAT_GAMESTARTTIME)) {
4442 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4443 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4444 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
4445 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4446 o += eY * fontsize_y;
4449 if(warmup_stage && !intermission)
4451 s = "^2Currently in ^1warmup^2 stage!";
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;
4459 if(mod(time, 1) >= 0.5)
4464 if(ready_waiting && !intermission && !spectatee_status)
4466 if(ready_waiting_for_me)
4469 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
4471 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
4476 s = strcat("^2Waiting for others to ready up to end warmup...");
4478 s = strcat("^2Waiting for others to ready up...");
4480 if(autocvar_hud_panel_infomessages_flip)
4481 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4482 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4483 o += eY * fontsize_y;
4485 else if(warmup_stage && !intermission && !spectatee_status)
4487 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
4488 if(autocvar_hud_panel_infomessages_flip)
4489 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4490 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4491 o += eY * fontsize_y;
4494 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4496 float ts_min, ts_max;
4497 tm = teams.sort_next;
4500 for(; tm.sort_next; tm = tm.sort_next)
4502 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4504 if(!ts_min) ts_min = tm.team_size;
4505 else ts_min = min(ts_min, tm.team_size);
4506 if(!ts_max) ts_max = tm.team_size;
4507 else ts_max = max(ts_max, tm.team_size);
4509 if ((ts_max - ts_min) > 1)
4511 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
4512 tm = GetTeam(myteam, false);
4514 if (tm.team != COLOR_SPECTATOR)
4515 if (tm.team_size == ts_max)
4516 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
4518 if(autocvar_hud_panel_infomessages_flip)
4519 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4520 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4521 o += eY * fontsize_y;
4528 s = "^7Press ^3ESC ^7to show HUD options.";
4529 if(autocvar_hud_panel_infomessages_flip)
4530 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4531 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4532 o += eY * fontsize_y;
4533 s = "^3Doubleclick ^7a panel for panel-specific options.";
4534 if(autocvar_hud_panel_infomessages_flip)
4535 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4536 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4537 o += eY * fontsize_y;
4538 s = "^3CTRL ^7to disable collision testing, ^3SHIFT ^7and";
4539 if(autocvar_hud_panel_infomessages_flip)
4540 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4541 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4542 o += eY * fontsize_y;
4543 s = "^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.";
4544 if(autocvar_hud_panel_infomessages_flip)
4545 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4546 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4547 o += eY * fontsize_y;
4557 void HUD_ShowSpeed(void)
4560 float pos, conversion_factor;
4561 string speed, zspeed, unit;
4563 switch(cvar("cl_showspeed_unit"))
4568 conversion_factor = 1.0;
4572 conversion_factor = 1.0;
4576 conversion_factor = 0.0254;
4580 conversion_factor = 0.0254 * 3.6;
4584 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4588 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4592 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4594 numsize_x = numsize_y = cvar("cl_showspeed_size");
4595 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4597 drawfont = hud_bigfont;
4598 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
4600 if (cvar("cl_showspeed_z") == 1) {
4601 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4602 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
4605 drawfont = hud_font;
4608 vector acc_prevspeed;
4612 void HUD_ShowAcceleration(void)
4614 float acceleration, sz, scale, alpha, f;
4615 vector pos, top, rgb;
4616 top_x = vid_conwidth/2;
4619 f = time - acc_prevtime;
4620 if(cvar("cl_showacceleration_z"))
4621 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4623 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4624 acc_prevspeed = pmove_vel;
4625 acc_prevtime = time;
4627 f = bound(0, f * 10, 1);
4628 acc_avg = acc_avg * (1 - f) + acceleration * f;
4629 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4631 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4633 sz = cvar("cl_showacceleration_size");
4634 scale = cvar("cl_showacceleration_scale");
4635 alpha = cvar("cl_showacceleration_alpha");
4636 if (cvar("cl_showacceleration_color_custom"))
4637 rgb = stov(cvar_string("cl_showacceleration_color"));
4640 if (acceleration < 0) {
4641 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4642 } else if (acceleration > 0) {
4643 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4647 if (acceleration > 0)
4648 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
4649 else if (acceleration < 0)
4650 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);
4653 void HUD_Reset (void)
4655 // reset gametype specific icons
4656 if(gametype == GAME_KEYHUNT)
4658 else if(gametype == GAME_CTF)
4659 HUD_Mod_CTF_Reset();
4662 #define HUD_DrawPanel(id)\
4664 case (HUD_PANEL_RADAR):\
4665 HUD_Radar(); break;\
4666 case (HUD_PANEL_WEAPONS):\
4667 HUD_Weapons(); break;\
4668 case (HUD_PANEL_AMMO):\
4670 case (HUD_PANEL_POWERUPS):\
4671 HUD_Powerups(); break;\
4672 case (HUD_PANEL_HEALTHARMOR):\
4673 HUD_HealthArmor(); break;\
4674 case (HUD_PANEL_NOTIFY):\
4675 HUD_Notify(); break;\
4676 case (HUD_PANEL_TIMER):\
4677 HUD_Timer(); break;\
4678 case (HUD_PANEL_SCORE):\
4679 HUD_Score(); break;\
4680 case (HUD_PANEL_RACETIMER):\
4681 HUD_RaceTimer(); break;\
4682 case (HUD_PANEL_VOTE):\
4683 HUD_VoteWindow(); break;\
4684 case (HUD_PANEL_MODICONS):\
4685 HUD_ModIcons(); break;\
4686 case (HUD_PANEL_PRESSEDKEYS):\
4687 HUD_DrawPressedKeys(); break;\
4688 case (HUD_PANEL_CHAT):\
4690 case (HUD_PANEL_ENGINEINFO):\
4691 HUD_EngineInfo(); break;\
4692 case (HUD_PANEL_INFOMESSAGES):\
4693 HUD_InfoMessages(); break;\
4696 void HUD_Main (void)
4698 hud_skin_path = strcat("gfx/hud/", autocvar_hud_skin);
4700 if(disable_menu_alphacheck == 1)
4701 menu_fade_alpha = 1;
4703 menu_fade_alpha = (1 - autocvar__menu_alpha);
4705 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4706 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4708 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4709 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4713 // HUD configure visible grid
4714 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4718 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2); ++i)
4720 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);
4723 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2); ++i)
4725 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);
4731 if((teamplay) && autocvar_hud_dock_color_team) {
4732 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4733 color = colormapPaletteColor(mod(f, 16), 1) * autocvar_hud_dock_color_team;
4735 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && autocvar_hud_dock_color_team) {
4736 color = '1 0 0' * autocvar_hud_dock_color_team;
4738 else if(autocvar_hud_dock_color == "shirt") {
4739 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4740 color = colormapPaletteColor(floor(f / 16), 0);
4742 else if(autocvar_hud_dock_color == "pants") {
4743 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4744 color = colormapPaletteColor(mod(f, 16), 1);
4747 color = stov(autocvar_hud_dock_color);
4750 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4753 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4754 if(precache_pic(pic) == "") {
4755 pic = "gfx/hud/default/dock";
4757 drawpic('0 0 0', pic, eX * vid_conwidth + eY * vid_conheight, color, autocvar_hud_dock_alpha * menu_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
4760 // cache the panel order into the panel_order array
4761 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4762 if(hud_panelorder_prev)
4763 strunzone(hud_panelorder_prev);
4764 hud_panelorder_prev = strzone(autocvar__hud_panelorder);
4765 tokenize_console(autocvar__hud_panelorder);
4766 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4767 panel_order[i] = stof(argv(i));
4770 // draw panels in order specified by panel_order array
4771 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
4772 if(i != HUD_PANEL_CHAT || !autocvar__con_chat_maximized) // don't draw maximized chat panel twice!
4773 HUD_DrawPanel(panel_order[i]);
4776 // draw chat panel on top if it is maximized
4777 if(autocvar__con_chat_maximized)
4778 HUD_DrawPanel(HUD_PANEL_CHAT);
4780 // TODO hud_'ify these
4781 if (cvar("cl_showspeed"))
4783 if (cvar("cl_showacceleration"))
4784 HUD_ShowAcceleration();
4786 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)
4787 localcmd("cmd selectteam auto; cmd join\n");
4789 hud_configure_prev = autocvar__hud_configure;
4791 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again
4792 disable_menu_alphacheck = 0;