7 // a border picture is a texture containing nine parts:
8 // 1/4 width: left part
9 // 1/2 width: middle part (stretched)
10 // 1/4 width: right part
12 // 1/4 height: top part
13 // 1/2 height: middle part (stretched)
14 // 1/4 height: bottom part
15 void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize)
17 if (theBorderSize_x < 0 && theBorderSize_y < 0) // draw whole image as it is
19 drawpic(theOrigin, pic, theSize, theColor, theAlpha, 0);
22 if (theBorderSize_x == 0 && theBorderSize_y == 0) // no border
24 // draw only the central part
25 drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
32 //pic = draw_UseSkinFor(pic);
33 width = eX * theSize_x;
34 height = eY * theSize_y;
35 if(theSize_x <= theBorderSize_x * 2)
37 // not wide enough... draw just left and right then
38 bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
39 if(theSize_y <= theBorderSize_y * 2)
41 // not high enough... draw just corners
42 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
43 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
44 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
45 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
46 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
50 dY = theBorderSize_x * eY;
51 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
52 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
53 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
54 drawsubpic(theOrigin + width * 0.5 + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0' + eX - bW, '0 0.5 0' + bW, theColor, theAlpha, 0);
55 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
56 drawsubpic(theOrigin + width * 0.5 + height - dY, width * 0.5 + dY, pic, '0 0.75 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
61 if(theSize_y <= theBorderSize_y * 2)
63 // not high enough... draw just top and bottom then
64 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
65 dX = theBorderSize_x * eX;
66 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
67 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
68 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
69 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
70 drawsubpic(theOrigin + dX + height * 0.5, width - 2 * dX + height * 0.5, pic, '0.25 0 0' + eY - bH, '0.5 0 0' + bH, theColor, theAlpha, 0);
71 drawsubpic(theOrigin + width - dX + height * 0.5, dX + height * 0.5, pic, '0.75 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
75 dX = theBorderSize_x * eX;
76 dY = theBorderSize_x * eY;
77 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
78 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
79 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
80 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
81 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
82 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
83 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
84 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
85 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
90 vector HUD_Get_Num_Color (float x, float maxvalue)
95 color_x = sin(2*M_PI*time);
97 color_z = sin(2*M_PI*time);
99 else if(x > maxvalue * 0.75) {
100 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
101 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
104 else if(x > maxvalue * 0.5) {
105 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
106 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
107 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
109 else if(x > maxvalue * 0.25) {
112 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
114 else if(x > maxvalue * 0.1) {
116 color_y = (x-20)*90/27/100; // green value between 0 -> 1
117 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
125 blinkingamt = (1 - x/maxvalue/0.25);
128 color_x = color_x - color_x * blinkingamt * sin(2*M_PI*time);
129 color_y = color_y - color_y * blinkingamt * sin(2*M_PI*time);
130 color_z = color_z - color_z * blinkingamt * sin(2*M_PI*time);
135 float stringwidth_colors(string s, vector theSize)
137 return stringwidth(s, TRUE, theSize);
140 float stringwidth_nocolors(string s, vector theSize)
142 return stringwidth(s, FALSE, theSize);
145 void drawstringright(vector position, string text, vector scale, vector rgb, float theAlpha, float flag)
147 position_x -= 2 / 3 * strlen(text) * scale_x;
148 drawstring(position, text, scale, rgb, theAlpha, flag);
151 void drawstringcenter(vector position, string text, vector scale, vector rgb, float theAlpha, float flag)
153 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
154 drawstring(position, text, scale, rgb, theAlpha, flag);
157 // return the string of the given race place
158 string race_PlaceName(float pos) {
166 return sprintf(_("%dth"), pos);
169 // return the string of the onscreen race timer
170 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
178 if(histime == 0) // goal hit
182 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
192 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
198 lapstr = sprintf(_(" (-%dL)"), lapdelta);
201 else if(lapdelta < 0)
203 lapstr = sprintf(_(" (+%dL)"), -lapdelta);
207 else if(histime > 0) // anticipation
209 if(mytime >= histime)
210 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
212 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
222 cpname = _("Start line");
224 cpname = _("Finish line");
226 cpname = sprintf(_("Intermediate %d"), cp);
228 cpname = _("Finish line");
231 return strcat(col, cpname);
232 else if(hisname == "")
233 return strcat(col, sprintf(_("%s (%s)"), cpname, timestr));
235 return strcat(col, sprintf(_("%s (%s %s)"), cpname, timestr, strcat(hisname, col, lapstr)));
238 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
239 float race_CheckName(string net_name) {
241 for (i=RANKINGS_CNT-1;i>=0;--i)
242 if(grecordholder[i] == net_name)
247 float GetPlayerColorForce(float i)
252 return stof(getplayerkeyvalue(i, "colors")) & 15;
255 float GetPlayerColor(float i)
257 if not(playerslots[i].gotscores) // unconnected
259 else if(stof(getplayerkeyvalue(i, "frags")) == FRAGS_SPECTATOR)
262 return GetPlayerColorForce(i);
265 string GetPlayerName(float i)
267 return ColorTranslateRGB(getplayerkeyvalue(i, "name"));
277 // draw the background/borders
278 #define HUD_Panel_DrawBg(theAlpha)\
280 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 * theAlpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER))
282 //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
283 void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, float vertical, float baralign, vector theColor, float theAlpha, float drawflag)
285 if(!length_ratio || !theAlpha)
291 if(length_ratio < -1)
294 else if(length_ratio < 0)
298 vector width, height;
300 pic = strcat(hud_skin_path, "/", pic, "_vertical");
301 if(precache_pic(pic) == "") {
302 pic = "gfx/hud/default/progressbar_vertical";
305 if (baralign == 1) // bottom align
306 theOrigin_y += (1 - length_ratio) * theSize_y;
307 else if (baralign == 2) // center align
308 theOrigin_y += 0.5 * (1 - length_ratio) * theSize_y;
309 else if (baralign == 3) // center align, positive values down, negative up
312 if (length_ratio > 0)
313 theOrigin_y += theSize_y;
316 theOrigin_y += (1 + length_ratio) * theSize_y;
317 length_ratio = -length_ratio;
320 theSize_y *= length_ratio;
323 width = eX * theSize_x;
324 height = eY * theSize_y;
325 if(theSize_y <= theSize_x * 2)
327 // button not high enough
328 // draw just upper and lower part then
329 square = eY * theSize_y * 0.5;
330 bH = eY * (0.25 * theSize_y / (theSize_x * 2));
331 drawsubpic(theOrigin, square + width, pic, '0 0 0', eX + bH, theColor, theAlpha, drawflag);
332 drawsubpic(theOrigin + square, square + width, pic, eY - bH, eX + bH, theColor, theAlpha, drawflag);
336 square = eY * theSize_x;
337 drawsubpic(theOrigin, width + square, pic, '0 0 0', '1 0.25 0', theColor, theAlpha, drawflag);
338 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0 0.25 0', '1 0.5 0', theColor, theAlpha, drawflag);
339 drawsubpic(theOrigin + height - square, width + square, pic, '0 0.75 0', '1 0.25 0', theColor, theAlpha, drawflag);
342 pic = strcat(hud_skin_path, "/", pic);
343 if(precache_pic(pic) == "") {
344 pic = "gfx/hud/default/progressbar";
347 if (baralign == 1) // right align
348 theOrigin_x += (1 - length_ratio) * theSize_x;
349 else if (baralign == 2) // center align
350 theOrigin_x += 0.5 * (1 - length_ratio) * theSize_x;
351 else if (baralign == 3) // center align, positive values on the right, negative on the left
354 if (length_ratio > 0)
355 theOrigin_x += theSize_x;
358 theOrigin_x += (1 + length_ratio) * theSize_x;
359 length_ratio = -length_ratio;
362 theSize_x *= length_ratio;
365 width = eX * theSize_x;
366 height = eY * theSize_y;
367 if(theSize_x <= theSize_y * 2)
369 // button not wide enough
370 // draw just left and right part then
371 square = eX * theSize_x * 0.5;
372 bW = eX * (0.25 * theSize_x / (theSize_y * 2));
373 drawsubpic(theOrigin, square + height, pic, '0 0 0', eY + bW, theColor, theAlpha, drawflag);
374 drawsubpic(theOrigin + square, square + height, pic, eX - bW, eY + bW, theColor, theAlpha, drawflag);
378 square = eX * theSize_y;
379 drawsubpic(theOrigin, height + square, pic, '0 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
380 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0.25 0 0', '0.5 1 0', theColor, theAlpha, drawflag);
381 drawsubpic(theOrigin + width - square, height + square, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
386 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float theAlpha, float drawflag)
392 pic = strcat(hud_skin_path, "/num_leading");
393 if(precache_pic(pic) == "") {
394 pic = "gfx/hud/default/num_leading";
397 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, theAlpha, drawflag);
398 if(mySize_x/mySize_y > 2)
399 drawsubpic(pos + eX * mySize_y, eX * (mySize_x - 2 * mySize_y) + eY * mySize_y, pic, '0.25 0 0', '0.5 1 0', color, theAlpha, drawflag);
400 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, theAlpha, drawflag);
405 entity weaponorder[WEP_MAXCOUNT];
406 void weaponorder_swap(float i, float j, entity pass)
410 weaponorder[i] = weaponorder[j];
414 string weaponorder_cmp_str;
415 float weaponorder_cmp(float i, float j, entity pass)
418 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
419 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
420 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)
423 float GetAmmoStat(float i)
427 case 0: return STAT_SHELLS;
428 case 1: return STAT_NAILS;
429 case 2: return STAT_ROCKETS;
430 case 3: return STAT_CELLS;
431 case 4: return STAT_FUEL;
436 float GetAmmoTypeForWep(float i)
440 case WEP_SHOTGUN: return 0;
441 case WEP_UZI: return 1;
442 case WEP_GRENADE_LAUNCHER: return 2;
443 case WEP_MINE_LAYER: return 2;
444 case WEP_ELECTRO: return 3;
445 case WEP_CRYLINK: return 3;
446 case WEP_HLAC: return 3;
447 case WEP_MINSTANEX: return 3;
448 case WEP_NEX: return 3;
449 case WEP_RIFLE: return 1;
450 case WEP_HAGAR: return 2;
451 case WEP_ROCKET_LAUNCHER: return 2;
452 case WEP_SEEKER: return 2;
453 case WEP_FIREBALL: return 4;
454 case WEP_HOOK: return 3;
459 void HUD_Weapons(void)
462 WEPSET_DECLARE_A(weapons_stat);
463 WEPSET_COPY_AS(weapons_stat);
464 float i, f, a, j, factor;
465 float screen_ar, center_x, center_y;
466 float weapon_count, weapon_id;
467 float row, column, rows, columns;
468 float aspect = autocvar_hud_panel_weapons_aspect;
470 float show_accuracy = false, panel_weapon_accuracy;
472 float timeout = autocvar_hud_panel_weapons_timeout;
473 float timein_effect_length = autocvar_hud_panel_weapons_timeout_speed_in; //? 0.375 : 0);
474 float timeout_effect_length = autocvar_hud_panel_weapons_timeout_speed_out; //? 0.75 : 0);
476 float ammo_type, ammo_full;
477 float barsize_x = 0, barsize_y = 0, baroffset_x = 0, baroffset_y = 0;
478 vector ammo_color = '1 0 1';
479 float ammo_alpha = 1;
481 float when = autocvar_hud_panel_weapons_complainbubble_time;
482 float fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
484 vector weapon_pos, weapon_size;
485 local noref vector old_panel_size; // fteqcc sucks
488 // check to see if we want to continue
489 if(hud != HUD_NORMAL) { return; }
491 if(!autocvar__hud_configure)
493 if((!autocvar_hud_panel_weapons) || (spectatee_status == -1))
495 else if(timeout && time >= weapontime + timeout + timeout_effect_length && ((autocvar_hud_panel_weapons_timeout_effect != 1) && !(autocvar_hud_panel_weapons_timeout_fadebgmin + autocvar_hud_panel_weapons_timeout_fadefgmin)))
497 weaponprevtime = time;
502 hud_configure_active_panel = HUD_PANEL_WEAPONS;
504 // update generic hud functions
505 HUD_Panel_UpdateCvars(weapons);
506 HUD_Panel_ApplyFadeAlpha();
508 draw_beginBoldFont();
510 // figure out weapon order (how the weapons are sorted) // TODO make this configurable
511 if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
514 if(weaponorder_bypriority)
515 strunzone(weaponorder_bypriority);
516 if(weaponorder_byimpulse)
517 strunzone(weaponorder_byimpulse);
519 weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
520 weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
521 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
524 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
526 self = get_weaponinfo(i);
527 if(self.impulse >= 0)
529 weaponorder[weapon_cnt] = self;
533 for(i = weapon_cnt; i < WEP_MAXCOUNT; ++i)
534 weaponorder[i] = world;
535 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
537 weaponorder_cmp_str = string_null;
540 // determine which weapons are going to be shown
541 if (autocvar_hud_panel_weapons_onlyowned)
543 if(autocvar__hud_configure)
545 if (WEPSET_EMPTY_A(weapons_stat))
546 for(i = WEP_FIRST; i <= WEP_LAST; i += floor((WEP_LAST-WEP_FIRST)/5))
547 WEPSET_OR_AW(weapons_stat, i);
549 if(menu_enabled != 2)
550 HUD_Panel_DrawBg(1); // also draw the bg of the entire panel
553 // do we own this weapon?
555 for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
556 if(WEPSET_CONTAINS_AW(weapons_stat, weaponorder[i].weapon))
559 // add it anyway if weaponcomplain is shown
560 if((!autocvar__hud_configure)
561 && (autocvar_hud_panel_weapons_complainbubble
562 && time - complain_weapon_time < when + fadetime))
565 // might as well commit suicide now, no reason to live ;)
566 if (weapon_count == 0) { return; }
568 // reduce size of the panel
569 if (panel_size_y > panel_size_x)
571 old_panel_size_y = panel_size_y;
572 panel_size_y *= weapon_count / WEP_COUNT;
573 panel_pos_y += (old_panel_size_y - panel_size_y) / 2;
577 old_panel_size_x = panel_size_x;
578 panel_size_x *= weapon_count / WEP_COUNT;
579 panel_pos_x += (old_panel_size_x - panel_size_x) / 2;
583 weapon_count = WEP_COUNT;
585 // animation for fading in/out the panel respectively when not in use
586 if(!autocvar__hud_configure)
588 if (timeout && time >= weapontime + timeout) // apply timeout effect if needed
590 f = bound(0, (time - (weapontime + timeout)) / timeout_effect_length, 1);
592 // fade the panel alpha
593 if(autocvar_hud_panel_weapons_timeout_effect == 1)
595 panel_bg_alpha *= (autocvar_hud_panel_weapons_timeout_fadebgmin * f + (1 - f));
596 panel_fg_alpha *= (autocvar_hud_panel_weapons_timeout_fadefgmin * f + (1 - f));
598 else if(autocvar_hud_panel_weapons_timeout_effect == 3)
600 panel_bg_alpha *= (1 - f);
601 panel_fg_alpha *= (1 - f);
604 // move the panel off the screen
605 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
607 f *= f; // for a cooler movement
608 center_x = panel_pos_x + panel_size_x/2;
609 center_y = panel_pos_y + panel_size_y/2;
610 screen_ar = vid_conwidth/vid_conheight;
611 if (center_x/center_y < screen_ar) //bottom left
613 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
614 panel_pos_y += f * (vid_conheight - panel_pos_y);
616 panel_pos_x -= f * (panel_pos_x + panel_size_x);
620 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
621 panel_pos_x += f * (vid_conwidth - panel_pos_x);
623 panel_pos_y -= f * (panel_pos_y + panel_size_y);
626 weaponprevtime = time - (1 - f) * timein_effect_length;
628 else if (timeout && time < weaponprevtime + timein_effect_length) // apply timein effect if needed
630 f = bound(0, (time - weaponprevtime) / timein_effect_length, 1);
632 // fade the panel alpha
633 if(autocvar_hud_panel_weapons_timeout_effect == 1)
635 panel_bg_alpha *= (autocvar_hud_panel_weapons_timeout_fadebgmin * (1 - f) + f);
636 panel_fg_alpha *= (autocvar_hud_panel_weapons_timeout_fadefgmin * (1 - f) + f);
638 else if(autocvar_hud_panel_weapons_timeout_effect == 3)
640 panel_bg_alpha *= (f);
641 panel_fg_alpha *= (f);
644 // move the panel back on screen
645 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
647 f *= f; // for a cooler movement
649 center_x = panel_pos_x + panel_size_x/2;
650 center_y = panel_pos_y + panel_size_y/2;
651 screen_ar = vid_conwidth/vid_conheight;
652 if (center_x/center_y < screen_ar) //bottom left
654 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
655 panel_pos_y += f * (vid_conheight - panel_pos_y);
657 panel_pos_x -= f * (panel_pos_x + panel_size_x);
661 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
662 panel_pos_x += f * (vid_conwidth - panel_pos_x);
664 panel_pos_y -= f * (panel_pos_y + panel_size_y);
670 // draw the background, then change the virtual size of it to better fit other items inside
674 panel_pos += '1 1 0' * panel_bg_padding;
675 panel_size -= '2 2 0' * panel_bg_padding;
678 // after the sizing and animations are done, update the other values
679 rows = panel_size_y/panel_size_x;
680 rows = bound(1, floor((sqrt(4 * aspect * rows * weapon_count + rows * rows) + rows + 0.5) / 2), weapon_count);
681 columns = ceil(weapon_count/rows);
682 weapon_size = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
684 // calculate position/size for visual bar displaying ammount of ammo status
685 if (autocvar_hud_panel_weapons_ammo)
687 ammo_color = stov(autocvar_hud_panel_weapons_ammo_color);
688 ammo_alpha = panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha;
690 if(weapon_size_x/weapon_size_y > aspect)
692 barsize_x = aspect * weapon_size_y;
693 barsize_y = weapon_size_y;
694 baroffset_x = (weapon_size_x - barsize_x) / 2;
698 barsize_y = 1/aspect * weapon_size_x;
699 barsize_x = weapon_size_x;
700 baroffset_y = (weapon_size_y - barsize_y) / 2;
704 if(autocvar_hud_panel_weapons_accuracy && acc_levels)
706 show_accuracy = true;
707 if (acc_col[0] == '-1 0 0')
708 for (i = 0; i < acc_levels; ++i)
709 acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
713 for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
715 // retrieve information about the current weapon to be drawn
716 self = weaponorder[i];
717 weapon_id = self.impulse;
719 // skip if this weapon doesn't exist
720 if (!self || self.impulse < 0) { continue; }
722 // skip this weapon if we don't own it (and onlyowned is enabled)-- or if weapons_complainbubble is showing for this weapon
723 if (autocvar_hud_panel_weapons_onlyowned
724 && !(WEPSET_CONTAINS_AW(weapons_stat, self.weapon)
725 || (self.weapon == complain_weapon
726 && time - complain_weapon_time < when + fadetime
727 && autocvar_hud_panel_weapons_complainbubble)))
730 // figure out the drawing position of weapon
731 weapon_pos = (panel_pos
732 + eX * column * weapon_size_x
733 + eY * row * weapon_size_y);
735 // draw background behind currently selected weapon
736 if(self.weapon == switchweapon)
737 drawpic_aspect_skin(weapon_pos, "weapon_current_bg", weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
739 // draw the weapon accuracy
742 panel_weapon_accuracy = weapon_accuracy[self.weapon-WEP_FIRST];
743 if(panel_weapon_accuracy >= 0)
745 // find the max level lower than weapon_accuracy
747 while ( j && panel_weapon_accuracy < acc_lev[j] )
750 // inject color j+1 in color j, how much depending on how much weapon_accuracy is higher than level j
751 factor = (panel_weapon_accuracy - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
753 color = color + factor * (acc_col[j+1] - color);
755 drawpic_aspect_skin(weapon_pos, "weapon_accuracy", weapon_size, color, panel_fg_alpha, DRAWFLAG_NORMAL);
759 // drawing all the weapon items
760 if(WEPSET_CONTAINS_AW(weapons_stat, self.weapon))
762 // draw the weapon image
763 drawpic_aspect_skin(weapon_pos, strcat("weapon", self.netname), weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
765 // draw weapon label string
766 switch(autocvar_hud_panel_weapons_label)
768 case 1: // weapon number
769 drawstring(weapon_pos, ftos(weapon_id), '1 1 0' * 0.5 * weapon_size_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
773 drawstring(weapon_pos, getcommandkey(ftos(weapon_id), strcat("weapon_group_", ftos(weapon_id))), '1 1 0' * 0.5 * weapon_size_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
776 case 3: // weapon name
777 drawstring(weapon_pos, self.netname, '1 1 0' * 0.5 * weapon_size_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
784 // draw ammo status bar
785 if(autocvar_hud_panel_weapons_ammo && self.weapon != WEP_TUBA && self.weapon != WEP_LASER && self.weapon != WEP_PORTO)
788 ammo_type = GetAmmoTypeForWep(self.weapon);
790 a = getstati(GetAmmoStat(ammo_type)); // how much ammo do we have?
795 case 0: ammo_full = autocvar_hud_panel_weapons_ammo_full_shells; break;
796 case 1: ammo_full = autocvar_hud_panel_weapons_ammo_full_nails; break;
797 case 2: ammo_full = autocvar_hud_panel_weapons_ammo_full_rockets; break;
798 case 3: ammo_full = autocvar_hud_panel_weapons_ammo_full_cells; break;
799 case 4: ammo_full = autocvar_hud_panel_weapons_ammo_full_fuel; break;
800 default: ammo_full = 60;
804 weapon_pos_x + baroffset_x,
805 weapon_pos_y + baroffset_y,
806 barsize_x * bound(0, a/ammo_full, 1),
808 drawpic_aspect_skin(weapon_pos, "weapon_ammo", weapon_size, ammo_color, ammo_alpha, DRAWFLAG_NORMAL);
813 else // draw a "ghost weapon icon" if you don't have the weapon
815 drawpic_aspect_skin(weapon_pos, strcat("weapon", self.netname), weapon_size, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
818 // draw the complain message
819 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
822 a = ((complain_weapon_time + when > time) ? 1 : bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1));
824 a = ((complain_weapon_time + when > time) ? 1 : 0);
828 if(complain_weapon_type == 0) {
829 s = _("Out of ammo");
830 color = stov(autocvar_hud_panel_weapons_complainbubble_color_outofammo);
832 else if(complain_weapon_type == 1) {
834 color = stov(autocvar_hud_panel_weapons_complainbubble_color_donthave);
837 s = _("Unavailable");
838 color = stov(autocvar_hud_panel_weapons_complainbubble_color_unavailable);
840 float padding = autocvar_hud_panel_weapons_complainbubble_padding;
841 drawpic_aspect_skin(weapon_pos + '1 1 0' * padding, "weapon_complainbubble", weapon_size - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
842 drawstring_aspect(weapon_pos + '1 1 0' * padding, s, weapon_size - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
845 // continue with new position for the next weapon
860 float GetAmmoItemCode(float i)
864 case 0: return IT_SHELLS;
865 case 1: return IT_NAILS;
866 case 2: return IT_ROCKETS;
867 case 3: return IT_CELLS;
868 case 4: return IT_FUEL;
873 string GetAmmoPicture(float i)
877 case 0: return "ammo_shells";
878 case 1: return "ammo_bullets";
879 case 2: return "ammo_rockets";
880 case 3: return "ammo_cells";
881 case 4: return "ammo_fuel";
886 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected, float infinite_ammo)
889 if(autocvar__hud_configure)
891 currently_selected = (itemcode == 2); //rockets always selected
892 a = 31 + mod(itemcode*93, 128);
895 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
899 color = '0 0.5 0.75';
906 if(currently_selected)
911 vector picpos, numpos;
912 if(autocvar_hud_panel_ammo_iconalign)
915 picpos = myPos + eX * 2 * mySize_y;
919 numpos = myPos + eX * mySize_y;
923 if (currently_selected)
924 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
926 if(a > 0 && autocvar_hud_panel_ammo_progressbar)
927 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, a/autocvar_hud_panel_ammo_maxammo, 0, 0, color, autocvar_hud_progressbar_alpha * panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
929 if(autocvar_hud_panel_ammo_text)
931 if(a > 0 || infinite_ammo)
932 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
933 else // "ghost" ammo count
934 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * theAlpha * 0.5, DRAWFLAG_NORMAL);
936 if(a > 0 || infinite_ammo)
937 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
938 else // "ghost" ammo icon
939 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '0 0 0', panel_fg_alpha * theAlpha * 0.5, DRAWFLAG_NORMAL);
944 if(hud != HUD_NORMAL) return;
945 if(!autocvar__hud_configure)
947 if(!autocvar_hud_panel_ammo) return;
948 if(spectatee_status == -1) return;
951 hud_configure_active_panel = HUD_PANEL_AMMO;
953 HUD_Panel_UpdateCvars(ammo);
954 HUD_Panel_ApplyFadeAlpha();
956 draw_beginBoldFont();
965 pos += '1 1 0' * panel_bg_padding;
966 mySize -= '2 2 0' * panel_bg_padding;
969 float rows = 0, columns, row, column;
971 if (autocvar_hud_panel_ammo_onlycurrent)
975 rows = mySize_y/mySize_x;
976 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
977 // ^^^ ammo item aspect goes here
979 columns = ceil(AMMO_COUNT/rows);
981 ammo_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
984 local vector offset = '0 0 0'; // fteqcc sucks
986 if(ammo_size_x/ammo_size_y > 3)
988 newSize = 3 * ammo_size_y;
989 offset_x = ammo_size_x - newSize;
991 ammo_size_x = newSize;
995 newSize = 1/3 * ammo_size_x;
996 offset_y = ammo_size_y - newSize;
998 ammo_size_y = newSize;
1001 float i, stat_items, currently_selected, infinite_ammo;
1002 infinite_ammo = FALSE;
1003 if (autocvar_hud_panel_ammo_onlycurrent)
1005 if(autocvar__hud_configure)
1007 DrawAmmoItem(pos, ammo_size, 2, true, FALSE); //show rockets
1011 stat_items = getstati(STAT_ITEMS, 0, 24);
1012 if (stat_items & IT_UNLIMITED_WEAPON_AMMO)
1013 infinite_ammo = TRUE;
1014 for (i = 0; i < AMMO_COUNT; ++i) {
1015 currently_selected = stat_items & GetAmmoItemCode(i);
1016 if (currently_selected)
1018 DrawAmmoItem(pos, ammo_size, i, true, infinite_ammo);
1026 stat_items = getstati(STAT_ITEMS, 0, 24);
1027 if (stat_items & IT_UNLIMITED_WEAPON_AMMO)
1028 infinite_ammo = TRUE;
1030 for (i = 0; i < AMMO_COUNT; ++i) {
1031 currently_selected = stat_items & GetAmmoItemCode(i);
1032 DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected, infinite_ammo);
1037 column = column + 1;
1045 void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float theAlpha, float fadelerp)
1047 vector newPos = '0 0 0', newSize = '0 0 0';
1048 vector picpos, numpos;
1052 if(mySize_y/mySize_x > 2)
1054 newSize_y = 2 * mySize_x;
1055 newSize_x = mySize_x;
1057 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1062 newSize_x = 1/2 * mySize_y;
1063 newSize_y = mySize_y;
1065 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1069 if(icon_right_align)
1072 picpos = newPos + eY * newSize_x;
1077 numpos = newPos + eY * newSize_x;
1081 drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
1082 // make number smaller than icon, it looks better
1083 // reduce only y to draw numbers with different number of digits with the same y size
1084 numpos_y += newSize_y * ((1 - 0.7) / 2);
1086 drawstring_aspect(numpos, ftos(x), newSize, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
1090 if(mySize_x/mySize_y > 3)
1092 newSize_x = 3 * mySize_y;
1093 newSize_y = mySize_y;
1095 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1100 newSize_y = 1/3 * mySize_x;
1101 newSize_x = mySize_x;
1103 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1107 if(icon_right_align) // right align
1110 picpos = newPos + eX * 2 * newSize_y;
1114 numpos = newPos + eX * newSize_y;
1118 // NOTE: newSize_x is always equal to 3 * mySize_y so we can use
1119 // '2 1 0' * newSize_y instead of eX * (2/3) * newSize_x + eY * newSize_y
1120 drawstring_aspect_expanding(numpos, ftos(x), '2 1 0' * newSize_y, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
1121 drawpic_aspect_skin_expanding(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
1124 void DrawNumIcon(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float theAlpha)
1126 DrawNumIcon_expanding(myPos, mySize, x, icon, vertical, icon_right_align, color, theAlpha, 0);
1131 void HUD_Powerups(void)
1133 float strength_time, shield_time, superweapons_time;
1134 if(!autocvar__hud_configure)
1136 if(!autocvar_hud_panel_powerups) return;
1137 if(spectatee_status == -1) return;
1138 if not(getstati(STAT_ITEMS, 0, 24) & (IT_STRENGTH | IT_INVINCIBLE | IT_SUPERWEAPON)) return;
1139 if (getstati(STAT_HEALTH) <= 0) return;
1141 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1142 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1143 superweapons_time = bound(0, getstatf(STAT_SUPERWEAPONS_FINISHED) - time, 99);
1145 if (getstati(STAT_ITEMS, 0, 24) & IT_UNLIMITED_SUPERWEAPONS)
1146 superweapons_time = 99; // force max
1148 // prevent stuff to show up on mismatch that will be fixed next frame
1149 if (!(getstati(STAT_ITEMS, 0, 24) & IT_SUPERWEAPON))
1150 superweapons_time = 0;
1154 hud_configure_active_panel = HUD_PANEL_POWERUPS;
1158 superweapons_time = 13;
1161 HUD_Panel_UpdateCvars(powerups);
1162 HUD_Panel_ApplyFadeAlpha();
1164 draw_beginBoldFont();
1168 mySize = panel_size;
1170 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time, superweapons_time), 1));
1171 if(panel_bg_padding)
1173 pos += '1 1 0' * panel_bg_padding;
1174 mySize -= '2 2 0' * panel_bg_padding;
1177 float panel_ar = mySize_x/mySize_y;
1178 float is_vertical = (panel_ar < 1);
1179 vector shield_offset = '0 0 0', strength_offset = '0 0 0', superweapons_offset = '0 0 0';
1181 float superweapons_is = -1;
1183 if(superweapons_time)
1188 superweapons_is = 0;
1190 superweapons_is = 2;
1195 superweapons_is = 1;
1197 superweapons_is = 2;
1201 // FIXME handle superweapons here
1202 if(superweapons_is == 0)
1204 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1206 mySize_x *= (1.0 / 3.0);
1207 superweapons_offset_x = mySize_x;
1208 if (autocvar_hud_panel_powerups_flip)
1209 shield_offset_x = 2*mySize_x;
1211 strength_offset_x = 2*mySize_x;
1215 mySize_y *= (1.0 / 3.0);
1216 superweapons_offset_y = mySize_y;
1217 if (autocvar_hud_panel_powerups_flip)
1218 shield_offset_y = 2*mySize_y;
1220 strength_offset_y = 2*mySize_y;
1225 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1228 if (autocvar_hud_panel_powerups_flip)
1229 shield_offset_x = mySize_x;
1231 strength_offset_x = mySize_x;
1236 if (autocvar_hud_panel_powerups_flip)
1237 shield_offset_y = mySize_y;
1239 strength_offset_y = mySize_y;
1243 float shield_baralign, strength_baralign, superweapons_baralign;
1244 float shield_iconalign, strength_iconalign, superweapons_iconalign;
1246 if (autocvar_hud_panel_powerups_flip)
1248 strength_baralign = (autocvar_hud_panel_powerups_baralign == 2 || autocvar_hud_panel_powerups_baralign == 1);
1249 shield_baralign = (autocvar_hud_panel_powerups_baralign == 3 || autocvar_hud_panel_powerups_baralign == 1);
1250 strength_iconalign = (autocvar_hud_panel_powerups_iconalign == 2 || autocvar_hud_panel_powerups_iconalign == 1);
1251 shield_iconalign = (autocvar_hud_panel_powerups_iconalign == 3 || autocvar_hud_panel_powerups_iconalign == 1);
1255 shield_baralign = (autocvar_hud_panel_powerups_baralign == 2 || autocvar_hud_panel_powerups_baralign == 1);
1256 strength_baralign = (autocvar_hud_panel_powerups_baralign == 3 || autocvar_hud_panel_powerups_baralign == 1);
1257 shield_iconalign = (autocvar_hud_panel_powerups_iconalign == 2 || autocvar_hud_panel_powerups_iconalign == 1);
1258 strength_iconalign = (autocvar_hud_panel_powerups_iconalign == 3 || autocvar_hud_panel_powerups_iconalign == 1);
1261 if(superweapons_is == 0)
1263 superweapons_iconalign = strength_iconalign;
1264 superweapons_baralign = 2;
1266 else if(superweapons_is == 1)
1268 superweapons_offset = strength_offset;
1269 superweapons_iconalign = strength_iconalign;
1270 superweapons_baralign = strength_baralign;
1272 else // if(superweapons_is == 2)
1274 superweapons_offset = shield_offset;
1275 superweapons_iconalign = shield_iconalign;
1276 superweapons_baralign = shield_baralign;
1281 const float maxshield = 30;
1282 float shield = ceil(shield_time);
1283 if(autocvar_hud_panel_powerups_progressbar)
1285 HUD_Panel_GetProgressBarColor(shield);
1286 HUD_Panel_DrawProgressBar(pos + shield_offset, mySize, autocvar_hud_panel_powerups_progressbar_shield, shield/maxshield, is_vertical, shield_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1288 if(autocvar_hud_panel_powerups_text)
1291 DrawNumIcon(pos + shield_offset, mySize, shield, "shield", is_vertical, shield_iconalign, '1 1 1', 1);
1293 DrawNumIcon_expanding(pos + shield_offset, mySize, shield, "shield", is_vertical, shield_iconalign, '1 1 1', 1, bound(0, (shield - shield_time) / 0.5, 1));
1299 const float maxstrength = 30;
1300 float strength = ceil(strength_time);
1301 if(autocvar_hud_panel_powerups_progressbar)
1303 HUD_Panel_GetProgressBarColor(strength);
1304 HUD_Panel_DrawProgressBar(pos + strength_offset, mySize, autocvar_hud_panel_powerups_progressbar_strength, strength/maxstrength, is_vertical, strength_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1306 if(autocvar_hud_panel_powerups_text)
1309 DrawNumIcon(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', 1);
1311 DrawNumIcon_expanding(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', 1, bound(0, (strength - strength_time) / 0.5, 1));
1315 if(superweapons_time)
1317 const float maxsuperweapons = 30;
1318 float superweapons = ceil(superweapons_time);
1319 if(autocvar_hud_panel_powerups_progressbar)
1321 HUD_Panel_GetProgressBarColor(superweapons);
1322 HUD_Panel_DrawProgressBar(pos + superweapons_offset, mySize, autocvar_hud_panel_powerups_progressbar_superweapons, superweapons/maxsuperweapons, is_vertical, superweapons_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1324 if(autocvar_hud_panel_powerups_text)
1326 if(superweapons > 1)
1327 DrawNumIcon(pos + superweapons_offset, mySize, superweapons, "superweapons", is_vertical, superweapons_iconalign, '1 1 1', 1);
1328 if(superweapons <= 5)
1329 DrawNumIcon_expanding(pos + superweapons_offset, mySize, superweapons, "superweapons", is_vertical, superweapons_iconalign, '1 1 1', 1, bound(0, (superweapons - superweapons_time) / 0.5, 1));
1336 // Health/armor (#3)
1339 // prev_* vars contain the health/armor at the previous FRAME
1340 // set to -1 when player is dead or was not playing
1341 float prev_health, prev_armor;
1342 float health_damagetime, armor_damagetime;
1343 float health_beforedamage, armor_beforedamage;
1344 // old_p_* vars keep track of previous values when smoothing value changes of the progressbar
1345 float old_p_health, old_p_armor;
1346 float old_p_healthtime, old_p_armortime;
1347 // prev_p_* vars contain the health/armor progressbar value at the previous FRAME
1348 // set to -1 to forcedly stop effects when we switch spectated player (e.g. from playerX: 70h to playerY: 50h)
1349 float prev_p_health, prev_p_armor;
1351 void HUD_HealthArmor(void)
1353 float armor, health, fuel;
1354 if(!autocvar__hud_configure)
1356 if(!autocvar_hud_panel_healtharmor) return;
1357 if(hud != HUD_NORMAL) return;
1358 if(spectatee_status == -1) return;
1360 health = getstati(STAT_HEALTH);
1366 armor = getstati(STAT_ARMOR);
1368 // code to check for spectatee_status changes is in Ent_ClientData()
1369 // prev_p_health and prev_health can be set to -1 there
1371 if (prev_p_health == -1)
1374 health_beforedamage = 0;
1375 armor_beforedamage = 0;
1376 health_damagetime = 0;
1377 armor_damagetime = 0;
1378 prev_health = health;
1380 old_p_health = health;
1381 old_p_armor = armor;
1382 prev_p_health = health;
1383 prev_p_armor = armor;
1385 else if (prev_health == -1)
1387 //start the load effect
1388 health_damagetime = 0;
1389 armor_damagetime = 0;
1393 fuel = getstati(STAT_FUEL);
1397 hud_configure_active_panel = HUD_PANEL_HEALTHARMOR;
1404 HUD_Panel_UpdateCvars(healtharmor);
1405 HUD_Panel_ApplyFadeAlpha();
1408 mySize = panel_size;
1410 HUD_Panel_DrawBg(1);
1411 if(panel_bg_padding)
1413 pos += '1 1 0' * panel_bg_padding;
1414 mySize -= '2 2 0' * panel_bg_padding;
1417 float baralign = autocvar_hud_panel_healtharmor_baralign;
1418 float iconalign = autocvar_hud_panel_healtharmor_iconalign;
1420 float maxhealth = autocvar_hud_panel_healtharmor_maxhealth;
1421 float maxarmor = autocvar_hud_panel_healtharmor_maxarmor;
1422 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
1425 v = healtharmor_maxdamage(health, armor, armorblockpercent);
1430 float maxtotal = maxhealth + maxarmor;
1432 if(v_z) // NOT fully armored
1434 biggercount = "health";
1435 if(autocvar_hud_panel_healtharmor_progressbar)
1437 HUD_Panel_GetProgressBarColor(health);
1438 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);
1441 if(autocvar_hud_panel_healtharmor_text)
1442 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);
1446 biggercount = "armor";
1447 if(autocvar_hud_panel_healtharmor_progressbar)
1449 HUD_Panel_GetProgressBarColor(armor);
1450 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);
1453 if(autocvar_hud_panel_healtharmor_text)
1454 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);
1456 if(autocvar_hud_panel_healtharmor_text)
1457 DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, maxtotal), 1);
1461 HUD_Panel_GetProgressBarColor(fuel);
1462 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);
1467 float panel_ar = mySize_x/mySize_y;
1468 float is_vertical = (panel_ar < 1);
1469 vector health_offset = '0 0 0', armor_offset = '0 0 0';
1470 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1473 if (autocvar_hud_panel_healtharmor_flip)
1474 health_offset_x = mySize_x;
1476 armor_offset_x = mySize_x;
1481 if (autocvar_hud_panel_healtharmor_flip)
1482 health_offset_y = mySize_y;
1484 armor_offset_y = mySize_y;
1487 float health_baralign, armor_baralign, fuel_baralign;
1488 float health_iconalign, armor_iconalign;
1489 if (autocvar_hud_panel_healtharmor_flip)
1491 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1492 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1493 fuel_baralign = health_baralign;
1494 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1495 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1499 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1500 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1501 fuel_baralign = armor_baralign;
1502 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1503 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1508 if(autocvar_hud_panel_healtharmor_progressbar)
1510 HUD_Panel_GetProgressBarColor(health);
1511 float p_health, pain_health_alpha;
1513 pain_health_alpha = 1;
1514 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1516 if (autocvar_hud_panel_healtharmor_progressbar_gfx_smooth > 0)
1518 if (fabs(prev_health - health) >= autocvar_hud_panel_healtharmor_progressbar_gfx_smooth)
1520 if (time - old_p_healthtime < 1)
1521 old_p_health = prev_p_health;
1523 old_p_health = prev_health;
1524 old_p_healthtime = time;
1526 if (time - old_p_healthtime < 1)
1528 p_health += (old_p_health - health) * (1 - (time - old_p_healthtime));
1529 prev_p_health = p_health;
1532 if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0)
1534 if (prev_health - health >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
1536 if (time - health_damagetime >= 1)
1537 health_beforedamage = prev_health;
1538 health_damagetime = time;
1540 if (time - health_damagetime < 1)
1542 float health_damagealpha = 1 - (time - health_damagetime)*(time - health_damagetime);
1543 HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, health_beforedamage/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * health_damagealpha, DRAWFLAG_NORMAL);
1546 prev_health = health;
1548 if (health <= autocvar_hud_panel_healtharmor_progressbar_gfx_lowhealth)
1550 float BLINK_FACTOR = 0.15;
1551 float BLINK_BASE = 0.85;
1552 float BLINK_FREQ = 9;
1553 pain_health_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
1556 HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, p_health/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * pain_health_alpha, DRAWFLAG_NORMAL);
1558 if(autocvar_hud_panel_healtharmor_text)
1559 DrawNumIcon(pos + health_offset, mySize, health, "health", is_vertical, health_iconalign, HUD_Get_Num_Color(health, maxhealth), 1);
1564 if(autocvar_hud_panel_healtharmor_progressbar)
1566 HUD_Panel_GetProgressBarColor(armor);
1569 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1571 if (autocvar_hud_panel_healtharmor_progressbar_gfx_smooth > 0)
1573 if (fabs(prev_armor - armor) >= autocvar_hud_panel_healtharmor_progressbar_gfx_smooth)
1575 if (time - old_p_armortime < 1)
1576 old_p_armor = prev_p_armor;
1578 old_p_armor = prev_armor;
1579 old_p_armortime = time;
1581 if (time - old_p_armortime < 1)
1583 p_armor += (old_p_armor - armor) * (1 - (time - old_p_armortime));
1584 prev_p_armor = p_armor;
1587 if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0)
1589 if (prev_armor - armor >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
1591 if (time - armor_damagetime >= 1)
1592 armor_beforedamage = prev_armor;
1593 armor_damagetime = time;
1595 if (time - armor_damagetime < 1)
1597 float armor_damagealpha = 1 - (time - armor_damagetime)*(time - armor_damagetime);
1598 HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, armor_beforedamage/maxarmor, is_vertical, armor_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * armor_damagealpha, DRAWFLAG_NORMAL);
1603 HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, p_armor/maxarmor, is_vertical, armor_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1605 if(autocvar_hud_panel_healtharmor_text)
1606 DrawNumIcon(pos + armor_offset, mySize, armor, "armor", is_vertical, armor_iconalign, HUD_Get_Num_Color(armor, maxarmor), 1);
1612 mySize_x *= 0.2 / 2; //if vertical always halve x to not cover too much numbers with 3 digits
1616 mySize_x *= 2; //restore full panel size
1617 else if (panel_ar < 1/4)
1618 mySize_y *= 2; //restore full panel size
1619 HUD_Panel_GetProgressBarColor(fuel);
1620 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
1625 // Notification area (#4)
1628 string Weapon_SuicideMessage(float deathtype)
1630 w_deathtype = deathtype;
1631 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
1632 return w_deathtypestring;
1635 string Weapon_KillMessage(float deathtype)
1637 w_deathtype = deathtype;
1638 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
1639 return w_deathtypestring;
1643 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
1647 float alsoprint, gentle;
1648 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
1649 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
1651 if ((msg == MSG_SUICIDE || msg == MSG_KILL || msg == MSG_KILL_ACTION) && gametype == MAPINFO_TYPE_CTS) // selfkill isn't interesting in CTS and only spams up the notify panel
1654 if(msg == MSG_SUICIDE) {
1655 w = DEATH_WEAPONOF(type);
1657 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1659 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
1660 } else if (type == DEATH_KILL) {
1661 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
1663 print (sprintf(_("^1%s^1 couldn't take it anymore\n"), s1));
1664 } else if (type == DEATH_ROT) {
1665 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1667 print (sprintf(_("^1%s^1 died\n"), s1));
1668 } else if (type == DEATH_NOAMMO) {
1669 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
1671 print (sprintf(_("^7%s^7 committed suicide. What's the point of living without ammo?\n"), s1));
1672 } else if (type == DEATH_CAMP) {
1673 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
1675 print (sprintf(_("^1%s^1 thought they found a nice camping ground\n"), s1));
1676 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
1677 HUD_KillNotify_Push(s1, "", 0, type);
1679 print (sprintf(_("^1%s^1 didn't become friends with the Lord of Teamplay\n"), s1));
1680 } else if (type == DEATH_CHEAT) {
1681 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1683 print (sprintf(_("^1%s^1 unfairly eliminated themself\n"), s1));
1684 } else if (type == DEATH_FIRE) {
1685 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1687 print (sprintf(_("^1%s^1 burned to death\n"), s1));
1688 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
1689 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1691 print (sprintf(_("^1%s^1 couldn't resist the urge to self-destruct\n"), s1));
1694 if (stof(s2) > 2) // killcount > 2
1695 print (sprintf(_("^1%s^1 ended it all after a %d kill spree\n"), s1, stof(s2)));
1696 } else if(msg == MSG_KILL) {
1697 w = DEATH_WEAPONOF(type);
1699 HUD_KillNotify_Push(s1, s2, 1, type);
1701 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
1703 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
1704 HUD_KillNotify_Push(s1, s2, 1, type);
1708 print (sprintf(_("^1%s^1 took action against a team mate\n"), s1));
1710 print (sprintf(_("^1%s^1 mows down a team mate\n"), s1));
1713 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
1715 print (sprintf(_("^1%s^1 ended a %d scoring spree by going against a team mate\n"), s1, stof(s3)));
1717 print (sprintf(_("^1%s^1 ended a %d kill spree by killing a team mate\n"), s1, stof(s3)));
1719 else if (stof(s2) > 2) {
1721 print (sprintf(_("^1%s^1's %s scoring spree was ended by a team mate!\n"), s1, stof(s3)));
1723 print (sprintf(_("^1%s^1's %s kill spree was ended by a team mate!\n"), s1, stof(s3)));
1726 else if(type == KILL_FIRST_BLOOD)
1727 print(sprintf(_("^1%s^1 drew first blood\n"), s1));
1728 else if (type == DEATH_TELEFRAG) {
1729 HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
1731 print (sprintf(_("^1%s^1 tried to occupy %s^1's teleport destination space\n"), s2, s1));
1733 print (sprintf(_("^1%s^1 was telefragged by %s\n"), s2, s1));
1735 else if (type == DEATH_DROWN) {
1736 HUD_KillNotify_Push(s1, s2, 1, DEATH_DROWN);
1738 print (sprintf(_("^1%s^1 was drowned by %s\n"), s2, s1));
1740 else if (type == DEATH_SLIME) {
1741 HUD_KillNotify_Push(s1, s2, 1, DEATH_SLIME);
1743 print (sprintf(_("^1%s^1 was slimed by %s\n"), s2, s1));
1745 else if (type == DEATH_LAVA) {
1746 HUD_KillNotify_Push(s1, s2, 1, DEATH_LAVA);
1748 print (sprintf(_("^1%s^1 was cooked by %s\n"), s2, s1));
1750 else if (type == DEATH_FALL) {
1751 HUD_KillNotify_Push(s1, s2, 1, DEATH_FALL);
1753 print (sprintf(_("^1%s^1 was grounded by %s\n"), s2, s1));
1755 else if (type == DEATH_SHOOTING_STAR) {
1756 HUD_KillNotify_Push(s1, s2, 1, DEATH_SHOOTING_STAR);
1758 print (sprintf(_("^1%s^1 was shot into space by %s\n"), s2, s1));
1760 else if (type == DEATH_SWAMP) {
1761 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1763 print (sprintf(_("^1%s^1 was conserved by %s\n"), s2, s1));
1765 else if (type == DEATH_HURTTRIGGER)
1767 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1769 print(sprintf(_("^1%s^1 was thrown into a world of hurt by %s\n"), s2, s1));
1770 } else if(type == DEATH_VHCRUSH) {
1771 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1773 print (sprintf(_("^1%s^1 was crushed by %s\n"), s2, s1));
1774 } else if(type == DEATH_SBMINIGUN) {
1775 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1777 print (sprintf(_("^1%s^1 got shredded by %s\n"), s2, s1));
1778 } else if(type == DEATH_SBROCKET) {
1779 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1781 print (sprintf(_("^1%s^1 was blasted to bits by %s\n"), s2, s1));
1782 } else if(type == DEATH_SBBLOWUP) {
1783 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1785 print (sprintf(_("^1%s^1 got caught in the blast when %s^1's destroys a vehicle\n"), s2, s1));
1786 } else if(type == DEATH_WAKIGUN) {
1787 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1789 print (sprintf(_("^1%s^1 was bolted down by %s\n"), s2, s1));
1790 } else if(type == DEATH_BUMB_GUN) {
1791 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1793 print (sprintf(_("^1%s^1 saw %s's preddy lights.\n"), s2, s1));
1794 } else if(type == DEATH_WAKIROCKET) {
1795 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1797 print (sprintf(_("^1%s^1 could find no shelter from %s^1's rockets\n"), s2, s1));
1798 } else if(type == DEATH_WAKIBLOWUP) {
1799 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1801 print (sprintf(_("^1%s^1 got caught in the blast when %s^1's destroys a vehicle\n"), s2, s1));
1802 } else if(type == DEATH_RAPTOR_CANNON) {
1803 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1805 print (sprintf(_("^1%s^1 nailed to hell by %s\n"), s2, s1));
1806 } else if(type == DEATH_RAPTOR_BOMB) {
1807 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1809 print (sprintf(_("^1%s^1 cluster crushed by %s\n"), s2, s1));
1810 } else if(type == DEATH_RAPTOR_DEATH) {
1811 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1813 print (sprintf(_("^1%s^1 got caught in the blast when %s^1's destroys a vehicle\n"), s2, s1));
1814 } else if(type == DEATH_TURRET) {
1815 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1817 print (sprintf(_("^1%s^1 was pushed into the line of fire by %s\n"), s2, s1));
1818 } else if(type == DEATH_TOUCHEXPLODE) {
1819 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1821 print (sprintf(_("^1%s^1 was pushed into an accident by %s\n"), s2, s1));
1822 } else if(type == DEATH_CHEAT) {
1823 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1825 print (sprintf(_("^1%s^1 was unfairly eliminated by %s\n"), s2, s1));
1826 } else if (type == DEATH_FIRE) {
1827 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1829 print (sprintf(_("^1%s^1 was burnt to death by %s\n"), s2, s1));
1830 } else if (type == DEATH_CUSTOM) {
1831 HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM);
1833 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1834 } else if (type == DEATH_HURTTRIGGER) {
1835 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1837 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1839 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1841 print (sprintf(_("^1%s^1 was fragged by %s\n"), s2, s1));
1843 } else if(msg == MSG_SPREE) {
1844 if(type == KILL_END_SPREE) {
1846 print (sprintf(_("^1%s^1's %s scoring spree was ended by %s\n"), s1, s2, s3));
1848 print (sprintf(_("^1%s^1's %s kill spree was ended by %s\n"), s1, s2, s3));
1849 } else if(type == KILL_SPREE) {
1851 print (sprintf(_("^1%s^1 made %s scores in a row\n"), s1, s2));
1853 print (sprintf(_("^1%s^1 has %s frags in a row\n"), s1, s2));
1854 } else if(type == KILL_SPREE_3) {
1856 print (sprintf(_("%s^7 made a ^1TRIPLE SCORE\n"), s1));
1858 print (sprintf(_("%s^7 made a ^1TRIPLE FRAG\n"), s1));
1859 } else if(type == KILL_SPREE_5) {
1861 print (sprintf(_("%s^7 unleashes ^1SCORING RAGE\n"), s1));
1863 print (sprintf(_("%s^7 unleashes ^1RAGE\n"), s1));
1864 } else if(type == KILL_SPREE_10) {
1866 print (sprintf(_("%s^7 made ^1TEN SCORES IN A ROW!\n"), s1));
1868 print (sprintf(_("%s^7 starts the ^1MASSACRE!\n"), s1));
1869 } else if(type == KILL_SPREE_15) {
1871 print (sprintf(_("%s^7 made ^1FIFTEEN SCORES IN A ROW!\n"), s1));
1873 print (sprintf(_("%s^7 executes ^1MAYHEM!\n"), s1));
1874 } else if(type == KILL_SPREE_20) {
1876 print (sprintf(_("%s^7 made ^1TWENTY SCORES IN A ROW!\n"), s1));
1878 print (sprintf(_("%s^7 is a ^1BERSERKER!\n"), s1));
1879 } else if(type == KILL_SPREE_25) {
1881 print (sprintf(_("%s^7 made ^1TWENTY FIVE SCORES IN A ROW!\n"), s1));
1883 print (sprintf(_("%s^7 inflicts ^1CARNAGE!\n"), s1));
1884 } else if(type == KILL_SPREE_30) {
1886 print (sprintf(_("%s^7 made ^1THIRTY SCORES IN A ROW!\n"), s1));
1888 print (sprintf(_("%s^7 unleashes ^1ARMAGEDDON!\n"), s1));
1890 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
1891 if (type == DEATH_DROWN) {
1892 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
1896 print (sprintf(_("^1%s^1 was in the water for too long\n"), s1));
1898 print (sprintf(_("^1%s^1 drowned\n"), s1));
1900 } else if (type == DEATH_SLIME) {
1901 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
1903 print (sprintf(_("^1%s^1 was slimed\n"), s1));
1904 } else if (type == DEATH_LAVA) {
1905 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
1909 print (sprintf(_("^1%s^1 found a hot place\n"), s1));
1911 print (sprintf(_("^1%s^1 turned into hot slag\n"), s1));
1913 } else if (type == DEATH_FALL) {
1914 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1918 print (sprintf(_("^1%s^1 tested gravity (and it worked)\n"), s1));
1920 print (sprintf(_("^1%s^1 hit the ground with a crunch\n"), s1));
1922 } else if (type == DEATH_SHOOTING_STAR) {
1923 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
1925 print (sprintf(_("^1%s^1 became a shooting star\n"), s1));
1926 } else if (type == DEATH_SWAMP) {
1927 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1931 print (sprintf(_("^1%s^1 discovered a swamp\n"), s1));
1933 print (sprintf(_("^1%s^1 is now conserved for centuries to come\n"), s1));
1935 } else if(DEATH_ISTURRET(type)) {
1936 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1940 print (sprintf(_("^1%s^1 ran into a turret\n"), s1));
1945 case DEATH_TURRET_EWHEEL:
1946 print (sprintf(_("^1%s^1 was laserd down by a eWheel turret \n"), s1));
1948 case DEATH_TURRET_FLAC:
1949 print (sprintf(_("^1%s^1 got caught in the flac \n"), s1));
1951 case DEATH_TURRET_MACHINEGUN:
1952 print (sprintf(_("^1%s^1 was riddeld full of riddled by a machinegun turret \n"), s1));
1954 case DEATH_TURRET_WALKER_GUN:
1955 print (sprintf(_("^1%s^1 got served a led enrichment by a walker turret \n"), s1));
1957 case DEATH_TURRET_WALKER_MEELE:
1958 print (sprintf(_("^1%s^1 was impaled by a walker turret \n"), s1));
1960 case DEATH_TURRET_WALKER_ROCKET:
1961 print (sprintf(_("^1%s^1 was rocketed to hell by a walker turret \n"), s1));
1963 case DEATH_TURRET_HELLION:
1964 print (sprintf(_("^1%s^1 was blasted away hellion turret \n"), s1));
1966 case DEATH_TURRET_HK:
1967 print (sprintf(_("^1%s^1 could not hide from the hunter turret \n"), s1));
1969 case DEATH_TURRET_MLRS:
1970 print (sprintf(_("^1%s^1 got turned into smoldering gibs by a mlrs turret \n"), s1));
1972 case DEATH_TURRET_PLASMA:
1973 print (sprintf(_("^1%s^1 got served some superheated plasma from a plasma turret \n"), s1));
1975 case DEATH_TURRET_PHASER:
1976 print (sprintf(_("^1%s^1 was phased out \n"), s1));
1978 case DEATH_TURRET_TESLA:
1979 print (sprintf(_("^1%s^1 was electrocuted by a tesla turret \n"), s1));
1984 } else if (type == DEATH_CUSTOM) {
1985 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
1987 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1988 } else if (type == DEATH_HURTTRIGGER) {
1989 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
1991 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1992 } else if(type == DEATH_TOUCHEXPLODE) {
1993 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1995 print (sprintf(_("^1%s^1 died in an accident\n"), s1));
1996 } else if(type == DEATH_CHEAT) {
1997 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1999 print (sprintf(_("^1%s^1 was unfairly eliminated\n"), s1));
2000 } else if(type == DEATH_FIRE) {
2001 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2005 print (sprintf(_("^1%s^1 felt a little hot\n"), s1));
2007 print (sprintf(_("^1%s^1 burnt to death\n"), s1));
2010 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2014 print (sprintf(_("^1%s^1 needs a restart\n"), s1));
2016 print (sprintf(_("^1%s^1 died\n"), s1));
2019 } else if(msg == MSG_KILL_ACTION_SPREE) {
2021 print (sprintf(_("^1%s^1 needs a restart after a %d scoring spree\n"), s1, stof(s2)));
2023 print (sprintf(_("^1%s^1 died with a %d kill spree\n"), s1, stof(s2)));
2024 } else if(msg == MSG_INFO) {
2025 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2026 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2027 print(sprintf(_("%s^7 got the %s\n"), s1, s2));
2028 } else if(type == INFO_LOSTFLAG) {
2029 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2030 print(sprintf(_("%s^7 lost the %s\n"), s1, s2));
2031 } else if(type == INFO_PICKUPFLAG) {
2032 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2033 print(sprintf(_("%s^7 picked up the %s\n"), s1, s2));
2034 } else if(type == INFO_RETURNFLAG) {
2035 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2036 print(sprintf(_("%s^7 returned the %s\n"), s1, s2));
2037 } else if(type == INFO_CAPTUREFLAG) {
2038 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
2039 print(sprintf(_("%s^7 captured the %s%s\n"), s1, s2, s3));
2041 } else if(msg == MSG_RACE) {
2042 if(type == RACE_SERVER_RECORD) {
2043 HUD_KillNotify_Push(s1, s2, 1, RACE_SERVER_RECORD);
2045 else if(type == RACE_NEW_RANK) {
2046 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_RANK);
2048 else if(type == RACE_NEW_TIME) {
2049 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_TIME);
2051 else if(type == RACE_FAIL) {
2052 HUD_KillNotify_Push(s1, s2, 1, RACE_FAIL);
2054 } else if(msg == MSG_KA) {
2055 if(type == KA_PICKUPBALL) {
2056 HUD_KillNotify_Push(s1, s2, 0, KA_PICKUPBALL);
2058 print (sprintf(_("%s^7 has picked up the ball!\n"), s1));
2060 else if(type == KA_DROPBALL) {
2061 HUD_KillNotify_Push(s1, s2, 0, KA_DROPBALL);
2063 print(sprintf(_("%s^7 has dropped the ball!\n"), s1));
2068 void HUD_KillCenterprint(string s1, string s2, float type, float msg)
2071 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2072 if(msg == MSG_SUICIDE) {
2073 if (type == DEATH_TEAMCHANGE) {
2074 centerprint_hud(sprintf(_("You are now on: %s"), s1));
2075 } else if (type == DEATH_AUTOTEAMCHANGE) {
2076 centerprint_hud(sprintf(_("You have been moved into a different team to improve team balance\nYou are now on: %s"), s1));
2077 } else if (type == DEATH_CAMP) {
2079 centerprint_hud(_("^1Reconsider your tactics, camper!"));
2081 centerprint_hud(_("^1Die camper!"));
2082 } else if (type == DEATH_NOAMMO) {
2084 centerprint_hud(_("^1You are reinserted into the game for running out of ammo..."));
2086 centerprint_hud(_("^1You were killed for running out of ammo..."));
2087 } else if (type == DEATH_ROT) {
2089 centerprint_hud(_("^1You need to preserve your health"));
2091 centerprint_hud(_("^1You grew too old without taking your medicine"));
2092 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2094 centerprint_hud(_("^1Don't go against team mates!"));
2096 centerprint_hud(_("^1Don't shoot your team mates!"));
2097 } else { // generic message
2099 centerprint_hud(_("^1You need to be more careful!"));
2101 centerprint_hud(_("^1You killed your own dumb self!"));
2103 } else if(msg == MSG_KILL) {
2104 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2106 centerprint_hud(sprintf(_("^1Moron! You went against ^7%s^1, a team mate!"), s1));
2108 centerprint_hud(sprintf(_("^1Moron! You fragged ^7%s^1, a team mate!"), s1));
2110 } else if (type == KILL_FIRST_BLOOD) {
2112 centerprint_hud(_("^1First score"));
2114 centerprint_hud(_("^1First blood"));
2116 } else if (type == KILL_FIRST_VICTIM) {
2118 centerprint_hud(_("^1First casualty"));
2120 centerprint_hud(_("^1First victim"));
2122 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2124 centerprint_hud(strcat(sprintf(_("^1You scored against ^7%s^1 who was typing!"), s1), s2));
2126 centerprint_hud(strcat(sprintf(_("^1You typefragged ^7%s"), s1), s2));
2128 } else if (type == KILL_TYPEFRAGGED) {
2130 centerprint_hud(strcat(sprintf(_("^1You were scored against by ^7%s^1 while you were typing!"), s1), s2));
2132 centerprint_hud(strcat(sprintf(_("^1You were typefragged by ^7%s"), s1), s2));
2134 } else if (type == KILL_FRAG) {
2136 centerprint_hud(strcat(sprintf(_("^4You scored against ^7%s"), s1), s2));
2138 centerprint_hud(strcat(sprintf(_("^4You fragged ^7%s"), s1), s2));
2140 } else { // generic message
2142 centerprint_hud(strcat(sprintf(_("^1You were scored against by ^7%s"), s1), s2));
2144 centerprint_hud(strcat(sprintf(_("^1You were fragged by ^7%s"), s1), s2));
2147 } else if(msg == MSG_KILL_ACTION) {
2148 // TODO: invent more centerprints here?
2149 centerprint_hud(_("^1Watch your step!"));
2153 void HUD_Notify(void)
2155 if(!autocvar__hud_configure)
2157 if(!autocvar_hud_panel_notify) return;
2160 hud_configure_active_panel = HUD_PANEL_NOTIFY;
2162 HUD_Panel_UpdateCvars(notify);
2163 HUD_Panel_ApplyFadeAlpha();
2166 mySize = panel_size;
2168 HUD_Panel_DrawBg(1);
2169 if(panel_bg_padding)
2171 pos += '1 1 0' * panel_bg_padding;
2172 mySize -= '2 2 0' * panel_bg_padding;
2175 float entries, height;
2176 entries = bound(1, floor(KN_MAX_ENTRIES * mySize_y/mySize_x), KN_MAX_ENTRIES);
2177 height = mySize_y/entries;
2180 float fontheight = height * autocvar_hud_panel_notify_fontsize;
2181 fontsize = '0.5 0.5 0' * fontheight;
2185 when = autocvar_hud_panel_notify_time;
2187 fadetime = autocvar_hud_panel_notify_fadetime;
2189 vector pos_attacker, pos_victim, pos_icon;
2190 float width_attacker;
2191 string attacker, victim, icon;
2193 float i, j, step, limit;
2194 if(autocvar_hud_panel_notify_flip) //order items from the top down
2200 else //order items from the bottom up
2207 for(j = kn_index; i != limit; i += step, ++j)
2209 if(autocvar__hud_configure)
2213 else // inverse order
2214 a = entries - 1 - i;
2215 attacker = textShortenToWidth(sprintf(_("Player %d"), a+1), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2216 victim = textShortenToWidth(sprintf(_("Player %d"), a+2), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2217 icon = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname);
2218 a = bound(0, (when - a) / 4, 1);
2219 goto hud_config_notifyprint;
2223 if (j == KN_MAX_ENTRIES)
2226 if(killnotify_times[j] + when > time)
2230 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2241 attacker = killnotify_attackers[j];
2242 victim = killnotify_victims[j];
2243 icon = killnotify_icon[j];
2246 //type = killnotify_deathtype[j];
2247 //w = DEATH_WEAPONOF(type);
2251 if((attacker != "") && (victim == ""))
2254 attacker = textShortenToWidth(attacker, 0.73 * mySize_x - height, fontsize, stringwidth_colors);
2255 pos_attacker = pos + eX * (0.27 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2256 pos_icon = pos + eX * 0.25 * mySize_x - eX * height + eY * i * height;
2258 drawpic_aspect_skin(pos_icon, icon, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2259 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2261 else if((attacker != "") && (victim != ""))
2263 // X [did action to] Y
2264 attacker = textShortenToWidth(attacker, 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2265 victim = textShortenToWidth(victim, 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2266 :hud_config_notifyprint
2267 width_attacker = stringwidth(attacker, TRUE, fontsize);
2268 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2269 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2270 pos_icon = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2272 drawpic_aspect_skin(pos_icon, icon, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2273 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2274 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2283 string seconds_tostring(float sec)
2286 minutes = floor(sec / 60);
2288 sec -= minutes * 60;
2289 return sprintf("%d:%02d", minutes, sec);
2292 void HUD_Timer(void)
2294 if(!autocvar__hud_configure)
2296 if(!autocvar_hud_panel_timer) return;
2299 hud_configure_active_panel = HUD_PANEL_TIMER;
2301 HUD_Panel_UpdateCvars(timer);
2302 HUD_Panel_ApplyFadeAlpha();
2304 draw_beginBoldFont();
2308 mySize = panel_size;
2310 HUD_Panel_DrawBg(1);
2311 if(panel_bg_padding)
2313 pos += '1 1 0' * panel_bg_padding;
2314 mySize -= '2 2 0' * panel_bg_padding;
2318 float timelimit, elapsedTime, timeleft, minutesLeft;
2320 timelimit = getstatf(STAT_TIMELIMIT);
2322 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
2323 timeleft = ceil(timeleft);
2325 minutesLeft = floor(timeleft / 60);
2328 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
2329 timer_color = '1 1 1'; //white
2330 else if(minutesLeft >= 1)
2331 timer_color = '1 1 0'; //yellow
2333 timer_color = '1 0 0'; //red
2335 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
2336 if (time < getstatf(STAT_GAMESTARTTIME)) {
2337 //while restart is still active, show 00:00
2338 timer = seconds_tostring(0);
2340 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
2341 timer = seconds_tostring(elapsedTime);
2344 timer = seconds_tostring(timeleft);
2347 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2354 void HUD_Radar(void)
2356 if (!autocvar__hud_configure)
2358 if (hud_panel_radar_maximized)
2360 if (!hud_draw_maximized) return;
2364 if (autocvar_hud_panel_radar == 0) return;
2365 if (autocvar_hud_panel_radar != 2 && !teamplay) return;
2369 hud_configure_active_panel = HUD_PANEL_RADAR;
2371 HUD_Panel_UpdateCvars(radar);
2372 HUD_Panel_ApplyFadeAlpha();
2374 if (hud_panel_radar_maximized && !autocvar__hud_configure)
2376 panel_size = autocvar_hud_panel_radar_maximized_size;
2377 panel_size_x = bound(0.2, panel_size_x, 1) * vid_conwidth;
2378 panel_size_y = bound(0.2, panel_size_y, 1) * vid_conheight;
2379 panel_pos_x = (vid_conwidth - panel_size_x) / 2;
2380 panel_pos_y = (vid_conheight - panel_size_y) / 2;
2382 panel_bg = strcat(hud_skin_path, "/border_default"); // always use the default border when maximized
2383 if(precache_pic(panel_bg) == "") { panel_bg = "gfx/hud/default/border_default"; } // fallback
2388 mySize = panel_size;
2390 HUD_Panel_DrawBg(1);
2391 if(panel_bg_padding)
2393 pos += '1 1 0' * panel_bg_padding;
2394 mySize -= '2 2 0' * panel_bg_padding;
2399 float scale2d, normalsize, bigsize;
2402 teamradar_origin2d = pos + 0.5 * mySize;
2403 teamradar_size2d = mySize;
2405 if(minimapname == "")
2408 teamradar_loadcvars();
2410 switch(hud_panel_radar_zoommode)
2414 f = current_zoomfraction;
2417 f = 1 - current_zoomfraction;
2427 switch(hud_panel_radar_rotation)
2430 teamradar_angle = view_angles_y - 90;
2433 teamradar_angle = 90 * hud_panel_radar_rotation;
2437 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
2438 teamradar_size2d = mySize;
2440 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
2442 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
2443 if(hud_panel_radar_rotation == 0)
2445 // max-min distance must fit the radar in any rotation
2446 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_scale));
2450 vector c0, c1, c2, c3, span;
2451 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
2452 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
2453 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
2454 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
2456 span_x = max(c0_x, c1_x, c2_x, c3_x) - min(c0_x, c1_x, c2_x, c3_x);
2457 span_y = max(c0_y, c1_y, c2_y, c3_y) - min(c0_y, c1_y, c2_y, c3_y);
2459 // max-min distance must fit the radar in x=x, y=y
2461 teamradar_size2d_x * scale2d / (1.05 * span_x),
2462 teamradar_size2d_y * scale2d / (1.05 * span_y)
2466 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
2467 if(bigsize > normalsize)
2468 normalsize = bigsize;
2472 + (1 - f) * normalsize;
2473 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
2475 + (1 - f) * view_origin);
2484 draw_teamradar_background(hud_panel_radar_foreground_alpha);
2486 for(tm = world; (tm = find(tm, classname, "radarlink")); )
2487 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
2488 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
2489 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
2490 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
2492 color2 = GetPlayerColor(tm.sv_entnum);
2493 //if(color == FL_SPECTATOR || color == color2)
2494 draw_teamradar_player(tm.origin, tm.angles, Team_ColorRGB(color2));
2496 draw_teamradar_player(view_origin, view_angles, '1 1 1');
2498 drawresetcliparea();
2503 void HUD_UpdatePlayerTeams();
2504 void HUD_Score_Rankings(vector pos, vector mySize, entity me, float team_count)
2507 entity tm = world, pl;
2508 #define SCOREPANEL_MAX_ENTRIES 6
2509 #define SCOREPANEL_ASPECTRATIO 2
2510 float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
2511 vector fontsize = '1 1 0' * (mySize_y/entries);
2513 vector rgb, score_color;
2515 score_color = '1 1 1';
2517 float name_size = mySize_x*0.75;
2518 float spacing_size = mySize_x*0.04;
2519 const float highlight_alpha = 0.2;
2520 float i = 0, me_printed = 0, first_pl = 0;
2522 if (autocvar__hud_configure)
2524 float players_per_team = 0;
2527 // show team scores in the first line
2528 float score_size = mySize_x / team_count;
2529 players_per_team = max(2, ceil((entries - 1) / team_count));
2530 for(i=0; i<team_count; ++i) {
2531 if (i == floor((entries - 2) / players_per_team) || (entries == 1 && i == 0))
2532 HUD_Panel_DrawHighlight(pos + eX * score_size * i, eX * score_size + eY * fontsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2533 drawstring_aspect(pos + eX * score_size * i, ftos(175 - 23*i), eX * score_size + eY * fontsize_y, Team_ColorRGB(ColorByTeam(i)) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2536 pos_y += fontsize_y;
2538 score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
2539 for (i=first_pl; i<entries; ++i)
2541 //simulate my score is lower than all displayed players,
2542 //so that I don't appear at all showing pure rankings.
2543 //This is to better show the difference between the 2 ranking views
2544 if (i == entries-1 && autocvar_hud_panel_score_rankings == 1)
2547 drawfill(pos, eX * mySize_x + eY * fontsize_y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2548 s = GetPlayerName(player_localnum);
2553 s = sprintf(_("Player %d"), i + 1 - first_pl);
2558 score_color = Team_ColorRGB(ColorByTeam(floor((i - first_pl) / players_per_team))) * 0.8;
2559 s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
2560 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2561 drawstring(pos + eX * (name_size + spacing_size), ftos(score), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2562 pos_y += fontsize_y;
2567 if (!scoreboard_fade_alpha) // the scoreboard too calls HUD_UpdatePlayerTeams
2568 HUD_UpdatePlayerTeams();
2571 // show team scores in the first line
2572 float score_size = mySize_x / team_count;
2573 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2574 if(tm.team == FL_SPECTATOR)
2576 if (tm.team == myteam)
2577 drawfill(pos + eX * score_size * i, eX * score_size + eY * fontsize_y, '1 1 1', highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2578 drawstring_aspect(pos + eX * score_size * i, ftos(tm.(teamscores[ts_primary])), eX * score_size + eY * fontsize_y, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2582 pos_y += fontsize_y;
2583 tm = teams.sort_next;
2588 for (pl = players.sort_next; pl && i<entries; pl = pl.sort_next)
2590 if ((team_count && pl.team != tm.team) || pl.team == FL_SPECTATOR)
2593 if (i == entries-1 && !me_printed && pl != me)
2594 if (autocvar_hud_panel_score_rankings == 1 && spectatee_status != -1)
2596 for (pl = me.sort_next; pl; pl = pl.sort_next)
2597 if (pl.team != FL_SPECTATOR)
2601 rgb = '1 1 0'; //not last but not among the leading players: yellow
2603 rgb = '1 0 0'; //last: red
2610 rgb = '0 1 0'; //first: green
2612 drawfill(pos, eX * mySize_x + eY * fontsize_y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2615 score_color = Team_ColorRGB(pl.team) * 0.8;
2616 s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
2617 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2618 drawstring(pos + eX * (name_size + spacing_size), ftos(pl.(scores[ps_primary])), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2619 pos_y += fontsize_y;
2622 while (i<entries && team_count && (tm = tm.sort_next) && (tm.team != FL_SPECTATOR || (tm = tm.sort_next)));
2625 void HUD_Score(void)
2627 if(!autocvar__hud_configure)
2629 if(!autocvar_hud_panel_score) return;
2630 if(spectatee_status == -1 && (gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) return;
2633 hud_configure_active_panel = HUD_PANEL_SCORE;
2635 HUD_Panel_UpdateCvars(score);
2636 HUD_Panel_ApplyFadeAlpha();
2639 mySize = panel_size;
2641 HUD_Panel_DrawBg(1);
2642 if(panel_bg_padding)
2644 pos += '1 1 0' * panel_bg_padding;
2645 mySize -= '2 2 0' * panel_bg_padding;
2648 float score, distribution = 0;
2650 vector distribution_color;
2653 #ifdef COMPAT_XON050_ENGINE
2654 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
2656 me = playerslots[player_localentnum - 1];
2659 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
2660 string timer, distrtimer;
2662 pl = players.sort_next;
2665 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
2666 if(pl.scores[ps_primary] == 0)
2669 score = me.(scores[ps_primary]);
2670 timer = TIME_ENCODED_TOSTRING(score);
2672 draw_beginBoldFont();
2673 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
2674 // distribution display
2675 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2677 distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS);
2679 if (distribution <= 0) {
2680 distribution_color = '0 1 0';
2684 distribution_color = '1 0 0';
2687 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);
2689 // race record display
2690 if (distribution <= 0)
2691 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2692 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2694 } else if (!teamplay) { // non-teamgames
2695 if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings)
2697 HUD_Score_Rankings(pos, mySize, me, 0);
2700 // me vector := [team/connected frags id]
2701 pl = players.sort_next;
2705 if(autocvar__hud_configure)
2708 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2712 score = me.(scores[ps_primary]);
2713 if(autocvar__hud_configure)
2716 if(distribution >= 5)
2717 distribution_color = eY;
2718 else if(distribution >= 0)
2719 distribution_color = '1 1 1';
2720 else if(distribution >= -5)
2721 distribution_color = '1 1 0';
2723 distribution_color = eX;
2725 string distribution_str;
2726 distribution_str = ftos(distribution);
2727 draw_beginBoldFont();
2728 if (distribution >= 0)
2730 if (distribution > 0)
2731 distribution_str = strcat("+", distribution_str);
2732 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2734 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2735 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);
2737 } else { // teamgames
2738 float scores_count = 0, row, column, rows = 0, columns = 0;
2739 local noref vector offset = '0 0 0';
2740 vector score_pos, score_size; //for scores other than myteam
2741 if (spectatee_status == -1 || autocvar_hud_panel_score_rankings)
2743 for(tm = teams.sort_next; tm, tm.team != FL_SPECTATOR; tm = tm.sort_next)
2745 if (autocvar_hud_panel_score_rankings)
2747 HUD_Score_Rankings(pos, mySize, me, scores_count);
2750 rows = mySize_y/mySize_x;
2751 rows = bound(1, floor((sqrt(4 * (3/1) * rows * scores_count + rows * rows) + rows + 0.5) / 2), scores_count);
2752 // ^^^ ammo item aspect goes here
2754 columns = ceil(scores_count/rows);
2756 score_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
2759 if(score_size_x/score_size_y > 3)
2761 newSize = 3 * score_size_y;
2762 offset_x = score_size_x - newSize;
2763 pos_x += offset_x/2;
2764 score_size_x = newSize;
2768 newSize = 1/3 * score_size_x;
2769 offset_y = score_size_y - newSize;
2770 pos_y += offset_y/2;
2771 score_size_y = newSize;
2775 score_size = eX * mySize_x*(1/4) + eY * mySize_y*(1/3);
2777 float max_fragcount;
2778 max_fragcount = -99;
2779 draw_beginBoldFont();
2781 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2782 if(tm.team == FL_SPECTATOR)
2784 score = tm.(teamscores[ts_primary]);
2785 if(autocvar__hud_configure)
2788 if (score > max_fragcount)
2789 max_fragcount = score;
2791 if (spectatee_status == -1)
2793 score_pos = pos + eX * column * (score_size_x + offset_x) + eY * row * (score_size_y + offset_y);
2794 if (max_fragcount == score)
2795 HUD_Panel_DrawHighlight(score_pos, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2796 drawstring_aspect(score_pos, ftos(score), score_size, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2804 else if(tm.team == myteam) {
2805 if (max_fragcount == score)
2806 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2807 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2809 if (max_fragcount == score)
2810 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);
2811 drawstring_aspect(pos + eX * 0.75 * mySize_x + eY * (1/3) * rows * mySize_y, ftos(score), score_size, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2821 void HUD_RaceTimer (void)
2823 if(!autocvar__hud_configure)
2825 if(!autocvar_hud_panel_racetimer) return;
2826 if(!(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) return;
2827 if(spectatee_status == -1) return;
2830 hud_configure_active_panel = HUD_PANEL_RACETIMER;
2832 HUD_Panel_UpdateCvars(racetimer);
2833 HUD_Panel_ApplyFadeAlpha();
2835 draw_beginBoldFont();
2839 mySize = panel_size;
2841 HUD_Panel_DrawBg(1);
2842 if(panel_bg_padding)
2844 pos += '1 1 0' * panel_bg_padding;
2845 mySize -= '2 2 0' * panel_bg_padding;
2848 // always force 4:1 aspect
2849 vector newSize = '0 0 0';
2850 if(mySize_x/mySize_y > 4)
2852 newSize_x = 4 * mySize_y;
2853 newSize_y = mySize_y;
2855 pos_x = pos_x + (mySize_x - newSize_x) / 2;
2859 newSize_y = 1/4 * mySize_x;
2860 newSize_x = mySize_x;
2862 pos_y = pos_y + (mySize_y - newSize_y) / 2;
2867 string s, forcetime;
2869 if(autocvar__hud_configure)
2872 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);
2873 s = _("^1Intermediate 1 (+15.42)");
2874 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);
2875 s = sprintf(_("^1PENALTY: %.1f (%s)"), 2, "missing a checkpoint");
2876 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);
2878 else if(race_checkpointtime)
2880 a = bound(0, 2 - (time - race_checkpointtime), 1);
2883 if(a > 0) // just hit a checkpoint?
2885 if(race_checkpoint != 254)
2887 if(race_time && race_previousbesttime)
2888 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
2890 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
2892 forcetime = TIME_ENCODED_TOSTRING(race_time);
2897 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
2899 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
2900 if(a > 0) // next one?
2902 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
2907 if(s != "" && a > 0)
2909 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);
2912 if(race_penaltytime)
2914 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
2917 s = sprintf(_("^1PENALTY: %.1f (%s)"), race_penaltytime * 0.1, race_penaltyreason);
2918 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);
2924 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
2925 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);
2930 if(race_laptime && race_checkpoint != 255)
2932 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
2933 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);
2938 if(race_mycheckpointtime)
2940 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
2941 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
2942 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);
2944 if(race_othercheckpointtime && race_othercheckpointenemy != "")
2946 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
2947 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
2948 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);
2951 if(race_penaltytime && !race_penaltyaccumulator)
2953 t = race_penaltytime * 0.1 + race_penaltyeventtime;
2954 a = bound(0, (1 + t - time), 1);
2958 s = sprintf(_("^1PENALTY: %.1f (%s)"), (t - time) * 0.1, race_penaltyreason);
2960 s = sprintf(_("^2PENALTY: %.1f (%s)"), 0, race_penaltyreason);
2961 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);
2971 float vote_yescount;
2974 float vote_highlighted; // currently selected vote
2976 float vote_active; // is there an active vote?
2977 float vote_prev; // previous state of vote_active to check for a change
2979 float vote_change; // "time" when vote_active changed
2981 void HUD_VoteWindow(void)
2983 if(autocvar_cl_allow_uid2name == -1 && (gametype == MAPINFO_TYPE_CTS || gametype == MAPINFO_TYPE_RACE || (serverflags & SERVERFLAG_PLAYERSTATS)))
2986 if (autocvar__hud_configure)
2990 print(_("^1You must answer before entering hud configure mode\n"));
2991 cvar_set("_hud_configure", "0");
2993 if(vote_called_vote)
2994 strunzone(vote_called_vote);
2995 vote_called_vote = strzone(_("^2Name ^7instead of \"^1Anonymous player^7\" in stats"));
2996 uid2name_dialog = 1;
2999 if(!autocvar__hud_configure)
3001 if(!autocvar_hud_panel_vote) return;
3003 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
3004 panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha;
3006 if(panel_bg_alpha_str == "") {
3007 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
3009 panel_bg_alpha = stof(panel_bg_alpha_str);
3013 hud_configure_active_panel = HUD_PANEL_VOTE;
3022 if(vote_active != vote_prev) {
3024 vote_prev = vote_active;
3027 if(vote_active || autocvar__hud_configure)
3028 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3030 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3035 HUD_Panel_UpdateCvars(vote);
3036 HUD_Panel_ApplyFadeAlpha();
3040 panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight;
3041 panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight;
3044 // these must be below above block
3047 mySize = panel_size;
3049 a = vote_alpha * (vote_highlighted ? autocvar_hud_panel_vote_alreadyvoted_alpha : 1);
3050 HUD_Panel_DrawBg(a);
3051 a = panel_fg_alpha * a;
3053 if(panel_bg_padding)
3055 pos += '1 1 0' * panel_bg_padding;
3056 mySize -= '2 2 0' * panel_bg_padding;
3059 // always force 3:1 aspect
3060 vector newSize = '0 0 0';
3061 if(mySize_x/mySize_y > 3)
3063 newSize_x = 3 * mySize_y;
3064 newSize_y = mySize_y;
3066 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3070 newSize_y = 1/3 * mySize_x;
3071 newSize_x = mySize_x;
3073 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3077 s = _("A vote has been called for:");
3079 s = _("Allow servers to store and display your name?");
3080 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3081 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1/8), stringwidth_colors);
3082 if(autocvar__hud_configure)
3083 s = _("^1Configure the HUD");
3084 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
3086 // print the yes/no counts
3087 s = sprintf(_("Yes (%s): %d"), getcommandkey("vyes", "vyes"), vote_yescount);
3088 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);
3089 s = sprintf(_("No (%s): %d"), getcommandkey("vno", "vno"), vote_nocount);
3090 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);
3092 // draw the progress bar backgrounds
3093 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3095 // draw the highlights
3096 if(vote_highlighted == 1) {
3097 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3098 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3100 else if(vote_highlighted == -1) {
3101 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3102 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3105 // draw the progress bars
3106 if(vote_yescount && vote_needed)
3108 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3109 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3112 if(vote_nocount && vote_needed)
3114 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3115 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3118 drawresetcliparea();
3121 // Mod icons panel (#10)
3124 float mod_active; // is there any active mod icon?
3126 // Clan Arena HUD modicons
3127 void HUD_Mod_CA(vector pos, vector mySize)
3129 mod_active = 1; // CA should never hide the mod icons panel
3130 float redalive, bluealive;
3131 redalive = getstati(STAT_REDALIVE);
3132 bluealive = getstati(STAT_BLUEALIVE);
3134 vector redpos, bluepos;
3135 if(mySize_x > mySize_y)
3138 bluepos = pos + eY * 0.5 * mySize_y;
3139 drawpic_aspect_skin(redpos, "player_red.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3140 drawstring_aspect(redpos + eX * 0.5 * mySize_x, ftos(redalive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3141 drawpic_aspect_skin(bluepos, "player_blue.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3142 drawstring_aspect(bluepos + eX * 0.5 * mySize_x, ftos(bluealive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3147 bluepos = pos + eY * 0.5 * mySize_y;
3148 drawpic_aspect_skin(redpos, "player_red.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3149 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);
3150 drawpic_aspect_skin(bluepos, "player_blue.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3151 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);
3155 // CTF HUD modicon section
3156 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3157 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3158 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3160 void HUD_Mod_CTF_Reset(void)
3162 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3165 void HUD_Mod_CTF(vector pos, vector mySize)
3167 vector redflag_pos, blueflag_pos;
3169 float f; // every function should have that
3171 float redflag, blueflag; // current status
3172 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3175 stat_items = getstati(STAT_ITEMS, 0, 24);
3176 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3177 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3179 if(redflag || blueflag)
3184 if(autocvar__hud_configure)
3190 // when status CHANGES, set old status into prevstatus and current status into status
3191 if (redflag != redflag_prevframe)
3193 redflag_statuschange_time = time;
3194 redflag_prevstatus = redflag_prevframe;
3195 redflag_prevframe = redflag;
3198 if (blueflag != blueflag_prevframe)
3200 blueflag_statuschange_time = time;
3201 blueflag_prevstatus = blueflag_prevframe;
3202 blueflag_prevframe = blueflag;
3205 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3206 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3208 float BLINK_FACTOR = 0.15;
3209 float BLINK_BASE = 0.85;
3211 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3213 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3215 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3217 string red_icon, red_icon_prevstatus;
3218 float red_alpha, red_alpha_prevstatus;
3219 red_alpha = red_alpha_prevstatus = 1;
3221 case 1: red_icon = "flag_red_taken"; break;
3222 case 2: red_icon = "flag_red_lost"; break;
3223 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3225 if((stat_items & IT_CTF_SHIELDED) && (myteam == FL_TEAM_2))
3226 red_icon = "flag_red_shielded";
3228 red_icon = string_null;
3231 switch(redflag_prevstatus) {
3232 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3233 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3234 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3237 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3238 else if((stat_items & IT_CTF_SHIELDED) && (myteam == FL_TEAM_2))
3239 red_icon_prevstatus = "flag_red_shielded";
3241 red_icon_prevstatus = string_null;
3245 string blue_icon, blue_icon_prevstatus;
3246 float blue_alpha, blue_alpha_prevstatus;
3247 blue_alpha = blue_alpha_prevstatus = 1;
3249 case 1: blue_icon = "flag_blue_taken"; break;
3250 case 2: blue_icon = "flag_blue_lost"; break;
3251 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3253 if((stat_items & IT_CTF_SHIELDED) && (myteam == FL_TEAM_1))
3254 blue_icon = "flag_blue_shielded";
3256 blue_icon = string_null;
3259 switch(blueflag_prevstatus) {
3260 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3261 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3262 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3265 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3266 else if((stat_items & IT_CTF_SHIELDED) && (myteam == FL_TEAM_1))
3267 blue_icon_prevstatus = "flag_blue_shielded";
3269 blue_icon_prevstatus = string_null;
3273 if(mySize_x > mySize_y) {
3274 if (myteam == FL_TEAM_1) { // always draw own flag on left
3276 blueflag_pos = pos + eX * 0.5 * mySize_x;
3279 redflag_pos = pos + eX * 0.5 * mySize_x;
3281 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3283 if (myteam == FL_TEAM_1) { // always draw own flag on left
3285 blueflag_pos = pos + eY * 0.5 * mySize_y;
3288 redflag_pos = pos + eY * 0.5 * mySize_y;
3290 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3293 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3294 if(red_icon_prevstatus && f < 1)
3295 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3297 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3299 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3300 if(blue_icon_prevstatus && f < 1)
3301 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3303 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3306 // Keyhunt HUD modicon section
3307 float kh_runheretime;
3309 void HUD_Mod_KH_Reset(void)
3314 void HUD_Mod_KH(vector pos, vector mySize)
3316 mod_active = 1; // keyhunt should never hide the mod icons panel
3320 vector p = '0 0 0', pa, kh_size = '0 0 0', kh_asize = '0 0 0';
3322 kh_keys = getstati(STAT_KH_KEYS);
3325 if(mySize_x > mySize_y)
3327 p_y = pos_y + 0.25 * mySize_y;
3328 pa = p - eY * 0.25 * mySize_y;
3330 kh_size_x = mySize_x * 0.25;
3331 kh_size_y = 0.75 * mySize_y;
3332 kh_asize_x = mySize_x * 0.25;
3333 kh_asize_y = mySize_y * 0.25;
3337 p_y = pos_y + 0.125 * mySize_y;
3338 pa = p - eY * 0.125 * mySize_y;
3340 kh_size_x = mySize_x * 0.5;
3341 kh_size_y = 0.375 * mySize_y;
3342 kh_asize_x = mySize_x * 0.5;
3343 kh_asize_y = mySize_y * 0.125;
3350 for(i = 0; i < 4; ++i)
3352 key = floor(kh_keys / pow(32, i)) & 31;
3354 if(keyteam == 30 && keycount <= 4)
3356 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3360 // this yields 8 exactly if "RUN HERE" shows
3365 kh_runheretime = time;
3366 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3371 for(i = 0; i < 4; ++i)
3373 key = floor(kh_keys / pow(32, i)) & 31;
3386 default: // owned or dropped
3391 a = a * panel_fg_alpha;
3392 aa = aa * panel_fg_alpha;
3398 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% theAlpha key
3401 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% theAlpha key
3404 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% theAlpha key
3407 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% theAlpha key
3412 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3415 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% theAlpha key
3418 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% theAlpha key
3421 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% theAlpha key
3424 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% theAlpha key
3428 if(mySize_x > mySize_y)
3430 p_x += 0.25 * mySize_x;
3431 pa_x += 0.25 * mySize_x;
3437 p_y = pos_y + 0.625 * mySize_y;
3438 pa_y = pos_y + 0.5 * mySize_y;
3444 p_x += 0.5 * mySize_x;
3445 pa_x += 0.5 * mySize_x;
3451 // Keepaway HUD mod icon
3452 float kaball_prevstatus; // last remembered status
3453 float kaball_statuschange_time; // time when the status changed
3455 // we don't need to reset for keepaway since it immediately
3456 // autocorrects prevstatus as to if the player has the ball or not
3458 void HUD_Mod_Keepaway(vector pos, vector mySize)
3460 mod_active = 1; // keepaway should always show the mod HUD
3462 float BLINK_FACTOR = 0.15;
3463 float BLINK_BASE = 0.85;
3464 float BLINK_FREQ = 5;
3465 float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
3467 float stat_items = getstati(STAT_ITEMS, 0, 24);
3468 float kaball = (stat_items/IT_KEY1) & 1;
3470 if(kaball != kaball_prevstatus)
3472 kaball_statuschange_time = time;
3473 kaball_prevstatus = kaball;
3476 vector kaball_pos, kaball_size;
3478 if(mySize_x > mySize_y) {
3479 kaball_pos = pos + eX * 0.25 * mySize_x;
3480 kaball_size = eX * 0.5 * mySize_x + eY * mySize_y;
3482 kaball_pos = pos + eY * 0.25 * mySize_y;
3483 kaball_size = eY * 0.5 * mySize_y + eX * mySize_x;
3486 float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
3487 float f = bound(0, kaball_statuschange_elapsedtime*2, 1);
3489 if(kaball_prevstatus && f < 1)
3490 drawpic_aspect_skin_expanding(kaball_pos, "keepawayball_carrying", kaball_size, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f);
3493 drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
3497 // Nexball HUD mod icon
3498 void HUD_Mod_NexBall(vector pos, vector mySize)
3500 float stat_items, nb_pb_starttime, dt, p;
3502 stat_items = getstati(STAT_ITEMS, 0, 24);
3503 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3505 if (stat_items & IT_KEY1)
3510 //Manage the progress bar if any
3511 if (nb_pb_starttime > 0)
3513 dt = mod(time - nb_pb_starttime, nb_pb_period);
3514 // one period of positive triangle
3515 p = 2 * dt / nb_pb_period;
3520 HUD_Panel_GetProgressBarColor(nexball);
3521 if(mySize_x > mySize_y)
3522 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, 0, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3524 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, 1, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3527 if (stat_items & IT_KEY1)
3528 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3531 // Race/CTS HUD mod icons
3532 float crecordtime_prev; // last remembered crecordtime
3533 float crecordtime_change_time; // time when crecordtime last changed
3534 float srecordtime_prev; // last remembered srecordtime
3535 float srecordtime_change_time; // time when srecordtime last changed
3537 float race_status_time;
3538 float race_status_prev;
3539 string race_status_name_prev;
3540 void HUD_Mod_Race(vector pos, vector mySize)
3542 mod_active = 1; // race should never hide the mod icons panel
3544 me = playerslots[player_localnum];
3546 float f; // yet another function has this
3547 score = me.(scores[ps_primary]);
3549 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3550 return; // no records in the actual race
3552 // clientside personal record
3554 if(gametype == MAPINFO_TYPE_CTS)
3558 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3560 if(score && (score < t || !t)) {
3561 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3562 if(autocvar_cl_autodemo_delete_keeprecords)
3564 f = autocvar_cl_autodemo_delete;
3566 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3570 if(t != crecordtime_prev) {
3571 crecordtime_prev = t;
3572 crecordtime_change_time = time;
3575 vector textPos, medalPos;
3577 if(mySize_x > mySize_y) {
3578 // text on left side
3579 squareSize = min(mySize_y, mySize_x/2);
3580 textPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eY * 0.5 * (mySize_y - squareSize);
3581 medalPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eX * 0.5 * mySize_x + eY * 0.5 * (mySize_y - squareSize);
3584 squareSize = min(mySize_x, mySize_y/2);
3585 textPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eX * 0.5 * (mySize_x - squareSize);
3586 medalPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eY * 0.5 * mySize_y + eX * 0.5 * (mySize_x - squareSize);
3589 f = time - crecordtime_change_time;
3592 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3593 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);
3595 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3596 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);
3597 drawstring_aspect_expanding(pos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
3598 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);
3602 t = race_server_record;
3603 if(t != srecordtime_prev) {
3604 srecordtime_prev = t;
3605 srecordtime_change_time = time;
3607 f = time - srecordtime_change_time;
3610 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3611 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);
3613 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3614 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);
3615 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);
3616 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);
3619 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
3620 race_status_time = time + 5;
3621 race_status_prev = race_status;
3622 if (race_status_name_prev)
3623 strunzone(race_status_name_prev);
3624 race_status_name_prev = strzone(race_status_name);
3629 a = bound(0, race_status_time - time, 1);
3632 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
3636 rank = race_CheckName(race_status_name);
3640 rankname = race_PlaceName(rank);
3643 namepos = medalPos + '0 0.8 0' * squareSize;
3645 rankpos = medalPos + '0 0.15 0' * squareSize;
3647 if(race_status == 0)
3648 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3649 else if(race_status == 1) {
3650 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);
3651 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3652 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3653 } else if(race_status == 2) {
3654 if(race_status_name == GetPlayerName(player_localnum) || !race_myrank || race_myrank < rank)
3655 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);
3657 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);
3658 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3659 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3660 } else if(race_status == 3) {
3661 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);
3662 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3663 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3666 if (race_status_time - time <= 0) {
3667 race_status_prev = -1;
3669 if(race_status_name)
3670 strunzone(race_status_name);
3671 race_status_name = string_null;
3672 if(race_status_name_prev)
3673 strunzone(race_status_name_prev);
3674 race_status_name_prev = string_null;
3678 void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, float layout, float i)
3680 float stat, pps_ratio;
3691 stat = getstatf(STAT_DOM_PPS_RED);
3692 pic = "dom_icon_red";
3696 stat = getstatf(STAT_DOM_PPS_BLUE);
3697 pic = "dom_icon_blue";
3701 stat = getstatf(STAT_DOM_PPS_YELLOW);
3702 pic = "dom_icon_yellow";
3707 stat = getstatf(STAT_DOM_PPS_PINK);
3708 pic = "dom_icon_pink";
3712 pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS);
3714 if(mySize_x/mySize_y > aspect_ratio)
3716 i = aspect_ratio * mySize_y;
3717 myPos_x = myPos_x + (mySize_x - i) / 2;
3722 i = 1/aspect_ratio * mySize_x;
3723 myPos_y = myPos_y + (mySize_y - i) / 2;
3727 if (layout) // show text too
3730 color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
3731 if (layout == 2) // average pps
3732 drawstring_aspect(myPos + eX * mySize_y, ftos_decimals(stat, 2), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
3733 else // percentage of average pps
3734 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);
3738 drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3741 drawsetcliparea(myPos_x, myPos_y + mySize_y * (1 - pps_ratio), mySize_y, mySize_y * pps_ratio);
3742 drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3743 drawresetcliparea();
3747 void HUD_Mod_Dom(vector myPos, vector mySize)
3749 mod_active = 1; // required in each mod function that always shows something
3751 float teams_count = 0;
3752 for(tm = teams.sort_next; tm; tm = tm.sort_next)
3753 if(tm.team != FL_SPECTATOR)
3756 float layout = autocvar_hud_panel_modicons_dom_layout;
3757 float rows, columns, aspect_ratio;
3758 rows = mySize_y/mySize_x;
3759 aspect_ratio = (layout) ? 3 : 1;
3760 rows = bound(1, floor((sqrt((4 * aspect_ratio * teams_count + rows) * rows) + rows + 0.5) / 2), teams_count);
3761 columns = ceil(teams_count/rows);
3764 float row = 0, column = 0;
3765 for(i=0; i<teams_count; ++i)
3767 vector pos, itemSize;
3768 pos = myPos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows);
3769 itemSize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
3771 DrawDomItem(pos, itemSize, aspect_ratio, layout, i);
3782 float mod_prev; // previous state of mod_active to check for a change
3784 float mod_change; // "time" when mod_active changed
3786 void HUD_ModIcons(void)
3788 if(!autocvar__hud_configure)
3790 if(!autocvar_hud_panel_modicons) return;
3791 if (gametype != MAPINFO_TYPE_CTF && gametype != MAPINFO_TYPE_KEYHUNT && gametype != MAPINFO_TYPE_NEXBALL && gametype != MAPINFO_TYPE_CTS && gametype != MAPINFO_TYPE_RACE && gametype != MAPINFO_TYPE_CA && gametype != MAPINFO_TYPE_FREEZETAG && gametype != MAPINFO_TYPE_KEEPAWAY && gametype != MAPINFO_TYPE_DOMINATION) return;
3794 hud_configure_active_panel = HUD_PANEL_MODICONS;
3796 HUD_Panel_UpdateCvars(modicons);
3797 HUD_Panel_ApplyFadeAlpha();
3799 draw_beginBoldFont();
3803 mySize = panel_size;
3805 if(mod_active != mod_prev) {
3807 mod_prev = mod_active;
3810 if(mod_active || autocvar__hud_configure)
3811 mod_alpha = bound(0, (time - mod_change) * 2, 1);
3813 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
3816 HUD_Panel_DrawBg(mod_alpha);
3818 if(panel_bg_padding)
3820 pos += '1 1 0' * panel_bg_padding;
3821 mySize -= '2 2 0' * panel_bg_padding;
3824 // these MUST be ran in order to update mod_active
3825 if(gametype == MAPINFO_TYPE_KEYHUNT)
3826 HUD_Mod_KH(pos, mySize);
3827 else if(gametype == MAPINFO_TYPE_CTF || autocvar__hud_configure)
3828 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
3829 else if(gametype == MAPINFO_TYPE_NEXBALL)
3830 HUD_Mod_NexBall(pos, mySize);
3831 else if(gametype == MAPINFO_TYPE_CTS || gametype == MAPINFO_TYPE_RACE)
3832 HUD_Mod_Race(pos, mySize);
3833 else if(gametype == MAPINFO_TYPE_CA || gametype == MAPINFO_TYPE_FREEZETAG)
3834 HUD_Mod_CA(pos, mySize);
3835 else if(gametype == MAPINFO_TYPE_DOMINATION)
3836 HUD_Mod_Dom(pos, mySize);
3837 else if(gametype == MAPINFO_TYPE_KEEPAWAY)
3838 HUD_Mod_Keepaway(pos, mySize);
3843 // Draw pressed keys (#11)
3845 void HUD_DrawPressedKeys(void)
3847 if(!autocvar__hud_configure)
3849 if(!autocvar_hud_panel_pressedkeys) return;
3850 if(spectatee_status <= 0 && autocvar_hud_panel_pressedkeys < 2) return;
3853 hud_configure_active_panel = HUD_PANEL_PRESSEDKEYS;
3856 HUD_Panel_UpdateCvars(pressedkeys);
3857 HUD_Panel_ApplyFadeAlpha();
3860 mySize = panel_size;
3862 HUD_Panel_DrawBg(1);
3863 if(panel_bg_padding)
3865 pos += '1 1 0' * panel_bg_padding;
3866 mySize -= '2 2 0' * panel_bg_padding;
3869 // force custom aspect
3870 float aspect = autocvar_hud_panel_pressedkeys_aspect;
3873 vector newSize = '0 0 0';
3874 if(mySize_x/mySize_y > aspect)
3876 newSize_x = aspect * mySize_y;
3877 newSize_y = mySize_y;
3879 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3883 newSize_y = 1/aspect * mySize_x;
3884 newSize_x = mySize_x;
3886 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3892 keysize = eX * mySize_x * (1/3.0) + eY * mySize_y * (1/(3.0 - !autocvar_hud_panel_pressedkeys_attack));
3894 pressedkeys = getstatf(STAT_PRESSED_KEYS);
3896 if(autocvar_hud_panel_pressedkeys_attack)
3898 drawpic_aspect_skin(pos + eX * keysize_x * 0.5, ((pressedkeys & KEY_ATCK) ? "key_atck_inv.tga" : "key_atck.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3899 drawpic_aspect_skin(pos + eX * keysize_x * 1.5, ((pressedkeys & KEY_ATCK2) ? "key_atck_inv.tga" : "key_atck.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3903 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3904 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);
3905 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);
3907 drawpic_aspect_skin(pos, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3908 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);
3909 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);
3912 // Handle chat as a panel (#12)
3916 if(!autocvar__hud_configure)
3918 if (!autocvar_hud_panel_chat)
3920 if (!autocvar_con_chatrect)
3921 cvar_set("con_chatrect", "0");
3924 if(autocvar__con_chat_maximized)
3925 if(!hud_draw_maximized) return;
3928 hud_configure_active_panel = HUD_PANEL_CHAT;
3930 HUD_Panel_UpdateCvars(chat);
3931 HUD_Panel_ApplyFadeAlpha();
3933 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
3935 panel_pos_y = panel_bg_border;
3936 panel_size_y = vid_conheight - panel_bg_border * 2;
3937 if(panel_bg == "0") // force a border when maximized
3939 if(precache_pic(panel_bg) == "") {
3940 panel_bg = strcat(hud_skin_path, "/border_default");
3941 if(precache_pic(panel_bg) == "") {
3942 panel_bg = "gfx/hud/default/border_default";
3946 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an theAlpha of at least 0.75
3951 mySize = panel_size;
3953 HUD_Panel_DrawBg(1);
3955 if(panel_bg_padding)
3957 pos += '1 1 0' * panel_bg_padding;
3958 mySize -= '2 2 0' * panel_bg_padding;
3961 if (!autocvar_con_chatrect)
3962 cvar_set("con_chatrect", "1");
3964 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
3965 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
3967 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
3968 cvar_set("con_chat", ftos(floor(mySize_y/autocvar_con_chatsize - 0.5)));
3970 if(autocvar__hud_configure)
3973 chatsize = '1 1 0' * autocvar_con_chatsize;
3974 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over theAlpha and such
3976 for(i = 0; i < autocvar_con_chat; ++i)
3978 if(i == autocvar_con_chat - 1)
3981 a = panel_fg_alpha * floor(((i + 1) * 7 + autocvar_con_chattime)/45);
3982 drawcolorcodedstring(pos, textShortenToWidth(_("^3Player^7: This is the chat area."), mySize_x, chatsize, stringwidth_colors), chatsize, a, DRAWFLAG_NORMAL);
3983 pos_y += chatsize_y;
3988 // Engine info panel (#13)
3995 float frametimeavg1; // 1 frame ago
3996 float frametimeavg2; // 2 frames ago
3997 void HUD_EngineInfo(void)
3999 if(!autocvar__hud_configure)
4001 if(!autocvar_hud_panel_engineinfo) return;
4004 hud_configure_active_panel = HUD_PANEL_ENGINEINFO;
4006 HUD_Panel_UpdateCvars(engineinfo);
4007 HUD_Panel_ApplyFadeAlpha();
4010 mySize = panel_size;
4012 HUD_Panel_DrawBg(1);
4013 if(panel_bg_padding)
4015 pos += '1 1 0' * panel_bg_padding;
4016 mySize -= '2 2 0' * panel_bg_padding;
4019 float currentTime = gettime(GETTIME_REALTIME);
4020 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
4022 float currentframetime = currentTime - prevfps_time;
4023 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4024 frametimeavg2 = frametimeavg1;
4025 frametimeavg1 = frametimeavg;
4028 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4029 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.
4031 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
4032 prevfps = (1/currentframetime);
4033 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"
4035 prevfps_time = currentTime;
4040 if(currentTime - prevfps_time > autocvar_hud_panel_engineinfo_framecounter_time)
4042 prevfps = framecounter/(currentTime - prevfps_time);
4044 prevfps_time = currentTime;
4049 color = HUD_Get_Num_Color (prevfps, 100);
4050 drawstring_aspect(pos, sprintf(_("FPS: %.*f"), autocvar_hud_panel_engineinfo_framecounter_decimals, prevfps), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4053 // Info messages panel (#14)
4055 #define drawInfoMessage(s)\
4056 if(autocvar_hud_panel_infomessages_flip)\
4057 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);\
4058 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
4060 void HUD_InfoMessages(void)
4062 if(!autocvar__hud_configure)
4064 if(!autocvar_hud_panel_infomessages) return;
4067 hud_configure_active_panel = HUD_PANEL_INFOMESSAGES;
4069 HUD_Panel_UpdateCvars(infomessages);
4070 HUD_Panel_ApplyFadeAlpha();
4073 mySize = panel_size;
4075 HUD_Panel_DrawBg(1);
4076 if(panel_bg_padding)
4078 pos += '1 1 0' * panel_bg_padding;
4079 mySize -= '2 2 0' * panel_bg_padding;
4082 // always force 5:1 aspect
4083 vector newSize = '0 0 0';
4084 if(mySize_x/mySize_y > 5)
4086 newSize_x = 5 * mySize_y;
4087 newSize_y = mySize_y;
4089 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4093 newSize_y = 1/5 * mySize_x;
4094 newSize_x = mySize_x;
4096 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4105 fontsize = '0.20 0.20 0' * mySize_y;
4111 if(!autocvar__hud_configure)
4113 if(spectatee_status && !intermission)
4116 if(spectatee_status == -1)
4117 s = _("^1Observing");
4119 #ifdef COMPAT_XON050_ENGINE
4120 s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(spectatee_status - 1));
4122 s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(player_localentnum - 1));
4126 if(spectatee_status == -1)
4127 s = sprintf(_("^1Press ^3%s^1 to spectate"), getcommandkey("primary fire", "+fire"));
4129 s = sprintf(_("^1Press ^3%s^1 for another player"), getcommandkey("primary fire", "+fire"));
4132 if(spectatee_status == -1)
4133 s = sprintf(_("^1Use ^3%s^1 or ^3%s^1 to change the speed"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
4135 s = sprintf(_("^1Press ^3%s^1 to observe"), getcommandkey("secondary fire", "+fire2"));
4138 s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey("server info", "+show_info"));
4141 if(gametype == MAPINFO_TYPE_ARENA)
4142 s = _("^1Wait for your turn to join");
4143 else if(gametype == MAPINFO_TYPE_LMS)
4146 sk = playerslots[player_localnum];
4147 if(sk.(scores[ps_primary]) >= 666)
4148 s = _("^1Match has already begun");
4149 else if(sk.(scores[ps_primary]) > 0)
4150 s = _("^1You have no more lives left");
4152 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
4155 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
4158 //show restart countdown:
4159 if (time < getstatf(STAT_GAMESTARTTIME)) {
4161 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4162 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4163 s = sprintf(_("^1Game starts in ^3%d^1 seconds"), countdown);
4164 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4168 if(warmup_stage && !intermission)
4170 s = _("^2Currently in ^1warmup^2 stage!");
4175 if(mod(time, 1) >= 0.5)
4180 if(ready_waiting && !intermission && !spectatee_status)
4182 if(ready_waiting_for_me)
4185 s = sprintf(_("%sPress ^3%s%s to end warmup"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
4187 s = sprintf(_("%sPress ^3%s%s once you are ready"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
4192 s = _("^2Waiting for others to ready up to end warmup...");
4194 s = _("^2Waiting for others to ready up...");
4198 else if(warmup_stage && !intermission && !spectatee_status)
4200 s = sprintf(_("^2Press ^3%s^2 to end warmup"), getcommandkey("ready", "ready"));
4204 if(teamplay && !intermission && !spectatee_status && gametype != MAPINFO_TYPE_CA && teamnagger)
4206 float ts_min = 0, ts_max = 0;
4207 tm = teams.sort_next;
4210 for(; tm.sort_next; tm = tm.sort_next)
4212 if(!tm.team_size || tm.team == FL_SPECTATOR)
4214 if(!ts_min) ts_min = tm.team_size;
4215 else ts_min = min(ts_min, tm.team_size);
4216 if(!ts_max) ts_max = tm.team_size;
4217 else ts_max = max(ts_max, tm.team_size);
4219 if ((ts_max - ts_min) > 1)
4221 s = strcat(blinkcolor, _("Teamnumbers are unbalanced!"));
4222 tm = GetTeam(myteam, false);
4224 if (tm.team != FL_SPECTATOR)
4225 if (tm.team_size == ts_max)
4226 s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey("team menu", "menu_showteamselect"), blinkcolor));
4234 s = _("^7Press ^3ESC ^7to show HUD options.");
4236 s = _("^3Doubleclick ^7a panel for panel-specific options.");
4238 s = _("^3CTRL ^7to disable collision testing, ^3SHIFT ^7and");
4240 s = _("^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.");
4245 // Physics panel (#15)
4247 vector acc_prevspeed;
4248 float acc_prevtime, acc_avg, top_speed, top_speed_time;
4249 void HUD_Physics(void)
4251 if(!autocvar__hud_configure)
4253 if(!autocvar_hud_panel_physics) return;
4254 if(spectatee_status == -1 && (autocvar_hud_panel_physics == 1 || autocvar_hud_panel_physics == 3)) return;
4255 if(autocvar_hud_panel_physics == 3 && !(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) return;
4258 hud_configure_active_panel = HUD_PANEL_PHYSICS;
4260 HUD_Panel_UpdateCvars(physics);
4261 HUD_Panel_ApplyFadeAlpha();
4263 draw_beginBoldFont();
4265 HUD_Panel_DrawBg(1);
4266 if(panel_bg_padding)
4268 panel_pos += '1 1 0' * panel_bg_padding;
4269 panel_size -= '2 2 0' * panel_bg_padding;
4272 float acceleration_progressbar_scale = 0;
4273 if(autocvar_hud_panel_physics_progressbar && autocvar_hud_panel_physics_acceleration_progressbar_scale > 1)
4274 acceleration_progressbar_scale = autocvar_hud_panel_physics_acceleration_progressbar_scale;
4277 if (autocvar_hud_panel_physics_text_scale <= 0)
4280 text_scale = min(autocvar_hud_panel_physics_text_scale, 1);
4283 float speed, conversion_factor;
4286 switch(autocvar_hud_panel_physics_speed_unit)
4291 conversion_factor = 1.0;
4295 conversion_factor = 0.0254;
4299 conversion_factor = 0.0254 * 3.6;
4303 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4307 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4311 vector vel = (csqcplayer ? csqcplayer.velocity : pmove_vel);
4313 float max_speed = floor( autocvar_hud_panel_physics_speed_max * conversion_factor + 0.5 );
4314 if (autocvar__hud_configure)
4315 speed = floor( max_speed * 0.65 + 0.5 );
4316 else if(autocvar_hud_panel_physics_speed_vertical)
4317 speed = floor( vlen(vel) * conversion_factor + 0.5 );
4319 speed = floor( vlen(vel - vel_z * '0 0 1') * conversion_factor + 0.5 );
4321 //compute acceleration
4322 float acceleration, f;
4323 if (autocvar__hud_configure)
4324 acceleration = autocvar_hud_panel_physics_acceleration_max * 0.3;
4327 // 1 m/s = 0.0254 qu/s; 1 g = 9.80665 m/s^2
4328 f = time - acc_prevtime;
4329 if(autocvar_hud_panel_physics_acceleration_vertical)
4330 acceleration = (vlen(vel) - vlen(acc_prevspeed));
4332 acceleration = (vlen(vel - '0 0 1' * vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z));
4334 acceleration = acceleration * (1 / max(0.0001, f)) * (0.0254 / 9.80665);
4336 acc_prevspeed = vel;
4337 acc_prevtime = time;
4339 f = bound(0, f * 10, 1);
4340 acc_avg = acc_avg * (1 - f) + acceleration * f;
4344 float panel_ar = panel_size_x/panel_size_y;
4345 vector speed_offset = '0 0 0', acceleration_offset = '0 0 0';
4346 if (panel_ar >= 5 && !acceleration_progressbar_scale)
4348 panel_size_x *= 0.5;
4349 if (autocvar_hud_panel_physics_flip)
4350 speed_offset_x = panel_size_x;
4352 acceleration_offset_x = panel_size_x;
4356 panel_size_y *= 0.5;
4357 if (autocvar_hud_panel_physics_flip)
4358 speed_offset_y = panel_size_y;
4360 acceleration_offset_y = panel_size_y;
4362 float speed_baralign, acceleration_baralign;
4363 if (autocvar_hud_panel_physics_baralign == 1)
4364 acceleration_baralign = speed_baralign = 1;
4365 else if(autocvar_hud_panel_physics_baralign == 4)
4366 acceleration_baralign = speed_baralign = 2;
4367 else if (autocvar_hud_panel_physics_flip)
4369 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 2);
4370 speed_baralign = (autocvar_hud_panel_physics_baralign == 3);
4374 speed_baralign = (autocvar_hud_panel_physics_baralign == 2);
4375 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 3);
4377 if (autocvar_hud_panel_physics_acceleration_progressbar_mode == 0)
4378 acceleration_baralign = 3; //override hud_panel_physics_baralign value for acceleration
4382 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
4384 HUD_Panel_GetProgressBarColor(speed);
4385 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);
4387 vector tmp_offset = '0 0 0', tmp_size = '0 0 0';
4388 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
4390 tmp_size_x = panel_size_x * 0.75;
4391 tmp_size_y = panel_size_y * text_scale;
4393 tmp_offset_x = panel_size_x - tmp_size_x;
4396 tmp_offset_y = (panel_size_y - tmp_size_y) / 2;
4397 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4403 tmp_offset_x = tmp_size_x;
4404 if (autocvar_hud_panel_physics_speed_unit_show)
4407 tmp_size_x = panel_size_x * (1 - 0.75);
4408 tmp_size_y = panel_size_y * 0.4 * text_scale;
4409 tmp_offset_y = (panel_size_y * 0.4 - tmp_size_y) / 2;
4410 drawstring_aspect(panel_pos + speed_offset + tmp_offset, unit, tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4414 //compute and draw top speed
4415 if (autocvar_hud_panel_physics_topspeed)
4416 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
4418 if (autocvar__hud_configure)
4420 top_speed = floor( max_speed * 0.75 + 0.5 );
4425 if (speed >= top_speed)
4428 top_speed_time = time;
4432 f = max(1, autocvar_hud_panel_physics_topspeed_time);
4433 // divide by f to make it start from 1
4434 f = cos( ((time - top_speed_time) / f) * PI/2 );
4436 else //hide top speed 0, it would be stupid
4441 //top speed progressbar peak
4442 if(speed < top_speed)
4443 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
4445 float peak_offset_x;
4446 vector peak_size = '0 0 0';
4447 if (speed_baralign == 0)
4448 peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x;
4449 else if (speed_baralign == 1)
4450 peak_offset_x = (1 - min(top_speed, max_speed)/max_speed) * panel_size_x;
4451 else // if (speed_baralign == 2)
4452 peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x * 0.5;
4453 //if speed is not 0 the speed progressbar already fetched the color
4455 HUD_Panel_GetProgressBarColor(speed);
4456 peak_size_x = floor(panel_size_x * 0.01 + 1.5);
4457 peak_size_y = panel_size_y;
4458 if (speed_baralign == 2) // draw two peaks, on both sides
4460 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);
4461 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);
4464 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);
4468 tmp_offset_y = panel_size_y * 0.4;
4469 tmp_size_x = panel_size_x * (1 - 0.75);
4470 tmp_size_y = (panel_size_y - tmp_offset_y) * text_scale;
4471 tmp_offset_y += (panel_size_y - tmp_offset_y - tmp_size_y) / 2;
4472 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(top_speed), tmp_size, '1 0 0', f * panel_fg_alpha, DRAWFLAG_NORMAL);
4480 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 3)
4482 if (acceleration < 0)
4483 HUD_Panel_GetProgressBarColor(acceleration_neg);
4485 HUD_Panel_GetProgressBarColor(acceleration);
4487 f = acceleration/autocvar_hud_panel_physics_acceleration_max;
4488 if (autocvar_hud_panel_physics_acceleration_progressbar_nonlinear)
4491 if (acceleration_progressbar_scale) // allow progressbar to go out of panel bounds
4493 tmp_size = acceleration_progressbar_scale * panel_size_x * eX + panel_size_y * eY;
4495 if (acceleration_baralign == 1)
4496 tmp_offset_x = panel_size_x - tmp_size_x;
4497 else if (acceleration_baralign == 2 || acceleration_baralign == 3)
4498 tmp_offset_x = (panel_size_x - tmp_size_x) / 2;
4505 tmp_size = panel_size;
4506 tmp_offset = '0 0 0';
4509 HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset + tmp_offset, tmp_size, "accelbar", f, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4511 tmp_size_x = panel_size_x;
4512 tmp_size_y = panel_size_y * text_scale;
4514 tmp_offset_y = (panel_size_y - tmp_size_y) / 2;
4515 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3)
4516 drawstring_aspect(panel_pos + acceleration_offset + tmp_offset, strcat(ftos_decimals(acceleration, 2), "g"), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4521 // CenterPrint (#16)
4523 #define CENTERPRINT_MAX_MSGS 10
4524 #define CENTERPRINT_MAX_ENTRIES 50
4525 #define CENTERPRINT_SPACING 0.7
4527 string centerprint_messages[CENTERPRINT_MAX_MSGS];
4528 float centerprint_msgID[CENTERPRINT_MAX_MSGS];
4529 float centerprint_time[CENTERPRINT_MAX_MSGS];
4530 float centerprint_expire_time[CENTERPRINT_MAX_MSGS];
4531 float centerprint_countdown_num[CENTERPRINT_MAX_MSGS];
4532 float centerprint_showing;
4534 void centerprint_generic(float new_id, string strMessage, float duration, float countdown_num)
4538 if(strMessage == "" && new_id == 0)
4541 // strip trailing newlines
4542 j = strlen(strMessage) - 1;
4543 while(substring(strMessage, j, 1) == "\n" && j >= 0)
4545 if (j < strlen(strMessage) - 1)
4546 strMessage = substring(strMessage, 0, j + 1);
4548 if(strMessage == "" && new_id == 0)
4551 // strip leading newlines
4553 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
4556 strMessage = substring(strMessage, j, strlen(strMessage) - j);
4558 if(strMessage == "" && new_id == 0)
4561 if (!centerprint_showing)
4562 centerprint_showing = TRUE;
4564 for (i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
4566 if (j == CENTERPRINT_MAX_MSGS)
4568 if (new_id && new_id == centerprint_msgID[j])
4570 if (strMessage == "" && centerprint_messages[j] != "" && centerprint_countdown_num[j] == 0)
4572 // fade out the current msg (duration and countdown_num are ignored)
4573 centerprint_time[j] = min(5, autocvar_hud_panel_centerprint_fade_out);
4574 if (centerprint_expire_time[j] > time + min(5, autocvar_hud_panel_centerprint_fade_out) || centerprint_expire_time[j] < time)
4575 centerprint_expire_time[j] = time + min(5, autocvar_hud_panel_centerprint_fade_out);
4578 break; // found a msg with the same id, at position j
4582 if (i == CENTERPRINT_MAX_MSGS)
4584 // a msg with the same id was not found, add the msg at the next position
4586 if (cpm_index == -1)
4587 cpm_index = CENTERPRINT_MAX_MSGS - 1;
4590 if(centerprint_messages[j])
4591 strunzone(centerprint_messages[j]);
4592 centerprint_messages[j] = strzone(strMessage);
4593 centerprint_msgID[j] = new_id;
4595 centerprint_time[j] = -1;
4599 duration = max(1, autocvar_hud_panel_centerprint_time);
4600 centerprint_time[j] = duration;
4601 centerprint_expire_time[j] = time + duration;
4603 centerprint_countdown_num[j] = countdown_num;
4606 void centerprint_hud(string strMessage)
4608 centerprint_generic(0, strMessage, autocvar_hud_panel_centerprint_time, 0);
4611 void reset_centerprint_messages(void)
4614 for (i=0; i<CENTERPRINT_MAX_MSGS; ++i)
4616 centerprint_expire_time[i] = 0;
4617 centerprint_time[i] = 1;
4618 centerprint_msgID[i] = 0;
4619 if(centerprint_messages[i])
4620 strunzone(centerprint_messages[i]);
4621 centerprint_messages[i] = string_null;
4624 float hud_configure_cp_generation_time;
4625 void HUD_CenterPrint (void)
4627 if(!autocvar__hud_configure)
4629 if(!autocvar_hud_panel_centerprint) return;
4631 if (hud_configure_prev && hud_configure_prev != -1)
4632 reset_centerprint_messages();
4636 hud_configure_active_panel = HUD_PANEL_CENTERPRINT;
4638 if (!hud_configure_prev)
4639 reset_centerprint_messages();
4640 if (time > hud_configure_cp_generation_time)
4645 centerprint_generic(floor(r*1000), strcat(sprintf("^3Countdown message at time %s", seconds_tostring(time)), ", seconds left: %d"), 1, 10);
4647 centerprint_generic(0, sprintf("^1Multiline message at time %s that\n^1lasts longer than normal", seconds_tostring(time)), 20, 0);
4649 centerprint_hud(sprintf("Message at time %s", seconds_tostring(time)));
4650 hud_configure_cp_generation_time = time + 1 + random()*4;
4654 HUD_Panel_UpdateCvars(centerprint);
4656 // this panel doesn't fade when showing the scoreboard
4657 if(autocvar__menu_alpha)
4658 HUD_Panel_ApplyFadeAlpha();
4660 if(scoreboard_fade_alpha)
4662 // move the panel below the scoreboard
4663 if (scoreboard_bottom >= 0.96 * vid_conheight)
4667 target_pos = eY * scoreboard_bottom + eX * 0.5 * (vid_conwidth - panel_size_x);
4669 if(target_pos_y > panel_pos_y)
4671 panel_pos = panel_pos + (target_pos - panel_pos) * sqrt(scoreboard_fade_alpha);
4672 panel_size_y = min(panel_size_y, vid_conheight - scoreboard_bottom);
4676 HUD_Panel_DrawBg(1);
4678 if (!centerprint_showing)
4681 if(panel_bg_padding)
4683 panel_pos += '1 1 0' * panel_bg_padding;
4684 panel_size -= '2 2 0' * panel_bg_padding;
4687 float entries, height;
4689 // entries = bound(1, floor(CENTERPRINT_MAX_ENTRIES * 4 * panel_size_y/panel_size_x), CENTERPRINT_MAX_ENTRIES);
4690 // height = panel_size_y/entries;
4691 // fontsize = '1 1 0' * height;
4692 height = vid_conheight/50 * autocvar_hud_panel_centerprint_fontscale;
4693 fontsize = '1 1 0' * height;
4694 entries = bound(1, floor(panel_size_y/height), CENTERPRINT_MAX_ENTRIES);
4697 float a, sz, align, current_msg_pos_y = 0, msg_size;
4701 n = -1; // if no msg will be displayed, n stays -1
4704 if (autocvar_hud_panel_centerprint_flip)
4705 pos_y += panel_size_y;
4706 align = bound(0, autocvar_hud_panel_centerprint_align, 1);
4707 for (i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
4709 if (j == CENTERPRINT_MAX_MSGS)
4711 if (centerprint_expire_time[j] <= time)
4713 if (centerprint_countdown_num[j] && centerprint_time[j] > 0)
4715 centerprint_countdown_num[j] = centerprint_countdown_num[j] - 1;
4716 if (centerprint_countdown_num[j] == 0)
4718 centerprint_expire_time[j] = centerprint_expire_time[j] + centerprint_time[j];
4724 // fade the centerprint_hud in/out
4725 if (centerprint_time[j] < 0 || centerprint_expire_time[j] - autocvar_hud_panel_centerprint_fade_out > time)
4726 a = bound(0, (time - (centerprint_expire_time[j] - centerprint_time[j])) / max(0.0001, autocvar_hud_panel_centerprint_fade_in), 1);
4727 else if (centerprint_expire_time[j] > time)
4728 a = (centerprint_expire_time[j] - time) / max(0.0001, autocvar_hud_panel_centerprint_fade_out);
4732 // set the size from fading in/out before subsequent fading
4733 sz = autocvar_hud_panel_centerprint_fade_minfontsize + a * (1 - autocvar_hud_panel_centerprint_fade_minfontsize);
4735 // also fade it based on positioning
4736 if(autocvar_hud_panel_centerprint_fade_subsequent)
4738 a = a * bound(autocvar_hud_panel_centerprint_fade_subsequent_passone_minalpha, (1 - (i / max(1, autocvar_hud_panel_centerprint_fade_subsequent_passone))), 1); // pass one: all messages after the first have half theAlpha
4739 a = a * bound(autocvar_hud_panel_centerprint_fade_subsequent_passtwo_minalpha, (1 - (i / max(1, autocvar_hud_panel_centerprint_fade_subsequent_passtwo))), 1); // pass two: after that, gradually lower theAlpha even more for each message
4742 // finally set the size based on the new theAlpha from subsequent fading
4743 sz = sz * (autocvar_hud_panel_centerprint_fade_subsequent_minfontsize + a * (1 - autocvar_hud_panel_centerprint_fade_subsequent_minfontsize));
4744 drawfontscale = sz * '1 1 0';
4746 if (centerprint_countdown_num[j])
4747 n = tokenizebyseparator(sprintf(centerprint_messages[j], centerprint_countdown_num[j]), "\n");
4749 n = tokenizebyseparator(centerprint_messages[j], "\n");
4751 if (autocvar_hud_panel_centerprint_flip)
4753 // check if the message can be entirely shown
4754 for(k = 0; k < n; ++k)
4756 getWrappedLine_remaining = argv(k);
4757 while(getWrappedLine_remaining)
4759 ts = getWrappedLine(panel_size_x * sz, fontsize, stringwidth_colors);
4761 pos_y -= fontsize_y;
4763 pos_y -= fontsize_y * CENTERPRINT_SPACING/2;
4766 current_msg_pos_y = pos_y; // save starting pos (first line) of the current message
4770 for(k = 0; k < n; ++k)
4772 getWrappedLine_remaining = argv(k);
4773 while(getWrappedLine_remaining)
4775 ts = getWrappedLine(panel_size_x * sz, fontsize, stringwidth_colors);
4779 pos_x = panel_pos_x + (panel_size_x - stringwidth(ts, TRUE, fontsize)) * align;
4780 drawcolorcodedstring(pos + eY * 0.5 * (1 - sz) * fontsize_y, ts, fontsize, a * panel_fg_alpha, DRAWFLAG_NORMAL);
4781 pos_y += fontsize_y;
4784 pos_y += fontsize_y * CENTERPRINT_SPACING/2;
4787 msg_size = pos_y - msg_size;
4788 if (autocvar_hud_panel_centerprint_flip)
4790 pos_y = current_msg_pos_y - CENTERPRINT_SPACING * fontsize_y;
4791 if (a < 1 && centerprint_msgID[j] == 0) // messages with id can be replaced just after they are faded out, so never move over them the next messages
4792 pos_y += (msg_size + CENTERPRINT_SPACING * fontsize_y) * (1 - sqrt(sz));
4794 if (pos_y < panel_pos_y) // check if the next message can be shown
4796 drawfontscale = '1 1 0';
4802 pos_y += CENTERPRINT_SPACING * fontsize_y;
4803 if (a < 1 && centerprint_msgID[j] == 0) // messages with id can be replaced just after they are faded out, so never move over them the next messages
4804 pos_y -= (msg_size + CENTERPRINT_SPACING * fontsize_y) * (1 - sqrt(sz));
4806 if(pos_y > panel_pos_y + panel_size_y - fontsize_y) // check if the next message can be shown
4808 drawfontscale = '1 1 0';
4813 drawfontscale = '1 1 0';
4816 centerprint_showing = FALSE;
4817 reset_centerprint_messages();
4827 void HUD_Reset (void)
4829 // reset gametype specific icons
4830 if(gametype == MAPINFO_TYPE_KEYHUNT)
4832 else if(gametype == MAPINFO_TYPE_CTF)
4833 HUD_Mod_CTF_Reset();
4836 #define HUD_DrawPanel(id)\
4838 case (HUD_PANEL_RADAR):\
4839 HUD_Radar(); break;\
4840 case (HUD_PANEL_WEAPONS):\
4841 HUD_Weapons(); break;\
4842 case (HUD_PANEL_AMMO):\
4844 case (HUD_PANEL_POWERUPS):\
4845 HUD_Powerups(); break;\
4846 case (HUD_PANEL_HEALTHARMOR):\
4847 HUD_HealthArmor(); break;\
4848 case (HUD_PANEL_NOTIFY):\
4849 HUD_Notify(); break;\
4850 case (HUD_PANEL_TIMER):\
4851 HUD_Timer(); break;\
4852 case (HUD_PANEL_SCORE):\
4853 HUD_Score(); break;\
4854 case (HUD_PANEL_RACETIMER):\
4855 HUD_RaceTimer(); break;\
4856 case (HUD_PANEL_VOTE):\
4857 HUD_VoteWindow(); break;\
4858 case (HUD_PANEL_MODICONS):\
4859 HUD_ModIcons(); break;\
4860 case (HUD_PANEL_PRESSEDKEYS):\
4861 HUD_DrawPressedKeys(); break;\
4862 case (HUD_PANEL_CHAT):\
4864 case (HUD_PANEL_ENGINEINFO):\
4865 HUD_EngineInfo(); break;\
4866 case (HUD_PANEL_INFOMESSAGES):\
4867 HUD_InfoMessages(); break;\
4868 case (HUD_PANEL_PHYSICS):\
4869 HUD_Physics(); break;\
4870 case (HUD_PANEL_CENTERPRINT):\
4871 HUD_CenterPrint(); break;\
4872 } ENDS_WITH_CURLY_BRACE
4874 void HUD_Main (void)
4877 // global hud theAlpha fade
4878 if(menu_enabled == 1)
4881 hud_fade_alpha = (1 - autocvar__menu_alpha);
4883 if(scoreboard_fade_alpha)
4884 hud_fade_alpha = (1 - scoreboard_fade_alpha);
4886 if(autocvar__hud_configure)
4888 HUD_Configure_Exit_Force();
4890 if(intermission == 2) // no hud during mapvote
4892 if (autocvar__hud_configure)
4893 HUD_Configure_Exit_Force();
4896 else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
4899 // panels that we want to be active together with the scoreboard
4900 // they must call HUD_Panel_ApplyFadeAlpha(); only when showing the menu
4901 if(scoreboard_fade_alpha == 1)
4907 if(!autocvar__hud_configure && !hud_fade_alpha)
4911 if (hud_skin_path != autocvar_hud_skin)
4914 strunzone(hud_skin_path);
4915 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
4918 // HUD configure visible grid
4919 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4921 hud_configure_gridSize_x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
4922 hud_configure_gridSize_y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
4923 hud_configure_realGridSize_x = hud_configure_gridSize_x * vid_conwidth;
4924 hud_configure_realGridSize_y = hud_configure_gridSize_y * vid_conheight;
4927 s = eX + eY * vid_conheight;
4928 for(i = 1; i < 1/hud_configure_gridSize_x; ++i)
4929 drawfill(eX * i * hud_configure_realGridSize_x, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4931 s = eY + eX * vid_conwidth;
4932 for(i = 1; i < 1/hud_configure_gridSize_y; ++i)
4933 drawfill(eY * i * hud_configure_realGridSize_y, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4936 #ifdef COMPAT_XON050_ENGINE
4937 current_player = (spectatee_status > 0) ? spectatee_status : player_localentnum;
4939 current_player = player_localentnum;
4943 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4947 float hud_dock_color_team = autocvar_hud_dock_color_team;
4948 if((teamplay) && hud_dock_color_team) {
4949 f = stof(getplayerkeyvalue(current_player - 1, "colors"));
4950 color = colormapPaletteColor(mod(f, 16), 1) * hud_dock_color_team;
4952 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
4953 color = '1 0 0' * hud_dock_color_team;
4957 string hud_dock_color = autocvar_hud_dock_color;
4958 if(hud_dock_color == "shirt") {
4959 f = stof(getplayerkeyvalue(current_player - 1, "colors"));
4960 color = colormapPaletteColor(floor(f / 16), 0);
4962 else if(hud_dock_color == "pants") {
4963 f = stof(getplayerkeyvalue(current_player - 1, "colors"));
4964 color = colormapPaletteColor(mod(f, 16), 1);
4967 color = stov(hud_dock_color);
4971 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4972 if(precache_pic(pic) == "") {
4973 pic = strcat(hud_skin_path, "/dock_medium");
4974 if(precache_pic(pic) == "") {
4975 pic = "gfx/hud/default/dock_medium";
4978 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...
4981 // cache the panel order into the panel_order array
4982 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4983 for(i = 0; i < HUD_PANEL_NUM; ++i)
4984 panel_order[i] = -1;
4986 float p_num, warning = false;
4987 float argc = tokenize_console(autocvar__hud_panelorder);
4988 if (argc > HUD_PANEL_NUM)
4990 //first detect wrong/missing panel numbers
4991 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4992 p_num = stof(argv(i));
4993 if (p_num >= 0 && p_num < HUD_PANEL_NUM) { //correct panel number?
4994 if (panel_order[p_num] == -1) //found for the first time?
4995 s = strcat(s, ftos(p_num), " ");
4996 panel_order[p_num] = 1; //mark as found
5001 for(i = 0; i < HUD_PANEL_NUM; ++i) {
5002 if (panel_order[i] == -1) {
5004 s = strcat(s, ftos(i), " "); //add missing panel number
5008 print(_("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n"));
5010 cvar_set("_hud_panelorder", s);
5011 if(hud_panelorder_prev)
5012 strunzone(hud_panelorder_prev);
5013 hud_panelorder_prev = strzone(s);
5015 //now properly set panel_order
5016 tokenize_console(s);
5017 for(i = 0; i < HUD_PANEL_NUM; ++i) {
5018 panel_order[i] = stof(argv(i));
5022 hud_draw_maximized = 0;
5023 // draw panels in order specified by panel_order array
5024 for(i = HUD_PANEL_NUM - 1; i >= 0; --i)
5025 HUD_DrawPanel(panel_order[i]);
5027 hud_draw_maximized = 1; // panels that may be maximized must check this var
5028 // draw maximized panels on top
5029 if(hud_panel_radar_maximized)
5031 if(autocvar__con_chat_maximized)
5034 if(autocvar__hud_configure)
5038 HUD_Panel_UpdatePosSizeForId(tab_panel)
5039 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
5041 if(highlightedPanel != -1)
5043 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
5044 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha));
5046 if (!hud_configure_prev)
5048 if(autocvar_hud_cursormode) { setcursormode(1); }
5052 else if (hud_configure_prev && autocvar_hud_cursormode)
5055 hud_configure_prev = autocvar__hud_configure;
5057 if (!autocvar__hud_configure) // hud config mode disabled, enable normal theAlpha stuff again