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) // draw whole image as it is
19 drawpic(theOrigin, pic, theSize, theColor, theAlpha, 0);
22 if (theBorderSize_x == 0 && theBorderSize_y == 0) // no border
24 // draw only the central part
25 drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
32 //pic = draw_UseSkinFor(pic);
33 width = eX * theSize_x;
34 height = eY * theSize_y;
35 if(theSize_x <= theBorderSize_x * 2)
37 // not wide enough... draw just left and right then
38 bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
39 if(theSize_y <= theBorderSize_y * 2)
41 // not high enough... draw just corners
42 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
43 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
44 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
45 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
46 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
50 dY = theBorderSize_x * eY;
51 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
52 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
53 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
54 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);
55 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
56 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);
61 if(theSize_y <= theBorderSize_y * 2)
63 // not high enough... draw just top and bottom then
64 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
65 dX = theBorderSize_x * eX;
66 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
67 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
68 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
69 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
70 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);
71 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);
75 dX = theBorderSize_x * eX;
76 dY = theBorderSize_x * eY;
77 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
78 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
79 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
80 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
81 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
82 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
83 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
84 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
85 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
90 vector HUD_Get_Num_Color (float x, float maxvalue)
95 color_x = sin(2*M_PI*time);
97 color_z = sin(2*M_PI*time);
99 else if(x > maxvalue * 0.75) {
100 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
101 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
104 else if(x > maxvalue * 0.5) {
105 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
106 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
107 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
109 else if(x > maxvalue * 0.25) {
112 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
114 else if(x > maxvalue * 0.1) {
116 color_y = (x-20)*90/27/100; // green value between 0 -> 1
117 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
125 blinkingamt = (1 - x/maxvalue/0.25);
128 color_x = color_x - color_x * blinkingamt * sin(2*M_PI*time);
129 color_y = color_y - color_y * blinkingamt * sin(2*M_PI*time);
130 color_z = color_z - color_z * blinkingamt * sin(2*M_PI*time);
135 float stringwidth_colors(string s, vector theSize)
137 return stringwidth(s, TRUE, theSize);
140 float stringwidth_nocolors(string s, vector theSize)
142 return stringwidth(s, FALSE, theSize);
145 #define CENTERPRINT_MAX_LINES 30
146 string centerprint_messages[CENTERPRINT_MAX_LINES];
147 float centerprint_width[CENTERPRINT_MAX_LINES];
148 float centerprint_time;
149 float centerprint_expire;
150 float centerprint_num;
151 float centerprint_offset_hint;
152 vector centerprint_fontsize;
154 void centerprint(string strMessage)
156 float i, j, n, hcount;
159 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
161 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
163 if(autocvar_scr_centertime <= 0)
169 // strip trailing newlines
170 j = strlen(strMessage) - 1;
171 while(substring(strMessage, j, 1) == "\n" && j >= 0)
173 strMessage = substring(strMessage, 0, j + 1);
178 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
180 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
182 strMessage = substring(strMessage, j, strlen(strMessage) - j);
183 centerprint_offset_hint = j;
188 // if we get here, we have a message. Initialize its height.
191 n = tokenizebyseparator(strMessage, "\n");
193 for(j = 0; j < n; ++j)
195 getWrappedLine_remaining = argv(j);
196 while(getWrappedLine_remaining)
198 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
199 if(centerprint_messages[i] != s) // don't fade the same message in, looks stupid
200 centerprint_time = time;
201 if(centerprint_messages[i])
202 strunzone(centerprint_messages[i]);
203 centerprint_messages[i] = strzone(s);
204 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
207 // half height for empty lines looks better
213 if(i >= CENTERPRINT_MAX_LINES)
219 h = centerprint_fontsize_y*hcount;
221 havail = vid_conheight;
222 if(autocvar_con_chatpos < 0)
223 havail -= (-autocvar_con_chatpos + autocvar_con_chat) * autocvar_con_chatsize; // avoid overlapping chat
224 if(havail > vid_conheight - 70)
225 havail = vid_conheight - 70; // avoid overlapping HUD
228 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
230 // here, the centerprint would cover the crosshair. REALLY BAD.
231 forbiddenmin = vid_conheight * 0.5 - h - 16;
232 forbiddenmax = vid_conheight * 0.5 + 16;
234 allowedmin = scoreboard_bottom;
235 allowedmax = havail - h;
236 preferred = (havail - h)/2;
239 // possible orderings (total: 4! / 4 = 6)
240 // allowedmin allowedmax forbiddenmin forbiddenmax
241 // forbiddenmin forbiddenmax allowedmin allowedmax
242 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
244 // forbidden doesn't matter in this case
245 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
247 // allowedmin forbiddenmin allowedmax forbiddenmax
248 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
250 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
252 // allowedmin forbiddenmin forbiddenmax allowedmax
253 else if(allowedmin < forbiddenmin)
255 // make sure the forbidden zone is not covered
256 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
257 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
259 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
261 // forbiddenmin allowedmin allowedmax forbiddenmax
262 else if(allowedmax < forbiddenmax)
264 // it's better to leave the allowed zone (overlap with scoreboard) than
265 // to cover the forbidden zone (crosshair)
266 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
267 centerprint_start_y = forbiddenmax;
269 centerprint_start_y = forbiddenmin;
271 // forbiddenmin allowedmin forbiddenmax allowedmax
274 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
281 centerprint_expire = time + autocvar_scr_centertime;
284 void HUD_DrawCenterPrint (void)
291 if(time - centerprint_time < 0.25)
292 a = (time - centerprint_time) / 0.25;
294 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
301 if(centerprint_num * autocvar_scr_centersize > 24 && scoreboard_active) // 24 = height of Scoreboard text
302 centerprint_start_y = scoreboard_bottom + centerprint_fontsize_y;
304 pos = centerprint_start;
305 for (i=0; i<centerprint_num; i = i + 1)
307 ts = centerprint_messages[i];
308 drawfontscale = sz * '1 1 0';
309 pos_x = (vid_conwidth - stringwidth(ts, TRUE, centerprint_fontsize)) * 0.5;
312 drawcolorcodedstring(pos + '0 1 0' * (1 - sz) * 0.5 *centerprint_fontsize_y, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
313 pos_y = pos_y + centerprint_fontsize_y;
316 // half height for empty lines looks better
317 pos_y = pos_y + sz * centerprint_fontsize_y * 0.5;
318 drawfontscale = '1 1 0';
322 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
324 position_x -= 2 / 3 * strlen(text) * scale_x;
325 drawstring(position, text, scale, rgb, alpha, flag);
328 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
330 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
331 drawstring(position, text, scale, rgb, alpha, flag);
334 // return the string of the given race place
335 string race_PlaceName(float pos) {
343 return sprintf(_("%dth"), pos);
346 // return the string of the onscreen race timer
347 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
355 if(histime == 0) // goal hit
359 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
369 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
375 lapstr = sprintf(_(" (-%dL)"), lapdelta);
378 else if(lapdelta < 0)
380 lapstr = sprintf(_(" (+%dL)"), -lapdelta);
384 else if(histime > 0) // anticipation
386 if(mytime >= histime)
387 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
389 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
396 cpname = _("Start line");
398 cpname = _("Finish line");
400 cpname = sprintf(_("Intermediate %d"), cp);
402 cpname = _("Finish line");
405 return strcat(col, cpname);
406 else if(hisname == "")
407 return strcat(col, sprintf(_("%s (%s)"), cpname, timestr));
409 return strcat(col, sprintf(_("%s (%s %s)"), cpname, timestr, strcat(hisname, col, lapstr)));
412 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
413 float race_CheckName(string net_name) {
415 for (i=RANKINGS_CNT-1;i>=0;--i)
416 if(grecordholder[i] == net_name)
427 #define HUD_Write(s) fputs(fh, s)
428 // q: quoted, n: not quoted
429 #define HUD_Write_Cvar_n(cvar) HUD_Write(strcat("seta ", cvar, " ", cvar_string(cvar), "\n"))
430 #define HUD_Write_Cvar_q(cvar) HUD_Write(strcat("seta ", cvar, " \"", cvar_string(cvar), "\"\n"))
431 #define HUD_Write_PanelCvar_n(cvar_suf) HUD_Write_Cvar_n(strcat("hud_panel_", panel_name, cvar_suf))
432 #define HUD_Write_PanelCvar_q(cvar_suf) HUD_Write_Cvar_q(strcat("hud_panel_", panel_name, cvar_suf))
434 void HUD_Panel_ExportCfg(string cfgname)
437 string filename = strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg");
438 fh = fopen(filename, FILE_WRITE);
441 HUD_Write_Cvar_q("hud_skin");
442 HUD_Write_Cvar_q("hud_panel_bg");
443 HUD_Write_Cvar_q("hud_panel_bg_color");
444 HUD_Write_Cvar_q("hud_panel_bg_color_team");
445 HUD_Write_Cvar_q("hud_panel_bg_alpha");
446 HUD_Write_Cvar_q("hud_panel_bg_border");
447 HUD_Write_Cvar_q("hud_panel_bg_padding");
448 HUD_Write_Cvar_q("hud_panel_fg_alpha");
451 HUD_Write_Cvar_q("hud_dock");
452 HUD_Write_Cvar_q("hud_dock_color");
453 HUD_Write_Cvar_q("hud_dock_color_team");
454 HUD_Write_Cvar_q("hud_dock_alpha");
457 HUD_Write_Cvar_q("hud_progressbar_alpha");
458 HUD_Write_Cvar_q("hud_progressbar_strength_color");
459 HUD_Write_Cvar_q("hud_progressbar_shield_color");
460 HUD_Write_Cvar_q("hud_progressbar_health_color");
461 HUD_Write_Cvar_q("hud_progressbar_armor_color");
462 HUD_Write_Cvar_q("hud_progressbar_fuel_color");
463 HUD_Write_Cvar_q("hud_progressbar_nexball_color");
466 HUD_Write_Cvar_q("_hud_panelorder");
469 HUD_Write_Cvar_q("hud_configure_grid");
470 HUD_Write_Cvar_q("hud_configure_grid_xsize");
471 HUD_Write_Cvar_q("hud_configure_grid_ysize");
474 HUD_Write_Cvar_q("scr_centerpos");
477 // common cvars for all panels
479 for (i = 0; i < HUD_PANEL_NUM; ++i)
481 HUD_Panel_GetName(i);
483 HUD_Write_PanelCvar_n("");
484 HUD_Write_PanelCvar_q("_pos");
485 HUD_Write_PanelCvar_q("_size");
486 HUD_Write_PanelCvar_q("_bg");
487 HUD_Write_PanelCvar_q("_bg_color");
488 HUD_Write_PanelCvar_q("_bg_color_team");
489 HUD_Write_PanelCvar_q("_bg_alpha");
490 HUD_Write_PanelCvar_q("_bg_border");
491 HUD_Write_PanelCvar_q("_bg_padding");
493 case HUD_PANEL_WEAPONS:
494 HUD_Write_PanelCvar_q("_complainbubble");
495 HUD_Write_PanelCvar_q("_complainbubble_padding");
496 HUD_Write_PanelCvar_q("_complainbubble_color_outofammo");
497 HUD_Write_PanelCvar_q("_complainbubble_color_donthave");
498 HUD_Write_PanelCvar_q("_complainbubble_color_unavailable");
499 HUD_Write_PanelCvar_q("_ammo_color");
500 HUD_Write_PanelCvar_q("_ammo_alpha");
501 HUD_Write_PanelCvar_q("_aspect");
502 HUD_Write_PanelCvar_q("_timeout");
503 HUD_Write_PanelCvar_q("_timeout_effect");
506 HUD_Write_PanelCvar_q("_onlycurrent");
507 HUD_Write_PanelCvar_q("_iconalign");
508 HUD_Write_PanelCvar_q("_progressbar");
509 HUD_Write_PanelCvar_q("_progressbar_name");
510 HUD_Write_PanelCvar_q("_progressbar_xoffset");
511 HUD_Write_PanelCvar_q("_text");
513 case HUD_PANEL_POWERUPS:
514 HUD_Write_PanelCvar_q("_flip");
515 HUD_Write_PanelCvar_q("_iconalign");
516 HUD_Write_PanelCvar_q("_baralign");
517 HUD_Write_PanelCvar_q("_progressbar");
518 HUD_Write_PanelCvar_q("_progressbar_strength");
519 HUD_Write_PanelCvar_q("_progressbar_shield");
520 HUD_Write_PanelCvar_q("_text");
522 case HUD_PANEL_HEALTHARMOR:
523 HUD_Write_PanelCvar_q("_flip");
524 HUD_Write_PanelCvar_q("_iconalign");
525 HUD_Write_PanelCvar_q("_baralign");
526 HUD_Write_PanelCvar_q("_progressbar");
527 HUD_Write_PanelCvar_q("_progressbar_health");
528 HUD_Write_PanelCvar_q("_progressbar_armor");
529 HUD_Write_PanelCvar_q("_text");
531 case HUD_PANEL_NOTIFY:
532 HUD_Write_PanelCvar_q("_flip");
533 HUD_Write_PanelCvar_q("_fontsize");
534 HUD_Write_PanelCvar_q("_print");
536 case HUD_PANEL_RADAR:
537 HUD_Write_PanelCvar_q("_foreground_alpha");
540 HUD_Write_PanelCvar_q("_alreadyvoted_alpha");
542 case HUD_PANEL_PRESSEDKEYS:
543 HUD_Write_PanelCvar_q("_aspect");
545 case HUD_PANEL_INFOMESSAGES:
546 HUD_Write_PanelCvar_q("_flip");
551 HUD_Write("menu_sync\n"); // force the menu to reread the cvars, so that the dialogs are updated
553 print(sprintf(_("^2Successfully exported to %s! (Note: It's saved in data/data/)\n"), filename));
557 print(sprintf(_("^1Couldn't write to %s\n"), filename));
560 const float hlBorderSize = 4;
561 const string hlBorder = "gfx/hud/default/border_highlighted";
562 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
563 void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
565 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
566 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);
567 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);
568 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);
569 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);
572 // draw the background/borders
573 #define HUD_Panel_DrawBg(alpha)\
575 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));\
576 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
578 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);\
579 } ENDS_WITH_CURLY_BRACE
581 void HUD_Panel_DrawProgressBar(vector pos, vector mySize, string pic, float vertical, float barflip, float x, vector color, float alpha, float drawflag)
589 pic = strcat(hud_skin_path, "/", pic, "_vertical");
590 if(precache_pic(pic) == "") {
591 pic = "gfx/hud/default/statusbar_vertical";
595 drawsetcliparea(pos_x, pos_y + mySize_y * (1 - x), mySize_x, mySize_y * x);
597 drawsetcliparea(pos_x, pos_y, mySize_x, mySize_y * x);
599 pic = strcat(hud_skin_path, "/", pic);
600 if(precache_pic(pic) == "") {
601 pic = "gfx/hud/default/statusbar";
605 drawsetcliparea(pos_x + mySize_x * (1 - x), pos_y, mySize_x * x, mySize_y);
607 drawsetcliparea(pos_x, pos_y, mySize_x * x, mySize_y);
610 drawpic(pos, pic, mySize, color, alpha, drawflag);
614 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
620 pic = strcat(hud_skin_path, "/num_leading");
621 if(precache_pic(pic) == "") {
622 pic = "gfx/hud/default/num_leading";
625 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
626 if(mySize_x/mySize_y > 2)
627 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);
628 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);
631 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
632 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
641 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
642 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
644 for (i = 0; i < HUD_PANEL_NUM; ++i) {
645 if(i == highlightedPanel || !panel_enabled)
648 HUD_Panel_UpdatePosSizeForId(i);
650 panel_pos -= '1 1 0' * panel_bg_border;
651 panel_size += '2 2 0' * panel_bg_border;
653 if(myPos_y + mySize_y < panel_pos_y)
655 if(myPos_y > panel_pos_y + panel_size_y)
658 if(myPos_x + mySize_x < panel_pos_x)
660 if(myPos_x > panel_pos_x + panel_size_x)
663 // OK, there IS a collision.
665 myCenter_x = myPos_x + 0.5 * mySize_x;
666 myCenter_y = myPos_y + 0.5 * mySize_y;
668 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
669 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
671 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
673 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
674 myTarget_x = panel_pos_x - mySize_x;
675 else // push it upwards
676 myTarget_y = panel_pos_y - mySize_y;
678 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
680 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
681 myTarget_x = panel_pos_x + panel_size_x;
682 else // push it upwards
683 myTarget_y = panel_pos_y - mySize_y;
685 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
687 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
688 myTarget_x = panel_pos_x - mySize_x;
689 else // push it downwards
690 myTarget_y = panel_pos_y + panel_size_y;
692 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
694 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
695 myTarget_x = panel_pos_x + panel_size_x;
696 else // push it downwards
697 myTarget_y = panel_pos_y + panel_size_y;
699 //if(cvar("hud_configure_checkcollisions_debug"))
700 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
706 void HUD_Panel_SetPos(vector pos)
708 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
712 //if(cvar("hud_configure_checkcollisions_debug"))
713 //drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
715 if(autocvar_hud_configure_grid)
717 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;
718 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;
721 if(hud_configure_checkcollisions)
722 pos = HUD_Panel_CheckMove(pos, mySize);
724 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
725 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
728 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
730 HUD_Panel_GetName(highlightedPanel);
731 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
734 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
735 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
740 float dist_x, dist_y;
742 ratio = mySize_x/mySize_y;
744 for (i = 0; i < HUD_PANEL_NUM; ++i) {
745 if(i == highlightedPanel || !panel_enabled)
748 HUD_Panel_UpdatePosSizeForId(i);
750 panel_pos -= '1 1 0' * panel_bg_border;
751 panel_size += '2 2 0' * panel_bg_border;
753 targEndPos = panel_pos + panel_size;
755 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
756 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
759 if (resizeCorner == 1)
761 // check if this panel is on our way
762 if (resizeorigin_x <= panel_pos_x)
764 if (resizeorigin_y <= panel_pos_y)
766 if (targEndPos_x <= resizeorigin_x - mySize_x)
768 if (targEndPos_y <= resizeorigin_y - mySize_y)
771 // there is a collision:
772 // detect which side of the panel we are facing is actually limiting the resizing
773 // (which side the resize direction finds for first) and reduce the size up to there
775 // dist is the distance between resizeorigin and the "analogous" point of the panel
776 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
777 dist_x = resizeorigin_x - targEndPos_x;
778 dist_y = resizeorigin_y - targEndPos_y;
779 if (dist_y <= 0 || dist_x / dist_y > ratio)
780 mySize_x = min(mySize_x, dist_x);
782 mySize_y = min(mySize_y, dist_y);
784 else if (resizeCorner == 2)
786 if (resizeorigin_x >= targEndPos_x)
788 if (resizeorigin_y <= panel_pos_y)
790 if (panel_pos_x >= resizeorigin_x + mySize_x)
792 if (targEndPos_y <= resizeorigin_y - mySize_y)
795 dist_x = panel_pos_x - resizeorigin_x;
796 dist_y = resizeorigin_y - targEndPos_y;
797 if (dist_y <= 0 || dist_x / dist_y > ratio)
798 mySize_x = min(mySize_x, dist_x);
800 mySize_y = min(mySize_y, dist_y);
802 else if (resizeCorner == 3)
804 if (resizeorigin_x <= panel_pos_x)
806 if (resizeorigin_y >= targEndPos_y)
808 if (targEndPos_x <= resizeorigin_x - mySize_x)
810 if (panel_pos_y >= resizeorigin_y + mySize_y)
813 dist_x = resizeorigin_x - targEndPos_x;
814 dist_y = panel_pos_y - resizeorigin_y;
815 if (dist_y <= 0 || dist_x / dist_y > ratio)
816 mySize_x = min(mySize_x, dist_x);
818 mySize_y = min(mySize_y, dist_y);
820 else if (resizeCorner == 4)
822 if (resizeorigin_x >= targEndPos_x)
824 if (resizeorigin_y >= targEndPos_y)
826 if (panel_pos_x >= resizeorigin_x + mySize_x)
828 if (panel_pos_y >= resizeorigin_y + mySize_y)
831 dist_x = panel_pos_x - resizeorigin_x;
832 dist_y = panel_pos_y - resizeorigin_y;
833 if (dist_y <= 0 || dist_x / dist_y > ratio)
834 mySize_x = min(mySize_x, dist_x);
836 mySize_y = min(mySize_y, dist_y);
838 //if(cvar("hud_configure_checkcollisions_debug"))
839 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
845 void HUD_Panel_SetPosSize(vector mySize)
847 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
849 resizeorigin = panel_click_resizeorigin;
852 // minimum panel size cap
853 mySize_x = max(0.025 * vid_conwidth, mySize_x);
854 mySize_y = max(0.025 * vid_conheight, mySize_y);
856 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.
858 mySize_x = max(17 * autocvar_con_chatsize, mySize_x);
859 mySize_y = max(2 * autocvar_con_chatsize + 2 * panel_bg_padding, mySize_y);
862 // collision testing|
863 // -----------------+
865 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
866 if(resizeCorner == 1) {
867 myPos_x = resizeorigin_x - mySize_x;
868 myPos_y = resizeorigin_y - mySize_y;
869 } else if(resizeCorner == 2) {
870 myPos_x = resizeorigin_x;
871 myPos_y = resizeorigin_y - mySize_y;
872 } else if(resizeCorner == 3) {
873 myPos_x = resizeorigin_x - mySize_x;
874 myPos_y = resizeorigin_y;
875 } else { // resizeCorner == 4
876 myPos_x = resizeorigin_x;
877 myPos_y = resizeorigin_y;
880 // left/top screen edges
882 mySize_x = mySize_x + myPos_x;
884 mySize_y = mySize_y + myPos_y;
886 // bottom/right screen edges
887 if(myPos_x + mySize_x > vid_conwidth)
888 mySize_x = vid_conwidth - myPos_x;
889 if(myPos_y + mySize_y > vid_conheight)
890 mySize_y = vid_conheight - myPos_y;
892 //if(cvar("hud_configure_checkcollisions_debug"))
893 //drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
895 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
896 if(autocvar_hud_configure_grid)
898 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;
899 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;
902 if(hud_configure_checkcollisions)
903 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
905 // 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)
906 mySize_x = max(0.025 * vid_conwidth, mySize_x);
907 mySize_y = max(0.025 * vid_conheight, mySize_y);
909 // do another pos check, as size might have changed by now
910 if(resizeCorner == 1) {
911 myPos_x = resizeorigin_x - mySize_x;
912 myPos_y = resizeorigin_y - mySize_y;
913 } else if(resizeCorner == 2) {
914 myPos_x = resizeorigin_x;
915 myPos_y = resizeorigin_y - mySize_y;
916 } else if(resizeCorner == 3) {
917 myPos_x = resizeorigin_x - mySize_x;
918 myPos_y = resizeorigin_y;
919 } else { // resizeCorner == 4
920 myPos_x = resizeorigin_x;
921 myPos_y = resizeorigin_y;
924 //if(cvar("hud_configure_checkcollisions_debug"))
925 //drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
927 HUD_Panel_GetName(highlightedPanel);
929 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
930 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
932 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
933 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
937 float prevMouseClicked; // previous state
938 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
939 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
941 float pressed_key_time;
942 void HUD_Panel_Arrow_Action(float nPrimary)
944 if (highlightedPanel_prev == -1 || mouseClicked)
947 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
950 if(autocvar_hud_configure_grid)
952 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
954 if (hudShiftState & S_SHIFT)
955 step = bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
957 step = 2 * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
961 if (hudShiftState & S_SHIFT)
962 step = bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
964 step = 2 * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
969 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
970 step = vid_conheight;
973 if (hudShiftState & S_SHIFT)
974 step = (step / 256); // more precision
976 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
979 highlightedPanel = highlightedPanel_prev;
981 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
983 vector prev_pos, prev_size;
984 prev_pos = panel_pos;
985 prev_size = panel_size;
987 if (hudShiftState & S_ALT) // resize
989 highlightedAction = 1;
990 if(nPrimary == K_UPARROW)
992 else if(nPrimary == K_RIGHTARROW)
994 else if(nPrimary == K_LEFTARROW)
996 else // if(nPrimary == K_DOWNARROW)
999 // ctrl+arrow reduces the size, instead of increasing it
1000 // Note that ctrl disables collisions check too, but it's fine
1001 // since we don't collide with anything reducing the size
1002 if (hudShiftState & S_CTRL) {
1004 resizeCorner = 5 - resizeCorner;
1008 mySize = panel_size;
1009 panel_click_resizeorigin = panel_pos;
1010 if(resizeCorner == 1) {
1011 panel_click_resizeorigin += mySize;
1013 } else if(resizeCorner == 2) {
1014 panel_click_resizeorigin_y += mySize_y;
1016 } else if(resizeCorner == 3) {
1017 panel_click_resizeorigin_x += mySize_x;
1019 } else { // resizeCorner == 4
1022 HUD_Panel_SetPosSize(mySize);
1026 highlightedAction = 2;
1029 if(nPrimary == K_UPARROW)
1031 else if(nPrimary == K_DOWNARROW)
1033 else if(nPrimary == K_LEFTARROW)
1035 else // if(nPrimary == K_RIGHTARROW)
1038 HUD_Panel_SetPos(pos);
1041 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
1043 if (prev_pos != panel_pos || prev_size != panel_size)
1046 panel_pos_backup = prev_pos;
1047 panel_size_backup = prev_size;
1048 highlightedPanel_backup = highlightedPanel;
1052 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1056 if(!autocvar__hud_configure)
1059 // allow console bind to work
1062 con_keys = findkeysforcommand("toggleconsole");
1063 keys = tokenize(con_keys);
1065 float hit_con_bind, i;
1066 for (i = 0; i < keys; ++i)
1068 if(nPrimary == stof(argv(i)))
1072 if(bInputType == 0) {
1073 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1074 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1075 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1077 else if(bInputType == 1) {
1078 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1079 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1080 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1083 if(nPrimary == K_MOUSE1)
1085 if(bInputType == 0) { // key pressed
1089 else if(bInputType == 1) {// key released
1094 else if(nPrimary == K_ESCAPE)
1096 if (bInputType == 1)
1099 menu_enabled_time = time;
1100 localcmd("menu_showhudexit\n");
1102 else if(hudShiftState & S_CTRL)
1107 if(nPrimary == K_SPACE) // enable/disable highlighted panel or dock
1109 if (bInputType == 1)
1112 if (highlightedPanel_prev != -1)
1113 cvar_set(strcat("hud_panel_", panel_name), ftos(!(panel_enabled)));
1115 cvar_set(strcat("hud_dock"), (autocvar_hud_dock == "") ? "dock" : "");
1117 if(nPrimary == 'c') // copy highlighted panel size
1119 if (bInputType == 1)
1122 if (highlightedPanel_prev != -1)
1124 panel_size_copied = panel_size;
1125 highlightedPanel_copied = highlightedPanel_prev;
1128 else if(nPrimary == 'v') // past copied size on the highlighted panel
1130 if (bInputType == 1)
1133 if (highlightedPanel_copied == -1 || highlightedPanel_prev == -1)
1136 HUD_Panel_UpdatePosSizeForId(highlightedPanel_prev);
1138 // reduce size if it'd go beyond screen boundaries
1139 vector tmp_size = panel_size_copied;
1140 if (panel_pos_x + panel_size_copied_x > vid_conwidth)
1141 tmp_size_x = vid_conwidth - panel_pos_x;
1142 if (panel_pos_y + panel_size_copied_y > vid_conheight)
1143 tmp_size_y = vid_conheight - panel_pos_y;
1145 if (panel_size == tmp_size)
1149 panel_pos_backup = panel_pos;
1150 panel_size_backup = panel_size;
1151 highlightedPanel_backup = highlightedPanel_prev;
1153 s = strcat(ftos(tmp_size_x/vid_conwidth), " ", ftos(tmp_size_y/vid_conheight));
1154 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
1156 else if(nPrimary == 'z') // undo last action
1158 if (bInputType == 1)
1160 //restore previous values
1161 if (highlightedPanel_backup != -1)
1163 HUD_Panel_GetName(highlightedPanel_backup);
1164 s = strcat(ftos(panel_pos_backup_x/vid_conwidth), " ", ftos(panel_pos_backup_y/vid_conheight));
1165 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
1166 s = strcat(ftos(panel_size_backup_x/vid_conwidth), " ", ftos(panel_size_backup_y/vid_conheight));
1167 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
1168 highlightedPanel_backup = -1;
1172 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1174 if (bInputType == 1)
1176 pressed_key_time = 0;
1179 else if (pressed_key_time == 0)
1180 pressed_key_time = time;
1182 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1184 else if(hit_con_bind)
1187 return true; // Suppress ALL other input
1190 float HUD_Panel_HighlightCheck()
1196 while(j <= HUD_PANEL_NUM)
1201 HUD_Panel_UpdatePosSizeForId(i);
1203 panelPos = panel_pos;
1204 panelSize = panel_size;
1205 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1208 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1212 // resize from topleft border
1213 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)
1217 // resize from topright border
1218 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)
1222 // resize from bottomleft border
1223 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)
1227 // resize from bottomright border
1228 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)
1236 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1237 void HUD_Panel_FirstInDrawQ(float id)
1240 var float place = -1;
1241 // find out where in the array our current id is, save into place
1242 for(i = 0; i < HUD_PANEL_NUM; ++i)
1244 if(panel_order[i] == id)
1250 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1252 place = HUD_PANEL_NUM - 1;
1254 // move all ids up by one step in the array until "place"
1255 for(i = place; i > 0; --i)
1257 panel_order[i] = panel_order[i-1];
1259 // now save the new top id
1260 panel_order[0] = id;
1262 // let's save them into the cvar by some strcat trickery
1264 for(i = 0; i < HUD_PANEL_NUM; ++i)
1266 s = strcat(s, ftos(panel_order[i]), " ");
1268 cvar_set("_hud_panelorder", s);
1269 if(hud_panelorder_prev)
1270 strunzone(hud_panelorder_prev);
1271 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1274 void HUD_Panel_Highlight()
1280 while(j <= HUD_PANEL_NUM)
1285 HUD_Panel_UpdatePosSizeForId(i);
1287 panelPos = panel_pos;
1288 panelSize = panel_size;
1289 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1292 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1294 highlightedPanel = i;
1295 HUD_Panel_FirstInDrawQ(i);
1296 highlightedAction = 1;
1297 panel_click_distance = mousepos - panelPos;
1300 // resize from topleft border
1301 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)
1303 highlightedPanel = i;
1304 HUD_Panel_FirstInDrawQ(i);
1305 highlightedAction = 2;
1307 panel_click_distance = mousepos - panelPos;
1308 panel_click_resizeorigin = panelPos + panelSize;
1311 // resize from topright border
1312 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)
1314 highlightedPanel = i;
1315 HUD_Panel_FirstInDrawQ(i);
1316 highlightedAction = 2;
1318 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1319 panel_click_distance_y = mousepos_y - panelPos_y;
1320 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1323 // resize from bottomleft border
1324 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)
1326 highlightedPanel = i;
1327 HUD_Panel_FirstInDrawQ(i);
1328 highlightedAction = 2;
1330 panel_click_distance_x = mousepos_x - panelPos_x;
1331 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1332 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1335 // resize from bottomright border
1336 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)
1338 highlightedPanel = i;
1339 HUD_Panel_FirstInDrawQ(i);
1340 highlightedAction = 2;
1342 panel_click_distance = panelSize - mousepos + panelPos;
1343 panel_click_resizeorigin = panelPos;
1348 highlightedPanel_prev = -1;
1353 float highlightcheck;
1354 vector prev_pos, prev_size;
1355 void HUD_Panel_Mouse()
1357 // 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
1358 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1362 print("menu_enabled: ", ftos(menu_enabled), "\n");
1363 print("Highlighted: ", ftos(highlightedPanel), "\n");
1364 print("Menu alpha: ", ftos(autocvar__menu_alpha), "\n");
1367 // instantly hide the editor cursor if we open the HUDExit dialog
1368 // as hud_fade_alpha doesn't decrease to 0 in this case
1369 // TODO: find a way to fade the cursor out even in this case
1370 if(menu_enabled == 1 || (menu_enabled == 2 && !hud_fade_alpha))
1373 if(mouseClicked == 0 && menu_enabled != 2 && highlightedPanel >= 0) { // don't reset these variables in menu_enabled mode 2!
1374 highlightedPanel = -1;
1375 highlightedAction = 0;
1377 if(highlightedPanel != -1)
1378 highlightedPanel_prev = highlightedPanel;
1380 mousepos = mousepos + getmousepos() * autocvar_menu_mouse_speed;
1382 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1383 mousepos_y = bound(0, mousepos_y, vid_conheight);
1387 if(prevMouseClicked == 0)
1389 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1390 // and calls HUD_Panel_UpdatePosSizeForId() for the highlighted panel
1391 prev_pos = panel_pos;
1392 prev_size = panel_size;
1395 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
1397 if (prev_pos != panel_pos || prev_size != panel_size)
1399 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1401 panel_pos_backup = prev_pos;
1402 panel_size_backup = prev_size;
1403 highlightedPanel_backup = highlightedPanel;
1406 // in case the clicked panel is inside another panel and we aren't
1407 // moving it, avoid the immediate "fix" of its position/size
1408 // (often unwanted and hateful) by disabling collisions check
1409 hud_configure_checkcollisions = false;
1411 if(highlightedAction == 1)
1412 HUD_Panel_SetPos(mousepos - panel_click_distance);
1413 else if(highlightedAction == 2)
1416 if(resizeCorner == 1) {
1417 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1418 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1419 } else if(resizeCorner == 2) {
1420 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1421 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1422 } else if(resizeCorner == 3) {
1423 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1424 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1425 } else { // resizeCorner == 4
1426 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1427 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1429 HUD_Panel_SetPosSize(mySize);
1432 // doubleclick check
1433 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1435 mouseClicked = 0; // to prevent spam, I guess.
1437 menu_enabled_time = time;
1438 HUD_Panel_GetName(highlightedPanel);
1439 localcmd("menu_showhudoptions ", panel_name, "\n");
1442 if(prevMouseClicked == 0)
1444 prevMouseClickedTime = time;
1445 prevMouseClickedPos = mousepos;
1450 highlightcheck = HUD_Panel_HighlightCheck();
1452 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1454 cursorsize = '32 32 0';
1456 if(highlightcheck == 0)
1457 drawpic(mousepos, strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1458 else if(highlightcheck == 1)
1459 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_move.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1460 else if(highlightcheck == 2)
1461 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_resize.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1463 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_resize2.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1465 prevMouseClicked = mouseClicked;
1468 // Weapon icons (#0)
1470 float weaponspace[10];
1471 #define HUD_Weapons_Clear()\
1473 for(idx = 0; idx < 10; ++idx)\
1474 weaponspace[idx] = 0
1476 entity weaponorder[WEP_MAXCOUNT];
1477 void weaponorder_swap(float i, float j, entity pass)
1481 weaponorder[i] = weaponorder[j];
1485 string weaponorder_cmp_str;
1486 float weaponorder_cmp(float i, float j, entity pass)
1489 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1490 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1491 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)
1494 float GetAmmoStat(float i)
1498 case 0: return STAT_SHELLS;
1499 case 1: return STAT_NAILS;
1500 case 2: return STAT_ROCKETS;
1501 case 3: return STAT_CELLS;
1502 case 4: return STAT_FUEL;
1507 float GetAmmoTypeForWep(float i)
1511 case WEP_SHOTGUN: return 0;
1512 case WEP_UZI: return 1;
1513 case WEP_GRENADE_LAUNCHER: return 2;
1514 case WEP_MINE_LAYER: return 2;
1515 case WEP_ELECTRO: return 3;
1516 case WEP_CRYLINK: return 3;
1517 case WEP_HLAC: return 3;
1518 case WEP_MINSTANEX: return 3;
1519 case WEP_NEX: return 3;
1520 case WEP_SNIPERRIFLE: return 1;
1521 case WEP_HAGAR: return 2;
1522 case WEP_ROCKET_LAUNCHER: return 2;
1523 case WEP_SEEKER: return 2;
1524 case WEP_FIREBALL: return 4;
1525 case WEP_HOOK: return 3;
1530 void HUD_Weapons(void)
1533 float center_x, center_y;
1535 if(!autocvar_hud_panel_weapons && !autocvar__hud_configure)
1538 float timeout = autocvar_hud_panel_weapons_timeout;
1539 float timeout_effect_length, timein_effect_length;
1540 if (autocvar_hud_panel_weapons_timeout_effect == 0)
1542 timeout_effect_length = 0;
1543 timein_effect_length = 0;
1547 timeout_effect_length = 0.75;
1548 timein_effect_length = 0.375;
1551 if (timeout && time >= weapontime + timeout + timeout_effect_length && !autocvar__hud_configure)
1553 weaponprevtime = time;
1557 active_panel = HUD_PANEL_WEAPONS;
1558 HUD_Panel_UpdateCvars(weapons);
1560 if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
1562 f = (time - (weapontime + timeout)) / timeout_effect_length;
1563 if (autocvar_hud_panel_weapons_timeout_effect)
1565 panel_bg_alpha *= (1 - f);
1566 panel_fg_alpha *= (1 - f);
1568 if (autocvar_hud_panel_weapons_timeout_effect == 1)
1570 f *= f; // for a cooler movement
1571 center_x = panel_pos_x + panel_size_x/2;
1572 center_y = panel_pos_y + panel_size_y/2;
1573 screen_ar = vid_conwidth/vid_conheight;
1574 if (center_x/center_y < screen_ar) //bottom left
1576 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
1577 panel_pos_y += f * (vid_conheight - panel_pos_y);
1579 panel_pos_x -= f * (panel_pos_x + panel_size_x);
1583 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
1584 panel_pos_x += f * (vid_conwidth - panel_pos_x);
1586 panel_pos_y -= f * (panel_pos_y + panel_size_y);
1589 weaponprevtime = time - (1 - f) * timein_effect_length;
1591 else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure)
1593 f = (time - weaponprevtime) / timein_effect_length;
1594 if (autocvar_hud_panel_weapons_timeout_effect)
1596 panel_bg_alpha *= (f);
1597 panel_fg_alpha *= (f);
1599 if (autocvar_hud_panel_weapons_timeout_effect == 1)
1601 f *= f; // for a cooler movement
1603 center_x = panel_pos_x + panel_size_x/2;
1604 center_y = panel_pos_y + panel_size_y/2;
1605 screen_ar = vid_conwidth/vid_conheight;
1606 if (center_x/center_y < screen_ar) //bottom left
1608 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
1609 panel_pos_y += f * (vid_conheight - panel_pos_y);
1611 panel_pos_x -= f * (panel_pos_x + panel_size_x);
1615 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
1616 panel_pos_x += f * (vid_conwidth - panel_pos_x);
1618 panel_pos_y -= f * (panel_pos_y + panel_size_y);
1623 float i, weapid, wpnalpha, weapon_cnt;
1625 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1627 self = get_weaponinfo(i);
1628 if(self.impulse >= 0)
1632 // TODO make this configurable
1633 if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
1635 if(weaponorder_bypriority)
1636 strunzone(weaponorder_bypriority);
1637 if(weaponorder_byimpulse)
1638 strunzone(weaponorder_byimpulse);
1640 weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
1641 weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
1642 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1645 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1647 self = get_weaponinfo(i);
1648 if(self.impulse >= 0)
1650 weaponorder[weapon_cnt] = self;
1654 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1656 weaponorder_cmp_str = string_null;
1659 HUD_Panel_DrawBg(1);
1660 if(panel_bg_padding)
1662 panel_pos += '1 1 0' * panel_bg_padding;
1663 panel_size -= '2 2 0' * panel_bg_padding;
1666 if(autocvar_hud_panel_weapons_fade)
1668 wpnalpha = 3.2 - 2 * (time - weapontime);
1669 wpnalpha = bound(0.7, wpnalpha, 1) * panel_fg_alpha;
1672 wpnalpha = panel_fg_alpha;
1674 HUD_Weapons_Clear();
1676 float rows, columns;
1677 float aspect = autocvar_hud_panel_weapons_aspect;
1678 rows = panel_size_y/panel_size_x;
1679 rows = bound(1, floor((sqrt(4 * aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1681 columns = ceil(WEP_COUNT/rows);
1684 float a, type, fullammo;
1686 when = autocvar_hud_panel_weapons_complainbubble_time;
1688 fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
1694 float fullammo_shells, fullammo_nails, fullammo_rockets, fullammo_cells, fullammo_fuel;
1697 wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
1698 float barsize_x, barsize_y, baroffset_x, baroffset_y;
1699 float show_ammo = autocvar_hud_panel_weapons_ammo;
1702 fullammo_shells = autocvar_hud_panel_weapons_ammo_full_shells;
1703 fullammo_nails = autocvar_hud_panel_weapons_ammo_full_nails;
1704 fullammo_rockets = autocvar_hud_panel_weapons_ammo_full_rockets;
1705 fullammo_cells = autocvar_hud_panel_weapons_ammo_full_cells;
1706 fullammo_fuel = autocvar_hud_panel_weapons_ammo_full_fuel;
1707 ammo_color = stov(autocvar_hud_panel_weapons_ammo_color);
1708 ammo_alpha = panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha;
1711 if(wpnsize_x/wpnsize_y > aspect)
1713 barsize_x = aspect * wpnsize_y;
1714 barsize_y = wpnsize_y;
1715 baroffset_x = (wpnsize_x - barsize_x) / 2;
1719 barsize_y = 1/aspect * wpnsize_x;
1720 barsize_x = wpnsize_x;
1721 baroffset_y = (wpnsize_y - barsize_y) / 2;
1725 float show_accuracy;
1727 if(autocvar_hud_panel_weapons_accuracy && acc_levels)
1729 show_accuracy = true;
1730 if (acc_col_x[0] == -1)
1731 for (i = 0; i < acc_levels; ++i)
1732 acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
1735 float weapons_st = getstati(STAT_WEAPONS);
1736 float label = autocvar_hud_panel_weapons_label;
1738 for(i = 0; i < weapon_cnt; ++i)
1740 wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y;
1742 self = weaponorder[i];
1743 weapid = self.impulse;
1745 // draw background behind currently selected weapon
1746 if(self.weapon == activeweapon)
1747 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
1749 // draw the weapon accuracy
1752 weapon_stats = weapon_accuracy[self.weapon-WEP_FIRST];
1753 if(weapon_stats >= 0)
1755 // find the max level lower than weapon_stats
1758 while ( j && weapon_stats < acc_lev[j] )
1761 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
1763 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
1765 color = color + factor * (acc_col[j+1] - color);
1767 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1771 // draw the weapon icon
1772 if((weapid >= 0) && (weapons_st & self.weapons))
1774 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
1776 if(label == 1) // weapon number
1777 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1778 else if(label == 2) // bind
1779 drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1781 // draw ammo status bar
1782 if(show_ammo && self.weapon != WEP_TUBA && self.weapon != WEP_LASER && self.weapon != WEP_PORTO)
1785 type = GetAmmoTypeForWep(self.weapon);
1787 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
1792 case 0: fullammo = fullammo_shells; break;
1793 case 1: fullammo = fullammo_nails; break;
1794 case 2: fullammo = fullammo_rockets; break;
1795 case 3: fullammo = fullammo_cells; break;
1796 case 4: fullammo = fullammo_fuel; break;
1797 default: fullammo = 60;
1801 wpnpos_x + baroffset_x,
1802 wpnpos_y + baroffset_y,
1803 barsize_x * bound(0, a/fullammo, 1),
1805 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, ammo_color, ammo_alpha, DRAWFLAG_NORMAL);
1806 drawresetcliparea();
1811 // draw a "ghost weapon icon" if you don't have the weapon
1814 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
1817 // draw the complain message
1818 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
1822 if(complain_weapon_time + when > time)
1825 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1829 if(complain_weapon_time + when > time)
1836 if(complain_weapon_type == 0) {
1837 s = _("Out of ammo");
1838 color = stov(autocvar_hud_panel_weapons_complainbubble_color_outofammo);
1840 else if(complain_weapon_type == 1) {
1841 s = _("Don't have");
1842 color = stov(autocvar_hud_panel_weapons_complainbubble_color_donthave);
1845 s = _("Unavailable");
1846 color = stov(autocvar_hud_panel_weapons_complainbubble_color_unavailable);
1848 float padding = autocvar_hud_panel_weapons_complainbubble_padding;
1849 drawpic_aspect_skin(wpnpos + '1 1 0' * padding, "weapon_complainbubble", wpnsize - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
1850 drawstring_aspect(wpnpos + '1 1 0' * padding, s, wpnsize - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
1866 float GetAmmoItemCode(float i)
1870 case 0: return IT_SHELLS;
1871 case 1: return IT_NAILS;
1872 case 2: return IT_ROCKETS;
1873 case 3: return IT_CELLS;
1874 case 4: return IT_FUEL;
1879 string GetAmmoPicture(float i)
1883 case 0: return "ammo_shells";
1884 case 1: return "ammo_bullets";
1885 case 2: return "ammo_rockets";
1886 case 3: return "ammo_cells";
1887 case 4: return "ammo_fuel";
1892 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1895 if(autocvar__hud_configure)
1897 currently_selected = (itemcode == 2); //rockets always selected
1901 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1910 if(currently_selected)
1915 vector picpos, numpos;
1916 if(autocvar_hud_panel_ammo_iconalign)
1919 picpos = myPos + eX * 2 * mySize_y;
1923 numpos = myPos + eX * mySize_y;
1927 if (currently_selected)
1928 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1930 if(a > 0 && autocvar_hud_panel_ammo_progressbar)
1931 HUD_Panel_DrawProgressBar(myPos + eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize_x, mySize - eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize_x, autocvar_hud_panel_ammo_progressbar_name, 0, 0, min(1, a/autocvar_hud_panel_ammo_maxammo), color, autocvar_hud_progressbar_alpha * panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1933 if(autocvar_hud_panel_ammo_text)
1936 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1937 else // "ghost" ammo count
1938 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1941 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1942 else // "ghost" ammo icon
1943 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1948 if(!autocvar_hud_panel_ammo && !autocvar__hud_configure)
1951 active_panel = HUD_PANEL_AMMO;
1952 HUD_Panel_UpdateCvars(ammo);
1955 mySize = panel_size;
1957 HUD_Panel_DrawBg(1);
1958 if(panel_bg_padding)
1960 pos += '1 1 0' * panel_bg_padding;
1961 mySize -= '2 2 0' * panel_bg_padding;
1964 float rows, columns, row, column;
1966 if (autocvar_hud_panel_ammo_onlycurrent)
1970 rows = mySize_y/mySize_x;
1971 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1972 // ^^^ ammo item aspect goes here
1974 columns = ceil(AMMO_COUNT/rows);
1976 ammo_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
1981 if(ammo_size_x/ammo_size_y > 3)
1983 newSize = 3 * ammo_size_y;
1984 offset_x = ammo_size_x - newSize;
1985 pos_x += offset_x/2;
1986 ammo_size_x = newSize;
1990 newSize = 1/3 * ammo_size_x;
1991 offset_y = ammo_size_y - newSize;
1992 pos_y += offset_y/2;
1993 ammo_size_y = newSize;
1996 float i, stat_items, currently_selected;
1997 if (autocvar_hud_panel_ammo_onlycurrent)
1999 if(autocvar__hud_configure)
2001 DrawAmmoItem(pos, ammo_size, 2, true); //show rockets
2004 stat_items = getstati(STAT_ITEMS);
2005 for (i = 0; i < AMMO_COUNT; ++i) {
2006 currently_selected = stat_items & GetAmmoItemCode(i);
2007 if (currently_selected)
2009 DrawAmmoItem(pos, ammo_size, i, true);
2013 return; // nothing to display
2016 stat_items = getstati(STAT_ITEMS);
2017 for (i = 0; i < AMMO_COUNT; ++i) {
2018 currently_selected = stat_items & GetAmmoItemCode(i);
2019 DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected);
2024 column = column + 1;
2029 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float alpha)
2032 float newSize_x, newSize_y;
2033 if(mySize_x/mySize_y > 3)
2035 newSize_x = 3 * mySize_y;
2036 newSize_y = mySize_y;
2038 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
2043 newSize_y = 1/3 * mySize_x;
2044 newSize_x = mySize_x;
2046 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
2050 vector picpos, numpos;
2053 if(iconalign == 1 || iconalign == 3) // right align
2056 picpos = newPos + eX * 2 * newSize_y;
2060 numpos = newPos + eX * newSize_y;
2066 if(iconalign == 0 || iconalign == 3) // left align
2068 numpos = newPos + eX * newSize_y;
2074 picpos = newPos + eX * 2 * newSize_y;
2078 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
2079 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
2082 void DrawNumIcon_expanding(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float fadelerp)
2085 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
2087 DrawNumIcon(iconalign, myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, left, color, (1 - fadelerp));
2092 void HUD_Powerups(void) {
2093 if(!autocvar_hud_panel_powerups && !autocvar__hud_configure)
2096 if(!autocvar__hud_configure)
2098 if not(getstati(STAT_ITEMS) & (IT_STRENGTH | IT_INVINCIBLE))
2101 if (getstati(STAT_HEALTH) <= 0)
2105 active_panel = HUD_PANEL_POWERUPS;
2106 HUD_Panel_UpdateCvars(powerups);
2109 mySize = panel_size;
2111 float strength_time, shield_time;
2112 if(autocvar__hud_configure)
2119 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
2120 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
2123 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
2124 if(panel_bg_padding)
2126 pos += '1 1 0' * panel_bg_padding;
2127 mySize -= '2 2 0' * panel_bg_padding;
2130 vector barpos, barsize;
2134 string leftname, rightname;
2135 string leftprogressname, rightprogressname;
2136 float leftcnt, rightcnt;
2137 float leftexact, rightexact;
2138 float flip = autocvar_hud_panel_powerups_flip;
2140 leftname = "strength";
2141 leftprogressname = autocvar_hud_panel_powerups_progressbar_strength;
2142 leftcnt = ceil(strength_time);
2143 leftexact = strength_time;
2145 rightname = "shield";
2146 rightprogressname = autocvar_hud_panel_powerups_progressbar_shield;
2147 rightcnt = ceil(shield_time);
2148 rightexact = shield_time;
2150 leftname = "shield";
2151 leftprogressname = autocvar_hud_panel_powerups_progressbar_shield;
2152 leftcnt = ceil(shield_time);
2153 leftexact = shield_time;
2155 rightname = "strength";
2156 rightprogressname = autocvar_hud_panel_powerups_progressbar_strength;
2157 rightcnt = ceil(strength_time);
2158 rightexact = strength_time;
2161 float baralign = autocvar_hud_panel_powerups_baralign;
2163 float iconalign = autocvar_hud_panel_powerups_iconalign;
2164 float progressbar = autocvar_hud_panel_powerups_progressbar;
2165 if (mySize_x/mySize_y > 4)
2167 barsize = eX * 0.5 * mySize_x + eY * mySize_y;
2170 if(baralign == 1 || baralign == 3) { // right align
2171 barpos = pos + eX * 0.5 * mySize_x;
2173 } else { // left align
2180 HUD_Panel_GetProgressBarColorForString(leftname);
2181 HUD_Panel_DrawProgressBar(barpos, barsize, leftprogressname, 0, barflip, min(1, leftcnt/30), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2183 if(autocvar_hud_panel_powerups_text)
2186 DrawNumIcon(iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
2188 DrawNumIcon_expanding(iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
2194 if(baralign == 0 || baralign == 3) { // left align
2197 } else { // right align
2198 barpos = pos + eX * 0.5 * mySize_x;
2204 HUD_Panel_GetProgressBarColorForString(rightname);
2205 HUD_Panel_DrawProgressBar(barpos, barsize, rightprogressname, 0, barflip, min(1, rightcnt/30), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2207 if(autocvar_hud_panel_powerups_text)
2210 DrawNumIcon(iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
2212 DrawNumIcon_expanding(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));
2216 else if (mySize_x/mySize_y > 1.5)
2218 barsize = eX * mySize_x + eY * 0.5 * mySize_y;
2222 if(baralign == 1 || baralign == 3) { // right/down align
2224 } else { // left/up align
2230 HUD_Panel_GetProgressBarColorForString(leftname);
2231 HUD_Panel_DrawProgressBar(barpos, barsize, leftprogressname, 0, barflip, min(1, leftcnt/30), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2233 if(autocvar_hud_panel_powerups_text)
2236 DrawNumIcon(iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
2238 DrawNumIcon_expanding(iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
2244 barpos = pos + eY * 0.5 * mySize_y;
2245 if(baralign == 0 || baralign == 3) { // left align
2247 } else { // right align
2253 HUD_Panel_GetProgressBarColorForString(rightname);
2254 HUD_Panel_DrawProgressBar(barpos, barsize, rightprogressname, 0, barflip, min(1, rightcnt/30), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2256 if(autocvar_hud_panel_powerups_text)
2259 DrawNumIcon(iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
2261 DrawNumIcon_expanding(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));
2267 barsize = eX * 0.5 * mySize_x + eY * mySize_y;
2271 if(baralign == 1 || baralign == 3) { // down align
2273 } else { // up align
2277 if(iconalign == 1 || iconalign == 3) { // down align
2278 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2279 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2280 } else { // up align
2281 picpos = pos + eX * 0.05 * mySize_x;
2282 numpos = pos + eY * 0.4 * mySize_x;
2287 HUD_Panel_GetProgressBarColorForString(leftname);
2288 HUD_Panel_DrawProgressBar(barpos, barsize, leftprogressname, 1, barflip, min(1, leftcnt/30), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2290 if(autocvar_hud_panel_powerups_text)
2293 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));
2295 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2296 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2302 barpos = pos + eX * 0.5 * mySize_x;
2303 if(baralign == 0 || baralign == 3) { // down align
2305 } else { // up align
2309 if(iconalign == 0 || iconalign == 3) { // up align
2310 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2311 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2312 } else { // down align
2313 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2314 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2319 HUD_Panel_GetProgressBarColorForString(rightname);
2320 HUD_Panel_DrawProgressBar(barpos, barsize, rightprogressname, 1, barflip, min(1, rightcnt/30), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2322 if(autocvar_hud_panel_powerups_text)
2325 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));
2327 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2328 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2334 // Health/armor (#3)
2336 void HUD_HealthArmor(void)
2338 if(!autocvar_hud_panel_healtharmor && !autocvar__hud_configure)
2341 active_panel = HUD_PANEL_HEALTHARMOR;
2342 HUD_Panel_UpdateCvars(healtharmor);
2345 mySize = panel_size;
2347 HUD_Panel_DrawBg(1);
2348 if(panel_bg_padding)
2350 pos += '1 1 0' * panel_bg_padding;
2351 mySize -= '2 2 0' * panel_bg_padding;
2354 float armor, health, fuel;
2355 armor = getstati(STAT_ARMOR);
2356 health = getstati(STAT_HEALTH);
2357 fuel = getstati(STAT_FUEL);
2359 if(autocvar__hud_configure)
2369 vector barpos, barsize;
2373 float baralign = autocvar_hud_panel_healtharmor_baralign;
2374 float iconalign = autocvar_hud_panel_healtharmor_iconalign;
2375 float progressbar = autocvar_hud_panel_healtharmor_progressbar;
2377 float maxhealth = autocvar_hud_panel_healtharmor_maxhealth;
2378 float maxarmor = autocvar_hud_panel_healtharmor_maxarmor;
2379 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
2382 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2387 float maxtotal = maxhealth + maxarmor;
2393 if(v_z) // NOT fully armored
2395 biggercount = "health";
2398 HUD_Panel_GetProgressBarColor(health);
2399 HUD_Panel_DrawProgressBar(barpos, barsize, autocvar_hud_panel_healtharmor_progressbar_health, 0, mod(baralign, 2), x/maxtotal, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2402 if(autocvar_hud_panel_healtharmor_text)
2403 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);
2407 biggercount = "armor";
2410 HUD_Panel_GetProgressBarColor(armor);
2411 HUD_Panel_DrawProgressBar(barpos, barsize, autocvar_hud_panel_healtharmor_progressbar_armor, 0, mod(baralign, 2), x/maxtotal, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2414 if(autocvar_hud_panel_healtharmor_text)
2415 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);
2417 if(autocvar_hud_panel_healtharmor_text)
2418 DrawNumIcon(iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, maxtotal), 1);
2424 barsize = eX * mySize_x + eY * 0.2 * mySize_y;
2425 HUD_Panel_GetProgressBarColor(fuel);
2426 HUD_Panel_DrawProgressBar(barpos, barsize, "progressbar", 0, mod(baralign, 2), min(1, fuel/100), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2431 string leftname, rightname;
2432 string leftprogressname, rightprogressname;
2433 float leftcnt, rightcnt;
2434 float leftmax, rightmax;
2435 float leftactive, rightactive;
2436 float leftalpha, rightalpha;
2437 float flip = autocvar_hud_panel_healtharmor_flip;
2439 if (flip) { // old style layout with armor left/top of health
2441 leftprogressname = autocvar_hud_panel_healtharmor_progressbar_armor;
2445 leftalpha = min((armor+10)/55, 1);
2448 rightname = "health";
2449 rightprogressname = autocvar_hud_panel_healtharmor_progressbar_health;
2453 rightmax = maxhealth;
2455 leftname = "health";
2456 leftprogressname = autocvar_hud_panel_healtharmor_progressbar_health;
2460 leftmax = maxhealth;
2462 rightname = "armor";
2463 rightprogressname = autocvar_hud_panel_healtharmor_progressbar_armor;
2467 rightalpha = min((armor+10)/55, 1);
2468 rightmax = maxarmor;
2471 if (mySize_x/mySize_y > 4)
2473 barsize = eX * 0.5 * mySize_x + eY * mySize_y;
2477 if(baralign == 1 || baralign == 3) { // right align
2479 } else { // left align
2485 HUD_Panel_GetProgressBarColorForString(leftname);
2486 HUD_Panel_DrawProgressBar(barpos, barsize, leftprogressname, 0, barflip, min(1, leftcnt/leftmax), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2488 if(autocvar_hud_panel_healtharmor_text)
2489 DrawNumIcon(iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, leftmax), 1);
2494 barpos = pos + eX * 0.5 * mySize_x;
2495 if(baralign == 0 || baralign == 3) { // left align
2497 } else { // right align
2503 HUD_Panel_GetProgressBarColorForString(rightname);
2504 HUD_Panel_DrawProgressBar(barpos, barsize, rightprogressname, 0, barflip, min(1, rightcnt/rightmax), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2506 if(autocvar_hud_panel_healtharmor_text)
2507 DrawNumIcon(iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(rightcnt, rightmax), 1);
2513 barsize = eX * mySize_x + eY * 0.2 * mySize_y;
2514 HUD_Panel_GetProgressBarColor(fuel);
2515 HUD_Panel_DrawProgressBar(barpos, barsize, "progressbar", 0, mod(baralign, 2), min(1, fuel/100), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2518 else if (mySize_x/mySize_y > 1.5)
2520 barsize = eX * mySize_x + eY * 0.5 * mySize_y;
2524 if(baralign == 1 || baralign == 3) { // right align
2526 } else { // left align
2532 HUD_Panel_GetProgressBarColorForString(leftname);
2533 HUD_Panel_DrawProgressBar(barpos, barsize, leftprogressname, 0, barflip, min(1, leftcnt/leftmax), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2535 if(autocvar_hud_panel_healtharmor_text)
2536 DrawNumIcon(iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, leftmax), 1);
2541 barpos = pos + eY * 0.5 * mySize_y;
2542 if(baralign == 0 || baralign == 3) { // left align
2544 } else { // right align
2550 HUD_Panel_GetProgressBarColorForString(rightname);
2551 HUD_Panel_DrawProgressBar(barpos, barsize, rightprogressname, 0, barflip, min(1, rightcnt/rightmax), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2553 if(autocvar_hud_panel_healtharmor_text)
2554 DrawNumIcon(iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(rightcnt, rightmax), 1);
2560 barsize = eX * mySize_x + eY * 0.2 * mySize_y;
2561 HUD_Panel_GetProgressBarColor(fuel);
2562 HUD_Panel_DrawProgressBar(barpos, barsize, "progressbar", 0, mod(baralign, 2), min(1, fuel/100), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2567 barsize = eX * 0.5 * mySize_x + eY * mySize_y;
2571 if(baralign == 1 || baralign == 3) { // right align
2573 } else { // left align
2577 if(iconalign == 1 || iconalign == 3) { // down align
2578 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2579 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2580 } else { // up align
2581 picpos = pos + eX * 0.05 * mySize_x;
2582 numpos = pos + eY * 0.4 * mySize_x;
2587 HUD_Panel_GetProgressBarColorForString(leftname);
2588 HUD_Panel_DrawProgressBar(barpos, barsize, leftprogressname, 1, barflip, min(1, leftcnt/leftmax), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2590 if(autocvar_hud_panel_healtharmor_text)
2592 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2593 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, HUD_Get_Num_Color(leftcnt, leftmax), panel_fg_alpha, DRAWFLAG_NORMAL);
2599 barpos = pos + eX * 0.5 * mySize_x;
2600 if(baralign == 0 || baralign == 3) { // left align
2602 } else { // right align
2606 if(iconalign == 0 || iconalign == 3) { // up align
2607 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2608 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2609 } else { // down align
2610 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2611 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2616 HUD_Panel_GetProgressBarColorForString(rightname);
2617 HUD_Panel_DrawProgressBar(barpos, barsize, rightprogressname, 1, barflip, min(1, rightcnt/rightmax), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2619 if(autocvar_hud_panel_healtharmor_text)
2621 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2622 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, HUD_Get_Num_Color(rightcnt, rightmax), panel_fg_alpha, DRAWFLAG_NORMAL);
2629 barsize = eX * 0.05 * mySize_x + eY * mySize_y;
2630 HUD_Panel_GetProgressBarColor(fuel);
2631 HUD_Panel_DrawProgressBar(barpos, barsize, "progressbar", 1, mod(baralign, 2), min(1, fuel/100), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2637 // Notification area (#4)
2640 string Weapon_SuicideMessage(float deathtype)
2642 w_deathtype = deathtype;
2643 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2644 return w_deathtypestring;
2647 string Weapon_KillMessage(float deathtype)
2649 w_deathtype = deathtype;
2650 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2651 return w_deathtypestring;
2654 #define KN_MAX_ENTRIES 10
2656 float killnotify_times[KN_MAX_ENTRIES];
2657 float killnotify_deathtype[KN_MAX_ENTRIES];
2658 float killnotify_actiontype[KN_MAX_ENTRIES]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2659 string killnotify_attackers[KN_MAX_ENTRIES];
2660 string killnotify_victims[KN_MAX_ENTRIES];
2661 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2665 kn_index = KN_MAX_ENTRIES-1;
2666 killnotify_times[kn_index] = time;
2667 killnotify_deathtype[kn_index] = wpn;
2668 killnotify_actiontype[kn_index] = actiontype;
2669 if(killnotify_attackers[kn_index])
2670 strunzone(killnotify_attackers[kn_index]);
2671 killnotify_attackers[kn_index] = strzone(attacker);
2672 if(killnotify_victims[kn_index])
2673 strunzone(killnotify_victims[kn_index]);
2674 killnotify_victims[kn_index] = strzone(victim);
2677 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
2680 float alsoprint, gentle;
2681 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2682 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2684 if ((msg == MSG_SUICIDE || msg == MSG_KILL || msg == MSG_KILL_ACTION) && gametype == GAME_CTS) // selfkill isn't interesting in CTS and only spams up the notify panel
2687 if(msg == MSG_SUICIDE) {
2688 w = DEATH_WEAPONOF(type);
2690 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2692 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
2693 } else if (type == DEATH_KILL) {
2694 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2696 print (sprintf(_("^1%s^1 couldn't take it anymore\n"), s1));
2697 } else if (type == DEATH_ROT) {
2698 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2700 print (sprintf(_("^1%s^1 died\n"), s1));
2701 } else if (type == DEATH_NOAMMO) {
2702 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2704 print (sprintf(_("^7%s^7 committed suicide. What's the point of living without ammo?\n"), s1));
2705 } else if (type == DEATH_CAMP) {
2706 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2708 print (sprintf(_("^1%s^1 thought they found a nice camping ground\n"), s1));
2709 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2710 HUD_KillNotify_Push(s1, "", 0, type);
2712 print (sprintf(_("^1%s^1 didn't become friends with the Lord of Teamplay\n"), s1));
2713 } else if (type == DEATH_CHEAT) {
2714 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2716 print (sprintf(_("^1%s^1 unfairly eliminated themself\n"), s1));
2717 } else if (type == DEATH_FIRE) {
2718 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2720 print (sprintf(_("^1%s^1 burned to death\n"), s1));
2721 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2722 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2724 print (sprintf(_("^1%s^1 couldn't resist the urge to self-destruct\n"), s1));
2727 if (stof(s2) > 2) // killcount > 2
2728 print (sprintf(_("^1%s^1 ended it all after a %d kill spree\n"), s1, stof(s2)));
2729 } else if(msg == MSG_KILL) {
2730 w = DEATH_WEAPONOF(type);
2732 if((w == WEP_SNIPERRIFLE || w == WEP_MINSTANEX) && type & HITTYPE_HEADSHOT) // all headshot weapons go here
2733 HUD_KillNotify_Push(s1, s2, 1, DEATH_HEADSHOT);
2735 HUD_KillNotify_Push(s1, s2, 1, type);
2738 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
2740 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2741 HUD_KillNotify_Push(s1, s2, 1, type);
2745 print (sprintf(_("^1%s^1 took action against a team mate\n"), s1));
2747 print (sprintf(_("^1%s^1 mows down a team mate\n"), s1));
2750 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2752 print (sprintf(_("^1%s^1 ended a %d scoring spree by going against a team mate\n"), s1, stof(s3)));
2754 print (sprintf(_("^1%s^1 ended a %d kill spree by killing a team mate\n"), s1, stof(s3)));
2756 else if (stof(s2) > 2) {
2758 print (sprintf(_("^1%s^1's %s scoring spree was ended by a team mate!\n"), s1, stof(s3)));
2760 print (sprintf(_("^1%s^1's %s kill spree was ended by a team mate!\n"), s1, stof(s3)));
2763 else if(type == KILL_FIRST_BLOOD)
2764 print(sprintf(_("^1%s^1 drew first blood\n"), s1));
2765 else if (type == DEATH_TELEFRAG) {
2766 HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
2768 print (sprintf(_("^1%s^1 tried to occupy %s^1's teleport destination space\n"), s2, s1));
2770 print (sprintf(_("^1%s^1 was telefragged by %s\n"), s2, s1));
2772 else if (type == DEATH_DROWN) {
2773 HUD_KillNotify_Push(s1, s2, 1, DEATH_DROWN);
2775 print (sprintf(_("^1%s^1 was drowned by %s\n"), s2, s1));
2777 else if (type == DEATH_SLIME) {
2778 HUD_KillNotify_Push(s1, s2, 1, DEATH_SLIME);
2780 print (sprintf(_("^1%s^1 was slimed by %s\n"), s2, s1));
2782 else if (type == DEATH_LAVA) {
2783 HUD_KillNotify_Push(s1, s2, 1, DEATH_LAVA);
2785 print (sprintf(_("^1%s^1 was cooked by %s\n"), s2, s1));
2787 else if (type == DEATH_FALL) {
2788 HUD_KillNotify_Push(s1, s2, 1, DEATH_FALL);
2790 print (sprintf(_("^1%s^1 was grounded by %s\n"), s2, s1));
2792 else if (type == DEATH_SHOOTING_STAR) {
2793 HUD_KillNotify_Push(s1, s2, 1, DEATH_SHOOTING_STAR);
2795 print (sprintf(_("^1%s^1 was shot into space by %s\n"), s2, s1));
2797 else if (type == DEATH_SWAMP) {
2798 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2800 print (sprintf(_("^1%s^1 was conserved by %s\n"), s2, s1));
2802 else if (type == DEATH_HURTTRIGGER)
2804 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
2806 print(sprintf(_("^1%s^1 was thrown into a world of hurt by %s\n"), s2, s1));
2807 } else if(type == DEATH_SBCRUSH) {
2808 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2810 print (sprintf(_("^1%s^1 was crushed by %s\n"), s2, s1));
2811 } else if(type == DEATH_SBMINIGUN) {
2812 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2814 print (sprintf(_("^1%s^1 got shredded by %s\n"), s2, s1));
2815 } else if(type == DEATH_SBROCKET) {
2816 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2818 print (sprintf(_("^1%s^1 was blasted to bits by %s\n"), s2, s1));
2819 } else if(type == DEATH_SBBLOWUP) {
2820 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2822 print (sprintf(_("^1%s^1 got caught in the destruction of %s^1's vehicle\n"), s2, s1));
2823 } else if(type == DEATH_WAKIGUN) {
2824 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2826 print (sprintf(_("^1%s^1 was bolted down by %s\n"), s2, s1));
2827 } else if(type == DEATH_WAKIROCKET) {
2828 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2830 print (sprintf(_("^1%s^1 could find no shelter from %s^1's rockets\n"), s2, s1));
2831 } else if(type == DEATH_WAKIBLOWUP) {
2832 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2834 print (sprintf(_("^1%s^1 dies when %s^1's wakizashi dies.\n"), s2, s1));
2835 } else if(type == DEATH_TURRET) {
2836 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2838 print (sprintf(_("^1%s^1 was pushed into the line of fire by %s\n"), s2, s1));
2839 } else if(type == DEATH_TOUCHEXPLODE) {
2840 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2842 print (sprintf(_("^1%s^1 was pushed into an accident by %s\n"), s2, s1));
2843 } else if(type == DEATH_CHEAT) {
2844 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2846 print (sprintf(_("^1%s^1 was unfairly eliminated by %s\n"), s2, s1));
2847 } else if (type == DEATH_FIRE) {
2848 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2850 print (sprintf(_("^1%s^1 was burnt to death by %s\n"), s2, s1));
2851 } else if (type == DEATH_CUSTOM) {
2852 HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM);
2854 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
2855 } else if (type == DEATH_HURTTRIGGER) {
2856 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
2858 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
2860 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2862 print (sprintf(_("^1%s^1 was fragged by %s\n"), s2, s1));
2864 } else if(msg == MSG_SPREE) {
2865 if(type == KILL_END_SPREE) {
2867 print (sprintf(_("^1%s^1's %s scoring spree was ended by %s\n"), s1, s2, s3));
2869 print (sprintf(_("^1%s^1's %s kill spree was ended by %s\n"), s1, s2, s3));
2870 } else if(type == KILL_SPREE) {
2872 print (sprintf(_("^1%s^1 made %s scores in a row\n"), s1, s2));
2874 print (sprintf(_("^1%s^1 has %s frags in a row\n"), s1, s2));
2875 } else if(type == KILL_SPREE_3) {
2877 print (sprintf(_("%s^7 made a ^1TRIPLE SCORE\n"), s1));
2879 print (sprintf(_("%s^7 made a ^1TRIPLE FRAG\n"), s1));
2880 } else if(type == KILL_SPREE_5) {
2882 print (sprintf(_("%s^7 unleashes ^1SCORING RAGE\n"), s1));
2884 print (sprintf(_("%s^7 unleashes ^1RAGE\n"), s1));
2885 } else if(type == KILL_SPREE_10) {
2887 print (sprintf(_("%s^7 made ^1TEN SCORES IN A ROW!\n"), s1));
2889 print (sprintf(_("%s^7 starts the ^1MASSACRE!\n"), s1));
2890 } else if(type == KILL_SPREE_15) {
2892 print (sprintf(_("%s^7 made ^1FIFTEEN SCORES IN A ROW!\n"), s1));
2894 print (sprintf(_("%s^7 executes ^1MAYHEM!\n"), s1));
2895 } else if(type == KILL_SPREE_20) {
2897 print (sprintf(_("%s^7 made ^1TWENTY SCORES IN A ROW!\n"), s1));
2899 print (sprintf(_("%s^7 is a ^1BERSERKER!\n"), s1));
2900 } else if(type == KILL_SPREE_25) {
2902 print (sprintf(_("%s^7 made ^1TWENTY FIFE SCORES IN A ROW!\n"), s1));
2904 print (sprintf(_("%s^7 inflicts ^1CARNAGE!\n"), s1));
2905 } else if(type == KILL_SPREE_30) {
2907 print (sprintf(_("%s^7 made ^1THIRTY SCORES IN A ROW!\n"), s1));
2909 print (sprintf(_("%s^7 unleashes ^1ARMAGEDDON!\n"), s1));
2911 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2912 if (type == DEATH_DROWN) {
2913 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2917 print (sprintf(_("^1%s^1 was in the water for too long\n"), s1));
2919 print (sprintf(_("^1%s^1 drowned\n"), s1));
2921 } else if (type == DEATH_SLIME) {
2922 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2924 print (sprintf(_("^1%s^1 was slimed\n"), s1));
2925 } else if (type == DEATH_LAVA) {
2926 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2930 print (sprintf(_("^1%s^1 found a hot place\n"), s1));
2932 print (sprintf(_("^1%s^1 turned into hot slag\n"), s1));
2934 } else if (type == DEATH_FALL) {
2935 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2939 print (sprintf(_("^1%s^1 tested gravity (and it worked)\n"), s1));
2941 print (sprintf(_("^1%s^1 hit the ground with a crunch\n"), s1));
2943 } else if (type == DEATH_SHOOTING_STAR) {
2944 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2946 print (sprintf(_("^1%s^1 became a shooting star\n"), s1));
2947 } else if (type == DEATH_SWAMP) {
2948 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2952 print (sprintf(_("^1%s^1 discovered a swamp\n"), s1));
2954 print (sprintf(_("^1%s^1 is now conserved for centuries to come\n"), s1));
2956 } else if(type == DEATH_TURRET) {
2957 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2959 print (sprintf(_("^1%s^1 was mowed down by a turret \n"), s1));
2960 } else if (type == DEATH_CUSTOM) {
2961 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2963 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
2964 } else if (type == DEATH_HURTTRIGGER) {
2965 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2967 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
2968 } else if(type == DEATH_TOUCHEXPLODE) {
2969 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2971 print (sprintf(_("^1%s^1 died in an accident\n"), s1));
2972 } else if(type == DEATH_CHEAT) {
2973 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2975 print (sprintf(_("^1%s^1 was unfairly eliminated\n"), s1));
2976 } else if(type == DEATH_FIRE) {
2977 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2981 print (sprintf(_("^1%s^1 felt a little hot\n"), s1));
2983 print (sprintf(_("^1%s^1 burnt to death\n"), s1));
2986 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2990 print (sprintf(_("^1%s^1 needs a restart\n"), s1));
2992 print (sprintf(_("^1%s^1 died\n"), s1));
2995 } else if(msg == MSG_KILL_ACTION_SPREE) {
2997 print (sprintf(_("^1%s^1 needs a restart after a %d scoring spree\n"), s1, stof(s2)));
2999 print (sprintf(_("^1%s^1 died with a %d kill spree\n"), s1, stof(s2)));
3000 } else if(msg == MSG_INFO) {
3001 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
3002 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
3003 print(sprintf(_("%s^7 got the %s\n"), s1, s2));
3004 } else if(type == INFO_LOSTFLAG) {
3005 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
3006 print(sprintf(_("%s^7 lost the %s\n"), s1, s2));
3007 } else if(type == INFO_PICKUPFLAG) {
3008 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
3009 print(sprintf(_("%s^7 picked up the %s\n"), s1, s2));
3010 } else if(type == INFO_RETURNFLAG) {
3011 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
3012 print(sprintf(_("%s^7 returned the %s\n"), s1, s2));
3013 } else if(type == INFO_CAPTUREFLAG) {
3014 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
3015 print(sprintf(_("%s^7 captured the %s%s\n"), s1, s2, s3));
3017 } else if(msg == MSG_RACE) {
3018 if(type == RACE_SERVER_RECORD) {
3019 HUD_KillNotify_Push(s1, s2, 1, RACE_SERVER_RECORD);
3021 else if(type == RACE_NEW_RANK) {
3022 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_RANK);
3024 else if(type == RACE_NEW_TIME) {
3025 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_TIME);
3027 else if(type == RACE_FAIL) {
3028 HUD_KillNotify_Push(s1, s2, 1, RACE_FAIL);
3030 } else if(msg == MSG_KA) {
3031 if(type == KA_PICKUPBALL) {
3032 HUD_KillNotify_Push(s1, s2, 0, KA_PICKUPBALL);
3034 print (sprintf(_("%s^7 has picked up the ball!\n"), s1));
3036 else if(type == KA_DROPBALL) {
3037 HUD_KillNotify_Push(s1, s2, 0, KA_DROPBALL);
3039 print(sprintf(_("%s^7 has dropped the ball!\n"), s1));
3044 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
3046 void HUD_Centerprint(string s1, string s2, float type, float msg)
3049 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
3050 if(msg == MSG_SUICIDE) {
3051 if (type == DEATH_TEAMCHANGE) {
3052 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("You are now on: %s"), s1)));
3053 } else if (type == DEATH_AUTOTEAMCHANGE) {
3054 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("You have been moved into a different team to improve team balance\nYou are now on: %s"), s1)));
3055 } else if (type == DEATH_CAMP) {
3057 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Reconsider your tactics, camper!")));
3059 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Die camper!")));
3060 } else if (type == DEATH_NOAMMO) {
3062 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You are reinserted into the game for running out of ammo...")));
3064 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You were killed for running out of ammo...")));
3065 } else if (type == DEATH_ROT) {
3067 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You need to preserve your health")));
3069 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You grew too old without taking your medicine")));
3070 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
3072 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Don't go against team mates!")));
3074 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Don't shoot your team mates!")));
3075 } else if (type == DEATH_QUIET) {
3077 } else { // generic message
3079 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You need to be more careful!")));
3081 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You killed your own dumb self!")));
3083 } else if(msg == MSG_KILL) {
3084 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
3086 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1Moron! You went against %s, a team mate!"), s1)));
3088 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1Moron! You fragged %s, a team mate!"), s1)));
3090 } else if (type == KILL_FIRST_BLOOD) {
3092 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First score")));
3094 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First blood")));
3096 } else if (type == KILL_FIRST_VICTIM) {
3098 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First casualty")));
3100 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First victim")));
3102 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
3104 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You scored against ^7%s^1 who was typing!"), s1), s2));
3106 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You typefragged ^7%s"), s1), s2));
3108 } else if (type == KILL_TYPEFRAGGED) {
3110 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were scored against by ^7%s^1 while you were typing!"), s1), s2));
3112 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were typefragged by ^7%s"), s1), s2));
3114 } else if (type == KILL_FRAG) {
3116 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^4You scored against ^7%s"), s1), s2));
3118 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^4You fragged ^7%s"), s1), s2));
3120 } else { // generic message
3122 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were scored against by ^7%s"), s1), s2));
3124 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were fragged by ^7%s"), s1), s2));
3127 } else if(msg == MSG_KILL_ACTION) {
3128 // TODO: invent more centerprints here?
3129 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Watch your step!")));
3133 void HUD_Notify (void)
3135 if(!autocvar_hud_panel_notify && !autocvar__hud_configure)
3138 active_panel = HUD_PANEL_NOTIFY;
3139 HUD_Panel_UpdateCvars(notify);
3142 mySize = panel_size;
3144 HUD_Panel_DrawBg(1);
3145 if(panel_bg_padding)
3147 pos += '1 1 0' * panel_bg_padding;
3148 mySize -= '2 2 0' * panel_bg_padding;
3151 float entries, height;
3152 entries = bound(1, floor(KN_MAX_ENTRIES * mySize_y/mySize_x), KN_MAX_ENTRIES);
3153 height = mySize_y/entries;
3156 float fontheight = height * autocvar_hud_panel_notify_fontsize;
3157 fontsize = '0.5 0.5 0' * fontheight;
3161 when = autocvar_hud_panel_notify_time;
3163 fadetime = autocvar_hud_panel_notify_fadetime;
3167 vector pos_attacker, pos_victim;
3169 float width_attacker;
3170 string attacker, victim;
3172 float i, j, w, step, limit;
3173 if(autocvar_hud_panel_notify_flip) //order items from the top down
3179 else //order items from the bottom up
3186 for(j = kn_index; i != limit; i += step, ++j)
3188 if(autocvar__hud_configure)
3192 else // inverse order
3193 a = entries - 1 - i;
3194 attacker = textShortenToWidth(sprintf(_("Player %d"), a+1), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3195 victim = textShortenToWidth(sprintf(_("Player %d"), a+2), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3196 s = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname);
3197 a = bound(0, (when - a) / 4, 1);
3198 goto hud_config_notifyprint;
3201 if (j == KN_MAX_ENTRIES)
3204 if(killnotify_times[j] + when > time)
3208 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
3222 w = DEATH_WEAPONOF(killnotify_deathtype[j]);
3224 // TODO: maybe print in team colors?
3227 if(killnotify_actiontype[j] == 0)
3229 if(killnotify_deathtype[j] == DEATH_GENERIC)
3233 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
3235 s = "notify_outofammo";
3237 else if(killnotify_deathtype[j] == DEATH_KILL)
3239 s = "notify_selfkill";
3241 else if(killnotify_deathtype[j] == DEATH_CAMP)
3243 s = "notify_camping";
3245 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
3247 s = "notify_teamkill_red";
3249 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
3251 s = "notify_teamkill_blue";
3253 else if(killnotify_deathtype[j] == DEATH_DROWN)
3257 else if(killnotify_deathtype[j] == DEATH_SLIME)
3261 else if(killnotify_deathtype[j] == DEATH_LAVA)
3265 else if(killnotify_deathtype[j] == DEATH_FALL)
3269 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
3271 s = "notify_shootingstar";
3273 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
3277 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
3279 if(killnotify_victims[j] == "^1RED^7 flag")
3281 s = "notify_red_taken";
3285 s = "notify_blue_taken";
3288 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
3290 if(killnotify_victims[j] == "^1RED^7 flag")
3292 s = "notify_red_returned";
3296 s = "notify_blue_returned";
3299 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
3301 if(killnotify_victims[j] == "^1RED^7 flag")
3303 s = "notify_red_lost";
3307 s = "notify_blue_lost";
3310 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
3312 if(killnotify_victims[j] == "^1RED^7 flag")
3314 s = "notify_red_captured";
3318 s = "notify_blue_captured";
3321 else if(killnotify_deathtype[j] == KA_DROPBALL)
3323 s = "notify_balldropped";
3325 else if(killnotify_deathtype[j] == KA_PICKUPBALL)
3327 s = "notify_ballpickedup";
3330 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3331 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
3332 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
3336 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3337 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3340 // X [did action to] Y
3343 if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
3345 s = "notify_melee_laser";
3347 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_SHOTGUN)
3349 s = "notify_melee_shotgun";
3351 else if(WEP_VALID(w))
3353 self = get_weaponinfo(w);
3354 s = strcat("weapon", self.netname);
3356 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
3358 s = "notify_teamkill_red";
3360 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
3362 s = "notify_teamkill_red";
3364 else if(killnotify_deathtype[j] == DEATH_TELEFRAG)
3366 s = "notify_telefrag";
3368 else if(killnotify_deathtype[j] == DEATH_DROWN)
3372 else if(killnotify_deathtype[j] == DEATH_SLIME)
3376 else if(killnotify_deathtype[j] == DEATH_LAVA)
3380 else if(killnotify_deathtype[j] == DEATH_FALL)
3384 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
3386 s = "notify_shootingstar";
3388 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
3392 else if(killnotify_deathtype[j] == DEATH_HEADSHOT)
3394 s = "notify_headshot";
3396 else if(killnotify_deathtype[j] == RACE_SERVER_RECORD)
3398 s = "race_newrecordserver";
3400 else if(killnotify_deathtype[j] == RACE_NEW_RANK)
3402 s = "race_newrankyellow";
3404 else if(killnotify_deathtype[j] == RACE_NEW_TIME)
3408 else if(killnotify_deathtype[j] == RACE_FAIL)
3413 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3414 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3415 :hud_config_notifyprint
3416 width_attacker = stringwidth(attacker, TRUE, fontsize);
3417 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
3418 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
3419 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
3423 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3424 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3425 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3434 string seconds_tostring(float sec)
3437 minutes = floor(sec / 60);
3439 sec -= minutes * 60;
3440 return sprintf("%d:%02d", minutes, sec);
3443 void HUD_Timer(void)
3445 if(!autocvar_hud_panel_timer && !autocvar__hud_configure)
3448 active_panel = HUD_PANEL_TIMER;
3449 HUD_Panel_UpdateCvars(timer);
3452 mySize = panel_size;
3454 HUD_Panel_DrawBg(1);
3455 if(panel_bg_padding)
3457 pos += '1 1 0' * panel_bg_padding;
3458 mySize -= '2 2 0' * panel_bg_padding;
3462 float timelimit, elapsedTime, timeleft, minutesLeft;
3464 timelimit = getstatf(STAT_TIMELIMIT);
3466 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3467 timeleft = ceil(timeleft);
3469 minutesLeft = floor(timeleft / 60);
3472 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3473 timer_color = '1 1 1'; //white
3474 else if(minutesLeft >= 1)
3475 timer_color = '1 1 0'; //yellow
3477 timer_color = '1 0 0'; //red
3479 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
3480 if (time < getstatf(STAT_GAMESTARTTIME)) {
3481 //while restart is still active, show 00:00
3482 timer = seconds_tostring(0);
3484 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3485 timer = seconds_tostring(elapsedTime);
3488 timer = seconds_tostring(timeleft);
3491 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3496 void HUD_Radar(void)
3498 if ((autocvar_hud_panel_radar == 0 || (autocvar_hud_panel_radar != 2 && !teamplay)) && !autocvar__hud_configure)
3501 active_panel = HUD_PANEL_RADAR;
3502 HUD_Panel_UpdateCvars(radar);
3505 mySize = panel_size;
3507 HUD_Panel_DrawBg(1);
3508 if(panel_bg_padding)
3510 pos += '1 1 0' * panel_bg_padding;
3511 mySize -= '2 2 0' * panel_bg_padding;
3514 local float color1, color2; // color already declared as a global in hud.qc
3517 float scale2d, normalsize, bigsize;
3520 teamradar_origin2d = pos + 0.5 * mySize;
3521 teamradar_size2d = mySize;
3523 if(minimapname == "")
3526 teamradar_loadcvars();
3528 switch(hud_panel_radar_zoommode)
3532 f = current_zoomfraction;
3535 f = 1 - current_zoomfraction;
3545 switch(hud_panel_radar_rotation)
3548 teamradar_angle = view_angles_y - 90;
3551 teamradar_angle = 90 * hud_panel_radar_rotation;
3555 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3556 teamradar_size2d = mySize;
3558 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3560 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3561 if(hud_panel_radar_rotation == 0)
3563 // max-min distance must fit the radar in any rotation
3564 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_scale));
3568 vector c0, c1, c2, c3, span;
3569 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3570 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3571 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3572 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3574 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3575 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3577 // max-min distance must fit the radar in x=x, y=y
3579 teamradar_size2d_x * scale2d / (1.05 * span_x),
3580 teamradar_size2d_y * scale2d / (1.05 * span_y)
3584 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
3585 if(bigsize > normalsize)
3586 normalsize = bigsize;
3590 + (1 - f) * normalsize;
3591 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3593 + (1 - f) * view_origin);
3595 color1 = GetPlayerColor(player_localentnum-1);
3596 rgb = GetTeamRGB(color1);
3605 draw_teamradar_background(hud_panel_radar_foreground_alpha);
3607 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3608 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3609 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3610 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3611 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3613 color2 = GetPlayerColor(tm.sv_entnum);
3614 //if(color == COLOR_SPECTATOR || color == color2)
3615 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3617 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3619 drawresetcliparea();
3624 void HUD_Score(void)
3626 if(!autocvar_hud_panel_score && !autocvar__hud_configure)
3629 active_panel = HUD_PANEL_SCORE;
3630 HUD_Panel_UpdateCvars(score);
3633 mySize = panel_size;
3635 HUD_Panel_DrawBg(1);
3636 if(panel_bg_padding)
3638 pos += '1 1 0' * panel_bg_padding;
3639 mySize -= '2 2 0' * panel_bg_padding;
3642 float score, distribution, leader;
3644 vector distribution_color;
3646 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3648 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3649 string timer, distrtimer;
3651 pl = players.sort_next;
3654 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3655 if(pl.scores[ps_primary] == 0)
3658 score = me.(scores[ps_primary]);
3659 timer = TIME_ENCODED_TOSTRING(score);
3661 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3662 // distribution display
3663 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3665 distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS);
3667 if (distribution <= 0) {
3668 distribution_color = '0 1 0';
3672 distribution_color = '1 0 0';
3675 drawstring_aspect(pos + eX * 0.75 * mySize_x, strcat(sign, distrtimer), eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3677 // race record display
3678 if (distribution <= 0)
3679 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3680 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3681 } else if (!teamplay) { // non-teamgames
3682 // me vector := [team/connected frags id]
3683 pl = players.sort_next;
3687 if(autocvar__hud_configure)
3690 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3694 score = me.(scores[ps_primary]);
3695 if(autocvar__hud_configure)
3698 if(distribution >= 5) {
3699 distribution_color = eY;
3701 } else if(distribution >= 0) {
3702 distribution_color = '1 1 1';
3704 } else if(distribution >= -5)
3705 distribution_color = '1 1 0';
3707 distribution_color = eX;
3709 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);
3711 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3712 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3713 } else { // teamgames
3714 float max_fragcount;
3715 max_fragcount = -99;
3718 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3719 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !autocvar__hud_configure)) // no players? don't display
3721 score = tm.(teamscores[ts_primary]);
3722 if(autocvar__hud_configure)
3726 if (score > max_fragcount)
3727 max_fragcount = score;
3729 if(tm.team == myteam) {
3730 if (max_fragcount == score)
3733 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3734 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3736 if (max_fragcount == score)
3739 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);
3740 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);
3749 void HUD_RaceTimer (void) {
3750 if(!autocvar_hud_panel_racetimer && !(gametype == GAME_RACE || gametype == GAME_CTS) && !autocvar__hud_configure)
3753 active_panel = HUD_PANEL_RACETIMER;
3754 HUD_Panel_UpdateCvars(racetimer);
3757 mySize = panel_size;
3759 HUD_Panel_DrawBg(1);
3760 if(panel_bg_padding)
3762 pos += '1 1 0' * panel_bg_padding;
3763 mySize -= '2 2 0' * panel_bg_padding;
3766 // always force 4:1 aspect
3768 if(mySize_x/mySize_y > 4)
3770 newSize_x = 4 * mySize_y;
3771 newSize_y = mySize_y;
3773 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3777 newSize_y = 1/4 * mySize_x;
3778 newSize_x = mySize_x;
3780 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3785 string s, forcetime;
3787 if(autocvar__hud_configure)
3790 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);
3791 s = _("^1Intermediate 1 (+15.42)");
3792 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);
3793 s = sprintf(_("^1PENALTY: %.1f (%s)"), 2, "missing a checkpoint");
3794 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);
3796 else if(race_checkpointtime)
3798 a = bound(0, 2 - (time - race_checkpointtime), 1);
3801 if(a > 0) // just hit a checkpoint?
3803 if(race_checkpoint != 254)
3805 if(race_time && race_previousbesttime)
3806 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3808 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3810 forcetime = TIME_ENCODED_TOSTRING(race_time);
3815 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3817 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3818 if(a > 0) // next one?
3820 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3825 if(s != "" && a > 0)
3827 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);
3830 if(race_penaltytime)
3832 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3835 s = sprintf(_("^1PENALTY: %.1f (%s)"), race_penaltytime * 0.1, race_penaltyreason);
3836 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);
3842 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3843 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);
3848 if(race_laptime && race_checkpoint != 255)
3850 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3851 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);
3856 if(race_mycheckpointtime)
3858 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3859 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3860 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);
3862 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3864 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3865 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3866 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);
3869 if(race_penaltytime && !race_penaltyaccumulator)
3871 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3872 a = bound(0, (1 + t - time), 1);
3876 s = sprintf(_("^1PENALTY: %.1f (%s)"), (t - time) * 0.1, race_penaltyreason);
3878 s = sprintf(_("^2PENALTY: %.1f (%s)"), 0, race_penaltyreason);
3879 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);
3887 float vote_yescount;
3890 float vote_highlighted; // currently selected vote
3892 float vote_active; // is there an active vote?
3893 float vote_prev; // previous state of vote_active to check for a change
3895 float vote_change; // "time" when vote_active changed
3897 void HUD_VoteWindow(void)
3899 uid2name_dialog = 0;
3900 if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
3903 vote_called_vote = strzone(_("^2Name ^7instead of \"^1Unregistered player^7\" in stats"));
3904 uid2name_dialog = 1;
3907 if(!autocvar_hud_panel_vote && !autocvar__hud_configure)
3910 if(!autocvar__hud_configure)
3912 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
3913 panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha;
3915 if(panel_bg_alpha_str == "") {
3916 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
3918 panel_bg_alpha = stof(panel_bg_alpha_str);
3923 if(vote_active != vote_prev) {
3925 vote_prev = vote_active;
3928 if(vote_active || autocvar__hud_configure)
3929 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3931 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3933 if(autocvar__hud_configure)
3943 active_panel = HUD_PANEL_VOTE;
3944 HUD_Panel_UpdateCvars(vote);
3948 panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight;
3949 panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight;
3952 // these must be below above block
3955 mySize = panel_size;
3957 a = vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3958 HUD_Panel_DrawBg(a);
3959 a = panel_fg_alpha * a;
3961 if(panel_bg_padding)
3963 pos += '1 1 0' * panel_bg_padding;
3964 mySize -= '2 2 0' * panel_bg_padding;
3967 // always force 3:1 aspect
3969 if(mySize_x/mySize_y > 3)
3971 newSize_x = 3 * mySize_y;
3972 newSize_y = mySize_y;
3974 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3978 newSize_y = 1/3 * mySize_x;
3979 newSize_x = mySize_x;
3981 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3985 s = _("A vote has been called for:");
3987 s = _("Allow servers to store and display your name?");
3988 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3989 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1/8), stringwidth_colors);
3990 if(autocvar__hud_configure)
3991 s = _("^1Configure the HUD");
3992 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
3994 // print the yes/no counts
3995 s = sprintf(_("Yes (%s): %d"), getcommandkey("vyes", "vyes"), vote_yescount);
3996 drawstring_aspect(pos + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '0 1 0', a, DRAWFLAG_NORMAL);
3997 s = sprintf(_("No (%s): %d"), getcommandkey("vno", "vno"), vote_nocount);
3998 drawstring_aspect(pos + eX * 0.5 * mySize_x + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '1 0 0', a, DRAWFLAG_NORMAL);
4000 // draw the progress bar backgrounds
4001 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
4003 // draw the highlights
4004 if(vote_highlighted == 1) {
4005 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
4006 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
4008 else if(vote_highlighted == 2) {
4009 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
4010 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
4013 // draw the progress bars
4014 if(vote_yescount && vote_needed)
4016 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
4017 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
4020 if(vote_nocount && vote_needed)
4022 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
4023 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
4026 drawresetcliparea();
4029 vote_highlighted = 0;
4033 // Mod icons panel (#10)
4036 float mod_active; // is there any active mod icon?
4038 // Clan Arena HUD modicons
4039 void HUD_Mod_CA(vector pos, vector mySize)
4041 mod_active = 1; // CA should never hide the mod icons panel
4042 float redalive, bluealive;
4043 redalive = getstati(STAT_REDALIVE);
4044 bluealive = getstati(STAT_BLUEALIVE);
4046 vector redpos, bluepos;
4047 if(mySize_x > mySize_y)
4050 bluepos = pos + eY * 0.5 * mySize_y;
4051 drawpic_aspect_skin(redpos, "player_red.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4052 drawstring_aspect(redpos + eX * 0.5 * mySize_x, ftos(redalive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4053 drawpic_aspect_skin(bluepos, "player_blue.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4054 drawstring_aspect(bluepos + eX * 0.5 * mySize_x, ftos(bluealive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4059 bluepos = pos + eY * 0.5 * mySize_y;
4060 drawpic_aspect_skin(redpos, "player_red.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4061 drawstring_aspect(redpos + eY * 0.3 * mySize_y, ftos(redalive), eX * mySize_x + eY * 0.2 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4062 drawpic_aspect_skin(bluepos, "player_blue.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4063 drawstring_aspect(bluepos + eY * 0.3 * mySize_y, ftos(bluealive), eX * mySize_x + eY * 0.2 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4067 // CTF HUD modicon section
4068 float redflag_prevframe, blueflag_prevframe; // status during previous frame
4069 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
4070 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
4072 void HUD_Mod_CTF_Reset(void)
4074 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
4077 void HUD_Mod_CTF(vector pos, vector mySize)
4079 vector redflag_pos, blueflag_pos;
4081 float f; // every function should have that
4083 float redflag, blueflag; // current status
4084 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
4087 stat_items = getstati(STAT_ITEMS);
4088 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
4089 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
4091 if(redflag || blueflag)
4096 if(autocvar__hud_configure)
4102 // when status CHANGES, set old status into prevstatus and current status into status
4103 if (redflag != redflag_prevframe)
4105 redflag_statuschange_time = time;
4106 redflag_prevstatus = redflag_prevframe;
4107 redflag_prevframe = redflag;
4110 if (blueflag != blueflag_prevframe)
4112 blueflag_statuschange_time = time;
4113 blueflag_prevstatus = blueflag_prevframe;
4114 blueflag_prevframe = blueflag;
4117 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
4118 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
4120 float BLINK_FACTOR = 0.15;
4121 float BLINK_BASE = 0.85;
4123 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
4125 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
4127 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
4129 string red_icon, red_icon_prevstatus;
4130 float red_alpha, red_alpha_prevstatus;
4131 red_alpha = red_alpha_prevstatus = 1;
4133 case 1: red_icon = "flag_red_taken"; break;
4134 case 2: red_icon = "flag_red_lost"; break;
4135 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4137 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
4138 red_icon = "flag_red_shielded";
4140 red_icon = string_null;
4143 switch(redflag_prevstatus) {
4144 case 1: red_icon_prevstatus = "flag_red_taken"; break;
4145 case 2: red_icon_prevstatus = "flag_red_lost"; break;
4146 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4149 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
4150 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
4151 red_icon_prevstatus = "flag_red_shielded";
4153 red_icon_prevstatus = string_null;
4157 string blue_icon, blue_icon_prevstatus;
4158 float blue_alpha, blue_alpha_prevstatus;
4159 blue_alpha = blue_alpha_prevstatus = 1;
4161 case 1: blue_icon = "flag_blue_taken"; break;
4162 case 2: blue_icon = "flag_blue_lost"; break;
4163 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4165 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
4166 blue_icon = "flag_blue_shielded";
4168 blue_icon = string_null;
4171 switch(blueflag_prevstatus) {
4172 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
4173 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
4174 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4177 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
4178 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
4179 blue_icon_prevstatus = "flag_blue_shielded";
4181 blue_icon_prevstatus = string_null;
4185 if(mySize_x > mySize_y) {
4186 if (myteam == COLOR_TEAM1) { // always draw own flag on left
4188 blueflag_pos = pos + eX * 0.5 * mySize_x;
4191 redflag_pos = pos + eX * 0.5 * mySize_x;
4193 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
4195 if (myteam == COLOR_TEAM1) { // always draw own flag on left
4197 blueflag_pos = pos + eY * 0.5 * mySize_y;
4200 redflag_pos = pos + eY * 0.5 * mySize_y;
4202 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
4205 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
4206 if(red_icon_prevstatus && f < 1)
4207 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
4209 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
4211 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
4212 if(blue_icon_prevstatus && f < 1)
4213 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
4215 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
4218 // Keyhunt HUD modicon section
4219 float kh_runheretime;
4221 void HUD_Mod_KH_Reset(void)
4226 void HUD_Mod_KH(vector pos, vector mySize)
4228 mod_active = 1; // keyhunt should never hide the mod icons panel
4232 vector p, pa, kh_size, kh_asize;
4234 kh_keys = getstati(STAT_KH_KEYS);
4237 if(mySize_x > mySize_y)
4239 p_y = pos_y + 0.25 * mySize_y;
4240 pa = p - eY * 0.25 * mySize_y;
4242 kh_size_x = mySize_x * 0.25;
4243 kh_size_y = 0.75 * mySize_y;
4244 kh_asize_x = mySize_x * 0.25;
4245 kh_asize_y = mySize_y * 0.25;
4249 p_y = pos_y + 0.125 * mySize_y;
4250 pa = p - eY * 0.125 * mySize_y;
4252 kh_size_x = mySize_x * 0.5;
4253 kh_size_y = 0.375 * mySize_y;
4254 kh_asize_x = mySize_x * 0.5;
4255 kh_asize_y = mySize_y * 0.125;
4262 for(i = 0; i < 4; ++i)
4264 key = floor(kh_keys / pow(32, i)) & 31;
4266 if(keyteam == 30 && keycount <= 4)
4268 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
4272 // this yields 8 exactly if "RUN HERE" shows
4277 kh_runheretime = time;
4278 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
4283 for(i = 0; i < 4; ++i)
4285 key = floor(kh_keys / pow(32, i)) & 31;
4298 default: // owned or dropped
4303 a = a * panel_fg_alpha;
4304 aa = aa * panel_fg_alpha;
4310 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4313 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4316 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4319 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4324 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
4327 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4330 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4333 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4336 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4340 if(mySize_x > mySize_y)
4342 p_x += 0.25 * mySize_x;
4343 pa_x += 0.25 * mySize_x;
4349 p_y = pos_y + 0.625 * mySize_y;
4350 pa_y = pos_y + 0.5 * mySize_y;
4356 p_x += 0.5 * mySize_x;
4357 pa_x += 0.5 * mySize_x;
4363 // Keepaway HUD mod icon
4364 float kaball_prevstatus; // last remembered status
4365 float kaball_statuschange_time; // time when the status changed
4367 // we don't need to reset for keepaway since it immediately
4368 // autocorrects prevstatus as to if the player has the ball or not
4370 void HUD_Mod_Keepaway(vector pos, vector mySize)
4372 mod_active = 1; // keepaway should always show the mod HUD
4374 float BLINK_FACTOR = 0.15;
4375 float BLINK_BASE = 0.85;
4376 float BLINK_FREQ = 5;
4377 float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
4379 float stat_items = getstati(STAT_ITEMS);
4380 float kaball = (stat_items/IT_KEY1) & 1;
4382 if(kaball != kaball_prevstatus)
4384 kaball_statuschange_time = time;
4385 kaball_prevstatus = kaball;
4388 vector kaball_pos, kaball_size;
4390 if(mySize_x > mySize_y) {
4391 kaball_pos = pos + eX * 0.25 * mySize_x;
4392 kaball_size = eX * 0.5 * mySize_x + eY * mySize_y;
4394 kaball_pos = pos + eY * 0.25 * mySize_y;
4395 kaball_size = eY * 0.5 * mySize_y + eX * mySize_x;
4398 float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
4399 float f = bound(0, kaball_statuschange_elapsedtime*2, 1);
4401 if(kaball_prevstatus && f < 1)
4402 drawpic_aspect_skin_expanding(kaball_pos, "keepawayball_carrying", kaball_size, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f);
4405 drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
4409 // Nexball HUD mod icon
4410 void HUD_Mod_NexBall(vector pos, vector mySize)
4412 float stat_items, nb_pb_starttime, dt, p;
4414 stat_items = getstati(STAT_ITEMS);
4415 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
4417 if (stat_items & IT_KEY1)
4422 //Manage the progress bar if any
4423 if (nb_pb_starttime > 0)
4425 dt = mod(time - nb_pb_starttime, nb_pb_period);
4426 // one period of positive triangle
4427 p = 2 * dt / nb_pb_period;
4433 if(mySize_x > mySize_y)
4441 HUD_Panel_GetProgressBarColor(nexball);
4442 HUD_Panel_DrawProgressBar(pos, mySize, "statusbar", vertical, 0, p, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4445 if (stat_items & IT_KEY1)
4446 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4449 // Race/CTS HUD mod icons
4450 float crecordtime_prev; // last remembered crecordtime
4451 float crecordtime_change_time; // time when crecordtime last changed
4452 float srecordtime_prev; // last remembered srecordtime
4453 float srecordtime_change_time; // time when srecordtime last changed
4455 float race_status_time;
4456 float race_status_prev;
4457 string race_status_name_prev;
4458 void HUD_Mod_Race(vector pos, vector mySize)
4460 mod_active = 1; // race should never hide the mod icons panel
4462 me = playerslots[player_localentnum - 1];
4464 float f; // yet another function has this
4465 score = me.(scores[ps_primary]);
4467 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
4468 return; // no records in the actual race
4470 // clientside personal record
4472 if(gametype == GAME_CTS)
4476 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4478 if(score && (score < t || !t)) {
4479 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4480 if(autocvar_cl_autodemo_delete_keeprecords)
4482 f = autocvar_cl_autodemo_delete;
4484 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4488 if(t != crecordtime_prev) {
4489 crecordtime_prev = t;
4490 crecordtime_change_time = time;
4493 vector textPos, medalPos;
4495 if(mySize_x > mySize_y) {
4496 // text on left side
4497 squareSize = min(mySize_y, mySize_x/2);
4498 textPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eY * 0.5 * (mySize_y - squareSize);
4499 medalPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eX * 0.5 * mySize_x + eY * 0.5 * (mySize_y - squareSize);
4502 squareSize = min(mySize_x, mySize_y/2);
4503 textPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eX * 0.5 * (mySize_x - squareSize);
4504 medalPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eY * 0.5 * mySize_y + eX * 0.5 * (mySize_x - squareSize);
4507 f = time - crecordtime_change_time;
4510 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4511 drawstring_aspect(textPos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4513 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4514 drawstring_aspect(textPos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4515 drawstring_aspect_expanding(pos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4516 drawstring_aspect_expanding(pos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4520 t = race_server_record;
4521 if(t != srecordtime_prev) {
4522 srecordtime_prev = t;
4523 srecordtime_change_time = time;
4525 f = time - srecordtime_change_time;
4528 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4529 drawstring_aspect(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4531 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4532 drawstring_aspect(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4533 drawstring_aspect_expanding(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4534 drawstring_aspect_expanding(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4537 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4538 race_status_time = time + 5;
4539 race_status_prev = race_status;
4540 if (race_status_name_prev)
4541 strunzone(race_status_name_prev);
4542 race_status_name_prev = strzone(race_status_name);
4547 a = bound(0, race_status_time - time, 1);
4550 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
4554 rank = race_CheckName(race_status_name);
4556 rankname = race_PlaceName(rank);
4559 namepos = medalPos + '0 0.8 0' * squareSize;
4561 rankpos = medalPos + '0 0.15 0' * squareSize;
4563 if(race_status == 0)
4564 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4565 else if(race_status == 1) {
4566 drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newtime", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4567 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4568 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4569 } else if(race_status == 2) {
4570 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4571 drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newrankgreen", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4573 drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newrankyellow", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4574 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4575 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4576 } else if(race_status == 3) {
4577 drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newrecordserver", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4578 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4579 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4582 if (race_status_time - time <= 0) {
4583 race_status_prev = -1;
4585 if(race_status_name)
4586 strunzone(race_status_name);
4587 race_status_name = string_null;
4588 if(race_status_name_prev)
4589 strunzone(race_status_name_prev);
4590 race_status_name_prev = string_null;
4594 float mod_prev; // previous state of mod_active to check for a change
4596 float mod_change; // "time" when mod_active changed
4598 void HUD_ModIcons(void)
4600 if(!autocvar_hud_panel_modicons && !autocvar__hud_configure)
4603 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && gametype != GAME_CA && gametype != GAME_FREEZETAG && gametype != GAME_KEEPAWAY && !autocvar__hud_configure)
4606 active_panel = HUD_PANEL_MODICONS;
4607 HUD_Panel_UpdateCvars(modicons);
4610 mySize = panel_size;
4612 if(mod_active != mod_prev) {
4614 mod_prev = mod_active;
4617 if(mod_active || autocvar__hud_configure)
4618 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4620 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4623 HUD_Panel_DrawBg(mod_alpha);
4625 if(panel_bg_padding)
4627 pos += '1 1 0' * panel_bg_padding;
4628 mySize -= '2 2 0' * panel_bg_padding;
4631 // these MUST be ran in order to update mod_active
4632 if(gametype == GAME_KEYHUNT)
4633 HUD_Mod_KH(pos, mySize);
4634 else if(gametype == GAME_CTF || autocvar__hud_configure)
4635 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4636 else if(gametype == GAME_NEXBALL)
4637 HUD_Mod_NexBall(pos, mySize);
4638 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4639 HUD_Mod_Race(pos, mySize);
4640 else if(gametype == GAME_CA || gametype == GAME_FREEZETAG)
4641 HUD_Mod_CA(pos, mySize);
4642 else if(gametype == GAME_KEEPAWAY)
4643 HUD_Mod_Keepaway(pos, mySize);
4646 // Draw pressed keys (#11)
4648 void HUD_DrawPressedKeys(void)
4650 if(!autocvar_hud_panel_pressedkeys && !autocvar__hud_configure)
4653 if(!(spectatee_status > 0 || autocvar_hud_panel_pressedkeys >= 2 || autocvar__hud_configure))
4656 active_panel = HUD_PANEL_PRESSEDKEYS;
4657 HUD_Panel_UpdateCvars(pressedkeys);
4660 mySize = panel_size;
4662 HUD_Panel_DrawBg(1);
4663 if(panel_bg_padding)
4665 pos += '1 1 0' * panel_bg_padding;
4666 mySize -= '2 2 0' * panel_bg_padding;
4669 // force custom aspect
4670 float aspect = autocvar_hud_panel_pressedkeys_aspect;
4674 if(mySize_x/mySize_y > aspect)
4676 newSize_x = aspect * mySize_y;
4677 newSize_y = mySize_y;
4679 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4683 newSize_y = 1/aspect * mySize_x;
4684 newSize_x = mySize_x;
4686 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4692 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4695 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4696 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4697 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);
4698 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);
4699 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);
4700 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);
4701 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);
4704 // Handle chat as a panel (#12)
4708 if(!autocvar_hud_panel_chat && !autocvar__hud_configure)
4710 cvar_set("con_chatrect", "0");
4714 active_panel = HUD_PANEL_CHAT;
4715 HUD_Panel_UpdateCvars(chat);
4717 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
4719 panel_pos_y = panel_bg_border;
4720 panel_size_y = vid_conheight - panel_bg_border * 2;
4721 if(panel_bg == "0") // force a border when maximized
4723 if(precache_pic(panel_bg) == "") {
4724 panel_bg = strcat(hud_skin_path, "/border_default");
4725 if(precache_pic(panel_bg) == "") {
4726 panel_bg = "gfx/hud/default/border_default";
4730 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an alpha of at least 0.75
4735 mySize = panel_size;
4737 HUD_Panel_DrawBg(1);
4739 if(panel_bg_padding)
4741 pos += '1 1 0' * panel_bg_padding;
4742 mySize -= '2 2 0' * panel_bg_padding;
4745 cvar_set("con_chatrect", "1");
4747 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4748 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4750 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4751 cvar_set("con_chat", ftos(floor(mySize_y/autocvar_con_chatsize - 0.5)));
4753 if(autocvar__hud_configure)
4756 chatsize = autocvar_con_chatsize;
4757 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4759 for(i = 0; i < autocvar_con_chat; ++i)
4761 if(i == autocvar_con_chat - 1)
4764 a = panel_fg_alpha * floor(((i + 1) * 7 + autocvar_con_chattime)/45);
4765 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);
4770 // Engine info panel (#13)
4777 float frametimeavg1; // 1 frame ago
4778 float frametimeavg2; // 2 frames ago
4779 void HUD_EngineInfo(void)
4781 if(!autocvar_hud_panel_engineinfo && !autocvar__hud_configure)
4784 active_panel = HUD_PANEL_ENGINEINFO;
4785 HUD_Panel_UpdateCvars(engineinfo);
4788 mySize = panel_size;
4790 HUD_Panel_DrawBg(1);
4791 if(panel_bg_padding)
4793 pos += '1 1 0' * panel_bg_padding;
4794 mySize -= '2 2 0' * panel_bg_padding;
4797 float currentTime = gettime(GETTIME_REALTIME);
4798 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
4800 float currentframetime = currentTime - prevfps_time;
4801 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4802 frametimeavg2 = frametimeavg1;
4803 frametimeavg1 = frametimeavg;
4806 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4807 if(currentframetime > 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.
4809 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/currentframetime) to make big updates instant
4810 prevfps = (1/currentframetime);
4811 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"
4813 prevfps_time = currentTime;
4818 if(currentTime - prevfps_time > autocvar_hud_panel_engineinfo_framecounter_time)
4820 prevfps = framecounter/(currentTime - prevfps_time);
4822 prevfps_time = currentTime;
4827 color = HUD_Get_Num_Color (prevfps, 100);
4828 drawstring_aspect(pos, sprintf(_("FPS: %.*f"), autocvar_hud_panel_engineinfo_framecounter_decimals, prevfps), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4831 // Info messages panel (#14)
4833 #define drawInfoMessage(s)\
4834 if(autocvar_hud_panel_infomessages_flip)\
4835 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);\
4836 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
4838 void HUD_InfoMessages(void)
4840 if(!autocvar_hud_panel_infomessages && !autocvar__hud_configure)
4843 active_panel = HUD_PANEL_INFOMESSAGES;
4844 HUD_Panel_UpdateCvars(infomessages);
4847 mySize = panel_size;
4849 HUD_Panel_DrawBg(1);
4850 if(panel_bg_padding)
4852 pos += '1 1 0' * panel_bg_padding;
4853 mySize -= '2 2 0' * panel_bg_padding;
4856 // always force 5:1 aspect
4858 if(mySize_x/mySize_y > 5)
4860 newSize_x = 5 * mySize_y;
4861 newSize_y = mySize_y;
4863 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4867 newSize_y = 1/5 * mySize_x;
4868 newSize_x = mySize_x;
4870 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4879 fontsize = '0.20 0.20 0' * mySize_y;
4882 if(spectatee_status != 0)
4888 if(!autocvar__hud_configure)
4890 if(spectatee_status && !intermission)
4892 if(spectatee_status == -1)
4893 s = _("^1Observing");
4895 s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(spectatee_status - 1));
4898 if(spectatee_status == -1)
4899 s = sprintf(_("^1Press ^3%s^1 to spectate"), getcommandkey("primary fire", "+fire"));
4901 s = sprintf(_("^1Press ^3%s^1 for another player"), getcommandkey("primary fire", "+fire"));
4904 if(spectatee_status == -1)
4905 s = sprintf(_("^1Use ^3%s^1 or ^3%s^1 to change the speed"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
4907 s = sprintf(_("^1Press ^3%s^1 to observe"), getcommandkey("secondary fire", "+fire2"));
4910 s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey("server info", "+show_info"));
4913 if(gametype == GAME_ARENA)
4914 s = _("^1Wait for your turn to join");
4915 else if(gametype == GAME_LMS)
4918 sk = playerslots[player_localentnum - 1];
4919 if(sk.(scores[ps_primary]) >= 666)
4920 s = _("^1Match has already begun");
4921 else if(sk.(scores[ps_primary]) > 0)
4922 s = _("^1You have no more lives left");
4924 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
4927 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
4930 //show restart countdown:
4931 if (time < getstatf(STAT_GAMESTARTTIME)) {
4933 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4934 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4935 s = sprintf(_("^1Game starts in ^3%d^1 seconds"), countdown);
4936 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4940 if(warmup_stage && !intermission)
4942 s = _("^2Currently in ^1warmup^2 stage!");
4947 if(mod(time, 1) >= 0.5)
4952 if(ready_waiting && !intermission && !spectatee_status)
4954 if(ready_waiting_for_me)
4957 s = sprintf(_("%sPress ^3%s%s to end warmup"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
4959 s = sprintf(_("%sPress ^3%s%s once you are ready"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
4964 s = _("^2Waiting for others to ready up to end warmup...");
4966 s = _("^2Waiting for others to ready up...");
4970 else if(warmup_stage && !intermission && !spectatee_status)
4972 s = sprintf(_("^2Press ^3%s^2 to end warmup"), getcommandkey("ready", "ready"));
4976 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4978 float ts_min, ts_max;
4979 tm = teams.sort_next;
4982 for(; tm.sort_next; tm = tm.sort_next)
4984 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4986 if(!ts_min) ts_min = tm.team_size;
4987 else ts_min = min(ts_min, tm.team_size);
4988 if(!ts_max) ts_max = tm.team_size;
4989 else ts_max = max(ts_max, tm.team_size);
4991 if ((ts_max - ts_min) > 1)
4993 s = strcat(blinkcolor, _("Teamnumbers are unbalanced!"));
4994 tm = GetTeam(myteam, false);
4996 if (tm.team != COLOR_SPECTATOR)
4997 if (tm.team_size == ts_max)
4998 s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey("team menu", "menu_showteamselect"), blinkcolor));
5006 s = _("^7Press ^3ESC ^7to show HUD options.");
5008 s = _("^3Doubleclick ^7a panel for panel-specific options.");
5010 s = _("^3CTRL ^7to disable collision testing, ^3SHIFT ^7and");
5012 s = _("^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.");
5023 void HUD_ShowSpeed(void)
5026 float pos, conversion_factor;
5027 string speed, zspeed, unit;
5029 switch(autocvar_cl_showspeed_unit)
5034 conversion_factor = 1.0;
5038 conversion_factor = 1.0;
5042 conversion_factor = 0.0254;
5046 conversion_factor = 0.0254 * 3.6;
5050 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
5054 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
5058 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
5060 numsize_x = numsize_y = autocvar_cl_showspeed_size;
5061 pos = (vid_conheight - numsize_y) * autocvar_cl_showspeed_position;
5063 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
5065 if (autocvar_cl_showspeed_z == 1) {
5066 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
5067 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
5071 vector acc_prevspeed;
5075 void HUD_ShowAcceleration(void)
5077 float acceleration, sz, scale, alpha, f;
5078 vector pos, top, rgb;
5079 top_x = vid_conwidth/2;
5082 f = time - acc_prevtime;
5083 if(autocvar_cl_showacceleration_z)
5084 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
5086 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
5087 acc_prevspeed = pmove_vel;
5088 acc_prevtime = time;
5090 f = bound(0, f * 10, 1);
5091 acc_avg = acc_avg * (1 - f) + acceleration * f;
5092 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
5093 if (acceleration == 0)
5096 pos = top - sz/2 * eY + (autocvar_cl_showacceleration_position * vid_conheight) * eY;
5098 sz = autocvar_cl_showacceleration_size;
5099 scale = autocvar_cl_showacceleration_scale;
5100 alpha = autocvar_cl_showacceleration_alpha;
5101 if (autocvar_cl_showacceleration_color_custom)
5102 rgb = stov(autocvar_cl_showacceleration_color);
5104 if (acceleration < 0)
5105 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
5107 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
5110 if (acceleration > 0)
5111 HUD_Panel_DrawProgressBar(pos, eX * (vid_conwidth - pos_x) + eY * sz, "accelbar", 0, 0, acceleration * scale, rgb, alpha * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
5113 HUD_Panel_DrawProgressBar(eY * pos_y, eX * pos_x + eY * sz, "accelbar", 0, 1, -acceleration * scale, rgb, alpha * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
5116 void HUD_Reset (void)
5118 // reset gametype specific icons
5119 if(gametype == GAME_KEYHUNT)
5121 else if(gametype == GAME_CTF)
5122 HUD_Mod_CTF_Reset();
5125 #define HUD_DrawPanel(id)\
5127 case (HUD_PANEL_RADAR):\
5128 HUD_Radar(); break;\
5129 case (HUD_PANEL_WEAPONS):\
5130 HUD_Weapons(); break;\
5131 case (HUD_PANEL_AMMO):\
5133 case (HUD_PANEL_POWERUPS):\
5134 HUD_Powerups(); break;\
5135 case (HUD_PANEL_HEALTHARMOR):\
5136 HUD_HealthArmor(); break;\
5137 case (HUD_PANEL_NOTIFY):\
5138 HUD_Notify(); break;\
5139 case (HUD_PANEL_TIMER):\
5140 HUD_Timer(); break;\
5141 case (HUD_PANEL_SCORE):\
5142 HUD_Score(); break;\
5143 case (HUD_PANEL_RACETIMER):\
5144 HUD_RaceTimer(); break;\
5145 case (HUD_PANEL_VOTE):\
5146 HUD_VoteWindow(); break;\
5147 case (HUD_PANEL_MODICONS):\
5148 HUD_ModIcons(); break;\
5149 case (HUD_PANEL_PRESSEDKEYS):\
5150 HUD_DrawPressedKeys(); break;\
5151 case (HUD_PANEL_CHAT):\
5153 case (HUD_PANEL_ENGINEINFO):\
5154 HUD_EngineInfo(); break;\
5155 case (HUD_PANEL_INFOMESSAGES):\
5156 HUD_InfoMessages(); break;\
5157 } ENDS_WITH_CURLY_BRACE
5159 void HUD_Main (void)
5162 // global hud alpha fade
5163 if(menu_enabled == 1)
5166 hud_fade_alpha = (1 - autocvar__menu_alpha);
5168 if(scoreboard_fade_alpha)
5169 hud_fade_alpha = (1 - scoreboard_fade_alpha);
5171 if(intermission == 2) // no hud during mapvote
5173 else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
5176 hud_fontsize = HUD_GetFontsize("hud_fontsize");
5178 if(!autocvar__hud_configure && !hud_fade_alpha)
5182 if (hud_skin_path != autocvar_hud_skin)
5185 strunzone(hud_skin_path);
5186 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
5189 // HUD configure visible grid
5190 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
5193 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2); ++i)
5195 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);
5198 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2); ++i)
5200 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);
5204 current_player = (spectatee_status > 0) ? spectatee_status : player_localentnum;
5207 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
5211 float hud_dock_color_team = autocvar_hud_dock_color_team;
5212 if((teamplay) && hud_dock_color_team) {
5213 f = stof(getplayerkey(current_player - 1, "colors"));
5214 color = colormapPaletteColor(mod(f, 16), 1) * hud_dock_color_team;
5216 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
5217 color = '1 0 0' * hud_dock_color_team;
5221 string hud_dock_color = autocvar_hud_dock_color;
5222 if(hud_dock_color == "shirt") {
5223 f = stof(getplayerkey(current_player - 1, "colors"));
5224 color = colormapPaletteColor(floor(f / 16), 0);
5226 else if(hud_dock_color == "pants") {
5227 f = stof(getplayerkey(current_player - 1, "colors"));
5228 color = colormapPaletteColor(mod(f, 16), 1);
5231 color = stov(hud_dock_color);
5235 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
5236 if(precache_pic(pic) == "") {
5237 pic = strcat(hud_skin_path, "/dock_medium");
5238 if(precache_pic(pic) == "") {
5239 pic = "gfx/hud/default/dock_medium";
5242 drawpic('0 0 0', pic, eX * vid_conwidth + eY * vid_conheight, color, autocvar_hud_dock_alpha * hud_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
5245 // cache the panel order into the panel_order array
5246 if(autocvar__hud_panelorder != hud_panelorder_prev) {
5247 if(hud_panelorder_prev)
5248 strunzone(hud_panelorder_prev);
5249 hud_panelorder_prev = strzone(autocvar__hud_panelorder);
5250 tokenize_console(autocvar__hud_panelorder);
5251 for(i = 0; i < HUD_PANEL_NUM; ++i) {
5252 panel_order[i] = stof(argv(i));
5255 // draw panels in order specified by panel_order array
5256 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
5257 if(i != HUD_PANEL_CHAT || !autocvar__con_chat_maximized) // don't draw maximized chat panel twice!
5258 HUD_DrawPanel(panel_order[i]);
5261 // draw chat panel on top if it is maximized
5262 if(autocvar__con_chat_maximized)
5263 HUD_Chat(); // HUD_DrawPanel(HUD_PANEL_CHAT);
5265 // TODO hud_'ify these
5266 if (autocvar_cl_showspeed)
5268 if (autocvar_cl_showacceleration)
5269 HUD_ShowAcceleration();
5271 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)
5272 localcmd("cmd selectteam auto; cmd join\n");
5274 hud_configure_prev = autocvar__hud_configure;
5276 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again