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)
98 else if(x > maxvalue * 0.75) {
99 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
100 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
103 else if(x > maxvalue * 0.5) {
104 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
105 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
106 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
108 else if(x > maxvalue * 0.25) {
111 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
113 else if(x > maxvalue * 0.1) {
115 color_y = (x-20)*90/27/100; // green value between 0 -> 1
116 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
126 float stringwidth_colors(string s, vector theSize)
128 return stringwidth(s, TRUE, theSize);
131 float stringwidth_nocolors(string s, vector theSize)
133 return stringwidth(s, FALSE, theSize);
136 #define CENTERPRINT_MAX_LINES 30
137 string centerprint_messages[CENTERPRINT_MAX_LINES];
138 float centerprint_width[CENTERPRINT_MAX_LINES];
139 float centerprint_time;
140 float centerprint_expire;
141 float centerprint_num;
142 float centerprint_offset_hint;
143 vector centerprint_fontsize;
145 void centerprint(string strMessage)
147 float i, j, n, hcount;
150 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
152 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
154 if(autocvar_scr_centertime <= 0)
160 // strip trailing newlines
161 j = strlen(strMessage) - 1;
162 while(substring(strMessage, j, 1) == "\n" && j >= 0)
164 strMessage = substring(strMessage, 0, j + 1);
169 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
171 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
173 strMessage = substring(strMessage, j, strlen(strMessage) - j);
174 centerprint_offset_hint = j;
179 // if we get here, we have a message. Initialize its height.
182 n = tokenizebyseparator(strMessage, "\n");
184 for(j = 0; j < n; ++j)
186 getWrappedLine_remaining = argv(j);
187 while(getWrappedLine_remaining)
189 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
190 if(centerprint_messages[i] != s) // don't fade the same message in, looks stupid
191 centerprint_time = time;
192 if(centerprint_messages[i])
193 strunzone(centerprint_messages[i]);
194 centerprint_messages[i] = strzone(s);
195 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
198 // half height for empty lines looks better
204 if(i >= CENTERPRINT_MAX_LINES)
210 h = centerprint_fontsize_y*hcount;
212 havail = vid_conheight;
213 if(autocvar_con_chatpos < 0)
214 havail -= (-autocvar_con_chatpos + autocvar_con_chat) * autocvar_con_chatsize; // avoid overlapping chat
215 if(havail > vid_conheight - 70)
216 havail = vid_conheight - 70; // avoid overlapping HUD
219 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
221 // here, the centerprint would cover the crosshair. REALLY BAD.
222 forbiddenmin = vid_conheight * 0.5 - h - 16;
223 forbiddenmax = vid_conheight * 0.5 + 16;
225 allowedmin = scoreboard_bottom;
226 allowedmax = havail - h;
227 preferred = (havail - h)/2;
230 // possible orderings (total: 4! / 4 = 6)
231 // allowedmin allowedmax forbiddenmin forbiddenmax
232 // forbiddenmin forbiddenmax allowedmin allowedmax
233 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
235 // forbidden doesn't matter in this case
236 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
238 // allowedmin forbiddenmin allowedmax forbiddenmax
239 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
241 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
243 // allowedmin forbiddenmin forbiddenmax allowedmax
244 else if(allowedmin < forbiddenmin)
246 // make sure the forbidden zone is not covered
247 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
248 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
250 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
252 // forbiddenmin allowedmin allowedmax forbiddenmax
253 else if(allowedmax < forbiddenmax)
255 // it's better to leave the allowed zone (overlap with scoreboard) than
256 // to cover the forbidden zone (crosshair)
257 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
258 centerprint_start_y = forbiddenmax;
260 centerprint_start_y = forbiddenmin;
262 // forbiddenmin allowedmin forbiddenmax allowedmax
265 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
272 centerprint_expire = time + autocvar_scr_centertime;
275 void HUD_DrawCenterPrint (void)
282 if(time - centerprint_time < 0.25)
283 a = (time - centerprint_time) / 0.25;
285 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
292 if(centerprint_num * autocvar_scr_centersize > 24 && scoreboard_active) // 24 = height of Scoreboard text
293 centerprint_start_y = scoreboard_bottom + centerprint_fontsize_y;
295 pos = centerprint_start;
296 for (i=0; i<centerprint_num; i = i + 1)
298 ts = centerprint_messages[i];
299 drawfontscale = sz * '1 1 0';
300 pos_x = (vid_conwidth - stringwidth(ts, TRUE, centerprint_fontsize)) * 0.5;
303 drawcolorcodedstring(pos + '0 1 0' * (1 - sz) * 0.5 *centerprint_fontsize_y, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
304 pos_y = pos_y + centerprint_fontsize_y;
307 // half height for empty lines looks better
308 pos_y = pos_y + sz * centerprint_fontsize_y * 0.5;
309 drawfontscale = '1 1 0';
313 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
315 position_x -= 2 / 3 * strlen(text) * scale_x;
316 drawstring(position, text, scale, rgb, alpha, flag);
319 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
321 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
322 drawstring(position, text, scale, rgb, alpha, flag);
325 // return the string of the given race place
326 string race_PlaceName(float pos) {
334 return sprintf(_("%dth"), pos);
337 // return the string of the onscreen race timer
338 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
346 if(histime == 0) // goal hit
350 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
360 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
366 lapstr = sprintf(_(" (-%dL)"), lapdelta);
369 else if(lapdelta < 0)
371 lapstr = sprintf(_(" (+%dL)"), -lapdelta);
375 else if(histime > 0) // anticipation
377 if(mytime >= histime)
378 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
380 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
387 cpname = _("Start line");
389 cpname = _("Finish line");
391 cpname = sprintf(_("Intermediate %d"), cp);
393 cpname = _("Finish line");
396 return strcat(col, cpname);
397 else if(hisname == "")
398 return strcat(col, sprintf(_("%s (%s)"), cpname, timestr));
400 return strcat(col, sprintf(_("%s (%s %s)"), cpname, timestr, strcat(hisname, col, lapstr)));
403 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
404 float race_CheckName(string net_name) {
406 for (i=RANKINGS_CNT-1;i>=0;--i)
407 if(grecordholder[i] == net_name)
418 #define HUD_Write(s) fputs(fh, s)
419 // q: quoted, n: not quoted
420 #define HUD_Write_Cvar_n(cvar) HUD_Write(strcat("seta ", cvar, " ", cvar_string(cvar), "\n"))
421 #define HUD_Write_Cvar_q(cvar) HUD_Write(strcat("seta ", cvar, " \"", cvar_string(cvar), "\"\n"))
422 #define HUD_Write_PanelCvar_n(cvar_suf) HUD_Write_Cvar_n(strcat("hud_panel_", panel_name, cvar_suf))
423 #define HUD_Write_PanelCvar_q(cvar_suf) HUD_Write_Cvar_q(strcat("hud_panel_", panel_name, cvar_suf))
425 void HUD_Panel_ExportCfg(string cfgname)
428 string filename = strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg");
429 fh = fopen(filename, FILE_WRITE);
432 HUD_Write_Cvar_q("hud_skin");
433 HUD_Write_Cvar_q("hud_panel_bg");
434 HUD_Write_Cvar_q("hud_panel_bg_color");
435 HUD_Write_Cvar_q("hud_panel_bg_color_team");
436 HUD_Write_Cvar_q("hud_panel_bg_alpha");
437 HUD_Write_Cvar_q("hud_panel_bg_border");
438 HUD_Write_Cvar_q("hud_panel_bg_padding");
439 HUD_Write_Cvar_q("hud_panel_fg_alpha");
442 HUD_Write_Cvar_q("hud_dock");
443 HUD_Write_Cvar_q("hud_dock_color");
444 HUD_Write_Cvar_q("hud_dock_color_team");
445 HUD_Write_Cvar_q("hud_dock_alpha");
448 HUD_Write_Cvar_q("hud_progressbar_alpha");
449 HUD_Write_Cvar_q("hud_progressbar_strength_color");
450 HUD_Write_Cvar_q("hud_progressbar_shield_color");
451 HUD_Write_Cvar_q("hud_progressbar_health_color");
452 HUD_Write_Cvar_q("hud_progressbar_armor_color");
453 HUD_Write_Cvar_q("hud_progressbar_fuel_color");
454 HUD_Write_Cvar_q("hud_progressbar_nexball_color");
457 HUD_Write_Cvar_q("_hud_panelorder");
460 HUD_Write_Cvar_q("hud_configure_grid");
461 HUD_Write_Cvar_q("hud_configure_grid_xsize");
462 HUD_Write_Cvar_q("hud_configure_grid_ysize");
465 HUD_Write_Cvar_q("scr_centerpos");
468 // common cvars for all panels
470 for (i = 0; i < HUD_PANEL_NUM; ++i)
472 HUD_Panel_GetName(i);
474 HUD_Write_PanelCvar_n("");
475 HUD_Write_PanelCvar_q("_pos");
476 HUD_Write_PanelCvar_q("_size");
477 HUD_Write_PanelCvar_q("_bg");
478 HUD_Write_PanelCvar_q("_bg_color");
479 HUD_Write_PanelCvar_q("_bg_color_team");
480 HUD_Write_PanelCvar_q("_bg_alpha");
481 HUD_Write_PanelCvar_q("_bg_border");
482 HUD_Write_PanelCvar_q("_bg_padding");
484 case HUD_PANEL_WEAPONS:
485 HUD_Write_PanelCvar_q("_complainbubble");
486 HUD_Write_PanelCvar_q("_complainbubble_padding");
487 HUD_Write_PanelCvar_q("_complainbubble_color_outofammo");
488 HUD_Write_PanelCvar_q("_complainbubble_color_donthave");
489 HUD_Write_PanelCvar_q("_complainbubble_color_unavailable");
490 HUD_Write_PanelCvar_q("_ammo_color");
491 HUD_Write_PanelCvar_q("_ammo_alpha");
492 HUD_Write_PanelCvar_q("_aspect");
493 HUD_Write_PanelCvar_q("_timeout");
494 HUD_Write_PanelCvar_q("_timeout_effect");
497 HUD_Write_PanelCvar_q("_onlycurrent");
498 HUD_Write_PanelCvar_q("_iconalign");
499 HUD_Write_PanelCvar_q("_progressbar");
500 HUD_Write_PanelCvar_q("_progressbar_name");
501 HUD_Write_PanelCvar_q("_progressbar_xoffset");
502 HUD_Write_PanelCvar_q("_text");
504 case HUD_PANEL_POWERUPS:
505 HUD_Write_PanelCvar_q("_flip");
506 HUD_Write_PanelCvar_q("_iconalign");
507 HUD_Write_PanelCvar_q("_baralign");
508 HUD_Write_PanelCvar_q("_progressbar");
509 HUD_Write_PanelCvar_q("_progressbar_strength");
510 HUD_Write_PanelCvar_q("_progressbar_shield");
511 HUD_Write_PanelCvar_q("_text");
513 case HUD_PANEL_HEALTHARMOR:
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_health");
519 HUD_Write_PanelCvar_q("_progressbar_armor");
520 HUD_Write_PanelCvar_q("_text");
522 case HUD_PANEL_NOTIFY:
523 HUD_Write_PanelCvar_q("_flip");
524 HUD_Write_PanelCvar_q("_fontsize");
525 HUD_Write_PanelCvar_q("_print");
527 case HUD_PANEL_RADAR:
528 HUD_Write_PanelCvar_q("_foreground_alpha");
531 HUD_Write_PanelCvar_q("_alreadyvoted_alpha");
533 case HUD_PANEL_PRESSEDKEYS:
534 HUD_Write_PanelCvar_q("_aspect");
536 case HUD_PANEL_INFOMESSAGES:
537 HUD_Write_PanelCvar_q("_flip");
542 HUD_Write("menu_sync\n"); // force the menu to reread the cvars, so that the dialogs are updated
544 print(sprintf(_("^2Successfully exported to %s! (Note: It's saved in data/data/)\n"), filename));
548 print(sprintf(_("^1Couldn't write to %s\n"), filename));
551 const float hlBorderSize = 4;
552 const string hlBorder = "gfx/hud/default/border_highlighted";
553 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
554 void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
556 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
557 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);
558 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);
559 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);
560 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);
563 // draw the background/borders
564 #define HUD_Panel_DrawBg(alpha)\
566 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));\
567 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
569 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);\
570 } ENDS_WITH_CURLY_BRACE
572 void HUD_Panel_DrawProgressBar(vector pos, vector mySize, string pic, float vertical, float barflip, float x, vector color, float alpha, float drawflag)
580 pic = strcat(hud_skin_path, "/", pic, "_vertical");
581 if(precache_pic(pic) == "") {
582 pic = "gfx/hud/default/statusbar_vertical";
586 drawsetcliparea(pos_x, pos_y + mySize_y * (1 - x), mySize_x, mySize_y * x);
588 drawsetcliparea(pos_x, pos_y, mySize_x, mySize_y * x);
590 pic = strcat(hud_skin_path, "/", pic);
591 if(precache_pic(pic) == "") {
592 pic = "gfx/hud/default/statusbar";
596 drawsetcliparea(pos_x + mySize_x * (1 - x), pos_y, mySize_x * x, mySize_y);
598 drawsetcliparea(pos_x, pos_y, mySize_x * x, mySize_y);
601 drawpic(pos, pic, mySize, color, alpha, drawflag);
605 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
611 pic = strcat(hud_skin_path, "/num_leading");
612 if(precache_pic(pic) == "") {
613 pic = "gfx/hud/default/num_leading";
616 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
617 if(mySize_x/mySize_y > 2)
618 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);
619 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);
622 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
623 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
632 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
633 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
635 for (i = 0; i < HUD_PANEL_NUM; ++i) {
636 if(i == highlightedPanel || !panel_enabled)
639 HUD_Panel_UpdatePosSizeForId(i);
641 panel_pos -= '1 1 0' * panel_bg_border;
642 panel_size += '2 2 0' * panel_bg_border;
644 if(myPos_y + mySize_y < panel_pos_y)
646 if(myPos_y > panel_pos_y + panel_size_y)
649 if(myPos_x + mySize_x < panel_pos_x)
651 if(myPos_x > panel_pos_x + panel_size_x)
654 // OK, there IS a collision.
656 myCenter_x = myPos_x + 0.5 * mySize_x;
657 myCenter_y = myPos_y + 0.5 * mySize_y;
659 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
660 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
662 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
664 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
665 myTarget_x = panel_pos_x - mySize_x;
666 else // push it upwards
667 myTarget_y = panel_pos_y - mySize_y;
669 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
671 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
672 myTarget_x = panel_pos_x + panel_size_x;
673 else // push it upwards
674 myTarget_y = panel_pos_y - mySize_y;
676 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
678 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
679 myTarget_x = panel_pos_x - mySize_x;
680 else // push it downwards
681 myTarget_y = panel_pos_y + panel_size_y;
683 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
685 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
686 myTarget_x = panel_pos_x + panel_size_x;
687 else // push it downwards
688 myTarget_y = panel_pos_y + panel_size_y;
690 //if(cvar("hud_configure_checkcollisions_debug"))
691 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
697 void HUD_Panel_SetPos(vector pos)
699 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
703 //if(cvar("hud_configure_checkcollisions_debug"))
704 //drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
706 if(autocvar_hud_configure_grid)
708 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;
709 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;
712 if(hud_configure_checkcollisions)
713 pos = HUD_Panel_CheckMove(pos, mySize);
715 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
716 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
719 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
721 HUD_Panel_GetName(highlightedPanel);
722 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
725 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
726 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
731 float dist_x, dist_y;
733 ratio = mySize_x/mySize_y;
735 for (i = 0; i < HUD_PANEL_NUM; ++i) {
736 if(i == highlightedPanel || !panel_enabled)
739 HUD_Panel_UpdatePosSizeForId(i);
741 panel_pos -= '1 1 0' * panel_bg_border;
742 panel_size += '2 2 0' * panel_bg_border;
744 targEndPos = panel_pos + panel_size;
746 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
747 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
750 if (resizeCorner == 1)
752 // check if this panel is on our way
753 if (resizeorigin_x <= panel_pos_x)
755 if (resizeorigin_y <= panel_pos_y)
757 if (targEndPos_x <= resizeorigin_x - mySize_x)
759 if (targEndPos_y <= resizeorigin_y - mySize_y)
762 // there is a collision:
763 // detect which side of the panel we are facing is actually limiting the resizing
764 // (which side the resize direction finds for first) and reduce the size up to there
766 // dist is the distance between resizeorigin and the "analogous" point of the panel
767 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
768 dist_x = resizeorigin_x - targEndPos_x;
769 dist_y = resizeorigin_y - targEndPos_y;
770 if (dist_y <= 0 || dist_x / dist_y > ratio)
771 mySize_x = min(mySize_x, dist_x);
773 mySize_y = min(mySize_y, dist_y);
775 else if (resizeCorner == 2)
777 if (resizeorigin_x >= targEndPos_x)
779 if (resizeorigin_y <= panel_pos_y)
781 if (panel_pos_x >= resizeorigin_x + mySize_x)
783 if (targEndPos_y <= resizeorigin_y - mySize_y)
786 dist_x = panel_pos_x - resizeorigin_x;
787 dist_y = resizeorigin_y - targEndPos_y;
788 if (dist_y <= 0 || dist_x / dist_y > ratio)
789 mySize_x = min(mySize_x, dist_x);
791 mySize_y = min(mySize_y, dist_y);
793 else if (resizeCorner == 3)
795 if (resizeorigin_x <= panel_pos_x)
797 if (resizeorigin_y >= targEndPos_y)
799 if (targEndPos_x <= resizeorigin_x - mySize_x)
801 if (panel_pos_y >= resizeorigin_y + mySize_y)
804 dist_x = resizeorigin_x - targEndPos_x;
805 dist_y = panel_pos_y - resizeorigin_y;
806 if (dist_y <= 0 || dist_x / dist_y > ratio)
807 mySize_x = min(mySize_x, dist_x);
809 mySize_y = min(mySize_y, dist_y);
811 else if (resizeCorner == 4)
813 if (resizeorigin_x >= targEndPos_x)
815 if (resizeorigin_y >= targEndPos_y)
817 if (panel_pos_x >= resizeorigin_x + mySize_x)
819 if (panel_pos_y >= resizeorigin_y + mySize_y)
822 dist_x = panel_pos_x - resizeorigin_x;
823 dist_y = panel_pos_y - resizeorigin_y;
824 if (dist_y <= 0 || dist_x / dist_y > ratio)
825 mySize_x = min(mySize_x, dist_x);
827 mySize_y = min(mySize_y, dist_y);
829 //if(cvar("hud_configure_checkcollisions_debug"))
830 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
836 void HUD_Panel_SetPosSize(vector mySize)
838 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
840 resizeorigin = panel_click_resizeorigin;
843 // minimum panel size cap
844 mySize_x = max(0.025 * vid_conwidth, mySize_x);
845 mySize_y = max(0.025 * vid_conheight, mySize_y);
847 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.
849 mySize_x = max(17 * autocvar_con_chatsize, mySize_x);
850 mySize_y = max(2 * autocvar_con_chatsize + 2 * panel_bg_padding, mySize_y);
853 // collision testing|
854 // -----------------+
856 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
857 if(resizeCorner == 1) {
858 myPos_x = resizeorigin_x - mySize_x;
859 myPos_y = resizeorigin_y - mySize_y;
860 } else if(resizeCorner == 2) {
861 myPos_x = resizeorigin_x;
862 myPos_y = resizeorigin_y - mySize_y;
863 } else if(resizeCorner == 3) {
864 myPos_x = resizeorigin_x - mySize_x;
865 myPos_y = resizeorigin_y;
866 } else { // resizeCorner == 4
867 myPos_x = resizeorigin_x;
868 myPos_y = resizeorigin_y;
871 // left/top screen edges
873 mySize_x = mySize_x + myPos_x;
875 mySize_y = mySize_y + myPos_y;
877 // bottom/right screen edges
878 if(myPos_x + mySize_x > vid_conwidth)
879 mySize_x = vid_conwidth - myPos_x;
880 if(myPos_y + mySize_y > vid_conheight)
881 mySize_y = vid_conheight - myPos_y;
883 //if(cvar("hud_configure_checkcollisions_debug"))
884 //drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
886 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
887 if(autocvar_hud_configure_grid)
889 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;
890 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;
893 if(hud_configure_checkcollisions)
894 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
896 // 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)
897 mySize_x = max(0.025 * vid_conwidth, mySize_x);
898 mySize_y = max(0.025 * vid_conheight, mySize_y);
900 // do another pos check, as size might have changed by now
901 if(resizeCorner == 1) {
902 myPos_x = resizeorigin_x - mySize_x;
903 myPos_y = resizeorigin_y - mySize_y;
904 } else if(resizeCorner == 2) {
905 myPos_x = resizeorigin_x;
906 myPos_y = resizeorigin_y - mySize_y;
907 } else if(resizeCorner == 3) {
908 myPos_x = resizeorigin_x - mySize_x;
909 myPos_y = resizeorigin_y;
910 } else { // resizeCorner == 4
911 myPos_x = resizeorigin_x;
912 myPos_y = resizeorigin_y;
915 //if(cvar("hud_configure_checkcollisions_debug"))
916 //drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
918 HUD_Panel_GetName(highlightedPanel);
920 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
921 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
923 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
924 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
928 float prevMouseClicked; // previous state
929 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
930 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
932 float pressed_key_time;
933 void HUD_Panel_Arrow_Action(float nPrimary)
935 if (highlightedPanel_prev == -1 || mouseClicked)
938 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
941 if(autocvar_hud_configure_grid)
943 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
945 if (hudShiftState & S_SHIFT)
946 step = bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
948 step = 2 * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
952 if (hudShiftState & S_SHIFT)
953 step = bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
955 step = 2 * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
960 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
961 step = vid_conheight;
964 if (hudShiftState & S_SHIFT)
965 step = (step / 256); // more precision
967 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
970 highlightedPanel = highlightedPanel_prev;
972 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
974 vector prev_pos, prev_size;
975 prev_pos = panel_pos;
976 prev_size = panel_size;
978 if (hudShiftState & S_ALT) // resize
980 highlightedAction = 1;
981 if(nPrimary == K_UPARROW)
983 else if(nPrimary == K_RIGHTARROW)
985 else if(nPrimary == K_LEFTARROW)
987 else // if(nPrimary == K_DOWNARROW)
990 // ctrl+arrow reduces the size, instead of increasing it
991 // Note that ctrl disables collisions check too, but it's fine
992 // since we don't collide with anything reducing the size
993 if (hudShiftState & S_CTRL) {
995 resizeCorner = 5 - resizeCorner;
1000 panel_click_resizeorigin = panel_pos;
1001 if(resizeCorner == 1) {
1002 panel_click_resizeorigin += mySize;
1004 } else if(resizeCorner == 2) {
1005 panel_click_resizeorigin_y += mySize_y;
1007 } else if(resizeCorner == 3) {
1008 panel_click_resizeorigin_x += mySize_x;
1010 } else { // resizeCorner == 4
1013 HUD_Panel_SetPosSize(mySize);
1017 highlightedAction = 2;
1020 if(nPrimary == K_UPARROW)
1022 else if(nPrimary == K_DOWNARROW)
1024 else if(nPrimary == K_LEFTARROW)
1026 else // if(nPrimary == K_RIGHTARROW)
1029 HUD_Panel_SetPos(pos);
1032 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
1034 if (prev_pos != panel_pos || prev_size != panel_size)
1037 panel_pos_backup = prev_pos;
1038 panel_size_backup = prev_size;
1039 highlightedPanel_backup = highlightedPanel;
1043 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1047 if(!autocvar__hud_configure)
1050 // allow console bind to work
1053 con_keys = findkeysforcommand("toggleconsole");
1054 keys = tokenize(con_keys);
1056 float hit_con_bind, i;
1057 for (i = 0; i < keys; ++i)
1059 if(nPrimary == stof(argv(i)))
1063 if(bInputType == 0) {
1064 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1065 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1066 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1068 else if(bInputType == 1) {
1069 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1070 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1071 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1074 if(nPrimary == K_MOUSE1)
1076 if(bInputType == 0) { // key pressed
1080 else if(bInputType == 1) {// key released
1085 else if(nPrimary == K_ESCAPE)
1087 if (bInputType == 1)
1090 menu_enabled_time = time;
1091 localcmd("menu_showhudexit\n");
1093 else if(hudShiftState & S_CTRL)
1098 if(nPrimary == K_SPACE) // enable/disable highlighted panel or dock
1100 if (bInputType == 1)
1103 if (highlightedPanel_prev != -1)
1104 cvar_set(strcat("hud_panel_", panel_name), ftos(!(panel_enabled)));
1106 cvar_set(strcat("hud_dock"), (autocvar_hud_dock == "") ? "dock" : "");
1108 if(nPrimary == 'c') // copy highlighted panel size
1110 if (bInputType == 1)
1113 if (highlightedPanel_prev != -1)
1115 panel_size_copied = panel_size;
1116 highlightedPanel_copied = highlightedPanel_prev;
1119 else if(nPrimary == 'v') // past copied size on the highlighted panel
1121 if (bInputType == 1)
1124 if (highlightedPanel_copied == -1 || highlightedPanel_prev == -1)
1127 HUD_Panel_UpdatePosSizeForId(highlightedPanel_prev);
1129 // reduce size if it'd go beyond screen boundaries
1130 vector tmp_size = panel_size_copied;
1131 if (panel_pos_x + panel_size_copied_x > vid_conwidth)
1132 tmp_size_x = vid_conwidth - panel_pos_x;
1133 if (panel_pos_y + panel_size_copied_y > vid_conheight)
1134 tmp_size_y = vid_conheight - panel_pos_y;
1136 if (panel_size == tmp_size)
1140 panel_pos_backup = panel_pos;
1141 panel_size_backup = panel_size;
1142 highlightedPanel_backup = highlightedPanel_prev;
1144 s = strcat(ftos(tmp_size_x/vid_conwidth), " ", ftos(tmp_size_y/vid_conheight));
1145 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
1147 else if(nPrimary == 'z') // undo last action
1149 if (bInputType == 1)
1151 //restore previous values
1152 if (highlightedPanel_backup != -1)
1154 HUD_Panel_GetName(highlightedPanel_backup);
1155 s = strcat(ftos(panel_pos_backup_x/vid_conwidth), " ", ftos(panel_pos_backup_y/vid_conheight));
1156 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
1157 s = strcat(ftos(panel_size_backup_x/vid_conwidth), " ", ftos(panel_size_backup_y/vid_conheight));
1158 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
1159 highlightedPanel_backup = -1;
1163 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1165 if (bInputType == 1)
1167 pressed_key_time = 0;
1170 else if (pressed_key_time == 0)
1171 pressed_key_time = time;
1173 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1175 else if(hit_con_bind)
1178 return true; // Suppress ALL other input
1181 float HUD_Panel_HighlightCheck()
1187 while(j <= HUD_PANEL_NUM)
1192 HUD_Panel_UpdatePosSizeForId(i);
1194 panelPos = panel_pos;
1195 panelSize = panel_size;
1196 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1199 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1203 // resize from topleft border
1204 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)
1208 // resize from topright border
1209 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)
1213 // resize from bottomleft border
1214 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)
1218 // resize from bottomright border
1219 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)
1227 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1228 void HUD_Panel_FirstInDrawQ(float id)
1231 var float place = -1;
1232 // find out where in the array our current id is, save into place
1233 for(i = 0; i < HUD_PANEL_NUM; ++i)
1235 if(panel_order[i] == id)
1241 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1243 place = HUD_PANEL_NUM - 1;
1245 // move all ids up by one step in the array until "place"
1246 for(i = place; i > 0; --i)
1248 panel_order[i] = panel_order[i-1];
1250 // now save the new top id
1251 panel_order[0] = id;
1253 // let's save them into the cvar by some strcat trickery
1255 for(i = 0; i < HUD_PANEL_NUM; ++i)
1257 s = strcat(s, ftos(panel_order[i]), " ");
1259 cvar_set("_hud_panelorder", s);
1260 if(hud_panelorder_prev)
1261 strunzone(hud_panelorder_prev);
1262 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1265 void HUD_Panel_Highlight()
1271 while(j <= HUD_PANEL_NUM)
1276 HUD_Panel_UpdatePosSizeForId(i);
1278 panelPos = panel_pos;
1279 panelSize = panel_size;
1280 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1283 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1285 highlightedPanel = i;
1286 HUD_Panel_FirstInDrawQ(i);
1287 highlightedAction = 1;
1288 panel_click_distance = mousepos - panelPos;
1291 // resize from topleft border
1292 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)
1294 highlightedPanel = i;
1295 HUD_Panel_FirstInDrawQ(i);
1296 highlightedAction = 2;
1298 panel_click_distance = mousepos - panelPos;
1299 panel_click_resizeorigin = panelPos + panelSize;
1302 // resize from topright border
1303 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)
1305 highlightedPanel = i;
1306 HUD_Panel_FirstInDrawQ(i);
1307 highlightedAction = 2;
1309 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1310 panel_click_distance_y = mousepos_y - panelPos_y;
1311 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1314 // resize from bottomleft border
1315 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)
1317 highlightedPanel = i;
1318 HUD_Panel_FirstInDrawQ(i);
1319 highlightedAction = 2;
1321 panel_click_distance_x = mousepos_x - panelPos_x;
1322 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1323 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1326 // resize from bottomright border
1327 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)
1329 highlightedPanel = i;
1330 HUD_Panel_FirstInDrawQ(i);
1331 highlightedAction = 2;
1333 panel_click_distance = panelSize - mousepos + panelPos;
1334 panel_click_resizeorigin = panelPos;
1339 highlightedPanel_prev = -1;
1344 float highlightcheck;
1345 vector prev_pos, prev_size;
1346 void HUD_Panel_Mouse()
1348 // 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
1349 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1353 print("menu_enabled: ", ftos(menu_enabled), "\n");
1354 print("Highlighted: ", ftos(highlightedPanel), "\n");
1355 print("Menu alpha: ", ftos(autocvar__menu_alpha), "\n");
1358 // instantly hide the editor cursor if we open the HUDExit dialog
1359 // as hud_fade_alpha doesn't decrease to 0 in this case
1360 // TODO: find a way to fade the cursor out even in this case
1361 if(menu_enabled == 1 || (menu_enabled == 2 && !hud_fade_alpha))
1364 if(mouseClicked == 0 && menu_enabled != 2 && highlightedPanel >= 0) { // don't reset these variables in menu_enabled mode 2!
1365 highlightedPanel = -1;
1366 highlightedAction = 0;
1368 if(highlightedPanel != -1)
1369 highlightedPanel_prev = highlightedPanel;
1371 mousepos = mousepos + getmousepos() * autocvar_menu_mouse_speed;
1373 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1374 mousepos_y = bound(0, mousepos_y, vid_conheight);
1378 if(prevMouseClicked == 0)
1380 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1381 // and calls HUD_Panel_UpdatePosSizeForId() for the highlighted panel
1382 prev_pos = panel_pos;
1383 prev_size = panel_size;
1386 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
1388 if (prev_pos != panel_pos || prev_size != panel_size)
1390 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1392 panel_pos_backup = prev_pos;
1393 panel_size_backup = prev_size;
1394 highlightedPanel_backup = highlightedPanel;
1397 // in case the clicked panel is inside another panel and we aren't
1398 // moving it, avoid the immediate "fix" of its position/size
1399 // (often unwanted and hateful) by disabling collisions check
1400 hud_configure_checkcollisions = false;
1402 if(highlightedAction == 1)
1403 HUD_Panel_SetPos(mousepos - panel_click_distance);
1404 else if(highlightedAction == 2)
1407 if(resizeCorner == 1) {
1408 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1409 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1410 } else if(resizeCorner == 2) {
1411 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1412 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1413 } else if(resizeCorner == 3) {
1414 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1415 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1416 } else { // resizeCorner == 4
1417 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1418 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1420 HUD_Panel_SetPosSize(mySize);
1423 // doubleclick check
1424 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1426 mouseClicked = 0; // to prevent spam, I guess.
1428 menu_enabled_time = time;
1429 HUD_Panel_GetName(highlightedPanel);
1430 localcmd("menu_showhudoptions ", panel_name, "\n");
1433 if(prevMouseClicked == 0)
1435 prevMouseClickedTime = time;
1436 prevMouseClickedPos = mousepos;
1441 highlightcheck = HUD_Panel_HighlightCheck();
1443 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1445 cursorsize = '32 32 0';
1447 if(highlightcheck == 0)
1448 drawpic(mousepos, strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1449 else if(highlightcheck == 1)
1450 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);
1451 else if(highlightcheck == 2)
1452 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);
1454 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);
1456 prevMouseClicked = mouseClicked;
1459 // Weapon icons (#0)
1461 float weaponspace[10];
1462 #define HUD_Weapons_Clear()\
1464 for(idx = 0; idx < 10; ++idx)\
1465 weaponspace[idx] = 0
1467 entity weaponorder[WEP_MAXCOUNT];
1468 void weaponorder_swap(float i, float j, entity pass)
1472 weaponorder[i] = weaponorder[j];
1476 string weaponorder_cmp_str;
1477 float weaponorder_cmp(float i, float j, entity pass)
1480 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1481 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1482 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)
1485 float GetAmmoStat(float i)
1489 case 0: return STAT_SHELLS;
1490 case 1: return STAT_NAILS;
1491 case 2: return STAT_ROCKETS;
1492 case 3: return STAT_CELLS;
1493 case 4: return STAT_FUEL;
1498 float GetAmmoTypeForWep(float i)
1502 case WEP_SHOTGUN: return 0;
1503 case WEP_UZI: return 1;
1504 case WEP_GRENADE_LAUNCHER: return 2;
1505 case WEP_MINE_LAYER: return 2;
1506 case WEP_ELECTRO: return 3;
1507 case WEP_CRYLINK: return 3;
1508 case WEP_HLAC: return 3;
1509 case WEP_MINSTANEX: return 3;
1510 case WEP_NEX: return 3;
1511 case WEP_SNIPERRIFLE: return 1;
1512 case WEP_HAGAR: return 2;
1513 case WEP_ROCKET_LAUNCHER: return 2;
1514 case WEP_SEEKER: return 2;
1515 case WEP_FIREBALL: return 4;
1516 case WEP_HOOK: return 3;
1521 void HUD_Weapons(void)
1524 float center_x, center_y;
1526 if(!autocvar_hud_panel_weapons && !autocvar__hud_configure)
1529 float timeout = autocvar_hud_panel_weapons_timeout;
1530 float timeout_effect_length, timein_effect_length;
1531 if (autocvar_hud_panel_weapons_timeout_effect == 0)
1533 timeout_effect_length = 0;
1534 timein_effect_length = 0;
1538 timeout_effect_length = 0.75;
1539 timein_effect_length = 0.375;
1542 if (timeout && time >= weapontime + timeout + timeout_effect_length && !autocvar__hud_configure)
1544 weaponprevtime = time;
1548 active_panel = HUD_PANEL_WEAPONS;
1549 HUD_Panel_UpdateCvars(weapons);
1551 if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
1553 f = (time - (weapontime + timeout)) / timeout_effect_length;
1554 if (autocvar_hud_panel_weapons_timeout_effect)
1556 panel_bg_alpha *= (1 - f);
1557 panel_fg_alpha *= (1 - f);
1559 if (autocvar_hud_panel_weapons_timeout_effect == 1)
1561 f *= f; // for a cooler movement
1562 center_x = panel_pos_x + panel_size_x/2;
1563 center_y = panel_pos_y + panel_size_y/2;
1564 screen_ar = vid_conwidth/vid_conheight;
1565 if (center_x/center_y < screen_ar) //bottom left
1567 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
1568 panel_pos_y += f * (vid_conheight - panel_pos_y);
1570 panel_pos_x -= f * (panel_pos_x + panel_size_x);
1574 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
1575 panel_pos_x += f * (vid_conwidth - panel_pos_x);
1577 panel_pos_y -= f * (panel_pos_y + panel_size_y);
1580 weaponprevtime = time - (1 - f) * timein_effect_length;
1582 else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure)
1584 f = (time - weaponprevtime) / timein_effect_length;
1585 if (autocvar_hud_panel_weapons_timeout_effect)
1587 panel_bg_alpha *= (f);
1588 panel_fg_alpha *= (f);
1590 if (autocvar_hud_panel_weapons_timeout_effect == 1)
1592 f *= f; // for a cooler movement
1594 center_x = panel_pos_x + panel_size_x/2;
1595 center_y = panel_pos_y + panel_size_y/2;
1596 screen_ar = vid_conwidth/vid_conheight;
1597 if (center_x/center_y < screen_ar) //bottom left
1599 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
1600 panel_pos_y += f * (vid_conheight - panel_pos_y);
1602 panel_pos_x -= f * (panel_pos_x + panel_size_x);
1606 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
1607 panel_pos_x += f * (vid_conwidth - panel_pos_x);
1609 panel_pos_y -= f * (panel_pos_y + panel_size_y);
1614 float i, weapid, wpnalpha, weapon_cnt;
1616 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1618 self = get_weaponinfo(i);
1619 if(self.impulse >= 0)
1623 // TODO make this configurable
1624 if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
1626 if(weaponorder_bypriority)
1627 strunzone(weaponorder_bypriority);
1628 if(weaponorder_byimpulse)
1629 strunzone(weaponorder_byimpulse);
1631 weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
1632 weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
1633 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1636 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1638 self = get_weaponinfo(i);
1639 if(self.impulse >= 0)
1641 weaponorder[weapon_cnt] = self;
1645 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1647 weaponorder_cmp_str = string_null;
1650 HUD_Panel_DrawBg(1);
1651 if(panel_bg_padding)
1653 panel_pos += '1 1 0' * panel_bg_padding;
1654 panel_size -= '2 2 0' * panel_bg_padding;
1657 if(autocvar_hud_panel_weapons_fade)
1659 wpnalpha = 3.2 - 2 * (time - weapontime);
1660 wpnalpha = bound(0.7, wpnalpha, 1) * panel_fg_alpha;
1663 wpnalpha = panel_fg_alpha;
1665 HUD_Weapons_Clear();
1667 float rows, columns;
1668 float aspect = autocvar_hud_panel_weapons_aspect;
1669 rows = panel_size_y/panel_size_x;
1670 rows = bound(1, floor((sqrt(4 * aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1672 columns = ceil(WEP_COUNT/rows);
1675 float a, type, fullammo;
1677 when = autocvar_hud_panel_weapons_complainbubble_time;
1679 fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
1685 float fullammo_shells, fullammo_nails, fullammo_rockets, fullammo_cells, fullammo_fuel;
1688 wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
1689 float barsize_x, barsize_y, baroffset_x, baroffset_y;
1690 float show_ammo = autocvar_hud_panel_weapons_ammo;
1693 fullammo_shells = autocvar_hud_panel_weapons_ammo_full_shells;
1694 fullammo_nails = autocvar_hud_panel_weapons_ammo_full_nails;
1695 fullammo_rockets = autocvar_hud_panel_weapons_ammo_full_rockets;
1696 fullammo_cells = autocvar_hud_panel_weapons_ammo_full_cells;
1697 fullammo_fuel = autocvar_hud_panel_weapons_ammo_full_fuel;
1698 ammo_color = stov(autocvar_hud_panel_weapons_ammo_color);
1699 ammo_alpha = panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha;
1702 if(wpnsize_x/wpnsize_y > aspect)
1704 barsize_x = aspect * wpnsize_y;
1705 barsize_y = wpnsize_y;
1706 baroffset_x = (wpnsize_x - barsize_x) / 2;
1710 barsize_y = 1/aspect * wpnsize_x;
1711 barsize_x = wpnsize_x;
1712 baroffset_y = (wpnsize_y - barsize_y) / 2;
1716 float show_accuracy;
1718 if(autocvar_hud_panel_weapons_accuracy && acc_levels)
1720 show_accuracy = true;
1721 if (acc_col_x[0] == -1)
1722 for (i = 0; i < acc_levels; ++i)
1723 acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
1726 float weapons_st = getstati(STAT_WEAPONS);
1727 float label = autocvar_hud_panel_weapons_label;
1729 for(i = 0; i < weapon_cnt; ++i)
1731 wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y;
1733 self = weaponorder[i];
1734 weapid = self.impulse;
1736 // draw background behind currently selected weapon
1737 if(self.weapon == activeweapon)
1738 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
1740 // draw the weapon accuracy
1743 weapon_stats = weapon_accuracy[self.weapon-WEP_FIRST];
1744 if(weapon_stats >= 0)
1746 // find the max level lower than weapon_stats
1749 while ( j && weapon_stats < acc_lev[j] )
1752 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
1754 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
1756 color = color + factor * (acc_col[j+1] - color);
1758 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1762 // draw the weapon icon
1763 if((weapid >= 0) && (weapons_st & self.weapons))
1765 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
1767 if(label == 1) // weapon number
1768 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1769 else if(label == 2) // bind
1770 drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1772 // draw ammo status bar
1773 if(show_ammo && self.weapon != WEP_TUBA && self.weapon != WEP_LASER && self.weapon != WEP_PORTO)
1776 type = GetAmmoTypeForWep(self.weapon);
1778 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
1783 case 0: fullammo = fullammo_shells; break;
1784 case 1: fullammo = fullammo_nails; break;
1785 case 2: fullammo = fullammo_rockets; break;
1786 case 3: fullammo = fullammo_cells; break;
1787 case 4: fullammo = fullammo_fuel; break;
1788 default: fullammo = 60;
1792 wpnpos_x + baroffset_x,
1793 wpnpos_y + baroffset_y,
1794 barsize_x * bound(0, a/fullammo, 1),
1796 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, ammo_color, ammo_alpha, DRAWFLAG_NORMAL);
1797 drawresetcliparea();
1802 // draw a "ghost weapon icon" if you don't have the weapon
1805 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
1808 // draw the complain message
1809 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
1813 if(complain_weapon_time + when > time)
1816 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1820 if(complain_weapon_time + when > time)
1827 if(complain_weapon_type == 0) {
1828 s = _("Out of ammo");
1829 color = stov(autocvar_hud_panel_weapons_complainbubble_color_outofammo);
1831 else if(complain_weapon_type == 1) {
1832 s = _("Don't have");
1833 color = stov(autocvar_hud_panel_weapons_complainbubble_color_donthave);
1836 s = _("Unavailable");
1837 color = stov(autocvar_hud_panel_weapons_complainbubble_color_unavailable);
1839 float padding = autocvar_hud_panel_weapons_complainbubble_padding;
1840 drawpic_aspect_skin(wpnpos + '1 1 0' * padding, "weapon_complainbubble", wpnsize - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
1841 drawstring_aspect(wpnpos + '1 1 0' * padding, s, wpnsize - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
1857 float GetAmmoItemCode(float i)
1861 case 0: return IT_SHELLS;
1862 case 1: return IT_NAILS;
1863 case 2: return IT_ROCKETS;
1864 case 3: return IT_CELLS;
1865 case 4: return IT_FUEL;
1870 string GetAmmoPicture(float i)
1874 case 0: return "ammo_shells";
1875 case 1: return "ammo_bullets";
1876 case 2: return "ammo_rockets";
1877 case 3: return "ammo_cells";
1878 case 4: return "ammo_fuel";
1883 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1886 if(autocvar__hud_configure)
1888 currently_selected = (itemcode == 2); //rockets always selected
1892 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1901 if(currently_selected)
1906 vector picpos, numpos;
1907 if(autocvar_hud_panel_ammo_iconalign)
1910 picpos = myPos + eX * 2 * mySize_y;
1914 numpos = myPos + eX * mySize_y;
1918 if (currently_selected)
1919 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1921 if(a > 0 && autocvar_hud_panel_ammo_progressbar)
1922 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);
1924 if(autocvar_hud_panel_ammo_text)
1927 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1928 else // "ghost" ammo count
1929 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1932 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1933 else // "ghost" ammo icon
1934 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1939 if(!autocvar_hud_panel_ammo && !autocvar__hud_configure)
1942 active_panel = HUD_PANEL_AMMO;
1943 HUD_Panel_UpdateCvars(ammo);
1946 mySize = panel_size;
1948 HUD_Panel_DrawBg(1);
1949 if(panel_bg_padding)
1951 pos += '1 1 0' * panel_bg_padding;
1952 mySize -= '2 2 0' * panel_bg_padding;
1955 float rows, columns, row, column;
1957 if (autocvar_hud_panel_ammo_onlycurrent)
1961 rows = mySize_y/mySize_x;
1962 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1963 // ^^^ ammo item aspect goes here
1965 columns = ceil(AMMO_COUNT/rows);
1967 ammo_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
1972 if(ammo_size_x/ammo_size_y > 3)
1974 newSize = 3 * ammo_size_y;
1975 offset_x = ammo_size_x - newSize;
1976 pos_x += offset_x/2;
1977 ammo_size_x = newSize;
1981 newSize = 1/3 * ammo_size_x;
1982 offset_y = ammo_size_y - newSize;
1983 pos_y += offset_y/2;
1984 ammo_size_y = newSize;
1987 float i, stat_items, currently_selected;
1988 if (autocvar_hud_panel_ammo_onlycurrent)
1990 if(autocvar__hud_configure)
1992 DrawAmmoItem(pos, ammo_size, 2, true); //show rockets
1995 stat_items = getstati(STAT_ITEMS);
1996 for (i = 0; i < AMMO_COUNT; ++i) {
1997 currently_selected = stat_items & GetAmmoItemCode(i);
1998 if (currently_selected)
2000 DrawAmmoItem(pos, ammo_size, i, true);
2004 return; // nothing to display
2007 stat_items = getstati(STAT_ITEMS);
2008 for (i = 0; i < AMMO_COUNT; ++i) {
2009 currently_selected = stat_items & GetAmmoItemCode(i);
2010 DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected);
2015 column = column + 1;
2020 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float alpha)
2023 float newSize_x, newSize_y;
2024 if(mySize_x/mySize_y > 3)
2026 newSize_x = 3 * mySize_y;
2027 newSize_y = mySize_y;
2029 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
2034 newSize_y = 1/3 * mySize_x;
2035 newSize_x = mySize_x;
2037 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
2041 vector picpos, numpos;
2044 if(iconalign == 1 || iconalign == 3) // right align
2047 picpos = newPos + eX * 2 * newSize_y;
2051 numpos = newPos + eX * newSize_y;
2057 if(iconalign == 0 || iconalign == 3) // left align
2059 numpos = newPos + eX * newSize_y;
2065 picpos = newPos + eX * 2 * newSize_y;
2069 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
2070 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
2073 void DrawNumIcon_expanding(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float fadelerp)
2076 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
2078 DrawNumIcon(iconalign, myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, left, color, (1 - fadelerp));
2083 void HUD_Powerups(void) {
2084 if(!autocvar_hud_panel_powerups && !autocvar__hud_configure)
2087 if(!autocvar__hud_configure)
2089 if not(getstati(STAT_ITEMS) & (IT_STRENGTH | IT_INVINCIBLE))
2092 if (getstati(STAT_HEALTH) <= 0)
2096 active_panel = HUD_PANEL_POWERUPS;
2097 HUD_Panel_UpdateCvars(powerups);
2100 mySize = panel_size;
2102 float strength_time, shield_time;
2103 if(autocvar__hud_configure)
2110 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
2111 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
2114 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
2115 if(panel_bg_padding)
2117 pos += '1 1 0' * panel_bg_padding;
2118 mySize -= '2 2 0' * panel_bg_padding;
2121 vector barpos, barsize;
2125 string leftname, rightname;
2126 string leftprogressname, rightprogressname;
2127 float leftcnt, rightcnt;
2128 float leftexact, rightexact;
2129 float flip = autocvar_hud_panel_powerups_flip;
2131 leftname = "strength";
2132 leftprogressname = autocvar_hud_panel_powerups_progressbar_strength;
2133 leftcnt = ceil(strength_time);
2134 leftexact = strength_time;
2136 rightname = "shield";
2137 rightprogressname = autocvar_hud_panel_powerups_progressbar_shield;
2138 rightcnt = ceil(shield_time);
2139 rightexact = shield_time;
2141 leftname = "shield";
2142 leftprogressname = autocvar_hud_panel_powerups_progressbar_shield;
2143 leftcnt = ceil(shield_time);
2144 leftexact = shield_time;
2146 rightname = "strength";
2147 rightprogressname = autocvar_hud_panel_powerups_progressbar_strength;
2148 rightcnt = ceil(strength_time);
2149 rightexact = strength_time;
2152 float baralign = autocvar_hud_panel_powerups_baralign;
2154 float iconalign = autocvar_hud_panel_powerups_iconalign;
2155 float progressbar = autocvar_hud_panel_powerups_progressbar;
2156 if (mySize_x/mySize_y > 4)
2158 barsize = eX * 0.5 * mySize_x + eY * mySize_y;
2161 if(baralign == 1 || baralign == 3) { // right align
2162 barpos = pos + eX * 0.5 * mySize_x;
2164 } else { // left align
2171 HUD_Panel_GetProgressBarColorForString(leftname);
2172 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);
2174 if(autocvar_hud_panel_powerups_text)
2177 DrawNumIcon(iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
2179 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));
2185 if(baralign == 0 || baralign == 3) { // left align
2188 } else { // right align
2189 barpos = pos + eX * 0.5 * mySize_x;
2195 HUD_Panel_GetProgressBarColorForString(rightname);
2196 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);
2198 if(autocvar_hud_panel_powerups_text)
2201 DrawNumIcon(iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
2203 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));
2207 else if (mySize_x/mySize_y > 1.5)
2209 barsize = eX * mySize_x + eY * 0.5 * mySize_y;
2213 if(baralign == 1 || baralign == 3) { // right/down align
2215 } else { // left/up align
2221 HUD_Panel_GetProgressBarColorForString(leftname);
2222 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);
2224 if(autocvar_hud_panel_powerups_text)
2227 DrawNumIcon(iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
2229 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));
2235 barpos = pos + eY * 0.5 * mySize_y;
2236 if(baralign == 0 || baralign == 3) { // left align
2238 } else { // right align
2244 HUD_Panel_GetProgressBarColorForString(rightname);
2245 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);
2247 if(autocvar_hud_panel_powerups_text)
2250 DrawNumIcon(iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
2252 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));
2258 barsize = eX * 0.5 * mySize_x + eY * mySize_y;
2262 if(baralign == 1 || baralign == 3) { // down align
2264 } else { // up align
2268 if(iconalign == 1 || iconalign == 3) { // down align
2269 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2270 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2271 } else { // up align
2272 picpos = pos + eX * 0.05 * mySize_x;
2273 numpos = pos + eY * 0.4 * mySize_x;
2278 HUD_Panel_GetProgressBarColorForString(leftname);
2279 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);
2281 if(autocvar_hud_panel_powerups_text)
2284 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));
2286 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2287 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2293 barpos = pos + eX * 0.5 * mySize_x;
2294 if(baralign == 0 || baralign == 3) { // down align
2296 } else { // up align
2300 if(iconalign == 0 || iconalign == 3) { // up align
2301 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2302 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2303 } else { // down align
2304 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2305 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2310 HUD_Panel_GetProgressBarColorForString(rightname);
2311 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);
2313 if(autocvar_hud_panel_powerups_text)
2316 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));
2318 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2319 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2325 // Health/armor (#3)
2327 void HUD_HealthArmor(void)
2329 if(!autocvar_hud_panel_healtharmor && !autocvar__hud_configure)
2332 active_panel = HUD_PANEL_HEALTHARMOR;
2333 HUD_Panel_UpdateCvars(healtharmor);
2336 mySize = panel_size;
2338 HUD_Panel_DrawBg(1);
2339 if(panel_bg_padding)
2341 pos += '1 1 0' * panel_bg_padding;
2342 mySize -= '2 2 0' * panel_bg_padding;
2345 float armor, health, fuel;
2346 armor = getstati(STAT_ARMOR);
2347 health = getstati(STAT_HEALTH);
2348 fuel = getstati(STAT_FUEL);
2350 if(autocvar__hud_configure)
2360 vector barpos, barsize;
2364 float baralign = autocvar_hud_panel_healtharmor_baralign;
2365 float iconalign = autocvar_hud_panel_healtharmor_iconalign;
2366 float progressbar = autocvar_hud_panel_healtharmor_progressbar;
2368 float maxhealth = autocvar_hud_panel_healtharmor_maxhealth;
2369 float maxarmor = autocvar_hud_panel_healtharmor_maxarmor;
2370 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
2373 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2378 float maxtotal = maxhealth + maxarmor;
2384 if(v_z) // NOT fully armored
2386 biggercount = "health";
2389 HUD_Panel_GetProgressBarColor(health);
2390 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);
2393 if(autocvar_hud_panel_healtharmor_text)
2394 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);
2398 biggercount = "armor";
2401 HUD_Panel_GetProgressBarColor(armor);
2402 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);
2405 if(autocvar_hud_panel_healtharmor_text)
2406 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);
2408 if(autocvar_hud_panel_healtharmor_text)
2409 DrawNumIcon(iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, maxtotal), 1);
2415 barsize = eX * mySize_x + eY * 0.2 * mySize_y;
2416 HUD_Panel_GetProgressBarColor(fuel);
2417 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);
2422 string leftname, rightname;
2423 string leftprogressname, rightprogressname;
2424 float leftcnt, rightcnt;
2425 float leftmax, rightmax;
2426 float leftactive, rightactive;
2427 float leftalpha, rightalpha;
2428 float flip = autocvar_hud_panel_healtharmor_flip;
2430 if (flip) { // old style layout with armor left/top of health
2432 leftprogressname = autocvar_hud_panel_healtharmor_progressbar_armor;
2436 leftalpha = min((armor+10)/55, 1);
2439 rightname = "health";
2440 rightprogressname = autocvar_hud_panel_healtharmor_progressbar_health;
2444 rightmax = maxhealth;
2446 leftname = "health";
2447 leftprogressname = autocvar_hud_panel_healtharmor_progressbar_health;
2451 leftmax = maxhealth;
2453 rightname = "armor";
2454 rightprogressname = autocvar_hud_panel_healtharmor_progressbar_armor;
2458 rightalpha = min((armor+10)/55, 1);
2459 rightmax = maxarmor;
2462 if (mySize_x/mySize_y > 4)
2464 barsize = eX * 0.5 * mySize_x + eY * mySize_y;
2468 if(baralign == 1 || baralign == 3) { // right align
2470 } else { // left align
2476 HUD_Panel_GetProgressBarColorForString(leftname);
2477 HUD_Panel_DrawProgressBar(barpos, barsize, leftprogressname, 0, barflip, min(1, leftcnt/leftmax), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2479 if(autocvar_hud_panel_healtharmor_text)
2480 DrawNumIcon(iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, leftmax), 1);
2485 barpos = pos + eX * 0.5 * mySize_x;
2486 if(baralign == 0 || baralign == 3) { // left align
2488 } else { // right align
2494 HUD_Panel_GetProgressBarColorForString(rightname);
2495 HUD_Panel_DrawProgressBar(barpos, barsize, rightprogressname, 0, barflip, min(1, rightcnt/rightmax), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2497 if(autocvar_hud_panel_healtharmor_text)
2498 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);
2504 barsize = eX * mySize_x + eY * 0.2 * mySize_y;
2505 HUD_Panel_GetProgressBarColor(fuel);
2506 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);
2509 else if (mySize_x/mySize_y > 1.5)
2511 barsize = eX * mySize_x + eY * 0.5 * mySize_y;
2515 if(baralign == 1 || baralign == 3) { // right align
2517 } else { // left align
2523 HUD_Panel_GetProgressBarColorForString(leftname);
2524 HUD_Panel_DrawProgressBar(barpos, barsize, leftprogressname, 0, barflip, min(1, leftcnt/leftmax), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2526 if(autocvar_hud_panel_healtharmor_text)
2527 DrawNumIcon(iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, leftmax), 1);
2532 barpos = pos + eY * 0.5 * mySize_y;
2533 if(baralign == 0 || baralign == 3) { // left align
2535 } else { // right align
2541 HUD_Panel_GetProgressBarColorForString(rightname);
2542 HUD_Panel_DrawProgressBar(barpos, barsize, rightprogressname, 0, barflip, min(1, rightcnt/rightmax), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2544 if(autocvar_hud_panel_healtharmor_text)
2545 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);
2551 barsize = eX * mySize_x + eY * 0.2 * mySize_y;
2552 HUD_Panel_GetProgressBarColor(fuel);
2553 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);
2558 barsize = eX * 0.5 * mySize_x + eY * mySize_y;
2562 if(baralign == 1 || baralign == 3) { // right align
2564 } else { // left align
2568 if(iconalign == 1 || iconalign == 3) { // down align
2569 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2570 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2571 } else { // up align
2572 picpos = pos + eX * 0.05 * mySize_x;
2573 numpos = pos + eY * 0.4 * mySize_x;
2578 HUD_Panel_GetProgressBarColorForString(leftname);
2579 HUD_Panel_DrawProgressBar(barpos, barsize, leftprogressname, 1, barflip, min(1, leftcnt/leftmax), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2581 if(autocvar_hud_panel_healtharmor_text)
2583 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2584 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);
2590 barpos = pos + eX * 0.5 * mySize_x;
2591 if(baralign == 0 || baralign == 3) { // left align
2593 } else { // right align
2597 if(iconalign == 0 || iconalign == 3) { // up align
2598 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2599 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2600 } else { // down align
2601 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2602 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2607 HUD_Panel_GetProgressBarColorForString(rightname);
2608 HUD_Panel_DrawProgressBar(barpos, barsize, rightprogressname, 1, barflip, min(1, rightcnt/rightmax), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2610 if(autocvar_hud_panel_healtharmor_text)
2612 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2613 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);
2620 barsize = eX * 0.05 * mySize_x + eY * mySize_y;
2621 HUD_Panel_GetProgressBarColor(fuel);
2622 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);
2628 // Notification area (#4)
2631 string Weapon_SuicideMessage(float deathtype)
2633 w_deathtype = deathtype;
2634 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2635 return w_deathtypestring;
2638 string Weapon_KillMessage(float deathtype)
2640 w_deathtype = deathtype;
2641 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2642 return w_deathtypestring;
2645 #define KN_MAX_ENTRIES 10
2647 float killnotify_times[KN_MAX_ENTRIES];
2648 float killnotify_deathtype[KN_MAX_ENTRIES];
2649 float killnotify_actiontype[KN_MAX_ENTRIES]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2650 string killnotify_attackers[KN_MAX_ENTRIES];
2651 string killnotify_victims[KN_MAX_ENTRIES];
2652 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2656 kn_index = KN_MAX_ENTRIES-1;
2657 killnotify_times[kn_index] = time;
2658 killnotify_deathtype[kn_index] = wpn;
2659 killnotify_actiontype[kn_index] = actiontype;
2660 if(killnotify_attackers[kn_index])
2661 strunzone(killnotify_attackers[kn_index]);
2662 killnotify_attackers[kn_index] = strzone(attacker);
2663 if(killnotify_victims[kn_index])
2664 strunzone(killnotify_victims[kn_index]);
2665 killnotify_victims[kn_index] = strzone(victim);
2668 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
2671 float alsoprint, gentle;
2672 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2673 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2675 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
2678 if(msg == MSG_SUICIDE) {
2679 w = DEATH_WEAPONOF(type);
2681 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2683 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
2684 } else if (type == DEATH_KILL) {
2685 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2687 print (sprintf(_("^1%s^1 couldn't take it anymore\n"), s1));
2688 } else if (type == DEATH_ROT) {
2689 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2691 print (sprintf(_("^1%s^1 died\n"), s1));
2692 } else if (type == DEATH_NOAMMO) {
2693 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2695 print (sprintf(_("^7%s^7 committed suicide. What's the point of living without ammo?\n"), s1));
2696 } else if (type == DEATH_CAMP) {
2697 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2699 print (sprintf(_("^1%s^1 thought they found a nice camping ground\n"), s1));
2700 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2701 HUD_KillNotify_Push(s1, "", 0, type);
2703 print (sprintf(_("^1%s^1 didn't become friends with the Lord of Teamplay\n"), s1));
2704 } else if (type == DEATH_CHEAT) {
2705 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2707 print (sprintf(_("^1%s^1 unfairly eliminated themself\n"), s1));
2708 } else if (type == DEATH_FIRE) {
2709 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2711 print (sprintf(_("^1%s^1 burned to death\n"), s1));
2712 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2713 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2715 print (sprintf(_("^1%s^1 couldn't resist the urge to self-destruct\n"), s1));
2718 if (stof(s2) > 2) // killcount > 2
2719 print (sprintf(_("^1%s^1 ended it all after a %d kill spree\n"), s1, stof(s2)));
2720 } else if(msg == MSG_KILL) {
2721 w = DEATH_WEAPONOF(type);
2723 if((w == WEP_SNIPERRIFLE || w == WEP_MINSTANEX) && type & HITTYPE_HEADSHOT) // all headshot weapons go here
2724 HUD_KillNotify_Push(s1, s2, 1, DEATH_HEADSHOT);
2726 HUD_KillNotify_Push(s1, s2, 1, type);
2729 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
2731 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2732 HUD_KillNotify_Push(s1, s2, 1, type);
2736 print (sprintf(_("^1%s^1 took action against a team mate\n"), s1));
2738 print (sprintf(_("^1%s^1 mows down a team mate\n"), s1));
2741 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2743 print (sprintf(_("^1%s^1 ended a %d scoring spree by going against a team mate\n"), s1, stof(s3)));
2745 print (sprintf(_("^1%s^1 ended a %d kill spree by killing a team mate\n"), s1, stof(s3)));
2747 else if (stof(s2) > 2) {
2749 print (sprintf(_("^1%s^1's %s scoring spree was ended by a team mate!\n"), s1, stof(s3)));
2751 print (sprintf(_("^1%s^1's %s kill spree was ended by a team mate!\n"), s1, stof(s3)));
2754 else if(type == KILL_FIRST_BLOOD)
2755 print(sprintf(_("^1%s^1 drew first blood\n"), s1));
2756 else if (type == DEATH_TELEFRAG) {
2757 HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
2759 print (sprintf(_("^1%s^1 tried to occupy %s^1's teleport destination space\n"), s2, s1));
2761 print (sprintf(_("^1%s^1 was telefragged by %s\n"), s2, s1));
2763 else if (type == DEATH_DROWN) {
2764 HUD_KillNotify_Push(s1, s2, 1, DEATH_DROWN);
2766 print (sprintf(_("^1%s^1 was drowned by %s\n"), s2, s1));
2768 else if (type == DEATH_SLIME) {
2769 HUD_KillNotify_Push(s1, s2, 1, DEATH_SLIME);
2771 print (sprintf(_("^1%s^1 was slimed by %s\n"), s2, s1));
2773 else if (type == DEATH_LAVA) {
2774 HUD_KillNotify_Push(s1, s2, 1, DEATH_LAVA);
2776 print (sprintf(_("^1%s^1 was cooked by %s\n"), s2, s1));
2778 else if (type == DEATH_FALL) {
2779 HUD_KillNotify_Push(s1, s2, 1, DEATH_FALL);
2781 print (sprintf(_("^1%s^1 was grounded by %s\n"), s2, s1));
2783 else if (type == DEATH_SHOOTING_STAR) {
2784 HUD_KillNotify_Push(s1, s2, 1, DEATH_SHOOTING_STAR);
2786 print (sprintf(_("^1%s^1 was shot into space by %s\n"), s2, s1));
2788 else if (type == DEATH_SWAMP) {
2789 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2791 print (sprintf(_("^1%s^1 was conserved by %s\n"), s2, s1));
2793 else if (type == DEATH_HURTTRIGGER)
2795 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
2797 print(sprintf(_("^1%s^1 was thrown into a world of hurt by %s\n"), s2, s1));
2798 } else if(type == DEATH_SBCRUSH) {
2799 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2801 print (sprintf(_("^1%s^1 was crushed by %s\n"), s2, s1));
2802 } else if(type == DEATH_SBMINIGUN) {
2803 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2805 print (sprintf(_("^1%s^1 got shredded by %s\n"), s2, s1));
2806 } else if(type == DEATH_SBROCKET) {
2807 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2809 print (sprintf(_("^1%s^1 was blasted to bits by %s\n"), s2, s1));
2810 } else if(type == DEATH_SBBLOWUP) {
2811 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2813 print (sprintf(_("^1%s^1 got caught in the destruction of %s^1's vehicle\n"), s2, s1));
2814 } else if(type == DEATH_WAKIGUN) {
2815 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2817 print (sprintf(_("^1%s^1 was bolted down by %s\n"), s2, s1));
2818 } else if(type == DEATH_WAKIROCKET) {
2819 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2821 print (sprintf(_("^1%s^1 could find no shelter from %s^1's rockets\n"), s2, s1));
2822 } else if(type == DEATH_WAKIBLOWUP) {
2823 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2825 print (sprintf(_("^1%s^1 dies when %s^1's wakizashi dies.\n"), s2, s1));
2826 } else if(type == DEATH_TURRET) {
2827 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2829 print (sprintf(_("^1%s^1 was pushed into the line of fire by %s\n"), s2, s1));
2830 } else if(type == DEATH_TOUCHEXPLODE) {
2831 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2833 print (sprintf(_("^1%s^1 was pushed into an accident by %s\n"), s2, s1));
2834 } else if(type == DEATH_CHEAT) {
2835 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2837 print (sprintf(_("^1%s^1 was unfairly eliminated by %s\n"), s2, s1));
2838 } else if (type == DEATH_FIRE) {
2839 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2841 print (sprintf(_("^1%s^1 was burnt to death by %s\n"), s2, s1));
2842 } else if (type == DEATH_CUSTOM) {
2843 HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM);
2845 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
2846 } else if (type == DEATH_HURTTRIGGER) {
2847 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
2849 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
2851 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2853 print (sprintf(_("^1%s^1 was fragged by %s\n"), s2, s1));
2855 } else if(msg == MSG_SPREE) {
2856 if(type == KILL_END_SPREE) {
2858 print (sprintf(_("^1%s^1's %s scoring spree was ended by %s\n"), s1, s2, s3));
2860 print (sprintf(_("^1%s^1's %s kill spree was ended by %s\n"), s1, s2, s3));
2861 } else if(type == KILL_SPREE) {
2863 print (sprintf(_("^1%s^1 made %s scores in a row\n"), s1, s2));
2865 print (sprintf(_("^1%s^1 has %s frags in a row\n"), s1, s2));
2866 } else if(type == KILL_SPREE_3) {
2868 print (sprintf(_("%s^7 made a ^1TRIPLE SCORE\n"), s1));
2870 print (sprintf(_("%s^7 made a ^1TRIPLE FRAG\n"), s1));
2871 } else if(type == KILL_SPREE_5) {
2873 print (sprintf(_("%s^7 unleashes ^1SCORING RAGE\n"), s1));
2875 print (sprintf(_("%s^7 unleashes ^1RAGE\n"), s1));
2876 } else if(type == KILL_SPREE_10) {
2878 print (sprintf(_("%s^7 made ^1TEN SCORES IN A ROW!\n"), s1));
2880 print (sprintf(_("%s^7 starts the ^1MASSACRE!\n"), s1));
2881 } else if(type == KILL_SPREE_15) {
2883 print (sprintf(_("%s^7 made ^1FIFTEEN SCORES IN A ROW!\n"), s1));
2885 print (sprintf(_("%s^7 executes ^1MAYHEM!\n"), s1));
2886 } else if(type == KILL_SPREE_20) {
2888 print (sprintf(_("%s^7 made ^1TWENTY SCORES IN A ROW!\n"), s1));
2890 print (sprintf(_("%s^7 is a ^1BERSERKER!\n"), s1));
2891 } else if(type == KILL_SPREE_25) {
2893 print (sprintf(_("%s^7 made ^1TWENTY FIFE SCORES IN A ROW!\n"), s1));
2895 print (sprintf(_("%s^7 inflicts ^1CARNAGE!\n"), s1));
2896 } else if(type == KILL_SPREE_30) {
2898 print (sprintf(_("%s^7 made ^1THIRTY SCORES IN A ROW!\n"), s1));
2900 print (sprintf(_("%s^7 unleashes ^1ARMAGEDDON!\n"), s1));
2902 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2903 if (type == DEATH_DROWN) {
2904 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2908 print (sprintf(_("^1%s^1 was in the water for too long\n"), s1));
2910 print (sprintf(_("^1%s^1 drowned\n"), s1));
2912 } else if (type == DEATH_SLIME) {
2913 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2915 print (sprintf(_("^1%s^1 was slimed\n"), s1));
2916 } else if (type == DEATH_LAVA) {
2917 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2921 print (sprintf(_("^1%s^1 found a hot place\n"), s1));
2923 print (sprintf(_("^1%s^1 turned into hot slag\n"), s1));
2925 } else if (type == DEATH_FALL) {
2926 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2930 print (sprintf(_("^1%s^1 tested gravity (and it worked)\n"), s1));
2932 print (sprintf(_("^1%s^1 hit the ground with a crunch\n"), s1));
2934 } else if (type == DEATH_SHOOTING_STAR) {
2935 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2937 print (sprintf(_("^1%s^1 became a shooting star\n"), s1));
2938 } else if (type == DEATH_SWAMP) {
2939 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2943 print (sprintf(_("^1%s^1 discovered a swamp\n"), s1));
2945 print (sprintf(_("^1%s^1 is now conserved for centuries to come\n"), s1));
2947 } else if(type == DEATH_TURRET) {
2948 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2950 print (sprintf(_("^1%s^1 was mowed down by a turret \n"), s1));
2951 } else if (type == DEATH_CUSTOM) {
2952 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2954 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
2955 } else if (type == DEATH_HURTTRIGGER) {
2956 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2958 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
2959 } else if(type == DEATH_TOUCHEXPLODE) {
2960 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2962 print (sprintf(_("^1%s^1 died in an accident\n"), s1));
2963 } else if(type == DEATH_CHEAT) {
2964 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2966 print (sprintf(_("^1%s^1 was unfairly eliminated\n"), s1));
2967 } else if(type == DEATH_FIRE) {
2968 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2972 print (sprintf(_("^1%s^1 felt a little hot\n"), s1));
2974 print (sprintf(_("^1%s^1 burnt to death\n"), s1));
2977 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2981 print (sprintf(_("^1%s^1 needs a restart\n"), s1));
2983 print (sprintf(_("^1%s^1 died\n"), s1));
2986 } else if(msg == MSG_KILL_ACTION_SPREE) {
2988 print (sprintf(_("^1%s^1 needs a restart after a %d scoring spree\n"), s1, stof(s2)));
2990 print (sprintf(_("^1%s^1 died with a %d kill spree\n"), s1, stof(s2)));
2991 } else if(msg == MSG_INFO) {
2992 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2993 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2994 print(sprintf(_("%s^7 got the %s\n"), s1, s2));
2995 } else if(type == INFO_LOSTFLAG) {
2996 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2997 print(sprintf(_("%s^7 lost the %s\n"), s1, s2));
2998 } else if(type == INFO_PICKUPFLAG) {
2999 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
3000 print(sprintf(_("%s^7 picked up the %s\n"), s1, s2));
3001 } else if(type == INFO_RETURNFLAG) {
3002 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
3003 print(sprintf(_("%s^7 returned the %s\n"), s1, s2));
3004 } else if(type == INFO_CAPTUREFLAG) {
3005 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
3006 print(sprintf(_("%s^7 captured the %s%s\n"), s1, s2, s3));
3008 } else if(msg == MSG_RACE) {
3009 if(type == RACE_SERVER_RECORD) {
3010 HUD_KillNotify_Push(s1, s2, 1, RACE_SERVER_RECORD);
3012 else if(type == RACE_NEW_RANK) {
3013 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_RANK);
3015 else if(type == RACE_NEW_TIME) {
3016 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_TIME);
3018 else if(type == RACE_FAIL) {
3019 HUD_KillNotify_Push(s1, s2, 1, RACE_FAIL);
3021 } else if(msg == MSG_KA) {
3022 if(type == KA_PICKUPBALL) {
3023 HUD_KillNotify_Push(s1, s2, 0, KA_PICKUPBALL);
3025 print (sprintf(_("%s^7 has picked up the ball!\n"), s1));
3027 else if(type == KA_DROPBALL) {
3028 HUD_KillNotify_Push(s1, s2, 0, KA_DROPBALL);
3030 print(sprintf(_("%s^7 has dropped the ball!\n"), s1));
3035 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
3037 void HUD_Centerprint(string s1, string s2, float type, float msg)
3040 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
3041 if(msg == MSG_SUICIDE) {
3042 if (type == DEATH_TEAMCHANGE) {
3043 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("You are now on: %s"), s1)));
3044 } else if (type == DEATH_AUTOTEAMCHANGE) {
3045 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("You have been moved into a different team to improve team balance\nYou are now on: %s"), s1)));
3046 } else if (type == DEATH_CAMP) {
3048 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Reconsider your tactics, camper!")));
3050 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Die camper!")));
3051 } else if (type == DEATH_NOAMMO) {
3053 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You are reinserted into the game for running out of ammo...")));
3055 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You were killed for running out of ammo...")));
3056 } else if (type == DEATH_ROT) {
3058 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You need to preserve your health")));
3060 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You grew too old without taking your medicine")));
3061 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
3063 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Don't go against team mates!")));
3065 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Don't shoot your team mates!")));
3066 } else if (type == DEATH_QUIET) {
3068 } else { // generic message
3070 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You need to be more careful!")));
3072 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You killed your own dumb self!")));
3074 } else if(msg == MSG_KILL) {
3075 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
3077 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1Moron! You went against %s, a team mate!"), s1)));
3079 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1Moron! You fragged %s, a team mate!"), s1)));
3081 } else if (type == KILL_FIRST_BLOOD) {
3083 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First score")));
3085 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First blood")));
3087 } else if (type == KILL_FIRST_VICTIM) {
3089 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First casualty")));
3091 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First victim")));
3093 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
3095 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You scored against ^7%s^1 who was typing!"), s1), s2));
3097 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You typefragged ^7%s"), s1), s2));
3099 } else if (type == KILL_TYPEFRAGGED) {
3101 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were scored against by ^7%s^1 while you were typing!"), s1), s2));
3103 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were typefragged by ^7%s"), s1), s2));
3105 } else if (type == KILL_FRAG) {
3107 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^4You scored against ^7%s"), s1), s2));
3109 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^4You fragged ^7%s"), s1), s2));
3111 } else { // generic message
3113 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were scored against by ^7%s"), s1), s2));
3115 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were fragged by ^7%s"), s1), s2));
3118 } else if(msg == MSG_KILL_ACTION) {
3119 // TODO: invent more centerprints here?
3120 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Watch your step!")));
3124 void HUD_Notify (void)
3126 if(!autocvar_hud_panel_notify && !autocvar__hud_configure)
3129 active_panel = HUD_PANEL_NOTIFY;
3130 HUD_Panel_UpdateCvars(notify);
3133 mySize = panel_size;
3135 HUD_Panel_DrawBg(1);
3136 if(panel_bg_padding)
3138 pos += '1 1 0' * panel_bg_padding;
3139 mySize -= '2 2 0' * panel_bg_padding;
3142 float entries, height;
3143 entries = bound(1, floor(KN_MAX_ENTRIES * mySize_y/mySize_x), KN_MAX_ENTRIES);
3144 height = mySize_y/entries;
3147 float fontheight = height * autocvar_hud_panel_notify_fontsize;
3148 fontsize = '0.5 0.5 0' * fontheight;
3152 when = autocvar_hud_panel_notify_time;
3154 fadetime = autocvar_hud_panel_notify_fadetime;
3158 vector pos_attacker, pos_victim;
3160 float width_attacker;
3161 string attacker, victim;
3163 float i, j, w, step, limit;
3164 if(autocvar_hud_panel_notify_flip) //order items from the top down
3170 else //order items from the bottom up
3177 for(j = kn_index; i != limit; i += step, ++j)
3179 if(autocvar__hud_configure)
3183 else // inverse order
3184 a = entries - 1 - i;
3185 attacker = textShortenToWidth(sprintf(_("Player %d"), a+1), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3186 victim = textShortenToWidth(sprintf(_("Player %d"), a+2), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3187 s = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname);
3188 a = bound(0, (when - a) / 4, 1);
3189 goto hud_config_notifyprint;
3192 if (j == KN_MAX_ENTRIES)
3195 if(killnotify_times[j] + when > time)
3199 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
3213 w = DEATH_WEAPONOF(killnotify_deathtype[j]);
3215 // TODO: maybe print in team colors?
3218 if(killnotify_actiontype[j] == 0)
3220 if(killnotify_deathtype[j] == DEATH_GENERIC)
3224 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
3226 s = "notify_outofammo";
3228 else if(killnotify_deathtype[j] == DEATH_KILL)
3230 s = "notify_selfkill";
3232 else if(killnotify_deathtype[j] == DEATH_CAMP)
3234 s = "notify_camping";
3236 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
3238 s = "notify_teamkill_red";
3240 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
3242 s = "notify_teamkill_blue";
3244 else if(killnotify_deathtype[j] == DEATH_DROWN)
3248 else if(killnotify_deathtype[j] == DEATH_SLIME)
3252 else if(killnotify_deathtype[j] == DEATH_LAVA)
3256 else if(killnotify_deathtype[j] == DEATH_FALL)
3260 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
3262 s = "notify_shootingstar";
3264 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
3268 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
3270 if(killnotify_victims[j] == "^1RED^7 flag")
3272 s = "notify_red_taken";
3276 s = "notify_blue_taken";
3279 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
3281 if(killnotify_victims[j] == "^1RED^7 flag")
3283 s = "notify_red_returned";
3287 s = "notify_blue_returned";
3290 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
3292 if(killnotify_victims[j] == "^1RED^7 flag")
3294 s = "notify_red_lost";
3298 s = "notify_blue_lost";
3301 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
3303 if(killnotify_victims[j] == "^1RED^7 flag")
3305 s = "notify_red_captured";
3309 s = "notify_blue_captured";
3312 else if(killnotify_deathtype[j] == KA_DROPBALL)
3314 s = "notify_balldropped";
3316 else if(killnotify_deathtype[j] == KA_PICKUPBALL)
3318 s = "notify_ballpickedup";
3321 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3322 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
3323 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
3327 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3328 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3331 // X [did action to] Y
3334 if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
3336 s = "notify_melee_laser";
3338 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_SHOTGUN)
3340 s = "notify_melee_shotgun";
3342 else if(WEP_VALID(w))
3344 self = get_weaponinfo(w);
3345 s = strcat("weapon", self.netname);
3347 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
3349 s = "notify_teamkill_red";
3351 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
3353 s = "notify_teamkill_red";
3355 else if(killnotify_deathtype[j] == DEATH_TELEFRAG)
3357 s = "notify_telefrag";
3359 else if(killnotify_deathtype[j] == DEATH_DROWN)
3363 else if(killnotify_deathtype[j] == DEATH_SLIME)
3367 else if(killnotify_deathtype[j] == DEATH_LAVA)
3371 else if(killnotify_deathtype[j] == DEATH_FALL)
3375 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
3377 s = "notify_shootingstar";
3379 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
3383 else if(killnotify_deathtype[j] == DEATH_HEADSHOT)
3385 s = "notify_headshot";
3387 else if(killnotify_deathtype[j] == RACE_SERVER_RECORD)
3389 s = "race_newrecordserver";
3391 else if(killnotify_deathtype[j] == RACE_NEW_RANK)
3393 s = "race_newrankyellow";
3395 else if(killnotify_deathtype[j] == RACE_NEW_TIME)
3399 else if(killnotify_deathtype[j] == RACE_FAIL)
3404 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3405 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3406 :hud_config_notifyprint
3407 width_attacker = stringwidth(attacker, TRUE, fontsize);
3408 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
3409 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
3410 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
3414 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3415 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3416 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3425 string seconds_tostring(float sec)
3428 minutes = floor(sec / 60);
3430 sec -= minutes * 60;
3431 return sprintf("%d:%02d", minutes, sec);
3434 void HUD_Timer(void)
3436 if(!autocvar_hud_panel_timer && !autocvar__hud_configure)
3439 active_panel = HUD_PANEL_TIMER;
3440 HUD_Panel_UpdateCvars(timer);
3443 mySize = panel_size;
3445 HUD_Panel_DrawBg(1);
3446 if(panel_bg_padding)
3448 pos += '1 1 0' * panel_bg_padding;
3449 mySize -= '2 2 0' * panel_bg_padding;
3453 float timelimit, elapsedTime, timeleft, minutesLeft;
3455 timelimit = getstatf(STAT_TIMELIMIT);
3457 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3458 timeleft = ceil(timeleft);
3460 minutesLeft = floor(timeleft / 60);
3463 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3464 timer_color = '1 1 1'; //white
3465 else if(minutesLeft >= 1)
3466 timer_color = '1 1 0'; //yellow
3468 timer_color = '1 0 0'; //red
3470 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
3471 if (time < getstatf(STAT_GAMESTARTTIME)) {
3472 //while restart is still active, show 00:00
3473 timer = seconds_tostring(0);
3475 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3476 timer = seconds_tostring(elapsedTime);
3479 timer = seconds_tostring(timeleft);
3482 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3487 void HUD_Radar(void)
3489 if ((autocvar_hud_panel_radar == 0 || (autocvar_hud_panel_radar != 2 && !teamplay)) && !autocvar__hud_configure)
3492 active_panel = HUD_PANEL_RADAR;
3493 HUD_Panel_UpdateCvars(radar);
3496 mySize = panel_size;
3498 HUD_Panel_DrawBg(1);
3499 if(panel_bg_padding)
3501 pos += '1 1 0' * panel_bg_padding;
3502 mySize -= '2 2 0' * panel_bg_padding;
3505 local float color1, color2; // color already declared as a global in hud.qc
3508 float scale2d, normalsize, bigsize;
3511 teamradar_origin2d = pos + 0.5 * mySize;
3512 teamradar_size2d = mySize;
3514 if(minimapname == "")
3517 teamradar_loadcvars();
3519 switch(hud_panel_radar_zoommode)
3523 f = current_zoomfraction;
3526 f = 1 - current_zoomfraction;
3536 switch(hud_panel_radar_rotation)
3539 teamradar_angle = view_angles_y - 90;
3542 teamradar_angle = 90 * hud_panel_radar_rotation;
3546 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3547 teamradar_size2d = mySize;
3549 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3551 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3552 if(hud_panel_radar_rotation == 0)
3554 // max-min distance must fit the radar in any rotation
3555 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_scale));
3559 vector c0, c1, c2, c3, span;
3560 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3561 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3562 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3563 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3565 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3566 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3568 // max-min distance must fit the radar in x=x, y=y
3570 teamradar_size2d_x * scale2d / (1.05 * span_x),
3571 teamradar_size2d_y * scale2d / (1.05 * span_y)
3575 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
3576 if(bigsize > normalsize)
3577 normalsize = bigsize;
3581 + (1 - f) * normalsize;
3582 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3584 + (1 - f) * view_origin);
3586 color1 = GetPlayerColor(player_localentnum-1);
3587 rgb = GetTeamRGB(color1);
3596 draw_teamradar_background(hud_panel_radar_foreground_alpha);
3598 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3599 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3600 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3601 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3602 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3604 color2 = GetPlayerColor(tm.sv_entnum);
3605 //if(color == COLOR_SPECTATOR || color == color2)
3606 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3608 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3610 drawresetcliparea();
3615 void HUD_Score(void)
3617 if(!autocvar_hud_panel_score && !autocvar__hud_configure)
3620 active_panel = HUD_PANEL_SCORE;
3621 HUD_Panel_UpdateCvars(score);
3624 mySize = panel_size;
3626 HUD_Panel_DrawBg(1);
3627 if(panel_bg_padding)
3629 pos += '1 1 0' * panel_bg_padding;
3630 mySize -= '2 2 0' * panel_bg_padding;
3633 float score, distribution, leader;
3635 vector distribution_color;
3637 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3639 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3640 string timer, distrtimer;
3642 pl = players.sort_next;
3645 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3646 if(pl.scores[ps_primary] == 0)
3649 score = me.(scores[ps_primary]);
3650 timer = TIME_ENCODED_TOSTRING(score);
3652 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3653 // distribution display
3654 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3656 distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS);
3658 if (distribution <= 0) {
3659 distribution_color = '0 1 0';
3663 distribution_color = '1 0 0';
3666 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);
3668 // race record display
3669 if (distribution <= 0)
3670 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3671 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3672 } else if (!teamplay) { // non-teamgames
3673 // me vector := [team/connected frags id]
3674 pl = players.sort_next;
3678 if(autocvar__hud_configure)
3681 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3685 score = me.(scores[ps_primary]);
3686 if(autocvar__hud_configure)
3689 if(distribution >= 5) {
3690 distribution_color = eY;
3692 } else if(distribution >= 0) {
3693 distribution_color = '1 1 1';
3695 } else if(distribution >= -5)
3696 distribution_color = '1 1 0';
3698 distribution_color = eX;
3700 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);
3702 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3703 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3704 } else { // teamgames
3705 float max_fragcount;
3706 max_fragcount = -99;
3709 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3710 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !autocvar__hud_configure)) // no players? don't display
3712 score = tm.(teamscores[ts_primary]);
3713 if(autocvar__hud_configure)
3717 if (score > max_fragcount)
3718 max_fragcount = score;
3720 if(tm.team == myteam) {
3721 if (max_fragcount == score)
3724 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3725 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3727 if (max_fragcount == score)
3730 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);
3731 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);
3740 void HUD_RaceTimer (void) {
3741 if(!autocvar_hud_panel_racetimer && !(gametype == GAME_RACE || gametype == GAME_CTS) && !autocvar__hud_configure)
3744 active_panel = HUD_PANEL_RACETIMER;
3745 HUD_Panel_UpdateCvars(racetimer);
3748 mySize = panel_size;
3750 HUD_Panel_DrawBg(1);
3751 if(panel_bg_padding)
3753 pos += '1 1 0' * panel_bg_padding;
3754 mySize -= '2 2 0' * panel_bg_padding;
3757 // always force 4:1 aspect
3759 if(mySize_x/mySize_y > 4)
3761 newSize_x = 4 * mySize_y;
3762 newSize_y = mySize_y;
3764 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3768 newSize_y = 1/4 * mySize_x;
3769 newSize_x = mySize_x;
3771 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3776 string s, forcetime;
3778 if(autocvar__hud_configure)
3781 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);
3782 s = _("^1Intermediate 1 (+15.42)");
3783 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);
3784 s = sprintf(_("^1PENALTY: %.1f (%s)"), 2, "missing a checkpoint");
3785 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);
3787 else if(race_checkpointtime)
3789 a = bound(0, 2 - (time - race_checkpointtime), 1);
3792 if(a > 0) // just hit a checkpoint?
3794 if(race_checkpoint != 254)
3796 if(race_time && race_previousbesttime)
3797 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3799 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3801 forcetime = TIME_ENCODED_TOSTRING(race_time);
3806 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3808 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3809 if(a > 0) // next one?
3811 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3816 if(s != "" && a > 0)
3818 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);
3821 if(race_penaltytime)
3823 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3826 s = sprintf(_("^1PENALTY: %.1f (%s)"), race_penaltytime * 0.1, race_penaltyreason);
3827 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);
3833 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3834 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);
3839 if(race_laptime && race_checkpoint != 255)
3841 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3842 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);
3847 if(race_mycheckpointtime)
3849 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3850 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3851 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);
3853 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3855 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3856 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3857 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);
3860 if(race_penaltytime && !race_penaltyaccumulator)
3862 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3863 a = bound(0, (1 + t - time), 1);
3867 s = sprintf(_("^1PENALTY: %.1f (%s)"), (t - time) * 0.1, race_penaltyreason);
3869 s = sprintf(_("^2PENALTY: %.1f (%s)"), 0, race_penaltyreason);
3870 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);
3878 float vote_yescount;
3881 float vote_highlighted; // currently selected vote
3883 float vote_active; // is there an active vote?
3884 float vote_prev; // previous state of vote_active to check for a change
3886 float vote_change; // "time" when vote_active changed
3888 void HUD_VoteWindow(void)
3890 uid2name_dialog = 0;
3891 if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
3894 vote_called_vote = strzone(_("^2Name ^7instead of \"^1Unregistered player^7\" in stats"));
3895 uid2name_dialog = 1;
3898 if(!autocvar_hud_panel_vote && !autocvar__hud_configure)
3901 if(!autocvar__hud_configure)
3903 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
3904 panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha;
3906 if(panel_bg_alpha_str == "") {
3907 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
3909 panel_bg_alpha = stof(panel_bg_alpha_str);
3914 if(vote_active != vote_prev) {
3916 vote_prev = vote_active;
3919 if(vote_active || autocvar__hud_configure)
3920 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3922 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3924 if(autocvar__hud_configure)
3934 active_panel = HUD_PANEL_VOTE;
3935 HUD_Panel_UpdateCvars(vote);
3939 panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight;
3940 panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight;
3943 // these must be below above block
3946 mySize = panel_size;
3948 a = vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3949 HUD_Panel_DrawBg(a);
3950 a = panel_fg_alpha * a;
3952 if(panel_bg_padding)
3954 pos += '1 1 0' * panel_bg_padding;
3955 mySize -= '2 2 0' * panel_bg_padding;
3958 // always force 3:1 aspect
3960 if(mySize_x/mySize_y > 3)
3962 newSize_x = 3 * mySize_y;
3963 newSize_y = mySize_y;
3965 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3969 newSize_y = 1/3 * mySize_x;
3970 newSize_x = mySize_x;
3972 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3976 s = _("A vote has been called for:");
3978 s = _("Allow servers to store and display your name?");
3979 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3980 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1/8), stringwidth_colors);
3981 if(autocvar__hud_configure)
3982 s = _("^1Configure the HUD");
3983 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
3985 // print the yes/no counts
3986 s = sprintf(_("Yes (%s): %d"), getcommandkey("vyes", "vyes"), vote_yescount);
3987 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);
3988 s = sprintf(_("No (%s): %d"), getcommandkey("vno", "vno"), vote_nocount);
3989 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);
3991 // draw the progress bar backgrounds
3992 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3994 // draw the highlights
3995 if(vote_highlighted == 1) {
3996 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3997 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3999 else if(vote_highlighted == 2) {
4000 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
4001 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
4004 // draw the progress bars
4005 if(vote_yescount && vote_needed)
4007 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
4008 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
4011 if(vote_nocount && vote_needed)
4013 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
4014 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
4017 drawresetcliparea();
4020 vote_highlighted = 0;
4024 // Mod icons panel (#10)
4027 float mod_active; // is there any active mod icon?
4029 // Clan Arena HUD modicons
4030 void HUD_Mod_CA(vector pos, vector mySize)
4032 mod_active = 1; // CA should never hide the mod icons panel
4033 float redalive, bluealive;
4034 redalive = getstati(STAT_REDALIVE);
4035 bluealive = getstati(STAT_BLUEALIVE);
4037 vector redpos, bluepos;
4038 if(mySize_x > mySize_y)
4041 bluepos = pos + eY * 0.5 * mySize_y;
4042 drawpic_aspect_skin(redpos, "player_red.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4043 drawstring_aspect(redpos + eX * 0.5 * mySize_x, ftos(redalive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4044 drawpic_aspect_skin(bluepos, "player_blue.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4045 drawstring_aspect(bluepos + eX * 0.5 * mySize_x, ftos(bluealive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4050 bluepos = pos + eY * 0.5 * mySize_y;
4051 drawpic_aspect_skin(redpos, "player_red.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4052 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);
4053 drawpic_aspect_skin(bluepos, "player_blue.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4054 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);
4058 // CTF HUD modicon section
4059 float redflag_prevframe, blueflag_prevframe; // status during previous frame
4060 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
4061 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
4063 void HUD_Mod_CTF_Reset(void)
4065 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
4068 void HUD_Mod_CTF(vector pos, vector mySize)
4070 vector redflag_pos, blueflag_pos;
4072 float f; // every function should have that
4074 float redflag, blueflag; // current status
4075 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
4078 stat_items = getstati(STAT_ITEMS);
4079 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
4080 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
4082 if(redflag || blueflag)
4087 if(autocvar__hud_configure)
4093 // when status CHANGES, set old status into prevstatus and current status into status
4094 if (redflag != redflag_prevframe)
4096 redflag_statuschange_time = time;
4097 redflag_prevstatus = redflag_prevframe;
4098 redflag_prevframe = redflag;
4101 if (blueflag != blueflag_prevframe)
4103 blueflag_statuschange_time = time;
4104 blueflag_prevstatus = blueflag_prevframe;
4105 blueflag_prevframe = blueflag;
4108 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
4109 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
4111 float BLINK_FACTOR = 0.15;
4112 float BLINK_BASE = 0.85;
4114 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
4116 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
4118 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
4120 string red_icon, red_icon_prevstatus;
4121 float red_alpha, red_alpha_prevstatus;
4122 red_alpha = red_alpha_prevstatus = 1;
4124 case 1: red_icon = "flag_red_taken"; break;
4125 case 2: red_icon = "flag_red_lost"; break;
4126 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4128 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
4129 red_icon = "flag_red_shielded";
4131 red_icon = string_null;
4134 switch(redflag_prevstatus) {
4135 case 1: red_icon_prevstatus = "flag_red_taken"; break;
4136 case 2: red_icon_prevstatus = "flag_red_lost"; break;
4137 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4140 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
4141 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
4142 red_icon_prevstatus = "flag_red_shielded";
4144 red_icon_prevstatus = string_null;
4148 string blue_icon, blue_icon_prevstatus;
4149 float blue_alpha, blue_alpha_prevstatus;
4150 blue_alpha = blue_alpha_prevstatus = 1;
4152 case 1: blue_icon = "flag_blue_taken"; break;
4153 case 2: blue_icon = "flag_blue_lost"; break;
4154 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4156 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
4157 blue_icon = "flag_blue_shielded";
4159 blue_icon = string_null;
4162 switch(blueflag_prevstatus) {
4163 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
4164 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
4165 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4168 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
4169 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
4170 blue_icon_prevstatus = "flag_blue_shielded";
4172 blue_icon_prevstatus = string_null;
4176 if(mySize_x > mySize_y) {
4177 if (myteam == COLOR_TEAM1) { // always draw own flag on left
4179 blueflag_pos = pos + eX * 0.5 * mySize_x;
4182 redflag_pos = pos + eX * 0.5 * mySize_x;
4184 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
4186 if (myteam == COLOR_TEAM1) { // always draw own flag on left
4188 blueflag_pos = pos + eY * 0.5 * mySize_y;
4191 redflag_pos = pos + eY * 0.5 * mySize_y;
4193 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
4196 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
4197 if(red_icon_prevstatus && f < 1)
4198 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
4200 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
4202 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
4203 if(blue_icon_prevstatus && f < 1)
4204 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
4206 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
4209 // Keyhunt HUD modicon section
4210 float kh_runheretime;
4212 void HUD_Mod_KH_Reset(void)
4217 void HUD_Mod_KH(vector pos, vector mySize)
4219 mod_active = 1; // keyhunt should never hide the mod icons panel
4223 vector p, pa, kh_size, kh_asize;
4225 kh_keys = getstati(STAT_KH_KEYS);
4228 if(mySize_x > mySize_y)
4230 p_y = pos_y + 0.25 * mySize_y;
4231 pa = p - eY * 0.25 * mySize_y;
4233 kh_size_x = mySize_x * 0.25;
4234 kh_size_y = 0.75 * mySize_y;
4235 kh_asize_x = mySize_x * 0.25;
4236 kh_asize_y = mySize_y * 0.25;
4240 p_y = pos_y + 0.125 * mySize_y;
4241 pa = p - eY * 0.125 * mySize_y;
4243 kh_size_x = mySize_x * 0.5;
4244 kh_size_y = 0.375 * mySize_y;
4245 kh_asize_x = mySize_x * 0.5;
4246 kh_asize_y = mySize_y * 0.125;
4253 for(i = 0; i < 4; ++i)
4255 key = floor(kh_keys / pow(32, i)) & 31;
4257 if(keyteam == 30 && keycount <= 4)
4259 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
4263 // this yields 8 exactly if "RUN HERE" shows
4268 kh_runheretime = time;
4269 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
4274 for(i = 0; i < 4; ++i)
4276 key = floor(kh_keys / pow(32, i)) & 31;
4289 default: // owned or dropped
4294 a = a * panel_fg_alpha;
4295 aa = aa * panel_fg_alpha;
4301 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4304 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4307 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4310 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4315 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
4318 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4321 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4324 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4327 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4331 if(mySize_x > mySize_y)
4333 p_x += 0.25 * mySize_x;
4334 pa_x += 0.25 * mySize_x;
4340 p_y = pos_y + 0.625 * mySize_y;
4341 pa_y = pos_y + 0.5 * mySize_y;
4347 p_x += 0.5 * mySize_x;
4348 pa_x += 0.5 * mySize_x;
4354 // Keepaway HUD mod icon
4355 float kaball_prevstatus; // last remembered status
4356 float kaball_statuschange_time; // time when the status changed
4358 // we don't need to reset for keepaway since it immediately
4359 // autocorrects prevstatus as to if the player has the ball or not
4361 void HUD_Mod_Keepaway(vector pos, vector mySize)
4363 mod_active = 1; // keepaway should always show the mod HUD
4365 float BLINK_FACTOR = 0.15;
4366 float BLINK_BASE = 0.85;
4367 float BLINK_FREQ = 5;
4368 float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
4370 float stat_items = getstati(STAT_ITEMS);
4371 float kaball = (stat_items/IT_KEY1) & 1;
4373 if(kaball != kaball_prevstatus)
4375 kaball_statuschange_time = time;
4376 kaball_prevstatus = kaball;
4379 vector kaball_pos, kaball_size;
4381 if(mySize_x > mySize_y) {
4382 kaball_pos = pos + eX * 0.25 * mySize_x;
4383 kaball_size = eX * 0.5 * mySize_x + eY * mySize_y;
4385 kaball_pos = pos + eY * 0.25 * mySize_y;
4386 kaball_size = eY * 0.5 * mySize_y + eX * mySize_x;
4389 float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
4390 float f = bound(0, kaball_statuschange_elapsedtime*2, 1);
4392 if(kaball_prevstatus && f < 1)
4393 drawpic_aspect_skin_expanding(kaball_pos, "keepawayball_carrying", kaball_size, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f);
4396 drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
4400 // Nexball HUD mod icon
4401 void HUD_Mod_NexBall(vector pos, vector mySize)
4403 float stat_items, nb_pb_starttime, dt, p;
4405 stat_items = getstati(STAT_ITEMS);
4406 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
4408 if (stat_items & IT_KEY1)
4413 //Manage the progress bar if any
4414 if (nb_pb_starttime > 0)
4416 dt = mod(time - nb_pb_starttime, nb_pb_period);
4417 // one period of positive triangle
4418 p = 2 * dt / nb_pb_period;
4424 if(mySize_x > mySize_y)
4432 HUD_Panel_GetProgressBarColor(nexball);
4433 HUD_Panel_DrawProgressBar(pos, mySize, "statusbar", vertical, 0, p, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4436 if (stat_items & IT_KEY1)
4437 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4440 // Race/CTS HUD mod icons
4441 float crecordtime_prev; // last remembered crecordtime
4442 float crecordtime_change_time; // time when crecordtime last changed
4443 float srecordtime_prev; // last remembered srecordtime
4444 float srecordtime_change_time; // time when srecordtime last changed
4446 float race_status_time;
4447 float race_status_prev;
4448 string race_status_name_prev;
4449 void HUD_Mod_Race(vector pos, vector mySize)
4451 mod_active = 1; // race should never hide the mod icons panel
4453 me = playerslots[player_localentnum - 1];
4455 float f; // yet another function has this
4456 score = me.(scores[ps_primary]);
4458 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
4459 return; // no records in the actual race
4461 // clientside personal record
4463 if(gametype == GAME_CTS)
4467 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4469 if(score && (score < t || !t)) {
4470 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4471 if(autocvar_cl_autodemo_delete_keeprecords)
4473 f = autocvar_cl_autodemo_delete;
4475 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4479 if(t != crecordtime_prev) {
4480 crecordtime_prev = t;
4481 crecordtime_change_time = time;
4484 vector textPos, medalPos;
4486 if(mySize_x > mySize_y) {
4487 // text on left side
4488 squareSize = min(mySize_y, mySize_x/2);
4489 textPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eY * 0.5 * (mySize_y - squareSize);
4490 medalPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eX * 0.5 * mySize_x + eY * 0.5 * (mySize_y - squareSize);
4493 squareSize = min(mySize_x, mySize_y/2);
4494 textPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eX * 0.5 * (mySize_x - squareSize);
4495 medalPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eY * 0.5 * mySize_y + eX * 0.5 * (mySize_x - squareSize);
4498 f = time - crecordtime_change_time;
4501 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4502 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);
4504 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4505 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);
4506 drawstring_aspect_expanding(pos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4507 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);
4511 t = race_server_record;
4512 if(t != srecordtime_prev) {
4513 srecordtime_prev = t;
4514 srecordtime_change_time = time;
4516 f = time - srecordtime_change_time;
4519 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4520 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);
4522 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4523 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);
4524 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);
4525 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);
4528 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4529 race_status_time = time + 5;
4530 race_status_prev = race_status;
4531 if (race_status_name_prev)
4532 strunzone(race_status_name_prev);
4533 race_status_name_prev = strzone(race_status_name);
4538 a = bound(0, race_status_time - time, 1);
4541 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
4545 rank = race_CheckName(race_status_name);
4547 rankname = race_PlaceName(rank);
4550 namepos = medalPos + '0 0.8 0' * squareSize;
4552 rankpos = medalPos + '0 0.15 0' * squareSize;
4554 if(race_status == 0)
4555 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4556 else if(race_status == 1) {
4557 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);
4558 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4559 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4560 } else if(race_status == 2) {
4561 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4562 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);
4564 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);
4565 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4566 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4567 } else if(race_status == 3) {
4568 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);
4569 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4570 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4573 if (race_status_time - time <= 0) {
4574 race_status_prev = -1;
4576 if(race_status_name)
4577 strunzone(race_status_name);
4578 race_status_name = string_null;
4579 if(race_status_name_prev)
4580 strunzone(race_status_name_prev);
4581 race_status_name_prev = string_null;
4585 float mod_prev; // previous state of mod_active to check for a change
4587 float mod_change; // "time" when mod_active changed
4589 void HUD_ModIcons(void)
4591 if(!autocvar_hud_panel_modicons && !autocvar__hud_configure)
4594 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)
4597 active_panel = HUD_PANEL_MODICONS;
4598 HUD_Panel_UpdateCvars(modicons);
4601 mySize = panel_size;
4603 if(mod_active != mod_prev) {
4605 mod_prev = mod_active;
4608 if(mod_active || autocvar__hud_configure)
4609 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4611 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4614 HUD_Panel_DrawBg(mod_alpha);
4616 if(panel_bg_padding)
4618 pos += '1 1 0' * panel_bg_padding;
4619 mySize -= '2 2 0' * panel_bg_padding;
4622 // these MUST be ran in order to update mod_active
4623 if(gametype == GAME_KEYHUNT)
4624 HUD_Mod_KH(pos, mySize);
4625 else if(gametype == GAME_CTF || autocvar__hud_configure)
4626 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4627 else if(gametype == GAME_NEXBALL)
4628 HUD_Mod_NexBall(pos, mySize);
4629 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4630 HUD_Mod_Race(pos, mySize);
4631 else if(gametype == GAME_CA || gametype == GAME_FREEZETAG)
4632 HUD_Mod_CA(pos, mySize);
4633 else if(gametype == GAME_KEEPAWAY)
4634 HUD_Mod_Keepaway(pos, mySize);
4637 // Draw pressed keys (#11)
4639 void HUD_DrawPressedKeys(void)
4641 if(!autocvar_hud_panel_pressedkeys && !autocvar__hud_configure)
4644 if(!(spectatee_status > 0 || autocvar_hud_panel_pressedkeys >= 2 || autocvar__hud_configure))
4647 active_panel = HUD_PANEL_PRESSEDKEYS;
4648 HUD_Panel_UpdateCvars(pressedkeys);
4651 mySize = panel_size;
4653 HUD_Panel_DrawBg(1);
4654 if(panel_bg_padding)
4656 pos += '1 1 0' * panel_bg_padding;
4657 mySize -= '2 2 0' * panel_bg_padding;
4660 // force custom aspect
4661 float aspect = autocvar_hud_panel_pressedkeys_aspect;
4665 if(mySize_x/mySize_y > aspect)
4667 newSize_x = aspect * mySize_y;
4668 newSize_y = mySize_y;
4670 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4674 newSize_y = 1/aspect * mySize_x;
4675 newSize_x = mySize_x;
4677 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4683 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4686 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4687 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4688 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);
4689 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);
4690 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);
4691 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);
4692 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);
4695 // Handle chat as a panel (#12)
4699 if(!autocvar_hud_panel_chat && !autocvar__hud_configure)
4701 cvar_set("con_chatrect", "0");
4705 active_panel = HUD_PANEL_CHAT;
4706 HUD_Panel_UpdateCvars(chat);
4708 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
4710 panel_pos_y = panel_bg_border;
4711 panel_size_y = vid_conheight - panel_bg_border * 2;
4712 if(panel_bg == "0") // force a border when maximized
4714 if(precache_pic(panel_bg) == "") {
4715 panel_bg = strcat(hud_skin_path, "/border_default");
4716 if(precache_pic(panel_bg) == "") {
4717 panel_bg = "gfx/hud/default/border_default";
4721 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an alpha of at least 0.75
4726 mySize = panel_size;
4728 HUD_Panel_DrawBg(1);
4730 if(panel_bg_padding)
4732 pos += '1 1 0' * panel_bg_padding;
4733 mySize -= '2 2 0' * panel_bg_padding;
4736 cvar_set("con_chatrect", "1");
4738 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4739 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4741 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4742 cvar_set("con_chat", ftos(floor(mySize_y/autocvar_con_chatsize - 0.5)));
4744 if(autocvar__hud_configure)
4747 chatsize = autocvar_con_chatsize;
4748 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4750 for(i = 0; i < autocvar_con_chat; ++i)
4752 if(i == autocvar_con_chat - 1)
4755 a = panel_fg_alpha * floor(((i + 1) * 7 + autocvar_con_chattime)/45);
4756 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);
4761 // Engine info panel (#13)
4768 float frametimeavg1; // 1 frame ago
4769 float frametimeavg2; // 2 frames ago
4770 void HUD_EngineInfo(void)
4772 if(!autocvar_hud_panel_engineinfo && !autocvar__hud_configure)
4775 active_panel = HUD_PANEL_ENGINEINFO;
4776 HUD_Panel_UpdateCvars(engineinfo);
4779 mySize = panel_size;
4781 HUD_Panel_DrawBg(1);
4782 if(panel_bg_padding)
4784 pos += '1 1 0' * panel_bg_padding;
4785 mySize -= '2 2 0' * panel_bg_padding;
4788 float currentTime = gettime(GETTIME_REALTIME);
4789 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
4791 float currentframetime = currentTime - prevfps_time;
4792 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4793 frametimeavg2 = frametimeavg1;
4794 frametimeavg1 = frametimeavg;
4797 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4798 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.
4800 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
4801 prevfps = (1/currentframetime);
4802 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"
4804 prevfps_time = currentTime;
4809 if(currentTime - prevfps_time > autocvar_hud_panel_engineinfo_framecounter_time)
4811 prevfps = framecounter/(currentTime - prevfps_time);
4813 prevfps_time = currentTime;
4818 color = HUD_Get_Num_Color (prevfps, 100);
4819 drawstring_aspect(pos, sprintf(_("FPS: %.*f"), autocvar_hud_panel_engineinfo_framecounter_decimals, prevfps), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4822 // Info messages panel (#14)
4824 #define drawInfoMessage(s)\
4825 if(autocvar_hud_panel_infomessages_flip)\
4826 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);\
4827 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
4829 void HUD_InfoMessages(void)
4831 if(!autocvar_hud_panel_infomessages && !autocvar__hud_configure)
4834 active_panel = HUD_PANEL_INFOMESSAGES;
4835 HUD_Panel_UpdateCvars(infomessages);
4838 mySize = panel_size;
4840 HUD_Panel_DrawBg(1);
4841 if(panel_bg_padding)
4843 pos += '1 1 0' * panel_bg_padding;
4844 mySize -= '2 2 0' * panel_bg_padding;
4847 // always force 5:1 aspect
4849 if(mySize_x/mySize_y > 5)
4851 newSize_x = 5 * mySize_y;
4852 newSize_y = mySize_y;
4854 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4858 newSize_y = 1/5 * mySize_x;
4859 newSize_x = mySize_x;
4861 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4870 fontsize = '0.20 0.20 0' * mySize_y;
4873 if(spectatee_status != 0)
4879 if(!autocvar__hud_configure)
4881 if(spectatee_status && !intermission)
4883 if(spectatee_status == -1)
4884 s = _("^1Observing");
4886 s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(spectatee_status - 1));
4889 if(spectatee_status == -1)
4890 s = sprintf(_("^1Press ^3%s^1 to spectate"), getcommandkey("primary fire", "+fire"));
4892 s = sprintf(_("^1Press ^3%s^1 for another player"), getcommandkey("primary fire", "+fire"));
4895 if(spectatee_status == -1)
4896 s = sprintf(_("^1Use ^3%s^1 or ^3%s^1 to change the speed"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
4898 s = sprintf(_("^1Press ^3%s^1 to observe"), getcommandkey("secondary fire", "+fire2"));
4901 s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey("server info", "+show_info"));
4904 if(gametype == GAME_ARENA)
4905 s = _("^1Wait for your turn to join");
4906 else if(gametype == GAME_LMS)
4909 sk = playerslots[player_localentnum - 1];
4910 if(sk.(scores[ps_primary]) >= 666)
4911 s = _("^1Match has already begun");
4912 else if(sk.(scores[ps_primary]) > 0)
4913 s = _("^1You have no more lives left");
4915 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
4918 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
4921 //show restart countdown:
4922 if (time < getstatf(STAT_GAMESTARTTIME)) {
4924 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4925 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4926 s = sprintf(_("^1Game starts in ^3%d^1 seconds"), countdown);
4927 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4931 if(warmup_stage && !intermission)
4933 s = _("^2Currently in ^1warmup^2 stage!");
4938 if(mod(time, 1) >= 0.5)
4943 if(ready_waiting && !intermission && !spectatee_status)
4945 if(ready_waiting_for_me)
4948 s = sprintf(_("%sPress ^3%s%s to end warmup"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
4950 s = sprintf(_("%sPress ^3%s%s once you are ready"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
4955 s = _("^2Waiting for others to ready up to end warmup...");
4957 s = _("^2Waiting for others to ready up...");
4961 else if(warmup_stage && !intermission && !spectatee_status)
4963 s = sprintf(_("^2Press ^3%s^2 to end warmup"), getcommandkey("ready", "ready"));
4967 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4969 float ts_min, ts_max;
4970 tm = teams.sort_next;
4973 for(; tm.sort_next; tm = tm.sort_next)
4975 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4977 if(!ts_min) ts_min = tm.team_size;
4978 else ts_min = min(ts_min, tm.team_size);
4979 if(!ts_max) ts_max = tm.team_size;
4980 else ts_max = max(ts_max, tm.team_size);
4982 if ((ts_max - ts_min) > 1)
4984 s = strcat(blinkcolor, _("Teamnumbers are unbalanced!"));
4985 tm = GetTeam(myteam, false);
4987 if (tm.team != COLOR_SPECTATOR)
4988 if (tm.team_size == ts_max)
4989 s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey("team menu", "menu_showteamselect"), blinkcolor));
4997 s = _("^7Press ^3ESC ^7to show HUD options.");
4999 s = _("^3Doubleclick ^7a panel for panel-specific options.");
5001 s = _("^3CTRL ^7to disable collision testing, ^3SHIFT ^7and");
5003 s = _("^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.");
5010 float shownames_alpha;
5011 void HUD_ShowNames(void)
5013 if(shownames_time < time && shownames_alpha == 0 && !autocvar__hud_configure)
5016 if(autocvar__hud_configure)
5018 shownames_alpha = 1;
5022 if(shownames_time < time)
5023 shownames_alpha = bound(0, shownames_alpha - 2 * frametime, 1);
5025 shownames_alpha = bound(0, shownames_alpha + 4 * frametime, 1);
5028 if(!autocvar_hud_panel_shownames && !autocvar__hud_configure)
5031 active_panel = HUD_PANEL_SHOWNAMES;
5032 HUD_Panel_UpdateCvars(shownames);
5033 panel_fg_alpha *= shownames_alpha;
5034 vector myPos, mySize;
5036 mySize = panel_size;
5038 HUD_Panel_DrawBg(shownames_alpha);
5039 if(panel_bg_padding)
5041 myPos += '1 1 0' * panel_bg_padding;
5042 mySize -= '2 2 0' * panel_bg_padding;
5045 vector iconpos, iconsize;
5046 vector namepos, namesize;
5047 if(mySize_x/mySize_y > 6)
5050 iconsize = eX * 2 * mySize_y + eY * mySize_y;
5052 namepos = myPos + eX * 2 * mySize_y;
5053 namesize = eX * mySize_x - eX * 2 * mySize_y + eY * mySize_y;
5057 iconpos = myPos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_y;
5058 iconsize = eX * mySize_y + eY * 0.5 * mySize_y;
5060 namepos = myPos + eY * 0.5 * mySize_y;
5061 namesize = eX * mySize_x + eY * 0.5 * mySize_y;
5064 if(shownames_health > 0) // otherwise player is an enemy
5066 // "ghost" backgrounds
5067 drawpic_aspect_skin(iconpos, "health", '1 1 0' * iconsize_y, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
5068 drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor", '1 1 0' * iconsize_y, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
5070 drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, shownames_health/200), vid_conwidth, myPos_y + iconsize_y);
5071 drawpic_aspect_skin(iconpos, "health", '1 1 0' * iconsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
5073 drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, shownames_armor/200), vid_conwidth, myPos_y + iconsize_y);
5074 drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor", '1 1 0' * iconsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
5075 drawresetcliparea();
5079 drawpic_aspect_skin(iconpos, "health_unknown", '1 1 0' * iconsize_y, '0 0 0', panel_fg_alpha, DRAWFLAG_NORMAL);
5080 drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor_unknown", '1 1 0' * iconsize_y, '0 0 0', panel_fg_alpha, DRAWFLAG_NORMAL);
5083 if(autocvar__hud_configure)
5084 drawcolorcodedstring_aspect(namepos, "Player1234", namesize, panel_fg_alpha, DRAWFLAG_NORMAL);
5086 drawcolorcodedstring_aspect(namepos, shownames_netname, namesize, panel_fg_alpha, DRAWFLAG_NORMAL);
5095 void HUD_ShowSpeed(void)
5098 float pos, conversion_factor;
5099 string speed, zspeed, unit;
5101 switch(autocvar_cl_showspeed_unit)
5106 conversion_factor = 1.0;
5110 conversion_factor = 1.0;
5114 conversion_factor = 0.0254;
5118 conversion_factor = 0.0254 * 3.6;
5122 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
5126 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
5130 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
5132 numsize_x = numsize_y = autocvar_cl_showspeed_size;
5133 pos = (vid_conheight - numsize_y) * autocvar_cl_showspeed_position;
5135 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
5137 if (autocvar_cl_showspeed_z == 1) {
5138 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
5139 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
5143 vector acc_prevspeed;
5147 void HUD_ShowAcceleration(void)
5149 float acceleration, sz, scale, alpha, f;
5150 vector pos, top, rgb;
5151 top_x = vid_conwidth/2;
5154 f = time - acc_prevtime;
5155 if(autocvar_cl_showacceleration_z)
5156 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
5158 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
5159 acc_prevspeed = pmove_vel;
5160 acc_prevtime = time;
5162 f = bound(0, f * 10, 1);
5163 acc_avg = acc_avg * (1 - f) + acceleration * f;
5164 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
5165 if (acceleration == 0)
5168 pos = top - sz/2 * eY + (autocvar_cl_showacceleration_position * vid_conheight) * eY;
5170 sz = autocvar_cl_showacceleration_size;
5171 scale = autocvar_cl_showacceleration_scale;
5172 alpha = autocvar_cl_showacceleration_alpha;
5173 if (autocvar_cl_showacceleration_color_custom)
5174 rgb = stov(autocvar_cl_showacceleration_color);
5176 if (acceleration < 0)
5177 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
5179 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
5182 if (acceleration > 0)
5183 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);
5185 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);
5188 void HUD_Reset (void)
5190 // reset gametype specific icons
5191 if(gametype == GAME_KEYHUNT)
5193 else if(gametype == GAME_CTF)
5194 HUD_Mod_CTF_Reset();
5197 #define HUD_DrawPanel(id)\
5199 case (HUD_PANEL_RADAR):\
5200 HUD_Radar(); break;\
5201 case (HUD_PANEL_WEAPONS):\
5202 HUD_Weapons(); break;\
5203 case (HUD_PANEL_AMMO):\
5205 case (HUD_PANEL_POWERUPS):\
5206 HUD_Powerups(); break;\
5207 case (HUD_PANEL_HEALTHARMOR):\
5208 HUD_HealthArmor(); break;\
5209 case (HUD_PANEL_NOTIFY):\
5210 HUD_Notify(); break;\
5211 case (HUD_PANEL_TIMER):\
5212 HUD_Timer(); break;\
5213 case (HUD_PANEL_SCORE):\
5214 HUD_Score(); break;\
5215 case (HUD_PANEL_RACETIMER):\
5216 HUD_RaceTimer(); break;\
5217 case (HUD_PANEL_VOTE):\
5218 HUD_VoteWindow(); break;\
5219 case (HUD_PANEL_MODICONS):\
5220 HUD_ModIcons(); break;\
5221 case (HUD_PANEL_PRESSEDKEYS):\
5222 HUD_DrawPressedKeys(); break;\
5223 case (HUD_PANEL_CHAT):\
5225 case (HUD_PANEL_ENGINEINFO):\
5226 HUD_EngineInfo(); break;\
5227 case (HUD_PANEL_INFOMESSAGES):\
5228 HUD_InfoMessages(); break;\
5229 case (HUD_PANEL_SHOWNAMES):\
5230 HUD_ShowNames(); break;\
5231 } ENDS_WITH_CURLY_BRACE
5233 void HUD_Main (void)
5236 // global hud alpha fade
5237 if(menu_enabled == 1)
5240 hud_fade_alpha = (1 - autocvar__menu_alpha);
5242 if(scoreboard_fade_alpha)
5243 hud_fade_alpha = (1 - scoreboard_fade_alpha);
5245 if(intermission == 2) // no hud during mapvote
5247 else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
5250 hud_fontsize = HUD_GetFontsize("hud_fontsize");
5252 if(!autocvar__hud_configure && !hud_fade_alpha)
5256 if (hud_skin_path != autocvar_hud_skin)
5259 strunzone(hud_skin_path);
5260 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
5263 // HUD configure visible grid
5264 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
5267 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2); ++i)
5269 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);
5272 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2); ++i)
5274 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);
5278 current_player = (spectatee_status > 0) ? spectatee_status : player_localentnum;
5281 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
5285 float hud_dock_color_team = autocvar_hud_dock_color_team;
5286 if((teamplay) && hud_dock_color_team) {
5287 f = stof(getplayerkey(current_player - 1, "colors"));
5288 color = colormapPaletteColor(mod(f, 16), 1) * hud_dock_color_team;
5290 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
5291 color = '1 0 0' * hud_dock_color_team;
5295 string hud_dock_color = autocvar_hud_dock_color;
5296 if(hud_dock_color == "shirt") {
5297 f = stof(getplayerkey(current_player - 1, "colors"));
5298 color = colormapPaletteColor(floor(f / 16), 0);
5300 else if(hud_dock_color == "pants") {
5301 f = stof(getplayerkey(current_player - 1, "colors"));
5302 color = colormapPaletteColor(mod(f, 16), 1);
5305 color = stov(hud_dock_color);
5309 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
5310 if(precache_pic(pic) == "") {
5311 pic = strcat(hud_skin_path, "/dock_medium");
5312 if(precache_pic(pic) == "") {
5313 pic = "gfx/hud/default/dock_medium";
5316 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...
5319 // cache the panel order into the panel_order array
5320 if(autocvar__hud_panelorder != hud_panelorder_prev) {
5321 if(hud_panelorder_prev)
5322 strunzone(hud_panelorder_prev);
5323 hud_panelorder_prev = strzone(autocvar__hud_panelorder);
5324 tokenize_console(autocvar__hud_panelorder);
5325 for(i = 0; i < HUD_PANEL_NUM; ++i) {
5326 panel_order[i] = stof(argv(i));
5329 // draw panels in order specified by panel_order array
5330 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
5331 if(i != HUD_PANEL_CHAT || !autocvar__con_chat_maximized) // don't draw maximized chat panel twice!
5332 HUD_DrawPanel(panel_order[i]);
5335 // draw chat panel on top if it is maximized
5336 if(autocvar__con_chat_maximized)
5337 HUD_Chat(); // HUD_DrawPanel(HUD_PANEL_CHAT);
5339 // TODO hud_'ify these
5340 if (autocvar_cl_showspeed)
5342 if (autocvar_cl_showacceleration)
5343 HUD_ShowAcceleration();
5345 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)
5346 localcmd("cmd selectteam auto; cmd join\n");
5348 hud_configure_prev = autocvar__hud_configure;
5350 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again