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 <= 0 || !theAlpha)
436 vector width, height;
438 pic = strcat(hud_skin_path, "/", pic, "_vertical");
439 if(precache_pic(pic) == "") {
440 pic = "gfx/hud/default/statusbar_vertical";
443 if (baralign == 1) // bottom align
444 theOrigin_y += (1 - length_ratio) * theSize_y;
445 else if (baralign == 2) // center align
446 theOrigin_y += 0.5 * (1 - length_ratio) * theSize_y;
447 theSize_y *= length_ratio;
450 width = eX * theSize_x;
451 height = eY * theSize_y;
452 if(theSize_y <= theSize_x * 2)
454 // button not high enough
455 // draw just upper and lower part then
456 square = eY * theSize_y * 0.5;
457 bH = eY * (0.25 * theSize_y / (theSize_x * 2));
458 drawsubpic(theOrigin, square + width, pic, '0 0 0', eX + bH, theColor, theAlpha, drawflag);
459 drawsubpic(theOrigin + square, square + width, pic, eY - bH, eX + bH, theColor, theAlpha, drawflag);
463 square = eY * theSize_x;
464 drawsubpic(theOrigin, width + square, pic, '0 0 0', '1 0.25 0', theColor, theAlpha, drawflag);
465 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0 0.25 0', '1 0.5 0', theColor, theAlpha, drawflag);
466 drawsubpic(theOrigin + height - square, width + square, pic, '0 0.75 0', '1 0.25 0', theColor, theAlpha, drawflag);
469 pic = strcat(hud_skin_path, "/", pic);
470 if(precache_pic(pic) == "") {
471 pic = "gfx/hud/default/statusbar";
474 if (baralign == 1) // right align
475 theOrigin_x += (1 - length_ratio) * theSize_x;
476 else if (baralign == 2) // center align
477 theOrigin_x += 0.5 * (1 - length_ratio) * theSize_x;
478 theSize_x *= length_ratio;
481 width = eX * theSize_x;
482 height = eY * theSize_y;
483 if(theSize_x <= theSize_y * 2)
485 // button not wide enough
486 // draw just left and right part then
487 square = eX * theSize_x * 0.5;
488 bW = eX * (0.25 * theSize_x / (theSize_y * 2));
489 drawsubpic(theOrigin, square + height, pic, '0 0 0', eY + bW, theColor, theAlpha, drawflag);
490 drawsubpic(theOrigin + square, square + height, pic, eX - bW, eY + bW, theColor, theAlpha, drawflag);
494 square = eX * theSize_y;
495 drawsubpic(theOrigin, height + square, pic, '0 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
496 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0.25 0 0', '0.5 1 0', theColor, theAlpha, drawflag);
497 drawsubpic(theOrigin + width - square, height + square, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
502 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
508 pic = strcat(hud_skin_path, "/num_leading");
509 if(precache_pic(pic) == "") {
510 pic = "gfx/hud/default/num_leading";
513 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
514 if(mySize_x/mySize_y > 2)
515 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);
516 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);
521 entity weaponorder[WEP_MAXCOUNT];
522 void weaponorder_swap(float i, float j, entity pass)
526 weaponorder[i] = weaponorder[j];
530 string weaponorder_cmp_str;
531 float weaponorder_cmp(float i, float j, entity pass)
534 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
535 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
536 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)
539 float GetAmmoStat(float i)
543 case 0: return STAT_SHELLS;
544 case 1: return STAT_NAILS;
545 case 2: return STAT_ROCKETS;
546 case 3: return STAT_CELLS;
547 case 4: return STAT_FUEL;
552 float GetAmmoTypeForWep(float i)
556 case WEP_SHOTGUN: return 0;
557 case WEP_UZI: return 1;
558 case WEP_GRENADE_LAUNCHER: return 2;
559 case WEP_MINE_LAYER: return 2;
560 case WEP_ELECTRO: return 3;
561 case WEP_CRYLINK: return 3;
562 case WEP_HLAC: return 3;
563 case WEP_MINSTANEX: return 3;
564 case WEP_NEX: return 3;
565 case WEP_CAMPINGRIFLE: return 1;
566 case WEP_HAGAR: return 2;
567 case WEP_ROCKET_LAUNCHER: return 2;
568 case WEP_SEEKER: return 2;
569 case WEP_FIREBALL: return 4;
570 case WEP_HOOK: return 3;
575 void HUD_Weapons(void)
578 float center_x, center_y;
580 if(!autocvar__hud_configure)
582 if(!autocvar_hud_panel_weapons) return;
583 if(spectatee_status == -1) return;
586 hud_configure_active_panel = HUD_PANEL_WEAPONS;
588 float timeout = autocvar_hud_panel_weapons_timeout;
589 float timeout_effect_length, timein_effect_length;
590 if (autocvar_hud_panel_weapons_timeout_effect == 0)
592 timeout_effect_length = 0;
593 timein_effect_length = 0;
597 timeout_effect_length = 0.75;
598 timein_effect_length = 0.375;
601 if (timeout && time >= weapontime + timeout + timeout_effect_length && !autocvar__hud_configure)
603 weaponprevtime = time;
607 HUD_Panel_UpdateCvars(weapons);
609 if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
611 f = (time - (weapontime + timeout)) / timeout_effect_length;
612 if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3)
614 panel_bg_alpha *= (1 - f);
615 panel_fg_alpha *= (1 - f);
617 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
619 f *= f; // for a cooler movement
620 center_x = panel_pos_x + panel_size_x/2;
621 center_y = panel_pos_y + panel_size_y/2;
622 screen_ar = vid_conwidth/vid_conheight;
623 if (center_x/center_y < screen_ar) //bottom left
625 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
626 panel_pos_y += f * (vid_conheight - panel_pos_y);
628 panel_pos_x -= f * (panel_pos_x + panel_size_x);
632 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
633 panel_pos_x += f * (vid_conwidth - panel_pos_x);
635 panel_pos_y -= f * (panel_pos_y + panel_size_y);
638 weaponprevtime = time - (1 - f) * timein_effect_length;
640 else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure)
642 f = (time - weaponprevtime) / timein_effect_length;
643 if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3)
645 panel_bg_alpha *= (f);
646 panel_fg_alpha *= (f);
648 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
650 f *= f; // for a cooler movement
652 center_x = panel_pos_x + panel_size_x/2;
653 center_y = panel_pos_y + panel_size_y/2;
654 screen_ar = vid_conwidth/vid_conheight;
655 if (center_x/center_y < screen_ar) //bottom left
657 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
658 panel_pos_y += f * (vid_conheight - panel_pos_y);
660 panel_pos_x -= f * (panel_pos_x + panel_size_x);
664 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
665 panel_pos_x += f * (vid_conwidth - panel_pos_x);
667 panel_pos_y -= f * (panel_pos_y + panel_size_y);
672 float i, weapid, wpnalpha, weapon_cnt;
674 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
676 self = get_weaponinfo(i);
677 if(self.impulse >= 0)
681 // TODO make this configurable
682 if(weaponorder_bypriority != autocvar_cl_weaponpriority)
684 if(weaponorder_bypriority)
685 strunzone(weaponorder_bypriority);
686 if(weaponorder_byimpulse)
687 strunzone(weaponorder_byimpulse);
689 weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
690 weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
691 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
694 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
696 self = get_weaponinfo(i);
697 if(self.impulse >= 0)
699 weaponorder[weapon_cnt] = self;
703 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
705 weaponorder_cmp_str = string_null;
711 panel_pos += '1 1 0' * panel_bg_padding;
712 panel_size -= '2 2 0' * panel_bg_padding;
715 if(autocvar_hud_panel_weapons_fade)
717 wpnalpha = 3.2 - 2 * (time - weapontime);
718 wpnalpha = bound(0.7, wpnalpha, 1) * panel_fg_alpha;
721 wpnalpha = panel_fg_alpha;
724 float aspect = autocvar_hud_panel_weapons_aspect;
725 rows = panel_size_y/panel_size_x;
726 rows = bound(1, floor((sqrt(4 * aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
728 columns = ceil(WEP_COUNT/rows);
731 float a, type, fullammo;
733 when = autocvar_hud_panel_weapons_complainbubble_time;
735 fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
743 wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
744 float barsize_x, barsize_y, baroffset_x, baroffset_y;
745 if (autocvar_hud_panel_weapons_ammo)
747 ammo_color = stov(autocvar_hud_panel_weapons_ammo_color);
748 ammo_alpha = panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha;
751 if(wpnsize_x/wpnsize_y > aspect)
753 barsize_x = aspect * wpnsize_y;
754 barsize_y = wpnsize_y;
755 baroffset_x = (wpnsize_x - barsize_x) / 2;
759 barsize_y = 1/aspect * wpnsize_x;
760 barsize_x = wpnsize_x;
761 baroffset_y = (wpnsize_y - barsize_y) / 2;
767 if(autocvar_hud_panel_weapons_accuracy && acc_levels)
769 show_accuracy = true;
770 if (acc_col_x[0] == -1)
771 for (i = 0; i < acc_levels; ++i)
772 acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
775 float weapons_st = getstati(STAT_WEAPONS);
776 float label = autocvar_hud_panel_weapons_label;
778 for(i = 0; i < weapon_cnt; ++i)
780 wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y;
782 self = weaponorder[i];
783 weapid = self.impulse;
785 // draw background behind currently selected weapon
786 if(self.weapon == activeweapon)
787 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
789 // draw the weapon accuracy
792 weapon_stats = weapon_accuracy[self.weapon-WEP_FIRST];
793 if(weapon_stats >= 0)
795 // find the max level lower than weapon_stats
798 while ( j && weapon_stats < acc_lev[j] )
801 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
803 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
805 color = color + factor * (acc_col[j+1] - color);
807 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
811 // draw the weapon icon
812 if((weapid >= 0) && (weapons_st & self.weapons))
814 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
816 if(label == 1) // weapon number
817 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
818 else if(label == 2) // bind
819 drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
821 // draw ammo status bar
822 if(autocvar_hud_panel_weapons_ammo && self.weapon != WEP_TUBA && self.weapon != WEP_LASER && self.weapon != WEP_PORTO)
825 type = GetAmmoTypeForWep(self.weapon);
827 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
832 case 0: fullammo = autocvar_hud_panel_weapons_ammo_full_shells; break;
833 case 1: fullammo = autocvar_hud_panel_weapons_ammo_full_nails; break;
834 case 2: fullammo = autocvar_hud_panel_weapons_ammo_full_rockets; break;
835 case 3: fullammo = autocvar_hud_panel_weapons_ammo_full_cells; break;
836 case 4: fullammo = autocvar_hud_panel_weapons_ammo_full_fuel; break;
837 default: fullammo = 60;
841 wpnpos_x + baroffset_x,
842 wpnpos_y + baroffset_y,
843 barsize_x * bound(0, a/fullammo, 1),
845 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, ammo_color, ammo_alpha, DRAWFLAG_NORMAL);
851 // draw a "ghost weapon icon" if you don't have the weapon
854 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
857 // draw the complain message
858 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
862 if(complain_weapon_time + when > time)
865 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
869 if(complain_weapon_time + when > time)
876 if(complain_weapon_type == 0) {
878 color = stov(autocvar_hud_panel_weapons_complainbubble_color_outofammo);
880 else if(complain_weapon_type == 1) {
882 color = stov(autocvar_hud_panel_weapons_complainbubble_color_donthave);
886 color = stov(autocvar_hud_panel_weapons_complainbubble_color_unavailable);
888 float padding = autocvar_hud_panel_weapons_complainbubble_padding;
889 drawpic_aspect_skin(wpnpos + '1 1 0' * padding, "weapon_complainbubble", wpnsize - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
890 drawstring_aspect(wpnpos + '1 1 0' * padding, s, wpnsize - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
906 float GetAmmoItemCode(float i)
910 case 0: return IT_SHELLS;
911 case 1: return IT_NAILS;
912 case 2: return IT_ROCKETS;
913 case 3: return IT_CELLS;
914 case 4: return IT_FUEL;
919 string GetAmmoPicture(float i)
923 case 0: return "ammo_shells";
924 case 1: return "ammo_bullets";
925 case 2: return "ammo_rockets";
926 case 3: return "ammo_cells";
927 case 4: return "ammo_fuel";
932 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
935 if(autocvar__hud_configure)
937 currently_selected = (itemcode == 2); //rockets always selected
938 a = 31 + mod(itemcode*93, 128);
941 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
950 if(currently_selected)
955 vector picpos, numpos;
956 if(autocvar_hud_panel_ammo_iconalign)
959 picpos = myPos + eX * 2 * mySize_y;
963 numpos = myPos + eX * mySize_y;
967 if (currently_selected)
968 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
970 if(a > 0 && autocvar_hud_panel_ammo_progressbar)
971 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);
973 if(autocvar_hud_panel_ammo_text)
976 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
977 else // "ghost" ammo count
978 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
981 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
982 else // "ghost" ammo icon
983 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
988 if(!autocvar__hud_configure)
990 if(!autocvar_hud_panel_ammo) return;
991 if(spectatee_status == -1) return;
994 hud_configure_active_panel = HUD_PANEL_AMMO;
996 HUD_Panel_UpdateCvars(ammo);
1001 HUD_Panel_DrawBg(1);
1002 if(panel_bg_padding)
1004 pos += '1 1 0' * panel_bg_padding;
1005 mySize -= '2 2 0' * panel_bg_padding;
1008 float rows, columns, row, column;
1010 if (autocvar_hud_panel_ammo_onlycurrent)
1014 rows = mySize_y/mySize_x;
1015 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1016 // ^^^ ammo item aspect goes here
1018 columns = ceil(AMMO_COUNT/rows);
1020 ammo_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
1025 if(ammo_size_x/ammo_size_y > 3)
1027 newSize = 3 * ammo_size_y;
1028 offset_x = ammo_size_x - newSize;
1029 pos_x += offset_x/2;
1030 ammo_size_x = newSize;
1034 newSize = 1/3 * ammo_size_x;
1035 offset_y = ammo_size_y - newSize;
1036 pos_y += offset_y/2;
1037 ammo_size_y = newSize;
1040 float i, stat_items, currently_selected;
1041 if (autocvar_hud_panel_ammo_onlycurrent)
1043 if(autocvar__hud_configure)
1045 DrawAmmoItem(pos, ammo_size, 2, true); //show rockets
1048 stat_items = getstati(STAT_ITEMS);
1049 for (i = 0; i < AMMO_COUNT; ++i) {
1050 currently_selected = stat_items & GetAmmoItemCode(i);
1051 if (currently_selected)
1053 DrawAmmoItem(pos, ammo_size, i, true);
1057 return; // nothing to display
1060 stat_items = getstati(STAT_ITEMS);
1061 for (i = 0; i < AMMO_COUNT; ++i) {
1062 currently_selected = stat_items & GetAmmoItemCode(i);
1063 DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected);
1068 column = column + 1;
1073 void DrawNumIcon(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float alpha)
1075 vector newPos, newSize;
1076 vector picpos, numpos;
1080 if(mySize_y/mySize_x > 2)
1082 newSize_y = 2 * mySize_x;
1083 newSize_x = mySize_x;
1085 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1090 newSize_x = 1/2 * mySize_y;
1091 newSize_y = mySize_y;
1093 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1097 if(icon_right_align)
1100 picpos = newPos + eY * newSize_x;
1105 numpos = newPos + eY * newSize_x;
1109 drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1110 // make number smaller than icon, it looks better
1111 // reduce only y to draw numbers with different number of digits with the same y size
1112 numpos_y += newSize_y * ((1 - 0.7) / 2);
1114 drawstring_aspect(numpos, ftos(x), newSize, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1118 if(mySize_x/mySize_y > 3)
1120 newSize_x = 3 * mySize_y;
1121 newSize_y = mySize_y;
1123 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1128 newSize_y = 1/3 * mySize_x;
1129 newSize_x = mySize_x;
1131 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1135 if(icon_right_align) // right align
1138 picpos = newPos + eX * 2 * newSize_y;
1142 numpos = newPos + eX * newSize_y;
1146 drawstring_aspect(numpos, ftos(x), '2 1 0' * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1147 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1150 void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float fadelerp)
1153 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
1155 DrawNumIcon(myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, vertical, icon_right_align, color, (1 - fadelerp));
1160 void HUD_Powerups(void)
1162 float strength_time, shield_time;
1163 if(!autocvar__hud_configure)
1165 if(!autocvar_hud_panel_powerups) return;
1166 if(spectatee_status == -1) return;
1167 if not(getstati(STAT_ITEMS) & (IT_STRENGTH | IT_INVINCIBLE)) return;
1168 if (getstati(STAT_HEALTH) <= 0) return;
1170 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1171 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1175 hud_configure_active_panel = HUD_PANEL_POWERUPS;
1181 HUD_Panel_UpdateCvars(powerups);
1184 mySize = panel_size;
1186 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
1187 if(panel_bg_padding)
1189 pos += '1 1 0' * panel_bg_padding;
1190 mySize -= '2 2 0' * panel_bg_padding;
1197 string leftname, rightname;
1198 string leftprogressname, rightprogressname;
1199 float leftcnt, rightcnt;
1200 float leftexact, rightexact;
1201 if (autocvar_hud_panel_powerups_flip) {
1202 leftname = "strength";
1203 leftprogressname = autocvar_hud_panel_powerups_progressbar_strength;
1204 leftcnt = ceil(strength_time);
1205 leftexact = strength_time;
1207 rightname = "shield";
1208 rightprogressname = autocvar_hud_panel_powerups_progressbar_shield;
1209 rightcnt = ceil(shield_time);
1210 rightexact = shield_time;
1212 leftname = "shield";
1213 leftprogressname = autocvar_hud_panel_powerups_progressbar_shield;
1214 leftcnt = ceil(shield_time);
1215 leftexact = shield_time;
1217 rightname = "strength";
1218 rightprogressname = autocvar_hud_panel_powerups_progressbar_strength;
1219 rightcnt = ceil(strength_time);
1220 rightexact = strength_time;
1223 float baralign = autocvar_hud_panel_powerups_baralign;
1224 float iconalign = autocvar_hud_panel_powerups_iconalign;
1226 float panel_ar = mySize_x/mySize_y;
1227 float is_vertical = (panel_ar < 1);
1228 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1230 barsize = eX * 0.5 * mySize_x + eY * mySize_y;
1233 if(autocvar_hud_panel_powerups_progressbar)
1235 HUD_Panel_GetProgressBarColorForString(leftname);
1236 HUD_Panel_DrawProgressBar(pos, barsize, leftprogressname, leftcnt/30, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
1238 if(autocvar_hud_panel_powerups_text)
1241 DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', 1);
1243 DrawNumIcon_expanding(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
1250 if(autocvar_hud_panel_powerups_progressbar)
1252 HUD_Panel_GetProgressBarColorForString(rightname);
1253 HUD_Panel_DrawProgressBar(pos, barsize, rightprogressname, rightcnt/30, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
1255 if(autocvar_hud_panel_powerups_text)
1258 DrawNumIcon(pos, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', 1);
1260 DrawNumIcon_expanding(pos, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1));
1266 barsize = eX * mySize_x + eY * 0.5 * mySize_y;
1269 if(autocvar_hud_panel_powerups_progressbar)
1271 HUD_Panel_GetProgressBarColorForString(leftname);
1272 HUD_Panel_DrawProgressBar(pos, barsize, leftprogressname, leftcnt/30, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
1274 if(autocvar_hud_panel_powerups_text)
1277 DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', 1);
1279 DrawNumIcon_expanding(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
1286 if(autocvar_hud_panel_powerups_progressbar)
1288 HUD_Panel_GetProgressBarColorForString(rightname);
1289 HUD_Panel_DrawProgressBar(pos, barsize, rightprogressname, rightcnt/30, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
1291 if(autocvar_hud_panel_powerups_text)
1294 DrawNumIcon(pos, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', 1);
1296 DrawNumIcon_expanding(pos, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1));
1302 // Health/armor (#3)
1304 void HUD_HealthArmor(void)
1306 float armor, health, fuel;
1307 if(!autocvar__hud_configure)
1309 if(!autocvar_hud_panel_healtharmor) return;
1310 if(spectatee_status == -1) return;
1312 health = getstati(STAT_HEALTH);
1315 armor = getstati(STAT_ARMOR);
1316 fuel = getstati(STAT_FUEL);
1320 hud_configure_active_panel = HUD_PANEL_HEALTHARMOR;
1327 HUD_Panel_UpdateCvars(healtharmor);
1330 mySize = panel_size;
1332 HUD_Panel_DrawBg(1);
1333 if(panel_bg_padding)
1335 pos += '1 1 0' * panel_bg_padding;
1336 mySize -= '2 2 0' * panel_bg_padding;
1340 vector picpos, numpos;
1342 float baralign = autocvar_hud_panel_healtharmor_baralign;
1343 float iconalign = autocvar_hud_panel_healtharmor_iconalign;
1345 float maxhealth = autocvar_hud_panel_healtharmor_maxhealth;
1346 float maxarmor = autocvar_hud_panel_healtharmor_maxarmor;
1347 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
1350 v = healtharmor_maxdamage(health, armor, armorblockpercent);
1355 float maxtotal = maxhealth + maxarmor;
1357 if(v_z) // NOT fully armored
1359 biggercount = "health";
1360 if(autocvar_hud_panel_healtharmor_progressbar)
1362 HUD_Panel_GetProgressBarColor(health);
1363 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);
1366 if(autocvar_hud_panel_healtharmor_text)
1367 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);
1371 biggercount = "armor";
1372 if(autocvar_hud_panel_healtharmor_progressbar)
1374 HUD_Panel_GetProgressBarColor(armor);
1375 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);
1378 if(autocvar_hud_panel_healtharmor_text)
1379 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);
1381 if(autocvar_hud_panel_healtharmor_text)
1382 DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, maxtotal), 1);
1386 HUD_Panel_GetProgressBarColor(fuel);
1387 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);
1392 string leftname, rightname;
1393 string leftprogressname, rightprogressname;
1394 float leftcnt, rightcnt;
1395 float leftmax, rightmax;
1396 float leftactive, rightactive;
1397 float leftalpha, rightalpha;
1398 if (autocvar_hud_panel_healtharmor_flip) { // old style layout with armor left/top of health
1400 leftprogressname = autocvar_hud_panel_healtharmor_progressbar_armor;
1404 leftalpha = min((armor+10)/55, 1);
1407 rightname = "health";
1408 rightprogressname = autocvar_hud_panel_healtharmor_progressbar_health;
1412 rightmax = maxhealth;
1414 leftname = "health";
1415 leftprogressname = autocvar_hud_panel_healtharmor_progressbar_health;
1419 leftmax = maxhealth;
1421 rightname = "armor";
1422 rightprogressname = autocvar_hud_panel_healtharmor_progressbar_armor;
1426 rightalpha = min((armor+10)/55, 1);
1427 rightmax = maxarmor;
1430 float panel_ar = mySize_x/mySize_y;
1431 float is_vertical = (panel_ar < 1);
1432 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1434 barsize = eX * 0.5 * mySize_x + eY * mySize_y;
1437 if(autocvar_hud_panel_healtharmor_progressbar)
1439 HUD_Panel_GetProgressBarColorForString(leftname);
1440 HUD_Panel_DrawProgressBar(pos, barsize, leftprogressname, leftcnt/leftmax, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1442 if(autocvar_hud_panel_healtharmor_text)
1443 DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), HUD_Get_Num_Color(leftcnt, leftmax), 1);
1448 if(autocvar_hud_panel_healtharmor_progressbar)
1450 HUD_Panel_GetProgressBarColorForString(rightname);
1451 HUD_Panel_DrawProgressBar(pos + eX * 0.5 * mySize_x, barsize, rightprogressname, rightcnt/rightmax, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1453 if(autocvar_hud_panel_healtharmor_text)
1454 DrawNumIcon(pos + eX * 0.5 * mySize_x, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), HUD_Get_Num_Color(rightcnt, rightmax), 1);
1459 HUD_Panel_GetProgressBarColor(fuel);
1460 if (is_vertical) //if vertical always halve x to not cover too much numbers with 3 digits
1461 mySize_x *= 0.2 * 0.5 / 2;
1464 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
1469 barsize = eX * mySize_x + eY * 0.5 * mySize_y;
1472 if(autocvar_hud_panel_healtharmor_progressbar)
1474 HUD_Panel_GetProgressBarColorForString(leftname);
1475 HUD_Panel_DrawProgressBar(pos, barsize, leftprogressname, leftcnt/leftmax, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1477 if(autocvar_hud_panel_healtharmor_text)
1478 DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), HUD_Get_Num_Color(leftcnt, leftmax), 1);
1483 if(autocvar_hud_panel_healtharmor_progressbar)
1485 HUD_Panel_GetProgressBarColorForString(rightname);
1486 HUD_Panel_DrawProgressBar(pos + eY * 0.5 * mySize_y, barsize, rightprogressname, rightcnt/rightmax, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1488 if(autocvar_hud_panel_healtharmor_text)
1489 DrawNumIcon(pos + eY * 0.5 * mySize_y, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), HUD_Get_Num_Color(rightcnt, rightmax), 1);
1494 HUD_Panel_GetProgressBarColor(fuel);
1495 if (is_vertical) //if vertical always halve x to not cover numbers with 3 digits
1496 mySize_x *= 0.2 / 2;
1498 mySize_y *= 0.2 * 0.5;
1499 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
1505 // Notification area (#4)
1508 string Weapon_SuicideMessage(float deathtype)
1510 w_deathtype = deathtype;
1511 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
1512 return w_deathtypestring;
1515 string Weapon_KillMessage(float deathtype)
1517 w_deathtype = deathtype;
1518 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
1519 return w_deathtypestring;
1522 #define KN_MAX_ENTRIES 10
1524 float killnotify_times[KN_MAX_ENTRIES];
1525 float killnotify_deathtype[KN_MAX_ENTRIES];
1526 float killnotify_actiontype[KN_MAX_ENTRIES]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
1527 string killnotify_attackers[KN_MAX_ENTRIES];
1528 string killnotify_victims[KN_MAX_ENTRIES];
1529 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
1533 kn_index = KN_MAX_ENTRIES-1;
1534 killnotify_times[kn_index] = time;
1535 killnotify_deathtype[kn_index] = wpn;
1536 killnotify_actiontype[kn_index] = actiontype;
1537 if(killnotify_attackers[kn_index])
1538 strunzone(killnotify_attackers[kn_index]);
1539 killnotify_attackers[kn_index] = strzone(attacker);
1540 if(killnotify_victims[kn_index])
1541 strunzone(killnotify_victims[kn_index]);
1542 killnotify_victims[kn_index] = strzone(victim);
1545 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
1548 float alsoprint, gentle;
1549 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
1550 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
1552 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
1555 if(msg == MSG_SUICIDE) {
1556 w = DEATH_WEAPONOF(type);
1558 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1560 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
1561 } else if (type == DEATH_KILL) {
1562 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
1564 print ("^1",s1, "^1 couldn't take it anymore\n");
1565 } else if (type == DEATH_ROT) {
1566 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1568 print ("^1",s1, "^1 died\n");
1569 } else if (type == DEATH_NOAMMO) {
1570 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
1572 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
1573 } else if (type == DEATH_CAMP) {
1574 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
1576 print ("^1",s1, "^1 thought they found a nice camping ground\n");
1577 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
1578 HUD_KillNotify_Push(s1, "", 0, type);
1580 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
1581 } else if (type == DEATH_CHEAT) {
1582 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1584 print ("^1",s1, "^1 unfairly eliminated themself\n");
1585 } else if (type == DEATH_FIRE) {
1586 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1588 print ("^1",s1, "^1 burned to death\n");
1589 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
1590 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1592 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
1595 if (stof(s2) > 2) // killcount > 2
1596 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
1597 } else if(msg == MSG_KILL) {
1598 w = DEATH_WEAPONOF(type);
1600 if((w == WEP_CAMPINGRIFLE || w == WEP_MINSTANEX) && type & HITTYPE_HEADSHOT) // all headshot weapons go here
1601 HUD_KillNotify_Push(s1, s2, 1, DEATH_HEADSHOT);
1603 HUD_KillNotify_Push(s1, s2, 1, type);
1606 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
1608 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
1609 HUD_KillNotify_Push(s1, s2, 1, type);
1613 print ("^1", s1, "^1 took action against a team mate\n");
1615 print ("^1", s1, "^1 mows down a team mate\n");
1618 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
1620 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
1622 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
1624 else if (stof(s2) > 2) {
1626 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
1628 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
1631 else if(type == KILL_FIRST_BLOOD)
1632 print("^1",s1, "^1 drew first blood", "\n");
1633 else if (type == DEATH_TELEFRAG) {
1634 HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
1636 print ("^1",s2, "^1 tried to occupy ", s1, "^1's teleport destination space\n");
1638 print ("^1",s2, "^1 was telefragged by ", s1, "\n");
1640 else if (type == DEATH_DROWN) {
1641 HUD_KillNotify_Push(s1, s2, 1, DEATH_DROWN);
1643 print ("^1",s2, "^1 was drowned by ", s1, "\n");
1645 else if (type == DEATH_SLIME) {
1646 HUD_KillNotify_Push(s1, s2, 1, DEATH_SLIME);
1648 print ("^1",s2, "^1 was slimed by ", s1, "\n");
1650 else if (type == DEATH_LAVA) {
1651 HUD_KillNotify_Push(s1, s2, 1, DEATH_LAVA);
1653 print ("^1",s2, "^1 was cooked by ", s1, "\n");
1655 else if (type == DEATH_FALL) {
1656 HUD_KillNotify_Push(s1, s2, 1, DEATH_FALL);
1658 print ("^1",s2, "^1 was grounded by ", s1, "\n");
1660 else if (type == DEATH_SHOOTING_STAR) {
1661 HUD_KillNotify_Push(s1, s2, 1, DEATH_SHOOTING_STAR);
1663 print ("^1",s2, "^1 was shot into space by ", s1, "\n");
1665 else if (type == DEATH_SWAMP) {
1666 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1668 print ("^1",s2, "^1 was conserved by ", s1, "\n");
1670 else if (type == DEATH_HURTTRIGGER)
1672 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1674 print("^1",s2, "^1 was thrown into a world of hurt by ", s1, "\n");
1675 } else if(type == DEATH_SBCRUSH) {
1676 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1678 print ("^1",s2, "^1 was crushed by ^1", s1, "\n");
1679 } else if(type == DEATH_SBMINIGUN) {
1680 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1682 print ("^1",s2, "^1 got shredded by ^1", s1, "\n");
1683 } else if(type == DEATH_SBROCKET) {
1684 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1686 print ("^1",s2, "^1 was blased to bits by ^1", s1, "\n");
1687 } else if(type == DEATH_SBBLOWUP) {
1688 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1690 print ("^1",s2, "^1 got caught in the destruction of ^1", s1, "'s vehicle\n");
1691 } else if(type == DEATH_WAKIGUN) {
1692 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1694 print ("^1",s2, "^1 was bolted down by ^1", s1, "\n");
1695 } else if(type == DEATH_WAKIROCKET) {
1696 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1698 print ("^1",s2, "^1 could find no shelter from ^1", s1, "'s rockets\n");
1699 } else if(type == DEATH_WAKIBLOWUP) {
1700 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1702 print ("^1",s2, "^1 dies when ^1", s1, "'s wakizashi dies.\n");
1703 } else if(type == DEATH_TURRET) {
1704 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1706 print ("^1",s2, "^1 was pushed into the line of fire by ^1", s1, "\n");
1707 } else if(type == DEATH_TOUCHEXPLODE) {
1708 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1710 print ("^1",s2, "^1 was pushed into an accident by ^1", s1, "\n");
1711 } else if(type == DEATH_CHEAT) {
1712 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1714 print ("^1",s2, "^1 was unfairly eliminated by ^1", s1, "\n");
1715 } else if (type == DEATH_FIRE) {
1716 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1718 print ("^1",s2, "^1 was burnt to death by ^1", s1, "\n");
1719 } else if (type == DEATH_CUSTOM) {
1720 HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM);
1722 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1723 } else if (type == DEATH_HURTTRIGGER) {
1724 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1726 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1728 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1730 print ("^1",s2, "^1 was fragged by ", s1, "\n");
1732 } else if(msg == MSG_SPREE) {
1733 if(type == KILL_END_SPREE) {
1735 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
1737 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
1738 } else if(type == KILL_SPREE) {
1740 print ("^1",s1,"^1 made ",s2," scores in a row\n");
1742 print ("^1",s1,"^1 has ",s2," frags in a row\n");
1743 } else if(type == KILL_SPREE_3) {
1745 print (s1,"^7 made a ^1TRIPLE SCORE\n");
1747 print (s1,"^7 made a ^1TRIPLE FRAG\n");
1748 } else if(type == KILL_SPREE_5) {
1750 print (s1,"^7 unleashes ^1SCORING RAGE\n");
1752 print (s1,"^7 unleashes ^1RAGE\n");
1753 } else if(type == KILL_SPREE_10) {
1755 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
1757 print (s1,"^7 starts the ^1MASSACRE!\n");
1758 } else if(type == KILL_SPREE_15) {
1760 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
1762 print (s1,"^7 executes ^1MAYHEM!\n");
1763 } else if(type == KILL_SPREE_20) {
1765 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
1767 print (s1,"^7 is a ^1BERSERKER!\n");
1768 } else if(type == KILL_SPREE_25) {
1770 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
1772 print (s1,"^7 inflicts ^1CARNAGE!\n");
1773 } else if(type == KILL_SPREE_30) {
1775 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
1777 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
1779 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
1780 if (type == DEATH_DROWN) {
1781 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
1785 print ("^1",s1, "^1 was in the water for too long\n");
1787 print ("^1",s1, "^1 drowned\n");
1789 } else if (type == DEATH_SLIME) {
1790 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
1792 print ("^1",s1, "^1 was slimed\n");
1793 } else if (type == DEATH_LAVA) {
1794 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
1798 print ("^1",s1, "^1 found a hot place\n");
1800 print ("^1",s1, "^1 turned into hot slag\n");
1802 } else if (type == DEATH_FALL) {
1803 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1807 print ("^1",s1, "^1 tested gravity (and it worked)\n");
1809 print ("^1",s1, "^1 hit the ground with a crunch\n");
1811 } else if (type == DEATH_SHOOTING_STAR) {
1812 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
1814 print ("^1",s1, "^1 became a shooting star\n");
1815 } else if (type == DEATH_SWAMP) {
1816 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1820 print ("^1",s1, "^1 discovered a swamp\n");
1822 print ("^1",s1, "^1 is now conserved for centuries to come\n");
1824 } else if(type == DEATH_TURRET) {
1825 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1827 print ("^1",s1, "^1 was mowed down by a turret \n");
1828 } else if (type == DEATH_CUSTOM) {
1829 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
1831 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1832 } else if (type == DEATH_HURTTRIGGER) {
1833 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
1835 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1836 } else if(type == DEATH_TOUCHEXPLODE) {
1837 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1839 print ("^1",s1, "^1 died in an accident\n");
1840 } else if(type == DEATH_CHEAT) {
1841 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1843 print ("^1",s1, "^1 was unfairly eliminated\n");
1844 } else if(type == DEATH_FIRE) {
1845 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1849 print ("^1",s1, "^1 felt a little hot\n");
1851 print ("^1",s1, "^1 burnt to death\n");
1854 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1858 print ("^1",s1, "^1 needs a restart\n");
1860 print ("^1",s1, "^1 died\n");
1863 } else if(msg == MSG_KILL_ACTION_SPREE) {
1865 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
1867 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
1868 } else if(msg == MSG_INFO) {
1869 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
1870 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
1871 print(s1, "^7 got the ", s2, "\n");
1872 } else if(type == INFO_LOSTFLAG) {
1873 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
1874 print(s1, "^7 lost the ", s2, "\n");
1875 } else if(type == INFO_PICKUPFLAG) {
1876 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
1877 print(s1, "^7 picked up the ", s2, "\n");
1878 } else if(type == INFO_RETURNFLAG) {
1879 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
1880 print(s1, "^7 returned the ", s2, "\n");
1881 } else if(type == INFO_CAPTUREFLAG) {
1882 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
1883 print(s1, "^7 captured the ", s2, s3, "\n");
1885 } else if(msg == MSG_RACE) {
1886 if(type == RACE_SERVER_RECORD) {
1887 HUD_KillNotify_Push(s1, s2, 1, RACE_SERVER_RECORD);
1889 else if(type == RACE_NEW_RANK) {
1890 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_RANK);
1892 else if(type == RACE_NEW_TIME) {
1893 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_TIME);
1895 else if(type == RACE_FAIL) {
1896 HUD_KillNotify_Push(s1, s2, 1, RACE_FAIL);
1898 } else if(msg == MSG_KA) {
1899 if(type == KA_PICKUPBALL) {
1900 HUD_KillNotify_Push(s1, s2, 0, KA_PICKUPBALL);
1902 print (s1, "^7 has picked up the ball!\n");
1904 else if(type == KA_DROPBALL) {
1905 HUD_KillNotify_Push(s1, s2, 0, KA_DROPBALL);
1907 print(s1, "^7 has dropped the ball!\n");
1912 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
1914 void HUD_Centerprint(string s1, string s2, float type, float msg)
1917 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
1918 if(msg == MSG_SUICIDE) {
1919 if (type == DEATH_TEAMCHANGE) {
1920 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
1921 } else if (type == DEATH_AUTOTEAMCHANGE) {
1922 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
1923 } else if (type == DEATH_CAMP) {
1925 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
1927 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
1928 } else if (type == DEATH_NOAMMO) {
1930 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
1932 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
1933 } else if (type == DEATH_ROT) {
1935 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
1937 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
1938 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
1940 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
1942 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
1943 } else if (type == DEATH_QUIET) {
1945 } else { // generic message
1947 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
1949 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
1951 } else if(msg == MSG_KILL) {
1952 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
1954 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
1956 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
1958 } else if (type == KILL_FIRST_BLOOD) {
1960 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
1962 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
1964 } else if (type == KILL_FIRST_VICTIM) {
1966 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
1968 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
1970 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
1972 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
1974 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
1976 } else if (type == KILL_TYPEFRAGGED) {
1978 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
1980 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
1982 } else if (type == KILL_FRAG) {
1984 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
1986 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
1988 } else { // generic message
1990 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
1992 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
1995 } else if(msg == MSG_KILL_ACTION) {
1996 // TODO: invent more centerprints here?
1997 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2001 void HUD_Notify (void)
2003 if(!autocvar__hud_configure)
2005 if(!autocvar_hud_panel_notify) return;
2008 hud_configure_active_panel = HUD_PANEL_NOTIFY;
2010 HUD_Panel_UpdateCvars(notify);
2013 mySize = panel_size;
2015 HUD_Panel_DrawBg(1);
2016 if(panel_bg_padding)
2018 pos += '1 1 0' * panel_bg_padding;
2019 mySize -= '2 2 0' * panel_bg_padding;
2022 float entries, height;
2023 entries = bound(1, floor(KN_MAX_ENTRIES * mySize_y/mySize_x), KN_MAX_ENTRIES);
2024 height = mySize_y/entries;
2027 fontsize = '0.5 0.5 0' * height;
2031 when = autocvar_hud_panel_notify_time;
2033 fadetime = autocvar_hud_panel_notify_fadetime;
2037 vector pos_attacker, pos_victim;
2039 float width_attacker;
2040 string attacker, victim;
2042 float i, j, w, step, limit;
2043 if(autocvar_hud_panel_notify_flip) //order items from the top down
2049 else //order items from the bottom up
2056 for(j = kn_index; i != limit; i += step, ++j)
2058 if(autocvar__hud_configure)
2062 else // inverse order
2063 a = entries - 1 - i;
2064 attacker = textShortenToWidth(strcat("Player", ftos(a+1)), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2065 victim = textShortenToWidth(strcat("Player", ftos(a+2)), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2066 s = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname);
2067 a = bound(0, (when - a) / 4, 1);
2068 goto hud_config_notifyprint;
2071 if (j == KN_MAX_ENTRIES)
2074 if(killnotify_times[j] + when > time)
2078 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2092 w = DEATH_WEAPONOF(killnotify_deathtype[j]);
2094 // TODO: maybe print in team colors?
2097 if(killnotify_actiontype[j] == 0)
2099 if(killnotify_deathtype[j] == DEATH_GENERIC)
2103 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2105 s = "notify_outofammo";
2107 else if(killnotify_deathtype[j] == DEATH_KILL)
2109 s = "notify_selfkill";
2111 else if(killnotify_deathtype[j] == DEATH_CAMP)
2113 s = "notify_camping";
2115 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2117 s = "notify_teamkill_red";
2119 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2121 s = "notify_teamkill_blue";
2123 else if(killnotify_deathtype[j] == DEATH_DROWN)
2127 else if(killnotify_deathtype[j] == DEATH_SLIME)
2131 else if(killnotify_deathtype[j] == DEATH_LAVA)
2135 else if(killnotify_deathtype[j] == DEATH_FALL)
2139 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2141 s = "notify_shootingstar";
2143 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2147 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2149 if(killnotify_victims[j] == "^1RED^7 flag")
2151 s = "notify_red_taken";
2155 s = "notify_blue_taken";
2158 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2160 if(killnotify_victims[j] == "^1RED^7 flag")
2162 s = "notify_red_returned";
2166 s = "notify_blue_returned";
2169 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2171 if(killnotify_victims[j] == "^1RED^7 flag")
2173 s = "notify_red_lost";
2177 s = "notify_blue_lost";
2180 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
2182 if(killnotify_victims[j] == "^1RED^7 flag")
2184 s = "notify_red_captured";
2188 s = "notify_blue_captured";
2191 else if(killnotify_deathtype[j] == KA_DROPBALL)
2193 s = "notify_balldropped";
2195 else if(killnotify_deathtype[j] == KA_PICKUPBALL)
2197 s = "notify_ballpickedup";
2200 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2201 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
2202 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2206 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2207 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2210 // X [did action to] Y
2213 if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
2215 s = "notify_melee_laser";
2217 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_SHOTGUN)
2219 s = "notify_melee_shotgun";
2221 else if(WEP_VALID(w))
2223 self = get_weaponinfo(w);
2224 s = strcat("weapon", self.netname);
2226 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2228 s = "notify_teamkill_red";
2230 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2232 s = "notify_teamkill_red";
2234 else if(killnotify_deathtype[j] == DEATH_TELEFRAG)
2236 s = "notify_telefrag";
2238 else if(killnotify_deathtype[j] == DEATH_DROWN)
2242 else if(killnotify_deathtype[j] == DEATH_SLIME)
2246 else if(killnotify_deathtype[j] == DEATH_LAVA)
2250 else if(killnotify_deathtype[j] == DEATH_FALL)
2254 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2256 s = "notify_shootingstar";
2258 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2262 else if(killnotify_deathtype[j] == DEATH_HEADSHOT)
2264 s = "notify_headshot";
2266 else if(killnotify_deathtype[j] == RACE_SERVER_RECORD)
2268 s = "race_newrecordserver";
2270 else if(killnotify_deathtype[j] == RACE_NEW_RANK)
2272 s = "race_newrankyellow";
2274 else if(killnotify_deathtype[j] == RACE_NEW_TIME)
2278 else if(killnotify_deathtype[j] == RACE_FAIL)
2283 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2284 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2285 :hud_config_notifyprint
2286 width_attacker = stringwidth(attacker, TRUE, fontsize);
2287 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
2288 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
2289 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2293 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2294 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2295 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2304 string seconds_tostring(float sec)
2307 minutes = floor(sec / 60);
2309 sec -= minutes * 60;
2312 s = ftos(100 + sec);
2314 return strcat(ftos(minutes), ":", substring(s, 1, 3));
2317 void HUD_Timer(void)
2319 if(!autocvar__hud_configure)
2321 if(!autocvar_hud_panel_timer) return;
2324 hud_configure_active_panel = HUD_PANEL_TIMER;
2326 HUD_Panel_UpdateCvars(timer);
2329 mySize = panel_size;
2331 HUD_Panel_DrawBg(1);
2332 if(panel_bg_padding)
2334 pos += '1 1 0' * panel_bg_padding;
2335 mySize -= '2 2 0' * panel_bg_padding;
2339 float timelimit, elapsedTime, timeleft, minutesLeft;
2341 timelimit = getstatf(STAT_TIMELIMIT);
2343 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
2344 timeleft = ceil(timeleft);
2346 minutesLeft = floor(timeleft / 60);
2349 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
2350 timer_color = '1 1 1'; //white
2351 else if(minutesLeft >= 1)
2352 timer_color = '1 1 0'; //yellow
2354 timer_color = '1 0 0'; //red
2356 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
2357 if (time < getstatf(STAT_GAMESTARTTIME)) {
2358 //while restart is still active, show 00:00
2359 timer = seconds_tostring(0);
2361 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
2362 timer = seconds_tostring(elapsedTime);
2365 timer = seconds_tostring(timeleft);
2368 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2373 void HUD_Radar(void)
2375 if (!autocvar__hud_configure)
2377 if (autocvar_hud_panel_radar == 0) return;
2378 if (autocvar_hud_panel_radar != 2 && !teamplay) return;
2381 hud_configure_active_panel = HUD_PANEL_RADAR;
2383 HUD_Panel_UpdateCvars(radar);
2386 mySize = panel_size;
2388 HUD_Panel_DrawBg(1);
2389 if(panel_bg_padding)
2391 pos += '1 1 0' * panel_bg_padding;
2392 mySize -= '2 2 0' * panel_bg_padding;
2397 float scale2d, normalsize, bigsize;
2400 teamradar_origin2d = pos + 0.5 * mySize;
2401 teamradar_size2d = mySize;
2403 if(minimapname == "")
2406 teamradar_loadcvars();
2408 switch(hud_panel_radar_zoommode)
2412 f = current_zoomfraction;
2415 f = 1 - current_zoomfraction;
2425 switch(hud_panel_radar_rotation)
2428 teamradar_angle = view_angles_y - 90;
2431 teamradar_angle = 90 * hud_panel_radar_rotation;
2435 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
2436 teamradar_size2d = mySize;
2438 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
2440 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
2441 if(hud_panel_radar_rotation == 0)
2443 // max-min distance must fit the radar in any rotation
2444 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_scale));
2448 vector c0, c1, c2, c3, span;
2449 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
2450 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
2451 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
2452 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
2454 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
2455 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
2457 // max-min distance must fit the radar in x=x, y=y
2459 teamradar_size2d_x * scale2d / (1.05 * span_x),
2460 teamradar_size2d_y * scale2d / (1.05 * span_y)
2464 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
2465 if(bigsize > normalsize)
2466 normalsize = bigsize;
2470 + (1 - f) * normalsize;
2471 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
2473 + (1 - f) * view_origin);
2482 draw_teamradar_background(hud_panel_radar_foreground_alpha);
2484 for(tm = world; (tm = find(tm, classname, "radarlink")); )
2485 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
2486 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
2487 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
2488 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
2490 color2 = GetPlayerColor(tm.sv_entnum);
2491 //if(color == COLOR_SPECTATOR || color == color2)
2492 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
2494 draw_teamradar_player(view_origin, view_angles, '1 1 1');
2496 drawresetcliparea();
2501 void HUD_UpdatePlayerTeams();
2502 void HUD_Score(void)
2504 if(!autocvar__hud_configure)
2506 if(!autocvar_hud_panel_score) return;
2507 if(spectatee_status == -1 && (gametype == GAME_RACE || gametype == GAME_CTS)) return;
2510 hud_configure_active_panel = HUD_PANEL_SCORE;
2512 HUD_Panel_UpdateCvars(score);
2515 mySize = panel_size;
2517 HUD_Panel_DrawBg(1);
2518 if(panel_bg_padding)
2520 pos += '1 1 0' * panel_bg_padding;
2521 mySize -= '2 2 0' * panel_bg_padding;
2524 float score, distribution;
2526 vector distribution_color;
2528 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
2530 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
2531 string timer, distrtimer;
2533 pl = players.sort_next;
2536 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
2537 if(pl.scores[ps_primary] == 0)
2540 score = me.(scores[ps_primary]);
2541 timer = TIME_ENCODED_TOSTRING(score);
2543 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
2544 // distribution display
2545 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2547 distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS);
2549 if (distribution <= 0) {
2550 distribution_color = '0 1 0';
2554 distribution_color = '1 0 0';
2557 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);
2559 // race record display
2560 if (distribution <= 0)
2561 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2562 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2563 } else if (!teamplay) { // non-teamgames
2564 if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings)
2566 #define SCOREPANEL_MAX_ENTRIES 6
2567 #define SCOREPANEL_ASPECTRATIO 2
2568 const float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
2569 const float height = mySize_y/entries;
2570 const vector fontsize = '0.9 0.9 0' * height;
2571 pos_y += height * (1 - 0.9) / 2;
2576 const float name_size = mySize_x*0.75;
2577 const float highlight_alpha = 0.2;
2578 float i, me_printed;
2580 if (autocvar__hud_configure)
2582 score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
2583 for (i=0; i<entries; ++i)
2585 //simulate my score is lower than all displayed players,
2586 //so that I don't appear at all showing pure rankings.
2587 //This is to better show the difference between the 2 ranking views
2588 if (i == entries-1 && autocvar_hud_panel_score_rankings == 1)
2591 drawfill(pos - eY * (height * (1 - 0.9) / 2), eX * mySize_x + eY * height, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2592 s = GetPlayerName(pl.sv_entnum);
2597 s = strcat("Player", ftos(i+1));
2601 s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
2602 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2603 drawstring(pos + eX * mySize_x*0.79, ftos(score), fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2609 if (!scoreboard_fade_alpha) // the scoreboard too calls HUD_UpdatePlayerTeams
2610 HUD_UpdatePlayerTeams();
2612 for (pl = players.sort_next, i=0; pl && i<entries; pl = pl.sort_next, ++i)
2614 if (pl.team == COLOR_SPECTATOR)
2617 if (i == entries-1 && !me_printed && pl != me)
2618 if (autocvar_hud_panel_score_rankings == 1 && spectatee_status != -1)
2620 for (pl = me.sort_next; pl; pl = pl.sort_next)
2621 if (pl.team != COLOR_SPECTATOR)
2625 rgb = '1 1 0'; //not last but not among the leading players: yellow
2627 rgb = '1 0 0'; //last: red
2634 rgb = '0 1 0'; //first: green
2636 drawfill(pos - eY * (height * (1 - 0.9) / 2), eX * mySize_x + eY * height, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2638 s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
2639 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2640 drawstring(pos + eX * mySize_x*0.79, ftos(pl.(scores[ps_primary])), fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2645 // me vector := [team/connected frags id]
2646 pl = players.sort_next;
2650 if(autocvar__hud_configure)
2653 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2657 score = me.(scores[ps_primary]);
2658 if(autocvar__hud_configure)
2661 if(distribution >= 5)
2662 distribution_color = eY;
2663 else if(distribution >= 0)
2664 distribution_color = '1 1 1';
2665 else if(distribution >= -5)
2666 distribution_color = '1 1 0';
2668 distribution_color = eX;
2670 string distribution_str;
2671 distribution_str = ftos(distribution);
2672 if (distribution >= 0)
2674 if (distribution > 0)
2675 distribution_str = strcat("+", distribution_str);
2676 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2678 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2679 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);
2680 } else { // teamgames
2681 float max_fragcount;
2682 max_fragcount = -99;
2684 float scores_count, row, column, rows, columns;
2686 vector score_pos, score_size; //for scores other than myteam
2687 if (spectatee_status == -1)
2689 if (autocvar__hud_configure)
2691 else for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2692 if(tm.team == COLOR_SPECTATOR)
2696 rows = mySize_y/mySize_x;
2697 rows = bound(1, floor((sqrt(4 * (3/1) * rows * scores_count + rows * rows) + rows + 0.5) / 2), scores_count);
2698 // ^^^ ammo item aspect goes here
2700 columns = ceil(scores_count/rows);
2702 score_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
2705 if(score_size_x/score_size_y > 3)
2707 newSize = 3 * score_size_y;
2708 offset_x = score_size_x - newSize;
2709 pos_x += offset_x/2;
2710 score_size_x = newSize;
2714 newSize = 1/3 * score_size_x;
2715 offset_y = score_size_y - newSize;
2716 pos_y += offset_y/2;
2717 score_size_y = newSize;
2721 score_size = eX * mySize_x*(1/4) + eY * mySize_y*(1/3);
2722 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2723 if(tm.team == COLOR_SPECTATOR)
2725 score = tm.(teamscores[ts_primary]);
2726 if(autocvar__hud_configure)
2729 if (score > max_fragcount)
2730 max_fragcount = score;
2732 if (spectatee_status == -1)
2734 score_pos = pos + eX * column * (score_size_x + offset_x) + eY * row * (score_size_y + offset_y);
2735 if (max_fragcount == score)
2736 HUD_Panel_DrawHighlight(score_pos, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2737 drawstring_aspect(score_pos, ftos(score), score_size, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2745 else if(tm.team == myteam) {
2746 if (max_fragcount == score)
2747 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2748 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2750 if (max_fragcount == score)
2751 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);
2752 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);
2761 void HUD_RaceTimer (void)
2763 if(!autocvar__hud_configure)
2765 if(!autocvar_hud_panel_racetimer) return;
2766 if(!(gametype == GAME_RACE || gametype == GAME_CTS)) return;
2767 if(spectatee_status == -1) return;
2770 hud_configure_active_panel = HUD_PANEL_RACETIMER;
2772 HUD_Panel_UpdateCvars(racetimer);
2775 mySize = panel_size;
2777 HUD_Panel_DrawBg(1);
2778 if(panel_bg_padding)
2780 pos += '1 1 0' * panel_bg_padding;
2781 mySize -= '2 2 0' * panel_bg_padding;
2784 // always force 4:1 aspect
2786 if(mySize_x/mySize_y > 4)
2788 newSize_x = 4 * mySize_y;
2789 newSize_y = mySize_y;
2791 pos_x = pos_x + (mySize_x - newSize_x) / 2;
2795 newSize_y = 1/4 * mySize_x;
2796 newSize_x = mySize_x;
2798 pos_y = pos_y + (mySize_y - newSize_y) / 2;
2803 string s, forcetime;
2805 if(autocvar__hud_configure)
2808 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);
2809 s = "^1Intermediate 1 (+15.42)";
2810 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);
2811 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
2812 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);
2814 else if(race_checkpointtime)
2816 a = bound(0, 2 - (time - race_checkpointtime), 1);
2819 if(a > 0) // just hit a checkpoint?
2821 if(race_checkpoint != 254)
2823 if(race_time && race_previousbesttime)
2824 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
2826 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
2828 forcetime = TIME_ENCODED_TOSTRING(race_time);
2833 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
2835 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
2836 if(a > 0) // next one?
2838 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
2843 if(s != "" && a > 0)
2845 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);
2848 if(race_penaltytime)
2850 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
2853 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
2854 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);
2860 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
2861 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);
2866 if(race_laptime && race_checkpoint != 255)
2868 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
2869 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);
2874 if(race_mycheckpointtime)
2876 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
2877 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
2878 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);
2880 if(race_othercheckpointtime && race_othercheckpointenemy != "")
2882 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
2883 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
2884 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);
2887 if(race_penaltytime && !race_penaltyaccumulator)
2889 t = race_penaltytime * 0.1 + race_penaltyeventtime;
2890 a = bound(0, (1 + t - time), 1);
2894 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
2896 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
2897 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);
2905 float vote_yescount;
2908 float vote_highlighted; // currently selected vote
2910 float vote_active; // is there an active vote?
2911 float vote_prev; // previous state of vote_active to check for a change
2913 float vote_change; // "time" when vote_active changed
2915 void HUD_VoteWindow(void)
2917 if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
2920 if (autocvar__hud_configure)
2924 print("^1You have to answer before entering hud configure mode\n");
2925 cvar_set("_hud_configure", "0");
2927 vote_called_vote = strzone("^2Name ^7instead of \"^1Unregistered player^7\" in stats");
2928 uid2name_dialog = 1;
2931 if(!autocvar__hud_configure)
2933 if(!autocvar_hud_panel_vote) return;
2935 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
2936 panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha;
2938 if(panel_bg_alpha_str == "") {
2939 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
2941 panel_bg_alpha = stof(panel_bg_alpha_str);
2945 hud_configure_active_panel = HUD_PANEL_VOTE;
2954 if(vote_active != vote_prev) {
2956 vote_prev = vote_active;
2959 if(vote_active || autocvar__hud_configure)
2960 vote_alpha = bound(0, (time - vote_change) * 2, 1);
2962 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
2967 HUD_Panel_UpdateCvars(vote);
2971 panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight;
2972 panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight;
2975 // these must be below above block
2978 mySize = panel_size;
2980 a = vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
2981 HUD_Panel_DrawBg(a);
2982 a = panel_fg_alpha * a;
2984 if(panel_bg_padding)
2986 pos += '1 1 0' * panel_bg_padding;
2987 mySize -= '2 2 0' * panel_bg_padding;
2990 // always force 3:1 aspect
2992 if(mySize_x/mySize_y > 3)
2994 newSize_x = 3 * mySize_y;
2995 newSize_y = mySize_y;
2997 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3001 newSize_y = 1/3 * mySize_x;
3002 newSize_x = mySize_x;
3004 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3008 s = "A vote has been called for:";
3010 s = "Allow servers to store and display your name?";
3011 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3012 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1/8), stringwidth_colors);
3013 if(autocvar__hud_configure)
3014 s = "^1Configure the HUD";
3015 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
3017 // print the yes/no counts
3018 s = strcat("Yes (", getcommandkey("vyes", "vyes"), "): ", ftos(vote_yescount));
3019 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);
3020 s = strcat("No (", getcommandkey("vno", "vno"), "): ", ftos(vote_nocount));
3021 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);
3023 // draw the progress bar backgrounds
3024 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3026 // draw the highlights
3027 if(vote_highlighted == 1) {
3028 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3029 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3031 else if(vote_highlighted == 2) {
3032 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3033 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3036 // draw the progress bars
3037 if(vote_yescount && vote_needed)
3039 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3040 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3043 if(vote_nocount && vote_needed)
3045 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3046 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3049 drawresetcliparea();
3052 vote_highlighted = 0;
3056 // Mod icons panel (#10)
3059 float mod_active; // is there any active mod icon?
3061 // Clan Arena HUD modicons
3062 void HUD_Mod_CA(vector pos, vector mySize)
3064 mod_active = 1; // CA should never hide the mod icons panel
3065 float redalive, bluealive;
3066 redalive = getstati(STAT_REDALIVE);
3067 bluealive = getstati(STAT_BLUEALIVE);
3069 vector redpos, bluepos;
3070 if(mySize_x > mySize_y)
3073 bluepos = pos + eY * 0.5 * mySize_y;
3074 drawpic_aspect_skin(redpos, "player_red.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3075 drawstring_aspect(redpos + eX * 0.5 * mySize_x, ftos(redalive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3076 drawpic_aspect_skin(bluepos, "player_blue.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3077 drawstring_aspect(bluepos + eX * 0.5 * mySize_x, ftos(bluealive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3082 bluepos = pos + eY * 0.5 * mySize_y;
3083 drawpic_aspect_skin(redpos, "player_red.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3084 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);
3085 drawpic_aspect_skin(bluepos, "player_blue.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3086 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);
3090 // CTF HUD modicon section
3091 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3092 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3093 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3095 void HUD_Mod_CTF_Reset(void)
3097 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3100 void HUD_Mod_CTF(vector pos, vector mySize)
3102 vector redflag_pos, blueflag_pos;
3104 float f; // every function should have that
3106 float redflag, blueflag; // current status
3107 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3110 stat_items = getstati(STAT_ITEMS);
3111 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3112 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3114 if(redflag || blueflag)
3119 if(autocvar__hud_configure)
3125 // when status CHANGES, set old status into prevstatus and current status into status
3126 if (redflag != redflag_prevframe)
3128 redflag_statuschange_time = time;
3129 redflag_prevstatus = redflag_prevframe;
3130 redflag_prevframe = redflag;
3133 if (blueflag != blueflag_prevframe)
3135 blueflag_statuschange_time = time;
3136 blueflag_prevstatus = blueflag_prevframe;
3137 blueflag_prevframe = blueflag;
3140 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3141 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3143 float BLINK_FACTOR = 0.15;
3144 float BLINK_BASE = 0.85;
3146 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3148 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3150 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3152 string red_icon, red_icon_prevstatus;
3153 float red_alpha, red_alpha_prevstatus;
3154 red_alpha = red_alpha_prevstatus = 1;
3156 case 1: red_icon = "flag_red_taken"; break;
3157 case 2: red_icon = "flag_red_lost"; break;
3158 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3160 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3161 red_icon = "flag_red_shielded";
3163 red_icon = string_null;
3166 switch(redflag_prevstatus) {
3167 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3168 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3169 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3172 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3173 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3174 red_icon_prevstatus = "flag_red_shielded";
3176 red_icon_prevstatus = string_null;
3180 string blue_icon, blue_icon_prevstatus;
3181 float blue_alpha, blue_alpha_prevstatus;
3182 blue_alpha = blue_alpha_prevstatus = 1;
3184 case 1: blue_icon = "flag_blue_taken"; break;
3185 case 2: blue_icon = "flag_blue_lost"; break;
3186 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3188 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3189 blue_icon = "flag_blue_shielded";
3191 blue_icon = string_null;
3194 switch(blueflag_prevstatus) {
3195 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3196 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3197 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3200 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3201 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3202 blue_icon_prevstatus = "flag_blue_shielded";
3204 blue_icon_prevstatus = string_null;
3208 if(mySize_x > mySize_y) {
3209 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3211 blueflag_pos = pos + eX * 0.5 * mySize_x;
3214 redflag_pos = pos + eX * 0.5 * mySize_x;
3216 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3218 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3220 blueflag_pos = pos + eY * 0.5 * mySize_y;
3223 redflag_pos = pos + eY * 0.5 * mySize_y;
3225 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3228 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3229 if(red_icon_prevstatus && f < 1)
3230 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3232 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3234 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3235 if(blue_icon_prevstatus && f < 1)
3236 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3238 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3241 // Keyhunt HUD modicon section
3242 float kh_runheretime;
3244 void HUD_Mod_KH_Reset(void)
3249 void HUD_Mod_KH(vector pos, vector mySize)
3251 mod_active = 1; // keyhunt should never hide the mod icons panel
3255 vector p, pa, kh_size, kh_asize;
3257 kh_keys = getstati(STAT_KH_KEYS);
3260 if(mySize_x > mySize_y)
3262 p_y = pos_y + 0.25 * mySize_y;
3263 pa = p - eY * 0.25 * mySize_y;
3265 kh_size_x = mySize_x * 0.25;
3266 kh_size_y = 0.75 * mySize_y;
3267 kh_asize_x = mySize_x * 0.25;
3268 kh_asize_y = mySize_y * 0.25;
3272 p_y = pos_y + 0.125 * mySize_y;
3273 pa = p - eY * 0.125 * mySize_y;
3275 kh_size_x = mySize_x * 0.5;
3276 kh_size_y = 0.375 * mySize_y;
3277 kh_asize_x = mySize_x * 0.5;
3278 kh_asize_y = mySize_y * 0.125;
3285 for(i = 0; i < 4; ++i)
3287 key = floor(kh_keys / pow(32, i)) & 31;
3289 if(keyteam == 30 && keycount <= 4)
3291 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3295 // this yields 8 exactly if "RUN HERE" shows
3300 kh_runheretime = time;
3301 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3306 for(i = 0; i < 4; ++i)
3308 key = floor(kh_keys / pow(32, i)) & 31;
3321 default: // owned or dropped
3326 a = a * panel_fg_alpha;
3327 aa = aa * panel_fg_alpha;
3333 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3336 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3339 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3342 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3347 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3350 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3353 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3356 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3359 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3363 if(mySize_x > mySize_y)
3365 p_x += 0.25 * mySize_x;
3366 pa_x += 0.25 * mySize_x;
3372 p_y = pos_y + 0.625 * mySize_y;
3373 pa_y = pos_y + 0.5 * mySize_y;
3379 p_x += 0.5 * mySize_x;
3380 pa_x += 0.5 * mySize_x;
3386 // Keepaway HUD mod icon
3387 float kaball_prevstatus; // last remembered status
3388 float kaball_statuschange_time; // time when the status changed
3390 // we don't need to reset for keepaway since it immediately
3391 // autocorrects prevstatus as to if the player has the ball or not
3393 void HUD_Mod_Keepaway(vector pos, vector mySize)
3395 mod_active = 1; // keepaway should always show the mod HUD
3397 float BLINK_FACTOR = 0.15;
3398 float BLINK_BASE = 0.85;
3399 float BLINK_FREQ = 5;
3400 float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
3402 float stat_items = getstati(STAT_ITEMS);
3403 float kaball = (stat_items/IT_KEY1) & 1;
3405 if(kaball != kaball_prevstatus)
3407 kaball_statuschange_time = time;
3408 kaball_prevstatus = kaball;
3411 // todo: Fix the sizing with the expanding image
3413 float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
3414 float f = bound(0, kaball_statuschange_elapsedtime*2, 1);
3416 if(kaball_prevstatus && f < 1)
3417 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);
3420 drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
3424 // Nexball HUD mod icon
3425 void HUD_Mod_NexBall(vector pos, vector mySize)
3427 float stat_items, nb_pb_starttime, dt, p;
3429 stat_items = getstati(STAT_ITEMS);
3430 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3432 if (stat_items & IT_KEY1)
3437 //Manage the progress bar if any
3438 if (nb_pb_starttime > 0)
3440 dt = mod(time - nb_pb_starttime, nb_pb_period);
3441 // one period of positive triangle
3442 p = 2 * dt / nb_pb_period;
3447 HUD_Panel_GetProgressBarColor(nexball);
3448 if(mySize_x > mySize_y)
3449 HUD_Panel_DrawProgressBar(pos, mySize, "statusbar", p, 0, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3451 HUD_Panel_DrawProgressBar(pos, mySize, "statusbar", p, 1, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3454 if (stat_items & IT_KEY1)
3455 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3458 // Race/CTS HUD mod icons
3459 float crecordtime_prev; // last remembered crecordtime
3460 float crecordtime_change_time; // time when crecordtime last changed
3461 float srecordtime_prev; // last remembered srecordtime
3462 float srecordtime_change_time; // time when srecordtime last changed
3464 float race_status_time;
3465 float race_status_prev;
3466 string race_status_name_prev;
3467 void HUD_Mod_Race(vector pos, vector mySize)
3469 mod_active = 1; // race should never hide the mod icons panel
3471 me = playerslots[player_localentnum - 1];
3473 float f; // yet another function has this
3474 score = me.(scores[ps_primary]);
3476 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3477 return; // no records in the actual race
3479 // clientside personal record
3481 if(gametype == GAME_CTS)
3485 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3487 if(score && (score < t || !t)) {
3488 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3489 if(autocvar_cl_autodemo_delete_keeprecords)
3491 f = autocvar_cl_autodemo_delete;
3493 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3497 if(t != crecordtime_prev) {
3498 crecordtime_prev = t;
3499 crecordtime_change_time = time;
3502 vector textPos, medalPos;
3504 if(mySize_x > mySize_y) {
3505 // text on left side
3506 squareSize = min(mySize_y, mySize_x/2);
3507 textPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eY * 0.5 * (mySize_y - squareSize);
3508 medalPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eX * 0.5 * mySize_x + eY * 0.5 * (mySize_y - squareSize);
3511 squareSize = min(mySize_x, mySize_y/2);
3512 textPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eX * 0.5 * (mySize_x - squareSize);
3513 medalPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eY * 0.5 * mySize_y + eX * 0.5 * (mySize_x - squareSize);
3516 f = time - crecordtime_change_time;
3519 drawstring_aspect(textPos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3520 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);
3522 drawstring_aspect(textPos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3523 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);
3524 drawstring_aspect_expanding(pos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
3525 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);
3529 t = race_server_record;
3530 if(t != srecordtime_prev) {
3531 srecordtime_prev = t;
3532 srecordtime_change_time = time;
3534 f = time - srecordtime_change_time;
3537 drawstring_aspect(textPos + eY * 0.5 * squareSize, "Server best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3538 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);
3540 drawstring_aspect(textPos + eY * 0.5 * squareSize, "Server best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3541 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);
3542 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);
3543 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);
3546 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
3547 race_status_time = time + 5;
3548 race_status_prev = race_status;
3549 if (race_status_name_prev)
3550 strunzone(race_status_name_prev);
3551 race_status_name_prev = strzone(race_status_name);
3556 a = bound(0, race_status_time - time, 1);
3559 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
3563 rank = race_CheckName(race_status_name);
3565 rankname = race_PlaceName(rank);
3568 namepos = medalPos + '0 0.8 0' * squareSize;
3570 rankpos = medalPos + '0 0.15 0' * squareSize;
3572 if(race_status == 0)
3573 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3574 else if(race_status == 1) {
3575 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);
3576 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3577 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3578 } else if(race_status == 2) {
3579 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
3580 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);
3582 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);
3583 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3584 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3585 } else if(race_status == 3) {
3586 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);
3587 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3588 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3591 if (race_status_time - time <= 0) {
3592 race_status_prev = -1;
3594 if(race_status_name)
3595 strunzone(race_status_name);
3596 race_status_name = string_null;
3597 if(race_status_name_prev)
3598 strunzone(race_status_name_prev);
3599 race_status_name_prev = string_null;
3603 void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, float layout, float i)
3605 float stat, pps_ratio;
3611 stat = getstatf(STAT_DOM_PPS_RED);
3612 pic = "dom_icon_red";
3616 stat = getstatf(STAT_DOM_PPS_BLUE);
3617 pic = "dom_icon_blue";
3621 stat = getstatf(STAT_DOM_PPS_YELLOW);
3622 pic = "dom_icon_yellow";
3626 stat = getstatf(STAT_DOM_PPS_PINK);
3627 pic = "dom_icon_pink";
3630 pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS);
3632 if(mySize_x/mySize_y > aspect_ratio)
3634 i = aspect_ratio * mySize_y;
3635 myPos_x = myPos_x + (mySize_x - i) / 2;
3640 i = 1/aspect_ratio * mySize_x;
3641 myPos_y = myPos_y + (mySize_y - i) / 2;
3645 if (layout) // show text too
3648 color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
3649 if (layout == 2) // average pps
3650 drawstring_aspect(myPos + eX * mySize_y, ftos_decimals(stat, 2), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
3651 else // percentage of average pps
3652 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);
3656 drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3659 drawsetcliparea(myPos_x, myPos_y + mySize_y * (1 - pps_ratio), mySize_y, mySize_y * pps_ratio);
3660 drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3661 drawresetcliparea();
3665 void HUD_Mod_Dom(vector myPos, vector mySize)
3667 mod_active = 1; // required in each mod function that always shows something
3670 for(tm = teams.sort_next; tm; tm = tm.sort_next)
3671 if(tm.team != COLOR_SPECTATOR)
3674 float layout = autocvar_hud_panel_modicons_dom_layout;
3675 float rows, columns, aspect_ratio;
3676 rows = mySize_y/mySize_x;
3677 aspect_ratio = (layout) ? 3 : 1;
3678 rows = bound(1, floor((sqrt((4 * aspect_ratio * teams_count + rows) * rows) + rows + 0.5) / 2), teams_count);
3679 columns = ceil(teams_count/rows);
3683 for(i=0; i<teams_count; ++i)
3685 vector pos, itemSize;
3686 pos = myPos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows);
3687 itemSize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
3689 DrawDomItem(pos, itemSize, aspect_ratio, layout, i);
3700 float mod_prev; // previous state of mod_active to check for a change
3702 float mod_change; // "time" when mod_active changed
3704 void HUD_ModIcons(void)
3706 if(!autocvar__hud_configure)
3708 if(!autocvar_hud_panel_modicons) return;
3709 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;
3712 hud_configure_active_panel = HUD_PANEL_MODICONS;
3714 HUD_Panel_UpdateCvars(modicons);
3717 mySize = panel_size;
3719 if(mod_active != mod_prev) {
3721 mod_prev = mod_active;
3724 if(mod_active || autocvar__hud_configure)
3725 mod_alpha = bound(0, (time - mod_change) * 2, 1);
3727 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
3730 HUD_Panel_DrawBg(mod_alpha);
3732 if(panel_bg_padding)
3734 pos += '1 1 0' * panel_bg_padding;
3735 mySize -= '2 2 0' * panel_bg_padding;
3738 // these MUST be ran in order to update mod_active
3739 if(gametype == GAME_KEYHUNT)
3740 HUD_Mod_KH(pos, mySize);
3741 else if(gametype == GAME_CTF || autocvar__hud_configure)
3742 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
3743 else if(gametype == GAME_NEXBALL)
3744 HUD_Mod_NexBall(pos, mySize);
3745 else if(gametype == GAME_CTS || gametype == GAME_RACE)
3746 HUD_Mod_Race(pos, mySize);
3747 else if(gametype == GAME_CA || gametype == GAME_FREEZETAG)
3748 HUD_Mod_CA(pos, mySize);
3749 else if(gametype == GAME_DOMINATION)
3750 HUD_Mod_Dom(pos, mySize);
3751 else if(gametype == GAME_KEEPAWAY)
3752 HUD_Mod_Keepaway(pos, mySize);
3755 // Draw pressed keys (#11)
3757 void HUD_DrawPressedKeys(void)
3759 if(!autocvar__hud_configure)
3761 if(!autocvar_hud_panel_pressedkeys) return;
3762 if(spectatee_status <= 0 && autocvar_hud_panel_pressedkeys < 2) return;
3765 hud_configure_active_panel = HUD_PANEL_PRESSEDKEYS;
3768 HUD_Panel_UpdateCvars(pressedkeys);
3771 mySize = panel_size;
3773 HUD_Panel_DrawBg(1);
3774 if(panel_bg_padding)
3776 pos += '1 1 0' * panel_bg_padding;
3777 mySize -= '2 2 0' * panel_bg_padding;
3780 // force custom aspect
3781 float aspect = autocvar_hud_panel_pressedkeys_aspect;
3785 if(mySize_x/mySize_y > aspect)
3787 newSize_x = aspect * mySize_y;
3788 newSize_y = mySize_y;
3790 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3794 newSize_y = 1/aspect * mySize_x;
3795 newSize_x = mySize_x;
3797 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3803 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
3805 pressedkeys = getstatf(STAT_PRESSED_KEYS);
3807 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3808 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);
3809 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);
3811 drawpic_aspect_skin(pos, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3812 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);
3813 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);
3816 // Handle chat as a panel (#12)
3820 if(!autocvar__hud_configure)
3822 if (!autocvar_hud_panel_chat)
3824 if (!autocvar_con_chatrect)
3825 cvar_set("con_chatrect", "0");
3830 hud_configure_active_panel = HUD_PANEL_CHAT;
3832 HUD_Panel_UpdateCvars(chat);
3834 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
3836 panel_pos_y = panel_bg_border;
3837 panel_size_y = vid_conheight - panel_bg_border * 2;
3838 if(panel_bg == "0") // force a border when maximized
3840 if(precache_pic(panel_bg) == "") {
3841 panel_bg = strcat(hud_skin_path, "/border_default");
3842 if(precache_pic(panel_bg) == "") {
3843 panel_bg = "gfx/hud/default/border_default";
3847 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an alpha of at least 0.75
3852 mySize = panel_size;
3854 HUD_Panel_DrawBg(1);
3856 if(panel_bg_padding)
3858 pos += '1 1 0' * panel_bg_padding;
3859 mySize -= '2 2 0' * panel_bg_padding;
3862 if (!autocvar_con_chatrect)
3863 cvar_set("con_chatrect", "1");
3865 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
3866 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
3868 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
3869 cvar_set("con_chat", ftos(floor(mySize_y/autocvar_con_chatsize - 0.5)));
3871 if(autocvar__hud_configure)
3874 chatsize = '1 1 0' * autocvar_con_chatsize;
3875 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
3877 for(i = 0; i < autocvar_con_chat; ++i)
3879 if(i == autocvar_con_chat - 1)
3882 a = panel_fg_alpha * floor(((i + 1) * 7 + autocvar_con_chattime)/45);
3883 drawcolorcodedstring(pos, textShortenToWidth("^3Player^7: This is the chat area.", mySize_x, chatsize, stringwidth_colors), chatsize, a, DRAWFLAG_NORMAL);
3884 pos_y += chatsize_y;
3889 // Engine info panel (#13)
3896 float frametimeavg1; // 1 frame ago
3897 float frametimeavg2; // 2 frames ago
3898 void HUD_EngineInfo(void)
3900 if(!autocvar__hud_configure)
3902 if(!autocvar_hud_panel_engineinfo) return;
3905 hud_configure_active_panel = HUD_PANEL_ENGINEINFO;
3907 HUD_Panel_UpdateCvars(engineinfo);
3910 mySize = panel_size;
3912 HUD_Panel_DrawBg(1);
3913 if(panel_bg_padding)
3915 pos += '1 1 0' * panel_bg_padding;
3916 mySize -= '2 2 0' * panel_bg_padding;
3919 float currentTime = gettime(GETTIME_REALTIME);
3920 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
3922 float currentframetime = currentTime - prevfps_time;
3923 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
3924 frametimeavg2 = frametimeavg1;
3925 frametimeavg1 = frametimeavg;
3928 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
3929 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.
3931 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
3932 prevfps = (1/currentframetime);
3933 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"
3935 prevfps_time = currentTime;
3940 if(currentTime - prevfps_time > autocvar_hud_panel_engineinfo_framecounter_time)
3942 prevfps = framecounter/(currentTime - prevfps_time);
3944 prevfps_time = currentTime;
3949 color = HUD_Get_Num_Color (prevfps, 100);
3950 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, autocvar_hud_panel_engineinfo_framecounter_decimals)), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
3953 // Info messages panel (#14)
3955 #define drawInfoMessage(s)\
3956 if(autocvar_hud_panel_infomessages_flip)\
3957 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);\
3958 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
3960 void HUD_InfoMessages(void)
3962 if(!autocvar__hud_configure)
3964 if(!autocvar_hud_panel_infomessages) return;
3967 hud_configure_active_panel = HUD_PANEL_INFOMESSAGES;
3969 HUD_Panel_UpdateCvars(infomessages);
3972 mySize = panel_size;
3974 HUD_Panel_DrawBg(1);
3975 if(panel_bg_padding)
3977 pos += '1 1 0' * panel_bg_padding;
3978 mySize -= '2 2 0' * panel_bg_padding;
3981 // always force 5:1 aspect
3983 if(mySize_x/mySize_y > 5)
3985 newSize_x = 5 * mySize_y;
3986 newSize_y = mySize_y;
3988 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3992 newSize_y = 1/5 * mySize_x;
3993 newSize_x = mySize_x;
3995 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4004 fontsize = '0.20 0.20 0' * mySize_y;
4007 if(spectatee_status != 0)
4013 if(!autocvar__hud_configure)
4015 if(spectatee_status && !intermission)
4017 if(spectatee_status == -1)
4020 s = strcat("^1Spectating: ^7", GetPlayerName(spectatee_status - 1));
4023 if(spectatee_status == -1)
4024 s = strcat("^1Press ^3", getcommandkey("primary fire", "+fire"), "^1 to spectate");
4026 s = strcat("^1Press ^3", getcommandkey("primary fire", "+fire"), "^1 for another player");
4029 if(spectatee_status == -1)
4030 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
4032 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+fire2"), "^1 to observe");
4035 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
4038 if(gametype == GAME_ARENA)
4039 s = "^1Wait for your turn to join";
4040 else if(gametype == GAME_LMS)
4043 sk = playerslots[player_localentnum - 1];
4044 if(sk.(scores[ps_primary]) >= 666)
4045 s = "^1Match has already begun";
4046 else if(sk.(scores[ps_primary]) > 0)
4047 s = "^1You have no more lives left";
4049 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4052 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4055 //show restart countdown:
4056 if (time < getstatf(STAT_GAMESTARTTIME)) {
4058 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4059 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4060 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
4061 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4065 if(warmup_stage && !intermission)
4067 s = "^2Currently in ^1warmup^2 stage!";
4072 if(mod(time, 1) >= 0.5)
4077 if(ready_waiting && !intermission && !spectatee_status)
4079 if(ready_waiting_for_me)
4082 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
4084 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
4089 s = strcat("^2Waiting for others to ready up to end warmup...");
4091 s = strcat("^2Waiting for others to ready up...");
4095 else if(warmup_stage && !intermission && !spectatee_status)
4097 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
4101 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4103 float ts_min, ts_max;
4104 tm = teams.sort_next;
4107 for(; tm.sort_next; tm = tm.sort_next)
4109 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4111 if(!ts_min) ts_min = tm.team_size;
4112 else ts_min = min(ts_min, tm.team_size);
4113 if(!ts_max) ts_max = tm.team_size;
4114 else ts_max = max(ts_max, tm.team_size);
4116 if ((ts_max - ts_min) > 1)
4118 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
4119 tm = GetTeam(myteam, false);
4121 if (tm.team != COLOR_SPECTATOR)
4122 if (tm.team_size == ts_max)
4123 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
4131 s = "^7Press ^3ESC ^7to show HUD options.";
4133 s = "^3Doubleclick ^7a panel for panel-specific options.";
4135 s = "^3CTRL ^7to disable collision testing, ^3SHIFT ^7and";
4137 s = "^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.";
4142 // Physics panel (#15)
4144 vector acc_prevspeed;
4145 float acc_prevtime, acc_avg, top_speed, top_speed_time;
4147 void HUD_Physics(void)
4149 if(!autocvar__hud_configure)
4151 if(!autocvar_hud_panel_physics) return;
4152 if(spectatee_status <= 0 && autocvar_hud_panel_physics < 2) return;
4155 hud_configure_active_panel = HUD_PANEL_PHYSICS;
4157 HUD_Panel_UpdateCvars(physics);
4159 HUD_Panel_DrawBg(1);
4160 if(panel_bg_padding)
4162 panel_pos += '1 1 0' * panel_bg_padding;
4163 panel_size -= '2 2 0' * panel_bg_padding;
4167 float speed, conversion_factor;
4170 switch(autocvar_hud_panel_physics_speed_unit)
4175 conversion_factor = 1.0;
4179 conversion_factor = 0.0254;
4183 conversion_factor = 0.0254 * 3.6;
4187 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4191 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4195 float max_speed = floor( autocvar_hud_panel_physics_speed_max * conversion_factor + 0.5 );
4196 if (autocvar__hud_configure)
4197 speed = floor( max_speed * 0.65 + 0.5 );
4198 else if(autocvar_hud_panel_physics_speed_z)
4199 speed = floor( vlen(pmove_vel) * conversion_factor + 0.5 );
4201 speed = floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 );
4203 //compute acceleration
4204 float acceleration, f;
4205 if (autocvar__hud_configure)
4206 acceleration = autocvar_hud_panel_physics_acceleration_max * 0.3;
4209 f = time - acc_prevtime;
4210 if(autocvar_hud_panel_physics_acceleration_z)
4211 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4213 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4214 acc_prevspeed = pmove_vel;
4215 acc_prevtime = time;
4217 f = bound(0, f * 10, 1);
4218 acc_avg = acc_avg * (1 - f) + acceleration * f;
4219 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4223 float panel_ar = panel_size_x/panel_size_y;
4224 vector speed_offset, acceleration_offset;
4227 panel_size_x *= 0.5;
4228 if (autocvar_hud_panel_physics_flip)
4229 speed_offset_x = panel_size_x;
4231 acceleration_offset_x = panel_size_x;
4235 panel_size_y *= 0.5;
4236 if (autocvar_hud_panel_physics_flip)
4237 speed_offset_y = panel_size_y;
4239 acceleration_offset_y = panel_size_y;
4241 float speed_baralign, acceleration_baralign;
4242 if (autocvar_hud_panel_physics_baralign == 1)
4243 acceleration_baralign = speed_baralign = 1;
4244 else if(autocvar_hud_panel_physics_baralign == 4)
4245 acceleration_baralign = speed_baralign = 2;
4246 else if (autocvar_hud_panel_physics_flip)
4248 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 2);
4249 speed_baralign = (autocvar_hud_panel_physics_baralign == 3);
4253 speed_baralign = (autocvar_hud_panel_physics_baralign == 2);
4254 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 3);
4258 if(speed && autocvar_hud_panel_physics_progressbar)
4260 HUD_Panel_GetProgressBarColor(speed);
4261 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);
4264 vector tmp_offset, tmp_size;
4265 tmp_size_x = panel_size_x * 0.75;
4266 tmp_size_y = panel_size_y;
4268 tmp_offset_x = panel_size_x - tmp_size_x;
4271 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4277 tmp_offset_x = tmp_size_x;
4278 if (autocvar_hud_panel_physics_speed_unit_show)
4281 tmp_size_x = panel_size_x * (1 - 0.75);
4282 tmp_size_y = panel_size_y * 0.4;
4283 drawstring_aspect(panel_pos + speed_offset + tmp_offset, unit, tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4286 //compute and draw top speed
4287 if (autocvar_hud_panel_physics_topspeed)
4289 if (autocvar__hud_configure)
4291 top_speed = floor( max_speed * 0.75 + 0.5 );
4296 if (speed >= top_speed)
4299 top_speed_time = time;
4302 else if (top_speed != 0)
4304 f = max(1, autocvar_hud_panel_physics_topspeed_time);
4305 // divide by f to make it start from 1
4306 f = cos( ((time - top_speed_time) / f) * PI/2 );
4308 else //hide top speed 0, it would be stupid
4313 //top speed progressbar peak
4314 if(autocvar_hud_panel_physics_progressbar && speed < top_speed)
4316 float peak_offset_x;
4318 if (speed_baralign == 0)
4319 peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x;
4320 else if (speed_baralign == 1)
4321 peak_offset_x = (1 - min(top_speed, max_speed)/max_speed) * panel_size_x;
4322 else if (speed_baralign == 2)
4323 peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x * 0.5;
4324 //if speed is not 0 the speed progressbar already fetched the color
4326 HUD_Panel_GetProgressBarColor(speed);
4327 peak_size_x = floor(panel_size_x * 0.01 + 1.5);
4328 peak_size_y = panel_size_y;
4329 if (speed_baralign == 2) // draw two peaks, on both sides
4331 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);
4332 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);
4335 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);
4339 tmp_offset_y = panel_size_y * 0.4;
4340 tmp_size_x = panel_size_x * (1 - 0.75);
4341 tmp_size_y = panel_size_y - tmp_offset_y;
4342 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(top_speed), tmp_size, '1 0 0', f * panel_fg_alpha, DRAWFLAG_NORMAL);
4349 if(acceleration && autocvar_hud_panel_physics_progressbar)
4351 if (acceleration < 0)
4352 HUD_Panel_GetProgressBarColor(acceleration_neg);
4354 HUD_Panel_GetProgressBarColor(acceleration);
4355 HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset, panel_size, "progressbar", fabs(acceleration)/autocvar_hud_panel_physics_acceleration_max, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4357 drawstring_aspect(panel_pos + acceleration_offset, ftos_decimals(acceleration, 3), panel_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4366 void HUD_Reset (void)
4368 // reset gametype specific icons
4369 if(gametype == GAME_KEYHUNT)
4371 else if(gametype == GAME_CTF)
4372 HUD_Mod_CTF_Reset();
4375 #define HUD_DrawPanel(id)\
4377 case (HUD_PANEL_RADAR):\
4378 HUD_Radar(); break;\
4379 case (HUD_PANEL_WEAPONS):\
4380 HUD_Weapons(); break;\
4381 case (HUD_PANEL_AMMO):\
4383 case (HUD_PANEL_POWERUPS):\
4384 HUD_Powerups(); break;\
4385 case (HUD_PANEL_HEALTHARMOR):\
4386 HUD_HealthArmor(); break;\
4387 case (HUD_PANEL_NOTIFY):\
4388 HUD_Notify(); break;\
4389 case (HUD_PANEL_TIMER):\
4390 HUD_Timer(); break;\
4391 case (HUD_PANEL_SCORE):\
4392 HUD_Score(); break;\
4393 case (HUD_PANEL_RACETIMER):\
4394 HUD_RaceTimer(); break;\
4395 case (HUD_PANEL_VOTE):\
4396 HUD_VoteWindow(); break;\
4397 case (HUD_PANEL_MODICONS):\
4398 HUD_ModIcons(); break;\
4399 case (HUD_PANEL_PRESSEDKEYS):\
4400 HUD_DrawPressedKeys(); break;\
4401 case (HUD_PANEL_CHAT):\
4403 case (HUD_PANEL_ENGINEINFO):\
4404 HUD_EngineInfo(); break;\
4405 case (HUD_PANEL_INFOMESSAGES):\
4406 HUD_InfoMessages(); break;\
4407 case (HUD_PANEL_PHYSICS):\
4408 HUD_Physics(); break;\
4409 } ENDS_WITH_CURLY_BRACE
4411 void HUD_Main (void)
4414 // global hud alpha fade
4415 if(menu_enabled == 1)
4418 hud_fade_alpha = (1 - autocvar__menu_alpha);
4420 if(scoreboard_fade_alpha)
4421 hud_fade_alpha = (1 - scoreboard_fade_alpha);
4423 if(intermission == 2) // no hud during mapvote
4425 else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
4428 if(!autocvar__hud_configure && !hud_fade_alpha)
4432 if (hud_skin_path != autocvar_hud_skin)
4435 strunzone(hud_skin_path);
4436 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
4439 // HUD configure visible grid
4440 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4442 hud_configure_gridSize_x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
4443 hud_configure_gridSize_y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
4444 hud_configure_realGridSize_x = hud_configure_gridSize_x * vid_conwidth;
4445 hud_configure_realGridSize_y = hud_configure_gridSize_y * vid_conheight;
4447 for(i = 0; i < 1/hud_configure_gridSize_x; ++i)
4448 drawfill(eX * i * hud_configure_realGridSize_x, eX + eY * vid_conheight, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4450 for(i = 0; i < 1/hud_configure_gridSize_y; ++i)
4451 drawfill(eY * i * hud_configure_realGridSize_y, eY + eX * vid_conwidth, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4454 current_player = (spectatee_status > 0) ? spectatee_status : player_localentnum;
4457 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4461 float hud_dock_color_team = autocvar_hud_dock_color_team;
4462 if((teamplay) && hud_dock_color_team) {
4463 f = stof(getplayerkey(current_player - 1, "colors"));
4464 color = colormapPaletteColor(mod(f, 16), 1) * hud_dock_color_team;
4466 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
4467 color = '1 0 0' * hud_dock_color_team;
4471 string hud_dock_color = autocvar_hud_dock_color;
4472 if(hud_dock_color == "shirt") {
4473 f = stof(getplayerkey(current_player - 1, "colors"));
4474 color = colormapPaletteColor(floor(f / 16), 0);
4476 else if(hud_dock_color == "pants") {
4477 f = stof(getplayerkey(current_player - 1, "colors"));
4478 color = colormapPaletteColor(mod(f, 16), 1);
4481 color = stov(hud_dock_color);
4485 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4486 if(precache_pic(pic) == "") {
4487 pic = strcat(hud_skin_path, "/dock_medium");
4488 if(precache_pic(pic) == "") {
4489 pic = "gfx/hud/default/dock_medium";
4492 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...
4495 // cache the panel order into the panel_order array
4496 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4497 for(i = 0; i < HUD_PANEL_NUM; ++i)
4498 panel_order[i] = -1;
4500 float p_num, warning;
4501 float argc = tokenize_console(autocvar__hud_panelorder);
4502 if (argc > HUD_PANEL_NUM)
4504 //first detect wrong/missing panel numbers
4505 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4506 p_num = stof(argv(i));
4507 if (p_num >= 0 && p_num < HUD_PANEL_NUM) { //correct panel number?
4508 if (panel_order[p_num] == -1) //found for the first time?
4509 s = strcat(s, ftos(p_num), " ");
4510 panel_order[p_num] = 1; //mark as found
4515 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4516 if (panel_order[i] == -1) {
4518 s = strcat(s, ftos(i), " "); //add missing panel number
4522 print("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n");
4524 cvar_set("_hud_panelorder", s);
4525 if(hud_panelorder_prev)
4526 strunzone(hud_panelorder_prev);
4527 hud_panelorder_prev = strzone(s);
4529 //now properly set panel_order
4530 tokenize_console(s);
4531 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4532 panel_order[i] = stof(argv(i));
4536 // draw panels in order specified by panel_order array
4537 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
4538 if(i != HUD_PANEL_CHAT || !autocvar__con_chat_maximized) // don't draw maximized chat panel twice!
4539 HUD_DrawPanel(panel_order[i]);
4542 // draw chat panel on top if it is maximized
4543 if(autocvar__con_chat_maximized)
4544 HUD_Chat(); // HUD_DrawPanel(HUD_PANEL_CHAT);
4546 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)
4547 localcmd("cmd selectteam auto; cmd join\n");
4549 if(autocvar__hud_configure && tab_panel != -1)
4551 HUD_Panel_UpdatePosSizeForId(tab_panel)
4552 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
4555 hud_configure_prev = autocvar__hud_configure;
4557 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again