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, weapon_alpha;
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_effect ? 0.375 : 0);
474 float timeout_effect_length = (autocvar_hud_panel_weapons_timeout_effect ? 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)
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 // calculate fading effect to weapon images for when the panel is idle
511 if(autocvar_hud_panel_weapons_fade)
513 weapon_alpha = 3.2 - 2 * (time - weapontime);
514 weapon_alpha = bound(0.7, weapon_alpha, 1) * panel_fg_alpha;
517 weapon_alpha = panel_fg_alpha;
519 // figure out weapon order (how the weapons are sorted) // TODO make this configurable
520 if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
523 if(weaponorder_bypriority)
524 strunzone(weaponorder_bypriority);
525 if(weaponorder_byimpulse)
526 strunzone(weaponorder_byimpulse);
528 weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
529 weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
530 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
533 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
535 self = get_weaponinfo(i);
536 if(self.impulse >= 0)
538 weaponorder[weapon_cnt] = self;
542 for(i = weapon_cnt; i < WEP_MAXCOUNT; ++i)
543 weaponorder[i] = world;
544 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
546 weaponorder_cmp_str = string_null;
549 // determine which weapons are going to be shown
550 if (autocvar_hud_panel_weapons_onlyowned)
552 if(autocvar__hud_configure)
554 if (WEPSET_EMPTY_A(weapons_stat))
555 for(i = WEP_FIRST; i <= WEP_LAST; i += floor((WEP_LAST-WEP_FIRST)/5))
556 WEPSET_OR_AW(weapons_stat, i);
558 if(menu_enabled != 2)
559 HUD_Panel_DrawBg(1); // also draw the bg of the entire panel
562 // do we own this weapon?
564 for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
565 if(WEPSET_CONTAINS_AW(weapons_stat, weaponorder[i].weapon))
568 // add it anyway if weaponcomplain is shown
569 if((!autocvar__hud_configure)
570 && (autocvar_hud_panel_weapons_complainbubble
571 && time - complain_weapon_time < when + fadetime))
574 // might as well commit suicide now, no reason to live ;)
575 if (weapon_count == 0) { return; }
577 // reduce size of the panel
578 if (panel_size_y > panel_size_x)
580 old_panel_size_y = panel_size_y;
581 panel_size_y *= weapon_count / WEP_COUNT;
582 panel_pos_y += (old_panel_size_y - panel_size_y) / 2;
586 old_panel_size_x = panel_size_x;
587 panel_size_x *= weapon_count / WEP_COUNT;
588 panel_pos_x += (old_panel_size_x - panel_size_x) / 2;
592 weapon_count = WEP_COUNT;
594 // animation for fading in/out the panel respectively when not in use
595 if(!autocvar__hud_configure)
597 if (timeout && time >= weapontime + timeout) // apply timeout effect if needed
599 f = (time - (weapontime + timeout)) / timeout_effect_length;
600 if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3)
602 panel_bg_alpha *= (1 - f);
603 panel_fg_alpha *= (1 - f);
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 = (time - weaponprevtime) / timein_effect_length;
631 if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3)
633 panel_bg_alpha *= (f);
634 panel_fg_alpha *= (f);
636 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
638 f *= f; // for a cooler movement
640 center_x = panel_pos_x + panel_size_x/2;
641 center_y = panel_pos_y + panel_size_y/2;
642 screen_ar = vid_conwidth/vid_conheight;
643 if (center_x/center_y < screen_ar) //bottom left
645 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
646 panel_pos_y += f * (vid_conheight - panel_pos_y);
648 panel_pos_x -= f * (panel_pos_x + panel_size_x);
652 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
653 panel_pos_x += f * (vid_conwidth - panel_pos_x);
655 panel_pos_y -= f * (panel_pos_y + panel_size_y);
661 // draw the background, then change the virtual size of it to better fit other items inside
665 panel_pos += '1 1 0' * panel_bg_padding;
666 panel_size -= '2 2 0' * panel_bg_padding;
669 // after the sizing and animations are done, update the other values
670 rows = panel_size_y/panel_size_x;
671 rows = bound(1, floor((sqrt(4 * aspect * rows * weapon_count + rows * rows) + rows + 0.5) / 2), weapon_count);
672 columns = ceil(weapon_count/rows);
673 weapon_size = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
675 // calculate position/size for visual bar displaying ammount of ammo status
676 if (autocvar_hud_panel_weapons_ammo)
678 ammo_color = stov(autocvar_hud_panel_weapons_ammo_color);
679 ammo_alpha = panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha;
681 if(weapon_size_x/weapon_size_y > aspect)
683 barsize_x = aspect * weapon_size_y;
684 barsize_y = weapon_size_y;
685 baroffset_x = (weapon_size_x - barsize_x) / 2;
689 barsize_y = 1/aspect * weapon_size_x;
690 barsize_x = weapon_size_x;
691 baroffset_y = (weapon_size_y - barsize_y) / 2;
695 if(autocvar_hud_panel_weapons_accuracy && acc_levels)
697 show_accuracy = true;
698 if (acc_col[0] == '-1 0 0')
699 for (i = 0; i < acc_levels; ++i)
700 acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
704 for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
706 // retrieve information about the current weapon to be drawn
707 self = weaponorder[i];
708 weapon_id = self.impulse;
710 // skip if this weapon doesn't exist
711 if (!self || self.impulse < 0) { continue; }
713 // skip this weapon if we don't own it (and onlyowned is enabled)-- or if weapons_complainbubble is showing for this weapon
714 if (autocvar_hud_panel_weapons_onlyowned
715 && !(WEPSET_CONTAINS_AW(weapons_stat, self.weapon)
716 || (self.weapon == complain_weapon
717 && time - complain_weapon_time < when + fadetime
718 && autocvar_hud_panel_weapons_complainbubble)))
721 // figure out the drawing position of weapon
722 weapon_pos = (panel_pos
723 + eX * column * weapon_size_x
724 + eY * row * weapon_size_y);
726 // draw background behind currently selected weapon
727 if(self.weapon == switchweapon)
728 drawpic_aspect_skin(weapon_pos, "weapon_current_bg", weapon_size, '1 1 1', weapon_alpha, DRAWFLAG_NORMAL);
730 // draw the weapon accuracy
733 panel_weapon_accuracy = weapon_accuracy[self.weapon-WEP_FIRST];
734 if(panel_weapon_accuracy >= 0)
736 // find the max level lower than weapon_accuracy
738 while ( j && panel_weapon_accuracy < acc_lev[j] )
741 // inject color j+1 in color j, how much depending on how much weapon_accuracy is higher than level j
742 factor = (panel_weapon_accuracy - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
744 color = color + factor * (acc_col[j+1] - color);
746 drawpic_aspect_skin(weapon_pos, "weapon_accuracy", weapon_size, color, panel_fg_alpha, DRAWFLAG_NORMAL);
750 // drawing all the weapon items
751 if(WEPSET_CONTAINS_AW(weapons_stat, self.weapon))
753 // draw the weapon image
754 drawpic_aspect_skin(weapon_pos, strcat("weapon", self.netname), weapon_size, '1 1 1', weapon_alpha, DRAWFLAG_NORMAL);
756 // draw weapon label string
757 switch(autocvar_hud_panel_weapons_label)
759 case 1: // weapon number
760 drawstring(weapon_pos, ftos(weapon_id), '1 1 0' * 0.5 * weapon_size_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
764 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);
767 case 3: // weapon name
768 drawstring(weapon_pos, self.netname, '1 1 0' * 0.5 * weapon_size_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
775 // draw ammo status bar
776 if(autocvar_hud_panel_weapons_ammo && self.weapon != WEP_TUBA && self.weapon != WEP_LASER && self.weapon != WEP_PORTO)
779 ammo_type = GetAmmoTypeForWep(self.weapon);
781 a = getstati(GetAmmoStat(ammo_type)); // how much ammo do we have?
786 case 0: ammo_full = autocvar_hud_panel_weapons_ammo_full_shells; break;
787 case 1: ammo_full = autocvar_hud_panel_weapons_ammo_full_nails; break;
788 case 2: ammo_full = autocvar_hud_panel_weapons_ammo_full_rockets; break;
789 case 3: ammo_full = autocvar_hud_panel_weapons_ammo_full_cells; break;
790 case 4: ammo_full = autocvar_hud_panel_weapons_ammo_full_fuel; break;
791 default: ammo_full = 60;
795 weapon_pos_x + baroffset_x,
796 weapon_pos_y + baroffset_y,
797 barsize_x * bound(0, a/ammo_full, 1),
799 drawpic_aspect_skin(weapon_pos, "weapon_ammo", weapon_size, ammo_color, ammo_alpha, DRAWFLAG_NORMAL);
804 else // draw a "ghost weapon icon" if you don't have the weapon
806 drawpic_aspect_skin(weapon_pos, strcat("weapon", self.netname), weapon_size, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
809 // draw the complain message
810 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
813 a = ((complain_weapon_time + when > time) ? 1 : bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1));
815 a = ((complain_weapon_time + when > time) ? 1 : 0);
819 if(complain_weapon_type == 0) {
820 s = _("Out of ammo");
821 color = stov(autocvar_hud_panel_weapons_complainbubble_color_outofammo);
823 else if(complain_weapon_type == 1) {
825 color = stov(autocvar_hud_panel_weapons_complainbubble_color_donthave);
828 s = _("Unavailable");
829 color = stov(autocvar_hud_panel_weapons_complainbubble_color_unavailable);
831 float padding = autocvar_hud_panel_weapons_complainbubble_padding;
832 drawpic_aspect_skin(weapon_pos + '1 1 0' * padding, "weapon_complainbubble", weapon_size - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
833 drawstring_aspect(weapon_pos + '1 1 0' * padding, s, weapon_size - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
836 // continue with new position for the next weapon
851 float GetAmmoItemCode(float i)
855 case 0: return IT_SHELLS;
856 case 1: return IT_NAILS;
857 case 2: return IT_ROCKETS;
858 case 3: return IT_CELLS;
859 case 4: return IT_FUEL;
864 string GetAmmoPicture(float i)
868 case 0: return "ammo_shells";
869 case 1: return "ammo_bullets";
870 case 2: return "ammo_rockets";
871 case 3: return "ammo_cells";
872 case 4: return "ammo_fuel";
877 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected, float infinite_ammo)
880 if(autocvar__hud_configure)
882 currently_selected = (itemcode == 2); //rockets always selected
883 a = 31 + mod(itemcode*93, 128);
886 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
890 color = '0 0.5 0.75';
897 if(currently_selected)
902 vector picpos, numpos;
903 if(autocvar_hud_panel_ammo_iconalign)
906 picpos = myPos + eX * 2 * mySize_y;
910 numpos = myPos + eX * mySize_y;
914 if (currently_selected)
915 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
917 if(a > 0 && autocvar_hud_panel_ammo_progressbar)
918 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);
920 if(autocvar_hud_panel_ammo_text)
922 if(a > 0 || infinite_ammo)
923 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
924 else // "ghost" ammo count
925 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * theAlpha * 0.5, DRAWFLAG_NORMAL);
927 if(a > 0 || infinite_ammo)
928 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
929 else // "ghost" ammo icon
930 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '0 0 0', panel_fg_alpha * theAlpha * 0.5, DRAWFLAG_NORMAL);
935 if(hud != HUD_NORMAL) return;
936 if(!autocvar__hud_configure)
938 if(!autocvar_hud_panel_ammo) return;
939 if(spectatee_status == -1) return;
942 hud_configure_active_panel = HUD_PANEL_AMMO;
944 HUD_Panel_UpdateCvars(ammo);
945 HUD_Panel_ApplyFadeAlpha();
947 draw_beginBoldFont();
956 pos += '1 1 0' * panel_bg_padding;
957 mySize -= '2 2 0' * panel_bg_padding;
960 float rows = 0, columns, row, column;
962 if (autocvar_hud_panel_ammo_onlycurrent)
966 rows = mySize_y/mySize_x;
967 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
968 // ^^^ ammo item aspect goes here
970 columns = ceil(AMMO_COUNT/rows);
972 ammo_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
975 local vector offset = '0 0 0'; // fteqcc sucks
977 if(ammo_size_x/ammo_size_y > 3)
979 newSize = 3 * ammo_size_y;
980 offset_x = ammo_size_x - newSize;
982 ammo_size_x = newSize;
986 newSize = 1/3 * ammo_size_x;
987 offset_y = ammo_size_y - newSize;
989 ammo_size_y = newSize;
992 float i, stat_items, currently_selected, infinite_ammo;
993 infinite_ammo = FALSE;
994 if (autocvar_hud_panel_ammo_onlycurrent)
996 if(autocvar__hud_configure)
998 DrawAmmoItem(pos, ammo_size, 2, true, FALSE); //show rockets
1002 stat_items = getstati(STAT_ITEMS, 0, 24);
1003 if (stat_items & IT_UNLIMITED_WEAPON_AMMO)
1004 infinite_ammo = TRUE;
1005 for (i = 0; i < AMMO_COUNT; ++i) {
1006 currently_selected = stat_items & GetAmmoItemCode(i);
1007 if (currently_selected)
1009 DrawAmmoItem(pos, ammo_size, i, true, infinite_ammo);
1017 stat_items = getstati(STAT_ITEMS, 0, 24);
1018 if (stat_items & IT_UNLIMITED_WEAPON_AMMO)
1019 infinite_ammo = TRUE;
1021 for (i = 0; i < AMMO_COUNT; ++i) {
1022 currently_selected = stat_items & GetAmmoItemCode(i);
1023 DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected, infinite_ammo);
1028 column = column + 1;
1036 void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float theAlpha, float fadelerp)
1038 vector newPos = '0 0 0', newSize = '0 0 0';
1039 vector picpos, numpos;
1043 if(mySize_y/mySize_x > 2)
1045 newSize_y = 2 * mySize_x;
1046 newSize_x = mySize_x;
1048 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1053 newSize_x = 1/2 * mySize_y;
1054 newSize_y = mySize_y;
1056 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1060 if(icon_right_align)
1063 picpos = newPos + eY * newSize_x;
1068 numpos = newPos + eY * newSize_x;
1072 drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
1073 // make number smaller than icon, it looks better
1074 // reduce only y to draw numbers with different number of digits with the same y size
1075 numpos_y += newSize_y * ((1 - 0.7) / 2);
1077 drawstring_aspect(numpos, ftos(x), newSize, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
1081 if(mySize_x/mySize_y > 3)
1083 newSize_x = 3 * mySize_y;
1084 newSize_y = mySize_y;
1086 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1091 newSize_y = 1/3 * mySize_x;
1092 newSize_x = mySize_x;
1094 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1098 if(icon_right_align) // right align
1101 picpos = newPos + eX * 2 * newSize_y;
1105 numpos = newPos + eX * newSize_y;
1109 // NOTE: newSize_x is always equal to 3 * mySize_y so we can use
1110 // '2 1 0' * newSize_y instead of eX * (2/3) * newSize_x + eY * newSize_y
1111 drawstring_aspect_expanding(numpos, ftos(x), '2 1 0' * newSize_y, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
1112 drawpic_aspect_skin_expanding(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
1115 void DrawNumIcon(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float theAlpha)
1117 DrawNumIcon_expanding(myPos, mySize, x, icon, vertical, icon_right_align, color, theAlpha, 0);
1122 void HUD_Powerups(void)
1124 float strength_time, shield_time, superweapons_time;
1125 if(!autocvar__hud_configure)
1127 if(!autocvar_hud_panel_powerups) return;
1128 if(spectatee_status == -1) return;
1129 if not(getstati(STAT_ITEMS, 0, 24) & (IT_STRENGTH | IT_INVINCIBLE | IT_SUPERWEAPON)) return;
1130 if (getstati(STAT_HEALTH) <= 0) return;
1132 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1133 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1134 superweapons_time = bound(0, getstatf(STAT_SUPERWEAPONS_FINISHED) - time, 99);
1136 if (getstati(STAT_ITEMS, 0, 24) & IT_UNLIMITED_SUPERWEAPONS)
1137 superweapons_time = 99; // force max
1139 // prevent stuff to show up on mismatch that will be fixed next frame
1140 if (!(getstati(STAT_ITEMS, 0, 24) & IT_SUPERWEAPON))
1141 superweapons_time = 0;
1145 hud_configure_active_panel = HUD_PANEL_POWERUPS;
1149 superweapons_time = 13;
1152 HUD_Panel_UpdateCvars(powerups);
1153 HUD_Panel_ApplyFadeAlpha();
1155 draw_beginBoldFont();
1159 mySize = panel_size;
1161 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time, superweapons_time), 1));
1162 if(panel_bg_padding)
1164 pos += '1 1 0' * panel_bg_padding;
1165 mySize -= '2 2 0' * panel_bg_padding;
1168 float panel_ar = mySize_x/mySize_y;
1169 float is_vertical = (panel_ar < 1);
1170 vector shield_offset = '0 0 0', strength_offset = '0 0 0', superweapons_offset = '0 0 0';
1172 float superweapons_is = -1;
1174 if(superweapons_time)
1179 superweapons_is = 0;
1181 superweapons_is = 2;
1186 superweapons_is = 1;
1188 superweapons_is = 2;
1192 // FIXME handle superweapons here
1193 if(superweapons_is == 0)
1195 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1197 mySize_x *= (1.0 / 3.0);
1198 superweapons_offset_x = mySize_x;
1199 if (autocvar_hud_panel_powerups_flip)
1200 shield_offset_x = 2*mySize_x;
1202 strength_offset_x = 2*mySize_x;
1206 mySize_y *= (1.0 / 3.0);
1207 superweapons_offset_y = mySize_y;
1208 if (autocvar_hud_panel_powerups_flip)
1209 shield_offset_y = 2*mySize_y;
1211 strength_offset_y = 2*mySize_y;
1216 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1219 if (autocvar_hud_panel_powerups_flip)
1220 shield_offset_x = mySize_x;
1222 strength_offset_x = mySize_x;
1227 if (autocvar_hud_panel_powerups_flip)
1228 shield_offset_y = mySize_y;
1230 strength_offset_y = mySize_y;
1234 float shield_baralign, strength_baralign, superweapons_baralign;
1235 float shield_iconalign, strength_iconalign, superweapons_iconalign;
1237 if (autocvar_hud_panel_powerups_flip)
1239 strength_baralign = (autocvar_hud_panel_powerups_baralign == 2 || autocvar_hud_panel_powerups_baralign == 1);
1240 shield_baralign = (autocvar_hud_panel_powerups_baralign == 3 || autocvar_hud_panel_powerups_baralign == 1);
1241 strength_iconalign = (autocvar_hud_panel_powerups_iconalign == 2 || autocvar_hud_panel_powerups_iconalign == 1);
1242 shield_iconalign = (autocvar_hud_panel_powerups_iconalign == 3 || autocvar_hud_panel_powerups_iconalign == 1);
1246 shield_baralign = (autocvar_hud_panel_powerups_baralign == 2 || autocvar_hud_panel_powerups_baralign == 1);
1247 strength_baralign = (autocvar_hud_panel_powerups_baralign == 3 || autocvar_hud_panel_powerups_baralign == 1);
1248 shield_iconalign = (autocvar_hud_panel_powerups_iconalign == 2 || autocvar_hud_panel_powerups_iconalign == 1);
1249 strength_iconalign = (autocvar_hud_panel_powerups_iconalign == 3 || autocvar_hud_panel_powerups_iconalign == 1);
1252 if(superweapons_is == 0)
1254 superweapons_iconalign = strength_iconalign;
1255 superweapons_baralign = 2;
1257 else if(superweapons_is == 1)
1259 superweapons_offset = strength_offset;
1260 superweapons_iconalign = strength_iconalign;
1261 superweapons_baralign = strength_baralign;
1263 else // if(superweapons_is == 2)
1265 superweapons_offset = shield_offset;
1266 superweapons_iconalign = shield_iconalign;
1267 superweapons_baralign = shield_baralign;
1272 const float maxshield = 30;
1273 float shield = ceil(shield_time);
1274 if(autocvar_hud_panel_powerups_progressbar)
1276 HUD_Panel_GetProgressBarColor(shield);
1277 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);
1279 if(autocvar_hud_panel_powerups_text)
1282 DrawNumIcon(pos + shield_offset, mySize, shield, "shield", is_vertical, shield_iconalign, '1 1 1', 1);
1284 DrawNumIcon_expanding(pos + shield_offset, mySize, shield, "shield", is_vertical, shield_iconalign, '1 1 1', 1, bound(0, (shield - shield_time) / 0.5, 1));
1290 const float maxstrength = 30;
1291 float strength = ceil(strength_time);
1292 if(autocvar_hud_panel_powerups_progressbar)
1294 HUD_Panel_GetProgressBarColor(strength);
1295 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);
1297 if(autocvar_hud_panel_powerups_text)
1300 DrawNumIcon(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', 1);
1302 DrawNumIcon_expanding(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', 1, bound(0, (strength - strength_time) / 0.5, 1));
1306 if(superweapons_time)
1308 const float maxsuperweapons = 30;
1309 float superweapons = ceil(superweapons_time);
1310 if(autocvar_hud_panel_powerups_progressbar)
1312 HUD_Panel_GetProgressBarColor(superweapons);
1313 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);
1315 if(autocvar_hud_panel_powerups_text)
1317 if(superweapons > 1)
1318 DrawNumIcon(pos + superweapons_offset, mySize, superweapons, "superweapons", is_vertical, superweapons_iconalign, '1 1 1', 1);
1319 if(superweapons <= 5)
1320 DrawNumIcon_expanding(pos + superweapons_offset, mySize, superweapons, "superweapons", is_vertical, superweapons_iconalign, '1 1 1', 1, bound(0, (superweapons - superweapons_time) / 0.5, 1));
1327 // Health/armor (#3)
1330 // prev_* vars contain the health/armor at the previous FRAME
1331 // set to -1 when player is dead or was not playing
1332 float prev_health, prev_armor;
1333 float health_damagetime, armor_damagetime;
1334 float health_beforedamage, armor_beforedamage;
1335 // old_p_* vars keep track of previous values when smoothing value changes of the progressbar
1336 float old_p_health, old_p_armor;
1337 float old_p_healthtime, old_p_armortime;
1338 // prev_p_* vars contain the health/armor progressbar value at the previous FRAME
1339 // set to -1 to forcedly stop effects when we switch spectated player (e.g. from playerX: 70h to playerY: 50h)
1340 float prev_p_health, prev_p_armor;
1342 void HUD_HealthArmor(void)
1344 float armor, health, fuel;
1345 if(!autocvar__hud_configure)
1347 if(!autocvar_hud_panel_healtharmor) return;
1348 if(hud != HUD_NORMAL) return;
1349 if(spectatee_status == -1) return;
1351 health = getstati(STAT_HEALTH);
1357 armor = getstati(STAT_ARMOR);
1359 // code to check for spectatee_status changes is in Ent_ClientData()
1360 // prev_p_health and prev_health can be set to -1 there
1362 if (prev_p_health == -1)
1365 health_beforedamage = 0;
1366 armor_beforedamage = 0;
1367 health_damagetime = 0;
1368 armor_damagetime = 0;
1369 prev_health = health;
1371 old_p_health = health;
1372 old_p_armor = armor;
1373 prev_p_health = health;
1374 prev_p_armor = armor;
1376 else if (prev_health == -1)
1378 //start the load effect
1379 health_damagetime = 0;
1380 armor_damagetime = 0;
1384 fuel = getstati(STAT_FUEL);
1388 hud_configure_active_panel = HUD_PANEL_HEALTHARMOR;
1395 HUD_Panel_UpdateCvars(healtharmor);
1396 HUD_Panel_ApplyFadeAlpha();
1399 mySize = panel_size;
1401 HUD_Panel_DrawBg(1);
1402 if(panel_bg_padding)
1404 pos += '1 1 0' * panel_bg_padding;
1405 mySize -= '2 2 0' * panel_bg_padding;
1408 float baralign = autocvar_hud_panel_healtharmor_baralign;
1409 float iconalign = autocvar_hud_panel_healtharmor_iconalign;
1411 float maxhealth = autocvar_hud_panel_healtharmor_maxhealth;
1412 float maxarmor = autocvar_hud_panel_healtharmor_maxarmor;
1413 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
1416 v = healtharmor_maxdamage(health, armor, armorblockpercent);
1421 float maxtotal = maxhealth + maxarmor;
1423 if(v_z) // NOT fully armored
1425 biggercount = "health";
1426 if(autocvar_hud_panel_healtharmor_progressbar)
1428 HUD_Panel_GetProgressBarColor(health);
1429 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);
1432 if(autocvar_hud_panel_healtharmor_text)
1433 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);
1437 biggercount = "armor";
1438 if(autocvar_hud_panel_healtharmor_progressbar)
1440 HUD_Panel_GetProgressBarColor(armor);
1441 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);
1444 if(autocvar_hud_panel_healtharmor_text)
1445 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);
1447 if(autocvar_hud_panel_healtharmor_text)
1448 DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, maxtotal), 1);
1452 HUD_Panel_GetProgressBarColor(fuel);
1453 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);
1458 float panel_ar = mySize_x/mySize_y;
1459 float is_vertical = (panel_ar < 1);
1460 vector health_offset = '0 0 0', armor_offset = '0 0 0';
1461 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1464 if (autocvar_hud_panel_healtharmor_flip)
1465 health_offset_x = mySize_x;
1467 armor_offset_x = mySize_x;
1472 if (autocvar_hud_panel_healtharmor_flip)
1473 health_offset_y = mySize_y;
1475 armor_offset_y = mySize_y;
1478 float health_baralign, armor_baralign, fuel_baralign;
1479 float health_iconalign, armor_iconalign;
1480 if (autocvar_hud_panel_healtharmor_flip)
1482 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1483 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1484 fuel_baralign = health_baralign;
1485 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1486 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1490 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1491 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1492 fuel_baralign = armor_baralign;
1493 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1494 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1499 if(autocvar_hud_panel_healtharmor_progressbar)
1501 HUD_Panel_GetProgressBarColor(health);
1502 float p_health, pain_health_alpha;
1504 pain_health_alpha = 1;
1505 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1507 if (autocvar_hud_panel_healtharmor_progressbar_gfx_smooth > 0)
1509 if (fabs(prev_health - health) >= autocvar_hud_panel_healtharmor_progressbar_gfx_smooth)
1511 if (time - old_p_healthtime < 1)
1512 old_p_health = prev_p_health;
1514 old_p_health = prev_health;
1515 old_p_healthtime = time;
1517 if (time - old_p_healthtime < 1)
1519 p_health += (old_p_health - health) * (1 - (time - old_p_healthtime));
1520 prev_p_health = p_health;
1523 if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0)
1525 if (prev_health - health >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
1527 if (time - health_damagetime >= 1)
1528 health_beforedamage = prev_health;
1529 health_damagetime = time;
1531 if (time - health_damagetime < 1)
1533 float health_damagealpha = 1 - (time - health_damagetime)*(time - health_damagetime);
1534 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);
1537 prev_health = health;
1539 if (health <= autocvar_hud_panel_healtharmor_progressbar_gfx_lowhealth)
1541 float BLINK_FACTOR = 0.15;
1542 float BLINK_BASE = 0.85;
1543 float BLINK_FREQ = 9;
1544 pain_health_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
1547 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);
1549 if(autocvar_hud_panel_healtharmor_text)
1550 DrawNumIcon(pos + health_offset, mySize, health, "health", is_vertical, health_iconalign, HUD_Get_Num_Color(health, maxhealth), 1);
1555 if(autocvar_hud_panel_healtharmor_progressbar)
1557 HUD_Panel_GetProgressBarColor(armor);
1560 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1562 if (autocvar_hud_panel_healtharmor_progressbar_gfx_smooth > 0)
1564 if (fabs(prev_armor - armor) >= autocvar_hud_panel_healtharmor_progressbar_gfx_smooth)
1566 if (time - old_p_armortime < 1)
1567 old_p_armor = prev_p_armor;
1569 old_p_armor = prev_armor;
1570 old_p_armortime = time;
1572 if (time - old_p_armortime < 1)
1574 p_armor += (old_p_armor - armor) * (1 - (time - old_p_armortime));
1575 prev_p_armor = p_armor;
1578 if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0)
1580 if (prev_armor - armor >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
1582 if (time - armor_damagetime >= 1)
1583 armor_beforedamage = prev_armor;
1584 armor_damagetime = time;
1586 if (time - armor_damagetime < 1)
1588 float armor_damagealpha = 1 - (time - armor_damagetime)*(time - armor_damagetime);
1589 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);
1594 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);
1596 if(autocvar_hud_panel_healtharmor_text)
1597 DrawNumIcon(pos + armor_offset, mySize, armor, "armor", is_vertical, armor_iconalign, HUD_Get_Num_Color(armor, maxarmor), 1);
1603 mySize_x *= 0.2 / 2; //if vertical always halve x to not cover too much numbers with 3 digits
1607 mySize_x *= 2; //restore full panel size
1608 else if (panel_ar < 1/4)
1609 mySize_y *= 2; //restore full panel size
1610 HUD_Panel_GetProgressBarColor(fuel);
1611 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
1616 // Notification area (#4)
1619 string Weapon_SuicideMessage(float deathtype)
1621 w_deathtype = deathtype;
1622 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
1623 return w_deathtypestring;
1626 string Weapon_KillMessage(float deathtype)
1628 w_deathtype = deathtype;
1629 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
1630 return w_deathtypestring;
1634 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
1638 float alsoprint, gentle;
1639 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
1640 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
1642 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
1645 if(msg == MSG_SUICIDE) {
1646 w = DEATH_WEAPONOF(type);
1648 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1650 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
1651 } else if (type == DEATH_KILL) {
1652 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
1654 print (sprintf(_("^1%s^1 couldn't take it anymore\n"), s1));
1655 } else if (type == DEATH_ROT) {
1656 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1658 print (sprintf(_("^1%s^1 died\n"), s1));
1659 } else if (type == DEATH_NOAMMO) {
1660 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
1662 print (sprintf(_("^7%s^7 committed suicide. What's the point of living without ammo?\n"), s1));
1663 } else if (type == DEATH_CAMP) {
1664 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
1666 print (sprintf(_("^1%s^1 thought they found a nice camping ground\n"), s1));
1667 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
1668 HUD_KillNotify_Push(s1, "", 0, type);
1670 print (sprintf(_("^1%s^1 didn't become friends with the Lord of Teamplay\n"), s1));
1671 } else if (type == DEATH_CHEAT) {
1672 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1674 print (sprintf(_("^1%s^1 unfairly eliminated themself\n"), s1));
1675 } else if (type == DEATH_FIRE) {
1676 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1678 print (sprintf(_("^1%s^1 burned to death\n"), s1));
1679 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
1680 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1682 print (sprintf(_("^1%s^1 couldn't resist the urge to self-destruct\n"), s1));
1685 if (stof(s2) > 2) // killcount > 2
1686 print (sprintf(_("^1%s^1 ended it all after a %d kill spree\n"), s1, stof(s2)));
1687 } else if(msg == MSG_KILL) {
1688 w = DEATH_WEAPONOF(type);
1690 HUD_KillNotify_Push(s1, s2, 1, type);
1692 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
1694 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
1695 HUD_KillNotify_Push(s1, s2, 1, type);
1699 print (sprintf(_("^1%s^1 took action against a team mate\n"), s1));
1701 print (sprintf(_("^1%s^1 mows down a team mate\n"), s1));
1704 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
1706 print (sprintf(_("^1%s^1 ended a %d scoring spree by going against a team mate\n"), s1, stof(s3)));
1708 print (sprintf(_("^1%s^1 ended a %d kill spree by killing a team mate\n"), s1, stof(s3)));
1710 else if (stof(s2) > 2) {
1712 print (sprintf(_("^1%s^1's %s scoring spree was ended by a team mate!\n"), s1, stof(s3)));
1714 print (sprintf(_("^1%s^1's %s kill spree was ended by a team mate!\n"), s1, stof(s3)));
1717 else if(type == KILL_FIRST_BLOOD)
1718 print(sprintf(_("^1%s^1 drew first blood\n"), s1));
1719 else if (type == DEATH_TELEFRAG) {
1720 HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
1722 print (sprintf(_("^1%s^1 tried to occupy %s^1's teleport destination space\n"), s2, s1));
1724 print (sprintf(_("^1%s^1 was telefragged by %s\n"), s2, s1));
1726 else if (type == DEATH_DROWN) {
1727 HUD_KillNotify_Push(s1, s2, 1, DEATH_DROWN);
1729 print (sprintf(_("^1%s^1 was drowned by %s\n"), s2, s1));
1731 else if (type == DEATH_SLIME) {
1732 HUD_KillNotify_Push(s1, s2, 1, DEATH_SLIME);
1734 print (sprintf(_("^1%s^1 was slimed by %s\n"), s2, s1));
1736 else if (type == DEATH_LAVA) {
1737 HUD_KillNotify_Push(s1, s2, 1, DEATH_LAVA);
1739 print (sprintf(_("^1%s^1 was cooked by %s\n"), s2, s1));
1741 else if (type == DEATH_FALL) {
1742 HUD_KillNotify_Push(s1, s2, 1, DEATH_FALL);
1744 print (sprintf(_("^1%s^1 was grounded by %s\n"), s2, s1));
1746 else if (type == DEATH_SHOOTING_STAR) {
1747 HUD_KillNotify_Push(s1, s2, 1, DEATH_SHOOTING_STAR);
1749 print (sprintf(_("^1%s^1 was shot into space by %s\n"), s2, s1));
1751 else if (type == DEATH_SWAMP) {
1752 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1754 print (sprintf(_("^1%s^1 was conserved by %s\n"), s2, s1));
1756 else if (type == DEATH_HURTTRIGGER)
1758 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1760 print(sprintf(_("^1%s^1 was thrown into a world of hurt by %s\n"), s2, s1));
1761 } else if(type == DEATH_VHCRUSH) {
1762 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1764 print (sprintf(_("^1%s^1 was crushed by %s\n"), s2, s1));
1765 } else if(type == DEATH_SBMINIGUN) {
1766 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1768 print (sprintf(_("^1%s^1 got shredded by %s\n"), s2, s1));
1769 } else if(type == DEATH_SBROCKET) {
1770 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1772 print (sprintf(_("^1%s^1 was blasted to bits by %s\n"), s2, s1));
1773 } else if(type == DEATH_SBBLOWUP) {
1774 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1776 print (sprintf(_("^1%s^1 got caught in the blast when %s^1's destroys a vehicle\n"), s2, s1));
1777 } else if(type == DEATH_WAKIGUN) {
1778 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1780 print (sprintf(_("^1%s^1 was bolted down by %s\n"), s2, s1));
1781 } else if(type == DEATH_BUMB_GUN) {
1782 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1784 print (sprintf(_("^1%s^1 saw %s's preddy lights.\n"), s2, s1));
1785 } else if(type == DEATH_WAKIROCKET) {
1786 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1788 print (sprintf(_("^1%s^1 could find no shelter from %s^1's rockets\n"), s2, s1));
1789 } else if(type == DEATH_WAKIBLOWUP) {
1790 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1792 print (sprintf(_("^1%s^1 got caught in the blast when %s^1's destroys a vehicle\n"), s2, s1));
1793 } else if(type == DEATH_RAPTOR_CANNON) {
1794 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1796 print (sprintf(_("^1%s^1 nailed to hell by %s\n"), s2, s1));
1797 } else if(type == DEATH_RAPTOR_BOMB) {
1798 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1800 print (sprintf(_("^1%s^1 cluster crushed by %s\n"), s2, s1));
1801 } else if(type == DEATH_RAPTOR_DEATH) {
1802 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1804 print (sprintf(_("^1%s^1 got caught in the blast when %s^1's destroys a vehicle\n"), s2, s1));
1805 } else if(type == DEATH_TURRET) {
1806 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1808 print (sprintf(_("^1%s^1 was pushed into the line of fire by %s\n"), s2, s1));
1809 } else if(type == DEATH_TOUCHEXPLODE) {
1810 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1812 print (sprintf(_("^1%s^1 was pushed into an accident by %s\n"), s2, s1));
1813 } else if(type == DEATH_CHEAT) {
1814 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1816 print (sprintf(_("^1%s^1 was unfairly eliminated by %s\n"), s2, s1));
1817 } else if (type == DEATH_FIRE) {
1818 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1820 print (sprintf(_("^1%s^1 was burnt to death by %s\n"), s2, s1));
1821 } else if (type == DEATH_CUSTOM) {
1822 HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM);
1824 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1825 } else if (type == DEATH_HURTTRIGGER) {
1826 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1828 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1830 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1832 print (sprintf(_("^1%s^1 was fragged by %s\n"), s2, s1));
1834 } else if(msg == MSG_SPREE) {
1835 if(type == KILL_END_SPREE) {
1837 print (sprintf(_("^1%s^1's %s scoring spree was ended by %s\n"), s1, s2, s3));
1839 print (sprintf(_("^1%s^1's %s kill spree was ended by %s\n"), s1, s2, s3));
1840 } else if(type == KILL_SPREE) {
1842 print (sprintf(_("^1%s^1 made %s scores in a row\n"), s1, s2));
1844 print (sprintf(_("^1%s^1 has %s frags in a row\n"), s1, s2));
1845 } else if(type == KILL_SPREE_3) {
1847 print (sprintf(_("%s^7 made a ^1TRIPLE SCORE\n"), s1));
1849 print (sprintf(_("%s^7 made a ^1TRIPLE FRAG\n"), s1));
1850 } else if(type == KILL_SPREE_5) {
1852 print (sprintf(_("%s^7 unleashes ^1SCORING RAGE\n"), s1));
1854 print (sprintf(_("%s^7 unleashes ^1RAGE\n"), s1));
1855 } else if(type == KILL_SPREE_10) {
1857 print (sprintf(_("%s^7 made ^1TEN SCORES IN A ROW!\n"), s1));
1859 print (sprintf(_("%s^7 starts the ^1MASSACRE!\n"), s1));
1860 } else if(type == KILL_SPREE_15) {
1862 print (sprintf(_("%s^7 made ^1FIFTEEN SCORES IN A ROW!\n"), s1));
1864 print (sprintf(_("%s^7 executes ^1MAYHEM!\n"), s1));
1865 } else if(type == KILL_SPREE_20) {
1867 print (sprintf(_("%s^7 made ^1TWENTY SCORES IN A ROW!\n"), s1));
1869 print (sprintf(_("%s^7 is a ^1BERSERKER!\n"), s1));
1870 } else if(type == KILL_SPREE_25) {
1872 print (sprintf(_("%s^7 made ^1TWENTY FIVE SCORES IN A ROW!\n"), s1));
1874 print (sprintf(_("%s^7 inflicts ^1CARNAGE!\n"), s1));
1875 } else if(type == KILL_SPREE_30) {
1877 print (sprintf(_("%s^7 made ^1THIRTY SCORES IN A ROW!\n"), s1));
1879 print (sprintf(_("%s^7 unleashes ^1ARMAGEDDON!\n"), s1));
1881 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
1882 if (type == DEATH_DROWN) {
1883 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
1887 print (sprintf(_("^1%s^1 was in the water for too long\n"), s1));
1889 print (sprintf(_("^1%s^1 drowned\n"), s1));
1891 } else if (type == DEATH_SLIME) {
1892 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
1894 print (sprintf(_("^1%s^1 was slimed\n"), s1));
1895 } else if (type == DEATH_LAVA) {
1896 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
1900 print (sprintf(_("^1%s^1 found a hot place\n"), s1));
1902 print (sprintf(_("^1%s^1 turned into hot slag\n"), s1));
1904 } else if (type == DEATH_FALL) {
1905 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1909 print (sprintf(_("^1%s^1 tested gravity (and it worked)\n"), s1));
1911 print (sprintf(_("^1%s^1 hit the ground with a crunch\n"), s1));
1913 } else if (type == DEATH_SHOOTING_STAR) {
1914 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
1916 print (sprintf(_("^1%s^1 became a shooting star\n"), s1));
1917 } else if (type == DEATH_SWAMP) {
1918 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1922 print (sprintf(_("^1%s^1 discovered a swamp\n"), s1));
1924 print (sprintf(_("^1%s^1 is now conserved for centuries to come\n"), s1));
1926 } else if(DEATH_ISTURRET(type)) {
1927 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1931 print (sprintf(_("^1%s^1 ran into a turret\n"), s1));
1936 case DEATH_TURRET_EWHEEL:
1937 print (sprintf(_("^1%s^1 was laserd down by a eWheel turret \n"), s1));
1939 case DEATH_TURRET_FLAC:
1940 print (sprintf(_("^1%s^1 got caught in the flac \n"), s1));
1942 case DEATH_TURRET_MACHINEGUN:
1943 print (sprintf(_("^1%s^1 was riddeld full of riddled by a machinegun turret \n"), s1));
1945 case DEATH_TURRET_WALKER_GUN:
1946 print (sprintf(_("^1%s^1 got served a led enrichment by a walker turret \n"), s1));
1948 case DEATH_TURRET_WALKER_MEELE:
1949 print (sprintf(_("^1%s^1 was impaled by a walker turret \n"), s1));
1951 case DEATH_TURRET_WALKER_ROCKET:
1952 print (sprintf(_("^1%s^1 was rocketed to hell by a walker turret \n"), s1));
1954 case DEATH_TURRET_HELLION:
1955 print (sprintf(_("^1%s^1 was blasted away hellion turret \n"), s1));
1957 case DEATH_TURRET_HK:
1958 print (sprintf(_("^1%s^1 could not hide from the hunter turret \n"), s1));
1960 case DEATH_TURRET_MLRS:
1961 print (sprintf(_("^1%s^1 got turned into smoldering gibs by a mlrs turret \n"), s1));
1963 case DEATH_TURRET_PLASMA:
1964 print (sprintf(_("^1%s^1 got served some superheated plasma from a plasma turret \n"), s1));
1966 case DEATH_TURRET_PHASER:
1967 print (sprintf(_("^1%s^1 was phased out \n"), s1));
1969 case DEATH_TURRET_TESLA:
1970 print (sprintf(_("^1%s^1 was electrocuted by a tesla turret \n"), s1));
1975 } else if (type == DEATH_CUSTOM) {
1976 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
1978 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1979 } else if (type == DEATH_HURTTRIGGER) {
1980 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
1982 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1983 } else if(type == DEATH_TOUCHEXPLODE) {
1984 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1986 print (sprintf(_("^1%s^1 died in an accident\n"), s1));
1987 } else if(type == DEATH_CHEAT) {
1988 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1990 print (sprintf(_("^1%s^1 was unfairly eliminated\n"), s1));
1991 } else if(type == DEATH_FIRE) {
1992 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1996 print (sprintf(_("^1%s^1 felt a little hot\n"), s1));
1998 print (sprintf(_("^1%s^1 burnt to death\n"), s1));
2001 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2005 print (sprintf(_("^1%s^1 needs a restart\n"), s1));
2007 print (sprintf(_("^1%s^1 died\n"), s1));
2010 } else if(msg == MSG_KILL_ACTION_SPREE) {
2012 print (sprintf(_("^1%s^1 needs a restart after a %d scoring spree\n"), s1, stof(s2)));
2014 print (sprintf(_("^1%s^1 died with a %d kill spree\n"), s1, stof(s2)));
2015 } else if(msg == MSG_INFO) {
2016 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2017 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2018 print(sprintf(_("%s^7 got the %s\n"), s1, s2));
2019 } else if(type == INFO_LOSTFLAG) {
2020 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2021 print(sprintf(_("%s^7 lost the %s\n"), s1, s2));
2022 } else if(type == INFO_PICKUPFLAG) {
2023 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2024 print(sprintf(_("%s^7 picked up the %s\n"), s1, s2));
2025 } else if(type == INFO_RETURNFLAG) {
2026 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2027 print(sprintf(_("%s^7 returned the %s\n"), s1, s2));
2028 } else if(type == INFO_CAPTUREFLAG) {
2029 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
2030 print(sprintf(_("%s^7 captured the %s%s\n"), s1, s2, s3));
2032 } else if(msg == MSG_RACE) {
2033 if(type == RACE_SERVER_RECORD) {
2034 HUD_KillNotify_Push(s1, s2, 1, RACE_SERVER_RECORD);
2036 else if(type == RACE_NEW_RANK) {
2037 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_RANK);
2039 else if(type == RACE_NEW_TIME) {
2040 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_TIME);
2042 else if(type == RACE_FAIL) {
2043 HUD_KillNotify_Push(s1, s2, 1, RACE_FAIL);
2045 } else if(msg == MSG_KA) {
2046 if(type == KA_PICKUPBALL) {
2047 HUD_KillNotify_Push(s1, s2, 0, KA_PICKUPBALL);
2049 print (sprintf(_("%s^7 has picked up the ball!\n"), s1));
2051 else if(type == KA_DROPBALL) {
2052 HUD_KillNotify_Push(s1, s2, 0, KA_DROPBALL);
2054 print(sprintf(_("%s^7 has dropped the ball!\n"), s1));
2059 void HUD_KillCenterprint(string s1, string s2, float type, float msg)
2062 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2063 if(msg == MSG_SUICIDE) {
2064 if (type == DEATH_TEAMCHANGE) {
2065 centerprint_hud(sprintf(_("You are now on: %s"), s1));
2066 } else if (type == DEATH_AUTOTEAMCHANGE) {
2067 centerprint_hud(sprintf(_("You have been moved into a different team to improve team balance\nYou are now on: %s"), s1));
2068 } else if (type == DEATH_CAMP) {
2070 centerprint_hud(_("^1Reconsider your tactics, camper!"));
2072 centerprint_hud(_("^1Die camper!"));
2073 } else if (type == DEATH_NOAMMO) {
2075 centerprint_hud(_("^1You are reinserted into the game for running out of ammo..."));
2077 centerprint_hud(_("^1You were killed for running out of ammo..."));
2078 } else if (type == DEATH_ROT) {
2080 centerprint_hud(_("^1You need to preserve your health"));
2082 centerprint_hud(_("^1You grew too old without taking your medicine"));
2083 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2085 centerprint_hud(_("^1Don't go against team mates!"));
2087 centerprint_hud(_("^1Don't shoot your team mates!"));
2088 } else { // generic message
2090 centerprint_hud(_("^1You need to be more careful!"));
2092 centerprint_hud(_("^1You killed your own dumb self!"));
2094 } else if(msg == MSG_KILL) {
2095 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2097 centerprint_hud(sprintf(_("^1Moron! You went against ^7%s^1, a team mate!"), s1));
2099 centerprint_hud(sprintf(_("^1Moron! You fragged ^7%s^1, a team mate!"), s1));
2101 } else if (type == KILL_FIRST_BLOOD) {
2103 centerprint_hud(_("^1First score"));
2105 centerprint_hud(_("^1First blood"));
2107 } else if (type == KILL_FIRST_VICTIM) {
2109 centerprint_hud(_("^1First casualty"));
2111 centerprint_hud(_("^1First victim"));
2113 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2115 centerprint_hud(strcat(sprintf(_("^1You scored against ^7%s^1 who was typing!"), s1), s2));
2117 centerprint_hud(strcat(sprintf(_("^1You typefragged ^7%s"), s1), s2));
2119 } else if (type == KILL_TYPEFRAGGED) {
2121 centerprint_hud(strcat(sprintf(_("^1You were scored against by ^7%s^1 while you were typing!"), s1), s2));
2123 centerprint_hud(strcat(sprintf(_("^1You were typefragged by ^7%s"), s1), s2));
2125 } else if (type == KILL_FRAG) {
2127 centerprint_hud(strcat(sprintf(_("^4You scored against ^7%s"), s1), s2));
2129 centerprint_hud(strcat(sprintf(_("^4You fragged ^7%s"), s1), s2));
2131 } else { // generic message
2133 centerprint_hud(strcat(sprintf(_("^1You were scored against by ^7%s"), s1), s2));
2135 centerprint_hud(strcat(sprintf(_("^1You were fragged by ^7%s"), s1), s2));
2138 } else if(msg == MSG_KILL_ACTION) {
2139 // TODO: invent more centerprints here?
2140 centerprint_hud(_("^1Watch your step!"));
2144 void HUD_Notify(void)
2146 if(!autocvar__hud_configure)
2148 if(!autocvar_hud_panel_notify) return;
2151 hud_configure_active_panel = HUD_PANEL_NOTIFY;
2153 HUD_Panel_UpdateCvars(notify);
2154 HUD_Panel_ApplyFadeAlpha();
2157 mySize = panel_size;
2159 HUD_Panel_DrawBg(1);
2160 if(panel_bg_padding)
2162 pos += '1 1 0' * panel_bg_padding;
2163 mySize -= '2 2 0' * panel_bg_padding;
2166 float entries, height;
2167 entries = bound(1, floor(KN_MAX_ENTRIES * mySize_y/mySize_x), KN_MAX_ENTRIES);
2168 height = mySize_y/entries;
2171 float fontheight = height * autocvar_hud_panel_notify_fontsize;
2172 fontsize = '0.5 0.5 0' * fontheight;
2176 when = autocvar_hud_panel_notify_time;
2178 fadetime = autocvar_hud_panel_notify_fadetime;
2180 vector pos_attacker, pos_victim, pos_icon;
2181 float width_attacker;
2182 string attacker, victim, icon;
2184 float i, j, w, type, step, limit;
2185 if(autocvar_hud_panel_notify_flip) //order items from the top down
2191 else //order items from the bottom up
2198 for(j = kn_index; i != limit; i += step, ++j)
2200 if(autocvar__hud_configure)
2204 else // inverse order
2205 a = entries - 1 - i;
2206 attacker = textShortenToWidth(sprintf(_("Player %d"), a+1), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2207 victim = textShortenToWidth(sprintf(_("Player %d"), a+2), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2208 icon = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname);
2209 a = bound(0, (when - a) / 4, 1);
2210 goto hud_config_notifyprint;
2214 if (j == KN_MAX_ENTRIES)
2217 if(killnotify_times[j] + when > time)
2221 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2232 attacker = killnotify_attackers[j];
2233 victim = killnotify_victims[j];
2234 icon = killnotify_icon[j];
2237 //type = killnotify_deathtype[j];
2238 //w = DEATH_WEAPONOF(type);
2242 if((attacker != "") && (victim == ""))
2245 attacker = textShortenToWidth(attacker, 0.73 * mySize_x - height, fontsize, stringwidth_colors);
2246 pos_attacker = pos + eX * (0.27 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2247 pos_icon = pos + eX * 0.25 * mySize_x - eX * height + eY * i * height;
2249 drawpic_aspect_skin(pos_icon, icon, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2250 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2252 else if((attacker != "") && (victim != ""))
2254 // X [did action to] Y
2255 attacker = textShortenToWidth(attacker, 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2256 victim = textShortenToWidth(victim, 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2257 :hud_config_notifyprint
2258 width_attacker = stringwidth(attacker, TRUE, fontsize);
2259 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2260 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2261 pos_icon = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2263 drawpic_aspect_skin(pos_icon, icon, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2264 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2265 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2274 string seconds_tostring(float sec)
2277 minutes = floor(sec / 60);
2279 sec -= minutes * 60;
2280 return sprintf("%d:%02d", minutes, sec);
2283 void HUD_Timer(void)
2285 if(!autocvar__hud_configure)
2287 if(!autocvar_hud_panel_timer) return;
2290 hud_configure_active_panel = HUD_PANEL_TIMER;
2292 HUD_Panel_UpdateCvars(timer);
2293 HUD_Panel_ApplyFadeAlpha();
2295 draw_beginBoldFont();
2299 mySize = panel_size;
2301 HUD_Panel_DrawBg(1);
2302 if(panel_bg_padding)
2304 pos += '1 1 0' * panel_bg_padding;
2305 mySize -= '2 2 0' * panel_bg_padding;
2309 float timelimit, elapsedTime, timeleft, minutesLeft;
2311 timelimit = getstatf(STAT_TIMELIMIT);
2313 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
2314 timeleft = ceil(timeleft);
2316 minutesLeft = floor(timeleft / 60);
2319 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
2320 timer_color = '1 1 1'; //white
2321 else if(minutesLeft >= 1)
2322 timer_color = '1 1 0'; //yellow
2324 timer_color = '1 0 0'; //red
2326 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
2327 if (time < getstatf(STAT_GAMESTARTTIME)) {
2328 //while restart is still active, show 00:00
2329 timer = seconds_tostring(0);
2331 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
2332 timer = seconds_tostring(elapsedTime);
2335 timer = seconds_tostring(timeleft);
2338 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2345 void HUD_Radar(void)
2347 if (!autocvar__hud_configure)
2349 if (hud_panel_radar_maximized)
2351 if (!hud_draw_maximized) return;
2355 if (autocvar_hud_panel_radar == 0) return;
2356 if (autocvar_hud_panel_radar != 2 && !teamplay) return;
2360 hud_configure_active_panel = HUD_PANEL_RADAR;
2362 HUD_Panel_UpdateCvars(radar);
2363 HUD_Panel_ApplyFadeAlpha();
2365 if (hud_panel_radar_maximized && !autocvar__hud_configure)
2367 panel_size = autocvar_hud_panel_radar_maximized_size;
2368 panel_size_x = bound(0.2, panel_size_x, 1) * vid_conwidth;
2369 panel_size_y = bound(0.2, panel_size_y, 1) * vid_conheight;
2370 panel_pos_x = (vid_conwidth - panel_size_x) / 2;
2371 panel_pos_y = (vid_conheight - panel_size_y) / 2;
2373 panel_bg = strcat(hud_skin_path, "/border_default"); // always use the default border when maximized
2374 if(precache_pic(panel_bg) == "") { panel_bg = "gfx/hud/default/border_default"; } // fallback
2379 mySize = panel_size;
2381 HUD_Panel_DrawBg(1);
2382 if(panel_bg_padding)
2384 pos += '1 1 0' * panel_bg_padding;
2385 mySize -= '2 2 0' * panel_bg_padding;
2390 float scale2d, normalsize, bigsize;
2393 teamradar_origin2d = pos + 0.5 * mySize;
2394 teamradar_size2d = mySize;
2396 if(minimapname == "")
2399 teamradar_loadcvars();
2401 switch(hud_panel_radar_zoommode)
2405 f = current_zoomfraction;
2408 f = 1 - current_zoomfraction;
2418 switch(hud_panel_radar_rotation)
2421 teamradar_angle = view_angles_y - 90;
2424 teamradar_angle = 90 * hud_panel_radar_rotation;
2428 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
2429 teamradar_size2d = mySize;
2431 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
2433 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
2434 if(hud_panel_radar_rotation == 0)
2436 // max-min distance must fit the radar in any rotation
2437 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_scale));
2441 vector c0, c1, c2, c3, span;
2442 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
2443 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
2444 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
2445 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
2447 span_x = max(c0_x, c1_x, c2_x, c3_x) - min(c0_x, c1_x, c2_x, c3_x);
2448 span_y = max(c0_y, c1_y, c2_y, c3_y) - min(c0_y, c1_y, c2_y, c3_y);
2450 // max-min distance must fit the radar in x=x, y=y
2452 teamradar_size2d_x * scale2d / (1.05 * span_x),
2453 teamradar_size2d_y * scale2d / (1.05 * span_y)
2457 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
2458 if(bigsize > normalsize)
2459 normalsize = bigsize;
2463 + (1 - f) * normalsize;
2464 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
2466 + (1 - f) * view_origin);
2475 draw_teamradar_background(hud_panel_radar_foreground_alpha);
2477 for(tm = world; (tm = find(tm, classname, "radarlink")); )
2478 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
2479 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
2480 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
2481 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
2483 color2 = GetPlayerColor(tm.sv_entnum);
2484 //if(color == FL_SPECTATOR || color == color2)
2485 draw_teamradar_player(tm.origin, tm.angles, Team_ColorRGB(color2));
2487 draw_teamradar_player(view_origin, view_angles, '1 1 1');
2489 drawresetcliparea();
2494 void HUD_UpdatePlayerTeams();
2495 void HUD_Score_Rankings(vector pos, vector mySize, entity me, float team_count)
2498 entity tm = world, pl;
2499 #define SCOREPANEL_MAX_ENTRIES 6
2500 #define SCOREPANEL_ASPECTRATIO 2
2501 float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
2502 vector fontsize = '1 1 0' * (mySize_y/entries);
2504 vector rgb, score_color;
2506 score_color = '1 1 1';
2508 float name_size = mySize_x*0.75;
2509 float spacing_size = mySize_x*0.04;
2510 const float highlight_alpha = 0.2;
2511 float i = 0, me_printed = 0, first_pl = 0;
2513 if (autocvar__hud_configure)
2515 float players_per_team = 0;
2518 // show team scores in the first line
2519 float score_size = mySize_x / team_count;
2520 players_per_team = max(2, ceil((entries - 1) / team_count));
2521 for(i=0; i<team_count; ++i) {
2522 if (i == floor((entries - 2) / players_per_team) || (entries == 1 && i == 0))
2523 HUD_Panel_DrawHighlight(pos + eX * score_size * i, eX * score_size + eY * fontsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2524 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);
2527 pos_y += fontsize_y;
2529 score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
2530 for (i=first_pl; i<entries; ++i)
2532 //simulate my score is lower than all displayed players,
2533 //so that I don't appear at all showing pure rankings.
2534 //This is to better show the difference between the 2 ranking views
2535 if (i == entries-1 && autocvar_hud_panel_score_rankings == 1)
2538 drawfill(pos, eX * mySize_x + eY * fontsize_y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2539 s = GetPlayerName(player_localnum);
2544 s = sprintf(_("Player %d"), i + 1 - first_pl);
2549 score_color = Team_ColorRGB(ColorByTeam(floor((i - first_pl) / players_per_team))) * 0.8;
2550 s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
2551 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2552 drawstring(pos + eX * (name_size + spacing_size), ftos(score), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2553 pos_y += fontsize_y;
2558 if (!scoreboard_fade_alpha) // the scoreboard too calls HUD_UpdatePlayerTeams
2559 HUD_UpdatePlayerTeams();
2562 // show team scores in the first line
2563 float score_size = mySize_x / team_count;
2564 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2565 if(tm.team == FL_SPECTATOR)
2567 if (tm.team == myteam)
2568 drawfill(pos + eX * score_size * i, eX * score_size + eY * fontsize_y, '1 1 1', highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2569 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);
2573 pos_y += fontsize_y;
2574 tm = teams.sort_next;
2579 for (pl = players.sort_next; pl && i<entries; pl = pl.sort_next)
2581 if ((team_count && pl.team != tm.team) || pl.team == FL_SPECTATOR)
2584 if (i == entries-1 && !me_printed && pl != me)
2585 if (autocvar_hud_panel_score_rankings == 1 && spectatee_status != -1)
2587 for (pl = me.sort_next; pl; pl = pl.sort_next)
2588 if (pl.team != FL_SPECTATOR)
2592 rgb = '1 1 0'; //not last but not among the leading players: yellow
2594 rgb = '1 0 0'; //last: red
2601 rgb = '0 1 0'; //first: green
2603 drawfill(pos, eX * mySize_x + eY * fontsize_y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2606 score_color = Team_ColorRGB(pl.team) * 0.8;
2607 s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
2608 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2609 drawstring(pos + eX * (name_size + spacing_size), ftos(pl.(scores[ps_primary])), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2610 pos_y += fontsize_y;
2613 while (i<entries && team_count && (tm = tm.sort_next) && (tm.team != FL_SPECTATOR || (tm = tm.sort_next)));
2616 void HUD_Score(void)
2618 if(!autocvar__hud_configure)
2620 if(!autocvar_hud_panel_score) return;
2621 if(spectatee_status == -1 && (gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) return;
2624 hud_configure_active_panel = HUD_PANEL_SCORE;
2626 HUD_Panel_UpdateCvars(score);
2627 HUD_Panel_ApplyFadeAlpha();
2630 mySize = panel_size;
2632 HUD_Panel_DrawBg(1);
2633 if(panel_bg_padding)
2635 pos += '1 1 0' * panel_bg_padding;
2636 mySize -= '2 2 0' * panel_bg_padding;
2639 float score, distribution = 0;
2641 vector distribution_color;
2644 #ifdef COMPAT_XON050_ENGINE
2645 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
2647 me = playerslots[player_localentnum - 1];
2650 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
2651 string timer, distrtimer;
2653 pl = players.sort_next;
2656 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
2657 if(pl.scores[ps_primary] == 0)
2660 score = me.(scores[ps_primary]);
2661 timer = TIME_ENCODED_TOSTRING(score);
2663 draw_beginBoldFont();
2664 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
2665 // distribution display
2666 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2668 distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS);
2670 if (distribution <= 0) {
2671 distribution_color = '0 1 0';
2675 distribution_color = '1 0 0';
2678 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);
2680 // race record display
2681 if (distribution <= 0)
2682 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2683 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2685 } else if (!teamplay) { // non-teamgames
2686 if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings)
2688 HUD_Score_Rankings(pos, mySize, me, 0);
2691 // me vector := [team/connected frags id]
2692 pl = players.sort_next;
2696 if(autocvar__hud_configure)
2699 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2703 score = me.(scores[ps_primary]);
2704 if(autocvar__hud_configure)
2707 if(distribution >= 5)
2708 distribution_color = eY;
2709 else if(distribution >= 0)
2710 distribution_color = '1 1 1';
2711 else if(distribution >= -5)
2712 distribution_color = '1 1 0';
2714 distribution_color = eX;
2716 string distribution_str;
2717 distribution_str = ftos(distribution);
2718 draw_beginBoldFont();
2719 if (distribution >= 0)
2721 if (distribution > 0)
2722 distribution_str = strcat("+", distribution_str);
2723 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2725 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2726 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);
2728 } else { // teamgames
2729 float scores_count = 0, row, column, rows = 0, columns = 0;
2730 local noref vector offset = '0 0 0';
2731 vector score_pos, score_size; //for scores other than myteam
2732 if (spectatee_status == -1 || autocvar_hud_panel_score_rankings)
2734 for(tm = teams.sort_next; tm, tm.team != FL_SPECTATOR; tm = tm.sort_next)
2736 if (autocvar_hud_panel_score_rankings)
2738 HUD_Score_Rankings(pos, mySize, me, scores_count);
2741 rows = mySize_y/mySize_x;
2742 rows = bound(1, floor((sqrt(4 * (3/1) * rows * scores_count + rows * rows) + rows + 0.5) / 2), scores_count);
2743 // ^^^ ammo item aspect goes here
2745 columns = ceil(scores_count/rows);
2747 score_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
2750 if(score_size_x/score_size_y > 3)
2752 newSize = 3 * score_size_y;
2753 offset_x = score_size_x - newSize;
2754 pos_x += offset_x/2;
2755 score_size_x = newSize;
2759 newSize = 1/3 * score_size_x;
2760 offset_y = score_size_y - newSize;
2761 pos_y += offset_y/2;
2762 score_size_y = newSize;
2766 score_size = eX * mySize_x*(1/4) + eY * mySize_y*(1/3);
2768 float max_fragcount;
2769 max_fragcount = -99;
2770 draw_beginBoldFont();
2772 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2773 if(tm.team == FL_SPECTATOR)
2775 score = tm.(teamscores[ts_primary]);
2776 if(autocvar__hud_configure)
2779 if (score > max_fragcount)
2780 max_fragcount = score;
2782 if (spectatee_status == -1)
2784 score_pos = pos + eX * column * (score_size_x + offset_x) + eY * row * (score_size_y + offset_y);
2785 if (max_fragcount == score)
2786 HUD_Panel_DrawHighlight(score_pos, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2787 drawstring_aspect(score_pos, ftos(score), score_size, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2795 else if(tm.team == myteam) {
2796 if (max_fragcount == score)
2797 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2798 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2800 if (max_fragcount == score)
2801 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);
2802 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);
2812 void HUD_RaceTimer (void)
2814 if(!autocvar__hud_configure)
2816 if(!autocvar_hud_panel_racetimer) return;
2817 if(!(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) return;
2818 if(spectatee_status == -1) return;
2821 hud_configure_active_panel = HUD_PANEL_RACETIMER;
2823 HUD_Panel_UpdateCvars(racetimer);
2824 HUD_Panel_ApplyFadeAlpha();
2826 draw_beginBoldFont();
2830 mySize = panel_size;
2832 HUD_Panel_DrawBg(1);
2833 if(panel_bg_padding)
2835 pos += '1 1 0' * panel_bg_padding;
2836 mySize -= '2 2 0' * panel_bg_padding;
2839 // always force 4:1 aspect
2840 vector newSize = '0 0 0';
2841 if(mySize_x/mySize_y > 4)
2843 newSize_x = 4 * mySize_y;
2844 newSize_y = mySize_y;
2846 pos_x = pos_x + (mySize_x - newSize_x) / 2;
2850 newSize_y = 1/4 * mySize_x;
2851 newSize_x = mySize_x;
2853 pos_y = pos_y + (mySize_y - newSize_y) / 2;
2858 string s, forcetime;
2860 if(autocvar__hud_configure)
2863 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);
2864 s = _("^1Intermediate 1 (+15.42)");
2865 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);
2866 s = sprintf(_("^1PENALTY: %.1f (%s)"), 2, "missing a checkpoint");
2867 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);
2869 else if(race_checkpointtime)
2871 a = bound(0, 2 - (time - race_checkpointtime), 1);
2874 if(a > 0) // just hit a checkpoint?
2876 if(race_checkpoint != 254)
2878 if(race_time && race_previousbesttime)
2879 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
2881 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
2883 forcetime = TIME_ENCODED_TOSTRING(race_time);
2888 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
2890 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
2891 if(a > 0) // next one?
2893 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
2898 if(s != "" && a > 0)
2900 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);
2903 if(race_penaltytime)
2905 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
2908 s = sprintf(_("^1PENALTY: %.1f (%s)"), race_penaltytime * 0.1, race_penaltyreason);
2909 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);
2915 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
2916 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);
2921 if(race_laptime && race_checkpoint != 255)
2923 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
2924 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);
2929 if(race_mycheckpointtime)
2931 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
2932 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
2933 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2935 if(race_othercheckpointtime && race_othercheckpointenemy != "")
2937 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
2938 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
2939 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);
2942 if(race_penaltytime && !race_penaltyaccumulator)
2944 t = race_penaltytime * 0.1 + race_penaltyeventtime;
2945 a = bound(0, (1 + t - time), 1);
2949 s = sprintf(_("^1PENALTY: %.1f (%s)"), (t - time) * 0.1, race_penaltyreason);
2951 s = sprintf(_("^2PENALTY: %.1f (%s)"), 0, race_penaltyreason);
2952 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);
2962 float vote_yescount;
2965 float vote_highlighted; // currently selected vote
2967 float vote_active; // is there an active vote?
2968 float vote_prev; // previous state of vote_active to check for a change
2970 float vote_change; // "time" when vote_active changed
2972 void HUD_VoteWindow(void)
2974 if(autocvar_cl_allow_uid2name == -1 && (gametype == MAPINFO_TYPE_CTS || gametype == MAPINFO_TYPE_RACE || (serverflags & SERVERFLAG_PLAYERSTATS)))
2977 if (autocvar__hud_configure)
2981 print(_("^1You must answer before entering hud configure mode\n"));
2982 cvar_set("_hud_configure", "0");
2984 if(vote_called_vote)
2985 strunzone(vote_called_vote);
2986 vote_called_vote = strzone(_("^2Name ^7instead of \"^1Anonymous player^7\" in stats"));
2987 uid2name_dialog = 1;
2990 if(!autocvar__hud_configure)
2992 if(!autocvar_hud_panel_vote) return;
2994 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
2995 panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha;
2997 if(panel_bg_alpha_str == "") {
2998 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
3000 panel_bg_alpha = stof(panel_bg_alpha_str);
3004 hud_configure_active_panel = HUD_PANEL_VOTE;
3013 if(vote_active != vote_prev) {
3015 vote_prev = vote_active;
3018 if(vote_active || autocvar__hud_configure)
3019 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3021 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3026 HUD_Panel_UpdateCvars(vote);
3027 HUD_Panel_ApplyFadeAlpha();
3031 panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight;
3032 panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight;
3035 // these must be below above block
3038 mySize = panel_size;
3040 a = vote_alpha * (vote_highlighted ? autocvar_hud_panel_vote_alreadyvoted_alpha : 1);
3041 HUD_Panel_DrawBg(a);
3042 a = panel_fg_alpha * a;
3044 if(panel_bg_padding)
3046 pos += '1 1 0' * panel_bg_padding;
3047 mySize -= '2 2 0' * panel_bg_padding;
3050 // always force 3:1 aspect
3051 vector newSize = '0 0 0';
3052 if(mySize_x/mySize_y > 3)
3054 newSize_x = 3 * mySize_y;
3055 newSize_y = mySize_y;
3057 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3061 newSize_y = 1/3 * mySize_x;
3062 newSize_x = mySize_x;
3064 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3068 s = _("A vote has been called for:");
3070 s = _("Allow servers to store and display your name?");
3071 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3072 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1/8), stringwidth_colors);
3073 if(autocvar__hud_configure)
3074 s = _("^1Configure the HUD");
3075 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
3077 // print the yes/no counts
3078 s = sprintf(_("Yes (%s): %d"), getcommandkey("vyes", "vyes"), vote_yescount);
3079 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);
3080 s = sprintf(_("No (%s): %d"), getcommandkey("vno", "vno"), vote_nocount);
3081 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);
3083 // draw the progress bar backgrounds
3084 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3086 // draw the highlights
3087 if(vote_highlighted == 1) {
3088 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3089 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3091 else if(vote_highlighted == -1) {
3092 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3093 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3096 // draw the progress bars
3097 if(vote_yescount && vote_needed)
3099 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3100 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3103 if(vote_nocount && vote_needed)
3105 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3106 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3109 drawresetcliparea();
3112 // Mod icons panel (#10)
3115 float mod_active; // is there any active mod icon?
3117 // Clan Arena HUD modicons
3118 void HUD_Mod_CA(vector pos, vector mySize)
3120 mod_active = 1; // CA should never hide the mod icons panel
3121 float redalive, bluealive;
3122 redalive = getstati(STAT_REDALIVE);
3123 bluealive = getstati(STAT_BLUEALIVE);
3125 vector redpos, bluepos;
3126 if(mySize_x > mySize_y)
3129 bluepos = pos + eY * 0.5 * mySize_y;
3130 drawpic_aspect_skin(redpos, "player_red.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3131 drawstring_aspect(redpos + eX * 0.5 * mySize_x, ftos(redalive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3132 drawpic_aspect_skin(bluepos, "player_blue.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3133 drawstring_aspect(bluepos + eX * 0.5 * mySize_x, ftos(bluealive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3138 bluepos = pos + eY * 0.5 * mySize_y;
3139 drawpic_aspect_skin(redpos, "player_red.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3140 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);
3141 drawpic_aspect_skin(bluepos, "player_blue.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3142 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);
3146 // CTF HUD modicon section
3147 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3148 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3149 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3151 void HUD_Mod_CTF_Reset(void)
3153 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3156 void HUD_Mod_CTF(vector pos, vector mySize)
3158 vector redflag_pos, blueflag_pos;
3160 float f; // every function should have that
3162 float redflag, blueflag; // current status
3163 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3166 stat_items = getstati(STAT_ITEMS, 0, 24);
3167 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3168 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3170 if(redflag || blueflag)
3175 if(autocvar__hud_configure)
3181 // when status CHANGES, set old status into prevstatus and current status into status
3182 if (redflag != redflag_prevframe)
3184 redflag_statuschange_time = time;
3185 redflag_prevstatus = redflag_prevframe;
3186 redflag_prevframe = redflag;
3189 if (blueflag != blueflag_prevframe)
3191 blueflag_statuschange_time = time;
3192 blueflag_prevstatus = blueflag_prevframe;
3193 blueflag_prevframe = blueflag;
3196 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3197 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3199 float BLINK_FACTOR = 0.15;
3200 float BLINK_BASE = 0.85;
3202 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3204 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3206 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3208 string red_icon, red_icon_prevstatus;
3209 float red_alpha, red_alpha_prevstatus;
3210 red_alpha = red_alpha_prevstatus = 1;
3212 case 1: red_icon = "flag_red_taken"; break;
3213 case 2: red_icon = "flag_red_lost"; break;
3214 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3216 if((stat_items & IT_CTF_SHIELDED) && (myteam == FL_TEAM_2))
3217 red_icon = "flag_red_shielded";
3219 red_icon = string_null;
3222 switch(redflag_prevstatus) {
3223 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3224 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3225 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3228 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3229 else if((stat_items & IT_CTF_SHIELDED) && (myteam == FL_TEAM_2))
3230 red_icon_prevstatus = "flag_red_shielded";
3232 red_icon_prevstatus = string_null;
3236 string blue_icon, blue_icon_prevstatus;
3237 float blue_alpha, blue_alpha_prevstatus;
3238 blue_alpha = blue_alpha_prevstatus = 1;
3240 case 1: blue_icon = "flag_blue_taken"; break;
3241 case 2: blue_icon = "flag_blue_lost"; break;
3242 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3244 if((stat_items & IT_CTF_SHIELDED) && (myteam == FL_TEAM_1))
3245 blue_icon = "flag_blue_shielded";
3247 blue_icon = string_null;
3250 switch(blueflag_prevstatus) {
3251 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3252 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3253 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3256 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3257 else if((stat_items & IT_CTF_SHIELDED) && (myteam == FL_TEAM_1))
3258 blue_icon_prevstatus = "flag_blue_shielded";
3260 blue_icon_prevstatus = string_null;
3264 if(mySize_x > mySize_y) {
3265 if (myteam == FL_TEAM_1) { // always draw own flag on left
3267 blueflag_pos = pos + eX * 0.5 * mySize_x;
3270 redflag_pos = pos + eX * 0.5 * mySize_x;
3272 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3274 if (myteam == FL_TEAM_1) { // always draw own flag on left
3276 blueflag_pos = pos + eY * 0.5 * mySize_y;
3279 redflag_pos = pos + eY * 0.5 * mySize_y;
3281 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3284 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3285 if(red_icon_prevstatus && f < 1)
3286 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3288 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3290 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3291 if(blue_icon_prevstatus && f < 1)
3292 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3294 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3297 // Keyhunt HUD modicon section
3298 float kh_runheretime;
3300 void HUD_Mod_KH_Reset(void)
3305 void HUD_Mod_KH(vector pos, vector mySize)
3307 mod_active = 1; // keyhunt should never hide the mod icons panel
3311 vector p = '0 0 0', pa, kh_size = '0 0 0', kh_asize = '0 0 0';
3313 kh_keys = getstati(STAT_KH_KEYS);
3316 if(mySize_x > mySize_y)
3318 p_y = pos_y + 0.25 * mySize_y;
3319 pa = p - eY * 0.25 * mySize_y;
3321 kh_size_x = mySize_x * 0.25;
3322 kh_size_y = 0.75 * mySize_y;
3323 kh_asize_x = mySize_x * 0.25;
3324 kh_asize_y = mySize_y * 0.25;
3328 p_y = pos_y + 0.125 * mySize_y;
3329 pa = p - eY * 0.125 * mySize_y;
3331 kh_size_x = mySize_x * 0.5;
3332 kh_size_y = 0.375 * mySize_y;
3333 kh_asize_x = mySize_x * 0.5;
3334 kh_asize_y = mySize_y * 0.125;
3341 for(i = 0; i < 4; ++i)
3343 key = floor(kh_keys / pow(32, i)) & 31;
3345 if(keyteam == 30 && keycount <= 4)
3347 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3351 // this yields 8 exactly if "RUN HERE" shows
3356 kh_runheretime = time;
3357 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3362 for(i = 0; i < 4; ++i)
3364 key = floor(kh_keys / pow(32, i)) & 31;
3377 default: // owned or dropped
3382 a = a * panel_fg_alpha;
3383 aa = aa * panel_fg_alpha;
3389 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% theAlpha key
3392 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% theAlpha key
3395 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% theAlpha key
3398 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% theAlpha key
3403 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3406 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% theAlpha key
3409 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% theAlpha key
3412 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% theAlpha key
3415 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% theAlpha key
3419 if(mySize_x > mySize_y)
3421 p_x += 0.25 * mySize_x;
3422 pa_x += 0.25 * mySize_x;
3428 p_y = pos_y + 0.625 * mySize_y;
3429 pa_y = pos_y + 0.5 * mySize_y;
3435 p_x += 0.5 * mySize_x;
3436 pa_x += 0.5 * mySize_x;
3442 // Keepaway HUD mod icon
3443 float kaball_prevstatus; // last remembered status
3444 float kaball_statuschange_time; // time when the status changed
3446 // we don't need to reset for keepaway since it immediately
3447 // autocorrects prevstatus as to if the player has the ball or not
3449 void HUD_Mod_Keepaway(vector pos, vector mySize)
3451 mod_active = 1; // keepaway should always show the mod HUD
3453 float BLINK_FACTOR = 0.15;
3454 float BLINK_BASE = 0.85;
3455 float BLINK_FREQ = 5;
3456 float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
3458 float stat_items = getstati(STAT_ITEMS, 0, 24);
3459 float kaball = (stat_items/IT_KEY1) & 1;
3461 if(kaball != kaball_prevstatus)
3463 kaball_statuschange_time = time;
3464 kaball_prevstatus = kaball;
3467 vector kaball_pos, kaball_size;
3469 if(mySize_x > mySize_y) {
3470 kaball_pos = pos + eX * 0.25 * mySize_x;
3471 kaball_size = eX * 0.5 * mySize_x + eY * mySize_y;
3473 kaball_pos = pos + eY * 0.25 * mySize_y;
3474 kaball_size = eY * 0.5 * mySize_y + eX * mySize_x;
3477 float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
3478 float f = bound(0, kaball_statuschange_elapsedtime*2, 1);
3480 if(kaball_prevstatus && f < 1)
3481 drawpic_aspect_skin_expanding(kaball_pos, "keepawayball_carrying", kaball_size, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f);
3484 drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
3488 // Nexball HUD mod icon
3489 void HUD_Mod_NexBall(vector pos, vector mySize)
3491 float stat_items, nb_pb_starttime, dt, p;
3493 stat_items = getstati(STAT_ITEMS, 0, 24);
3494 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3496 if (stat_items & IT_KEY1)
3501 //Manage the progress bar if any
3502 if (nb_pb_starttime > 0)
3504 dt = mod(time - nb_pb_starttime, nb_pb_period);
3505 // one period of positive triangle
3506 p = 2 * dt / nb_pb_period;
3511 HUD_Panel_GetProgressBarColor(nexball);
3512 if(mySize_x > mySize_y)
3513 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, 0, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3515 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, 1, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3518 if (stat_items & IT_KEY1)
3519 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3522 // Race/CTS HUD mod icons
3523 float crecordtime_prev; // last remembered crecordtime
3524 float crecordtime_change_time; // time when crecordtime last changed
3525 float srecordtime_prev; // last remembered srecordtime
3526 float srecordtime_change_time; // time when srecordtime last changed
3528 float race_status_time;
3529 float race_status_prev;
3530 string race_status_name_prev;
3531 void HUD_Mod_Race(vector pos, vector mySize)
3533 mod_active = 1; // race should never hide the mod icons panel
3535 me = playerslots[player_localnum];
3537 float f; // yet another function has this
3538 score = me.(scores[ps_primary]);
3540 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3541 return; // no records in the actual race
3543 // clientside personal record
3545 if(gametype == MAPINFO_TYPE_CTS)
3549 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3551 if(score && (score < t || !t)) {
3552 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3553 if(autocvar_cl_autodemo_delete_keeprecords)
3555 f = autocvar_cl_autodemo_delete;
3557 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3561 if(t != crecordtime_prev) {
3562 crecordtime_prev = t;
3563 crecordtime_change_time = time;
3566 vector textPos, medalPos;
3568 if(mySize_x > mySize_y) {
3569 // text on left side
3570 squareSize = min(mySize_y, mySize_x/2);
3571 textPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eY * 0.5 * (mySize_y - squareSize);
3572 medalPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eX * 0.5 * mySize_x + eY * 0.5 * (mySize_y - squareSize);
3575 squareSize = min(mySize_x, mySize_y/2);
3576 textPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eX * 0.5 * (mySize_x - squareSize);
3577 medalPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eY * 0.5 * mySize_y + eX * 0.5 * (mySize_x - squareSize);
3580 f = time - crecordtime_change_time;
3583 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3584 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);
3586 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3587 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);
3588 drawstring_aspect_expanding(pos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
3589 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);
3593 t = race_server_record;
3594 if(t != srecordtime_prev) {
3595 srecordtime_prev = t;
3596 srecordtime_change_time = time;
3598 f = time - srecordtime_change_time;
3601 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3602 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);
3604 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3605 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);
3606 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);
3607 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);
3610 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
3611 race_status_time = time + 5;
3612 race_status_prev = race_status;
3613 if (race_status_name_prev)
3614 strunzone(race_status_name_prev);
3615 race_status_name_prev = strzone(race_status_name);
3620 a = bound(0, race_status_time - time, 1);
3623 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
3627 rank = race_CheckName(race_status_name);
3631 rankname = race_PlaceName(rank);
3634 namepos = medalPos + '0 0.8 0' * squareSize;
3636 rankpos = medalPos + '0 0.15 0' * squareSize;
3638 if(race_status == 0)
3639 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3640 else if(race_status == 1) {
3641 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);
3642 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3643 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3644 } else if(race_status == 2) {
3645 if(race_status_name == GetPlayerName(player_localnum) || !race_myrank || race_myrank < rank)
3646 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);
3648 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);
3649 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3650 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3651 } else if(race_status == 3) {
3652 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);
3653 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3654 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3657 if (race_status_time - time <= 0) {
3658 race_status_prev = -1;
3660 if(race_status_name)
3661 strunzone(race_status_name);
3662 race_status_name = string_null;
3663 if(race_status_name_prev)
3664 strunzone(race_status_name_prev);
3665 race_status_name_prev = string_null;
3669 void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, float layout, float i)
3671 float stat, pps_ratio;
3682 stat = getstatf(STAT_DOM_PPS_RED);
3683 pic = "dom_icon_red";
3687 stat = getstatf(STAT_DOM_PPS_BLUE);
3688 pic = "dom_icon_blue";
3692 stat = getstatf(STAT_DOM_PPS_YELLOW);
3693 pic = "dom_icon_yellow";
3698 stat = getstatf(STAT_DOM_PPS_PINK);
3699 pic = "dom_icon_pink";
3703 pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS);
3705 if(mySize_x/mySize_y > aspect_ratio)
3707 i = aspect_ratio * mySize_y;
3708 myPos_x = myPos_x + (mySize_x - i) / 2;
3713 i = 1/aspect_ratio * mySize_x;
3714 myPos_y = myPos_y + (mySize_y - i) / 2;
3718 if (layout) // show text too
3721 color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
3722 if (layout == 2) // average pps
3723 drawstring_aspect(myPos + eX * mySize_y, ftos_decimals(stat, 2), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
3724 else // percentage of average pps
3725 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);
3729 drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3732 drawsetcliparea(myPos_x, myPos_y + mySize_y * (1 - pps_ratio), mySize_y, mySize_y * pps_ratio);
3733 drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3734 drawresetcliparea();
3738 void HUD_Mod_Dom(vector myPos, vector mySize)
3740 mod_active = 1; // required in each mod function that always shows something
3742 float teams_count = 0;
3743 for(tm = teams.sort_next; tm; tm = tm.sort_next)
3744 if(tm.team != FL_SPECTATOR)
3747 float layout = autocvar_hud_panel_modicons_dom_layout;
3748 float rows, columns, aspect_ratio;
3749 rows = mySize_y/mySize_x;
3750 aspect_ratio = (layout) ? 3 : 1;
3751 rows = bound(1, floor((sqrt((4 * aspect_ratio * teams_count + rows) * rows) + rows + 0.5) / 2), teams_count);
3752 columns = ceil(teams_count/rows);
3755 float row = 0, column = 0;
3756 for(i=0; i<teams_count; ++i)
3758 vector pos, itemSize;
3759 pos = myPos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows);
3760 itemSize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
3762 DrawDomItem(pos, itemSize, aspect_ratio, layout, i);
3773 float mod_prev; // previous state of mod_active to check for a change
3775 float mod_change; // "time" when mod_active changed
3777 void HUD_ModIcons(void)
3779 if(!autocvar__hud_configure)
3781 if(!autocvar_hud_panel_modicons) return;
3782 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;
3785 hud_configure_active_panel = HUD_PANEL_MODICONS;
3787 HUD_Panel_UpdateCvars(modicons);
3788 HUD_Panel_ApplyFadeAlpha();
3790 draw_beginBoldFont();
3794 mySize = panel_size;
3796 if(mod_active != mod_prev) {
3798 mod_prev = mod_active;
3801 if(mod_active || autocvar__hud_configure)
3802 mod_alpha = bound(0, (time - mod_change) * 2, 1);
3804 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
3807 HUD_Panel_DrawBg(mod_alpha);
3809 if(panel_bg_padding)
3811 pos += '1 1 0' * panel_bg_padding;
3812 mySize -= '2 2 0' * panel_bg_padding;
3815 // these MUST be ran in order to update mod_active
3816 if(gametype == MAPINFO_TYPE_KEYHUNT)
3817 HUD_Mod_KH(pos, mySize);
3818 else if(gametype == MAPINFO_TYPE_CTF || autocvar__hud_configure)
3819 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
3820 else if(gametype == MAPINFO_TYPE_NEXBALL)
3821 HUD_Mod_NexBall(pos, mySize);
3822 else if(gametype == MAPINFO_TYPE_CTS || gametype == MAPINFO_TYPE_RACE)
3823 HUD_Mod_Race(pos, mySize);
3824 else if(gametype == MAPINFO_TYPE_CA || gametype == MAPINFO_TYPE_FREEZETAG)
3825 HUD_Mod_CA(pos, mySize);
3826 else if(gametype == MAPINFO_TYPE_DOMINATION)
3827 HUD_Mod_Dom(pos, mySize);
3828 else if(gametype == MAPINFO_TYPE_KEEPAWAY)
3829 HUD_Mod_Keepaway(pos, mySize);
3834 // Draw pressed keys (#11)
3836 void HUD_DrawPressedKeys(void)
3838 if(!autocvar__hud_configure)
3840 if(!autocvar_hud_panel_pressedkeys) return;
3841 if(spectatee_status <= 0 && autocvar_hud_panel_pressedkeys < 2) return;
3844 hud_configure_active_panel = HUD_PANEL_PRESSEDKEYS;
3847 HUD_Panel_UpdateCvars(pressedkeys);
3848 HUD_Panel_ApplyFadeAlpha();
3851 mySize = panel_size;
3853 HUD_Panel_DrawBg(1);
3854 if(panel_bg_padding)
3856 pos += '1 1 0' * panel_bg_padding;
3857 mySize -= '2 2 0' * panel_bg_padding;
3860 // force custom aspect
3861 float aspect = autocvar_hud_panel_pressedkeys_aspect;
3864 vector newSize = '0 0 0';
3865 if(mySize_x/mySize_y > aspect)
3867 newSize_x = aspect * mySize_y;
3868 newSize_y = mySize_y;
3870 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3874 newSize_y = 1/aspect * mySize_x;
3875 newSize_x = mySize_x;
3877 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3883 keysize = eX * mySize_x * (1/3.0) + eY * mySize_y * (1/(3.0 - !autocvar_hud_panel_pressedkeys_attack));
3885 pressedkeys = getstatf(STAT_PRESSED_KEYS);
3887 if(autocvar_hud_panel_pressedkeys_attack)
3889 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);
3890 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);
3894 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3895 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);
3896 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);
3898 drawpic_aspect_skin(pos, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3899 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);
3900 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);
3903 // Handle chat as a panel (#12)
3907 if(!autocvar__hud_configure)
3909 if (!autocvar_hud_panel_chat)
3911 if (!autocvar_con_chatrect)
3912 cvar_set("con_chatrect", "0");
3915 if(autocvar__con_chat_maximized)
3916 if(!hud_draw_maximized) return;
3919 hud_configure_active_panel = HUD_PANEL_CHAT;
3921 HUD_Panel_UpdateCvars(chat);
3922 HUD_Panel_ApplyFadeAlpha();
3924 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
3926 panel_pos_y = panel_bg_border;
3927 panel_size_y = vid_conheight - panel_bg_border * 2;
3928 if(panel_bg == "0") // force a border when maximized
3930 if(precache_pic(panel_bg) == "") {
3931 panel_bg = strcat(hud_skin_path, "/border_default");
3932 if(precache_pic(panel_bg) == "") {
3933 panel_bg = "gfx/hud/default/border_default";
3937 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an theAlpha of at least 0.75
3942 mySize = panel_size;
3944 HUD_Panel_DrawBg(1);
3946 if(panel_bg_padding)
3948 pos += '1 1 0' * panel_bg_padding;
3949 mySize -= '2 2 0' * panel_bg_padding;
3952 if (!autocvar_con_chatrect)
3953 cvar_set("con_chatrect", "1");
3955 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
3956 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
3958 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
3959 cvar_set("con_chat", ftos(floor(mySize_y/autocvar_con_chatsize - 0.5)));
3961 if(autocvar__hud_configure)
3964 chatsize = '1 1 0' * autocvar_con_chatsize;
3965 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over theAlpha and such
3967 for(i = 0; i < autocvar_con_chat; ++i)
3969 if(i == autocvar_con_chat - 1)
3972 a = panel_fg_alpha * floor(((i + 1) * 7 + autocvar_con_chattime)/45);
3973 drawcolorcodedstring(pos, textShortenToWidth(_("^3Player^7: This is the chat area."), mySize_x, chatsize, stringwidth_colors), chatsize, a, DRAWFLAG_NORMAL);
3974 pos_y += chatsize_y;
3979 // Engine info panel (#13)
3986 float frametimeavg1; // 1 frame ago
3987 float frametimeavg2; // 2 frames ago
3988 void HUD_EngineInfo(void)
3990 if(!autocvar__hud_configure)
3992 if(!autocvar_hud_panel_engineinfo) return;
3995 hud_configure_active_panel = HUD_PANEL_ENGINEINFO;
3997 HUD_Panel_UpdateCvars(engineinfo);
3998 HUD_Panel_ApplyFadeAlpha();
4001 mySize = panel_size;
4003 HUD_Panel_DrawBg(1);
4004 if(panel_bg_padding)
4006 pos += '1 1 0' * panel_bg_padding;
4007 mySize -= '2 2 0' * panel_bg_padding;
4010 float currentTime = gettime(GETTIME_REALTIME);
4011 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
4013 float currentframetime = currentTime - prevfps_time;
4014 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4015 frametimeavg2 = frametimeavg1;
4016 frametimeavg1 = frametimeavg;
4019 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4020 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.
4022 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
4023 prevfps = (1/currentframetime);
4024 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"
4026 prevfps_time = currentTime;
4031 if(currentTime - prevfps_time > autocvar_hud_panel_engineinfo_framecounter_time)
4033 prevfps = framecounter/(currentTime - prevfps_time);
4035 prevfps_time = currentTime;
4040 color = HUD_Get_Num_Color (prevfps, 100);
4041 drawstring_aspect(pos, sprintf(_("FPS: %.*f"), autocvar_hud_panel_engineinfo_framecounter_decimals, prevfps), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4044 // Info messages panel (#14)
4046 #define drawInfoMessage(s)\
4047 if(autocvar_hud_panel_infomessages_flip)\
4048 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);\
4049 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
4051 void HUD_InfoMessages(void)
4053 if(!autocvar__hud_configure)
4055 if(!autocvar_hud_panel_infomessages) return;
4058 hud_configure_active_panel = HUD_PANEL_INFOMESSAGES;
4060 HUD_Panel_UpdateCvars(infomessages);
4061 HUD_Panel_ApplyFadeAlpha();
4064 mySize = panel_size;
4066 HUD_Panel_DrawBg(1);
4067 if(panel_bg_padding)
4069 pos += '1 1 0' * panel_bg_padding;
4070 mySize -= '2 2 0' * panel_bg_padding;
4073 // always force 5:1 aspect
4074 vector newSize = '0 0 0';
4075 if(mySize_x/mySize_y > 5)
4077 newSize_x = 5 * mySize_y;
4078 newSize_y = mySize_y;
4080 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4084 newSize_y = 1/5 * mySize_x;
4085 newSize_x = mySize_x;
4087 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4096 fontsize = '0.20 0.20 0' * mySize_y;
4102 if(!autocvar__hud_configure)
4104 if(spectatee_status && !intermission)
4107 if(spectatee_status == -1)
4108 s = _("^1Observing");
4110 #ifdef COMPAT_XON050_ENGINE
4111 s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(spectatee_status - 1));
4113 s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(player_localentnum - 1));
4117 if(spectatee_status == -1)
4118 s = sprintf(_("^1Press ^3%s^1 to spectate"), getcommandkey("primary fire", "+fire"));
4120 s = sprintf(_("^1Press ^3%s^1 for another player"), getcommandkey("primary fire", "+fire"));
4123 if(spectatee_status == -1)
4124 s = sprintf(_("^1Use ^3%s^1 or ^3%s^1 to change the speed"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
4126 s = sprintf(_("^1Press ^3%s^1 to observe"), getcommandkey("secondary fire", "+fire2"));
4129 s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey("server info", "+show_info"));
4132 if(gametype == MAPINFO_TYPE_ARENA)
4133 s = _("^1Wait for your turn to join");
4134 else if(gametype == MAPINFO_TYPE_LMS)
4137 sk = playerslots[player_localnum];
4138 if(sk.(scores[ps_primary]) >= 666)
4139 s = _("^1Match has already begun");
4140 else if(sk.(scores[ps_primary]) > 0)
4141 s = _("^1You have no more lives left");
4143 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
4146 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
4149 //show restart countdown:
4150 if (time < getstatf(STAT_GAMESTARTTIME)) {
4152 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4153 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4154 s = sprintf(_("^1Game starts in ^3%d^1 seconds"), countdown);
4155 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4159 if(warmup_stage && !intermission)
4161 s = _("^2Currently in ^1warmup^2 stage!");
4166 if(mod(time, 1) >= 0.5)
4171 if(ready_waiting && !intermission && !spectatee_status)
4173 if(ready_waiting_for_me)
4176 s = sprintf(_("%sPress ^3%s%s to end warmup"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
4178 s = sprintf(_("%sPress ^3%s%s once you are ready"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
4183 s = _("^2Waiting for others to ready up to end warmup...");
4185 s = _("^2Waiting for others to ready up...");
4189 else if(warmup_stage && !intermission && !spectatee_status)
4191 s = sprintf(_("^2Press ^3%s^2 to end warmup"), getcommandkey("ready", "ready"));
4195 if(teamplay && !intermission && !spectatee_status && gametype != MAPINFO_TYPE_CA && teamnagger)
4197 float ts_min = 0, ts_max = 0;
4198 tm = teams.sort_next;
4201 for(; tm.sort_next; tm = tm.sort_next)
4203 if(!tm.team_size || tm.team == FL_SPECTATOR)
4205 if(!ts_min) ts_min = tm.team_size;
4206 else ts_min = min(ts_min, tm.team_size);
4207 if(!ts_max) ts_max = tm.team_size;
4208 else ts_max = max(ts_max, tm.team_size);
4210 if ((ts_max - ts_min) > 1)
4212 s = strcat(blinkcolor, _("Teamnumbers are unbalanced!"));
4213 tm = GetTeam(myteam, false);
4215 if (tm.team != FL_SPECTATOR)
4216 if (tm.team_size == ts_max)
4217 s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey("team menu", "menu_showteamselect"), blinkcolor));
4225 s = _("^7Press ^3ESC ^7to show HUD options.");
4227 s = _("^3Doubleclick ^7a panel for panel-specific options.");
4229 s = _("^3CTRL ^7to disable collision testing, ^3SHIFT ^7and");
4231 s = _("^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.");
4236 // Physics panel (#15)
4238 vector acc_prevspeed;
4239 float acc_prevtime, acc_avg, top_speed, top_speed_time;
4240 void HUD_Physics(void)
4242 if(!autocvar__hud_configure)
4244 if(!autocvar_hud_panel_physics) return;
4245 if(spectatee_status == -1 && (autocvar_hud_panel_physics == 1 || autocvar_hud_panel_physics == 3)) return;
4246 if(autocvar_hud_panel_physics == 3 && !(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) return;
4249 hud_configure_active_panel = HUD_PANEL_PHYSICS;
4251 HUD_Panel_UpdateCvars(physics);
4252 HUD_Panel_ApplyFadeAlpha();
4254 draw_beginBoldFont();
4256 HUD_Panel_DrawBg(1);
4257 if(panel_bg_padding)
4259 panel_pos += '1 1 0' * panel_bg_padding;
4260 panel_size -= '2 2 0' * panel_bg_padding;
4263 float acceleration_progressbar_scale = 0;
4264 if(autocvar_hud_panel_physics_progressbar && autocvar_hud_panel_physics_acceleration_progressbar_scale > 1)
4265 acceleration_progressbar_scale = autocvar_hud_panel_physics_acceleration_progressbar_scale;
4268 if (autocvar_hud_panel_physics_text_scale <= 0)
4271 text_scale = min(autocvar_hud_panel_physics_text_scale, 1);
4274 float speed, conversion_factor;
4277 switch(autocvar_hud_panel_physics_speed_unit)
4282 conversion_factor = 1.0;
4286 conversion_factor = 0.0254;
4290 conversion_factor = 0.0254 * 3.6;
4294 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4298 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4302 vector vel = (csqcplayer ? csqcplayer.velocity : pmove_vel);
4304 float max_speed = floor( autocvar_hud_panel_physics_speed_max * conversion_factor + 0.5 );
4305 if (autocvar__hud_configure)
4306 speed = floor( max_speed * 0.65 + 0.5 );
4307 else if(autocvar_hud_panel_physics_speed_vertical)
4308 speed = floor( vlen(vel) * conversion_factor + 0.5 );
4310 speed = floor( vlen(vel - vel_z * '0 0 1') * conversion_factor + 0.5 );
4312 //compute acceleration
4313 float acceleration, f;
4314 if (autocvar__hud_configure)
4315 acceleration = autocvar_hud_panel_physics_acceleration_max * 0.3;
4318 // 1 m/s = 0.0254 qu/s; 1 g = 9.80665 m/s^2
4319 f = time - acc_prevtime;
4320 if(autocvar_hud_panel_physics_acceleration_vertical)
4321 acceleration = (vlen(vel) - vlen(acc_prevspeed));
4323 acceleration = (vlen(vel - '0 0 1' * vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z));
4325 acceleration = acceleration * (1 / max(0.0001, f)) * (0.0254 / 9.80665);
4327 acc_prevspeed = vel;
4328 acc_prevtime = time;
4330 f = bound(0, f * 10, 1);
4331 acc_avg = acc_avg * (1 - f) + acceleration * f;
4335 float panel_ar = panel_size_x/panel_size_y;
4336 vector speed_offset = '0 0 0', acceleration_offset = '0 0 0';
4337 if (panel_ar >= 5 && !acceleration_progressbar_scale)
4339 panel_size_x *= 0.5;
4340 if (autocvar_hud_panel_physics_flip)
4341 speed_offset_x = panel_size_x;
4343 acceleration_offset_x = panel_size_x;
4347 panel_size_y *= 0.5;
4348 if (autocvar_hud_panel_physics_flip)
4349 speed_offset_y = panel_size_y;
4351 acceleration_offset_y = panel_size_y;
4353 float speed_baralign, acceleration_baralign;
4354 if (autocvar_hud_panel_physics_baralign == 1)
4355 acceleration_baralign = speed_baralign = 1;
4356 else if(autocvar_hud_panel_physics_baralign == 4)
4357 acceleration_baralign = speed_baralign = 2;
4358 else if (autocvar_hud_panel_physics_flip)
4360 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 2);
4361 speed_baralign = (autocvar_hud_panel_physics_baralign == 3);
4365 speed_baralign = (autocvar_hud_panel_physics_baralign == 2);
4366 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 3);
4368 if (autocvar_hud_panel_physics_acceleration_progressbar_mode == 0)
4369 acceleration_baralign = 3; //override hud_panel_physics_baralign value for acceleration
4373 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
4375 HUD_Panel_GetProgressBarColor(speed);
4376 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);
4378 vector tmp_offset = '0 0 0', tmp_size = '0 0 0';
4379 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
4381 tmp_size_x = panel_size_x * 0.75;
4382 tmp_size_y = panel_size_y * text_scale;
4384 tmp_offset_x = panel_size_x - tmp_size_x;
4387 tmp_offset_y = (panel_size_y - tmp_size_y) / 2;
4388 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4394 tmp_offset_x = tmp_size_x;
4395 if (autocvar_hud_panel_physics_speed_unit_show)
4398 tmp_size_x = panel_size_x * (1 - 0.75);
4399 tmp_size_y = panel_size_y * 0.4 * text_scale;
4400 tmp_offset_y = (panel_size_y * 0.4 - tmp_size_y) / 2;
4401 drawstring_aspect(panel_pos + speed_offset + tmp_offset, unit, tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4405 //compute and draw top speed
4406 if (autocvar_hud_panel_physics_topspeed)
4407 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
4409 if (autocvar__hud_configure)
4411 top_speed = floor( max_speed * 0.75 + 0.5 );
4416 if (speed >= top_speed)
4419 top_speed_time = time;
4423 f = max(1, autocvar_hud_panel_physics_topspeed_time);
4424 // divide by f to make it start from 1
4425 f = cos( ((time - top_speed_time) / f) * PI/2 );
4427 else //hide top speed 0, it would be stupid
4432 //top speed progressbar peak
4433 if(speed < top_speed)
4434 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
4436 float peak_offset_x;
4437 vector peak_size = '0 0 0';
4438 if (speed_baralign == 0)
4439 peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x;
4440 else if (speed_baralign == 1)
4441 peak_offset_x = (1 - min(top_speed, max_speed)/max_speed) * panel_size_x;
4442 else // if (speed_baralign == 2)
4443 peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x * 0.5;
4444 //if speed is not 0 the speed progressbar already fetched the color
4446 HUD_Panel_GetProgressBarColor(speed);
4447 peak_size_x = floor(panel_size_x * 0.01 + 1.5);
4448 peak_size_y = panel_size_y;
4449 if (speed_baralign == 2) // draw two peaks, on both sides
4451 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);
4452 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);
4455 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);
4459 tmp_offset_y = panel_size_y * 0.4;
4460 tmp_size_x = panel_size_x * (1 - 0.75);
4461 tmp_size_y = (panel_size_y - tmp_offset_y) * text_scale;
4462 tmp_offset_y += (panel_size_y - tmp_offset_y - tmp_size_y) / 2;
4463 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(top_speed), tmp_size, '1 0 0', f * panel_fg_alpha, DRAWFLAG_NORMAL);
4471 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 3)
4473 if (acceleration < 0)
4474 HUD_Panel_GetProgressBarColor(acceleration_neg);
4476 HUD_Panel_GetProgressBarColor(acceleration);
4478 f = acceleration/autocvar_hud_panel_physics_acceleration_max;
4479 if (autocvar_hud_panel_physics_acceleration_progressbar_nonlinear)
4482 if (acceleration_progressbar_scale) // allow progressbar to go out of panel bounds
4484 tmp_size = acceleration_progressbar_scale * panel_size_x * eX + panel_size_y * eY;
4486 if (acceleration_baralign == 1)
4487 tmp_offset_x = panel_size_x - tmp_size_x;
4488 else if (acceleration_baralign == 2 || acceleration_baralign == 3)
4489 tmp_offset_x = (panel_size_x - tmp_size_x) / 2;
4496 tmp_size = panel_size;
4497 tmp_offset = '0 0 0';
4500 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);
4502 tmp_size_x = panel_size_x;
4503 tmp_size_y = panel_size_y * text_scale;
4505 tmp_offset_y = (panel_size_y - tmp_size_y) / 2;
4506 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3)
4507 drawstring_aspect(panel_pos + acceleration_offset + tmp_offset, strcat(ftos_decimals(acceleration, 2), "g"), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4512 // CenterPrint (#16)
4514 #define CENTERPRINT_MAX_MSGS 10
4515 #define CENTERPRINT_MAX_ENTRIES 50
4516 #define CENTERPRINT_SPACING 0.7
4518 string centerprint_messages[CENTERPRINT_MAX_MSGS];
4519 float centerprint_msgID[CENTERPRINT_MAX_MSGS];
4520 float centerprint_time[CENTERPRINT_MAX_MSGS];
4521 float centerprint_expire_time[CENTERPRINT_MAX_MSGS];
4522 float centerprint_countdown_num[CENTERPRINT_MAX_MSGS];
4523 float centerprint_showing;
4525 void centerprint_generic(float new_id, string strMessage, float duration, float countdown_num)
4529 if(strMessage == "" && new_id == 0)
4532 // strip trailing newlines
4533 j = strlen(strMessage) - 1;
4534 while(substring(strMessage, j, 1) == "\n" && j >= 0)
4536 if (j < strlen(strMessage) - 1)
4537 strMessage = substring(strMessage, 0, j + 1);
4539 if(strMessage == "" && new_id == 0)
4542 // strip leading newlines
4544 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
4547 strMessage = substring(strMessage, j, strlen(strMessage) - j);
4549 if(strMessage == "" && new_id == 0)
4552 if (!centerprint_showing)
4553 centerprint_showing = TRUE;
4555 for (i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
4557 if (j == CENTERPRINT_MAX_MSGS)
4559 if (new_id && new_id == centerprint_msgID[j])
4561 if (strMessage == "" && centerprint_messages[j] != "" && centerprint_countdown_num[j] == 0)
4563 // fade out the current msg (duration and countdown_num are ignored)
4564 centerprint_time[j] = min(5, autocvar_hud_panel_centerprint_fade_out);
4565 if (centerprint_expire_time[j] > time + min(5, autocvar_hud_panel_centerprint_fade_out) || centerprint_expire_time[j] < time)
4566 centerprint_expire_time[j] = time + min(5, autocvar_hud_panel_centerprint_fade_out);
4569 break; // found a msg with the same id, at position j
4573 if (i == CENTERPRINT_MAX_MSGS)
4575 // a msg with the same id was not found, add the msg at the next position
4577 if (cpm_index == -1)
4578 cpm_index = CENTERPRINT_MAX_MSGS - 1;
4581 if(centerprint_messages[j])
4582 strunzone(centerprint_messages[j]);
4583 centerprint_messages[j] = strzone(strMessage);
4584 centerprint_msgID[j] = new_id;
4586 centerprint_time[j] = -1;
4590 duration = max(1, autocvar_hud_panel_centerprint_time);
4591 centerprint_time[j] = duration;
4592 centerprint_expire_time[j] = time + duration;
4594 centerprint_countdown_num[j] = countdown_num;
4597 void centerprint_hud(string strMessage)
4599 centerprint_generic(0, strMessage, autocvar_hud_panel_centerprint_time, 0);
4602 void reset_centerprint_messages(void)
4605 for (i=0; i<CENTERPRINT_MAX_MSGS; ++i)
4607 centerprint_expire_time[i] = 0;
4608 centerprint_time[i] = 1;
4609 centerprint_msgID[i] = 0;
4610 if(centerprint_messages[i])
4611 strunzone(centerprint_messages[i]);
4612 centerprint_messages[i] = string_null;
4615 float hud_configure_cp_generation_time;
4616 void HUD_CenterPrint (void)
4618 if(!autocvar__hud_configure)
4620 if(!autocvar_hud_panel_centerprint) return;
4622 if (hud_configure_prev && hud_configure_prev != -1)
4623 reset_centerprint_messages();
4627 hud_configure_active_panel = HUD_PANEL_CENTERPRINT;
4629 if (!hud_configure_prev)
4630 reset_centerprint_messages();
4631 if (time > hud_configure_cp_generation_time)
4636 centerprint_generic(floor(r*1000), strcat(sprintf("^3Countdown message at time %s", seconds_tostring(time)), ", seconds left: %d"), 1, 10);
4638 centerprint_generic(0, sprintf("^1Multiline message at time %s that\n^1lasts longer than normal", seconds_tostring(time)), 20, 0);
4640 centerprint_hud(sprintf("Message at time %s", seconds_tostring(time)));
4641 hud_configure_cp_generation_time = time + 1 + random()*4;
4645 HUD_Panel_UpdateCvars(centerprint);
4647 // this panel doesn't fade when showing the scoreboard
4648 if(autocvar__menu_alpha)
4649 HUD_Panel_ApplyFadeAlpha();
4651 if(scoreboard_fade_alpha)
4653 // move the panel below the scoreboard
4654 if (scoreboard_bottom >= 0.96 * vid_conheight)
4658 target_pos = eY * scoreboard_bottom + eX * 0.5 * (vid_conwidth - panel_size_x);
4660 if(target_pos_y > panel_pos_y)
4662 panel_pos = panel_pos + (target_pos - panel_pos) * sqrt(scoreboard_fade_alpha);
4663 panel_size_y = min(panel_size_y, vid_conheight - scoreboard_bottom);
4667 HUD_Panel_DrawBg(1);
4669 if (!centerprint_showing)
4672 if(panel_bg_padding)
4674 panel_pos += '1 1 0' * panel_bg_padding;
4675 panel_size -= '2 2 0' * panel_bg_padding;
4678 float entries, height;
4680 // entries = bound(1, floor(CENTERPRINT_MAX_ENTRIES * 4 * panel_size_y/panel_size_x), CENTERPRINT_MAX_ENTRIES);
4681 // height = panel_size_y/entries;
4682 // fontsize = '1 1 0' * height;
4683 height = vid_conheight/50 * autocvar_hud_panel_centerprint_fontscale;
4684 fontsize = '1 1 0' * height;
4685 entries = bound(1, floor(panel_size_y/height), CENTERPRINT_MAX_ENTRIES);
4688 float a, sz, align, current_msg_pos_y = 0, msg_size;
4692 n = -1; // if no msg will be displayed, n stays -1
4695 if (autocvar_hud_panel_centerprint_flip)
4696 pos_y += panel_size_y;
4697 align = bound(0, autocvar_hud_panel_centerprint_align, 1);
4698 for (i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
4700 if (j == CENTERPRINT_MAX_MSGS)
4702 if (centerprint_expire_time[j] <= time)
4704 if (centerprint_countdown_num[j] && centerprint_time[j] > 0)
4706 centerprint_countdown_num[j] = centerprint_countdown_num[j] - 1;
4707 if (centerprint_countdown_num[j] == 0)
4709 centerprint_expire_time[j] = centerprint_expire_time[j] + centerprint_time[j];
4715 // fade the centerprint_hud in/out
4716 if (centerprint_time[j] < 0 || centerprint_expire_time[j] - autocvar_hud_panel_centerprint_fade_out > time)
4717 a = bound(0, (time - (centerprint_expire_time[j] - centerprint_time[j])) / max(0.0001, autocvar_hud_panel_centerprint_fade_in), 1);
4718 else if (centerprint_expire_time[j] > time)
4719 a = (centerprint_expire_time[j] - time) / max(0.0001, autocvar_hud_panel_centerprint_fade_out);
4723 // set the size from fading in/out before subsequent fading
4724 sz = autocvar_hud_panel_centerprint_fade_minfontsize + a * (1 - autocvar_hud_panel_centerprint_fade_minfontsize);
4726 // also fade it based on positioning
4727 if(autocvar_hud_panel_centerprint_fade_subsequent)
4729 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
4730 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
4733 // finally set the size based on the new theAlpha from subsequent fading
4734 sz = sz * (autocvar_hud_panel_centerprint_fade_subsequent_minfontsize + a * (1 - autocvar_hud_panel_centerprint_fade_subsequent_minfontsize));
4735 drawfontscale = sz * '1 1 0';
4737 if (centerprint_countdown_num[j])
4738 n = tokenizebyseparator(sprintf(centerprint_messages[j], centerprint_countdown_num[j]), "\n");
4740 n = tokenizebyseparator(centerprint_messages[j], "\n");
4742 if (autocvar_hud_panel_centerprint_flip)
4744 // check if the message can be entirely shown
4745 for(k = 0; k < n; ++k)
4747 getWrappedLine_remaining = argv(k);
4748 while(getWrappedLine_remaining)
4750 ts = getWrappedLine(panel_size_x * sz, fontsize, stringwidth_colors);
4752 pos_y -= fontsize_y;
4754 pos_y -= fontsize_y * CENTERPRINT_SPACING/2;
4757 current_msg_pos_y = pos_y; // save starting pos (first line) of the current message
4761 for(k = 0; k < n; ++k)
4763 getWrappedLine_remaining = argv(k);
4764 while(getWrappedLine_remaining)
4766 ts = getWrappedLine(panel_size_x * sz, fontsize, stringwidth_colors);
4770 pos_x = panel_pos_x + (panel_size_x - stringwidth(ts, TRUE, fontsize)) * align;
4771 drawcolorcodedstring(pos + eY * 0.5 * (1 - sz) * fontsize_y, ts, fontsize, a * panel_fg_alpha, DRAWFLAG_NORMAL);
4772 pos_y += fontsize_y;
4775 pos_y += fontsize_y * CENTERPRINT_SPACING/2;
4778 msg_size = pos_y - msg_size;
4779 if (autocvar_hud_panel_centerprint_flip)
4781 pos_y = current_msg_pos_y - CENTERPRINT_SPACING * fontsize_y;
4782 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
4783 pos_y += (msg_size + CENTERPRINT_SPACING * fontsize_y) * (1 - sqrt(sz));
4785 if (pos_y < panel_pos_y) // check if the next message can be shown
4787 drawfontscale = '1 1 0';
4793 pos_y += CENTERPRINT_SPACING * fontsize_y;
4794 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
4795 pos_y -= (msg_size + CENTERPRINT_SPACING * fontsize_y) * (1 - sqrt(sz));
4797 if(pos_y > panel_pos_y + panel_size_y - fontsize_y) // check if the next message can be shown
4799 drawfontscale = '1 1 0';
4804 drawfontscale = '1 1 0';
4807 centerprint_showing = FALSE;
4808 reset_centerprint_messages();
4818 void HUD_Reset (void)
4820 // reset gametype specific icons
4821 if(gametype == MAPINFO_TYPE_KEYHUNT)
4823 else if(gametype == MAPINFO_TYPE_CTF)
4824 HUD_Mod_CTF_Reset();
4827 #define HUD_DrawPanel(id)\
4829 case (HUD_PANEL_RADAR):\
4830 HUD_Radar(); break;\
4831 case (HUD_PANEL_WEAPONS):\
4832 HUD_Weapons(); break;\
4833 case (HUD_PANEL_AMMO):\
4835 case (HUD_PANEL_POWERUPS):\
4836 HUD_Powerups(); break;\
4837 case (HUD_PANEL_HEALTHARMOR):\
4838 HUD_HealthArmor(); break;\
4839 case (HUD_PANEL_NOTIFY):\
4840 HUD_Notify(); break;\
4841 case (HUD_PANEL_TIMER):\
4842 HUD_Timer(); break;\
4843 case (HUD_PANEL_SCORE):\
4844 HUD_Score(); break;\
4845 case (HUD_PANEL_RACETIMER):\
4846 HUD_RaceTimer(); break;\
4847 case (HUD_PANEL_VOTE):\
4848 HUD_VoteWindow(); break;\
4849 case (HUD_PANEL_MODICONS):\
4850 HUD_ModIcons(); break;\
4851 case (HUD_PANEL_PRESSEDKEYS):\
4852 HUD_DrawPressedKeys(); break;\
4853 case (HUD_PANEL_CHAT):\
4855 case (HUD_PANEL_ENGINEINFO):\
4856 HUD_EngineInfo(); break;\
4857 case (HUD_PANEL_INFOMESSAGES):\
4858 HUD_InfoMessages(); break;\
4859 case (HUD_PANEL_PHYSICS):\
4860 HUD_Physics(); break;\
4861 case (HUD_PANEL_CENTERPRINT):\
4862 HUD_CenterPrint(); break;\
4863 } ENDS_WITH_CURLY_BRACE
4865 void HUD_Main (void)
4868 // global hud theAlpha fade
4869 if(menu_enabled == 1)
4872 hud_fade_alpha = (1 - autocvar__menu_alpha);
4874 if(scoreboard_fade_alpha)
4875 hud_fade_alpha = (1 - scoreboard_fade_alpha);
4877 if(autocvar__hud_configure)
4879 HUD_Configure_Exit_Force();
4881 if(intermission == 2) // no hud during mapvote
4883 if (autocvar__hud_configure)
4884 HUD_Configure_Exit_Force();
4887 else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
4890 // panels that we want to be active together with the scoreboard
4891 // they must call HUD_Panel_ApplyFadeAlpha(); only when showing the menu
4892 if(scoreboard_fade_alpha == 1)
4898 if(!autocvar__hud_configure && !hud_fade_alpha)
4902 if (hud_skin_path != autocvar_hud_skin)
4905 strunzone(hud_skin_path);
4906 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
4909 // HUD configure visible grid
4910 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4912 hud_configure_gridSize_x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
4913 hud_configure_gridSize_y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
4914 hud_configure_realGridSize_x = hud_configure_gridSize_x * vid_conwidth;
4915 hud_configure_realGridSize_y = hud_configure_gridSize_y * vid_conheight;
4918 s = eX + eY * vid_conheight;
4919 for(i = 1; i < 1/hud_configure_gridSize_x; ++i)
4920 drawfill(eX * i * hud_configure_realGridSize_x, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4922 s = eY + eX * vid_conwidth;
4923 for(i = 1; i < 1/hud_configure_gridSize_y; ++i)
4924 drawfill(eY * i * hud_configure_realGridSize_y, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4927 #ifdef COMPAT_XON050_ENGINE
4928 current_player = (spectatee_status > 0) ? spectatee_status : player_localentnum;
4930 current_player = player_localentnum;
4934 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4938 float hud_dock_color_team = autocvar_hud_dock_color_team;
4939 if((teamplay) && hud_dock_color_team) {
4940 f = stof(getplayerkeyvalue(current_player - 1, "colors"));
4941 color = colormapPaletteColor(mod(f, 16), 1) * hud_dock_color_team;
4943 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
4944 color = '1 0 0' * hud_dock_color_team;
4948 string hud_dock_color = autocvar_hud_dock_color;
4949 if(hud_dock_color == "shirt") {
4950 f = stof(getplayerkeyvalue(current_player - 1, "colors"));
4951 color = colormapPaletteColor(floor(f / 16), 0);
4953 else if(hud_dock_color == "pants") {
4954 f = stof(getplayerkeyvalue(current_player - 1, "colors"));
4955 color = colormapPaletteColor(mod(f, 16), 1);
4958 color = stov(hud_dock_color);
4962 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4963 if(precache_pic(pic) == "") {
4964 pic = strcat(hud_skin_path, "/dock_medium");
4965 if(precache_pic(pic) == "") {
4966 pic = "gfx/hud/default/dock_medium";
4969 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...
4972 // cache the panel order into the panel_order array
4973 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4974 for(i = 0; i < HUD_PANEL_NUM; ++i)
4975 panel_order[i] = -1;
4977 float p_num, warning = false;
4978 float argc = tokenize_console(autocvar__hud_panelorder);
4979 if (argc > HUD_PANEL_NUM)
4981 //first detect wrong/missing panel numbers
4982 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4983 p_num = stof(argv(i));
4984 if (p_num >= 0 && p_num < HUD_PANEL_NUM) { //correct panel number?
4985 if (panel_order[p_num] == -1) //found for the first time?
4986 s = strcat(s, ftos(p_num), " ");
4987 panel_order[p_num] = 1; //mark as found
4992 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4993 if (panel_order[i] == -1) {
4995 s = strcat(s, ftos(i), " "); //add missing panel number
4999 print(_("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n"));
5001 cvar_set("_hud_panelorder", s);
5002 if(hud_panelorder_prev)
5003 strunzone(hud_panelorder_prev);
5004 hud_panelorder_prev = strzone(s);
5006 //now properly set panel_order
5007 tokenize_console(s);
5008 for(i = 0; i < HUD_PANEL_NUM; ++i) {
5009 panel_order[i] = stof(argv(i));
5013 hud_draw_maximized = 0;
5014 // draw panels in order specified by panel_order array
5015 for(i = HUD_PANEL_NUM - 1; i >= 0; --i)
5016 HUD_DrawPanel(panel_order[i]);
5018 hud_draw_maximized = 1; // panels that may be maximized must check this var
5019 // draw maximized panels on top
5020 if(hud_panel_radar_maximized)
5022 if(autocvar__con_chat_maximized)
5025 if(autocvar__hud_configure)
5029 HUD_Panel_UpdatePosSizeForId(tab_panel)
5030 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
5032 if(highlightedPanel != -1)
5034 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
5035 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha));
5037 if (!hud_configure_prev)
5039 if(autocvar_hud_cursormode) { setcursormode(1); }
5043 else if (hud_configure_prev && autocvar_hud_cursormode)
5046 hud_configure_prev = autocvar__hud_configure;
5048 if (!autocvar__hud_configure) // hud config mode disabled, enable normal theAlpha stuff again