7 // a border picture is a texture containing nine parts:
8 // 1/4 width: left part
9 // 1/2 width: middle part (stretched)
10 // 1/4 width: right part
12 // 1/4 height: top part
13 // 1/2 height: middle part (stretched)
14 // 1/4 height: bottom part
15 void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize)
17 if (theBorderSize_x < 0 && theBorderSize_y < 0) // draw whole image as it is
19 drawpic(theOrigin, pic, theSize, theColor, theAlpha, 0);
22 if (theBorderSize_x == 0 && theBorderSize_y == 0) // no border
24 // draw only the central part
25 drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
32 //pic = draw_UseSkinFor(pic);
33 width = eX * theSize_x;
34 height = eY * theSize_y;
35 if(theSize_x <= theBorderSize_x * 2)
37 // not wide enough... draw just left and right then
38 bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
39 if(theSize_y <= theBorderSize_y * 2)
41 // not high enough... draw just corners
42 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
43 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
44 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
45 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
46 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
50 dY = theBorderSize_x * eY;
51 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
52 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
53 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
54 drawsubpic(theOrigin + width * 0.5 + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0' + eX - bW, '0 0.5 0' + bW, theColor, theAlpha, 0);
55 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
56 drawsubpic(theOrigin + width * 0.5 + height - dY, width * 0.5 + dY, pic, '0 0.75 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
61 if(theSize_y <= theBorderSize_y * 2)
63 // not high enough... draw just top and bottom then
64 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
65 dX = theBorderSize_x * eX;
66 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
67 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
68 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
69 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
70 drawsubpic(theOrigin + dX + height * 0.5, width - 2 * dX + height * 0.5, pic, '0.25 0 0' + eY - bH, '0.5 0 0' + bH, theColor, theAlpha, 0);
71 drawsubpic(theOrigin + width - dX + height * 0.5, dX + height * 0.5, pic, '0.75 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
75 dX = theBorderSize_x * eX;
76 dY = theBorderSize_x * eY;
77 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
78 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
79 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
80 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
81 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
82 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
83 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
84 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
85 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
90 vector HUD_Get_Num_Color (float x, float maxvalue)
98 else if(x > maxvalue * 0.75) {
99 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
100 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
103 else if(x > maxvalue * 0.5) {
104 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
105 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
106 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
108 else if(x > maxvalue * 0.25) {
111 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
113 else if(x > maxvalue * 0.1) {
115 color_y = (x-20)*90/27/100; // green value between 0 -> 1
116 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
126 float stringwidth_colors(string s, vector theSize)
128 return stringwidth(s, TRUE, theSize);
131 float stringwidth_nocolors(string s, vector theSize)
133 return stringwidth(s, FALSE, theSize);
136 #define CENTERPRINT_MAX_LINES 30
137 string centerprint_messages[CENTERPRINT_MAX_LINES];
138 float centerprint_width[CENTERPRINT_MAX_LINES];
139 float centerprint_time;
140 float centerprint_expire;
141 float centerprint_num;
142 float centerprint_offset_hint;
143 vector centerprint_fontsize;
145 void centerprint(string strMessage)
147 float i, j, n, hcount;
150 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
152 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
154 if(autocvar_scr_centertime <= 0)
160 // strip trailing newlines
161 j = strlen(strMessage) - 1;
162 while(substring(strMessage, j, 1) == "\n" && j >= 0)
164 strMessage = substring(strMessage, 0, j + 1);
169 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
171 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
173 strMessage = substring(strMessage, j, strlen(strMessage) - j);
174 centerprint_offset_hint = j;
179 // if we get here, we have a message. Initialize its height.
182 n = tokenizebyseparator(strMessage, "\n");
184 for(j = 0; j < n; ++j)
186 getWrappedLine_remaining = argv(j);
187 while(getWrappedLine_remaining)
189 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
190 if(centerprint_messages[i] != s) // don't fade the same message in, looks stupid
191 centerprint_time = time;
192 if(centerprint_messages[i])
193 strunzone(centerprint_messages[i]);
194 centerprint_messages[i] = strzone(s);
195 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
198 // half height for empty lines looks better
204 if(i >= CENTERPRINT_MAX_LINES)
210 h = centerprint_fontsize_y*hcount;
212 havail = vid_conheight;
213 if(autocvar_con_chatpos < 0)
214 havail -= (-autocvar_con_chatpos + autocvar_con_chat) * autocvar_con_chatsize; // avoid overlapping chat
215 if(havail > vid_conheight - 70)
216 havail = vid_conheight - 70; // avoid overlapping HUD
219 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
221 // here, the centerprint would cover the crosshair. REALLY BAD.
222 forbiddenmin = vid_conheight * 0.5 - h - 16;
223 forbiddenmax = vid_conheight * 0.5 + 16;
225 allowedmin = scoreboard_bottom;
226 allowedmax = havail - h;
227 preferred = (havail - h)/2;
230 // possible orderings (total: 4! / 4 = 6)
231 // allowedmin allowedmax forbiddenmin forbiddenmax
232 // forbiddenmin forbiddenmax allowedmin allowedmax
233 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
235 // forbidden doesn't matter in this case
236 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
238 // allowedmin forbiddenmin allowedmax forbiddenmax
239 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
241 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
243 // allowedmin forbiddenmin forbiddenmax allowedmax
244 else if(allowedmin < forbiddenmin)
246 // make sure the forbidden zone is not covered
247 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
248 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
250 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
252 // forbiddenmin allowedmin allowedmax forbiddenmax
253 else if(allowedmax < forbiddenmax)
255 // it's better to leave the allowed zone (overlap with scoreboard) than
256 // to cover the forbidden zone (crosshair)
257 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
258 centerprint_start_y = forbiddenmax;
260 centerprint_start_y = forbiddenmin;
262 // forbiddenmin allowedmin forbiddenmax allowedmax
265 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
272 centerprint_expire = time + autocvar_scr_centertime;
275 void HUD_DrawCenterPrint (void)
282 if(time - centerprint_time < 0.25)
283 a = (time - centerprint_time) / 0.25;
285 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
292 if(centerprint_num * autocvar_scr_centersize > 24 && scoreboard_active) // 24 = height of Scoreboard text
293 centerprint_start_y = scoreboard_bottom + centerprint_fontsize_y;
295 pos = centerprint_start;
296 for (i=0; i<centerprint_num; i = i + 1)
298 ts = centerprint_messages[i];
299 drawfontscale = sz * '1 1 0';
300 pos_x = (vid_conwidth - stringwidth(ts, TRUE, centerprint_fontsize)) * 0.5;
303 drawcolorcodedstring(pos + '0 1 0' * (1 - sz) * 0.5 *centerprint_fontsize_y, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
304 pos_y = pos_y + centerprint_fontsize_y;
307 // half height for empty lines looks better
308 pos_y = pos_y + sz * centerprint_fontsize_y * 0.5;
309 drawfontscale = '1 1 0';
313 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
315 position_x -= 2 / 3 * strlen(text) * scale_x;
316 drawstring(position, text, scale, rgb, alpha, flag);
319 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
321 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
322 drawstring(position, text, scale, rgb, alpha, flag);
325 // return the string of the given race place
326 string race_PlaceName(float pos) {
334 return strcat(ftos(pos), "th");
337 // return the string of the onscreen race timer
338 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
346 if(histime == 0) // goal hit
350 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
360 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
366 lapstr = strcat(" (-", ftos(lapdelta), "L)");
369 else if(lapdelta < 0)
371 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
375 else if(histime > 0) // anticipation
377 if(mytime >= histime)
378 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
380 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
387 cpname = "Start line";
389 cpname = "Finish line";
391 cpname = strcat("Intermediate ", ftos(cp));
393 cpname = "Finish line";
396 return strcat(col, cpname);
397 else if(hisname == "")
398 return strcat(col, cpname, " (", timestr, ")");
400 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
403 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
404 float race_CheckName(string net_name) {
406 for (i=RANKINGS_CNT-1;i>=0;--i)
407 if(grecordholder[i] == net_name)
418 // draw the background/borders
419 #define HUD_Panel_DrawBg(alpha)\
421 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));\
422 if(highlightedPanel == hud_configure_active_panel && autocvar__hud_configure)\
424 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);\
425 } ENDS_WITH_CURLY_BRACE
427 //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
428 void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, float vertical, float baralign, vector theColor, float theAlpha, float drawflag)
430 if(!length_ratio || !theAlpha)
436 if(length_ratio < -1)
439 else if(length_ratio < 0)
443 vector width, height;
445 pic = strcat(hud_skin_path, "/", pic, "_vertical");
446 if(precache_pic(pic) == "") {
447 pic = "gfx/hud/default/statusbar_vertical";
450 if (baralign == 1) // bottom align
451 theOrigin_y += (1 - length_ratio) * theSize_y;
452 else if (baralign == 2) // center align
453 theOrigin_y += 0.5 * (1 - length_ratio) * theSize_y;
454 else if (baralign == 3) // center align, positive values down, negative up
457 if (length_ratio > 0)
458 theOrigin_y += theSize_y;
461 theOrigin_y += (1 + length_ratio) * theSize_y;
462 length_ratio = -length_ratio;
465 theSize_y *= length_ratio;
468 width = eX * theSize_x;
469 height = eY * theSize_y;
470 if(theSize_y <= theSize_x * 2)
472 // button not high enough
473 // draw just upper and lower part then
474 square = eY * theSize_y * 0.5;
475 bH = eY * (0.25 * theSize_y / (theSize_x * 2));
476 drawsubpic(theOrigin, square + width, pic, '0 0 0', eX + bH, theColor, theAlpha, drawflag);
477 drawsubpic(theOrigin + square, square + width, pic, eY - bH, eX + bH, theColor, theAlpha, drawflag);
481 square = eY * theSize_x;
482 drawsubpic(theOrigin, width + square, pic, '0 0 0', '1 0.25 0', theColor, theAlpha, drawflag);
483 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0 0.25 0', '1 0.5 0', theColor, theAlpha, drawflag);
484 drawsubpic(theOrigin + height - square, width + square, pic, '0 0.75 0', '1 0.25 0', theColor, theAlpha, drawflag);
487 pic = strcat(hud_skin_path, "/", pic);
488 if(precache_pic(pic) == "") {
489 pic = "gfx/hud/default/statusbar";
492 if (baralign == 1) // right align
493 theOrigin_x += (1 - length_ratio) * theSize_x;
494 else if (baralign == 2) // center align
495 theOrigin_x += 0.5 * (1 - length_ratio) * theSize_x;
496 else if (baralign == 3) // center align, positive values on the right, negative on the left
499 if (length_ratio > 0)
500 theOrigin_x += theSize_x;
503 theOrigin_x += (1 + length_ratio) * theSize_x;
504 length_ratio = -length_ratio;
507 theSize_x *= length_ratio;
510 width = eX * theSize_x;
511 height = eY * theSize_y;
512 if(theSize_x <= theSize_y * 2)
514 // button not wide enough
515 // draw just left and right part then
516 square = eX * theSize_x * 0.5;
517 bW = eX * (0.25 * theSize_x / (theSize_y * 2));
518 drawsubpic(theOrigin, square + height, pic, '0 0 0', eY + bW, theColor, theAlpha, drawflag);
519 drawsubpic(theOrigin + square, square + height, pic, eX - bW, eY + bW, theColor, theAlpha, drawflag);
523 square = eX * theSize_y;
524 drawsubpic(theOrigin, height + square, pic, '0 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
525 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0.25 0 0', '0.5 1 0', theColor, theAlpha, drawflag);
526 drawsubpic(theOrigin + width - square, height + square, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
531 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
537 pic = strcat(hud_skin_path, "/num_leading");
538 if(precache_pic(pic) == "") {
539 pic = "gfx/hud/default/num_leading";
542 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
543 if(mySize_x/mySize_y > 2)
544 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);
545 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);
550 entity weaponorder[WEP_MAXCOUNT];
551 void weaponorder_swap(float i, float j, entity pass)
555 weaponorder[i] = weaponorder[j];
559 string weaponorder_cmp_str;
560 float weaponorder_cmp(float i, float j, entity pass)
563 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
564 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
565 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)
568 float GetAmmoStat(float i)
572 case 0: return STAT_SHELLS;
573 case 1: return STAT_NAILS;
574 case 2: return STAT_ROCKETS;
575 case 3: return STAT_CELLS;
576 case 4: return STAT_FUEL;
581 float GetAmmoTypeForWep(float i)
585 case WEP_SHOTGUN: return 0;
586 case WEP_UZI: return 1;
587 case WEP_GRENADE_LAUNCHER: return 2;
588 case WEP_MINE_LAYER: return 2;
589 case WEP_ELECTRO: return 3;
590 case WEP_CRYLINK: return 3;
591 case WEP_HLAC: return 3;
592 case WEP_MINSTANEX: return 3;
593 case WEP_NEX: return 3;
594 case WEP_SNIPERRIFLE: return 1;
595 case WEP_HAGAR: return 2;
596 case WEP_ROCKET_LAUNCHER: return 2;
597 case WEP_SEEKER: return 2;
598 case WEP_FIREBALL: return 4;
599 case WEP_HOOK: return 3;
604 void HUD_Weapons(void)
607 float center_x, center_y;
609 if(!autocvar__hud_configure)
611 if(!autocvar_hud_panel_weapons) return;
612 if(spectatee_status == -1) return;
615 hud_configure_active_panel = HUD_PANEL_WEAPONS;
617 float timeout = autocvar_hud_panel_weapons_timeout;
618 float timeout_effect_length, timein_effect_length;
619 if (autocvar_hud_panel_weapons_timeout_effect == 0)
621 timeout_effect_length = 0;
622 timein_effect_length = 0;
626 timeout_effect_length = 0.75;
627 timein_effect_length = 0.375;
630 if (timeout && time >= weapontime + timeout + timeout_effect_length && !autocvar__hud_configure)
632 weaponprevtime = time;
636 HUD_Panel_UpdateCvars(weapons);
638 if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
640 f = (time - (weapontime + timeout)) / timeout_effect_length;
641 if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3)
643 panel_bg_alpha *= (1 - f);
644 panel_fg_alpha *= (1 - f);
646 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
648 f *= f; // for a cooler movement
649 center_x = panel_pos_x + panel_size_x/2;
650 center_y = panel_pos_y + panel_size_y/2;
651 screen_ar = vid_conwidth/vid_conheight;
652 if (center_x/center_y < screen_ar) //bottom left
654 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
655 panel_pos_y += f * (vid_conheight - panel_pos_y);
657 panel_pos_x -= f * (panel_pos_x + panel_size_x);
661 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
662 panel_pos_x += f * (vid_conwidth - panel_pos_x);
664 panel_pos_y -= f * (panel_pos_y + panel_size_y);
667 weaponprevtime = time - (1 - f) * timein_effect_length;
669 else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure)
671 f = (time - weaponprevtime) / timein_effect_length;
672 if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3)
674 panel_bg_alpha *= (f);
675 panel_fg_alpha *= (f);
677 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
679 f *= f; // for a cooler movement
681 center_x = panel_pos_x + panel_size_x/2;
682 center_y = panel_pos_y + panel_size_y/2;
683 screen_ar = vid_conwidth/vid_conheight;
684 if (center_x/center_y < screen_ar) //bottom left
686 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
687 panel_pos_y += f * (vid_conheight - panel_pos_y);
689 panel_pos_x -= f * (panel_pos_x + panel_size_x);
693 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
694 panel_pos_x += f * (vid_conwidth - panel_pos_x);
696 panel_pos_y -= f * (panel_pos_y + panel_size_y);
701 float i, weapid, wpnalpha, weapon_cnt;
703 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
705 self = get_weaponinfo(i);
706 if(self.impulse >= 0)
710 // TODO make this configurable
711 if(weaponorder_bypriority != autocvar_cl_weaponpriority)
713 if(weaponorder_bypriority)
714 strunzone(weaponorder_bypriority);
715 if(weaponorder_byimpulse)
716 strunzone(weaponorder_byimpulse);
718 weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
719 weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
720 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
723 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
725 self = get_weaponinfo(i);
726 if(self.impulse >= 0)
728 weaponorder[weapon_cnt] = self;
732 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
734 weaponorder_cmp_str = string_null;
740 panel_pos += '1 1 0' * panel_bg_padding;
741 panel_size -= '2 2 0' * panel_bg_padding;
744 if(autocvar_hud_panel_weapons_fade)
746 wpnalpha = 3.2 - 2 * (time - weapontime);
747 wpnalpha = bound(0.7, wpnalpha, 1) * panel_fg_alpha;
750 wpnalpha = panel_fg_alpha;
753 float aspect = autocvar_hud_panel_weapons_aspect;
754 rows = panel_size_y/panel_size_x;
755 rows = bound(1, floor((sqrt(4 * aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
757 columns = ceil(WEP_COUNT/rows);
760 float a, type, fullammo;
762 when = autocvar_hud_panel_weapons_complainbubble_time;
764 fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
772 wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
773 float barsize_x, barsize_y, baroffset_x, baroffset_y;
774 if (autocvar_hud_panel_weapons_ammo)
776 ammo_color = stov(autocvar_hud_panel_weapons_ammo_color);
777 ammo_alpha = panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha;
780 if(wpnsize_x/wpnsize_y > aspect)
782 barsize_x = aspect * wpnsize_y;
783 barsize_y = wpnsize_y;
784 baroffset_x = (wpnsize_x - barsize_x) / 2;
788 barsize_y = 1/aspect * wpnsize_x;
789 barsize_x = wpnsize_x;
790 baroffset_y = (wpnsize_y - barsize_y) / 2;
796 if(autocvar_hud_panel_weapons_accuracy && acc_levels)
798 show_accuracy = true;
799 if (acc_col_x[0] == -1)
800 for (i = 0; i < acc_levels; ++i)
801 acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
804 float weapons_st = getstati(STAT_WEAPONS);
806 for(i = 0; i < weapon_cnt; ++i)
808 wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y;
810 self = weaponorder[i];
811 weapid = self.impulse;
813 // draw background behind currently selected weapon
814 if(self.weapon == activeweapon)
815 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
817 // draw the weapon accuracy
820 weapon_stats = weapon_accuracy[self.weapon-WEP_FIRST];
821 if(weapon_stats >= 0)
823 // find the max level lower than weapon_stats
826 while ( j && weapon_stats < acc_lev[j] )
829 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
831 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
833 color = color + factor * (acc_col[j+1] - color);
835 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
839 // draw the weapon icon
840 if((weapid >= 0) && (weapons_st & self.weapons))
842 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
844 if(autocvar_hud_panel_weapons_label == 1) // weapon number
845 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
846 else if(autocvar_hud_panel_weapons_label == 2) // bind
847 drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
849 // draw ammo status bar
850 if(autocvar_hud_panel_weapons_ammo && self.weapon != WEP_TUBA && self.weapon != WEP_LASER && self.weapon != WEP_PORTO)
853 type = GetAmmoTypeForWep(self.weapon);
855 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
860 case 0: fullammo = autocvar_hud_panel_weapons_ammo_full_shells; break;
861 case 1: fullammo = autocvar_hud_panel_weapons_ammo_full_nails; break;
862 case 2: fullammo = autocvar_hud_panel_weapons_ammo_full_rockets; break;
863 case 3: fullammo = autocvar_hud_panel_weapons_ammo_full_cells; break;
864 case 4: fullammo = autocvar_hud_panel_weapons_ammo_full_fuel; break;
865 default: fullammo = 60;
869 wpnpos_x + baroffset_x,
870 wpnpos_y + baroffset_y,
871 barsize_x * bound(0, a/fullammo, 1),
873 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, ammo_color, ammo_alpha, DRAWFLAG_NORMAL);
879 // draw a "ghost weapon icon" if you don't have the weapon
882 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
885 // draw the complain message
886 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
890 if(complain_weapon_time + when > time)
893 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
897 if(complain_weapon_time + when > time)
904 if(complain_weapon_type == 0) {
906 color = stov(autocvar_hud_panel_weapons_complainbubble_color_outofammo);
908 else if(complain_weapon_type == 1) {
910 color = stov(autocvar_hud_panel_weapons_complainbubble_color_donthave);
914 color = stov(autocvar_hud_panel_weapons_complainbubble_color_unavailable);
916 float padding = autocvar_hud_panel_weapons_complainbubble_padding;
917 drawpic_aspect_skin(wpnpos + '1 1 0' * padding, "weapon_complainbubble", wpnsize - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
918 drawstring_aspect(wpnpos + '1 1 0' * padding, s, wpnsize - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
934 float GetAmmoItemCode(float i)
938 case 0: return IT_SHELLS;
939 case 1: return IT_NAILS;
940 case 2: return IT_ROCKETS;
941 case 3: return IT_CELLS;
942 case 4: return IT_FUEL;
947 string GetAmmoPicture(float i)
951 case 0: return "ammo_shells";
952 case 1: return "ammo_bullets";
953 case 2: return "ammo_rockets";
954 case 3: return "ammo_cells";
955 case 4: return "ammo_fuel";
960 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
963 if(autocvar__hud_configure)
965 currently_selected = (itemcode == 2); //rockets always selected
966 a = 31 + mod(itemcode*93, 128);
969 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
978 if(currently_selected)
983 vector picpos, numpos;
984 if(autocvar_hud_panel_ammo_iconalign)
987 picpos = myPos + eX * 2 * mySize_y;
991 numpos = myPos + eX * mySize_y;
995 if (currently_selected)
996 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
998 if(a > 0 && autocvar_hud_panel_ammo_progressbar)
999 HUD_Panel_DrawProgressBar(myPos + eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize_x, mySize - eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize_x, autocvar_hud_panel_ammo_progressbar_name, 0, 0, a/autocvar_hud_panel_ammo_maxammo, color, autocvar_hud_progressbar_alpha * panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1001 if(autocvar_hud_panel_ammo_text)
1004 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1005 else // "ghost" ammo count
1006 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1009 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1010 else // "ghost" ammo icon
1011 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1016 if(!autocvar__hud_configure)
1018 if(!autocvar_hud_panel_ammo) return;
1019 if(spectatee_status == -1) return;
1022 hud_configure_active_panel = HUD_PANEL_AMMO;
1024 HUD_Panel_UpdateCvars(ammo);
1027 mySize = panel_size;
1029 HUD_Panel_DrawBg(1);
1030 if(panel_bg_padding)
1032 pos += '1 1 0' * panel_bg_padding;
1033 mySize -= '2 2 0' * panel_bg_padding;
1036 float rows, columns, row, column;
1038 if (autocvar_hud_panel_ammo_onlycurrent)
1042 rows = mySize_y/mySize_x;
1043 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1044 // ^^^ ammo item aspect goes here
1046 columns = ceil(AMMO_COUNT/rows);
1048 ammo_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
1053 if(ammo_size_x/ammo_size_y > 3)
1055 newSize = 3 * ammo_size_y;
1056 offset_x = ammo_size_x - newSize;
1057 pos_x += offset_x/2;
1058 ammo_size_x = newSize;
1062 newSize = 1/3 * ammo_size_x;
1063 offset_y = ammo_size_y - newSize;
1064 pos_y += offset_y/2;
1065 ammo_size_y = newSize;
1068 float i, stat_items, currently_selected;
1069 if (autocvar_hud_panel_ammo_onlycurrent)
1071 if(autocvar__hud_configure)
1073 DrawAmmoItem(pos, ammo_size, 2, true); //show rockets
1076 stat_items = getstati(STAT_ITEMS);
1077 for (i = 0; i < AMMO_COUNT; ++i) {
1078 currently_selected = stat_items & GetAmmoItemCode(i);
1079 if (currently_selected)
1081 DrawAmmoItem(pos, ammo_size, i, true);
1085 return; // nothing to display
1088 stat_items = getstati(STAT_ITEMS);
1089 for (i = 0; i < AMMO_COUNT; ++i) {
1090 currently_selected = stat_items & GetAmmoItemCode(i);
1091 DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected);
1096 column = column + 1;
1101 void DrawNumIcon(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float alpha)
1103 vector newPos, newSize;
1104 vector picpos, numpos;
1108 if(mySize_y/mySize_x > 2)
1110 newSize_y = 2 * mySize_x;
1111 newSize_x = mySize_x;
1113 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1118 newSize_x = 1/2 * mySize_y;
1119 newSize_y = mySize_y;
1121 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1125 if(icon_right_align)
1128 picpos = newPos + eY * newSize_x;
1133 numpos = newPos + eY * newSize_x;
1137 drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1138 // make number smaller than icon, it looks better
1139 // reduce only y to draw numbers with different number of digits with the same y size
1140 numpos_y += newSize_y * ((1 - 0.7) / 2);
1142 drawstring_aspect(numpos, ftos(x), newSize, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1146 if(mySize_x/mySize_y > 3)
1148 newSize_x = 3 * mySize_y;
1149 newSize_y = mySize_y;
1151 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1156 newSize_y = 1/3 * mySize_x;
1157 newSize_x = mySize_x;
1159 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1163 if(icon_right_align) // right align
1166 picpos = newPos + eX * 2 * newSize_y;
1170 numpos = newPos + eX * newSize_y;
1174 drawstring_aspect(numpos, ftos(x), '2 1 0' * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1175 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1178 void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float fadelerp)
1181 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
1183 DrawNumIcon(myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, vertical, icon_right_align, color, (1 - fadelerp));
1188 void HUD_Powerups(void)
1190 float strength_time, shield_time;
1191 if(!autocvar__hud_configure)
1193 if(!autocvar_hud_panel_powerups) return;
1194 if(spectatee_status == -1) return;
1195 if not(getstati(STAT_ITEMS) & (IT_STRENGTH | IT_INVINCIBLE)) return;
1196 if (getstati(STAT_HEALTH) <= 0) return;
1198 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1199 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1203 hud_configure_active_panel = HUD_PANEL_POWERUPS;
1209 HUD_Panel_UpdateCvars(powerups);
1212 mySize = panel_size;
1214 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
1215 if(panel_bg_padding)
1217 pos += '1 1 0' * panel_bg_padding;
1218 mySize -= '2 2 0' * panel_bg_padding;
1221 float panel_ar = mySize_x/mySize_y;
1222 float is_vertical = (panel_ar < 1);
1223 vector shield_offset, strength_offset;
1224 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1227 if (autocvar_hud_panel_powerups_flip)
1228 shield_offset_x = mySize_x;
1230 strength_offset_x = mySize_x;
1235 if (autocvar_hud_panel_powerups_flip)
1236 shield_offset_y = mySize_y;
1238 strength_offset_y = mySize_y;
1241 float shield_baralign, strength_baralign;
1242 float shield_iconalign, strength_iconalign;
1243 if (autocvar_hud_panel_powerups_flip)
1245 strength_baralign = (autocvar_hud_panel_powerups_baralign == 2 || autocvar_hud_panel_powerups_baralign == 1);
1246 shield_baralign = (autocvar_hud_panel_powerups_baralign == 3 || autocvar_hud_panel_powerups_baralign == 1);
1247 strength_iconalign = (autocvar_hud_panel_powerups_iconalign == 2 || autocvar_hud_panel_powerups_iconalign == 1);
1248 shield_iconalign = (autocvar_hud_panel_powerups_iconalign == 3 || autocvar_hud_panel_powerups_iconalign == 1);
1252 shield_baralign = (autocvar_hud_panel_powerups_baralign == 2 || autocvar_hud_panel_powerups_baralign == 1);
1253 strength_baralign = (autocvar_hud_panel_powerups_baralign == 3 || autocvar_hud_panel_powerups_baralign == 1);
1254 shield_iconalign = (autocvar_hud_panel_powerups_iconalign == 2 || autocvar_hud_panel_powerups_iconalign == 1);
1255 strength_iconalign = (autocvar_hud_panel_powerups_iconalign == 3 || autocvar_hud_panel_powerups_iconalign == 1);
1260 const float maxshield = 30;
1261 float shield = ceil(shield_time);
1262 if(autocvar_hud_panel_powerups_progressbar)
1264 HUD_Panel_GetProgressBarColor(shield);
1265 HUD_Panel_DrawProgressBar(pos + shield_offset, mySize, autocvar_hud_panel_powerups_progressbar_shield, shield/maxshield, is_vertical, shield_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1267 if(autocvar_hud_panel_powerups_text)
1270 DrawNumIcon(pos + shield_offset, mySize, shield, "shield", is_vertical, shield_iconalign, '1 1 1', 1);
1272 DrawNumIcon_expanding(pos + shield_offset, mySize, shield, "shield", is_vertical, shield_iconalign, '1 1 1', bound(0, (shield - shield_time) / 0.5, 1));
1278 const float maxstrength = 30;
1279 float strength = ceil(strength_time);
1280 if(autocvar_hud_panel_powerups_progressbar)
1282 HUD_Panel_GetProgressBarColor(strength);
1283 HUD_Panel_DrawProgressBar(pos + strength_offset, mySize, autocvar_hud_panel_powerups_progressbar_strength, strength/maxstrength, is_vertical, strength_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1285 if(autocvar_hud_panel_powerups_text)
1288 DrawNumIcon(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', 1);
1290 DrawNumIcon_expanding(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', bound(0, (strength - strength_time) / 0.5, 1));
1295 // Health/armor (#3)
1297 float health_time, prev_health;
1298 float armor_time, prev_armor;
1299 var float saved_health = -2;
1300 var float saved_armor = -2;
1301 void HUD_HealthArmor(void)
1303 float armor, health, fuel;
1304 if(!autocvar__hud_configure)
1306 if(!autocvar_hud_panel_healtharmor) return;
1307 if(spectatee_status == -1) return;
1309 health = getstati(STAT_HEALTH);
1315 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1317 if ( (prev_spectatee_status == -1 && spectatee_status > 0) //before observing, now spectating
1318 || (prev_spectatee_status > 0 && spectatee_status > 0 && prev_spectatee_status != spectatee_status) //changed spectated player
1327 else if(prev_spectatee_status == -1 || (prev_spectatee_status > 0 && !spectatee_status)) //before spectating/observing, now playing
1330 if (health_time == -1)
1332 //start the load effect
1341 armor = getstati(STAT_ARMOR);
1342 fuel = getstati(STAT_FUEL);
1346 hud_configure_active_panel = HUD_PANEL_HEALTHARMOR;
1353 HUD_Panel_UpdateCvars(healtharmor);
1356 mySize = panel_size;
1358 HUD_Panel_DrawBg(1);
1359 if(panel_bg_padding)
1361 pos += '1 1 0' * panel_bg_padding;
1362 mySize -= '2 2 0' * panel_bg_padding;
1365 float baralign = autocvar_hud_panel_healtharmor_baralign;
1366 float iconalign = autocvar_hud_panel_healtharmor_iconalign;
1368 float maxhealth = autocvar_hud_panel_healtharmor_maxhealth;
1369 float maxarmor = autocvar_hud_panel_healtharmor_maxarmor;
1370 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
1373 v = healtharmor_maxdamage(health, armor, armorblockpercent);
1378 float maxtotal = maxhealth + maxarmor;
1380 if(v_z) // NOT fully armored
1382 biggercount = "health";
1383 if(autocvar_hud_panel_healtharmor_progressbar)
1385 HUD_Panel_GetProgressBarColor(health);
1386 HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_health, x/maxtotal, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1389 if(autocvar_hud_panel_healtharmor_text)
1390 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);
1394 biggercount = "armor";
1395 if(autocvar_hud_panel_healtharmor_progressbar)
1397 HUD_Panel_GetProgressBarColor(armor);
1398 HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, x/maxtotal, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1401 if(autocvar_hud_panel_healtharmor_text)
1402 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);
1404 if(autocvar_hud_panel_healtharmor_text)
1405 DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, maxtotal), 1);
1409 HUD_Panel_GetProgressBarColor(fuel);
1410 HUD_Panel_DrawProgressBar(pos, eX * mySize_x + eY * 0.2 * mySize_y, "progressbar", fuel/100, 0, (baralign == 1 || baralign == 3), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
1415 float panel_ar = mySize_x/mySize_y;
1416 float is_vertical = (panel_ar < 1);
1417 vector health_offset, armor_offset;
1418 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1421 if (autocvar_hud_panel_healtharmor_flip)
1422 health_offset_x = mySize_x;
1424 armor_offset_x = mySize_x;
1429 if (autocvar_hud_panel_healtharmor_flip)
1430 health_offset_y = mySize_y;
1432 armor_offset_y = mySize_y;
1435 float health_baralign, armor_baralign, fuel_baralign;
1436 float health_iconalign, armor_iconalign;
1437 if (autocvar_hud_panel_healtharmor_flip)
1439 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1440 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1441 fuel_baralign = health_baralign;
1442 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1443 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1447 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1448 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1449 fuel_baralign = armor_baralign;
1450 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1451 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1456 if(autocvar_hud_panel_healtharmor_progressbar)
1458 HUD_Panel_GetProgressBarColor(health);
1461 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1463 if (saved_health == -1)
1465 if (prev_health == 0 || prev_health - health >= 3)
1468 saved_health = prev_health;
1471 if (saved_health != -1)
1473 float d = time - health_time;
1476 if (saved_health == -2)
1477 p_health *= sqrt(d);
1480 HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, saved_health/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * (1 - d * d), DRAWFLAG_NORMAL);
1481 if (prev_health - health >= 1) //refresh the effect if repeatedly damaged
1486 saved_health = -1; //damage effect ended
1488 prev_health = health;
1490 HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, p_health/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1492 if(autocvar_hud_panel_healtharmor_text)
1493 DrawNumIcon(pos + health_offset, mySize, health, "health", is_vertical, health_iconalign, HUD_Get_Num_Color(health, maxhealth), 1);
1498 if(autocvar_hud_panel_healtharmor_progressbar)
1500 HUD_Panel_GetProgressBarColor(armor);
1503 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1505 if (saved_armor == -1)
1507 if (prev_armor == 0 || prev_armor - armor >= 3)
1510 saved_armor = prev_armor;
1513 if (saved_armor != -1)
1515 float d = time - armor_time;
1518 if (saved_armor == -2)
1522 HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, saved_armor/maxarmor, is_vertical, armor_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * (1 - d * d), DRAWFLAG_NORMAL);
1523 if (prev_armor - armor >= 1) //refresh the effect if repeatedly damaged
1528 saved_armor = -1; //damage effect ended
1532 HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, p_armor/maxarmor, is_vertical, armor_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1534 if(autocvar_hud_panel_healtharmor_text)
1535 DrawNumIcon(pos + armor_offset, mySize, armor, "armor", is_vertical, armor_iconalign, HUD_Get_Num_Color(armor, maxarmor), 1);
1541 mySize_x *= 0.2 / 2; //if vertical always halve x to not cover too much numbers with 3 digits
1545 mySize_x *= 2; //restore full panel size
1546 else if (panel_ar < 1/4)
1547 mySize_y *= 2; //restore full panel size
1548 HUD_Panel_GetProgressBarColor(fuel);
1549 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
1554 // Notification area (#4)
1557 string Weapon_SuicideMessage(float deathtype)
1559 w_deathtype = deathtype;
1560 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
1561 return w_deathtypestring;
1564 string Weapon_KillMessage(float deathtype)
1566 w_deathtype = deathtype;
1567 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
1568 return w_deathtypestring;
1571 #define KN_MAX_ENTRIES 10
1573 float killnotify_times[KN_MAX_ENTRIES];
1574 float killnotify_deathtype[KN_MAX_ENTRIES];
1575 float killnotify_actiontype[KN_MAX_ENTRIES]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
1576 string killnotify_attackers[KN_MAX_ENTRIES];
1577 string killnotify_victims[KN_MAX_ENTRIES];
1578 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
1582 kn_index = KN_MAX_ENTRIES-1;
1583 killnotify_times[kn_index] = time;
1584 killnotify_deathtype[kn_index] = wpn;
1585 killnotify_actiontype[kn_index] = actiontype;
1586 if(killnotify_attackers[kn_index])
1587 strunzone(killnotify_attackers[kn_index]);
1588 killnotify_attackers[kn_index] = strzone(attacker);
1589 if(killnotify_victims[kn_index])
1590 strunzone(killnotify_victims[kn_index]);
1591 killnotify_victims[kn_index] = strzone(victim);
1594 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
1597 float alsoprint, gentle;
1598 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
1599 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
1601 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
1604 if(msg == MSG_SUICIDE) {
1605 w = DEATH_WEAPONOF(type);
1607 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1609 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
1610 } else if (type == DEATH_KILL) {
1611 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
1613 print ("^1",s1, "^1 couldn't take it anymore\n");
1614 } else if (type == DEATH_ROT) {
1615 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1617 print ("^1",s1, "^1 died\n");
1618 } else if (type == DEATH_NOAMMO) {
1619 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
1621 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
1622 } else if (type == DEATH_CAMP) {
1623 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
1625 print ("^1",s1, "^1 thought they found a nice camping ground\n");
1626 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
1627 HUD_KillNotify_Push(s1, "", 0, type);
1629 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
1630 } else if (type == DEATH_CHEAT) {
1631 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1633 print ("^1",s1, "^1 unfairly eliminated themself\n");
1634 } else if (type == DEATH_FIRE) {
1635 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1637 print ("^1",s1, "^1 burned to death\n");
1638 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
1639 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1641 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
1644 if (stof(s2) > 2) // killcount > 2
1645 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
1646 } else if(msg == MSG_KILL) {
1647 w = DEATH_WEAPONOF(type);
1649 if((w == WEP_SNIPERRIFLE || w == WEP_MINSTANEX) && type & HITTYPE_HEADSHOT) // all headshot weapons go here
1650 HUD_KillNotify_Push(s1, s2, 1, DEATH_HEADSHOT);
1652 HUD_KillNotify_Push(s1, s2, 1, type);
1655 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
1657 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
1658 HUD_KillNotify_Push(s1, s2, 1, type);
1662 print ("^1", s1, "^1 took action against a team mate\n");
1664 print ("^1", s1, "^1 mows down a team mate\n");
1667 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
1669 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
1671 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
1673 else if (stof(s2) > 2) {
1675 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
1677 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
1680 else if(type == KILL_FIRST_BLOOD)
1681 print("^1",s1, "^1 drew first blood", "\n");
1682 else if (type == DEATH_TELEFRAG) {
1683 HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
1685 print ("^1",s2, "^1 tried to occupy ", s1, "^1's teleport destination space\n");
1687 print ("^1",s2, "^1 was telefragged by ", s1, "\n");
1689 else if (type == DEATH_DROWN) {
1690 HUD_KillNotify_Push(s1, s2, 1, DEATH_DROWN);
1692 print ("^1",s2, "^1 was drowned by ", s1, "\n");
1694 else if (type == DEATH_SLIME) {
1695 HUD_KillNotify_Push(s1, s2, 1, DEATH_SLIME);
1697 print ("^1",s2, "^1 was slimed by ", s1, "\n");
1699 else if (type == DEATH_LAVA) {
1700 HUD_KillNotify_Push(s1, s2, 1, DEATH_LAVA);
1702 print ("^1",s2, "^1 was cooked by ", s1, "\n");
1704 else if (type == DEATH_FALL) {
1705 HUD_KillNotify_Push(s1, s2, 1, DEATH_FALL);
1707 print ("^1",s2, "^1 was grounded by ", s1, "\n");
1709 else if (type == DEATH_SHOOTING_STAR) {
1710 HUD_KillNotify_Push(s1, s2, 1, DEATH_SHOOTING_STAR);
1712 print ("^1",s2, "^1 was shot into space by ", s1, "\n");
1714 else if (type == DEATH_SWAMP) {
1715 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1717 print ("^1",s2, "^1 was conserved by ", s1, "\n");
1719 else if (type == DEATH_HURTTRIGGER)
1721 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1723 print("^1",s2, "^1 was thrown into a world of hurt by ", s1, "\n");
1724 } else if(type == DEATH_SBCRUSH) {
1725 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1727 print ("^1",s2, "^1 was crushed by ^1", s1, "\n");
1728 } else if(type == DEATH_SBMINIGUN) {
1729 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1731 print ("^1",s2, "^1 got shredded by ^1", s1, "\n");
1732 } else if(type == DEATH_SBROCKET) {
1733 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1735 print ("^1",s2, "^1 was blased to bits by ^1", s1, "\n");
1736 } else if(type == DEATH_SBBLOWUP) {
1737 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1739 print ("^1",s2, "^1 got caught in the destruction of ^1", s1, "'s vehicle\n");
1740 } else if(type == DEATH_WAKIGUN) {
1741 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1743 print ("^1",s2, "^1 was bolted down by ^1", s1, "\n");
1744 } else if(type == DEATH_WAKIROCKET) {
1745 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1747 print ("^1",s2, "^1 could find no shelter from ^1", s1, "'s rockets\n");
1748 } else if(type == DEATH_WAKIBLOWUP) {
1749 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1751 print ("^1",s2, "^1 dies when ^1", s1, "'s wakizashi dies.\n");
1752 } else if(type == DEATH_TURRET) {
1753 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1755 print ("^1",s2, "^1 was pushed into the line of fire by ^1", s1, "\n");
1756 } else if(type == DEATH_TOUCHEXPLODE) {
1757 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1759 print ("^1",s2, "^1 was pushed into an accident by ^1", s1, "\n");
1760 } else if(type == DEATH_CHEAT) {
1761 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1763 print ("^1",s2, "^1 was unfairly eliminated by ^1", s1, "\n");
1764 } else if (type == DEATH_FIRE) {
1765 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1767 print ("^1",s2, "^1 was burnt to death by ^1", s1, "\n");
1768 } else if (type == DEATH_CUSTOM) {
1769 HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM);
1771 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1772 } else if (type == DEATH_HURTTRIGGER) {
1773 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1775 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1777 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1779 print ("^1",s2, "^1 was fragged by ", s1, "\n");
1781 } else if(msg == MSG_SPREE) {
1782 if(type == KILL_END_SPREE) {
1784 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
1786 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
1787 } else if(type == KILL_SPREE) {
1789 print ("^1",s1,"^1 made ",s2," scores in a row\n");
1791 print ("^1",s1,"^1 has ",s2," frags in a row\n");
1792 } else if(type == KILL_SPREE_3) {
1794 print (s1,"^7 made a ^1TRIPLE SCORE\n");
1796 print (s1,"^7 made a ^1TRIPLE FRAG\n");
1797 } else if(type == KILL_SPREE_5) {
1799 print (s1,"^7 unleashes ^1SCORING RAGE\n");
1801 print (s1,"^7 unleashes ^1RAGE\n");
1802 } else if(type == KILL_SPREE_10) {
1804 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
1806 print (s1,"^7 starts the ^1MASSACRE!\n");
1807 } else if(type == KILL_SPREE_15) {
1809 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
1811 print (s1,"^7 executes ^1MAYHEM!\n");
1812 } else if(type == KILL_SPREE_20) {
1814 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
1816 print (s1,"^7 is a ^1BERSERKER!\n");
1817 } else if(type == KILL_SPREE_25) {
1819 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
1821 print (s1,"^7 inflicts ^1CARNAGE!\n");
1822 } else if(type == KILL_SPREE_30) {
1824 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
1826 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
1828 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
1829 if (type == DEATH_DROWN) {
1830 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
1834 print ("^1",s1, "^1 was in the water for too long\n");
1836 print ("^1",s1, "^1 drowned\n");
1838 } else if (type == DEATH_SLIME) {
1839 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
1841 print ("^1",s1, "^1 was slimed\n");
1842 } else if (type == DEATH_LAVA) {
1843 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
1847 print ("^1",s1, "^1 found a hot place\n");
1849 print ("^1",s1, "^1 turned into hot slag\n");
1851 } else if (type == DEATH_FALL) {
1852 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1856 print ("^1",s1, "^1 tested gravity (and it worked)\n");
1858 print ("^1",s1, "^1 hit the ground with a crunch\n");
1860 } else if (type == DEATH_SHOOTING_STAR) {
1861 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
1863 print ("^1",s1, "^1 became a shooting star\n");
1864 } else if (type == DEATH_SWAMP) {
1865 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1869 print ("^1",s1, "^1 discovered a swamp\n");
1871 print ("^1",s1, "^1 is now conserved for centuries to come\n");
1873 } else if(type == DEATH_TURRET) {
1874 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1876 print ("^1",s1, "^1 was mowed down by a turret \n");
1877 } else if (type == DEATH_CUSTOM) {
1878 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
1880 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1881 } else if (type == DEATH_HURTTRIGGER) {
1882 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
1884 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1885 } else if(type == DEATH_TOUCHEXPLODE) {
1886 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1888 print ("^1",s1, "^1 died in an accident\n");
1889 } else if(type == DEATH_CHEAT) {
1890 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1892 print ("^1",s1, "^1 was unfairly eliminated\n");
1893 } else if(type == DEATH_FIRE) {
1894 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1898 print ("^1",s1, "^1 felt a little hot\n");
1900 print ("^1",s1, "^1 burnt to death\n");
1903 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1907 print ("^1",s1, "^1 needs a restart\n");
1909 print ("^1",s1, "^1 died\n");
1912 } else if(msg == MSG_KILL_ACTION_SPREE) {
1914 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
1916 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
1917 } else if(msg == MSG_INFO) {
1918 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
1919 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
1920 print(s1, "^7 got the ", s2, "\n");
1921 } else if(type == INFO_LOSTFLAG) {
1922 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
1923 print(s1, "^7 lost the ", s2, "\n");
1924 } else if(type == INFO_PICKUPFLAG) {
1925 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
1926 print(s1, "^7 picked up the ", s2, "\n");
1927 } else if(type == INFO_RETURNFLAG) {
1928 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
1929 print(s1, "^7 returned the ", s2, "\n");
1930 } else if(type == INFO_CAPTUREFLAG) {
1931 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
1932 print(s1, "^7 captured the ", s2, s3, "\n");
1934 } else if(msg == MSG_RACE) {
1935 if(type == RACE_SERVER_RECORD) {
1936 HUD_KillNotify_Push(s1, s2, 1, RACE_SERVER_RECORD);
1938 else if(type == RACE_NEW_RANK) {
1939 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_RANK);
1941 else if(type == RACE_NEW_TIME) {
1942 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_TIME);
1944 else if(type == RACE_FAIL) {
1945 HUD_KillNotify_Push(s1, s2, 1, RACE_FAIL);
1947 } else if(msg == MSG_KA) {
1948 if(type == KA_PICKUPBALL) {
1949 HUD_KillNotify_Push(s1, s2, 0, KA_PICKUPBALL);
1951 print (s1, "^7 has picked up the ball!\n");
1953 else if(type == KA_DROPBALL) {
1954 HUD_KillNotify_Push(s1, s2, 0, KA_DROPBALL);
1956 print(s1, "^7 has dropped the ball!\n");
1961 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
1963 void HUD_Centerprint(string s1, string s2, float type, float msg)
1966 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
1967 if(msg == MSG_SUICIDE) {
1968 if (type == DEATH_TEAMCHANGE) {
1969 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
1970 } else if (type == DEATH_AUTOTEAMCHANGE) {
1971 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
1972 } else if (type == DEATH_CAMP) {
1974 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
1976 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
1977 } else if (type == DEATH_NOAMMO) {
1979 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
1981 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
1982 } else if (type == DEATH_ROT) {
1984 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
1986 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
1987 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
1989 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
1991 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
1992 } else if (type == DEATH_QUIET) {
1994 } else { // generic message
1996 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
1998 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2000 } else if(msg == MSG_KILL) {
2001 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2003 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2005 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2007 } else if (type == KILL_FIRST_BLOOD) {
2009 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2011 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2013 } else if (type == KILL_FIRST_VICTIM) {
2015 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2017 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2019 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2021 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2023 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2025 } else if (type == KILL_TYPEFRAGGED) {
2027 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2029 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2031 } else if (type == KILL_FRAG) {
2033 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2035 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2037 } else { // generic message
2039 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2041 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2044 } else if(msg == MSG_KILL_ACTION) {
2045 // TODO: invent more centerprints here?
2046 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2050 void HUD_Notify (void)
2052 if(!autocvar__hud_configure)
2054 if(!autocvar_hud_panel_notify) return;
2057 hud_configure_active_panel = HUD_PANEL_NOTIFY;
2059 HUD_Panel_UpdateCvars(notify);
2062 mySize = panel_size;
2064 HUD_Panel_DrawBg(1);
2065 if(panel_bg_padding)
2067 pos += '1 1 0' * panel_bg_padding;
2068 mySize -= '2 2 0' * panel_bg_padding;
2071 float entries, height;
2072 entries = bound(1, floor(KN_MAX_ENTRIES * mySize_y/mySize_x), KN_MAX_ENTRIES);
2073 height = mySize_y/entries;
2076 fontsize = '0.5 0.5 0' * height;
2080 when = autocvar_hud_panel_notify_time;
2082 fadetime = autocvar_hud_panel_notify_fadetime;
2086 vector pos_attacker, pos_victim;
2088 float width_attacker;
2089 string attacker, victim;
2091 float i, j, w, step, limit;
2092 if(autocvar_hud_panel_notify_flip) //order items from the top down
2098 else //order items from the bottom up
2105 for(j = kn_index; i != limit; i += step, ++j)
2107 if(autocvar__hud_configure)
2111 else // inverse order
2112 a = entries - 1 - i;
2113 attacker = textShortenToWidth(strcat("Player", ftos(a+1)), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2114 victim = textShortenToWidth(strcat("Player", ftos(a+2)), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2115 s = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname);
2116 a = bound(0, (when - a) / 4, 1);
2117 goto hud_config_notifyprint;
2120 if (j == KN_MAX_ENTRIES)
2123 if(killnotify_times[j] + when > time)
2127 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2141 w = DEATH_WEAPONOF(killnotify_deathtype[j]);
2143 // TODO: maybe print in team colors?
2146 if(killnotify_actiontype[j] == 0)
2148 if(killnotify_deathtype[j] == DEATH_GENERIC)
2152 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2154 s = "notify_outofammo";
2156 else if(killnotify_deathtype[j] == DEATH_KILL)
2158 s = "notify_selfkill";
2160 else if(killnotify_deathtype[j] == DEATH_CAMP)
2162 s = "notify_camping";
2164 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2166 s = "notify_teamkill_red";
2168 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2170 s = "notify_teamkill_blue";
2172 else if(killnotify_deathtype[j] == DEATH_DROWN)
2176 else if(killnotify_deathtype[j] == DEATH_SLIME)
2180 else if(killnotify_deathtype[j] == DEATH_LAVA)
2184 else if(killnotify_deathtype[j] == DEATH_FALL)
2188 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2190 s = "notify_shootingstar";
2192 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2196 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2198 if(killnotify_victims[j] == "^1RED^7 flag")
2200 s = "notify_red_taken";
2204 s = "notify_blue_taken";
2207 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2209 if(killnotify_victims[j] == "^1RED^7 flag")
2211 s = "notify_red_returned";
2215 s = "notify_blue_returned";
2218 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2220 if(killnotify_victims[j] == "^1RED^7 flag")
2222 s = "notify_red_lost";
2226 s = "notify_blue_lost";
2229 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
2231 if(killnotify_victims[j] == "^1RED^7 flag")
2233 s = "notify_red_captured";
2237 s = "notify_blue_captured";
2240 else if(killnotify_deathtype[j] == KA_DROPBALL)
2242 s = "notify_balldropped";
2244 else if(killnotify_deathtype[j] == KA_PICKUPBALL)
2246 s = "notify_ballpickedup";
2249 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2250 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
2251 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2255 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2256 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2259 // X [did action to] Y
2262 if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
2264 s = "notify_melee_laser";
2266 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_SHOTGUN)
2268 s = "notify_melee_shotgun";
2270 else if(WEP_VALID(w))
2272 self = get_weaponinfo(w);
2273 s = strcat("weapon", self.netname);
2275 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2277 s = "notify_teamkill_red";
2279 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2281 s = "notify_teamkill_red";
2283 else if(killnotify_deathtype[j] == DEATH_TELEFRAG)
2285 s = "notify_telefrag";
2287 else if(killnotify_deathtype[j] == DEATH_DROWN)
2291 else if(killnotify_deathtype[j] == DEATH_SLIME)
2295 else if(killnotify_deathtype[j] == DEATH_LAVA)
2299 else if(killnotify_deathtype[j] == DEATH_FALL)
2303 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2305 s = "notify_shootingstar";
2307 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2311 else if(killnotify_deathtype[j] == DEATH_HEADSHOT)
2313 s = "notify_headshot";
2315 else if(killnotify_deathtype[j] == RACE_SERVER_RECORD)
2317 s = "race_newrecordserver";
2319 else if(killnotify_deathtype[j] == RACE_NEW_RANK)
2321 s = "race_newrankyellow";
2323 else if(killnotify_deathtype[j] == RACE_NEW_TIME)
2327 else if(killnotify_deathtype[j] == RACE_FAIL)
2332 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2333 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2334 :hud_config_notifyprint
2335 width_attacker = stringwidth(attacker, TRUE, fontsize);
2336 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
2337 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
2338 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2342 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2343 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2344 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2353 string seconds_tostring(float sec)
2356 minutes = floor(sec / 60);
2358 sec -= minutes * 60;
2361 s = ftos(100 + sec);
2363 return strcat(ftos(minutes), ":", substring(s, 1, 3));
2366 void HUD_Timer(void)
2368 if(!autocvar__hud_configure)
2370 if(!autocvar_hud_panel_timer) return;
2373 hud_configure_active_panel = HUD_PANEL_TIMER;
2375 HUD_Panel_UpdateCvars(timer);
2378 mySize = panel_size;
2380 HUD_Panel_DrawBg(1);
2381 if(panel_bg_padding)
2383 pos += '1 1 0' * panel_bg_padding;
2384 mySize -= '2 2 0' * panel_bg_padding;
2388 float timelimit, elapsedTime, timeleft, minutesLeft;
2390 timelimit = getstatf(STAT_TIMELIMIT);
2392 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
2393 timeleft = ceil(timeleft);
2395 minutesLeft = floor(timeleft / 60);
2398 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
2399 timer_color = '1 1 1'; //white
2400 else if(minutesLeft >= 1)
2401 timer_color = '1 1 0'; //yellow
2403 timer_color = '1 0 0'; //red
2405 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
2406 if (time < getstatf(STAT_GAMESTARTTIME)) {
2407 //while restart is still active, show 00:00
2408 timer = seconds_tostring(0);
2410 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
2411 timer = seconds_tostring(elapsedTime);
2414 timer = seconds_tostring(timeleft);
2417 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2422 void HUD_Radar(void)
2424 if (!autocvar__hud_configure)
2426 if (autocvar_hud_panel_radar == 0) return;
2427 if (autocvar_hud_panel_radar != 2 && !teamplay) return;
2430 hud_configure_active_panel = HUD_PANEL_RADAR;
2432 HUD_Panel_UpdateCvars(radar);
2435 mySize = panel_size;
2437 HUD_Panel_DrawBg(1);
2438 if(panel_bg_padding)
2440 pos += '1 1 0' * panel_bg_padding;
2441 mySize -= '2 2 0' * panel_bg_padding;
2446 float scale2d, normalsize, bigsize;
2449 teamradar_origin2d = pos + 0.5 * mySize;
2450 teamradar_size2d = mySize;
2452 if(minimapname == "")
2455 teamradar_loadcvars();
2457 switch(hud_panel_radar_zoommode)
2461 f = current_zoomfraction;
2464 f = 1 - current_zoomfraction;
2474 switch(hud_panel_radar_rotation)
2477 teamradar_angle = view_angles_y - 90;
2480 teamradar_angle = 90 * hud_panel_radar_rotation;
2484 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
2485 teamradar_size2d = mySize;
2487 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
2489 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
2490 if(hud_panel_radar_rotation == 0)
2492 // max-min distance must fit the radar in any rotation
2493 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_scale));
2497 vector c0, c1, c2, c3, span;
2498 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
2499 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
2500 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
2501 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
2503 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
2504 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
2506 // max-min distance must fit the radar in x=x, y=y
2508 teamradar_size2d_x * scale2d / (1.05 * span_x),
2509 teamradar_size2d_y * scale2d / (1.05 * span_y)
2513 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
2514 if(bigsize > normalsize)
2515 normalsize = bigsize;
2519 + (1 - f) * normalsize;
2520 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
2522 + (1 - f) * view_origin);
2531 draw_teamradar_background(hud_panel_radar_foreground_alpha);
2533 for(tm = world; (tm = find(tm, classname, "radarlink")); )
2534 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
2535 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
2536 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
2537 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
2539 color2 = GetPlayerColor(tm.sv_entnum);
2540 //if(color == COLOR_SPECTATOR || color == color2)
2541 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
2543 draw_teamradar_player(view_origin, view_angles, '1 1 1');
2545 drawresetcliparea();
2550 void HUD_UpdatePlayerTeams();
2551 void HUD_Score(void)
2553 if(!autocvar__hud_configure)
2555 if(!autocvar_hud_panel_score) return;
2556 if(spectatee_status == -1 && (gametype == GAME_RACE || gametype == GAME_CTS)) return;
2559 hud_configure_active_panel = HUD_PANEL_SCORE;
2561 HUD_Panel_UpdateCvars(score);
2564 mySize = panel_size;
2566 HUD_Panel_DrawBg(1);
2567 if(panel_bg_padding)
2569 pos += '1 1 0' * panel_bg_padding;
2570 mySize -= '2 2 0' * panel_bg_padding;
2573 float score, distribution;
2575 vector distribution_color;
2577 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
2579 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
2580 string timer, distrtimer;
2582 pl = players.sort_next;
2585 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
2586 if(pl.scores[ps_primary] == 0)
2589 score = me.(scores[ps_primary]);
2590 timer = TIME_ENCODED_TOSTRING(score);
2592 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
2593 // distribution display
2594 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2596 distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS);
2598 if (distribution <= 0) {
2599 distribution_color = '0 1 0';
2603 distribution_color = '1 0 0';
2606 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);
2608 // race record display
2609 if (distribution <= 0)
2610 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2611 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2612 } else if (!teamplay) { // non-teamgames
2613 if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings)
2615 #define SCOREPANEL_MAX_ENTRIES 6
2616 #define SCOREPANEL_ASPECTRATIO 2
2617 const float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
2618 const float height = mySize_y/entries;
2619 const vector fontsize = '0.9 0.9 0' * height;
2620 pos_y += height * (1 - 0.9) / 2;
2625 const float name_size = mySize_x*0.75;
2626 const float highlight_alpha = 0.2;
2627 float i, me_printed;
2629 if (autocvar__hud_configure)
2631 score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
2632 for (i=0; i<entries; ++i)
2634 //simulate my score is lower than all displayed players,
2635 //so that I don't appear at all showing pure rankings.
2636 //This is to better show the difference between the 2 ranking views
2637 if (i == entries-1 && autocvar_hud_panel_score_rankings == 1)
2640 drawfill(pos - eY * (height * (1 - 0.9) / 2), eX * mySize_x + eY * height, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2641 s = GetPlayerName(pl.sv_entnum);
2646 s = strcat("Player", ftos(i+1));
2650 s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
2651 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2652 drawstring(pos + eX * mySize_x*0.79, ftos(score), fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2658 if (!scoreboard_fade_alpha) // the scoreboard too calls HUD_UpdatePlayerTeams
2659 HUD_UpdatePlayerTeams();
2661 for (pl = players.sort_next, i=0; pl && i<entries; pl = pl.sort_next, ++i)
2663 if (pl.team == COLOR_SPECTATOR)
2666 if (i == entries-1 && !me_printed && pl != me)
2667 if (autocvar_hud_panel_score_rankings == 1 && spectatee_status != -1)
2669 for (pl = me.sort_next; pl; pl = pl.sort_next)
2670 if (pl.team != COLOR_SPECTATOR)
2674 rgb = '1 1 0'; //not last but not among the leading players: yellow
2676 rgb = '1 0 0'; //last: red
2683 rgb = '0 1 0'; //first: green
2685 drawfill(pos - eY * (height * (1 - 0.9) / 2), eX * mySize_x + eY * height, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2687 s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
2688 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2689 drawstring(pos + eX * mySize_x*0.79, ftos(pl.(scores[ps_primary])), fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2694 // me vector := [team/connected frags id]
2695 pl = players.sort_next;
2699 if(autocvar__hud_configure)
2702 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2706 score = me.(scores[ps_primary]);
2707 if(autocvar__hud_configure)
2710 if(distribution >= 5)
2711 distribution_color = eY;
2712 else if(distribution >= 0)
2713 distribution_color = '1 1 1';
2714 else if(distribution >= -5)
2715 distribution_color = '1 1 0';
2717 distribution_color = eX;
2719 string distribution_str;
2720 distribution_str = ftos(distribution);
2721 if (distribution >= 0)
2723 if (distribution > 0)
2724 distribution_str = strcat("+", distribution_str);
2725 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2727 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2728 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);
2729 } else { // teamgames
2730 float max_fragcount;
2731 max_fragcount = -99;
2733 float scores_count, row, column, rows, columns;
2735 vector score_pos, score_size; //for scores other than myteam
2736 if (spectatee_status == -1)
2738 if (autocvar__hud_configure)
2740 else for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2741 if(tm.team == COLOR_SPECTATOR)
2745 rows = mySize_y/mySize_x;
2746 rows = bound(1, floor((sqrt(4 * (3/1) * rows * scores_count + rows * rows) + rows + 0.5) / 2), scores_count);
2747 // ^^^ ammo item aspect goes here
2749 columns = ceil(scores_count/rows);
2751 score_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
2754 if(score_size_x/score_size_y > 3)
2756 newSize = 3 * score_size_y;
2757 offset_x = score_size_x - newSize;
2758 pos_x += offset_x/2;
2759 score_size_x = newSize;
2763 newSize = 1/3 * score_size_x;
2764 offset_y = score_size_y - newSize;
2765 pos_y += offset_y/2;
2766 score_size_y = newSize;
2770 score_size = eX * mySize_x*(1/4) + eY * mySize_y*(1/3);
2771 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2772 if(tm.team == COLOR_SPECTATOR)
2774 score = tm.(teamscores[ts_primary]);
2775 if(autocvar__hud_configure)
2778 if (score > max_fragcount)
2779 max_fragcount = score;
2781 if (spectatee_status == -1)
2783 score_pos = pos + eX * column * (score_size_x + offset_x) + eY * row * (score_size_y + offset_y);
2784 if (max_fragcount == score)
2785 HUD_Panel_DrawHighlight(score_pos, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2786 drawstring_aspect(score_pos, ftos(score), score_size, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2794 else if(tm.team == myteam) {
2795 if (max_fragcount == score)
2796 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2797 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2799 if (max_fragcount == score)
2800 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);
2801 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);
2810 void HUD_RaceTimer (void)
2812 if(!autocvar__hud_configure)
2814 if(!autocvar_hud_panel_racetimer) return;
2815 if(!(gametype == GAME_RACE || gametype == GAME_CTS)) return;
2816 if(spectatee_status == -1) return;
2819 hud_configure_active_panel = HUD_PANEL_RACETIMER;
2821 HUD_Panel_UpdateCvars(racetimer);
2824 mySize = panel_size;
2826 HUD_Panel_DrawBg(1);
2827 if(panel_bg_padding)
2829 pos += '1 1 0' * panel_bg_padding;
2830 mySize -= '2 2 0' * panel_bg_padding;
2833 // always force 4:1 aspect
2835 if(mySize_x/mySize_y > 4)
2837 newSize_x = 4 * mySize_y;
2838 newSize_y = mySize_y;
2840 pos_x = pos_x + (mySize_x - newSize_x) / 2;
2844 newSize_y = 1/4 * mySize_x;
2845 newSize_x = mySize_x;
2847 pos_y = pos_y + (mySize_y - newSize_y) / 2;
2852 string s, forcetime;
2854 if(autocvar__hud_configure)
2857 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);
2858 s = "^1Intermediate 1 (+15.42)";
2859 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);
2860 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
2861 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);
2863 else if(race_checkpointtime)
2865 a = bound(0, 2 - (time - race_checkpointtime), 1);
2868 if(a > 0) // just hit a checkpoint?
2870 if(race_checkpoint != 254)
2872 if(race_time && race_previousbesttime)
2873 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
2875 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
2877 forcetime = TIME_ENCODED_TOSTRING(race_time);
2882 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
2884 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
2885 if(a > 0) // next one?
2887 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
2892 if(s != "" && a > 0)
2894 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);
2897 if(race_penaltytime)
2899 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
2902 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
2903 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);
2909 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
2910 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);
2915 if(race_laptime && race_checkpoint != 255)
2917 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
2918 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);
2923 if(race_mycheckpointtime)
2925 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
2926 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
2927 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);
2929 if(race_othercheckpointtime && race_othercheckpointenemy != "")
2931 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
2932 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
2933 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);
2936 if(race_penaltytime && !race_penaltyaccumulator)
2938 t = race_penaltytime * 0.1 + race_penaltyeventtime;
2939 a = bound(0, (1 + t - time), 1);
2943 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
2945 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
2946 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);
2954 float vote_yescount;
2957 float vote_highlighted; // currently selected vote
2959 float vote_active; // is there an active vote?
2960 float vote_prev; // previous state of vote_active to check for a change
2962 float vote_change; // "time" when vote_active changed
2964 void HUD_VoteWindow(void)
2966 if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
2969 if (autocvar__hud_configure)
2973 print("^1You have to answer before entering hud configure mode\n");
2974 cvar_set("_hud_configure", "0");
2976 vote_called_vote = strzone("^2Name ^7instead of \"^1Unregistered player^7\" in stats");
2977 uid2name_dialog = 1;
2980 if(!autocvar__hud_configure)
2982 if(!autocvar_hud_panel_vote) return;
2984 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
2985 panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha;
2987 if(panel_bg_alpha_str == "") {
2988 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
2990 panel_bg_alpha = stof(panel_bg_alpha_str);
2994 hud_configure_active_panel = HUD_PANEL_VOTE;
3003 if(vote_active != vote_prev) {
3005 vote_prev = vote_active;
3008 if(vote_active || autocvar__hud_configure)
3009 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3011 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3016 HUD_Panel_UpdateCvars(vote);
3020 panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight;
3021 panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight;
3024 // these must be below above block
3027 mySize = panel_size;
3029 a = vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3030 HUD_Panel_DrawBg(a);
3031 a = panel_fg_alpha * a;
3033 if(panel_bg_padding)
3035 pos += '1 1 0' * panel_bg_padding;
3036 mySize -= '2 2 0' * panel_bg_padding;
3039 // always force 3:1 aspect
3041 if(mySize_x/mySize_y > 3)
3043 newSize_x = 3 * mySize_y;
3044 newSize_y = mySize_y;
3046 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3050 newSize_y = 1/3 * mySize_x;
3051 newSize_x = mySize_x;
3053 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3057 s = "A vote has been called for:";
3059 s = "Allow servers to store and display your name?";
3060 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3061 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1/8), stringwidth_colors);
3062 if(autocvar__hud_configure)
3063 s = "^1Configure the HUD";
3064 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
3066 // print the yes/no counts
3067 s = strcat("Yes (", getcommandkey("vyes", "vyes"), "): ", ftos(vote_yescount));
3068 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);
3069 s = strcat("No (", getcommandkey("vno", "vno"), "): ", ftos(vote_nocount));
3070 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);
3072 // draw the progress bar backgrounds
3073 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3075 // draw the highlights
3076 if(vote_highlighted == 1) {
3077 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3078 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3080 else if(vote_highlighted == 2) {
3081 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3082 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3085 // draw the progress bars
3086 if(vote_yescount && vote_needed)
3088 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3089 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3092 if(vote_nocount && vote_needed)
3094 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3095 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3098 drawresetcliparea();
3101 vote_highlighted = 0;
3105 // Mod icons panel (#10)
3108 float mod_active; // is there any active mod icon?
3110 // Clan Arena HUD modicons
3111 void HUD_Mod_CA(vector pos, vector mySize)
3113 mod_active = 1; // CA should never hide the mod icons panel
3114 float redalive, bluealive;
3115 redalive = getstati(STAT_REDALIVE);
3116 bluealive = getstati(STAT_BLUEALIVE);
3118 vector redpos, bluepos;
3119 if(mySize_x > mySize_y)
3122 bluepos = pos + eY * 0.5 * mySize_y;
3123 drawpic_aspect_skin(redpos, "player_red.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3124 drawstring_aspect(redpos + eX * 0.5 * mySize_x, ftos(redalive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3125 drawpic_aspect_skin(bluepos, "player_blue.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3126 drawstring_aspect(bluepos + eX * 0.5 * mySize_x, ftos(bluealive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3131 bluepos = pos + eY * 0.5 * mySize_y;
3132 drawpic_aspect_skin(redpos, "player_red.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3133 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);
3134 drawpic_aspect_skin(bluepos, "player_blue.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3135 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);
3139 // CTF HUD modicon section
3140 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3141 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3142 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3144 void HUD_Mod_CTF_Reset(void)
3146 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3149 void HUD_Mod_CTF(vector pos, vector mySize)
3151 vector redflag_pos, blueflag_pos;
3153 float f; // every function should have that
3155 float redflag, blueflag; // current status
3156 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3159 stat_items = getstati(STAT_ITEMS);
3160 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3161 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3163 if(redflag || blueflag)
3168 if(autocvar__hud_configure)
3174 // when status CHANGES, set old status into prevstatus and current status into status
3175 if (redflag != redflag_prevframe)
3177 redflag_statuschange_time = time;
3178 redflag_prevstatus = redflag_prevframe;
3179 redflag_prevframe = redflag;
3182 if (blueflag != blueflag_prevframe)
3184 blueflag_statuschange_time = time;
3185 blueflag_prevstatus = blueflag_prevframe;
3186 blueflag_prevframe = blueflag;
3189 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3190 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3192 float BLINK_FACTOR = 0.15;
3193 float BLINK_BASE = 0.85;
3195 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3197 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3199 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3201 string red_icon, red_icon_prevstatus;
3202 float red_alpha, red_alpha_prevstatus;
3203 red_alpha = red_alpha_prevstatus = 1;
3205 case 1: red_icon = "flag_red_taken"; break;
3206 case 2: red_icon = "flag_red_lost"; break;
3207 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3209 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3210 red_icon = "flag_red_shielded";
3212 red_icon = string_null;
3215 switch(redflag_prevstatus) {
3216 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3217 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3218 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3221 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3222 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3223 red_icon_prevstatus = "flag_red_shielded";
3225 red_icon_prevstatus = string_null;
3229 string blue_icon, blue_icon_prevstatus;
3230 float blue_alpha, blue_alpha_prevstatus;
3231 blue_alpha = blue_alpha_prevstatus = 1;
3233 case 1: blue_icon = "flag_blue_taken"; break;
3234 case 2: blue_icon = "flag_blue_lost"; break;
3235 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3237 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3238 blue_icon = "flag_blue_shielded";
3240 blue_icon = string_null;
3243 switch(blueflag_prevstatus) {
3244 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3245 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3246 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3249 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3250 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3251 blue_icon_prevstatus = "flag_blue_shielded";
3253 blue_icon_prevstatus = string_null;
3257 if(mySize_x > mySize_y) {
3258 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3260 blueflag_pos = pos + eX * 0.5 * mySize_x;
3263 redflag_pos = pos + eX * 0.5 * mySize_x;
3265 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3267 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3269 blueflag_pos = pos + eY * 0.5 * mySize_y;
3272 redflag_pos = pos + eY * 0.5 * mySize_y;
3274 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3277 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3278 if(red_icon_prevstatus && f < 1)
3279 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3281 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3283 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3284 if(blue_icon_prevstatus && f < 1)
3285 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3287 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3290 // Keyhunt HUD modicon section
3291 float kh_runheretime;
3293 void HUD_Mod_KH_Reset(void)
3298 void HUD_Mod_KH(vector pos, vector mySize)
3300 mod_active = 1; // keyhunt should never hide the mod icons panel
3304 vector p, pa, kh_size, kh_asize;
3306 kh_keys = getstati(STAT_KH_KEYS);
3309 if(mySize_x > mySize_y)
3311 p_y = pos_y + 0.25 * mySize_y;
3312 pa = p - eY * 0.25 * mySize_y;
3314 kh_size_x = mySize_x * 0.25;
3315 kh_size_y = 0.75 * mySize_y;
3316 kh_asize_x = mySize_x * 0.25;
3317 kh_asize_y = mySize_y * 0.25;
3321 p_y = pos_y + 0.125 * mySize_y;
3322 pa = p - eY * 0.125 * mySize_y;
3324 kh_size_x = mySize_x * 0.5;
3325 kh_size_y = 0.375 * mySize_y;
3326 kh_asize_x = mySize_x * 0.5;
3327 kh_asize_y = mySize_y * 0.125;
3334 for(i = 0; i < 4; ++i)
3336 key = floor(kh_keys / pow(32, i)) & 31;
3338 if(keyteam == 30 && keycount <= 4)
3340 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3344 // this yields 8 exactly if "RUN HERE" shows
3349 kh_runheretime = time;
3350 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3355 for(i = 0; i < 4; ++i)
3357 key = floor(kh_keys / pow(32, i)) & 31;
3370 default: // owned or dropped
3375 a = a * panel_fg_alpha;
3376 aa = aa * panel_fg_alpha;
3382 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3385 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3388 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3391 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3396 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3399 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3402 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3405 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3408 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3412 if(mySize_x > mySize_y)
3414 p_x += 0.25 * mySize_x;
3415 pa_x += 0.25 * mySize_x;
3421 p_y = pos_y + 0.625 * mySize_y;
3422 pa_y = pos_y + 0.5 * mySize_y;
3428 p_x += 0.5 * mySize_x;
3429 pa_x += 0.5 * mySize_x;
3435 // Keepaway HUD mod icon
3436 float kaball_prevstatus; // last remembered status
3437 float kaball_statuschange_time; // time when the status changed
3439 // we don't need to reset for keepaway since it immediately
3440 // autocorrects prevstatus as to if the player has the ball or not
3442 void HUD_Mod_Keepaway(vector pos, vector mySize)
3444 mod_active = 1; // keepaway should always show the mod HUD
3446 float BLINK_FACTOR = 0.15;
3447 float BLINK_BASE = 0.85;
3448 float BLINK_FREQ = 5;
3449 float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
3451 float stat_items = getstati(STAT_ITEMS);
3452 float kaball = (stat_items/IT_KEY1) & 1;
3454 if(kaball != kaball_prevstatus)
3456 kaball_statuschange_time = time;
3457 kaball_prevstatus = kaball;
3460 // todo: Fix the sizing with the expanding image
3462 float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
3463 float f = bound(0, kaball_statuschange_elapsedtime*2, 1);
3465 if(kaball_prevstatus && f < 1)
3466 drawpic_aspect_skin_expanding(pos + eY * 0.25 * mySize_y, "keepawayball_carrying", eX * mySize_x + eY * mySize_y * 0.5, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f);
3469 drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
3473 // Nexball HUD mod icon
3474 void HUD_Mod_NexBall(vector pos, vector mySize)
3476 float stat_items, nb_pb_starttime, dt, p;
3478 stat_items = getstati(STAT_ITEMS);
3479 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3481 if (stat_items & IT_KEY1)
3486 //Manage the progress bar if any
3487 if (nb_pb_starttime > 0)
3489 dt = mod(time - nb_pb_starttime, nb_pb_period);
3490 // one period of positive triangle
3491 p = 2 * dt / nb_pb_period;
3496 HUD_Panel_GetProgressBarColor(nexball);
3497 if(mySize_x > mySize_y)
3498 HUD_Panel_DrawProgressBar(pos, mySize, "statusbar", p, 0, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3500 HUD_Panel_DrawProgressBar(pos, mySize, "statusbar", p, 1, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3503 if (stat_items & IT_KEY1)
3504 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3507 // Race/CTS HUD mod icons
3508 float crecordtime_prev; // last remembered crecordtime
3509 float crecordtime_change_time; // time when crecordtime last changed
3510 float srecordtime_prev; // last remembered srecordtime
3511 float srecordtime_change_time; // time when srecordtime last changed
3513 float race_status_time;
3514 float race_status_prev;
3515 string race_status_name_prev;
3516 void HUD_Mod_Race(vector pos, vector mySize)
3518 mod_active = 1; // race should never hide the mod icons panel
3520 me = playerslots[player_localentnum - 1];
3522 float f; // yet another function has this
3523 score = me.(scores[ps_primary]);
3525 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3526 return; // no records in the actual race
3528 // clientside personal record
3530 if(gametype == GAME_CTS)
3534 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3536 if(score && (score < t || !t)) {
3537 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3538 if(autocvar_cl_autodemo_delete_keeprecords)
3540 f = autocvar_cl_autodemo_delete;
3542 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3546 if(t != crecordtime_prev) {
3547 crecordtime_prev = t;
3548 crecordtime_change_time = time;
3551 vector textPos, medalPos;
3553 if(mySize_x > mySize_y) {
3554 // text on left side
3555 squareSize = min(mySize_y, mySize_x/2);
3556 textPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eY * 0.5 * (mySize_y - squareSize);
3557 medalPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eX * 0.5 * mySize_x + eY * 0.5 * (mySize_y - squareSize);
3560 squareSize = min(mySize_x, mySize_y/2);
3561 textPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eX * 0.5 * (mySize_x - squareSize);
3562 medalPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eY * 0.5 * mySize_y + eX * 0.5 * (mySize_x - squareSize);
3565 f = time - crecordtime_change_time;
3568 drawstring_aspect(textPos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3569 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);
3571 drawstring_aspect(textPos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3572 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);
3573 drawstring_aspect_expanding(pos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
3574 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);
3578 t = race_server_record;
3579 if(t != srecordtime_prev) {
3580 srecordtime_prev = t;
3581 srecordtime_change_time = time;
3583 f = time - srecordtime_change_time;
3586 drawstring_aspect(textPos + eY * 0.5 * squareSize, "Server best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3587 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);
3589 drawstring_aspect(textPos + eY * 0.5 * squareSize, "Server best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3590 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);
3591 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);
3592 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);
3595 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
3596 race_status_time = time + 5;
3597 race_status_prev = race_status;
3598 if (race_status_name_prev)
3599 strunzone(race_status_name_prev);
3600 race_status_name_prev = strzone(race_status_name);
3605 a = bound(0, race_status_time - time, 1);
3608 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
3612 rank = race_CheckName(race_status_name);
3614 rankname = race_PlaceName(rank);
3617 namepos = medalPos + '0 0.8 0' * squareSize;
3619 rankpos = medalPos + '0 0.15 0' * squareSize;
3621 if(race_status == 0)
3622 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3623 else if(race_status == 1) {
3624 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);
3625 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3626 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3627 } else if(race_status == 2) {
3628 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
3629 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);
3631 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);
3632 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3633 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3634 } else if(race_status == 3) {
3635 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);
3636 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3637 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3640 if (race_status_time - time <= 0) {
3641 race_status_prev = -1;
3643 if(race_status_name)
3644 strunzone(race_status_name);
3645 race_status_name = string_null;
3646 if(race_status_name_prev)
3647 strunzone(race_status_name_prev);
3648 race_status_name_prev = string_null;
3652 void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, float layout, float i)
3654 float stat, pps_ratio;
3660 stat = getstatf(STAT_DOM_PPS_RED);
3661 pic = "dom_icon_red";
3665 stat = getstatf(STAT_DOM_PPS_BLUE);
3666 pic = "dom_icon_blue";
3670 stat = getstatf(STAT_DOM_PPS_YELLOW);
3671 pic = "dom_icon_yellow";
3675 stat = getstatf(STAT_DOM_PPS_PINK);
3676 pic = "dom_icon_pink";
3679 pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS);
3681 if(mySize_x/mySize_y > aspect_ratio)
3683 i = aspect_ratio * mySize_y;
3684 myPos_x = myPos_x + (mySize_x - i) / 2;
3689 i = 1/aspect_ratio * mySize_x;
3690 myPos_y = myPos_y + (mySize_y - i) / 2;
3694 if (layout) // show text too
3697 color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
3698 if (layout == 2) // average pps
3699 drawstring_aspect(myPos + eX * mySize_y, ftos_decimals(stat, 2), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
3700 else // percentage of average pps
3701 drawstring_aspect(myPos + eX * mySize_y, strcat( ftos(floor(pps_ratio*100 + 0.5)), "%" ), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
3705 drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3708 drawsetcliparea(myPos_x, myPos_y + mySize_y * (1 - pps_ratio), mySize_y, mySize_y * pps_ratio);
3709 drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3710 drawresetcliparea();
3714 void HUD_Mod_Dom(vector myPos, vector mySize)
3716 mod_active = 1; // required in each mod function that always shows something
3719 for(tm = teams.sort_next; tm; tm = tm.sort_next)
3720 if(tm.team != COLOR_SPECTATOR)
3723 float layout = autocvar_hud_panel_modicons_dom_layout;
3724 float rows, columns, aspect_ratio;
3725 rows = mySize_y/mySize_x;
3726 aspect_ratio = (layout) ? 3 : 1;
3727 rows = bound(1, floor((sqrt((4 * aspect_ratio * teams_count + rows) * rows) + rows + 0.5) / 2), teams_count);
3728 columns = ceil(teams_count/rows);
3732 for(i=0; i<teams_count; ++i)
3734 vector pos, itemSize;
3735 pos = myPos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows);
3736 itemSize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
3738 DrawDomItem(pos, itemSize, aspect_ratio, layout, i);
3749 float mod_prev; // previous state of mod_active to check for a change
3751 float mod_change; // "time" when mod_active changed
3753 void HUD_ModIcons(void)
3755 if(!autocvar__hud_configure)
3757 if(!autocvar_hud_panel_modicons) return;
3758 if (gametype != GAME_CTF && gametype != GAME_KEYHUNT && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && gametype != GAME_CA && gametype != GAME_FREEZETAG && gametype != GAME_KEEPAWAY && gametype != GAME_DOMINATION) return;
3761 hud_configure_active_panel = HUD_PANEL_MODICONS;
3763 HUD_Panel_UpdateCvars(modicons);
3766 mySize = panel_size;
3768 if(mod_active != mod_prev) {
3770 mod_prev = mod_active;
3773 if(mod_active || autocvar__hud_configure)
3774 mod_alpha = bound(0, (time - mod_change) * 2, 1);
3776 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
3779 HUD_Panel_DrawBg(mod_alpha);
3781 if(panel_bg_padding)
3783 pos += '1 1 0' * panel_bg_padding;
3784 mySize -= '2 2 0' * panel_bg_padding;
3787 // these MUST be ran in order to update mod_active
3788 if(gametype == GAME_KEYHUNT)
3789 HUD_Mod_KH(pos, mySize);
3790 else if(gametype == GAME_CTF || autocvar__hud_configure)
3791 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
3792 else if(gametype == GAME_NEXBALL)
3793 HUD_Mod_NexBall(pos, mySize);
3794 else if(gametype == GAME_CTS || gametype == GAME_RACE)
3795 HUD_Mod_Race(pos, mySize);
3796 else if(gametype == GAME_CA || gametype == GAME_FREEZETAG)
3797 HUD_Mod_CA(pos, mySize);
3798 else if(gametype == GAME_DOMINATION)
3799 HUD_Mod_Dom(pos, mySize);
3800 else if(gametype == GAME_KEEPAWAY)
3801 HUD_Mod_Keepaway(pos, mySize);
3804 // Draw pressed keys (#11)
3806 void HUD_DrawPressedKeys(void)
3808 if(!autocvar__hud_configure)
3810 if(!autocvar_hud_panel_pressedkeys) return;
3811 if(spectatee_status <= 0 && autocvar_hud_panel_pressedkeys < 2) return;
3814 hud_configure_active_panel = HUD_PANEL_PRESSEDKEYS;
3817 HUD_Panel_UpdateCvars(pressedkeys);
3820 mySize = panel_size;
3822 HUD_Panel_DrawBg(1);
3823 if(panel_bg_padding)
3825 pos += '1 1 0' * panel_bg_padding;
3826 mySize -= '2 2 0' * panel_bg_padding;
3829 // force custom aspect
3830 float aspect = autocvar_hud_panel_pressedkeys_aspect;
3834 if(mySize_x/mySize_y > aspect)
3836 newSize_x = aspect * mySize_y;
3837 newSize_y = mySize_y;
3839 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3843 newSize_y = 1/aspect * mySize_x;
3844 newSize_x = mySize_x;
3846 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3852 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
3854 pressedkeys = getstatf(STAT_PRESSED_KEYS);
3856 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3857 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);
3858 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);
3860 drawpic_aspect_skin(pos, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3861 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);
3862 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);
3865 // Handle chat as a panel (#12)
3869 if(!autocvar__hud_configure)
3871 if (!autocvar_hud_panel_chat)
3873 if (!autocvar_con_chatrect)
3874 cvar_set("con_chatrect", "0");
3879 hud_configure_active_panel = HUD_PANEL_CHAT;
3881 HUD_Panel_UpdateCvars(chat);
3883 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
3885 panel_pos_y = panel_bg_border;
3886 panel_size_y = vid_conheight - panel_bg_border * 2;
3887 if(panel_bg == "0") // force a border when maximized
3889 if(precache_pic(panel_bg) == "") {
3890 panel_bg = strcat(hud_skin_path, "/border_default");
3891 if(precache_pic(panel_bg) == "") {
3892 panel_bg = "gfx/hud/default/border_default";
3896 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an alpha of at least 0.75
3901 mySize = panel_size;
3903 HUD_Panel_DrawBg(1);
3905 if(panel_bg_padding)
3907 pos += '1 1 0' * panel_bg_padding;
3908 mySize -= '2 2 0' * panel_bg_padding;
3911 if (!autocvar_con_chatrect)
3912 cvar_set("con_chatrect", "1");
3914 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
3915 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
3917 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
3918 cvar_set("con_chat", ftos(floor(mySize_y/autocvar_con_chatsize - 0.5)));
3920 if(autocvar__hud_configure)
3923 chatsize = '1 1 0' * autocvar_con_chatsize;
3924 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
3926 for(i = 0; i < autocvar_con_chat; ++i)
3928 if(i == autocvar_con_chat - 1)
3931 a = panel_fg_alpha * floor(((i + 1) * 7 + autocvar_con_chattime)/45);
3932 drawcolorcodedstring(pos, textShortenToWidth("^3Player^7: This is the chat area.", mySize_x, chatsize, stringwidth_colors), chatsize, a, DRAWFLAG_NORMAL);
3933 pos_y += chatsize_y;
3938 // Engine info panel (#13)
3945 float frametimeavg1; // 1 frame ago
3946 float frametimeavg2; // 2 frames ago
3947 void HUD_EngineInfo(void)
3949 if(!autocvar__hud_configure)
3951 if(!autocvar_hud_panel_engineinfo) return;
3954 hud_configure_active_panel = HUD_PANEL_ENGINEINFO;
3956 HUD_Panel_UpdateCvars(engineinfo);
3959 mySize = panel_size;
3961 HUD_Panel_DrawBg(1);
3962 if(panel_bg_padding)
3964 pos += '1 1 0' * panel_bg_padding;
3965 mySize -= '2 2 0' * panel_bg_padding;
3968 float currentTime = gettime(GETTIME_REALTIME);
3969 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
3971 float currentframetime = currentTime - prevfps_time;
3972 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
3973 frametimeavg2 = frametimeavg1;
3974 frametimeavg1 = frametimeavg;
3977 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
3978 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.
3980 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
3981 prevfps = (1/currentframetime);
3982 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"
3984 prevfps_time = currentTime;
3989 if(currentTime - prevfps_time > autocvar_hud_panel_engineinfo_framecounter_time)
3991 prevfps = framecounter/(currentTime - prevfps_time);
3993 prevfps_time = currentTime;
3998 color = HUD_Get_Num_Color (prevfps, 100);
3999 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, autocvar_hud_panel_engineinfo_framecounter_decimals)), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4002 // Info messages panel (#14)
4004 #define drawInfoMessage(s)\
4005 if(autocvar_hud_panel_infomessages_flip)\
4006 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);\
4007 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
4009 void HUD_InfoMessages(void)
4011 if(!autocvar__hud_configure)
4013 if(!autocvar_hud_panel_infomessages) return;
4016 hud_configure_active_panel = HUD_PANEL_INFOMESSAGES;
4018 HUD_Panel_UpdateCvars(infomessages);
4021 mySize = panel_size;
4023 HUD_Panel_DrawBg(1);
4024 if(panel_bg_padding)
4026 pos += '1 1 0' * panel_bg_padding;
4027 mySize -= '2 2 0' * panel_bg_padding;
4030 // always force 5:1 aspect
4032 if(mySize_x/mySize_y > 5)
4034 newSize_x = 5 * mySize_y;
4035 newSize_y = mySize_y;
4037 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4041 newSize_y = 1/5 * mySize_x;
4042 newSize_x = mySize_x;
4044 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4053 fontsize = '0.20 0.20 0' * mySize_y;
4056 if(spectatee_status != 0)
4062 if(!autocvar__hud_configure)
4064 if(spectatee_status && !intermission)
4066 if(spectatee_status == -1)
4069 s = strcat("^1Spectating: ^7", GetPlayerName(spectatee_status - 1));
4072 if(spectatee_status == -1)
4073 s = strcat("^1Press ^3", getcommandkey("primary fire", "+fire"), "^1 to spectate");
4075 s = strcat("^1Press ^3", getcommandkey("primary fire", "+fire"), "^1 for another player");
4078 if(spectatee_status == -1)
4079 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
4081 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+fire2"), "^1 to observe");
4084 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
4087 if(gametype == GAME_ARENA)
4088 s = "^1Wait for your turn to join";
4089 else if(gametype == GAME_LMS)
4092 sk = playerslots[player_localentnum - 1];
4093 if(sk.(scores[ps_primary]) >= 666)
4094 s = "^1Match has already begun";
4095 else if(sk.(scores[ps_primary]) > 0)
4096 s = "^1You have no more lives left";
4098 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4101 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4104 //show restart countdown:
4105 if (time < getstatf(STAT_GAMESTARTTIME)) {
4107 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4108 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4109 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
4110 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4114 if(warmup_stage && !intermission)
4116 s = "^2Currently in ^1warmup^2 stage!";
4121 if(mod(time, 1) >= 0.5)
4126 if(ready_waiting && !intermission && !spectatee_status)
4128 if(ready_waiting_for_me)
4131 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
4133 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
4138 s = strcat("^2Waiting for others to ready up to end warmup...");
4140 s = strcat("^2Waiting for others to ready up...");
4144 else if(warmup_stage && !intermission && !spectatee_status)
4146 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
4150 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4152 float ts_min, ts_max;
4153 tm = teams.sort_next;
4156 for(; tm.sort_next; tm = tm.sort_next)
4158 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4160 if(!ts_min) ts_min = tm.team_size;
4161 else ts_min = min(ts_min, tm.team_size);
4162 if(!ts_max) ts_max = tm.team_size;
4163 else ts_max = max(ts_max, tm.team_size);
4165 if ((ts_max - ts_min) > 1)
4167 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
4168 tm = GetTeam(myteam, false);
4170 if (tm.team != COLOR_SPECTATOR)
4171 if (tm.team_size == ts_max)
4172 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
4180 s = "^7Press ^3ESC ^7to show HUD options.";
4182 s = "^3Doubleclick ^7a panel for panel-specific options.";
4184 s = "^3CTRL ^7to disable collision testing, ^3SHIFT ^7and";
4186 s = "^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.";
4191 // Physics panel (#15)
4193 vector acc_prevspeed;
4194 float acc_prevtime, acc_avg, top_speed, top_speed_time;
4196 void HUD_Physics(void)
4198 if(!autocvar__hud_configure)
4200 if(!autocvar_hud_panel_physics) return;
4201 if(spectatee_status == -1 && autocvar_hud_panel_physics < 2) return;
4204 hud_configure_active_panel = HUD_PANEL_PHYSICS;
4206 HUD_Panel_UpdateCvars(physics);
4208 HUD_Panel_DrawBg(1);
4209 if(panel_bg_padding)
4211 panel_pos += '1 1 0' * panel_bg_padding;
4212 panel_size -= '2 2 0' * panel_bg_padding;
4216 float speed, conversion_factor;
4219 switch(autocvar_hud_panel_physics_speed_unit)
4224 conversion_factor = 1.0;
4228 conversion_factor = 0.0254;
4232 conversion_factor = 0.0254 * 3.6;
4236 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4240 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4244 float max_speed = floor( autocvar_hud_panel_physics_speed_max * conversion_factor + 0.5 );
4245 if (autocvar__hud_configure)
4246 speed = floor( max_speed * 0.65 + 0.5 );
4247 else if(autocvar_hud_panel_physics_speed_vertical)
4248 speed = floor( vlen(pmove_vel) * conversion_factor + 0.5 );
4250 speed = floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 );
4252 //compute acceleration
4253 float acceleration, f;
4254 if (autocvar__hud_configure)
4255 acceleration = autocvar_hud_panel_physics_acceleration_max * 0.3;
4258 // 1 m/s = 0.0254 qu/s; 1 g = 9.80665 m/s^2
4259 f = time - acc_prevtime;
4260 if(autocvar_hud_panel_physics_acceleration_vertical)
4261 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f) * (0.0254 / 9.80665);
4263 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f) * (0.0254 / 9.80665);
4264 acc_prevspeed = pmove_vel;
4265 acc_prevtime = time;
4267 f = bound(0, f * 10, 1);
4268 acc_avg = acc_avg * (1 - f) + acceleration * f;
4272 float panel_ar = panel_size_x/panel_size_y;
4273 vector speed_offset, acceleration_offset;
4276 panel_size_x *= 0.5;
4277 if (autocvar_hud_panel_physics_flip)
4278 speed_offset_x = panel_size_x;
4280 acceleration_offset_x = panel_size_x;
4284 panel_size_y *= 0.5;
4285 if (autocvar_hud_panel_physics_flip)
4286 speed_offset_y = panel_size_y;
4288 acceleration_offset_y = panel_size_y;
4290 float speed_baralign, acceleration_baralign;
4291 if (autocvar_hud_panel_physics_baralign == 1)
4292 acceleration_baralign = speed_baralign = 1;
4293 else if(autocvar_hud_panel_physics_baralign == 4)
4294 acceleration_baralign = speed_baralign = 2;
4295 else if (autocvar_hud_panel_physics_flip)
4297 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 2);
4298 speed_baralign = (autocvar_hud_panel_physics_baralign == 3);
4302 speed_baralign = (autocvar_hud_panel_physics_baralign == 2);
4303 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 3);
4305 if (autocvar_hud_panel_physics_acceleration_progressbar_mode == 0)
4306 acceleration_baralign = 3; //override hud_panel_physics_baralign value for acceleration
4310 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
4312 HUD_Panel_GetProgressBarColor(speed);
4313 HUD_Panel_DrawProgressBar(panel_pos + speed_offset, panel_size, "progressbar", speed/max_speed, 0, speed_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4315 vector tmp_offset, tmp_size;
4316 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
4318 tmp_size_x = panel_size_x * 0.75;
4319 tmp_size_y = panel_size_y;
4321 tmp_offset_x = panel_size_x - tmp_size_x;
4324 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4330 tmp_offset_x = tmp_size_x;
4331 if (autocvar_hud_panel_physics_speed_unit_show)
4334 tmp_size_x = panel_size_x * (1 - 0.75);
4335 tmp_size_y = panel_size_y * 0.4;
4336 drawstring_aspect(panel_pos + speed_offset + tmp_offset, unit, tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4340 //compute and draw top speed
4341 if (autocvar_hud_panel_physics_topspeed)
4342 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
4344 if (autocvar__hud_configure)
4346 top_speed = floor( max_speed * 0.75 + 0.5 );
4351 if (speed >= top_speed)
4354 top_speed_time = time;
4358 f = max(1, autocvar_hud_panel_physics_topspeed_time);
4359 // divide by f to make it start from 1
4360 f = cos( ((time - top_speed_time) / f) * PI/2 );
4362 else //hide top speed 0, it would be stupid
4367 //top speed progressbar peak
4368 if(speed < top_speed)
4369 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
4371 float peak_offset_x;
4373 if (speed_baralign == 0)
4374 peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x;
4375 else if (speed_baralign == 1)
4376 peak_offset_x = (1 - min(top_speed, max_speed)/max_speed) * panel_size_x;
4377 else if (speed_baralign == 2)
4378 peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x * 0.5;
4379 //if speed is not 0 the speed progressbar already fetched the color
4381 HUD_Panel_GetProgressBarColor(speed);
4382 peak_size_x = floor(panel_size_x * 0.01 + 1.5);
4383 peak_size_y = panel_size_y;
4384 if (speed_baralign == 2) // draw two peaks, on both sides
4386 drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size_x + peak_offset_x - peak_size_x), peak_size, progressbar_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4387 drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size_x - peak_offset_x + peak_size_x), peak_size, progressbar_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4390 drawfill(panel_pos + speed_offset + eX * (peak_offset_x - peak_size_x), peak_size, progressbar_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4394 tmp_offset_y = panel_size_y * 0.4;
4395 tmp_size_x = panel_size_x * (1 - 0.75);
4396 tmp_size_y = panel_size_y - tmp_offset_y;
4397 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(top_speed), tmp_size, '1 0 0', f * panel_fg_alpha, DRAWFLAG_NORMAL);
4405 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 3)
4407 if (acceleration < 0)
4408 HUD_Panel_GetProgressBarColor(acceleration_neg);
4410 HUD_Panel_GetProgressBarColor(acceleration);
4411 HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset, panel_size, "progressbar", acceleration/autocvar_hud_panel_physics_acceleration_max, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4413 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3)
4414 drawstring_aspect(panel_pos + acceleration_offset, strcat(ftos_decimals(acceleration, 2), "g"), panel_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4423 void HUD_Reset (void)
4425 // reset gametype specific icons
4426 if(gametype == GAME_KEYHUNT)
4428 else if(gametype == GAME_CTF)
4429 HUD_Mod_CTF_Reset();
4432 #define HUD_DrawPanel(id)\
4434 case (HUD_PANEL_RADAR):\
4435 HUD_Radar(); break;\
4436 case (HUD_PANEL_WEAPONS):\
4437 HUD_Weapons(); break;\
4438 case (HUD_PANEL_AMMO):\
4440 case (HUD_PANEL_POWERUPS):\
4441 HUD_Powerups(); break;\
4442 case (HUD_PANEL_HEALTHARMOR):\
4443 HUD_HealthArmor(); break;\
4444 case (HUD_PANEL_NOTIFY):\
4445 HUD_Notify(); break;\
4446 case (HUD_PANEL_TIMER):\
4447 HUD_Timer(); break;\
4448 case (HUD_PANEL_SCORE):\
4449 HUD_Score(); break;\
4450 case (HUD_PANEL_RACETIMER):\
4451 HUD_RaceTimer(); break;\
4452 case (HUD_PANEL_VOTE):\
4453 HUD_VoteWindow(); break;\
4454 case (HUD_PANEL_MODICONS):\
4455 HUD_ModIcons(); break;\
4456 case (HUD_PANEL_PRESSEDKEYS):\
4457 HUD_DrawPressedKeys(); break;\
4458 case (HUD_PANEL_CHAT):\
4460 case (HUD_PANEL_ENGINEINFO):\
4461 HUD_EngineInfo(); break;\
4462 case (HUD_PANEL_INFOMESSAGES):\
4463 HUD_InfoMessages(); break;\
4464 case (HUD_PANEL_PHYSICS):\
4465 HUD_Physics(); break;\
4466 } ENDS_WITH_CURLY_BRACE
4468 void HUD_Main (void)
4471 // global hud alpha fade
4472 if(menu_enabled == 1)
4475 hud_fade_alpha = (1 - autocvar__menu_alpha);
4477 if(scoreboard_fade_alpha)
4478 hud_fade_alpha = (1 - scoreboard_fade_alpha);
4480 if(intermission == 2) // no hud during mapvote
4482 else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
4485 if(!autocvar__hud_configure && !hud_fade_alpha)
4489 if (hud_skin_path != autocvar_hud_skin)
4492 strunzone(hud_skin_path);
4493 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
4496 // HUD configure visible grid
4497 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4499 hud_configure_gridSize_x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
4500 hud_configure_gridSize_y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
4501 hud_configure_realGridSize_x = hud_configure_gridSize_x * vid_conwidth;
4502 hud_configure_realGridSize_y = hud_configure_gridSize_y * vid_conheight;
4504 for(i = 0; i < 1/hud_configure_gridSize_x; ++i)
4505 drawfill(eX * i * hud_configure_realGridSize_x, eX + eY * vid_conheight, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4507 for(i = 0; i < 1/hud_configure_gridSize_y; ++i)
4508 drawfill(eY * i * hud_configure_realGridSize_y, eY + eX * vid_conwidth, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4511 current_player = (spectatee_status > 0) ? spectatee_status : player_localentnum;
4514 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4518 float hud_dock_color_team = autocvar_hud_dock_color_team;
4519 if((teamplay) && hud_dock_color_team) {
4520 f = stof(getplayerkey(current_player - 1, "colors"));
4521 color = colormapPaletteColor(mod(f, 16), 1) * hud_dock_color_team;
4523 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
4524 color = '1 0 0' * hud_dock_color_team;
4528 string hud_dock_color = autocvar_hud_dock_color;
4529 if(hud_dock_color == "shirt") {
4530 f = stof(getplayerkey(current_player - 1, "colors"));
4531 color = colormapPaletteColor(floor(f / 16), 0);
4533 else if(hud_dock_color == "pants") {
4534 f = stof(getplayerkey(current_player - 1, "colors"));
4535 color = colormapPaletteColor(mod(f, 16), 1);
4538 color = stov(hud_dock_color);
4542 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4543 if(precache_pic(pic) == "") {
4544 pic = strcat(hud_skin_path, "/dock_medium");
4545 if(precache_pic(pic) == "") {
4546 pic = "gfx/hud/default/dock_medium";
4549 drawpic('0 0 0', pic, eX * vid_conwidth + eY * vid_conheight, color, autocvar_hud_dock_alpha * hud_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
4552 // cache the panel order into the panel_order array
4553 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4554 for(i = 0; i < HUD_PANEL_NUM; ++i)
4555 panel_order[i] = -1;
4557 float p_num, warning;
4558 float argc = tokenize_console(autocvar__hud_panelorder);
4559 if (argc > HUD_PANEL_NUM)
4561 //first detect wrong/missing panel numbers
4562 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4563 p_num = stof(argv(i));
4564 if (p_num >= 0 && p_num < HUD_PANEL_NUM) { //correct panel number?
4565 if (panel_order[p_num] == -1) //found for the first time?
4566 s = strcat(s, ftos(p_num), " ");
4567 panel_order[p_num] = 1; //mark as found
4572 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4573 if (panel_order[i] == -1) {
4575 s = strcat(s, ftos(i), " "); //add missing panel number
4579 print("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n");
4581 cvar_set("_hud_panelorder", s);
4582 if(hud_panelorder_prev)
4583 strunzone(hud_panelorder_prev);
4584 hud_panelorder_prev = strzone(s);
4586 //now properly set panel_order
4587 tokenize_console(s);
4588 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4589 panel_order[i] = stof(argv(i));
4593 // draw panels in order specified by panel_order array
4594 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
4595 if(i != HUD_PANEL_CHAT || !autocvar__con_chat_maximized) // don't draw maximized chat panel twice!
4596 HUD_DrawPanel(panel_order[i]);
4599 // draw chat panel on top if it is maximized
4600 if(autocvar__con_chat_maximized)
4601 HUD_Chat(); // HUD_DrawPanel(HUD_PANEL_CHAT);
4603 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)
4604 localcmd("cmd selectteam auto; cmd join\n");
4606 if(autocvar__hud_configure && tab_panel != -1)
4608 HUD_Panel_UpdatePosSizeForId(tab_panel)
4609 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
4612 hud_configure_prev = autocvar__hud_configure;
4614 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again