7 // a border picture is a texture containing nine parts:
8 // 1/4 width: left part
9 // 1/2 width: middle part (stretched)
10 // 1/4 width: right part
12 // 1/4 height: top part
13 // 1/2 height: middle part (stretched)
14 // 1/4 height: bottom part
15 void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize)
17 if (theBorderSize_x <= 0 && theBorderSize_y <= 0) // no border
19 // draw only the central part
20 drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
27 //pic = draw_UseSkinFor(pic);
28 width = eX * theSize_x;
29 height = eY * theSize_y;
30 if(theSize_x <= theBorderSize_x * 2)
32 // not wide enough... draw just left and right then
33 bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
34 if(theSize_y <= theBorderSize_y * 2)
36 // not high enough... draw just corners
37 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
38 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
39 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
40 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
41 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
45 dY = theBorderSize_x * eY;
46 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
47 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
48 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
49 drawsubpic(theOrigin + width * 0.5 + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0' + eX - bW, '0 0.5 0' + bW, theColor, theAlpha, 0);
50 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
51 drawsubpic(theOrigin + width * 0.5 + height - dY, width * 0.5 + dY, pic, '0 0.75 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
56 if(theSize_y <= theBorderSize_y * 2)
58 // not high enough... draw just top and bottom then
59 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
60 dX = theBorderSize_x * eX;
61 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
62 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
63 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
64 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
65 drawsubpic(theOrigin + dX + height * 0.5, width - 2 * dX + height * 0.5, pic, '0.25 0 0' + eY - bH, '0.5 0 0' + bH, theColor, theAlpha, 0);
66 drawsubpic(theOrigin + width - dX + height * 0.5, dX + height * 0.5, pic, '0.75 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
70 dX = theBorderSize_x * eX;
71 dY = theBorderSize_x * eY;
72 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
73 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
74 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
75 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
76 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
77 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
78 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
79 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
80 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
85 vector HUD_Get_Num_Color (float x, float maxvalue)
93 else if(x > maxvalue * 0.75) {
94 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
95 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
98 else if(x > maxvalue * 0.5) {
99 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
100 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
101 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
103 else if(x > maxvalue * 0.25) {
106 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
108 else if(x > maxvalue * 0.1) {
110 color_y = (x-20)*90/27/100; // green value between 0 -> 1
111 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
121 float stringwidth_colors(string s, vector theSize)
123 return stringwidth(s, TRUE, theSize);
126 float stringwidth_nocolors(string s, vector theSize)
128 return stringwidth(s, FALSE, theSize);
131 #define CENTERPRINT_MAX_LINES 30
132 string centerprint_messages[CENTERPRINT_MAX_LINES];
133 float centerprint_width[CENTERPRINT_MAX_LINES];
134 float centerprint_time;
135 float centerprint_expire;
136 float centerprint_num;
137 float centerprint_offset_hint;
138 vector centerprint_fontsize;
140 void centerprint(string strMessage)
142 float i, j, n, hcount;
145 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
147 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
149 if(cvar("scr_centertime") <= 0)
155 // strip trailing newlines
156 j = strlen(strMessage) - 1;
157 while(substring(strMessage, j, 1) == "\n" && j >= 0)
159 strMessage = substring(strMessage, 0, j + 1);
164 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
166 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
168 strMessage = substring(strMessage, j, strlen(strMessage) - j);
169 centerprint_offset_hint = j;
174 // if we get here, we have a message. Initialize its height.
177 n = tokenizebyseparator(strMessage, "\n");
179 for(j = 0; j < n; ++j)
181 getWrappedLine_remaining = argv(j);
182 while(getWrappedLine_remaining)
184 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
185 if(centerprint_messages[i] != s) // don't fade the same message in, looks stupid
186 centerprint_time = time;
187 if(centerprint_messages[i])
188 strunzone(centerprint_messages[i]);
189 centerprint_messages[i] = strzone(s);
190 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
193 // half height for empty lines looks better
199 if(i >= CENTERPRINT_MAX_LINES)
205 h = centerprint_fontsize_y*hcount;
207 havail = vid_conheight;
208 if(cvar("con_chatpos") < 0)
209 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
210 if(havail > vid_conheight - 70)
211 havail = vid_conheight - 70; // avoid overlapping HUD
214 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
216 // here, the centerprint would cover the crosshair. REALLY BAD.
217 forbiddenmin = vid_conheight * 0.5 - h - 16;
218 forbiddenmax = vid_conheight * 0.5 + 16;
220 allowedmin = scoreboard_bottom;
221 allowedmax = havail - h;
222 preferred = (havail - h)/2;
225 // possible orderings (total: 4! / 4 = 6)
226 // allowedmin allowedmax forbiddenmin forbiddenmax
227 // forbiddenmin forbiddenmax allowedmin allowedmax
228 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
230 // forbidden doesn't matter in this case
231 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
233 // allowedmin forbiddenmin allowedmax forbiddenmax
234 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
236 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
238 // allowedmin forbiddenmin forbiddenmax allowedmax
239 else if(allowedmin < forbiddenmin)
241 // make sure the forbidden zone is not covered
242 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
243 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
245 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
247 // forbiddenmin allowedmin allowedmax forbiddenmax
248 else if(allowedmax < forbiddenmax)
250 // it's better to leave the allowed zone (overlap with scoreboard) than
251 // to cover the forbidden zone (crosshair)
252 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
253 centerprint_start_y = forbiddenmax;
255 centerprint_start_y = forbiddenmin;
257 // forbiddenmin allowedmin forbiddenmax allowedmax
260 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
267 centerprint_expire = time + cvar("scr_centertime");
270 void HUD_DrawCenterPrint (void)
277 if(time - centerprint_time < 0.25)
278 a = (time - centerprint_time) / 0.25;
280 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
287 if(centerprint_num * cvar("scr_centersize") > 24 && scoreboard_active) // 24 = height of Scoreboard text
288 centerprint_start_y = scoreboard_bottom + centerprint_fontsize_y;
290 pos = centerprint_start;
291 for (i=0; i<centerprint_num; i = i + 1)
293 ts = centerprint_messages[i];
294 drawfontscale = sz * '1 1 0';
295 drawfont = hud_bigfont;
296 pos_x = (vid_conwidth - stringwidth(ts, TRUE, centerprint_fontsize)) * 0.5;
299 drawcolorcodedstring(pos + '0 1 0' * (1 - sz) * 0.5 *centerprint_fontsize_y, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
300 pos_y = pos_y + centerprint_fontsize_y;
303 // half height for empty lines looks better
304 pos_y = pos_y + sz * centerprint_fontsize_y * 0.5;
305 drawfontscale = '1 1 0';
310 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
312 position_x -= 2 / 3 * strlen(text) * scale_x;
313 drawstring(position, text, scale, rgb, alpha, flag);
316 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
318 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
319 drawstring(position, text, scale, rgb, alpha, flag);
322 // return the string of the given race place
323 string race_PlaceName(float pos) {
331 return strcat(ftos(pos), "th");
334 // return the string of the onscreen race timer
335 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
343 if(histime == 0) // goal hit
347 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
357 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
363 lapstr = strcat(" (-", ftos(lapdelta), "L)");
366 else if(lapdelta < 0)
368 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
372 else if(histime > 0) // anticipation
374 if(mytime >= histime)
375 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
377 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
384 cpname = "Start line";
386 cpname = "Finish line";
388 cpname = strcat("Intermediate ", ftos(cp));
390 cpname = "Finish line";
393 return strcat(col, cpname);
394 else if(hisname == "")
395 return strcat(col, cpname, " (", timestr, ")");
397 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
400 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
401 float race_CheckName(string net_name) {
403 for (i=RANKINGS_CNT-1;i>=0;--i)
404 if(grecordholder[i] == net_name)
415 #define HUD_Write(s) fputs(fh, s)
416 // q: quoted, n: not quoted
417 #define HUD_Write_Cvar_n(cvar) HUD_Write(strcat("seta ", cvar, " ", cvar_string(cvar), "\n"))
418 #define HUD_Write_Cvar_q(cvar) HUD_Write(strcat("seta ", cvar, " \"", cvar_string(cvar), "\"\n"))
419 #define HUD_Write_PanelCvar_n(cvar_suf) HUD_Write_Cvar_n(strcat("hud_panel_", panel_name, cvar_suf))
420 #define HUD_Write_PanelCvar_q(cvar_suf) HUD_Write_Cvar_q(strcat("hud_panel_", panel_name, cvar_suf))
422 void HUD_Panel_ExportCfg(string cfgname)
425 string filename = strcat("hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg");
426 fh = fopen(filename, FILE_WRITE);
429 HUD_Write_Cvar_q("hud_skin");
430 HUD_Write_Cvar_q("hud_panel_bg");
431 HUD_Write_Cvar_q("hud_panel_bg_color");
432 HUD_Write_Cvar_q("hud_panel_bg_color_team");
433 HUD_Write_Cvar_q("hud_panel_bg_alpha");
434 HUD_Write_Cvar_q("hud_panel_bg_border");
435 HUD_Write_Cvar_q("hud_panel_bg_padding");
436 HUD_Write_Cvar_q("hud_panel_fg_alpha");
439 HUD_Write_Cvar_q("hud_dock");
440 HUD_Write_Cvar_q("hud_dock_color");
441 HUD_Write_Cvar_q("hud_dock_color_team");
442 HUD_Write_Cvar_q("hud_dock_alpha");
445 HUD_Write_Cvar_q("hud_progressbar_alpha");
446 HUD_Write_Cvar_q("hud_progressbar_strength_color");
447 HUD_Write_Cvar_q("hud_progressbar_shield_color");
448 HUD_Write_Cvar_q("hud_progressbar_health_color");
449 HUD_Write_Cvar_q("hud_progressbar_armor_color");
450 HUD_Write_Cvar_q("hud_progressbar_fuel_color");
451 HUD_Write_Cvar_q("hud_progressbar_nexball_color");
454 HUD_Write_Cvar_q("_hud_panelorder");
457 HUD_Write_Cvar_q("hud_configure_grid");
458 HUD_Write_Cvar_q("hud_configure_grid_xsize");
459 HUD_Write_Cvar_q("hud_configure_grid_ysize");
462 HUD_Write_Cvar_q("scr_centerpos");
465 // common cvars for all panels
467 for (i = 0; i < HUD_PANEL_NUM; ++i)
469 HUD_Panel_GetName(i);
471 HUD_Write_PanelCvar_n("");
472 HUD_Write_PanelCvar_q("_pos");
473 HUD_Write_PanelCvar_q("_size");
474 HUD_Write_PanelCvar_q("_bg");
475 HUD_Write_PanelCvar_q("_bg_color");
476 HUD_Write_PanelCvar_q("_bg_color_team");
477 HUD_Write_PanelCvar_q("_bg_alpha");
478 HUD_Write_PanelCvar_q("_bg_border");
479 HUD_Write_PanelCvar_q("_bg_padding");
481 case HUD_PANEL_WEAPONS:
482 HUD_Write_PanelCvar_q("_complainbubble");
483 HUD_Write_PanelCvar_q("_complainbubble_padding");
484 HUD_Write_PanelCvar_q("_complainbubble_color_outofammo");
485 HUD_Write_PanelCvar_q("_complainbubble_color_donthave");
486 HUD_Write_PanelCvar_q("_complainbubble_color_unavailable");
487 HUD_Write_PanelCvar_q("_ammo_color");
488 HUD_Write_PanelCvar_q("_ammo_alpha");
489 HUD_Write_PanelCvar_q("_aspect");
492 HUD_Write_PanelCvar_q("_onlycurrent");
493 HUD_Write_PanelCvar_q("_iconalign");
495 case HUD_PANEL_POWERUPS:
496 HUD_Write_PanelCvar_q("_flip");
497 HUD_Write_PanelCvar_q("_iconalign");
498 HUD_Write_PanelCvar_q("_baralign");
499 HUD_Write_PanelCvar_q("_progressbar");
501 case HUD_PANEL_HEALTHARMOR:
502 HUD_Write_PanelCvar_q("_flip");
503 HUD_Write_PanelCvar_q("_iconalign");
504 HUD_Write_PanelCvar_q("_baralign");
505 HUD_Write_PanelCvar_q("_progressbar");
507 case HUD_PANEL_NOTIFY:
508 HUD_Write_PanelCvar_q("_flip");
509 HUD_Write_PanelCvar_q("_print");
511 case HUD_PANEL_RADAR:
512 HUD_Write_PanelCvar_q("_foreground_alpha");
515 HUD_Write_PanelCvar_q("_alreadyvoted_alpha");
517 case HUD_PANEL_PRESSEDKEYS:
518 HUD_Write_PanelCvar_q("_aspect");
520 case HUD_PANEL_INFOMESSAGES:
521 HUD_Write_PanelCvar_q("_flip");
526 HUD_Write("menu_sync\n"); // force the menu to reread the cvars, so that the dialogs are updated
528 print("^2Successfully exported to ", filename, "! (Note: It's saved in data/data/)\n");
532 print("^1Couldn't write to ", filename, "\n");
535 const float hlBorderSize = 4;
536 const string hlBorder = "gfx/hud/default/border_highlighted";
537 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
538 void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
540 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
541 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);
542 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);
543 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);
544 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);
547 // draw the background/borders
548 #define HUD_Panel_DrawBg(alpha)\
550 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));\
551 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
553 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);\
554 } ENDS_WITH_CURLY_BRACE
556 //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
557 void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, float lenght_ratio, float vertical, float right_align, vector theColor, float theAlpha, float drawflag)
559 if(lenght_ratio <= 0 || !theAlpha)
566 vector width, height;
568 pic = strcat(hud_skin_path, "/statusbar_vertical");
569 if(precache_pic(pic) == "") {
570 pic = "gfx/hud/default/statusbar_vertical";
574 theOrigin_y += (1 - lenght_ratio) * theSize_y;
575 theSize_y *= lenght_ratio;
578 width = eX * theSize_x;
579 height = eY * theSize_y;
580 if(theSize_y <= theSize_x * 2)
582 // button not high enough
583 // draw just upper and lower part then
584 square = eY * theSize_y * 0.5;
585 bH = eY * (0.25 * theSize_y / (theSize_x * 2));
586 drawsubpic(theOrigin, square + width, pic, '0 0 0', eX + bH, theColor, theAlpha, drawflag);
587 drawsubpic(theOrigin + square, square + width, pic, eY - bH, eX + bH, theColor, theAlpha, drawflag);
591 square = eY * theSize_x;
592 drawsubpic(theOrigin, width + square, pic, '0 0 0', '1 0.25 0', theColor, theAlpha, drawflag);
593 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0 0.25 0', '1 0.5 0', theColor, theAlpha, drawflag);
594 drawsubpic(theOrigin + height - square, width + square, pic, '0 0.75 0', '1 0.25 0', theColor, theAlpha, drawflag);
597 pic = strcat(hud_skin_path, "/statusbar");
598 if(precache_pic(pic) == "") {
599 pic = "gfx/hud/default/statusbar";
603 theOrigin_x += (1 - lenght_ratio) * theSize_x;
604 theSize_x *= lenght_ratio;
607 width = eX * theSize_x;
608 height = eY * theSize_y;
609 if(theSize_x <= theSize_y * 2)
611 // button not wide enough
612 // draw just left and right part then
613 square = eX * theSize_x * 0.5;
614 bW = eX * (0.25 * theSize_x / (theSize_y * 2));
615 drawsubpic(theOrigin, square + height, pic, '0 0 0', eY + bW, theColor, theAlpha, drawflag);
616 drawsubpic(theOrigin + square, square + height, pic, eX - bW, eY + bW, theColor, theAlpha, drawflag);
620 square = eX * theSize_y;
621 drawsubpic(theOrigin, height + square, pic, '0 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
622 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0.25 0 0', '0.5 1 0', theColor, theAlpha, drawflag);
623 drawsubpic(theOrigin + width - square, height + square, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
628 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
634 pic = strcat(hud_skin_path, "/num_leading");
635 if(precache_pic(pic) == "") {
636 pic = "gfx/hud/default/num_leading";
639 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
640 if(mySize_x/mySize_y > 2)
641 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);
642 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);
645 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
646 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
655 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
656 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
658 for (i = 0; i < HUD_PANEL_NUM; ++i) {
659 if(i == highlightedPanel || !panel_enabled)
662 HUD_Panel_UpdatePosSizeForId(i);
664 panel_pos -= '1 1 0' * panel_bg_border;
665 panel_size += '2 2 0' * panel_bg_border;
667 if(myPos_y + mySize_y < panel_pos_y)
669 if(myPos_y > panel_pos_y + panel_size_y)
672 if(myPos_x + mySize_x < panel_pos_x)
674 if(myPos_x > panel_pos_x + panel_size_x)
677 // OK, there IS a collision.
679 myCenter_x = myPos_x + 0.5 * mySize_x;
680 myCenter_y = myPos_y + 0.5 * mySize_y;
682 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
683 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
685 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
687 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
688 myTarget_x = panel_pos_x - mySize_x;
689 else // push it upwards
690 myTarget_y = panel_pos_y - mySize_y;
692 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
694 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
695 myTarget_x = panel_pos_x + panel_size_x;
696 else // push it upwards
697 myTarget_y = panel_pos_y - mySize_y;
699 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
701 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
702 myTarget_x = panel_pos_x - mySize_x;
703 else // push it downwards
704 myTarget_y = panel_pos_y + panel_size_y;
706 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
708 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
709 myTarget_x = panel_pos_x + panel_size_x;
710 else // push it downwards
711 myTarget_y = panel_pos_y + panel_size_y;
713 //if(cvar("hud_configure_checkcollisions_debug"))
714 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
720 void HUD_Panel_SetPos(vector pos)
722 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
726 //if(cvar("hud_configure_checkcollisions_debug"))
727 //drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
729 if(cvar("hud_configure_grid"))
731 pos_x = floor((pos_x/vid_conwidth)/hud_configure_gridSize_x + 0.5) * hud_configure_realGridSize_x;
732 pos_y = floor((pos_y/vid_conheight)/hud_configure_gridSize_y + 0.5) * hud_configure_realGridSize_y;
735 if(hud_configure_checkcollisions)
736 pos = HUD_Panel_CheckMove(pos, mySize);
738 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
739 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
742 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
744 HUD_Panel_GetName(highlightedPanel);
745 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
748 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
749 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
754 float dist_x, dist_y;
756 ratio = mySize_x/mySize_y;
758 for (i = 0; i < HUD_PANEL_NUM; ++i) {
759 if(i == highlightedPanel || !panel_enabled)
762 HUD_Panel_UpdatePosSizeForId(i);
764 panel_pos -= '1 1 0' * panel_bg_border;
765 panel_size += '2 2 0' * panel_bg_border;
767 targEndPos = panel_pos + panel_size;
769 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
770 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
773 if (resizeCorner == 1)
775 // check if this panel is on our way
776 if (resizeorigin_x <= panel_pos_x)
778 if (resizeorigin_y <= panel_pos_y)
780 if (targEndPos_x <= resizeorigin_x - mySize_x)
782 if (targEndPos_y <= resizeorigin_y - mySize_y)
785 // there is a collision:
786 // detect which side of the panel we are facing is actually limiting the resizing
787 // (which side the resize direction finds for first) and reduce the size up to there
789 // dist is the distance between resizeorigin and the "analogous" point of the panel
790 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
791 dist_x = resizeorigin_x - targEndPos_x;
792 dist_y = resizeorigin_y - targEndPos_y;
793 if (dist_y <= 0 || dist_x / dist_y > ratio)
794 mySize_x = min(mySize_x, dist_x);
796 mySize_y = min(mySize_y, dist_y);
798 else if (resizeCorner == 2)
800 if (resizeorigin_x >= targEndPos_x)
802 if (resizeorigin_y <= panel_pos_y)
804 if (panel_pos_x >= resizeorigin_x + mySize_x)
806 if (targEndPos_y <= resizeorigin_y - mySize_y)
809 dist_x = panel_pos_x - resizeorigin_x;
810 dist_y = resizeorigin_y - targEndPos_y;
811 if (dist_y <= 0 || dist_x / dist_y > ratio)
812 mySize_x = min(mySize_x, dist_x);
814 mySize_y = min(mySize_y, dist_y);
816 else if (resizeCorner == 3)
818 if (resizeorigin_x <= panel_pos_x)
820 if (resizeorigin_y >= targEndPos_y)
822 if (targEndPos_x <= resizeorigin_x - mySize_x)
824 if (panel_pos_y >= resizeorigin_y + mySize_y)
827 dist_x = resizeorigin_x - targEndPos_x;
828 dist_y = panel_pos_y - resizeorigin_y;
829 if (dist_y <= 0 || dist_x / dist_y > ratio)
830 mySize_x = min(mySize_x, dist_x);
832 mySize_y = min(mySize_y, dist_y);
834 else if (resizeCorner == 4)
836 if (resizeorigin_x >= targEndPos_x)
838 if (resizeorigin_y >= targEndPos_y)
840 if (panel_pos_x >= resizeorigin_x + mySize_x)
842 if (panel_pos_y >= resizeorigin_y + mySize_y)
845 dist_x = panel_pos_x - resizeorigin_x;
846 dist_y = panel_pos_y - resizeorigin_y;
847 if (dist_y <= 0 || dist_x / dist_y > ratio)
848 mySize_x = min(mySize_x, dist_x);
850 mySize_y = min(mySize_y, dist_y);
852 //if(cvar("hud_configure_checkcollisions_debug"))
853 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
859 void HUD_Panel_SetPosSize(vector mySize)
861 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
863 resizeorigin = panel_click_resizeorigin;
866 // minimum panel size cap
867 mySize_x = max(0.025 * vid_conwidth, mySize_x);
868 mySize_y = max(0.025 * vid_conheight, mySize_y);
870 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.
872 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
873 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
876 // collision testing|
877 // -----------------+
879 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
880 if(resizeCorner == 1) {
881 myPos_x = resizeorigin_x - mySize_x;
882 myPos_y = resizeorigin_y - mySize_y;
883 } else if(resizeCorner == 2) {
884 myPos_x = resizeorigin_x;
885 myPos_y = resizeorigin_y - mySize_y;
886 } else if(resizeCorner == 3) {
887 myPos_x = resizeorigin_x - mySize_x;
888 myPos_y = resizeorigin_y;
889 } else { // resizeCorner == 4
890 myPos_x = resizeorigin_x;
891 myPos_y = resizeorigin_y;
894 // left/top screen edges
896 mySize_x = mySize_x + myPos_x;
898 mySize_y = mySize_y + myPos_y;
900 // bottom/right screen edges
901 if(myPos_x + mySize_x > vid_conwidth)
902 mySize_x = vid_conwidth - myPos_x;
903 if(myPos_y + mySize_y > vid_conheight)
904 mySize_y = vid_conheight - myPos_y;
906 //if(cvar("hud_configure_checkcollisions_debug"))
907 //drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
909 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
910 if(cvar("hud_configure_grid"))
912 mySize_x = floor((mySize_x/vid_conwidth)/hud_configure_gridSize_x + 0.5) * hud_configure_realGridSize_x;
913 mySize_y = floor((mySize_y/vid_conheight)/hud_configure_gridSize_y + 0.5) * hud_configure_realGridSize_y;
916 if(hud_configure_checkcollisions)
917 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
919 // 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)
920 mySize_x = max(0.025 * vid_conwidth, mySize_x);
921 mySize_y = max(0.025 * vid_conheight, mySize_y);
923 // do another pos check, as size might have changed by now
924 if(resizeCorner == 1) {
925 myPos_x = resizeorigin_x - mySize_x;
926 myPos_y = resizeorigin_y - mySize_y;
927 } else if(resizeCorner == 2) {
928 myPos_x = resizeorigin_x;
929 myPos_y = resizeorigin_y - mySize_y;
930 } else if(resizeCorner == 3) {
931 myPos_x = resizeorigin_x - mySize_x;
932 myPos_y = resizeorigin_y;
933 } else { // resizeCorner == 4
934 myPos_x = resizeorigin_x;
935 myPos_y = resizeorigin_y;
938 //if(cvar("hud_configure_checkcollisions_debug"))
939 //drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
941 HUD_Panel_GetName(highlightedPanel);
943 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
944 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
946 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
947 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
951 float prevMouseClicked; // previous state
952 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
953 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
955 float pressed_key_time;
956 void HUD_Panel_Arrow_Action(float nPrimary)
958 if (highlightedPanel_prev == -1 || mouseClicked)
961 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
964 if(cvar("hud_configure_grid"))
966 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
968 if (hudShiftState & S_SHIFT)
969 step = hud_configure_realGridSize_y;
971 step = 2 * hud_configure_realGridSize_y;
975 if (hudShiftState & S_SHIFT)
976 step = hud_configure_realGridSize_x;
978 step = 2 * hud_configure_realGridSize_x;
983 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
984 step = vid_conheight;
987 if (hudShiftState & S_SHIFT)
988 step = (step / 256); // more precision
990 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
993 highlightedPanel = highlightedPanel_prev;
995 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
997 vector prev_pos, prev_size;
998 prev_pos = panel_pos;
999 prev_size = panel_size;
1001 if (hudShiftState & S_ALT) // resize
1003 highlightedAction = 1;
1004 if(nPrimary == K_UPARROW)
1006 else if(nPrimary == K_RIGHTARROW)
1008 else if(nPrimary == K_LEFTARROW)
1010 else // if(nPrimary == K_DOWNARROW)
1013 // ctrl+arrow reduces the size, instead of increasing it
1014 // Note that ctrl disables collisions check too, but it's fine
1015 // since we don't collide with anything reducing the size
1016 if (hudShiftState & S_CTRL) {
1018 resizeCorner = 5 - resizeCorner;
1022 mySize = panel_size;
1023 panel_click_resizeorigin = panel_pos;
1024 if(resizeCorner == 1) {
1025 panel_click_resizeorigin += mySize;
1027 } else if(resizeCorner == 2) {
1028 panel_click_resizeorigin_y += mySize_y;
1030 } else if(resizeCorner == 3) {
1031 panel_click_resizeorigin_x += mySize_x;
1033 } else { // resizeCorner == 4
1036 HUD_Panel_SetPosSize(mySize);
1040 highlightedAction = 2;
1043 if(nPrimary == K_UPARROW)
1045 else if(nPrimary == K_DOWNARROW)
1047 else if(nPrimary == K_LEFTARROW)
1049 else // if(nPrimary == K_RIGHTARROW)
1052 HUD_Panel_SetPos(pos);
1055 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
1057 if (prev_pos != panel_pos || prev_size != panel_size)
1060 panel_pos_backup = prev_pos;
1061 panel_size_backup = prev_size;
1062 highlightedPanel_backup = highlightedPanel;
1066 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1070 if(!autocvar__hud_configure)
1073 // allow console bind to work
1076 con_keys = findkeysforcommand("toggleconsole");
1077 keys = tokenize(con_keys);
1079 float hit_con_bind, i;
1080 for (i = 0; i < keys; ++i)
1082 if(nPrimary == stof(argv(i)))
1086 if(bInputType == 0) {
1087 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1088 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1089 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1091 else if(bInputType == 1) {
1092 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1093 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1094 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1097 if(nPrimary == K_MOUSE1)
1099 if(bInputType == 0) { // key pressed
1103 else if(bInputType == 1) {// key released
1108 else if(nPrimary == K_ESCAPE)
1110 if (bInputType == 1)
1113 menu_enabled_time = time;
1114 localcmd("menu_showhudexit\n");
1116 else if(nPrimary == K_SPACE && hudShiftState & S_CTRL) // enable/disable highlighted panel or dock
1118 if (bInputType == 1 || mouseClicked)
1121 if (highlightedPanel_prev != -1)
1122 cvar_set(strcat("hud_panel_", panel_name), ftos(!(panel_enabled)));
1124 cvar_set(strcat("hud_dock"), (autocvar_hud_dock == "") ? "dock" : "");
1126 else if(nPrimary == 'c' && hudShiftState & S_CTRL) // copy highlighted panel size
1128 if (bInputType == 1 || mouseClicked)
1131 if (highlightedPanel_prev != -1)
1133 panel_size_copied = panel_size;
1134 highlightedPanel_copied = highlightedPanel_prev;
1137 else if(nPrimary == 'v' && hudShiftState & S_CTRL) // past copied size on the highlighted panel
1139 if (bInputType == 1 || mouseClicked)
1142 if (highlightedPanel_copied == -1 || highlightedPanel_prev == -1)
1145 HUD_Panel_UpdatePosSizeForId(highlightedPanel_prev);
1147 // reduce size if it'd go beyond screen boundaries
1148 vector tmp_size = panel_size_copied;
1149 if (panel_pos_x + panel_size_copied_x > vid_conwidth)
1150 tmp_size_x = vid_conwidth - panel_pos_x;
1151 if (panel_pos_y + panel_size_copied_y > vid_conheight)
1152 tmp_size_y = vid_conheight - panel_pos_y;
1154 if (panel_size == tmp_size)
1158 panel_pos_backup = panel_pos;
1159 panel_size_backup = panel_size;
1160 highlightedPanel_backup = highlightedPanel_prev;
1162 s = strcat(ftos(tmp_size_x/vid_conwidth), " ", ftos(tmp_size_y/vid_conheight));
1163 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
1165 else if(nPrimary == 'z' && hudShiftState & S_CTRL) // undo last action
1167 if (bInputType == 1 || mouseClicked)
1169 //restore previous values
1170 if (highlightedPanel_backup != -1)
1172 HUD_Panel_GetName(highlightedPanel_backup);
1173 s = strcat(ftos(panel_pos_backup_x/vid_conwidth), " ", ftos(panel_pos_backup_y/vid_conheight));
1174 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
1175 s = strcat(ftos(panel_size_backup_x/vid_conwidth), " ", ftos(panel_size_backup_y/vid_conheight));
1176 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
1177 highlightedPanel_backup = -1;
1180 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1182 if (bInputType == 1)
1184 pressed_key_time = 0;
1187 else if (pressed_key_time == 0)
1188 pressed_key_time = time;
1190 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1192 else if(hit_con_bind)
1195 return true; // Suppress ALL other input
1198 float HUD_Panel_HighlightCheck()
1202 while(j < HUD_PANEL_NUM)
1207 HUD_Panel_UpdatePosSizeForId(i);
1209 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1212 if(mousepos_x >= panel_pos_x && mousepos_y >= panel_pos_y && mousepos_x <= panel_pos_x + panel_size_x && mousepos_y <= panel_pos_y + panel_size_y)
1216 // resize from topleft border
1217 else if(mousepos_x >= panel_pos_x - border && mousepos_y >= panel_pos_y - border && mousepos_x <= panel_pos_x + 0.5 * panel_size_x && mousepos_y <= panel_pos_y + 0.5 * panel_size_y)
1221 // resize from topright border
1222 else if(mousepos_x >= panel_pos_x + 0.5 * panel_size_x && mousepos_y >= panel_pos_y - border && mousepos_x <= panel_pos_x + panel_size_x + border && mousepos_y <= panel_pos_y + 0.5 * panel_size_y)
1226 // resize from bottomleft border
1227 else if(mousepos_x >= panel_pos_x - border && mousepos_y >= panel_pos_y + 0.5 * panel_size_y && mousepos_x <= panel_pos_x + 0.5 * panel_size_x && mousepos_y <= panel_pos_y + panel_size_y + border)
1231 // resize from bottomright border
1232 else if(mousepos_x >= panel_pos_x + 0.5 * panel_size_x && mousepos_y >= panel_pos_y + 0.5 * panel_size_y && mousepos_x <= panel_pos_x + panel_size_x + border && mousepos_y <= panel_pos_y + panel_size_y + border)
1240 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1241 void HUD_Panel_FirstInDrawQ(float id)
1244 var float place = -1;
1245 // find out where in the array our current id is, save into place
1246 for(i = 0; i < HUD_PANEL_NUM; ++i)
1248 if(panel_order[i] == id)
1254 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1256 place = HUD_PANEL_NUM - 1;
1258 // move all ids up by one step in the array until "place"
1259 for(i = place; i > 0; --i)
1261 panel_order[i] = panel_order[i-1];
1263 // now save the new top id
1264 panel_order[0] = id;
1266 // let's save them into the cvar by some strcat trickery
1268 for(i = 0; i < HUD_PANEL_NUM; ++i)
1270 s = strcat(s, ftos(panel_order[i]), " ");
1272 cvar_set("_hud_panelorder", s);
1273 if(hud_panelorder_prev)
1274 strunzone(hud_panelorder_prev);
1275 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1278 void HUD_Panel_Highlight()
1282 while(j < HUD_PANEL_NUM)
1287 HUD_Panel_UpdatePosSizeForId(i);
1289 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1292 if(mousepos_x >= panel_pos_x && mousepos_y >= panel_pos_y && mousepos_x <= panel_pos_x + panel_size_x && mousepos_y <= panel_pos_y + panel_size_y)
1294 highlightedPanel = i;
1295 HUD_Panel_FirstInDrawQ(i);
1296 highlightedAction = 1;
1297 panel_click_distance = mousepos - panel_pos;
1300 // resize from topleft border
1301 else if(mousepos_x >= panel_pos_x - border && mousepos_y >= panel_pos_y - border && mousepos_x <= panel_pos_x + 0.5 * panel_size_x && mousepos_y <= panel_pos_y + 0.5 * panel_size_y)
1303 highlightedPanel = i;
1304 HUD_Panel_FirstInDrawQ(i);
1305 highlightedAction = 2;
1307 panel_click_distance = mousepos - panel_pos;
1308 panel_click_resizeorigin = panel_pos + panel_size;
1311 // resize from topright border
1312 else if(mousepos_x >= panel_pos_x + 0.5 * panel_size_x && mousepos_y >= panel_pos_y - border && mousepos_x <= panel_pos_x + panel_size_x + border && mousepos_y <= panel_pos_y + 0.5 * panel_size_y)
1314 highlightedPanel = i;
1315 HUD_Panel_FirstInDrawQ(i);
1316 highlightedAction = 2;
1318 panel_click_distance_x = panel_size_x - mousepos_x + panel_pos_x;
1319 panel_click_distance_y = mousepos_y - panel_pos_y;
1320 panel_click_resizeorigin = panel_pos + eY * panel_size_y;
1323 // resize from bottomleft border
1324 else if(mousepos_x >= panel_pos_x - border && mousepos_y >= panel_pos_y + 0.5 * panel_size_y && mousepos_x <= panel_pos_x + 0.5 * panel_size_x && mousepos_y <= panel_pos_y + panel_size_y + border)
1326 highlightedPanel = i;
1327 HUD_Panel_FirstInDrawQ(i);
1328 highlightedAction = 2;
1330 panel_click_distance_x = mousepos_x - panel_pos_x;
1331 panel_click_distance_y = panel_size_y - mousepos_y + panel_pos_y;
1332 panel_click_resizeorigin = panel_pos + eX * panel_size_x;
1335 // resize from bottomright border
1336 else if(mousepos_x >= panel_pos_x + 0.5 * panel_size_x && mousepos_y >= panel_pos_y + 0.5 * panel_size_y && mousepos_x <= panel_pos_x + panel_size_x + border && mousepos_y <= panel_pos_y + panel_size_y + border)
1338 highlightedPanel = i;
1339 HUD_Panel_FirstInDrawQ(i);
1340 highlightedAction = 2;
1342 panel_click_distance = panel_size - mousepos + panel_pos;
1343 panel_click_resizeorigin = panel_pos;
1348 highlightedPanel_prev = -1;
1353 float highlightcheck;
1354 vector prev_pos, prev_size;
1355 void HUD_Panel_Mouse()
1357 // TODO: needs better check... is there any float that contains the current state of the menu? _menu_alpha isn't apparently updated the frame the menu gets enabled
1358 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1362 print("menu_enabled: ", ftos(menu_enabled), "\n");
1363 print("Highlighted: ", ftos(highlightedPanel), "\n");
1364 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1367 // instantly hide the editor cursor if we open the HUDExit dialog
1368 // as hud_fade_alpha doesn't decrease to 0 in this case
1369 // TODO: find a way to fade the cursor out even in this case
1370 if(menu_enabled == 1 || (menu_enabled == 2 && !hud_fade_alpha))
1373 if(mouseClicked == 0 && menu_enabled != 2 && highlightedPanel >= 0) { // don't reset these variables in menu_enabled mode 2!
1374 highlightedPanel = -1;
1375 highlightedAction = 0;
1377 if(highlightedPanel != -1)
1378 highlightedPanel_prev = highlightedPanel;
1380 mousepos = mousepos + getmousepos() * cvar("menu_mouse_speed");
1382 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1383 mousepos_y = bound(0, mousepos_y, vid_conheight);
1387 if(prevMouseClicked == 0)
1389 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1390 // and calls HUD_Panel_UpdatePosSizeForId() for the highlighted panel
1391 prev_pos = panel_pos;
1392 prev_size = panel_size;
1395 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
1397 if (prev_pos != panel_pos || prev_size != panel_size)
1399 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
1401 panel_pos_backup = prev_pos;
1402 panel_size_backup = prev_size;
1403 highlightedPanel_backup = highlightedPanel;
1406 // in case the clicked panel is inside another panel and we aren't
1407 // moving it, avoid the immediate "fix" of its position/size
1408 // (often unwanted and hateful) by disabling collisions check
1409 hud_configure_checkcollisions = false;
1411 if(highlightedAction == 1)
1412 HUD_Panel_SetPos(mousepos - panel_click_distance);
1413 else if(highlightedAction == 2)
1416 if(resizeCorner == 1) {
1417 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1418 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1419 } else if(resizeCorner == 2) {
1420 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1421 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1422 } else if(resizeCorner == 3) {
1423 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1424 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1425 } else { // resizeCorner == 4
1426 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1427 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1429 HUD_Panel_SetPosSize(mySize);
1432 // doubleclick check
1433 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1435 mouseClicked = 0; // to prevent spam, I guess.
1437 menu_enabled_time = time;
1438 HUD_Panel_GetName(highlightedPanel);
1439 localcmd("menu_showhudoptions ", panel_name, "\n");
1442 if(prevMouseClicked == 0)
1444 prevMouseClickedTime = time;
1445 prevMouseClickedPos = mousepos;
1450 highlightcheck = HUD_Panel_HighlightCheck();
1452 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1454 cursorsize = '32 32 0';
1456 if(highlightcheck == 0)
1457 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1458 else if(highlightcheck == 1)
1459 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1460 else if(highlightcheck == 2)
1461 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1463 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1465 prevMouseClicked = mouseClicked;
1468 // Weapon icons (#0)
1470 float weaponspace[10];
1471 #define HUD_Weapons_Clear()\
1473 for(idx = 0; idx < 10; ++idx)\
1474 weaponspace[idx] = 0
1476 entity weaponorder[WEP_MAXCOUNT];
1477 void weaponorder_swap(float i, float j, entity pass)
1481 weaponorder[i] = weaponorder[j];
1485 string weaponorder_cmp_str;
1486 float weaponorder_cmp(float i, float j, entity pass)
1489 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1490 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1491 return aj - ai; // the string is in REVERSE order (higher prio at the right is what we want, but higher prio first is the string)
1494 float GetAmmoStat(float i)
1498 case 0: return STAT_SHELLS;
1499 case 1: return STAT_NAILS;
1500 case 2: return STAT_ROCKETS;
1501 case 3: return STAT_CELLS;
1502 case 4: return STAT_FUEL;
1507 float GetAmmoTypeForWep(float i)
1511 case WEP_SHOTGUN: return 0;
1512 case WEP_UZI: return 1;
1513 case WEP_GRENADE_LAUNCHER: return 2;
1514 case WEP_MINE_LAYER: return 2;
1515 case WEP_ELECTRO: return 3;
1516 case WEP_CRYLINK: return 3;
1517 case WEP_HLAC: return 3;
1518 case WEP_MINSTANEX: return 3;
1519 case WEP_NEX: return 3;
1520 case WEP_CAMPINGRIFLE: return 1;
1521 case WEP_HAGAR: return 2;
1522 case WEP_ROCKET_LAUNCHER: return 2;
1523 case WEP_SEEKER: return 2;
1524 case WEP_FIREBALL: return 4;
1525 case WEP_HOOK: return 3;
1530 void HUD_Weapons(void)
1533 float center_x, center_y;
1535 if(!autocvar__hud_configure)
1537 if(!autocvar_hud_panel_weapons) return;
1538 if(spectatee_status == -1) return;
1541 float timeout = cvar("hud_panel_weapons_timeout");
1542 float timeout_effect_length, timein_effect_length;
1543 if (cvar("hud_panel_weapons_timeout_effect") == 0)
1545 timeout_effect_length = 0;
1546 timein_effect_length = 0;
1550 timeout_effect_length = 0.75;
1551 timein_effect_length = 0.375;
1554 if (timeout && time >= weapontime + timeout + timeout_effect_length && !autocvar__hud_configure)
1556 weaponprevtime = time;
1560 active_panel = HUD_PANEL_WEAPONS;
1561 HUD_Panel_UpdateCvars(weapons);
1563 if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
1565 f = (time - (weapontime + timeout)) / timeout_effect_length;
1566 if (cvar("hud_panel_weapons_timeout_effect"))
1568 panel_bg_alpha *= (1 - f);
1569 panel_fg_alpha *= (1 - f);
1571 if (cvar("hud_panel_weapons_timeout_effect") == 1)
1573 f *= f; // for a cooler movement
1574 center_x = panel_pos_x + panel_size_x/2;
1575 center_y = panel_pos_y + panel_size_y/2;
1576 screen_ar = vid_conwidth/vid_conheight;
1577 if (center_x/center_y < screen_ar) //bottom left
1579 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
1580 panel_pos_y += f * (vid_conheight - panel_pos_y);
1582 panel_pos_x -= f * (panel_pos_x + panel_size_x);
1586 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
1587 panel_pos_x += f * (vid_conwidth - panel_pos_x);
1589 panel_pos_y -= f * (panel_pos_y + panel_size_y);
1592 weaponprevtime = time - (1 - f) * timein_effect_length;
1594 else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure)
1596 f = (time - weaponprevtime) / timein_effect_length;
1597 if (cvar("hud_panel_weapons_timeout_effect"))
1599 panel_bg_alpha *= (f);
1600 panel_fg_alpha *= (f);
1602 if (cvar("hud_panel_weapons_timeout_effect") == 1)
1604 f *= f; // for a cooler movement
1606 center_x = panel_pos_x + panel_size_x/2;
1607 center_y = panel_pos_y + panel_size_y/2;
1608 screen_ar = vid_conwidth/vid_conheight;
1609 if (center_x/center_y < screen_ar) //bottom left
1611 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
1612 panel_pos_y += f * (vid_conheight - panel_pos_y);
1614 panel_pos_x -= f * (panel_pos_x + panel_size_x);
1618 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
1619 panel_pos_x += f * (vid_conwidth - panel_pos_x);
1621 panel_pos_y -= f * (panel_pos_y + panel_size_y);
1626 float i, weapid, wpnalpha, weapon_cnt;
1628 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1630 self = get_weaponinfo(i);
1631 if(self.impulse >= 0)
1635 // TODO make this configurable
1636 if(weaponorder_bypriority != cvar_string("cl_weaponpriority"))
1638 if(weaponorder_bypriority)
1639 strunzone(weaponorder_bypriority);
1640 if(weaponorder_byimpulse)
1641 strunzone(weaponorder_byimpulse);
1643 weaponorder_bypriority = strzone(cvar_string("cl_weaponpriority"));
1644 weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
1645 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1648 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1650 self = get_weaponinfo(i);
1651 if(self.impulse >= 0)
1653 weaponorder[weapon_cnt] = self;
1657 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1659 weaponorder_cmp_str = string_null;
1662 HUD_Panel_DrawBg(1);
1663 if(panel_bg_padding)
1665 panel_pos += '1 1 0' * panel_bg_padding;
1666 panel_size -= '2 2 0' * panel_bg_padding;
1669 if(cvar_or("hud_panel_weapons_fade", 1))
1671 wpnalpha = 3.2 - 2 * (time - weapontime);
1672 wpnalpha = bound(0.7, wpnalpha, 1) * panel_fg_alpha;
1675 wpnalpha = panel_fg_alpha;
1677 HUD_Weapons_Clear();
1679 float rows, columns;
1680 float aspect = cvar("hud_panel_weapons_aspect");
1681 rows = panel_size_y/panel_size_x;
1682 rows = bound(1, floor((sqrt(4 * aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1684 columns = ceil(WEP_COUNT/rows);
1687 float a, type, fullammo;
1689 when = cvar("hud_panel_weapons_complainbubble_time");
1691 fadetime = cvar("hud_panel_weapons_complainbubble_fadetime");
1697 float fullammo_shells, fullammo_nails, fullammo_rockets, fullammo_cells, fullammo_fuel;
1700 wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
1701 float barsize_x, barsize_y, baroffset_x, baroffset_y;
1702 float show_ammo = cvar("hud_panel_weapons_ammo");
1705 fullammo_shells = cvar("hud_panel_weapons_ammo_full_shells");
1706 fullammo_nails = cvar("hud_panel_weapons_ammo_full_nails");
1707 fullammo_rockets = cvar("hud_panel_weapons_ammo_full_rockets");
1708 fullammo_cells = cvar("hud_panel_weapons_ammo_full_cells");
1709 fullammo_fuel = cvar("hud_panel_weapons_ammo_full_fuel");
1710 ammo_color = stov(cvar_string("hud_panel_weapons_ammo_color"));
1711 ammo_alpha = panel_fg_alpha * cvar("hud_panel_weapons_ammo_alpha");
1714 if(wpnsize_x/wpnsize_y > aspect)
1716 barsize_x = aspect * wpnsize_y;
1717 barsize_y = wpnsize_y;
1718 baroffset_x = (wpnsize_x - barsize_x) / 2;
1722 barsize_y = 1/aspect * wpnsize_x;
1723 barsize_x = wpnsize_x;
1724 baroffset_y = (wpnsize_y - barsize_y) / 2;
1728 float show_accuracy;
1730 if(cvar("hud_panel_weapons_accuracy") && acc_levels)
1732 show_accuracy = true;
1733 if (acc_col_x[0] == -1)
1734 for (i = 0; i < acc_levels; ++i)
1735 acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
1738 float weapons_st = getstati(STAT_WEAPONS);
1739 float label = cvar("hud_panel_weapons_label");
1741 for(i = 0; i < weapon_cnt; ++i)
1743 wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y;
1745 self = weaponorder[i];
1746 weapid = self.impulse;
1748 // draw background behind currently selected weapon
1749 if(self.weapon == activeweapon)
1750 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
1752 // draw the weapon accuracy
1755 weapon_stats = weapon_accuracy[self.weapon-WEP_FIRST];
1756 if(weapon_stats >= 0)
1758 // find the max level lower than weapon_stats
1761 while ( j && weapon_stats < acc_lev[j] )
1764 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
1766 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
1768 color = color + factor * (acc_col[j+1] - color);
1770 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1774 // draw the weapon icon
1775 if((weapid >= 0) && (weapons_st & self.weapons))
1777 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
1779 if(label == 1) // weapon number
1780 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1781 else if(label == 2) // bind
1782 drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1784 // draw ammo status bar
1785 if(show_ammo && weapid != WEP_TUBA && weapid != WEP_LASER && weapid != WEP_PORTO)
1788 type = GetAmmoTypeForWep(weapid);
1790 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
1795 case 0: fullammo = fullammo_shells; break;
1796 case 1: fullammo = fullammo_nails; break;
1797 case 2: fullammo = fullammo_rockets; break;
1798 case 3: fullammo = fullammo_cells; break;
1799 case 4: fullammo = fullammo_fuel; break;
1800 default: fullammo = 60;
1804 wpnpos_x + baroffset_x,
1805 wpnpos_y + baroffset_y,
1806 barsize_x * bound(0, a/fullammo, 1),
1808 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, ammo_color, ammo_alpha, DRAWFLAG_NORMAL);
1809 drawresetcliparea();
1814 // draw a "ghost weapon icon" if you don't have the weapon
1817 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
1820 // draw the complain message
1821 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && cvar("hud_panel_weapons_complainbubble"))
1825 if(complain_weapon_time + when > time)
1828 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1832 if(complain_weapon_time + when > time)
1839 if(complain_weapon_type == 0) {
1841 color = stov(cvar_string("hud_panel_weapons_complainbubble_color_outofammo"));
1843 else if(complain_weapon_type == 1) {
1845 color = stov(cvar_string("hud_panel_weapons_complainbubble_color_donthave"));
1849 color = stov(cvar_string("hud_panel_weapons_complainbubble_color_unavailable"));
1851 float padding = cvar("hud_panel_weapons_complainbubble_padding");
1852 drawpic_aspect_skin(wpnpos + '1 1 0' * padding, "weapon_complainbubble", wpnsize - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
1853 drawstring_aspect(wpnpos + '1 1 0' * padding, s, wpnsize - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
1869 float GetAmmoItemCode(float i)
1873 case 0: return IT_SHELLS;
1874 case 1: return IT_NAILS;
1875 case 2: return IT_ROCKETS;
1876 case 3: return IT_CELLS;
1877 case 4: return IT_FUEL;
1882 string GetAmmoPicture(float i)
1886 case 0: return "ammo_shells";
1887 case 1: return "ammo_bullets";
1888 case 2: return "ammo_rockets";
1889 case 3: return "ammo_cells";
1890 case 4: return "ammo_fuel";
1895 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1898 if(autocvar__hud_configure)
1900 currently_selected = (itemcode == 2); //rockets always selected
1901 a = 31 + mod(itemcode*93, 128);
1904 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1913 if(currently_selected)
1918 vector picpos, numpos;
1919 if(autocvar_hud_panel_ammo_iconalign)
1922 picpos = myPos + eX * 2 * mySize_y;
1926 numpos = myPos + eX * mySize_y;
1930 if (currently_selected)
1931 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1934 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1935 else // "ghost" ammo count
1936 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1938 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1939 else // "ghost" ammo icon
1940 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1945 if(!autocvar__hud_configure)
1947 if(!autocvar_hud_panel_ammo) return;
1948 if(spectatee_status == -1) return;
1951 active_panel = HUD_PANEL_AMMO;
1952 HUD_Panel_UpdateCvars(ammo);
1955 mySize = panel_size;
1957 HUD_Panel_DrawBg(1);
1958 if(panel_bg_padding)
1960 pos += '1 1 0' * panel_bg_padding;
1961 mySize -= '2 2 0' * panel_bg_padding;
1964 float rows, columns, row, column;
1966 if (autocvar_hud_panel_ammo_onlycurrent)
1970 rows = mySize_y/mySize_x;
1971 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1972 // ^^^ ammo item aspect goes here
1974 columns = ceil(AMMO_COUNT/rows);
1976 ammo_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
1981 if(ammo_size_x/ammo_size_y > 3)
1983 newSize = 3 * ammo_size_y;
1984 offset_x = ammo_size_x - newSize;
1985 pos_x += offset_x/2;
1986 ammo_size_x = newSize;
1990 newSize = 1/3 * ammo_size_x;
1991 offset_y = ammo_size_y - newSize;
1992 pos_y += offset_y/2;
1993 ammo_size_y = newSize;
1996 drawfont = hud_bigfont;
1997 float i, stat_items, currently_selected;
1998 if (autocvar_hud_panel_ammo_onlycurrent)
2000 if(autocvar__hud_configure)
2002 DrawAmmoItem(pos, ammo_size, 2, true); //show rockets
2005 stat_items = getstati(STAT_ITEMS);
2006 for (i = 0; i < AMMO_COUNT; ++i) {
2007 currently_selected = stat_items & GetAmmoItemCode(i);
2008 if (currently_selected)
2010 DrawAmmoItem(pos, ammo_size, i, true);
2014 return; // nothing to display
2017 stat_items = getstati(STAT_ITEMS);
2018 for (i = 0; i < AMMO_COUNT; ++i) {
2019 currently_selected = stat_items & GetAmmoItemCode(i);
2020 DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected);
2025 column = column + 1;
2028 drawfont = hud_font;
2031 void DrawNumIcon(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float alpha)
2033 vector newPos, newSize;
2034 vector picpos, numpos;
2038 if(mySize_y/mySize_x > 2)
2040 newSize_y = 2 * mySize_x;
2041 newSize_x = mySize_x;
2043 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
2048 newSize_x = 1/2 * mySize_y;
2049 newSize_y = mySize_y;
2051 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
2055 if(icon_right_align)
2058 picpos = newPos + eY * newSize_x;
2063 numpos = newPos + eY * newSize_x;
2067 drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
2068 // make number smaller than icon, it looks better
2069 // reduce only y to draw numbers with different number of digits with the same y size
2070 numpos_y += newSize_y * ((1 - 0.7) / 2);
2072 drawstring_aspect(numpos, ftos(x), newSize, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
2076 if(mySize_x/mySize_y > 3)
2078 newSize_x = 3 * mySize_y;
2079 newSize_y = mySize_y;
2081 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
2086 newSize_y = 1/3 * mySize_x;
2087 newSize_x = mySize_x;
2089 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
2093 if(icon_right_align) // right align
2096 picpos = newPos + eX * 2 * newSize_y;
2100 numpos = newPos + eX * newSize_y;
2104 drawstring_aspect(numpos, ftos(x), '2 1 0' * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
2105 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
2108 void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float fadelerp)
2111 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
2113 DrawNumIcon(myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, vertical, icon_right_align, color, (1 - fadelerp));
2118 void HUD_Powerups(void) {
2119 if(!autocvar__hud_configure)
2121 if(!autocvar_hud_panel_powerups) return;
2122 if(spectatee_status == -1) return;
2123 if not(getstati(STAT_ITEMS) & (IT_STRENGTH | IT_INVINCIBLE)) return;
2124 if (getstati(STAT_HEALTH) <= 0) return;
2127 active_panel = HUD_PANEL_POWERUPS;
2128 HUD_Panel_UpdateCvars(powerups);
2131 mySize = panel_size;
2133 float strength_time, shield_time;
2134 if(autocvar__hud_configure)
2141 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
2142 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
2145 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
2146 if(panel_bg_padding)
2148 pos += '1 1 0' * panel_bg_padding;
2149 mySize -= '2 2 0' * panel_bg_padding;
2152 vector barpos, barsize;
2156 string leftname, rightname;
2157 float leftcnt, rightcnt;
2158 float leftexact, rightexact;
2159 if (cvar("hud_panel_powerups_flip")) {
2160 leftname = "strength";
2161 leftcnt = ceil(strength_time);
2162 leftexact = strength_time;
2164 rightname = "shield";
2165 rightcnt = ceil(shield_time);
2166 rightexact = shield_time;
2168 leftname = "shield";
2169 leftcnt = ceil(shield_time);
2170 leftexact = shield_time;
2172 rightname = "strength";
2173 rightcnt = ceil(strength_time);
2174 rightexact = strength_time;
2177 drawfont = hud_bigfont;
2178 float baralign = cvar("hud_panel_powerups_baralign");
2179 float iconalign = cvar("hud_panel_powerups_iconalign");
2180 float progressbar = cvar("hud_panel_powerups_progressbar");
2181 float panel_ar = mySize_x/mySize_y;
2182 float is_vertical = (panel_ar < 1);
2183 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
2189 HUD_Panel_GetProgressBarColorForString(leftname);
2190 HUD_Panel_DrawProgressBar(pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt/30, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2193 DrawNumIcon(pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', 1);
2195 DrawNumIcon_expanding(pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
2202 HUD_Panel_GetProgressBarColorForString(rightname);
2203 HUD_Panel_DrawProgressBar(pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt/30, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2206 DrawNumIcon(pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', 1);
2208 DrawNumIcon_expanding(pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1));
2217 HUD_Panel_GetProgressBarColorForString(leftname);
2218 HUD_Panel_DrawProgressBar(pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt/30, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2221 DrawNumIcon(pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', 1);
2223 DrawNumIcon_expanding(pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
2230 HUD_Panel_GetProgressBarColorForString(rightname);
2231 HUD_Panel_DrawProgressBar(pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt/30, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2234 DrawNumIcon(pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', 1);
2236 DrawNumIcon_expanding(pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1));
2239 drawfont = hud_font;
2242 // Health/armor (#3)
2244 void HUD_HealthArmor(void)
2246 if(!autocvar__hud_configure)
2248 if(!autocvar_hud_panel_healtharmor) return;
2249 if(spectatee_status == -1) return;
2252 active_panel = HUD_PANEL_HEALTHARMOR;
2253 HUD_Panel_UpdateCvars(healtharmor);
2256 mySize = panel_size;
2258 HUD_Panel_DrawBg(1);
2259 if(panel_bg_padding)
2261 pos += '1 1 0' * panel_bg_padding;
2262 mySize -= '2 2 0' * panel_bg_padding;
2265 float armor, health, fuel;
2266 armor = getstati(STAT_ARMOR);
2267 health = getstati(STAT_HEALTH);
2268 fuel = getstati(STAT_FUEL);
2270 if(autocvar__hud_configure)
2280 vector barpos, barsize;
2281 vector picpos, numpos;
2283 drawfont = hud_bigfont;
2284 float baralign = cvar("hud_panel_healtharmor_baralign");
2285 float iconalign = cvar("hud_panel_healtharmor_iconalign");
2286 float progressbar = cvar("hud_panel_healtharmor_progressbar");
2287 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
2290 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2296 if(v_z) // NOT fully armored
2298 biggercount = "health";
2301 HUD_Panel_GetProgressBarColor(health);
2302 HUD_Panel_DrawProgressBar(pos, mySize, x/400, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2305 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);
2309 biggercount = "armor";
2312 HUD_Panel_GetProgressBarColor(armor);
2313 HUD_Panel_DrawProgressBar(pos, mySize, x/400, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2316 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);
2318 DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, 2 * 200), 1);
2322 HUD_Panel_GetProgressBarColor(fuel);
2323 HUD_Panel_DrawProgressBar(pos, eX * mySize_x + eY * 0.2 * mySize_y, fuel/100, 0, (baralign == 1 || baralign == 3), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2328 string leftname, rightname;
2329 float leftcnt, rightcnt;
2330 float leftactive, rightactive;
2331 float leftalpha, rightalpha;
2332 if (cvar("hud_panel_healtharmor_flip")) { // layout with armor left/top of health
2337 leftalpha = min((armor+10)/55, 1);
2339 rightname = "health";
2344 leftname = "health";
2349 rightname = "armor";
2353 rightalpha = min((armor+10)/55, 1);
2356 float panel_ar = mySize_x/mySize_y;
2357 float is_vertical = (panel_ar < 1);
2358 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
2364 HUD_Panel_GetProgressBarColorForString(leftname);
2365 HUD_Panel_DrawProgressBar(pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt/200, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2367 DrawNumIcon(pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), HUD_Get_Num_Color(leftcnt, 200), 1);
2374 HUD_Panel_GetProgressBarColorForString(rightname);
2375 HUD_Panel_DrawProgressBar(pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt/200, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2377 DrawNumIcon(pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), HUD_Get_Num_Color(rightcnt, 200), 1);
2382 HUD_Panel_GetProgressBarColor(fuel);
2383 if (is_vertical) //if vertical always halve x to not cover too much numbers with 3 digits
2384 mySize_x *= 0.2 * 0.5 / 2;
2387 HUD_Panel_DrawProgressBar(pos, mySize, fuel/100, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2396 HUD_Panel_GetProgressBarColorForString(leftname);
2397 HUD_Panel_DrawProgressBar(pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt/200, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2399 DrawNumIcon(pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), HUD_Get_Num_Color(leftcnt, 200), 1);
2406 HUD_Panel_GetProgressBarColorForString(rightname);
2407 HUD_Panel_DrawProgressBar(pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt/200, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2409 DrawNumIcon(pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), HUD_Get_Num_Color(rightcnt, 200), 1);
2414 HUD_Panel_GetProgressBarColor(fuel);
2415 if (is_vertical) //if vertical always halve x to not cover numbers with 3 digits
2416 mySize_x *= 0.2 / 2;
2418 mySize_y *= 0.2 * 0.5;
2419 HUD_Panel_DrawProgressBar(pos, mySize, fuel/100, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2423 drawfont = hud_font;
2426 // Notification area (#4)
2429 string Weapon_SuicideMessage(float deathtype)
2431 w_deathtype = deathtype;
2432 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2433 return w_deathtypestring;
2436 string Weapon_KillMessage(float deathtype)
2438 w_deathtype = deathtype;
2439 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2440 return w_deathtypestring;
2443 #define KN_MAX_ENTRIES 10
2445 float killnotify_times[KN_MAX_ENTRIES];
2446 float killnotify_deathtype[KN_MAX_ENTRIES];
2447 float killnotify_actiontype[KN_MAX_ENTRIES]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2448 string killnotify_attackers[KN_MAX_ENTRIES];
2449 string killnotify_victims[KN_MAX_ENTRIES];
2450 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2454 kn_index = KN_MAX_ENTRIES-1;
2455 killnotify_times[kn_index] = time;
2456 killnotify_deathtype[kn_index] = wpn;
2457 killnotify_actiontype[kn_index] = actiontype;
2458 if(killnotify_attackers[kn_index])
2459 strunzone(killnotify_attackers[kn_index]);
2460 killnotify_attackers[kn_index] = strzone(attacker);
2461 if(killnotify_victims[kn_index])
2462 strunzone(killnotify_victims[kn_index]);
2463 killnotify_victims[kn_index] = strzone(victim);
2466 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
2469 float alsoprint, gentle;
2470 alsoprint = (cvar("hud_panel_notify_print") || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2471 gentle = (cvar("cl_gentle") || cvar("cl_gentle_messages"));
2473 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
2476 if(msg == MSG_SUICIDE) {
2477 w = DEATH_WEAPONOF(type);
2479 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2481 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
2482 } else if (type == DEATH_KILL) {
2483 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2485 print ("^1",s1, "^1 couldn't take it anymore\n");
2486 } else if (type == DEATH_ROT) {
2487 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2489 print ("^1",s1, "^1 died\n");
2490 } else if (type == DEATH_NOAMMO) {
2491 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2493 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2494 } else if (type == DEATH_CAMP) {
2495 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2497 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2498 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2499 HUD_KillNotify_Push(s1, "", 0, type);
2501 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2502 } else if (type == DEATH_CHEAT) {
2503 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2505 print ("^1",s1, "^1 unfairly eliminated themself\n");
2506 } else if (type == DEATH_FIRE) {
2507 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2509 print ("^1",s1, "^1 burned to death\n");
2510 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2511 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2513 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2516 if (stof(s2) > 2) // killcount > 2
2517 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2518 } else if(msg == MSG_KILL) {
2519 w = DEATH_WEAPONOF(type);
2521 if((w == WEP_CAMPINGRIFLE || w == WEP_MINSTANEX) && type & HITTYPE_HEADSHOT) // all headshot weapons go here
2522 HUD_KillNotify_Push(s1, s2, 1, DEATH_HEADSHOT);
2524 HUD_KillNotify_Push(s1, s2, 1, type);
2527 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
2529 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2530 HUD_KillNotify_Push(s1, s2, 1, type);
2534 print ("^1", s1, "^1 took action against a team mate\n");
2536 print ("^1", s1, "^1 mows down a team mate\n");
2539 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2541 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2543 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2545 else if (stof(s2) > 2) {
2547 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2549 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2552 else if(type == KILL_FIRST_BLOOD)
2553 print("^1",s1, "^1 drew first blood", "\n");
2554 else if (type == DEATH_TELEFRAG) {
2555 HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
2557 print ("^1",s2, "^1 tried to occupy ", s1, "^1's teleport destination space\n");
2559 print ("^1",s2, "^1 was telefragged by ", s1, "\n");
2561 else if (type == DEATH_DROWN) {
2562 HUD_KillNotify_Push(s1, s2, 1, DEATH_DROWN);
2564 print ("^1",s2, "^1 was drowned by ", s1, "\n");
2566 else if (type == DEATH_SLIME) {
2567 HUD_KillNotify_Push(s1, s2, 1, DEATH_SLIME);
2569 print ("^1",s2, "^1 was slimed by ", s1, "\n");
2571 else if (type == DEATH_LAVA) {
2572 HUD_KillNotify_Push(s1, s2, 1, DEATH_LAVA);
2574 print ("^1",s2, "^1 was cooked by ", s1, "\n");
2576 else if (type == DEATH_FALL) {
2577 HUD_KillNotify_Push(s1, s2, 1, DEATH_FALL);
2579 print ("^1",s2, "^1 was grounded by ", s1, "\n");
2581 else if (type == DEATH_SHOOTING_STAR) {
2582 HUD_KillNotify_Push(s1, s2, 1, DEATH_SHOOTING_STAR);
2584 print ("^1",s2, "^1 was shot into space by ", s1, "\n");
2586 else if (type == DEATH_SWAMP) {
2587 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2589 print ("^1",s2, "^1 was conserved by ", s1, "\n");
2591 else if (type == DEATH_HURTTRIGGER)
2593 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
2595 print("^1",s2, "^1 was thrown into a world of hurt by ", s1, "\n");
2596 } else if(type == DEATH_SBCRUSH) {
2597 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2599 print ("^1",s2, "^1 was crushed by ^1", s1, "\n");
2600 } else if(type == DEATH_SBMINIGUN) {
2601 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2603 print ("^1",s2, "^1 got shredded by ^1", s1, "\n");
2604 } else if(type == DEATH_SBROCKET) {
2605 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2607 print ("^1",s2, "^1 was blased to bits by ^1", s1, "\n");
2608 } else if(type == DEATH_SBBLOWUP) {
2609 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2611 print ("^1",s2, "^1 got caught in the destruction of ^1", s1, "'s vehicle\n");
2612 } else if(type == DEATH_WAKIGUN) {
2613 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2615 print ("^1",s2, "^1 was bolted down by ^1", s1, "\n");
2616 } else if(type == DEATH_WAKIROCKET) {
2617 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2619 print ("^1",s2, "^1 could find no shelter from ^1", s1, "'s rockets\n");
2620 } else if(type == DEATH_WAKIBLOWUP) {
2621 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2623 print ("^1",s2, "^1 dies when ^1", s1, "'s wakizashi dies.\n");
2624 } else if(type == DEATH_TURRET) {
2625 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2627 print ("^1",s2, "^1 was pushed into the line of fire by ^1", s1, "\n");
2628 } else if(type == DEATH_TOUCHEXPLODE) {
2629 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2631 print ("^1",s2, "^1 was pushed into an accident by ^1", s1, "\n");
2632 } else if(type == DEATH_CHEAT) {
2633 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2635 print ("^1",s2, "^1 was unfairly eliminated by ^1", s1, "\n");
2636 } else if (type == DEATH_FIRE) {
2637 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2639 print ("^1",s2, "^1 was burnt to death by ^1", s1, "\n");
2640 } else if (type == DEATH_CUSTOM) {
2641 HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM);
2643 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
2644 } else if (type == DEATH_HURTTRIGGER) {
2645 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
2647 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
2649 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2651 print ("^1",s2, "^1 was fragged by ", s1, "\n");
2653 } else if(msg == MSG_SPREE) {
2654 if(type == KILL_END_SPREE) {
2656 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2658 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2659 } else if(type == KILL_SPREE) {
2661 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2663 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2664 } else if(type == KILL_SPREE_3) {
2666 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2668 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2669 } else if(type == KILL_SPREE_5) {
2671 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2673 print (s1,"^7 unleashes ^1RAGE\n");
2674 } else if(type == KILL_SPREE_10) {
2676 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2678 print (s1,"^7 starts the ^1MASSACRE!\n");
2679 } else if(type == KILL_SPREE_15) {
2681 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2683 print (s1,"^7 executes ^1MAYHEM!\n");
2684 } else if(type == KILL_SPREE_20) {
2686 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2688 print (s1,"^7 is a ^1BERSERKER!\n");
2689 } else if(type == KILL_SPREE_25) {
2691 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2693 print (s1,"^7 inflicts ^1CARNAGE!\n");
2694 } else if(type == KILL_SPREE_30) {
2696 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2698 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2700 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2701 if (type == DEATH_DROWN) {
2702 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2706 print ("^1",s1, "^1 was in the water for too long\n");
2708 print ("^1",s1, "^1 drowned\n");
2710 } else if (type == DEATH_SLIME) {
2711 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2713 print ("^1",s1, "^1 was slimed\n");
2714 } else if (type == DEATH_LAVA) {
2715 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2719 print ("^1",s1, "^1 found a hot place\n");
2721 print ("^1",s1, "^1 turned into hot slag\n");
2723 } else if (type == DEATH_FALL) {
2724 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2728 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2730 print ("^1",s1, "^1 hit the ground with a crunch\n");
2732 } else if (type == DEATH_SHOOTING_STAR) {
2733 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2735 print ("^1",s1, "^1 became a shooting star\n");
2736 } else if (type == DEATH_SWAMP) {
2737 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2741 print ("^1",s1, "^1 discovered a swamp\n");
2743 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2745 } else if(type == DEATH_TURRET) {
2746 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2748 print ("^1",s1, "^1 was mowed down by a turret \n");
2749 } else if (type == DEATH_CUSTOM) {
2750 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2752 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
2753 } else if (type == DEATH_HURTTRIGGER) {
2754 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2756 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
2757 } else if(type == DEATH_TOUCHEXPLODE) {
2758 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2760 print ("^1",s1, "^1 died in an accident\n");
2761 } else if(type == DEATH_CHEAT) {
2762 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2764 print ("^1",s1, "^1 was unfairly eliminated\n");
2765 } else if(type == DEATH_FIRE) {
2766 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2770 print ("^1",s1, "^1 felt a little hot\n");
2772 print ("^1",s1, "^1 burnt to death\n");
2775 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2779 print ("^1",s1, "^1 needs a restart\n");
2781 print ("^1",s1, "^1 died\n");
2784 } else if(msg == MSG_KILL_ACTION_SPREE) {
2786 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2788 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2789 } else if(msg == MSG_INFO) {
2790 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2791 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2792 print(s1, "^7 got the ", s2, "\n");
2793 } else if(type == INFO_LOSTFLAG) {
2794 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2795 print(s1, "^7 lost the ", s2, "\n");
2796 } else if(type == INFO_PICKUPFLAG) {
2797 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2798 print(s1, "^7 picked up the ", s2, "\n");
2799 } else if(type == INFO_RETURNFLAG) {
2800 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2801 print(s1, "^7 returned the ", s2, "\n");
2802 } else if(type == INFO_CAPTUREFLAG) {
2803 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
2804 print(s1, "^7 captured the ", s2, s3, "\n");
2806 } else if(msg == MSG_RACE) {
2807 if(type == RACE_SERVER_RECORD) {
2808 HUD_KillNotify_Push(s1, s2, 1, RACE_SERVER_RECORD);
2810 else if(type == RACE_NEW_RANK) {
2811 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_RANK);
2813 else if(type == RACE_NEW_TIME) {
2814 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_TIME);
2816 else if(type == RACE_FAIL) {
2817 HUD_KillNotify_Push(s1, s2, 1, RACE_FAIL);
2822 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2824 void HUD_Centerprint(string s1, string s2, float type, float msg)
2827 gentle = (cvar("cl_gentle") || cvar("cl_gentle_messages"));
2828 if(msg == MSG_SUICIDE) {
2829 if (type == DEATH_TEAMCHANGE) {
2830 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2831 } else if (type == DEATH_AUTOTEAMCHANGE) {
2832 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2833 } else if (type == DEATH_CAMP) {
2835 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2837 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2838 } else if (type == DEATH_NOAMMO) {
2840 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2842 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2843 } else if (type == DEATH_ROT) {
2845 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2847 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2848 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2850 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2852 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2853 } else if (type == DEATH_QUIET) {
2855 } else { // generic message
2857 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2859 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2861 } else if(msg == MSG_KILL) {
2862 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2864 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2866 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2868 } else if (type == KILL_FIRST_BLOOD) {
2870 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2872 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2874 } else if (type == KILL_FIRST_VICTIM) {
2876 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2878 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2880 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2882 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2884 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2886 } else if (type == KILL_TYPEFRAGGED) {
2888 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2890 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2892 } else if (type == KILL_FRAG) {
2894 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2896 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2898 } else { // generic message
2900 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2902 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2905 } else if(msg == MSG_KILL_ACTION) {
2906 // TODO: invent more centerprints here?
2907 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2911 void HUD_Notify (void)
2913 if(!autocvar_hud_panel_notify && !autocvar__hud_configure)
2916 active_panel = HUD_PANEL_NOTIFY;
2917 HUD_Panel_UpdateCvars(notify);
2920 mySize = panel_size;
2922 HUD_Panel_DrawBg(1);
2923 if(panel_bg_padding)
2925 pos += '1 1 0' * panel_bg_padding;
2926 mySize -= '2 2 0' * panel_bg_padding;
2929 float entries, height;
2930 entries = bound(1, floor(KN_MAX_ENTRIES * mySize_y/mySize_x), KN_MAX_ENTRIES);
2931 height = mySize_y/entries;
2934 fontsize = '0.5 0.5 0' * height;
2938 when = cvar("hud_panel_notify_time");
2940 fadetime = cvar("hud_panel_notify_fadetime");
2944 vector pos_attacker, pos_victim;
2946 float width_attacker;
2947 string attacker, victim;
2949 float i, j, w, step, limit;
2950 if(cvar("hud_panel_notify_flip")) //order items from the top down
2956 else //order items from the bottom up
2963 for(j = kn_index; i != limit; i += step, ++j)
2965 if(autocvar__hud_configure)
2969 else // inverse order
2970 a = entries - 1 - i;
2971 attacker = textShortenToWidth(strcat("Player", ftos(a+1)), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2972 victim = textShortenToWidth(strcat("Player", ftos(a+2)), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2973 s = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname);
2974 a = bound(0, (when - a) / 4, 1);
2975 goto hud_config_notifyprint;
2978 if (j == KN_MAX_ENTRIES)
2981 if(killnotify_times[j] + when > time)
2985 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2999 w = DEATH_WEAPONOF(killnotify_deathtype[j]);
3001 // TODO: maybe print in team colors?
3004 if(killnotify_actiontype[j] == 0)
3006 if(killnotify_deathtype[j] == DEATH_GENERIC)
3010 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
3012 s = "notify_outofammo";
3014 else if(killnotify_deathtype[j] == DEATH_KILL)
3016 s = "notify_selfkill";
3018 else if(killnotify_deathtype[j] == DEATH_CAMP)
3020 s = "notify_camping";
3022 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
3024 s = "notify_teamkill_red";
3026 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
3028 s = "notify_teamkill_blue";
3030 else if(killnotify_deathtype[j] == DEATH_DROWN)
3034 else if(killnotify_deathtype[j] == DEATH_SLIME)
3038 else if(killnotify_deathtype[j] == DEATH_LAVA)
3042 else if(killnotify_deathtype[j] == DEATH_FALL)
3046 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
3048 s = "notify_shootingstar";
3050 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
3054 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
3056 if(killnotify_victims[j] == "^1RED^7 flag")
3058 s = "notify_red_taken";
3062 s = "notify_blue_taken";
3065 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
3067 if(killnotify_victims[j] == "^1RED^7 flag")
3069 s = "notify_red_returned";
3073 s = "notify_blue_returned";
3076 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
3078 if(killnotify_victims[j] == "^1RED^7 flag")
3080 s = "notify_red_lost";
3084 s = "notify_blue_lost";
3087 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
3089 if(killnotify_victims[j] == "^1RED^7 flag")
3091 s = "notify_red_captured";
3095 s = "notify_blue_captured";
3098 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3099 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
3100 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
3104 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3105 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3108 // X [did action to] Y
3111 if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
3113 s = "notify_melee_laser";
3115 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_SHOTGUN)
3117 s = "notify_melee_shotgun";
3119 else if(WEP_VALID(w))
3121 self = get_weaponinfo(w);
3122 s = strcat("weapon", self.netname);
3124 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
3126 s = "notify_teamkill_red";
3128 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
3130 s = "notify_teamkill_red";
3132 else if(killnotify_deathtype[j] == DEATH_TELEFRAG)
3134 s = "notify_telefrag";
3136 else if(killnotify_deathtype[j] == DEATH_DROWN)
3140 else if(killnotify_deathtype[j] == DEATH_SLIME)
3144 else if(killnotify_deathtype[j] == DEATH_LAVA)
3148 else if(killnotify_deathtype[j] == DEATH_FALL)
3152 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
3154 s = "notify_shootingstar";
3156 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
3160 else if(killnotify_deathtype[j] == DEATH_HEADSHOT)
3162 s = "notify_headshot";
3164 else if(killnotify_deathtype[j] == RACE_SERVER_RECORD)
3166 s = "race_newrecordserver";
3168 else if(killnotify_deathtype[j] == RACE_NEW_RANK)
3170 s = "race_newrankyellow";
3172 else if(killnotify_deathtype[j] == RACE_NEW_TIME)
3176 else if(killnotify_deathtype[j] == RACE_FAIL)
3181 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3182 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3183 :hud_config_notifyprint
3184 width_attacker = stringwidth(attacker, TRUE, fontsize);
3185 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
3186 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
3187 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
3191 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3192 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3193 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3202 string seconds_tostring(float sec)
3205 minutes = floor(sec / 60);
3207 sec -= minutes * 60;
3210 s = ftos(100 + sec);
3212 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3215 void HUD_Timer(void)
3217 if(!autocvar_hud_panel_timer && !autocvar__hud_configure)
3220 active_panel = HUD_PANEL_TIMER;
3221 HUD_Panel_UpdateCvars(timer);
3224 mySize = panel_size;
3226 HUD_Panel_DrawBg(1);
3227 if(panel_bg_padding)
3229 pos += '1 1 0' * panel_bg_padding;
3230 mySize -= '2 2 0' * panel_bg_padding;
3234 float timelimit, elapsedTime, timeleft, minutesLeft;
3236 timelimit = getstatf(STAT_TIMELIMIT);
3238 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3239 timeleft = ceil(timeleft);
3241 minutesLeft = floor(timeleft / 60);
3244 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3245 timer_color = '1 1 1'; //white
3246 else if(minutesLeft >= 1)
3247 timer_color = '1 1 0'; //yellow
3249 timer_color = '1 0 0'; //red
3251 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
3252 if (time < getstatf(STAT_GAMESTARTTIME)) {
3253 //while restart is still active, show 00:00
3254 timer = seconds_tostring(0);
3256 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3257 timer = seconds_tostring(elapsedTime);
3260 timer = seconds_tostring(timeleft);
3263 drawfont = hud_bigfont;
3264 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3265 drawfont = hud_font;
3270 void HUD_Radar(void)
3272 if ((autocvar_hud_panel_radar == 0 || (autocvar_hud_panel_radar != 2 && !teamplay)) && !autocvar__hud_configure)
3275 active_panel = HUD_PANEL_RADAR;
3276 HUD_Panel_UpdateCvars(radar);
3279 mySize = panel_size;
3281 HUD_Panel_DrawBg(1);
3282 if(panel_bg_padding)
3284 pos += '1 1 0' * panel_bg_padding;
3285 mySize -= '2 2 0' * panel_bg_padding;
3290 float scale2d, normalsize, bigsize;
3293 teamradar_origin2d = pos + 0.5 * mySize;
3294 teamradar_size2d = mySize;
3296 if(minimapname == "")
3299 teamradar_loadcvars();
3301 switch(hud_panel_radar_zoommode)
3305 f = current_zoomfraction;
3308 f = 1 - current_zoomfraction;
3318 switch(hud_panel_radar_rotation)
3321 teamradar_angle = view_angles_y - 90;
3324 teamradar_angle = 90 * hud_panel_radar_rotation;
3328 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3329 teamradar_size2d = mySize;
3331 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3333 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3334 if(hud_panel_radar_rotation == 0)
3336 // max-min distance must fit the radar in any rotation
3337 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3341 vector c0, c1, c2, c3, span;
3342 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3343 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3344 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3345 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3347 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3348 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3350 // max-min distance must fit the radar in x=x, y=y
3352 teamradar_size2d_x * scale2d / (1.05 * span_x),
3353 teamradar_size2d_y * scale2d / (1.05 * span_y)
3357 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
3358 if(bigsize > normalsize)
3359 normalsize = bigsize;
3363 + (1 - f) * normalsize;
3364 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3365 f * (mi_min + mi_max) * 0.5
3366 + (1 - f) * view_origin);
3375 draw_teamradar_background(hud_panel_radar_foreground_alpha);
3377 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3378 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3379 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3380 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3381 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3383 color2 = GetPlayerColor(tm.sv_entnum);
3384 //if(color == COLOR_SPECTATOR || color == color2)
3385 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3387 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3389 drawresetcliparea();
3394 void HUD_UpdatePlayerTeams();
3395 void HUD_Score(void)
3397 if(!autocvar__hud_configure && !autocvar_hud_panel_score)
3400 active_panel = HUD_PANEL_SCORE;
3401 HUD_Panel_UpdateCvars(score);
3404 mySize = panel_size;
3406 HUD_Panel_DrawBg(1);
3407 if(panel_bg_padding)
3409 pos += '1 1 0' * panel_bg_padding;
3410 mySize -= '2 2 0' * panel_bg_padding;
3413 float score, distribution;
3415 vector distribution_color;
3417 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3419 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3420 string timer, distrtimer;
3422 pl = players.sort_next;
3425 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3426 if(pl.scores[ps_primary] == 0)
3429 score = me.(scores[ps_primary]);
3430 timer = TIME_ENCODED_TOSTRING(score);
3432 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3433 // distribution display
3434 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3436 distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS);
3438 if (distribution <= 0) {
3439 distribution_color = '0 1 0';
3443 distribution_color = '1 0 0';
3446 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);
3448 // race record display
3449 if (distribution <= 0)
3450 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3451 drawfont = hud_bigfont;
3452 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3453 drawfont = hud_font;
3454 } else if (!teamplay) { // non-teamgames
3455 if ((spectatee_status == -1 && !autocvar__hud_configure) || cvar("hud_panel_score_rankings"))
3457 #define SCOREPANEL_MAX_ENTRIES 6
3458 #define SCOREPANEL_ASPECTRATIO 2
3459 float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
3460 float height = mySize_y/entries;
3461 vector fontsize = '0.9 0.9 0' * height;
3462 pos_y += height * (1 - 0.9) / 2;
3467 float name_size = mySize_x*0.75;
3468 float i, me_printed;
3470 if (autocvar__hud_configure)
3472 score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
3473 for (i=0; i<entries; ++i)
3475 //simulate my score is lower than all displayed players,
3476 //so that I don't appear at all showing pure rankings.
3477 //This is to better show the difference between the 2 ranking views
3478 if (i == entries-1 && cvar("hud_panel_score_rankings") == 1)
3481 drawfill(pos - eY * (height * (1 - 0.9) / 2), eX * mySize_x + eY * height, rgb, 0.3 * panel_fg_alpha, DRAWFLAG_NORMAL);
3482 s = GetPlayerName(pl.sv_entnum);
3487 s = strcat("Player", ftos(i+1));
3491 s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
3492 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3493 drawstring(pos + eX * mySize_x*0.79, ftos(score), fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3499 if (!scoreboard_fade_alpha) // the scoreboard too calls HUD_UpdatePlayerTeams
3500 HUD_UpdatePlayerTeams();
3502 for (pl = players.sort_next, i=0; pl && i<entries; pl = pl.sort_next, ++i)
3504 if (pl.team == COLOR_SPECTATOR)
3507 if (i == entries-1 && !me_printed && pl != me)
3508 if (cvar("hud_panel_score_rankings") == 1 && spectatee_status != -1)
3510 for (pl = me.sort_next; pl; pl = pl.sort_next)
3511 if (pl.team != COLOR_SPECTATOR)
3515 rgb = '1 1 0'; //not last but not among the leading players: yellow
3517 rgb = '1 0 0'; //last: red
3524 rgb = '0 1 0'; //first: green
3526 drawfill(pos - eY * (height * (1 - 0.9) / 2), eX * mySize_x + eY * height, rgb, 0.3 * panel_fg_alpha, DRAWFLAG_NORMAL);
3528 s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
3529 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3530 drawstring(pos + eX * mySize_x*0.79, ftos(pl.(scores[ps_primary])), fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3535 // me vector := [team/connected frags id]
3536 pl = players.sort_next;
3540 if(autocvar__hud_configure)
3543 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3547 score = me.(scores[ps_primary]);
3548 if(autocvar__hud_configure)
3551 if(distribution >= 5)
3552 distribution_color = eY;
3553 else if(distribution >= 0)
3554 distribution_color = '1 1 1';
3555 else if(distribution >= -5)
3556 distribution_color = '1 1 0';
3558 distribution_color = eX;
3560 string distribution_str;
3561 distribution_str = ftos(distribution);
3562 if (distribution >= 0)
3564 if (distribution > 0)
3565 distribution_str = strcat("+", distribution_str);
3566 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3568 drawfont = hud_bigfont;
3569 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3570 drawfont = hud_font;
3571 drawstring_aspect(pos + eX * 0.75 * mySize_x, distribution_str, eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3572 } else { // teamgames
3573 float max_fragcount;
3574 max_fragcount = -99;
3576 float scores_count, row, column, rows, columns;
3578 vector score_pos, score_size; //for scores other than myteam
3579 if (spectatee_status == -1)
3581 if (autocvar__hud_configure)
3583 else for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3584 if(tm.team == COLOR_SPECTATOR)
3588 rows = mySize_y/mySize_x;
3589 rows = bound(1, floor((sqrt(4 * (3/1) * rows * scores_count + rows * rows) + rows + 0.5) / 2), scores_count);
3590 // ^^^ ammo item aspect goes here
3592 columns = ceil(scores_count/rows);
3594 score_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
3597 if(score_size_x/score_size_y > 3)
3599 newSize = 3 * score_size_y;
3600 offset_x = score_size_x - newSize;
3601 pos_x += offset_x/2;
3602 score_size_x = newSize;
3606 newSize = 1/3 * score_size_x;
3607 offset_y = score_size_y - newSize;
3608 pos_y += offset_y/2;
3609 score_size_y = newSize;
3613 score_size = eX * mySize_x*(1/4) + eY * mySize_y*(1/3);
3614 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3615 if(tm.team == COLOR_SPECTATOR)
3617 score = tm.(teamscores[ts_primary]);
3618 if(autocvar__hud_configure)
3621 if (score > max_fragcount)
3622 max_fragcount = score;
3624 if (spectatee_status == -1)
3626 score_pos = pos + eX * column * (score_size_x + offset_x) + eY * row * (score_size_y + offset_y);
3627 if (max_fragcount == score)
3628 HUD_Panel_DrawHighlight(score_pos, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3629 drawfont = hud_bigfont;
3630 drawstring_aspect(score_pos, ftos(score), score_size, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3631 drawfont = hud_font;
3639 else if(tm.team == myteam) {
3640 if (max_fragcount == score)
3641 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3642 drawfont = hud_bigfont;
3643 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3644 drawfont = hud_font;
3646 if (max_fragcount == score)
3647 HUD_Panel_DrawHighlight(pos + eX * 0.75 * mySize_x + eY * (1/3) * rows * mySize_y, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3648 drawstring_aspect(pos + eX * 0.75 * mySize_x + eY * (1/3) * rows * mySize_y, ftos(score), score_size, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3657 void HUD_RaceTimer (void) {
3658 if(!autocvar__hud_configure)
3660 if(!autocvar_hud_panel_racetimer) return;
3661 if(!(gametype == GAME_RACE || gametype == GAME_CTS)) return;
3662 if(spectatee_status == -1) return;
3665 active_panel = HUD_PANEL_RACETIMER;
3666 HUD_Panel_UpdateCvars(racetimer);
3669 mySize = panel_size;
3671 HUD_Panel_DrawBg(1);
3672 if(panel_bg_padding)
3674 pos += '1 1 0' * panel_bg_padding;
3675 mySize -= '2 2 0' * panel_bg_padding;
3678 // always force 4:1 aspect
3680 if(mySize_x/mySize_y > 4)
3682 newSize_x = 4 * mySize_y;
3683 newSize_y = mySize_y;
3685 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3689 newSize_y = 1/4 * mySize_x;
3690 newSize_x = mySize_x;
3692 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3696 drawfont = hud_bigfont;
3698 string s, forcetime;
3700 if(autocvar__hud_configure)
3703 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);
3704 s = "^1Intermediate 1 (+15.42)";
3705 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);
3706 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3707 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);
3709 else if(race_checkpointtime)
3711 a = bound(0, 2 - (time - race_checkpointtime), 1);
3714 if(a > 0) // just hit a checkpoint?
3716 if(race_checkpoint != 254)
3718 if(race_time && race_previousbesttime)
3719 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3721 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3723 forcetime = TIME_ENCODED_TOSTRING(race_time);
3728 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3730 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3731 if(a > 0) // next one?
3733 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3738 if(s != "" && a > 0)
3740 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);
3743 if(race_penaltytime)
3745 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3748 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3749 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);
3755 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3756 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);
3761 if(race_laptime && race_checkpoint != 255)
3763 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3764 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);
3769 if(race_mycheckpointtime)
3771 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3772 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3773 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);
3775 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3777 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3778 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3779 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);
3782 if(race_penaltytime && !race_penaltyaccumulator)
3784 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3785 a = bound(0, (1 + t - time), 1);
3789 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3791 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3792 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);
3797 drawfont = hud_font;
3802 float vote_yescount;
3805 float vote_highlighted; // currently selected vote
3807 float vote_active; // is there an active vote?
3808 float vote_prev; // previous state of vote_active to check for a change
3810 float vote_change; // "time" when vote_active changed
3812 void HUD_VoteWindow(void)
3814 if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
3817 vote_called_vote = strzone(strcat("^2Name ^7instead of \"^1Unregistered player\"", " ^7in stats"));
3820 if(!autocvar_hud_panel_vote && !autocvar__hud_configure)
3823 if(!autocvar__hud_configure)
3825 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
3826 panel_bg_alpha_str = cvar_string("hud_panel_vote_bg_alpha");
3828 if(panel_bg_alpha_str == "") {
3829 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
3831 panel_bg_alpha = stof(panel_bg_alpha_str);
3836 if(vote_active != vote_prev) {
3838 vote_prev = vote_active;
3841 if(vote_active || autocvar__hud_configure)
3842 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3844 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3846 if(autocvar__hud_configure)
3856 active_panel = HUD_PANEL_VOTE;
3857 HUD_Panel_UpdateCvars(vote);
3860 mySize = panel_size;
3862 if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
3864 panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight;
3865 panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight;
3868 a = vote_alpha * bound(cvar("hud_panel_vote_alreadyvoted_alpha"), 1 - vote_highlighted, 1);
3869 HUD_Panel_DrawBg(a);
3870 a = panel_fg_alpha * a;
3872 if(panel_bg_padding)
3874 pos += '1 1 0' * panel_bg_padding;
3875 mySize -= '2 2 0' * panel_bg_padding;
3878 // always force 3:1 aspect
3880 if(mySize_x/mySize_y > 3)
3882 newSize_x = 3 * mySize_y;
3883 newSize_y = mySize_y;
3885 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3889 newSize_y = 1/3 * mySize_x;
3890 newSize_x = mySize_x;
3892 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3896 s = "A vote has been called for:";
3897 if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
3898 s = "Allow servers to store and display your name?";
3899 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3900 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1/8), stringwidth_colors);
3901 if(autocvar__hud_configure)
3902 s = "^1Configure the HUD";
3903 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
3905 // print the yes/no counts
3906 s = strcat("Yes (", getcommandkey("vyes", "vyes"), "): ", ftos(vote_yescount));
3907 if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
3908 s = strcat("Yes: (press y)");
3909 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);
3910 s = strcat("No (", getcommandkey("vno", "vno"), "): ", ftos(vote_nocount));
3911 if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
3912 s = strcat("No: (press n)");
3913 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);
3915 // draw the progress bar backgrounds
3916 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3918 // draw the highlights
3919 if(vote_highlighted == 1) {
3920 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3921 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3923 else if(vote_highlighted == 2) {
3924 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3925 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3928 // draw the progress bars
3929 if(vote_yescount && vote_needed)
3931 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3932 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3935 if(vote_nocount && vote_needed)
3937 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3938 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3941 drawresetcliparea();
3944 vote_highlighted = 0;
3948 // Mod icons panel (#10)
3951 float mod_active; // is there any active mod icon?
3953 // Clan Arena HUD modicons
3954 void HUD_Mod_CA(vector pos, vector mySize)
3956 mod_active = 1; // CA should never hide the mod icons panel
3957 float redalive, bluealive;
3958 redalive = getstati(STAT_REDALIVE);
3959 bluealive = getstati(STAT_BLUEALIVE);
3961 drawfont = hud_bigfont;
3962 vector redpos, bluepos;
3963 if(mySize_x > mySize_y)
3966 bluepos = pos + eY * 0.5 * mySize_y;
3967 drawpic_aspect_skin(redpos, "player_red.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3968 drawstring_aspect(redpos + eX * 0.5 * mySize_x, ftos(redalive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3969 drawpic_aspect_skin(bluepos, "player_blue.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3970 drawstring_aspect(bluepos + eX * 0.5 * mySize_x, ftos(bluealive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3975 bluepos = pos + eY * 0.5 * mySize_y;
3976 drawpic_aspect_skin(redpos, "player_red.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3977 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);
3978 drawpic_aspect_skin(bluepos, "player_blue.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3979 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);
3981 drawfont = hud_font;
3984 // CTF HUD modicon section
3985 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3986 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3987 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3989 void HUD_Mod_CTF_Reset(void)
3991 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3994 void HUD_Mod_CTF(vector pos, vector mySize)
3996 vector redflag_pos, blueflag_pos;
3998 float f; // every function should have that
4000 float redflag, blueflag; // current status
4001 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
4004 stat_items = getstati(STAT_ITEMS);
4005 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
4006 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
4008 if(redflag || blueflag)
4013 if(autocvar__hud_configure)
4019 // when status CHANGES, set old status into prevstatus and current status into status
4020 if (redflag != redflag_prevframe)
4022 redflag_statuschange_time = time;
4023 redflag_prevstatus = redflag_prevframe;
4024 redflag_prevframe = redflag;
4027 if (blueflag != blueflag_prevframe)
4029 blueflag_statuschange_time = time;
4030 blueflag_prevstatus = blueflag_prevframe;
4031 blueflag_prevframe = blueflag;
4034 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
4035 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
4037 float BLINK_FACTOR = 0.15;
4038 float BLINK_BASE = 0.85;
4040 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
4042 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
4044 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
4046 string red_icon, red_icon_prevstatus;
4047 float red_alpha, red_alpha_prevstatus;
4048 red_alpha = red_alpha_prevstatus = 1;
4050 case 1: red_icon = "flag_red_taken"; break;
4051 case 2: red_icon = "flag_red_lost"; break;
4052 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4054 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
4055 red_icon = "flag_red_shielded";
4057 red_icon = string_null;
4060 switch(redflag_prevstatus) {
4061 case 1: red_icon_prevstatus = "flag_red_taken"; break;
4062 case 2: red_icon_prevstatus = "flag_red_lost"; break;
4063 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4066 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
4067 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
4068 red_icon_prevstatus = "flag_red_shielded";
4070 red_icon_prevstatus = string_null;
4074 string blue_icon, blue_icon_prevstatus;
4075 float blue_alpha, blue_alpha_prevstatus;
4076 blue_alpha = blue_alpha_prevstatus = 1;
4078 case 1: blue_icon = "flag_blue_taken"; break;
4079 case 2: blue_icon = "flag_blue_lost"; break;
4080 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4082 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
4083 blue_icon = "flag_blue_shielded";
4085 blue_icon = string_null;
4088 switch(blueflag_prevstatus) {
4089 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
4090 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
4091 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4094 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
4095 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
4096 blue_icon_prevstatus = "flag_blue_shielded";
4098 blue_icon_prevstatus = string_null;
4102 if(mySize_x > mySize_y) {
4103 if (myteam == COLOR_TEAM1) { // always draw own flag on left
4105 blueflag_pos = pos + eX * 0.5 * mySize_x;
4108 redflag_pos = pos + eX * 0.5 * mySize_x;
4110 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
4112 if (myteam == COLOR_TEAM1) { // always draw own flag on left
4114 blueflag_pos = pos + eY * 0.5 * mySize_y;
4117 redflag_pos = pos + eY * 0.5 * mySize_y;
4119 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
4122 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
4123 if(red_icon_prevstatus && f < 1)
4124 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
4126 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
4128 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
4129 if(blue_icon_prevstatus && f < 1)
4130 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
4132 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
4135 // Keyhunt HUD modicon section
4136 float kh_runheretime;
4138 void HUD_Mod_KH_Reset(void)
4143 void HUD_Mod_KH(vector pos, vector mySize)
4145 mod_active = 1; // keyhunt should never hide the mod icons panel
4149 vector p, pa, kh_size, kh_asize;
4151 kh_keys = getstati(STAT_KH_KEYS);
4154 if(mySize_x > mySize_y)
4156 p_y = pos_y + 0.25 * mySize_y;
4157 pa = p - eY * 0.25 * mySize_y;
4159 kh_size_x = mySize_x * 0.25;
4160 kh_size_y = 0.75 * mySize_y;
4161 kh_asize_x = mySize_x * 0.25;
4162 kh_asize_y = mySize_y * 0.25;
4166 p_y = pos_y + 0.125 * mySize_y;
4167 pa = p - eY * 0.125 * mySize_y;
4169 kh_size_x = mySize_x * 0.5;
4170 kh_size_y = 0.375 * mySize_y;
4171 kh_asize_x = mySize_x * 0.5;
4172 kh_asize_y = mySize_y * 0.125;
4179 for(i = 0; i < 4; ++i)
4181 key = floor(kh_keys / pow(32, i)) & 31;
4183 if(keyteam == 30 && keycount <= 4)
4185 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
4189 // this yields 8 exactly if "RUN HERE" shows
4194 kh_runheretime = time;
4195 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
4200 for(i = 0; i < 4; ++i)
4202 key = floor(kh_keys / pow(32, i)) & 31;
4215 default: // owned or dropped
4220 a = a * panel_fg_alpha;
4221 aa = aa * panel_fg_alpha;
4227 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4230 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4233 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4236 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4241 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
4244 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4247 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4250 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4253 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4257 if(mySize_x > mySize_y)
4259 p_x += 0.25 * mySize_x;
4260 pa_x += 0.25 * mySize_x;
4266 p_y = pos_y + 0.625 * mySize_y;
4267 pa_y = pos_y + 0.5 * mySize_y;
4273 p_x += 0.5 * mySize_x;
4274 pa_x += 0.5 * mySize_x;
4280 // Nexball HUD mod icon
4281 void HUD_Mod_NexBall(vector pos, vector mySize)
4283 float stat_items, nb_pb_starttime, dt, p;
4285 stat_items = getstati(STAT_ITEMS);
4286 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
4288 if (stat_items & IT_KEY1)
4293 //Manage the progress bar if any
4294 if (nb_pb_starttime > 0)
4296 dt = mod(time - nb_pb_starttime, nb_pb_period);
4297 // one period of positive triangle
4298 p = 2 * dt / nb_pb_period;
4305 HUD_Panel_GetProgressBarColor(nexball);
4306 if(mySize_x > mySize_y)
4307 HUD_Panel_DrawProgressBar(pos, mySize, p, 0, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4309 HUD_Panel_DrawProgressBar(pos, mySize, p, 1, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4312 if (stat_items & IT_KEY1)
4313 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4316 // Race/CTS HUD mod icons
4317 float crecordtime_prev; // last remembered crecordtime
4318 float crecordtime_change_time; // time when crecordtime last changed
4319 float srecordtime_prev; // last remembered srecordtime
4320 float srecordtime_change_time; // time when srecordtime last changed
4322 float race_status_time;
4323 float race_status_prev;
4324 string race_status_name_prev;
4325 void HUD_Mod_Race(vector pos, vector mySize)
4327 mod_active = 1; // race should never hide the mod icons panel
4329 me = playerslots[player_localentnum - 1];
4331 float f; // yet another function has this
4332 score = me.(scores[ps_primary]);
4334 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
4335 return; // no records in the actual race
4337 drawfont = hud_bigfont;
4339 // clientside personal record
4341 if(gametype == GAME_CTS)
4345 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4347 if(score && (score < t || !t)) {
4348 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4349 if(cvar("cl_autodemo_delete_keeprecords"))
4351 f = cvar("cl_autodemo_delete");
4353 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4357 if(t != crecordtime_prev) {
4358 crecordtime_prev = t;
4359 crecordtime_change_time = time;
4362 vector textPos, medalPos;
4364 if(mySize_x > mySize_y) {
4365 // text on left side
4366 squareSize = min(mySize_y, mySize_x/2);
4367 textPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eY * 0.5 * (mySize_y - squareSize);
4368 medalPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eX * 0.5 * mySize_x + eY * 0.5 * (mySize_y - squareSize);
4371 squareSize = min(mySize_x, mySize_y/2);
4372 textPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eX * 0.5 * (mySize_x - squareSize);
4373 medalPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eY * 0.5 * mySize_y + eX * 0.5 * (mySize_x - squareSize);
4376 f = time - crecordtime_change_time;
4379 drawstring_aspect(textPos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4380 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);
4382 drawstring_aspect(textPos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4383 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);
4384 drawstring_aspect_expanding(pos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4385 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);
4389 t = race_server_record;
4390 if(t != srecordtime_prev) {
4391 srecordtime_prev = t;
4392 srecordtime_change_time = time;
4394 f = time - srecordtime_change_time;
4397 drawstring_aspect(textPos + eY * 0.5 * squareSize, "Server best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4398 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);
4400 drawstring_aspect(textPos + eY * 0.5 * squareSize, "Server best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4401 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);
4402 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);
4403 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);
4406 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4407 race_status_time = time + 5;
4408 race_status_prev = race_status;
4409 if (race_status_name_prev)
4410 strunzone(race_status_name_prev);
4411 race_status_name_prev = strzone(race_status_name);
4416 a = bound(0, race_status_time - time, 1);
4419 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
4423 rank = race_CheckName(race_status_name);
4425 rankname = race_PlaceName(rank);
4428 namepos = medalPos + '0 0.8 0' * squareSize;
4430 rankpos = medalPos + '0 0.15 0' * squareSize;
4432 if(race_status == 0)
4433 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4434 else if(race_status == 1) {
4435 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);
4436 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4437 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4438 } else if(race_status == 2) {
4439 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4440 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);
4442 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);
4443 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4444 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4445 } else if(race_status == 3) {
4446 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);
4447 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4448 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4451 if (race_status_time - time <= 0) {
4452 race_status_prev = -1;
4454 if(race_status_name)
4455 strunzone(race_status_name);
4456 race_status_name = string_null;
4457 if(race_status_name_prev)
4458 strunzone(race_status_name_prev);
4459 race_status_name_prev = string_null;
4461 drawfont = hud_font;
4464 float mod_prev; // previous state of mod_active to check for a change
4466 float mod_change; // "time" when mod_active changed
4468 void HUD_ModIcons(void)
4470 if(!autocvar_hud_panel_modicons && !autocvar__hud_configure)
4473 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && gametype != GAME_CA && !autocvar__hud_configure)
4476 active_panel = HUD_PANEL_MODICONS;
4477 HUD_Panel_UpdateCvars(modicons);
4480 mySize = panel_size;
4482 if(mod_active != mod_prev) {
4484 mod_prev = mod_active;
4487 if(mod_active || autocvar__hud_configure)
4488 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4490 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4493 HUD_Panel_DrawBg(mod_alpha);
4495 if(panel_bg_padding)
4497 pos += '1 1 0' * panel_bg_padding;
4498 mySize -= '2 2 0' * panel_bg_padding;
4501 // these MUST be ran in order to update mod_active
4502 if(gametype == GAME_KEYHUNT)
4503 HUD_Mod_KH(pos, mySize);
4504 else if(gametype == GAME_CTF || autocvar__hud_configure)
4505 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4506 else if(gametype == GAME_NEXBALL)
4507 HUD_Mod_NexBall(pos, mySize);
4508 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4509 HUD_Mod_Race(pos, mySize);
4510 else if(gametype == GAME_CA)
4511 HUD_Mod_CA(pos, mySize);
4514 // Draw pressed keys (#11)
4516 void HUD_DrawPressedKeys(void)
4518 if(!autocvar_hud_panel_pressedkeys && !autocvar__hud_configure)
4521 if(!(spectatee_status > 0 || autocvar_hud_panel_pressedkeys >= 2 || autocvar__hud_configure))
4524 active_panel = HUD_PANEL_PRESSEDKEYS;
4525 HUD_Panel_UpdateCvars(pressedkeys);
4528 mySize = panel_size;
4530 HUD_Panel_DrawBg(1);
4531 if(panel_bg_padding)
4533 pos += '1 1 0' * panel_bg_padding;
4534 mySize -= '2 2 0' * panel_bg_padding;
4537 // force custom aspect
4538 float aspect = cvar("hud_panel_pressedkeys_aspect");
4542 if(mySize_x/mySize_y > aspect)
4544 newSize_x = aspect * mySize_y;
4545 newSize_y = mySize_y;
4547 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4551 newSize_y = 1/aspect * mySize_x;
4552 newSize_x = mySize_x;
4554 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4560 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4562 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4564 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4565 drawpic_aspect_skin(pos + eX * keysize_x, ((pressedkeys & KEY_FORWARD) ? "key_forward_inv.tga" : "key_forward.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4566 drawpic_aspect_skin(pos + eX * keysize_x * 2, ((pressedkeys & KEY_JUMP) ? "key_jump_inv.tga" : "key_jump.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4568 drawpic_aspect_skin(pos, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4569 drawpic_aspect_skin(pos + eX * keysize_x, ((pressedkeys & KEY_BACKWARD) ? "key_backward_inv.tga" : "key_backward.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4570 drawpic_aspect_skin(pos + eX * keysize_x * 2, ((pressedkeys & KEY_RIGHT) ? "key_right_inv.tga" : "key_right.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4573 // Handle chat as a panel (#12)
4577 if(!autocvar_hud_panel_chat && !autocvar__hud_configure)
4579 cvar_set("con_chatrect", "0");
4583 active_panel = HUD_PANEL_CHAT;
4584 HUD_Panel_UpdateCvars(chat);
4586 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
4588 panel_pos_y = panel_bg_border;
4589 panel_size_y = vid_conheight - panel_bg_border * 2;
4590 if(panel_bg == "0") // force a border when maximized
4592 if(precache_pic(panel_bg) == "") {
4593 panel_bg = strcat(hud_skin_path, "/border_default");
4594 if(precache_pic(panel_bg) == "") {
4595 panel_bg = "gfx/hud/default/border_default";
4599 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an alpha of at least 0.75
4604 mySize = panel_size;
4606 HUD_Panel_DrawBg(1);
4608 if(panel_bg_padding)
4610 pos += '1 1 0' * panel_bg_padding;
4611 mySize -= '2 2 0' * panel_bg_padding;
4614 cvar_set("con_chatrect", "1");
4616 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4617 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4619 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4620 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4622 if(autocvar__hud_configure)
4625 chatsize = cvar("con_chatsize");
4626 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4628 for(i = 0; i < cvar("con_chat"); ++i)
4630 if(i == cvar("con_chat") - 1)
4633 a = panel_fg_alpha * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4634 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);
4639 // Engine info panel (#13)
4646 float frametimeavg1; // 1 frame ago
4647 float frametimeavg2; // 2 frames ago
4648 void HUD_EngineInfo(void)
4650 if(!autocvar_hud_panel_engineinfo && !autocvar__hud_configure)
4653 active_panel = HUD_PANEL_ENGINEINFO;
4654 HUD_Panel_UpdateCvars(engineinfo);
4657 mySize = panel_size;
4659 HUD_Panel_DrawBg(1);
4660 if(panel_bg_padding)
4662 pos += '1 1 0' * panel_bg_padding;
4663 mySize -= '2 2 0' * panel_bg_padding;
4666 float currentTime = gettime(GETTIME_REALTIME);
4667 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
4669 float currentframetime = currentTime - prevfps_time;
4670 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4671 frametimeavg2 = frametimeavg1;
4672 frametimeavg1 = frametimeavg;
4675 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4676 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.
4678 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
4679 prevfps = (1/currentframetime);
4680 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"
4682 prevfps_time = currentTime;
4687 if(currentTime - prevfps_time > cvar("hud_panel_engineinfo_framecounter_time"))
4689 prevfps = framecounter/(currentTime - prevfps_time);
4691 prevfps_time = currentTime;
4696 color = HUD_Get_Num_Color (prevfps, 100);
4697 drawfont = hud_bigfont;
4698 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_panel_engineinfo_framecounter_decimals"))), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4699 drawfont = hud_font;
4702 // Info messages panel (#14)
4704 #define drawInfoMessage(s)\
4705 if(autocvar_hud_panel_infomessages_flip)\
4706 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);\
4707 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
4709 void HUD_InfoMessages(void)
4711 if(!autocvar_hud_panel_infomessages && !autocvar__hud_configure)
4714 active_panel = HUD_PANEL_INFOMESSAGES;
4715 HUD_Panel_UpdateCvars(infomessages);
4718 mySize = panel_size;
4720 HUD_Panel_DrawBg(1);
4721 if(panel_bg_padding)
4723 pos += '1 1 0' * panel_bg_padding;
4724 mySize -= '2 2 0' * panel_bg_padding;
4727 // always force 5:1 aspect
4729 if(mySize_x/mySize_y > 5)
4731 newSize_x = 5 * mySize_y;
4732 newSize_y = mySize_y;
4734 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4738 newSize_y = 1/5 * mySize_x;
4739 newSize_x = mySize_x;
4741 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4750 fontsize = '0.20 0.20 0' * mySize_y;
4753 if(spectatee_status != 0)
4759 if(!autocvar__hud_configure)
4761 if(spectatee_status && !intermission)
4763 if(spectatee_status == -1)
4766 s = strcat("^1Spectating: ^7", GetPlayerName(spectatee_status - 1));
4769 if(spectatee_status == -1)
4770 s = strcat("^1Press ^3", getcommandkey("primary fire", "+fire"), "^1 to spectate");
4772 s = strcat("^1Press ^3", getcommandkey("primary fire", "+fire"), "^1 for another player");
4775 if(spectatee_status == -1)
4776 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
4778 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+fire2"), "^1 to observe");
4781 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
4784 if(gametype == GAME_ARENA)
4785 s = "^1Wait for your turn to join";
4786 else if(gametype == GAME_LMS)
4789 sk = playerslots[player_localentnum - 1];
4790 if(sk.(scores[ps_primary]) >= 666)
4791 s = "^1Match has already begun";
4792 else if(sk.(scores[ps_primary]) > 0)
4793 s = "^1You have no more lives left";
4795 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4798 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4801 //show restart countdown:
4802 if (time < getstatf(STAT_GAMESTARTTIME)) {
4804 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4805 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4806 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
4807 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4811 if(warmup_stage && !intermission)
4813 s = "^2Currently in ^1warmup^2 stage!";
4818 if(mod(time, 1) >= 0.5)
4823 if(ready_waiting && !intermission && !spectatee_status)
4825 if(ready_waiting_for_me)
4828 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
4830 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
4835 s = strcat("^2Waiting for others to ready up to end warmup...");
4837 s = strcat("^2Waiting for others to ready up...");
4841 else if(warmup_stage && !intermission && !spectatee_status)
4843 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
4847 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4849 float ts_min, ts_max;
4850 tm = teams.sort_next;
4853 for(; tm.sort_next; tm = tm.sort_next)
4855 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4857 if(!ts_min) ts_min = tm.team_size;
4858 else ts_min = min(ts_min, tm.team_size);
4859 if(!ts_max) ts_max = tm.team_size;
4860 else ts_max = max(ts_max, tm.team_size);
4862 if ((ts_max - ts_min) > 1)
4864 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
4865 tm = GetTeam(myteam, false);
4867 if (tm.team != COLOR_SPECTATOR)
4868 if (tm.team_size == ts_max)
4869 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
4877 s = "^7Press ^3ESC ^7to show HUD options.";
4879 s = "^3Doubleclick ^7a panel for panel-specific options.";
4881 s = "^3CTRL ^7to disable collision testing, ^3SHIFT ^7and";
4883 s = "^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.";
4894 void HUD_ShowSpeed(void)
4897 float pos, conversion_factor;
4898 string speed, zspeed, unit;
4900 switch(cvar("cl_showspeed_unit"))
4905 conversion_factor = 1.0;
4909 conversion_factor = 1.0;
4913 conversion_factor = 0.0254;
4917 conversion_factor = 0.0254 * 3.6;
4921 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4925 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4929 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4931 numsize_x = numsize_y = cvar("cl_showspeed_size");
4932 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4934 drawfont = hud_bigfont;
4935 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
4937 if (cvar("cl_showspeed_z") == 1) {
4938 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4939 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
4942 drawfont = hud_font;
4945 vector acc_prevspeed;
4949 void HUD_ShowAcceleration(void)
4951 float acceleration, sz, scale, alpha, f;
4952 vector pos, mySize, rgb;
4954 f = time - acc_prevtime;
4955 if(cvar("cl_showacceleration_z"))
4956 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4958 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4959 acc_prevspeed = pmove_vel;
4960 acc_prevtime = time;
4962 f = bound(0, f * 10, 1);
4963 acc_avg = acc_avg * (1 - f) + acceleration * f;
4964 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4965 if (acceleration == 0)
4968 sz = cvar("cl_showacceleration_size");
4969 scale = cvar("cl_showacceleration_scale");
4970 alpha = cvar("cl_showacceleration_alpha");
4971 if (cvar("cl_showacceleration_color_custom"))
4972 rgb = stov(cvar_string("cl_showacceleration_color"));
4974 if (acceleration < 0)
4975 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4977 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4980 mySize_x = vid_conwidth/2;
4982 pos_y = cvar("cl_showacceleration_position") * vid_conheight - sz/2;
4983 if (acceleration > 0)
4986 HUD_Panel_DrawProgressBar(pos, mySize, acceleration * scale, 0, 0, rgb, alpha * autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
4991 HUD_Panel_DrawProgressBar(pos, mySize, -acceleration * scale, 0, 1, rgb, alpha * autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
4995 void HUD_Reset (void)
4997 // reset gametype specific icons
4998 if(gametype == GAME_KEYHUNT)
5000 else if(gametype == GAME_CTF)
5001 HUD_Mod_CTF_Reset();
5004 #define HUD_DrawPanel(id)\
5006 case (HUD_PANEL_RADAR):\
5007 HUD_Radar(); break;\
5008 case (HUD_PANEL_WEAPONS):\
5009 HUD_Weapons(); break;\
5010 case (HUD_PANEL_AMMO):\
5012 case (HUD_PANEL_POWERUPS):\
5013 HUD_Powerups(); break;\
5014 case (HUD_PANEL_HEALTHARMOR):\
5015 HUD_HealthArmor(); break;\
5016 case (HUD_PANEL_NOTIFY):\
5017 HUD_Notify(); break;\
5018 case (HUD_PANEL_TIMER):\
5019 HUD_Timer(); break;\
5020 case (HUD_PANEL_SCORE):\
5021 HUD_Score(); break;\
5022 case (HUD_PANEL_RACETIMER):\
5023 HUD_RaceTimer(); break;\
5024 case (HUD_PANEL_VOTE):\
5025 HUD_VoteWindow(); break;\
5026 case (HUD_PANEL_MODICONS):\
5027 HUD_ModIcons(); break;\
5028 case (HUD_PANEL_PRESSEDKEYS):\
5029 HUD_DrawPressedKeys(); break;\
5030 case (HUD_PANEL_CHAT):\
5032 case (HUD_PANEL_ENGINEINFO):\
5033 HUD_EngineInfo(); break;\
5034 case (HUD_PANEL_INFOMESSAGES):\
5035 HUD_InfoMessages(); break;\
5036 } ENDS_WITH_CURLY_BRACE
5038 void HUD_Main (void)
5041 // global hud alpha fade
5042 if(menu_enabled == 1)
5045 hud_fade_alpha = (1 - autocvar__menu_alpha);
5047 if(scoreboard_fade_alpha)
5048 hud_fade_alpha = (1 - scoreboard_fade_alpha);
5050 if(intermission == 2) // no hud during mapvote
5052 else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
5055 if(!autocvar__hud_configure && !hud_fade_alpha)
5059 if (hud_skin_path != cvar_string("hud_skin"))
5062 strunzone(hud_skin_path);
5063 hud_skin_path = strzone(strcat("gfx/hud/", cvar_string("hud_skin")));
5066 // HUD configure visible grid
5067 float hud_configure_grid_alpha;
5068 if(autocvar__hud_configure && cvar("hud_configure_grid") && (hud_configure_grid_alpha = cvar("hud_configure_grid_alpha")))
5070 hud_configure_gridSize_x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
5071 hud_configure_gridSize_y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
5072 hud_configure_realGridSize_x = hud_configure_gridSize_x * vid_conwidth;
5073 hud_configure_realGridSize_y = hud_configure_gridSize_y * vid_conheight;
5075 for(i = 0; i < 1/hud_configure_gridSize_x; ++i)
5076 drawfill(eX * i * hud_configure_realGridSize_x, eX + eY * vid_conheight, '0.5 0.5 0.5', hud_configure_grid_alpha, DRAWFLAG_NORMAL);
5078 for(i = 0; i < 1/hud_configure_gridSize_y; ++i)
5079 drawfill(eY * i * hud_configure_realGridSize_y, eY + eX * vid_conwidth, '0.5 0.5 0.5', hud_configure_grid_alpha, DRAWFLAG_NORMAL);
5083 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
5087 float hud_dock_color_team = cvar("hud_dock_color_team");
5088 if((teamplay) && hud_dock_color_team) {
5089 f = stof(getplayerkey(player_localentnum - 1, "colors"));
5090 color = colormapPaletteColor(mod(f, 16), 1) * hud_dock_color_team;
5092 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
5093 color = '1 0 0' * hud_dock_color_team;
5097 string hud_dock_color = cvar_string("hud_dock_color");
5098 if(hud_dock_color == "shirt") {
5099 f = stof(getplayerkey(player_localentnum - 1, "colors"));
5100 color = colormapPaletteColor(floor(f / 16), 0);
5102 else if(hud_dock_color == "pants") {
5103 f = stof(getplayerkey(player_localentnum - 1, "colors"));
5104 color = colormapPaletteColor(mod(f, 16), 1);
5107 color = stov(hud_dock_color);
5111 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
5112 if(precache_pic(pic) == "") {
5113 pic = strcat(hud_skin_path, "/dock_medium");
5114 if(precache_pic(pic) == "") {
5115 pic = "gfx/hud/default/dock_medium";
5118 drawpic('0 0 0', pic, eX * vid_conwidth + eY * vid_conheight, color, cvar("hud_dock_alpha") * hud_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
5121 // cache the panel order into the panel_order array
5122 if(autocvar__hud_panelorder != hud_panelorder_prev) {
5123 for(i = 0; i < HUD_PANEL_NUM; ++i)
5124 panel_order[i] = -1;
5126 float p_num, warning;
5127 float argc = tokenize_console(autocvar__hud_panelorder);
5128 if (argc > HUD_PANEL_NUM)
5130 //first detect wrong/missing panel numbers
5131 for(i = 0; i < HUD_PANEL_NUM; ++i) {
5132 p_num = stof(argv(i));
5133 if (p_num >= 0 && p_num < HUD_PANEL_NUM) { //correct panel number?
5134 if (panel_order[p_num] == -1) //found for the first time?
5135 s = strcat(s, ftos(p_num), " ");
5136 panel_order[p_num] = 1; //mark as found
5141 for(i = 0; i < HUD_PANEL_NUM; ++i) {
5142 if (panel_order[i] == -1) {
5144 s = strcat(s, ftos(i), " "); //add missing panel number
5148 print("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n");
5150 cvar_set("_hud_panelorder", s);
5151 if(hud_panelorder_prev)
5152 strunzone(hud_panelorder_prev);
5153 hud_panelorder_prev = strzone(s);
5155 //now properly set panel_order
5156 tokenize_console(s);
5157 for(i = 0; i < HUD_PANEL_NUM; ++i) {
5158 panel_order[i] = stof(argv(i));
5161 // draw panels in order specified by panel_order array
5162 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
5163 if(i != HUD_PANEL_CHAT || !autocvar__con_chat_maximized) // don't draw maximized chat panel twice!
5164 HUD_DrawPanel(panel_order[i]);
5167 // draw chat panel on top if it is maximized
5168 if(autocvar__con_chat_maximized)
5169 HUD_Chat(); // HUD_DrawPanel(HUD_PANEL_CHAT);
5171 // TODO hud_'ify these
5172 if (cvar("cl_showspeed"))
5174 if (cvar("cl_showacceleration"))
5175 HUD_ShowAcceleration();
5177 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)
5178 localcmd("cmd selectteam auto; cmd join\n");
5180 hud_configure_prev = autocvar__hud_configure;
5182 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again