4 #include "hud_config.qh"
5 #include "mapvoting.qh"
6 #include "scoreboard.qh"
7 #include "teamradar.qh"
10 #include "../dpdefs/keycodes.qh"
12 #include "../common/buffs.qh"
13 #include "../common/constants.qh"
14 #include "../common/deathtypes.qh"
15 #include "../common/items/all.qc"
16 #include "../common/mapinfo.qh"
17 #include "../common/nades.qh"
19 #include "../server/mutators/gamemode_ctf.qh"
21 #include "../common/stats.qh"
23 #include "../csqcmodellib/cl_player.qh"
32 vector HUD_Get_Num_Color (float x, float maxvalue)
37 color.x = sin(2*M_PI*time);
39 color.z = sin(2*M_PI*time);
41 else if(x > maxvalue * 0.75) {
42 color.x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
43 color.y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
46 else if(x > maxvalue * 0.5) {
47 color.x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
48 color.y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
49 color.z = 1 - (x-100)*0.02; // blue value between 1 -> 0
51 else if(x > maxvalue * 0.25) {
54 color.z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
56 else if(x > maxvalue * 0.1) {
58 color.y = (x-20)*90/27/100; // green value between 0 -> 1
59 color.z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
67 blinkingamt = (1 - x/maxvalue/0.25);
70 color.x = color.x - color.x * blinkingamt * sin(2*M_PI*time);
71 color.y = color.y - color.y * blinkingamt * sin(2*M_PI*time);
72 color.z = color.z - color.z * blinkingamt * sin(2*M_PI*time);
77 float HUD_GetRowCount(int item_count, vector size, float item_aspect)
79 float aspect = size_y / size_x;
80 return bound(1, floor((sqrt(4 * item_aspect * aspect * item_count + aspect * aspect) + aspect + 0.5) / 2), item_count);
83 vector HUD_GetTableSize_BestItemAR(int item_count, vector psize, float item_aspect)
86 float ratio, best_ratio = 0;
87 float best_columns = 1, best_rows = 1;
88 bool vertical = (psize.x / psize.y >= item_aspect);
91 psize = eX * psize.y + eY * psize.x;
92 item_aspect = 1 / item_aspect;
95 rows = ceil(sqrt(item_count));
96 columns = ceil(item_count/rows);
99 ratio = (psize.x/columns) / (psize.y/rows);
100 if(ratio > item_aspect)
101 ratio = item_aspect * item_aspect / ratio;
103 if(ratio <= best_ratio)
104 break; // ratio starts decreasing by now, skip next configurations
106 best_columns = columns;
114 rows = ceil(item_count/columns);
118 return eX * best_rows + eY * best_columns;
120 return eX * best_columns + eY * best_rows;
123 // return the string of the onscreen race timer
124 string MakeRaceString(int cp, float mytime, float theirtime, float lapdelta, string theirname)
132 if(theirtime == 0) // goal hit
136 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
146 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
152 lapstr = sprintf(_(" (-%dL)"), lapdelta);
155 else if(lapdelta < 0)
157 lapstr = sprintf(_(" (+%dL)"), -lapdelta);
161 else if(theirtime > 0) // anticipation
163 if(mytime >= theirtime)
164 timestr = strcat("+", ftos_decimals(mytime - theirtime, TIME_DECIMALS));
166 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(theirtime));
176 cpname = _("Start line");
178 cpname = _("Finish line");
180 cpname = sprintf(_("Intermediate %d"), cp);
182 cpname = _("Finish line");
185 return strcat(col, cpname);
186 else if(theirname == "")
187 return strcat(col, sprintf("%s (%s)", cpname, timestr));
189 return strcat(col, sprintf("%s (%s %s)", cpname, timestr, strcat(theirname, col, lapstr)));
192 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
193 int race_CheckName(string net_name)
196 for (i=RANKINGS_CNT-1;i>=0;--i)
197 if(grecordholder[i] == net_name)
208 // draw the background/borders
209 #define HUD_Panel_DrawBg(theAlpha) do { \
210 if(panel.current_panel_bg != "0" && panel.current_panel_bg != "") \
211 draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel.current_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));\
214 //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
215 void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, bool vertical, float baralign, vector theColor, float theAlpha, int drawflag)
217 if(!length_ratio || !theAlpha)
223 if(length_ratio < -1)
226 else if(length_ratio < 0)
230 vector width, height;
232 pic = strcat(hud_skin_path, "/", pic, "_vertical");
233 if(precache_pic(pic) == "") {
234 pic = "gfx/hud/default/progressbar_vertical";
237 if (baralign == 1) // bottom align
238 theOrigin.y += (1 - length_ratio) * theSize.y;
239 else if (baralign == 2) // center align
240 theOrigin.y += 0.5 * (1 - length_ratio) * theSize.y;
241 else if (baralign == 3) // center align, positive values down, negative up
244 if (length_ratio > 0)
245 theOrigin.y += theSize.y;
248 theOrigin.y += (1 + length_ratio) * theSize.y;
249 length_ratio = -length_ratio;
252 theSize.y *= length_ratio;
255 width = eX * theSize.x;
256 height = eY * theSize.y;
257 if(theSize.y <= theSize.x * 2)
259 // button not high enough
260 // draw just upper and lower part then
261 square = eY * theSize.y * 0.5;
262 bH = eY * (0.25 * theSize.y / (theSize.x * 2));
263 drawsubpic(theOrigin, square + width, pic, '0 0 0', eX + bH, theColor, theAlpha, drawflag);
264 drawsubpic(theOrigin + square, square + width, pic, eY - bH, eX + bH, theColor, theAlpha, drawflag);
268 square = eY * theSize.x;
269 drawsubpic(theOrigin, width + square, pic, '0 0 0', '1 0.25 0', theColor, theAlpha, drawflag);
270 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0 0.25 0', '1 0.5 0', theColor, theAlpha, drawflag);
271 drawsubpic(theOrigin + height - square, width + square, pic, '0 0.75 0', '1 0.25 0', theColor, theAlpha, drawflag);
274 pic = strcat(hud_skin_path, "/", pic);
275 if(precache_pic(pic) == "") {
276 pic = "gfx/hud/default/progressbar";
279 if (baralign == 1) // right align
280 theOrigin.x += (1 - length_ratio) * theSize.x;
281 else if (baralign == 2) // center align
282 theOrigin.x += 0.5 * (1 - length_ratio) * theSize.x;
283 else if (baralign == 3) // center align, positive values on the right, negative on the left
286 if (length_ratio > 0)
287 theOrigin.x += theSize.x;
290 theOrigin.x += (1 + length_ratio) * theSize.x;
291 length_ratio = -length_ratio;
294 theSize.x *= length_ratio;
297 width = eX * theSize.x;
298 height = eY * theSize.y;
299 if(theSize.x <= theSize.y * 2)
301 // button not wide enough
302 // draw just left and right part then
303 square = eX * theSize.x * 0.5;
304 bW = eX * (0.25 * theSize.x / (theSize.y * 2));
305 drawsubpic(theOrigin, square + height, pic, '0 0 0', eY + bW, theColor, theAlpha, drawflag);
306 drawsubpic(theOrigin + square, square + height, pic, eX - bW, eY + bW, theColor, theAlpha, drawflag);
310 square = eX * theSize.y;
311 drawsubpic(theOrigin, height + square, pic, '0 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
312 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0.25 0 0', '0.5 1 0', theColor, theAlpha, drawflag);
313 drawsubpic(theOrigin + width - square, height + square, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
318 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float theAlpha, int drawflag)
324 pic = strcat(hud_skin_path, "/num_leading");
325 if(precache_pic(pic) == "") {
326 pic = "gfx/hud/default/num_leading";
329 drawsubpic(pos, eX * min(mySize.x * 0.5, mySize.y) + eY * mySize.y, pic, '0 0 0', '0.25 1 0', color, theAlpha, drawflag);
330 if(mySize.x/mySize.y > 2)
331 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);
332 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);
337 entity weaponorder[Weapons_MAX];
338 void weaponorder_swap(int i, int j, entity pass)
340 entity h = weaponorder[i];
341 weaponorder[i] = weaponorder[j];
345 string weaponorder_cmp_str;
346 int weaponorder_cmp(int i, int j, entity pass)
349 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
350 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
351 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)
354 void HUD_Weapons(void)
357 WepSet weapons_stat = WepSet_GetFromStat();
361 vector center = '0 0 0';
362 int weapon_count, weapon_id;
363 int row, column, rows = 0, columns = 0;
364 bool vertical_order = true;
365 float aspect = autocvar_hud_panel_weapons_aspect;
367 float timeout = autocvar_hud_panel_weapons_timeout;
368 float timein_effect_length = autocvar_hud_panel_weapons_timeout_speed_in; //? 0.375 : 0);
369 float timeout_effect_length = autocvar_hud_panel_weapons_timeout_speed_out; //? 0.75 : 0);
371 vector barsize = '0 0 0', baroffset = '0 0 0';
372 vector ammo_color = '1 0 1';
373 float ammo_alpha = 1;
375 float when = max(1, autocvar_hud_panel_weapons_complainbubble_time);
376 float fadetime = max(0, autocvar_hud_panel_weapons_complainbubble_fadetime);
378 vector weapon_pos, weapon_size = '0 0 0';
381 // check to see if we want to continue
382 if(intermission == 2) return;
383 if(hud != HUD_NORMAL) return;
385 if(!autocvar__hud_configure)
387 if((!autocvar_hud_panel_weapons) || (spectatee_status == -1))
389 if(timeout && time >= weapontime + timeout + timeout_effect_length)
390 if(autocvar_hud_panel_weapons_timeout_effect == 3 || (autocvar_hud_panel_weapons_timeout_effect == 1 && !(autocvar_hud_panel_weapons_timeout_fadebgmin + autocvar_hud_panel_weapons_timeout_fadefgmin)))
392 weaponprevtime = time;
397 // update generic hud functions
398 HUD_Panel_UpdateCvars();
400 // figure out weapon order (how the weapons are sorted) // TODO make this configurable
401 if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
404 if(weaponorder_bypriority)
405 strunzone(weaponorder_bypriority);
406 if(weaponorder_byimpulse)
407 strunzone(weaponorder_byimpulse);
409 weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
410 weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
411 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
414 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
416 setself(get_weaponinfo(i));
417 if(self.impulse >= 0)
419 weaponorder[weapon_cnt] = self;
423 for(i = weapon_cnt; i < Weapons_MAX; ++i)
424 weaponorder[i] = world;
425 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
427 weaponorder_cmp_str = string_null;
430 if(!autocvar_hud_panel_weapons_complainbubble || autocvar__hud_configure || time - complain_weapon_time >= when + fadetime)
433 if(autocvar__hud_configure)
436 for(i = WEP_FIRST; i <= WEP_LAST; i += floor((WEP_LAST-WEP_FIRST)/5))
437 weapons_stat |= WepSet_FromWeapon(i);
443 weapons_stat = '0 0 0';
444 float countw = 1 + floor((floor(time * cvar("wep_add"))) % (Weapons_COUNT - 1));
445 for(i = WEP_FIRST; i <= countw; ++i)
446 weapons_stat |= WepSet_FromWeapon(i);
451 // determine which weapons are going to be shown
452 if (autocvar_hud_panel_weapons_onlyowned)
454 if(autocvar__hud_configure)
456 if(menu_enabled != 2)
457 HUD_Panel_DrawBg(1); // also draw the bg of the entire panel
460 // do we own this weapon?
462 for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
463 if((weapons_stat & WepSet_FromWeapon(weaponorder[i].weapon)) || (weaponorder[i].weapon == complain_weapon))
467 // might as well commit suicide now, no reason to live ;)
468 if (weapon_count == 0)
471 vector old_panel_size = panel_size;
472 vector padded_panel_size = panel_size - '2 2 0' * panel_bg_padding;
474 // get the all-weapons layout
476 WepSet weapons_stat = WepSet_GetFromStat();
477 for (int i = WEP_FIRST; i <= WEP_LAST; ++i) {
478 WepSet weapons_wep = WepSet_FromWeapon(i);
479 if (weapons_stat & weapons_wep) continue;
480 Weapon w = get_weaponinfo(i);
481 if (w.spawnflags & WEP_FLAG_MUTATORBLOCKED) nHidden += 1;
483 vector table_size = HUD_GetTableSize_BestItemAR((Weapons_COUNT - 1) - nHidden, padded_panel_size, aspect);
484 columns = table_size.x;
486 weapon_size.x = padded_panel_size.x / columns;
487 weapon_size.y = padded_panel_size.y / rows;
489 // NOTE: although weapons should aways look the same even if onlyowned is enabled,
490 // we enlarge them a bit when possible to better match the desired aspect ratio
491 if(padded_panel_size.x / padded_panel_size.y < aspect)
493 // maximum number of rows that allows to display items with the desired aspect ratio
494 int max_rows = floor(padded_panel_size.y / (weapon_size.x / aspect));
495 columns = min(columns, ceil(weapon_count / max_rows));
496 rows = ceil(weapon_count / columns);
497 weapon_size.y = min(padded_panel_size.y / rows, weapon_size.x / aspect);
498 weapon_size.x = min(padded_panel_size.x / columns, aspect * weapon_size.y);
499 vertical_order = false;
503 int max_columns = floor(padded_panel_size.x / (weapon_size.y * aspect));
504 rows = min(rows, ceil(weapon_count / max_columns));
505 columns = ceil(weapon_count / rows);
506 weapon_size.x = min(padded_panel_size.x / columns, aspect * weapon_size.y);
507 weapon_size.y = min(padded_panel_size.y / rows, weapon_size.x / aspect);
508 vertical_order = true;
511 // reduce size of the panel
512 panel_size.x = columns * weapon_size.x;
513 panel_size.y = rows * weapon_size.y;
514 panel_size += '2 2 0' * panel_bg_padding;
516 // center the resized panel, or snap it to the screen edge when close enough
517 if(panel_pos.x > vid_conwidth * 0.001)
519 if(panel_pos.x + old_panel_size.x > vid_conwidth * 0.999)
520 panel_pos.x += old_panel_size.x - panel_size.x;
522 panel_pos.x += (old_panel_size.x - panel_size.x) / 2;
524 else if(old_panel_size.x > vid_conwidth * 0.999)
525 panel_pos.x += (old_panel_size.x - panel_size.x) / 2;
527 if(panel_pos.y > vid_conheight * 0.001)
529 if(panel_pos.y + old_panel_size.y > vid_conheight * 0.999)
530 panel_pos.y += old_panel_size.y - panel_size.y;
532 panel_pos.y += (old_panel_size.y - panel_size.y) / 2;
534 else if(old_panel_size.y > vid_conheight * 0.999)
535 panel_pos.y += (old_panel_size.y - panel_size.y) / 2;
538 weapon_count = (Weapons_COUNT - 1);
540 // animation for fading in/out the panel respectively when not in use
541 if(!autocvar__hud_configure)
543 if (timeout && time >= weapontime + timeout) // apply timeout effect if needed
545 f = bound(0, (time - (weapontime + timeout)) / timeout_effect_length, 1);
547 // fade the panel alpha
548 if(autocvar_hud_panel_weapons_timeout_effect == 1)
550 panel_bg_alpha *= (autocvar_hud_panel_weapons_timeout_fadebgmin * f + (1 - f));
551 panel_fg_alpha *= (autocvar_hud_panel_weapons_timeout_fadefgmin * f + (1 - f));
553 else if(autocvar_hud_panel_weapons_timeout_effect == 3)
555 panel_bg_alpha *= (1 - f);
556 panel_fg_alpha *= (1 - f);
559 // move the panel off the screen
560 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
562 f *= f; // for a cooler movement
563 center.x = panel_pos.x + panel_size.x/2;
564 center.y = panel_pos.y + panel_size.y/2;
565 screen_ar = vid_conwidth/vid_conheight;
566 if (center.x/center.y < screen_ar) //bottom left
568 if ((vid_conwidth - center.x)/center.y < screen_ar) //bottom
569 panel_pos.y += f * (vid_conheight - panel_pos.y);
571 panel_pos.x -= f * (panel_pos.x + panel_size.x);
575 if ((vid_conwidth - center.x)/center.y < screen_ar) //right
576 panel_pos.x += f * (vid_conwidth - panel_pos.x);
578 panel_pos.y -= f * (panel_pos.y + panel_size.y);
581 center.x = -1; // mark the panel as off screen
583 weaponprevtime = time - (1 - f) * timein_effect_length;
585 else if (timeout && time < weaponprevtime + timein_effect_length) // apply timein effect if needed
587 f = bound(0, (time - weaponprevtime) / timein_effect_length, 1);
589 // fade the panel alpha
590 if(autocvar_hud_panel_weapons_timeout_effect == 1)
592 panel_bg_alpha *= (autocvar_hud_panel_weapons_timeout_fadebgmin * (1 - f) + f);
593 panel_fg_alpha *= (autocvar_hud_panel_weapons_timeout_fadefgmin * (1 - f) + f);
595 else if(autocvar_hud_panel_weapons_timeout_effect == 3)
597 panel_bg_alpha *= (f);
598 panel_fg_alpha *= (f);
601 // move the panel back on screen
602 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
604 f *= f; // for a cooler movement
606 center.x = panel_pos.x + panel_size.x/2;
607 center.y = panel_pos.y + panel_size.y/2;
608 screen_ar = vid_conwidth/vid_conheight;
609 if (center.x/center.y < screen_ar) //bottom left
611 if ((vid_conwidth - center.x)/center.y < screen_ar) //bottom
612 panel_pos.y += f * (vid_conheight - panel_pos.y);
614 panel_pos.x -= f * (panel_pos.x + panel_size.x);
618 if ((vid_conwidth - center.x)/center.y < screen_ar) //right
619 panel_pos.x += f * (vid_conwidth - panel_pos.x);
621 panel_pos.y -= f * (panel_pos.y + panel_size.y);
627 // draw the background, then change the virtual size of it to better fit other items inside
635 panel_pos += '1 1 0' * panel_bg_padding;
636 panel_size -= '2 2 0' * panel_bg_padding;
639 // after the sizing and animations are done, update the other values
641 if(!rows) // if rows is > 0 onlyowned code has already updated these vars
643 vector table_size = HUD_GetTableSize_BestItemAR((Weapons_COUNT - 1), panel_size, aspect);
644 columns = table_size.x;
646 weapon_size.x = panel_size.x / columns;
647 weapon_size.y = panel_size.y / rows;
648 vertical_order = (panel_size.x / panel_size.y >= aspect);
651 // calculate position/size for visual bar displaying ammount of ammo status
652 if (autocvar_hud_panel_weapons_ammo)
654 ammo_color = stov(autocvar_hud_panel_weapons_ammo_color);
655 ammo_alpha = panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha;
657 if(weapon_size.x/weapon_size.y > aspect)
659 barsize.x = aspect * weapon_size.y;
660 barsize.y = weapon_size.y;
661 baroffset.x = (weapon_size.x - barsize.x) / 2;
665 barsize.y = 1/aspect * weapon_size.x;
666 barsize.x = weapon_size.x;
667 baroffset.y = (weapon_size.y - barsize.y) / 2;
670 if(autocvar_hud_panel_weapons_accuracy)
671 Accuracy_LoadColors();
675 vector label_size = '1 1 0' * min(weapon_size.x, weapon_size.y) * bound(0, autocvar_hud_panel_weapons_label_scale, 1);
676 vector noncurrent_pos = '0 0 0';
677 vector noncurrent_size = weapon_size * bound(0, autocvar_hud_panel_weapons_noncurrent_scale, 1);
678 float noncurrent_alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_weapons_noncurrent_alpha, 1);
681 for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
683 // retrieve information about the current weapon to be drawn
684 setself(weaponorder[i]);
685 weapon_id = self.impulse;
686 isCurrent = (self.weapon == switchweapon);
688 // skip if this weapon doesn't exist
689 if(!self || weapon_id < 0) { continue; }
691 // skip this weapon if we don't own it (and onlyowned is enabled)-- or if weapons_complainbubble is showing for this weapon
692 if(autocvar_hud_panel_weapons_onlyowned)
693 if (!((weapons_stat & WepSet_FromWeapon(self.weapon)) || (self.weapon == complain_weapon)))
696 // figure out the drawing position of weapon
697 weapon_pos = (panel_pos + eX * column * weapon_size.x + eY * row * weapon_size.y);
698 noncurrent_pos.x = weapon_pos.x + (weapon_size.x - noncurrent_size.x) / 2;
699 noncurrent_pos.y = weapon_pos.y + (weapon_size.y - noncurrent_size.y) / 2;
701 // draw background behind currently selected weapon
703 drawpic_aspect_skin(weapon_pos, "weapon_current_bg", weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
705 // draw the weapon accuracy
706 if(autocvar_hud_panel_weapons_accuracy)
708 float panel_weapon_accuracy = weapon_accuracy[self.weapon-WEP_FIRST];
709 if(panel_weapon_accuracy >= 0)
711 color = Accuracy_GetColor(panel_weapon_accuracy);
712 drawpic_aspect_skin(weapon_pos, "weapon_accuracy", weapon_size, color, panel_fg_alpha, DRAWFLAG_NORMAL);
716 // drawing all the weapon items
717 if(weapons_stat & WepSet_FromWeapon(self.weapon))
719 // draw the weapon image
721 drawpic_aspect_skin(weapon_pos, self.model2, weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
723 drawpic_aspect_skin(noncurrent_pos, self.model2, noncurrent_size, '1 1 1', noncurrent_alpha, DRAWFLAG_NORMAL);
725 // draw weapon label string
726 switch(autocvar_hud_panel_weapons_label)
728 case 1: // weapon number
729 drawstring(weapon_pos, ftos(weapon_id), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
733 drawstring(weapon_pos, getcommandkey(ftos(weapon_id), strcat("weapon_group_", ftos(weapon_id))), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
736 case 3: // weapon name
737 drawstring(weapon_pos, strtolower(self.message), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
744 // draw ammo status bar
745 if(autocvar_hud_panel_weapons_ammo && (self.ammo_field != ammo_none))
748 a = getstati(GetAmmoStat(self.ammo_field)); // how much ammo do we have?
752 switch(self.ammo_field)
754 case ammo_shells: ammo_full = autocvar_hud_panel_weapons_ammo_full_shells; break;
755 case ammo_nails: ammo_full = autocvar_hud_panel_weapons_ammo_full_nails; break;
756 case ammo_rockets: ammo_full = autocvar_hud_panel_weapons_ammo_full_rockets; break;
757 case ammo_cells: ammo_full = autocvar_hud_panel_weapons_ammo_full_cells; break;
758 case ammo_plasma: ammo_full = autocvar_hud_panel_weapons_ammo_full_plasma; break;
759 case ammo_fuel: ammo_full = autocvar_hud_panel_weapons_ammo_full_fuel; break;
760 default: ammo_full = 60;
764 weapon_pos.x + baroffset.x,
765 weapon_pos.y + baroffset.y,
766 barsize.x * bound(0, a/ammo_full, 1),
783 else // draw a "ghost weapon icon" if you don't have the weapon
785 drawpic_aspect_skin(noncurrent_pos, self.model2, noncurrent_size, '0.2 0.2 0.2', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
788 // draw the complain message
789 if(self.weapon == complain_weapon)
792 a = ((complain_weapon_time + when > time) ? 1 : bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1));
794 a = ((complain_weapon_time + when > time) ? 1 : 0);
797 if(complain_weapon_type == 0) {
798 s = _("Out of ammo");
799 color = stov(autocvar_hud_panel_weapons_complainbubble_color_outofammo);
801 else if(complain_weapon_type == 1) {
803 color = stov(autocvar_hud_panel_weapons_complainbubble_color_donthave);
806 s = _("Unavailable");
807 color = stov(autocvar_hud_panel_weapons_complainbubble_color_unavailable);
809 float padding = autocvar_hud_panel_weapons_complainbubble_padding;
810 drawpic_aspect_skin(weapon_pos + '1 1 0' * padding, "weapon_complainbubble", weapon_size - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
811 drawstring_aspect(weapon_pos + '1 1 0' * padding, s, weapon_size - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
816 if(!autocvar_hud_panel_weapons_onlyowned)
818 drawfill(weapon_pos + '1 1 0', weapon_size - '2 2 0', '1 1 1', panel_fg_alpha * 0.2, DRAWFLAG_NORMAL);
819 drawstring(weapon_pos, ftos(i + 1), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
823 // continue with new position for the next weapon
827 if(column >= columns)
846 void DrawNadeProgressBar(vector myPos, vector mySize, float progress, vector color)
848 HUD_Panel_DrawProgressBar(
849 myPos + eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize.x,
850 mySize - eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize.x,
851 autocvar_hud_panel_ammo_progressbar_name,
852 progress, 0, 0, color,
853 autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
856 void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expand_time)
858 float bonusNades = getstatf(STAT_NADE_BONUS);
859 float bonusProgress = getstatf(STAT_NADE_BONUS_SCORE);
860 float bonusType = getstati(STAT_NADE_BONUS_TYPE);
861 vector nadeColor = NADES[bonusType].m_color;
862 string nadeIcon = NADES[bonusType].m_icon;
864 vector iconPos, textPos;
866 if(autocvar_hud_panel_ammo_iconalign)
868 iconPos = myPos + eX * 2 * mySize.y;
874 textPos = myPos + eX * mySize.y;
877 if(bonusNades > 0 || bonusProgress > 0)
879 DrawNadeProgressBar(myPos, mySize, bonusProgress, nadeColor);
881 if(autocvar_hud_panel_ammo_text)
882 drawstring_aspect(textPos, ftos(bonusNades), eX * (2/3) * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
885 drawpic_aspect_skin_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, expand_time);
887 drawpic_aspect_skin(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
891 void DrawAmmoItem(vector myPos, vector mySize, .int ammoType, bool isCurrent, bool isInfinite)
893 if(ammoType == ammo_none)
896 // Initialize variables
899 if(autocvar__hud_configure)
901 isCurrent = (ammoType == ammo_rockets); // Rockets always current
905 ammo = getstati(GetAmmoStat(ammoType));
909 float scale = bound(0, autocvar_hud_panel_ammo_noncurrent_scale, 1);
910 myPos = myPos + (mySize - mySize * scale) * 0.5;
911 mySize = mySize * scale;
914 vector iconPos, textPos;
915 if(autocvar_hud_panel_ammo_iconalign)
917 iconPos = myPos + eX * 2 * mySize.y;
923 textPos = myPos + eX * mySize.y;
926 bool isShadowed = (ammo <= 0 && !isCurrent && !isInfinite);
928 vector iconColor = isShadowed ? '0 0 0' : '1 1 1';
931 textColor = '0.2 0.95 0';
935 textColor = '0.8 0.04 0';
941 alpha = panel_fg_alpha;
943 alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_ammo_noncurrent_alpha, 1) * 0.5;
945 alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_ammo_noncurrent_alpha, 1);
947 string text = isInfinite ? "\xE2\x88\x9E" : ftos(ammo); // Use infinity symbol (U+221E)
952 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
954 if(ammo > 0 && autocvar_hud_panel_ammo_progressbar)
955 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, ammo/autocvar_hud_panel_ammo_maxammo, 0, 0, textColor, autocvar_hud_progressbar_alpha * alpha, DRAWFLAG_NORMAL);
957 if(autocvar_hud_panel_ammo_text)
958 drawstring_aspect(textPos, text, eX * (2/3) * mySize.x + eY * mySize.y, textColor, alpha, DRAWFLAG_NORMAL);
960 drawpic_aspect_skin(iconPos, GetAmmoPicture(ammoType), '1 1 0' * mySize.y, iconColor, alpha, DRAWFLAG_NORMAL);
965 float nade_statuschange_time;
968 if(intermission == 2) return;
969 if(hud != HUD_NORMAL) return;
970 if(!autocvar__hud_configure)
972 if(!autocvar_hud_panel_ammo) return;
973 if(spectatee_status == -1) return;
976 HUD_Panel_UpdateCvars();
978 draw_beginBoldFont();
987 pos += '1 1 0' * panel_bg_padding;
988 mySize -= '2 2 0' * panel_bg_padding;
991 int rows = 0, columns, row, column;
992 float nade_cnt = getstatf(STAT_NADE_BONUS), nade_score = getstatf(STAT_NADE_BONUS_SCORE);
993 bool draw_nades = (nade_cnt > 0 || nade_score > 0);
994 float nade_statuschange_elapsedtime;
995 int total_ammo_count;
998 if (autocvar_hud_panel_ammo_onlycurrent)
999 total_ammo_count = 1;
1001 total_ammo_count = AMMO_COUNT;
1006 if (nade_cnt != nade_prevframe)
1008 nade_statuschange_time = time;
1009 nade_prevstatus = nade_prevframe;
1010 nade_prevframe = nade_cnt;
1014 nade_prevstatus = nade_prevframe = nade_statuschange_time = 0;
1016 rows = HUD_GetRowCount(total_ammo_count, mySize, 3);
1017 columns = ceil((total_ammo_count)/rows);
1018 ammo_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
1020 vector offset = '0 0 0'; // fteqcc sucks
1022 if(ammo_size.x/ammo_size.y > 3)
1024 newSize = 3 * ammo_size.y;
1025 offset.x = ammo_size.x - newSize;
1026 pos.x += offset.x/2;
1027 ammo_size.x = newSize;
1031 newSize = 1/3 * ammo_size.x;
1032 offset.y = ammo_size.y - newSize;
1033 pos.y += offset.y/2;
1034 ammo_size.y = newSize;
1038 bool infinite_ammo = (getstati(STAT_ITEMS, 0, 24) & IT_UNLIMITED_WEAPON_AMMO);
1040 if(autocvar_hud_panel_ammo_onlycurrent)
1042 if(autocvar__hud_configure)
1044 DrawAmmoItem(pos, ammo_size, ammo_rockets, true, false);
1051 (get_weaponinfo(switchweapon)).ammo_field,
1061 column = column + 1;
1068 for(i = 0; i < AMMO_COUNT; ++i)
1070 ammotype = GetAmmoFieldFromNum(i);
1072 pos + eX * column * (ammo_size.x + offset.x) + eY * row * (ammo_size.y + offset.y),
1075 ((get_weaponinfo(switchweapon)).ammo_field == ammotype),
1083 column = column + 1;
1090 nade_statuschange_elapsedtime = time - nade_statuschange_time;
1092 float f = bound(0, nade_statuschange_elapsedtime*2, 1);
1094 DrawAmmoNades(pos + eX * column * (ammo_size.x + offset.x) + eY * row * (ammo_size.y + offset.y), ammo_size, nade_prevstatus < nade_cnt && nade_cnt != 0 && f < 1, f);
1100 void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, bool vertical, bool icon_right_align, vector color, float theAlpha, float fadelerp)
1102 vector newPos = '0 0 0', newSize = '0 0 0';
1103 vector picpos, numpos;
1107 if(mySize.y/mySize.x > 2)
1109 newSize.y = 2 * mySize.x;
1110 newSize.x = mySize.x;
1112 newPos.y = myPos.y + (mySize.y - newSize.y) / 2;
1117 newSize.x = 1/2 * mySize.y;
1118 newSize.y = mySize.y;
1120 newPos.x = myPos.x + (mySize.x - newSize.x) / 2;
1124 if(icon_right_align)
1127 picpos = newPos + eY * newSize.x;
1132 numpos = newPos + eY * newSize.x;
1136 drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
1137 // make number smaller than icon, it looks better
1138 // reduce only y to draw numbers with different number of digits with the same y size
1139 numpos.y += newSize.y * ((1 - 0.7) / 2);
1141 drawstring_aspect(numpos, ftos(x), newSize, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
1145 if(mySize.x/mySize.y > 3)
1147 newSize.x = 3 * mySize.y;
1148 newSize.y = mySize.y;
1150 newPos.x = myPos.x + (mySize.x - newSize.x) / 2;
1155 newSize.y = 1/3 * mySize.x;
1156 newSize.x = mySize.x;
1158 newPos.y = myPos.y + (mySize.y - newSize.y) / 2;
1162 if(icon_right_align) // right align
1165 picpos = newPos + eX * 2 * newSize.y;
1169 numpos = newPos + eX * newSize.y;
1173 // NOTE: newSize_x is always equal to 3 * mySize_y so we can use
1174 // '2 1 0' * newSize_y instead of eX * (2/3) * newSize_x + eY * newSize_y
1175 drawstring_aspect_expanding(numpos, ftos(x), '2 1 0' * newSize.y, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
1176 drawpic_aspect_skin_expanding(picpos, icon, '1 1 0' * newSize.y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
1179 void DrawNumIcon(vector myPos, vector mySize, float x, string icon, bool vertical, bool icon_right_align, vector color, float theAlpha)
1181 DrawNumIcon_expanding(myPos, mySize, x, icon, vertical, icon_right_align, color, theAlpha, 0);
1187 // Powerup item fields (reusing existing fields)
1188 .string message; // Human readable name
1189 .string netname; // Icon name
1190 .vector colormod; // Color
1191 .float count; // Time left
1192 .float lifetime; // Maximum time
1194 entity powerupItems;
1195 int powerupItemsCount;
1197 void resetPowerupItems()
1200 for(item = powerupItems; item; item = item.chain)
1203 powerupItemsCount = 0;
1206 void addPowerupItem(string name, string icon, vector color, float currentTime, float lifeTime)
1209 powerupItems = spawn();
1212 for(item = powerupItems; item.count; item = item.chain)
1214 item.chain = spawn();
1216 item.message = name;
1217 item.netname = icon;
1218 item.colormod = color;
1219 item.count = currentTime;
1220 item.lifetime = lifeTime;
1222 ++powerupItemsCount;
1225 int getPowerupItemAlign(int align, int column, int row, int columns, int rows, bool isVertical)
1230 bool isTop = isVertical && rows > 1 && row == 0;
1231 bool isBottom = isVertical && rows > 1 && row == rows-1;
1232 bool isLeft = !isVertical && columns > 1 && column == 0;
1233 bool isRight = !isVertical && columns > 1 && column == columns-1;
1235 if(isTop || isLeft) return (align == 2) ? 1 : 0;
1236 if(isBottom || isRight) return (align == 2) ? 0 : 1;
1243 if(intermission == 2) return;
1245 int allItems = getstati(STAT_ITEMS, 0, 24);
1246 int allBuffs = getstati(STAT_BUFFS, 0, 24);
1247 int strengthTime, shieldTime, superTime;
1250 if(!autocvar__hud_configure)
1252 if(!autocvar_hud_panel_powerups) return;
1253 if(spectatee_status == -1) return;
1254 if(getstati(STAT_HEALTH) <= 0) return;
1255 if(!(allItems & (ITEM_Strength.m_itemid | ITEM_Shield.m_itemid | IT_SUPERWEAPON)) && !allBuffs) return;
1257 strengthTime = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1258 shieldTime = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1259 superTime = bound(0, getstatf(STAT_SUPERWEAPONS_FINISHED) - time, 99);
1261 if(allItems & IT_UNLIMITED_SUPERWEAPONS)
1264 // Prevent stuff to show up on mismatch that will be fixed next frame
1265 if(!(allItems & IT_SUPERWEAPON))
1276 // Add items to linked list
1277 resetPowerupItems();
1280 addPowerupItem("Strength", "strength", autocvar_hud_progressbar_strength_color, strengthTime, 30);
1282 addPowerupItem("Shield", "shield", autocvar_hud_progressbar_shield_color, shieldTime, 30);
1284 addPowerupItem("Superweapons", "superweapons", autocvar_hud_progressbar_superweapons_color, superTime, 30);
1286 FOREACH(BUFFS, it.m_itemid & allBuffs, LAMBDA(
1287 addPowerupItem(it.m_prettyName, strcat("buff_", it.m_name), it.m_color, bound(0, getstatf(STAT_BUFF_TIME) - time, 99), 60);
1290 if(!powerupItemsCount)
1293 // Draw panel background
1294 HUD_Panel_UpdateCvars();
1295 HUD_Panel_DrawBg(1);
1298 vector pos = panel_pos;
1299 vector size = panel_size;
1300 bool isVertical = size.y > size.x;
1302 if(panel_bg_padding)
1304 pos += '1 1 0' * panel_bg_padding;
1305 size -= '2 2 0' * panel_bg_padding;
1308 // Find best partitioning of the drawing area
1309 const float DESIRED_ASPECT = 6;
1310 float aspect = 0, a;
1317 c = floor(powerupItemsCount / i);
1318 r = ceil(powerupItemsCount / c);
1319 a = isVertical ? (size.y/r) / (size.x/c) : (size.x/c) / (size.y/r);
1321 if(i == 1 || fabs(DESIRED_ASPECT - a) < fabs(DESIRED_ASPECT - aspect))
1328 while(++i <= powerupItemsCount);
1330 // Prevent single items from getting too wide
1331 if(powerupItemsCount == 1 && aspect > DESIRED_ASPECT)
1336 pos.y += size.y * 0.5;
1341 pos.x += size.x * 0.5;
1345 // Draw items from linked list
1346 vector itemPos = pos;
1347 vector itemSize = eX * (size.x / columns) + eY * (size.y / rows);
1348 vector textColor = '1 1 1';
1350 int fullSeconds = 0;
1355 draw_beginBoldFont();
1356 for(entity item = powerupItems; item.count; item = item.chain)
1358 itemPos = eX * (pos.x + column * itemSize.x) + eY * (pos.y + row * itemSize.y);
1361 if(autocvar_hud_panel_powerups_progressbar)
1363 align = getPowerupItemAlign(autocvar_hud_panel_powerups_baralign, column, row, columns, rows, isVertical);
1364 HUD_Panel_DrawProgressBar(itemPos, itemSize, "progressbar", item.count / item.lifetime, isVertical, align, item.colormod, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1367 // Draw icon and text
1368 if(autocvar_hud_panel_powerups_text)
1370 align = getPowerupItemAlign(autocvar_hud_panel_powerups_iconalign, column, row, columns, rows, isVertical);
1371 fullSeconds = ceil(item.count);
1372 textColor = '0.6 0.6 0.6' + (item.colormod * 0.4);
1375 DrawNumIcon(itemPos, itemSize, fullSeconds, item.netname, isVertical, align, textColor, panel_fg_alpha);
1377 DrawNumIcon_expanding(itemPos, itemSize, fullSeconds, item.netname, isVertical, align, textColor, panel_fg_alpha, bound(0, (fullSeconds - item.count) / 0.5, 1));
1380 // Determine next section
1383 if(++column >= columns)
1401 // Health/armor (#3)
1405 void HUD_HealthArmor(void)
1407 int armor, health, fuel;
1408 if(intermission == 2) return;
1409 if(!autocvar__hud_configure)
1411 if(!autocvar_hud_panel_healtharmor) return;
1412 if(hud != HUD_NORMAL) return;
1413 if(spectatee_status == -1) return;
1415 health = getstati(STAT_HEALTH);
1421 armor = getstati(STAT_ARMOR);
1423 // code to check for spectatee_status changes is in Ent_ClientData()
1424 // prev_p_health and prev_health can be set to -1 there
1426 if (prev_p_health == -1)
1429 health_beforedamage = 0;
1430 armor_beforedamage = 0;
1431 health_damagetime = 0;
1432 armor_damagetime = 0;
1433 prev_health = health;
1435 old_p_health = health;
1436 old_p_armor = armor;
1437 prev_p_health = health;
1438 prev_p_armor = armor;
1440 else if (prev_health == -1)
1442 //start the load effect
1443 health_damagetime = 0;
1444 armor_damagetime = 0;
1448 fuel = getstati(STAT_FUEL);
1457 HUD_Panel_UpdateCvars();
1459 draw_beginBoldFont();
1463 mySize = panel_size;
1465 HUD_Panel_DrawBg(1);
1466 if(panel_bg_padding)
1468 pos += '1 1 0' * panel_bg_padding;
1469 mySize -= '2 2 0' * panel_bg_padding;
1472 int baralign = autocvar_hud_panel_healtharmor_baralign;
1473 int iconalign = autocvar_hud_panel_healtharmor_iconalign;
1475 int maxhealth = autocvar_hud_panel_healtharmor_maxhealth;
1476 int maxarmor = autocvar_hud_panel_healtharmor_maxarmor;
1477 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
1480 v = healtharmor_maxdamage(health, armor, armorblockpercent, DEATH_WEAPON);
1485 float maxtotal = maxhealth + maxarmor;
1487 if(v.z) // NOT fully armored
1489 biggercount = "health";
1490 if(autocvar_hud_panel_healtharmor_progressbar)
1491 HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_health, x/maxtotal, 0, (baralign == 1 || baralign == 2), autocvar_hud_progressbar_health_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1493 if(autocvar_hud_panel_healtharmor_text)
1494 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);
1498 biggercount = "armor";
1499 if(autocvar_hud_panel_healtharmor_progressbar)
1500 HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, x/maxtotal, 0, (baralign == 1 || baralign == 2), autocvar_hud_progressbar_armor_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1502 if(autocvar_hud_panel_healtharmor_text)
1503 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);
1505 if(autocvar_hud_panel_healtharmor_text)
1506 DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, maxtotal), 1);
1509 HUD_Panel_DrawProgressBar(pos, eX * mySize.x + eY * 0.2 * mySize.y, "progressbar", fuel/100, 0, (baralign == 1 || baralign == 3), autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
1513 float panel_ar = mySize.x/mySize.y;
1514 bool is_vertical = (panel_ar < 1);
1515 vector health_offset = '0 0 0', armor_offset = '0 0 0';
1516 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1519 if (autocvar_hud_panel_healtharmor_flip)
1520 health_offset.x = mySize.x;
1522 armor_offset.x = mySize.x;
1527 if (autocvar_hud_panel_healtharmor_flip)
1528 health_offset.y = mySize.y;
1530 armor_offset.y = mySize.y;
1533 bool health_baralign, armor_baralign, fuel_baralign;
1534 bool health_iconalign, armor_iconalign;
1535 if (autocvar_hud_panel_healtharmor_flip)
1537 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1538 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1539 fuel_baralign = health_baralign;
1540 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1541 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1545 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1546 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1547 fuel_baralign = armor_baralign;
1548 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1549 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1554 if(autocvar_hud_panel_healtharmor_progressbar)
1556 float p_health, pain_health_alpha;
1558 pain_health_alpha = 1;
1559 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1561 if (autocvar_hud_panel_healtharmor_progressbar_gfx_smooth > 0)
1563 if (fabs(prev_health - health) >= autocvar_hud_panel_healtharmor_progressbar_gfx_smooth)
1565 if (time - old_p_healthtime < 1)
1566 old_p_health = prev_p_health;
1568 old_p_health = prev_health;
1569 old_p_healthtime = time;
1571 if (time - old_p_healthtime < 1)
1573 p_health += (old_p_health - health) * (1 - (time - old_p_healthtime));
1574 prev_p_health = p_health;
1577 if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0)
1579 if (prev_health - health >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
1581 if (time - health_damagetime >= 1)
1582 health_beforedamage = prev_health;
1583 health_damagetime = time;
1585 if (time - health_damagetime < 1)
1587 float health_damagealpha = 1 - (time - health_damagetime)*(time - health_damagetime);
1588 HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, health_beforedamage/maxhealth, is_vertical, health_baralign, autocvar_hud_progressbar_health_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * health_damagealpha, DRAWFLAG_NORMAL);
1591 prev_health = health;
1593 if (health <= autocvar_hud_panel_healtharmor_progressbar_gfx_lowhealth)
1595 float BLINK_FACTOR = 0.15;
1596 float BLINK_BASE = 0.85;
1597 float BLINK_FREQ = 9;
1598 pain_health_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
1601 HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, p_health/maxhealth, is_vertical, health_baralign, autocvar_hud_progressbar_health_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * pain_health_alpha, DRAWFLAG_NORMAL);
1603 if(autocvar_hud_panel_healtharmor_text)
1604 DrawNumIcon(pos + health_offset, mySize, health, "health", is_vertical, health_iconalign, HUD_Get_Num_Color(health, maxhealth), 1);
1609 if(autocvar_hud_panel_healtharmor_progressbar)
1613 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1615 if (autocvar_hud_panel_healtharmor_progressbar_gfx_smooth > 0)
1617 if (fabs(prev_armor - armor) >= autocvar_hud_panel_healtharmor_progressbar_gfx_smooth)
1619 if (time - old_p_armortime < 1)
1620 old_p_armor = prev_p_armor;
1622 old_p_armor = prev_armor;
1623 old_p_armortime = time;
1625 if (time - old_p_armortime < 1)
1627 p_armor += (old_p_armor - armor) * (1 - (time - old_p_armortime));
1628 prev_p_armor = p_armor;
1631 if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0)
1633 if (prev_armor - armor >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
1635 if (time - armor_damagetime >= 1)
1636 armor_beforedamage = prev_armor;
1637 armor_damagetime = time;
1639 if (time - armor_damagetime < 1)
1641 float armor_damagealpha = 1 - (time - armor_damagetime)*(time - armor_damagetime);
1642 HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, armor_beforedamage/maxarmor, is_vertical, armor_baralign, autocvar_hud_progressbar_armor_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * armor_damagealpha, DRAWFLAG_NORMAL);
1647 HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, p_armor/maxarmor, is_vertical, armor_baralign, autocvar_hud_progressbar_armor_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1649 if(autocvar_hud_panel_healtharmor_text)
1650 DrawNumIcon(pos + armor_offset, mySize, armor, "armor", is_vertical, armor_iconalign, HUD_Get_Num_Color(armor, maxarmor), 1);
1656 mySize.x *= 0.2 / 2; //if vertical always halve x to not cover too much numbers with 3 digits
1660 mySize.x *= 2; //restore full panel size
1661 else if (panel_ar < 1/4)
1662 mySize.y *= 2; //restore full panel size
1663 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
1670 // Notification area (#4)
1673 void HUD_Notify_Push(string icon, string attacker, string victim)
1681 if (notify_index == -1)
1682 notify_index = NOTIFY_MAX_ENTRIES-1;
1685 if (notify_attackers[notify_index])
1686 strunzone(notify_attackers[notify_index]);
1688 if (notify_victims[notify_index])
1689 strunzone(notify_victims[notify_index]);
1691 if (notify_icons[notify_index])
1692 strunzone(notify_icons[notify_index]);
1694 // Allocate new strings
1697 notify_attackers[notify_index] = strzone(attacker);
1698 notify_victims[notify_index] = strzone(victim);
1702 // In case of a notification without a victim, the attacker
1703 // is displayed on the victim's side. Instead of special
1704 // treatment later on, we can simply switch them here.
1705 notify_attackers[notify_index] = string_null;
1706 notify_victims[notify_index] = strzone(attacker);
1709 notify_icons[notify_index] = strzone(icon);
1710 notify_times[notify_index] = time;
1713 void HUD_Notify(void)
1715 if(intermission == 2) return;
1716 if (!autocvar__hud_configure)
1717 if (!autocvar_hud_panel_notify)
1720 HUD_Panel_UpdateCvars();
1721 HUD_Panel_DrawBg(1);
1723 if (!autocvar__hud_configure)
1724 if (notify_count == 0)
1731 if (panel_bg_padding)
1733 pos += '1 1 0' * panel_bg_padding;
1734 size -= '2 2 0' * panel_bg_padding;
1737 float fade_start = max(0, autocvar_hud_panel_notify_time);
1738 float fade_time = max(0, autocvar_hud_panel_notify_fadetime);
1739 float icon_aspect = max(1, autocvar_hud_panel_notify_icon_aspect);
1741 int entry_count = bound(1, floor(NOTIFY_MAX_ENTRIES * size.y / size.x), NOTIFY_MAX_ENTRIES);
1742 float entry_height = size.y / entry_count;
1744 float panel_width_half = size.x * 0.5;
1745 float icon_width_half = entry_height * icon_aspect / 2;
1746 float name_maxwidth = panel_width_half - icon_width_half - size.x * NOTIFY_ICON_MARGIN;
1748 vector font_size = '0.5 0.5 0' * entry_height * autocvar_hud_panel_notify_fontsize;
1749 vector icon_size = (eX * icon_aspect + eY) * entry_height;
1750 vector icon_left = eX * (panel_width_half - icon_width_half);
1751 vector attacker_right = eX * name_maxwidth;
1752 vector victim_left = eX * (size.x - name_maxwidth);
1754 vector attacker_pos, victim_pos, icon_pos;
1755 string attacker, victim, icon;
1756 int i, j, count, step, limit;
1759 if (autocvar_hud_panel_notify_flip)
1761 // Order items from the top down
1764 limit = entry_count;
1768 // Order items from the bottom up
1769 i = entry_count - 1;
1774 for (j = notify_index, count = 0; i != limit; i += step, ++j, ++count)
1776 if(autocvar__hud_configure)
1778 attacker = sprintf(_("Player %d"), count + 1);
1779 victim = sprintf(_("Player %d"), count + 2);
1780 icon = get_weaponinfo(min(WEP_FIRST + count * 2, WEP_LAST)).model2;
1781 alpha = bound(0, 1.2 - count / entry_count, 1);
1785 if (j == NOTIFY_MAX_ENTRIES)
1788 if (notify_times[j] + fade_start > time)
1790 else if (fade_time != 0)
1792 alpha = bound(0, (notify_times[j] + fade_start + fade_time - time) / fade_time, 1);
1799 attacker = notify_attackers[j];
1800 victim = notify_victims[j];
1801 icon = notify_icons[j];
1804 if (icon != "" && victim != "")
1806 vector name_top = eY * (i * entry_height + 0.5 * (entry_height - font_size.y));
1808 icon_pos = pos + icon_left + eY * i * entry_height;
1809 drawpic_aspect_skin(icon_pos, icon, icon_size, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1811 victim = textShortenToWidth(victim, name_maxwidth, font_size, stringwidth_colors);
1812 victim_pos = pos + victim_left + name_top;
1813 drawcolorcodedstring(victim_pos, victim, font_size, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1817 attacker = textShortenToWidth(attacker, name_maxwidth, font_size, stringwidth_colors);
1818 attacker_pos = pos + attacker_right - eX * stringwidth(attacker, true, font_size) + name_top;
1819 drawcolorcodedstring(attacker_pos, attacker, font_size, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1824 notify_count = count;
1827 void HUD_Timer(void)
1829 if(intermission == 2) return;
1830 if(!autocvar__hud_configure)
1832 if(!autocvar_hud_panel_timer) return;
1835 HUD_Panel_UpdateCvars();
1837 draw_beginBoldFont();
1841 mySize = panel_size;
1843 HUD_Panel_DrawBg(1);
1844 if(panel_bg_padding)
1846 pos += '1 1 0' * panel_bg_padding;
1847 mySize -= '2 2 0' * panel_bg_padding;
1851 float timelimit, elapsedTime, timeleft, minutesLeft;
1853 timelimit = getstatf(STAT_TIMELIMIT);
1855 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
1856 timeleft = ceil(timeleft);
1858 minutesLeft = floor(timeleft / 60);
1861 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
1862 timer_color = '1 1 1'; //white
1863 else if(minutesLeft >= 1)
1864 timer_color = '1 1 0'; //yellow
1866 timer_color = '1 0 0'; //red
1868 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
1869 if (time < getstatf(STAT_GAMESTARTTIME)) {
1870 //while restart is still active, show 00:00
1871 timer = seconds_tostring(0);
1873 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
1874 timer = seconds_tostring(elapsedTime);
1877 timer = seconds_tostring(timeleft);
1880 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
1888 float HUD_Radar_Clickable()
1890 return hud_panel_radar_mouse && !hud_panel_radar_temp_hidden;
1893 void HUD_Radar_Show_Maximized(bool doshow,float clickable)
1895 hud_panel_radar_maximized = doshow;
1896 hud_panel_radar_temp_hidden = 0;
1902 if(autocvar_hud_cursormode)
1904 hud_panel_radar_mouse = 1;
1907 else if ( hud_panel_radar_mouse )
1909 hud_panel_radar_mouse = 0;
1911 if(autocvar_hud_cursormode)
1916 void HUD_Radar_Hide_Maximized()
1918 HUD_Radar_Show_Maximized(false,false);
1922 float HUD_Radar_InputEvent(float bInputType, float nPrimary, float nSecondary)
1924 if(!hud_panel_radar_maximized || !hud_panel_radar_mouse ||
1925 autocvar__hud_configure || mv_active)
1930 mousepos_x = nPrimary;
1931 mousepos_y = nSecondary;
1935 if(nPrimary == K_MOUSE1)
1937 if(bInputType == 0) // key pressed
1938 mouseClicked |= S_MOUSE1;
1939 else if(bInputType == 1) // key released
1940 mouseClicked -= (mouseClicked & S_MOUSE1);
1942 else if(nPrimary == K_MOUSE2)
1944 if(bInputType == 0) // key pressed
1945 mouseClicked |= S_MOUSE2;
1946 else if(bInputType == 1) // key released
1947 mouseClicked -= (mouseClicked & S_MOUSE2);
1949 else if ( nPrimary == K_ESCAPE && bInputType == 0 )
1951 HUD_Radar_Hide_Maximized();
1955 // allow console/use binds to work without hiding the map
1959 con_keys = strcat(findkeysforcommand("toggleconsole", 0)," ",findkeysforcommand("+use", 0)) ;
1960 keys = tokenize(con_keys); // findkeysforcommand returns data for this
1961 for (i = 0; i < keys; ++i)
1963 if(nPrimary == stof(argv(i)))
1967 if ( getstati(STAT_HEALTH) <= 0 )
1970 if ( bInputType < 2 )
1972 con_keys = findkeysforcommand("+showscores", 0);
1973 keys = tokenize(con_keys);
1974 for (i = 0; i < keys; ++i)
1976 if ( nPrimary == stof(argv(i)) )
1978 hud_panel_radar_temp_hidden = bInputType == 0;
1984 else if ( bInputType == 0 )
1985 HUD_Radar_Hide_Maximized();
1993 void HUD_Radar_Mouse()
1995 if ( !hud_panel_radar_mouse ) return;
1996 if(mv_active) return;
2000 HUD_Radar_Hide_Maximized();
2004 if(mouseClicked & S_MOUSE2)
2006 HUD_Radar_Hide_Maximized();
2010 if(!autocvar_hud_cursormode)
2012 mousepos = mousepos + getmousepos() * autocvar_menu_mouse_speed;
2014 mousepos_x = bound(0, mousepos_x, vid_conwidth);
2015 mousepos_y = bound(0, mousepos_y, vid_conheight);
2018 HUD_Panel_UpdateCvars();
2021 panel_size = autocvar_hud_panel_radar_maximized_size;
2022 panel_size_x = bound(0.2, panel_size_x, 1) * vid_conwidth;
2023 panel_size_y = bound(0.2, panel_size_y, 1) * vid_conheight;
2024 panel_pos_x = (vid_conwidth - panel_size_x) / 2;
2025 panel_pos_y = (vid_conheight - panel_size_y) / 2;
2027 if(mouseClicked & S_MOUSE1)
2030 if ( mousepos_x < panel_pos_x || mousepos_x > panel_pos_x + panel_size_x ||
2031 mousepos_y < panel_pos_y || mousepos_y > panel_pos_y + panel_size_y )
2033 HUD_Radar_Hide_Maximized();
2036 vector pos = teamradar_texcoord_to_3dcoord(teamradar_2dcoord_to_texcoord(mousepos),view_origin_z);
2037 localcmd(sprintf("cmd ons_spawn %f %f %f",pos_x,pos_y,pos_z));
2039 HUD_Radar_Hide_Maximized();
2044 const vector cursor_size = '32 32 0';
2045 drawpic(mousepos-'8 4 0', strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursor_size, '1 1 1', 0.8, DRAWFLAG_NORMAL);
2048 void HUD_Radar(void)
2050 if(intermission == 2) return;
2051 if (!autocvar__hud_configure)
2053 if (hud_panel_radar_maximized)
2055 if (!hud_draw_maximized) return;
2059 if (autocvar_hud_panel_radar == 0) return;
2060 if (autocvar_hud_panel_radar != 2 && !teamplay) return;
2061 if(radar_panel_modified)
2063 panel.update_time = time; // forces reload of panel attributes
2064 radar_panel_modified = false;
2069 if ( hud_panel_radar_temp_hidden )
2072 HUD_Panel_UpdateCvars();
2076 if (hud_panel_radar_maximized && !autocvar__hud_configure)
2078 panel_size = autocvar_hud_panel_radar_maximized_size;
2079 panel_size.x = bound(0.2, panel_size.x, 1) * vid_conwidth;
2080 panel_size.y = bound(0.2, panel_size.y, 1) * vid_conheight;
2081 panel_pos.x = (vid_conwidth - panel_size.x) / 2;
2082 panel_pos.y = (vid_conheight - panel_size.y) / 2;
2085 panel_bg = strcat(hud_skin_path, "/border_default"); // always use the default border when maximized
2086 if(precache_pic(panel_bg) == "")
2087 panel_bg = "gfx/hud/default/border_default"; // fallback
2088 if(!radar_panel_modified && panel_bg != panel.current_panel_bg)
2089 radar_panel_modified = true;
2090 if(panel.current_panel_bg)
2091 strunzone(panel.current_panel_bg);
2092 panel.current_panel_bg = strzone(panel_bg);
2094 switch(hud_panel_radar_maximized_zoommode)
2098 f = current_zoomfraction;
2101 f = 1 - current_zoomfraction;
2111 switch(hud_panel_radar_maximized_rotation)
2114 teamradar_angle = view_angles.y - 90;
2117 teamradar_angle = 90 * hud_panel_radar_maximized_rotation;
2121 if (!hud_panel_radar_maximized && !autocvar__hud_configure)
2123 switch(hud_panel_radar_zoommode)
2127 f = current_zoomfraction;
2130 f = 1 - current_zoomfraction;
2140 switch(hud_panel_radar_rotation)
2143 teamradar_angle = view_angles.y - 90;
2146 teamradar_angle = 90 * hud_panel_radar_rotation;
2153 mySize = panel_size;
2155 HUD_Panel_DrawBg(1);
2156 if(panel_bg_padding)
2158 pos += '1 1 0' * panel_bg_padding;
2159 mySize -= '2 2 0' * panel_bg_padding;
2164 float scale2d, normalsize, bigsize;
2166 teamradar_origin2d = pos + 0.5 * mySize;
2167 teamradar_size2d = mySize;
2169 if(minimapname == "")
2172 teamradar_loadcvars();
2174 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
2175 teamradar_size2d = mySize;
2177 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
2179 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
2180 if((hud_panel_radar_rotation == 0 && !hud_panel_radar_maximized) || (hud_panel_radar_maximized_rotation == 0 && hud_panel_radar_maximized))
2182 // max-min distance must fit the radar in any rotation
2183 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_scale));
2187 vector c0, c1, c2, c3, span;
2188 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
2189 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
2190 c2 = rotate('1 0 0' * mi_min.x + '0 1 0' * mi_max.y, teamradar_angle * DEG2RAD);
2191 c3 = rotate('1 0 0' * mi_max.x + '0 1 0' * mi_min.y, teamradar_angle * DEG2RAD);
2193 span.x = max(c0_x, c1_x, c2_x, c3_x) - min(c0_x, c1_x, c2_x, c3_x);
2194 span.y = max(c0_y, c1_y, c2_y, c3_y) - min(c0_y, c1_y, c2_y, c3_y);
2196 // max-min distance must fit the radar in x=x, y=y
2198 teamradar_size2d.x * scale2d / (1.05 * span.x),
2199 teamradar_size2d.y * scale2d / (1.05 * span.y)
2203 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
2204 if(bigsize > normalsize)
2205 normalsize = bigsize;
2209 + (1 - f) * normalsize;
2210 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
2212 + (1 - f) * view_origin);
2221 draw_teamradar_background(hud_panel_radar_foreground_alpha);
2223 for(tm = world; (tm = find(tm, classname, "radarlink")); )
2224 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
2228 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
2230 if ( hud_panel_radar_mouse )
2231 if ( tm.health > 0 )
2232 if ( tm.team == myteam+1 )
2234 coord = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(tm.origin));
2235 if ( vlen(mousepos-coord) < 8 )
2237 brightcolor_x = min(1,tm.teamradar_color_x*1.5);
2238 brightcolor_y = min(1,tm.teamradar_color_y*1.5);
2239 brightcolor_z = min(1,tm.teamradar_color_z*1.5);
2240 drawpic(coord - '8 8 0', "gfx/teamradar_icon_glow", '16 16 0', brightcolor, panel_fg_alpha, 0);
2244 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
2246 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
2248 color2 = GetPlayerColor(tm.sv_entnum);
2249 //if(color == NUM_SPECTATOR || color == color2)
2250 draw_teamradar_player(tm.origin, tm.angles, Team_ColorRGB(color2));
2252 draw_teamradar_player(view_origin, view_angles, '1 1 1');
2254 drawresetcliparea();
2256 if ( hud_panel_radar_mouse )
2258 string message = "Click to select teleport destination";
2260 if ( getstati(STAT_HEALTH) <= 0 )
2262 message = "Click to select spawn location";
2265 drawcolorcodedstring(pos + '0.5 0 0' * (mySize_x - stringwidth(message, true, hud_fontsize)) - '0 1 0' * hud_fontsize_y * 2,
2266 message, hud_fontsize, hud_panel_radar_foreground_alpha, DRAWFLAG_NORMAL);
2268 hud_panel_radar_bottom = pos_y + mySize_y + hud_fontsize_y;
2274 void HUD_UpdatePlayerTeams();
2275 void HUD_Score_Rankings(vector pos, vector mySize, entity me)
2278 entity tm = world, pl;
2279 int SCOREPANEL_MAX_ENTRIES = 6;
2280 float SCOREPANEL_ASPECTRATIO = 2;
2281 int entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize.y/mySize.x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
2282 vector fontsize = '1 1 0' * (mySize.y/entries);
2284 vector rgb, score_color;
2286 score_color = '1 1 1';
2288 float name_size = mySize.x*0.75;
2289 float spacing_size = mySize.x*0.04;
2290 const float highlight_alpha = 0.2;
2291 int i = 0, first_pl = 0;
2292 bool me_printed = false;
2294 if (autocvar__hud_configure)
2296 float players_per_team = 0;
2299 // show team scores in the first line
2300 float score_size = mySize.x / team_count;
2301 players_per_team = max(2, ceil((entries - 1) / team_count));
2302 for(i=0; i<team_count; ++i) {
2303 if (i == floor((entries - 2) / players_per_team) || (entries == 1 && i == 0))
2304 HUD_Panel_DrawHighlight(pos + eX * score_size * i, eX * score_size + eY * fontsize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2305 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);
2308 pos.y += fontsize.y;
2310 score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
2311 for (i=first_pl; i<entries; ++i)
2313 //simulate my score is lower than all displayed players,
2314 //so that I don't appear at all showing pure rankings.
2315 //This is to better show the difference between the 2 ranking views
2316 if (i == entries-1 && autocvar_hud_panel_score_rankings == 1)
2319 drawfill(pos, eX * mySize.x + eY * fontsize.y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2320 s = GetPlayerName(player_localnum);
2325 s = sprintf(_("Player %d"), i + 1 - first_pl);
2330 score_color = Team_ColorRGB(ColorByTeam(floor((i - first_pl) / players_per_team))) * 0.8;
2331 s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
2332 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, true, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2333 drawstring(pos + eX * (name_size + spacing_size), ftos(score), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2334 pos.y += fontsize.y;
2339 if (!scoreboard_fade_alpha) // the scoreboard too calls HUD_UpdatePlayerTeams
2340 HUD_UpdatePlayerTeams();
2343 // show team scores in the first line
2344 float score_size = mySize.x / team_count;
2345 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2346 if(tm.team == NUM_SPECTATOR)
2348 if (tm.team == myteam)
2349 drawfill(pos + eX * score_size * i, eX * score_size + eY * fontsize.y, '1 1 1', highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2350 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);
2354 pos.y += fontsize.y;
2355 tm = teams.sort_next;
2360 for (pl = players.sort_next; pl && i<entries; pl = pl.sort_next)
2362 if ((team_count && pl.team != tm.team) || pl.team == NUM_SPECTATOR)
2365 if (i == entries-1 && !me_printed && pl != me)
2366 if (autocvar_hud_panel_score_rankings == 1 && spectatee_status != -1)
2368 for (pl = me.sort_next; pl; pl = pl.sort_next)
2369 if (pl.team != NUM_SPECTATOR)
2373 rgb = '1 1 0'; //not last but not among the leading players: yellow
2375 rgb = '1 0 0'; //last: red
2382 rgb = '0 1 0'; //first: green
2384 drawfill(pos, eX * mySize.x + eY * fontsize.y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2387 score_color = Team_ColorRGB(pl.team) * 0.8;
2388 s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
2389 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, true, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2390 drawstring(pos + eX * (name_size + spacing_size), ftos(pl.(scores[ps_primary])), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2391 pos.y += fontsize.y;
2394 while (i<entries && team_count && (tm = tm.sort_next) && (tm.team != NUM_SPECTATOR || (tm = tm.sort_next)));
2397 void HUD_Score(void)
2399 if(intermission == 2) return;
2400 if(!autocvar__hud_configure)
2402 if(!autocvar_hud_panel_score) return;
2403 if(spectatee_status == -1 && (gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) return;
2406 HUD_Panel_UpdateCvars();
2409 mySize = panel_size;
2411 HUD_Panel_DrawBg(1);
2412 if(panel_bg_padding)
2414 pos += '1 1 0' * panel_bg_padding;
2415 mySize -= '2 2 0' * panel_bg_padding;
2418 float score, distribution = 0;
2420 vector distribution_color;
2423 me = playerslots[current_player];
2425 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
2426 string timer, distrtimer;
2428 pl = players.sort_next;
2431 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
2432 if(pl.scores[ps_primary] == 0)
2435 score = me.(scores[ps_primary]);
2436 timer = TIME_ENCODED_TOSTRING(score);
2438 draw_beginBoldFont();
2439 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
2440 // distribution display
2441 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2443 distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS);
2445 if (distribution <= 0) {
2446 distribution_color = '0 1 0';
2450 distribution_color = '1 0 0';
2453 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);
2455 // race record display
2456 if (distribution <= 0)
2457 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2458 drawstring_aspect(pos, timer, eX * 0.75 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2460 } else if (!teamplay) { // non-teamgames
2461 if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings)
2463 HUD_Score_Rankings(pos, mySize, me);
2466 // me vector := [team/connected frags id]
2467 pl = players.sort_next;
2471 if(autocvar__hud_configure)
2474 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2478 score = me.(scores[ps_primary]);
2479 if(autocvar__hud_configure)
2482 if(distribution >= 5)
2483 distribution_color = eY;
2484 else if(distribution >= 0)
2485 distribution_color = '1 1 1';
2486 else if(distribution >= -5)
2487 distribution_color = '1 1 0';
2489 distribution_color = eX;
2491 string distribution_str;
2492 distribution_str = ftos(distribution);
2493 draw_beginBoldFont();
2494 if (distribution >= 0)
2496 if (distribution > 0)
2497 distribution_str = strcat("+", distribution_str);
2498 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2500 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize.x + eY * mySize.y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2501 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);
2503 } else { // teamgames
2504 float row, column, rows = 0, columns = 0;
2505 vector offset = '0 0 0';
2506 vector score_pos, score_size; //for scores other than myteam
2507 if(autocvar_hud_panel_score_rankings)
2509 HUD_Score_Rankings(pos, mySize, me);
2512 if(spectatee_status == -1)
2514 rows = HUD_GetRowCount(team_count, mySize, 3);
2515 columns = ceil(team_count/rows);
2516 score_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
2519 if(score_size.x/score_size.y > 3)
2521 newSize = 3 * score_size.y;
2522 offset.x = score_size.x - newSize;
2523 pos.x += offset.x/2;
2524 score_size.x = newSize;
2528 newSize = 1/3 * score_size.x;
2529 offset.y = score_size.y - newSize;
2530 pos.y += offset.y/2;
2531 score_size.y = newSize;
2535 score_size = eX * mySize.x*(1/4) + eY * mySize.y*(1/3);
2537 float max_fragcount;
2538 max_fragcount = -99;
2539 draw_beginBoldFont();
2541 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2542 if(tm.team == NUM_SPECTATOR)
2544 score = tm.(teamscores[ts_primary]);
2545 if(autocvar__hud_configure)
2548 if (score > max_fragcount)
2549 max_fragcount = score;
2551 if (spectatee_status == -1)
2553 score_pos = pos + eX * column * (score_size.x + offset.x) + eY * row * (score_size.y + offset.y);
2554 if (max_fragcount == score)
2555 HUD_Panel_DrawHighlight(score_pos, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2556 drawstring_aspect(score_pos, ftos(score), score_size, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2564 else if(tm.team == myteam) {
2565 if (max_fragcount == score)
2566 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2567 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize.x + eY * mySize.y, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2569 if (max_fragcount == score)
2570 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);
2571 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);
2581 void HUD_RaceTimer (void)
2583 if(intermission == 2) return;
2584 if(!autocvar__hud_configure)
2586 if(!autocvar_hud_panel_racetimer) return;
2587 if(!(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) return;
2588 if(spectatee_status == -1) return;
2591 HUD_Panel_UpdateCvars();
2595 mySize = panel_size;
2597 HUD_Panel_DrawBg(1);
2598 if(panel_bg_padding)
2600 pos += '1 1 0' * panel_bg_padding;
2601 mySize -= '2 2 0' * panel_bg_padding;
2604 // always force 4:1 aspect
2605 vector newSize = '0 0 0';
2606 if(mySize.x/mySize.y > 4)
2608 newSize.x = 4 * mySize.y;
2609 newSize.y = mySize.y;
2611 pos.x = pos.x + (mySize.x - newSize.x) / 2;
2615 newSize.y = 1/4 * mySize.x;
2616 newSize.x = mySize.x;
2618 pos.y = pos.y + (mySize.y - newSize.y) / 2;
2623 string s, forcetime;
2625 if(autocvar__hud_configure)
2628 draw_beginBoldFont();
2629 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);
2631 s = _("^1Intermediate 1 (+15.42)");
2632 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);
2633 s = sprintf(_("^1PENALTY: %.1f (%s)"), 2, "missing a checkpoint");
2634 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);
2636 else if(race_checkpointtime)
2638 a = bound(0, 2 - (time - race_checkpointtime), 1);
2641 if(a > 0) // just hit a checkpoint?
2643 if(race_checkpoint != 254)
2645 if(race_time && race_previousbesttime)
2646 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
2648 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
2650 forcetime = TIME_ENCODED_TOSTRING(race_time);
2655 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
2657 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
2658 if(a > 0) // next one?
2660 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
2665 if(s != "" && a > 0)
2667 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);
2670 if(race_penaltytime)
2672 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
2675 s = sprintf(_("^1PENALTY: %.1f (%s)"), race_penaltytime * 0.1, race_penaltyreason);
2676 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);
2680 draw_beginBoldFont();
2684 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
2685 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);
2690 if(race_laptime && race_checkpoint != 255)
2692 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
2693 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);
2700 if(race_mycheckpointtime)
2702 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
2703 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -(race_mycheckpointenemy == ""), race_mycheckpointlapsdelta, race_mycheckpointenemy);
2704 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);
2706 if(race_othercheckpointtime && race_othercheckpointenemy != "")
2708 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
2709 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -(race_othercheckpointenemy == ""), race_othercheckpointlapsdelta, race_othercheckpointenemy);
2710 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);
2713 if(race_penaltytime && !race_penaltyaccumulator)
2715 t = race_penaltytime * 0.1 + race_penaltyeventtime;
2716 a = bound(0, (1 + t - time), 1);
2720 s = sprintf(_("^1PENALTY: %.1f (%s)"), (t - time) * 0.1, race_penaltyreason);
2722 s = sprintf(_("^2PENALTY: %.1f (%s)"), 0, race_penaltyreason);
2723 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);
2734 if(intermission == 2) return;
2735 if(autocvar_cl_allow_uid2name == -1 && (gametype == MAPINFO_TYPE_CTS || gametype == MAPINFO_TYPE_RACE || (serverflags & SERVERFLAG_PLAYERSTATS)))
2738 if (autocvar__hud_configure)
2742 LOG_INFO(_("^1You must answer before entering hud configure mode\n"));
2743 cvar_set("_hud_configure", "0");
2745 if(vote_called_vote)
2746 strunzone(vote_called_vote);
2747 vote_called_vote = strzone(_("^2Name ^7instead of \"^1Anonymous player^7\" in stats"));
2748 uid2name_dialog = 1;
2751 if(!autocvar__hud_configure)
2753 if(!autocvar_hud_panel_vote) return;
2755 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
2756 panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha;
2758 if(panel_bg_alpha_str == "") {
2759 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
2761 panel_bg_alpha = stof(panel_bg_alpha_str);
2772 if(vote_active != vote_prev) {
2774 vote_prev = vote_active;
2777 if(vote_active || autocvar__hud_configure)
2778 vote_alpha = bound(0, (time - vote_change) * 2, 1);
2780 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
2785 HUD_Panel_UpdateCvars();
2789 panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight;
2790 panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight;
2793 // these must be below above block
2796 mySize = panel_size;
2798 a = vote_alpha * (vote_highlighted ? autocvar_hud_panel_vote_alreadyvoted_alpha : 1);
2799 HUD_Panel_DrawBg(a);
2800 a = panel_fg_alpha * a;
2802 if(panel_bg_padding)
2804 pos += '1 1 0' * panel_bg_padding;
2805 mySize -= '2 2 0' * panel_bg_padding;
2808 // always force 3:1 aspect
2809 vector newSize = '0 0 0';
2810 if(mySize.x/mySize.y > 3)
2812 newSize.x = 3 * mySize.y;
2813 newSize.y = mySize.y;
2815 pos.x = pos.x + (mySize.x - newSize.x) / 2;
2819 newSize.y = 1/3 * mySize.x;
2820 newSize.x = mySize.x;
2822 pos.y = pos.y + (mySize.y - newSize.y) / 2;
2826 s = _("A vote has been called for:");
2828 s = _("Allow servers to store and display your name?");
2829 drawstring_aspect(pos, s, eX * mySize.x + eY * (2/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
2830 s = textShortenToWidth(vote_called_vote, mySize.x, '1 1 0' * mySize.y * (1/8), stringwidth_colors);
2831 if(autocvar__hud_configure)
2832 s = _("^1Configure the HUD");
2833 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize.y, s, eX * mySize.x + eY * (1.75/8) * mySize.y, a, DRAWFLAG_NORMAL);
2835 // print the yes/no counts
2836 s = sprintf(_("Yes (%s): %d"), getcommandkey("vyes", "vyes"), vote_yescount);
2837 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);
2838 s = sprintf(_("No (%s): %d"), getcommandkey("vno", "vno"), vote_nocount);
2839 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);
2841 // draw the progress bar backgrounds
2842 drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_back", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
2844 // draw the highlights
2845 if(vote_highlighted == 1) {
2846 drawsetcliparea(pos.x, pos.y, mySize.x * 0.5, mySize.y);
2847 drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_voted", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
2849 else if(vote_highlighted == -1) {
2850 drawsetcliparea(pos.x + 0.5 * mySize.x, pos.y, mySize.x * 0.5, mySize.y);
2851 drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_voted", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
2854 // draw the progress bars
2855 if(vote_yescount && vote_needed)
2857 drawsetcliparea(pos.x, pos.y, mySize.x * 0.5 * (vote_yescount/vote_needed), mySize.y);
2858 drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_prog", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
2861 if(vote_nocount && vote_needed)
2863 drawsetcliparea(pos.x + mySize.x - mySize.x * 0.5 * (vote_nocount/vote_needed), pos.y, mySize.x * 0.5, mySize.y);
2864 drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_prog", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
2867 drawresetcliparea();
2870 // Mod icons panel (#10)
2873 bool mod_active; // is there any active mod icon?
2875 void DrawCAItem(vector myPos, vector mySize, float aspect_ratio, int layout, int i)
2879 vector color = '0 0 0';
2883 stat = getstati(STAT_REDALIVE);
2884 pic = "player_red.tga";
2888 stat = getstati(STAT_BLUEALIVE);
2889 pic = "player_blue.tga";
2893 stat = getstati(STAT_YELLOWALIVE);
2894 pic = "player_yellow.tga";
2899 stat = getstati(STAT_PINKALIVE);
2900 pic = "player_pink.tga";
2905 if(mySize.x/mySize.y > aspect_ratio)
2907 i = aspect_ratio * mySize.y;
2908 myPos.x = myPos.x + (mySize.x - i) / 2;
2913 i = 1/aspect_ratio * mySize.x;
2914 myPos.y = myPos.y + (mySize.y - i) / 2;
2920 drawpic_aspect_skin(myPos, pic, eX * 0.7 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2921 drawstring_aspect(myPos + eX * 0.7 * mySize.x, ftos(stat), eX * 0.3 * mySize.x + eY * mySize.y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
2924 drawstring_aspect(myPos, ftos(stat), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
2927 // Clan Arena and Freeze Tag HUD modicons
2928 void HUD_Mod_CA(vector myPos, vector mySize)
2930 mod_active = 1; // required in each mod function that always shows something
2933 if(gametype == MAPINFO_TYPE_CA)
2934 layout = autocvar_hud_panel_modicons_ca_layout;
2935 else //if(gametype == MAPINFO_TYPE_FREEZETAG)
2936 layout = autocvar_hud_panel_modicons_freezetag_layout;
2939 aspect_ratio = (layout) ? 2 : 1;
2940 rows = HUD_GetRowCount(team_count, mySize, aspect_ratio);
2941 columns = ceil(team_count/rows);
2944 float row = 0, column = 0;
2945 vector pos, itemSize;
2946 itemSize = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
2947 for(i=0; i<team_count; ++i)
2949 pos = myPos + eX * column * itemSize.x + eY * row * itemSize.y;
2951 DrawCAItem(pos, itemSize, aspect_ratio, layout, i);
2962 // CTF HUD modicon section
2963 int redflag_prevframe, blueflag_prevframe, yellowflag_prevframe, pinkflag_prevframe, neutralflag_prevframe; // status during previous frame
2964 int redflag_prevstatus, blueflag_prevstatus, yellowflag_prevstatus, pinkflag_prevstatus, neutralflag_prevstatus; // last remembered status
2965 float redflag_statuschange_time, blueflag_statuschange_time, yellowflag_statuschange_time, pinkflag_statuschange_time, neutralflag_statuschange_time; // time when the status changed
2967 void HUD_Mod_CTF_Reset(void)
2969 redflag_prevstatus = blueflag_prevstatus = yellowflag_prevstatus = pinkflag_prevstatus = neutralflag_prevstatus = 0;
2970 redflag_prevframe = blueflag_prevframe = yellowflag_prevframe = pinkflag_prevframe = neutralflag_prevframe = 0;
2971 redflag_statuschange_time = blueflag_statuschange_time = yellowflag_statuschange_time = pinkflag_statuschange_time = neutralflag_statuschange_time = 0;
2974 void HUD_Mod_CTF(vector pos, vector mySize)
2976 vector redflag_pos, blueflag_pos, yellowflag_pos, pinkflag_pos, neutralflag_pos;
2978 float f; // every function should have that
2980 int redflag, blueflag, yellowflag, pinkflag, neutralflag; // current status
2981 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime, yellowflag_statuschange_elapsedtime, pinkflag_statuschange_elapsedtime, neutralflag_statuschange_elapsedtime; // time since the status changed
2982 bool ctf_oneflag; // one-flag CTF mode enabled/disabled
2983 int stat_items = getstati(STAT_CTF_FLAGSTATUS, 0, 24);
2984 float fs, fs2, fs3, size1, size2;
2987 redflag = (stat_items/CTF_RED_FLAG_TAKEN) & 3;
2988 blueflag = (stat_items/CTF_BLUE_FLAG_TAKEN) & 3;
2989 yellowflag = (stat_items/CTF_YELLOW_FLAG_TAKEN) & 3;
2990 pinkflag = (stat_items/CTF_PINK_FLAG_TAKEN) & 3;
2991 neutralflag = (stat_items/CTF_NEUTRAL_FLAG_TAKEN) & 3;
2993 ctf_oneflag = (stat_items & CTF_FLAG_NEUTRAL);
2995 mod_active = (redflag || blueflag || yellowflag || pinkflag || neutralflag);
2997 if (autocvar__hud_configure) {
3000 if (team_count >= 3)
3002 if (team_count >= 4)
3004 ctf_oneflag = neutralflag = 0; // disable neutral flag in hud editor?
3007 // when status CHANGES, set old status into prevstatus and current status into status
3008 #define X(team) do { \
3009 if (team##flag != team##flag_prevframe) { \
3010 team##flag_statuschange_time = time; \
3011 team##flag_prevstatus = team##flag_prevframe; \
3012 team##flag_prevframe = team##flag; \
3014 team##flag_statuschange_elapsedtime = time - team##flag_statuschange_time; \
3023 const float BLINK_FACTOR = 0.15;
3024 const float BLINK_BASE = 0.85;
3026 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3028 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3030 const float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3032 #define X(team, cond) \
3033 string team##_icon, team##_icon_prevstatus; \
3034 int team##_alpha, team##_alpha_prevstatus; \
3035 team##_alpha = team##_alpha_prevstatus = 1; \
3037 switch (team##flag) { \
3038 case 1: team##_icon = "flag_" #team "_taken"; break; \
3039 case 2: team##_icon = "flag_" #team "_lost"; break; \
3040 case 3: team##_icon = "flag_" #team "_carrying"; team##_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; \
3042 if ((stat_items & CTF_SHIELDED) && (cond)) { \
3043 team##_icon = "flag_" #team "_shielded"; \
3045 team##_icon = string_null; \
3049 switch (team##flag_prevstatus) { \
3050 case 1: team##_icon_prevstatus = "flag_" #team "_taken"; break; \
3051 case 2: team##_icon_prevstatus = "flag_" #team "_lost"; break; \
3052 case 3: team##_icon_prevstatus = "flag_" #team "_carrying"; team##_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; \
3054 if (team##flag == 3) { \
3055 team##_icon_prevstatus = "flag_" #team "_carrying"; /* make it more visible */\
3056 } else if((stat_items & CTF_SHIELDED) && (cond)) { \
3057 team##_icon_prevstatus = "flag_" #team "_shielded"; \
3059 team##_icon_prevstatus = string_null; \
3064 X(red, myteam != NUM_TEAM_1);
3065 X(blue, myteam != NUM_TEAM_2);
3066 X(yellow, myteam != NUM_TEAM_3);
3067 X(pink, myteam != NUM_TEAM_4);
3072 // hacky, but these aren't needed
3073 red_icon = red_icon_prevstatus = blue_icon = blue_icon_prevstatus = yellow_icon = yellow_icon_prevstatus = pink_icon = pink_icon_prevstatus = string_null;
3075 } else switch (team_count) {
3077 case 2: fs = 0.5; fs2 = 0.5; fs3 = 0.5; break;
3078 case 3: fs = 1; fs2 = 0.35; fs3 = 0.35; break;
3079 case 4: fs = 0.75; fs2 = 0.25; fs3 = 0.5; break;
3082 if (mySize_x > mySize_y) {
3098 blueflag_pos = pos + eX * fs2 * size1;
3099 yellowflag_pos = pos - eX * fs2 * size1;
3100 pinkflag_pos = pos + eX * fs3 * size1;
3104 redflag_pos = pos + eX * fs2 * size1;
3106 yellowflag_pos = pos - eX * fs2 * size1;
3107 pinkflag_pos = pos + eX * fs3 * size1;
3111 redflag_pos = pos + eX * fs3 * size1;
3112 blueflag_pos = pos - eX * fs2 * size1;
3113 yellowflag_pos = pos;
3114 pinkflag_pos = pos + eX * fs2 * size1;
3118 redflag_pos = pos - eX * fs2 * size1;
3119 blueflag_pos = pos + eX * fs3 * size1;
3120 yellowflag_pos = pos + eX * fs2 * size1;
3125 neutralflag_pos = pos;
3126 flag_size = e1 * fs * size1 + e2 * size2;
3128 #define X(team) do { \
3129 f = bound(0, team##flag_statuschange_elapsedtime * 2, 1); \
3130 if (team##_icon_prevstatus && f < 1) \
3131 drawpic_aspect_skin_expanding(team##flag_pos, team##_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * team##_alpha_prevstatus, DRAWFLAG_NORMAL, f); \
3133 drawpic_aspect_skin(team##flag_pos, team##_icon, flag_size, '1 1 1', panel_fg_alpha * team##_alpha * f, DRAWFLAG_NORMAL); \
3143 // Keyhunt HUD modicon section
3146 void HUD_Mod_KH(vector pos, vector mySize)
3148 mod_active = 1; // keyhunt should never hide the mod icons panel
3150 // Read current state
3152 int state = getstati(STAT_KH_KEYS);
3154 int all_keys, team1_keys, team2_keys, team3_keys, team4_keys, dropped_keys, carrying_keys;
3155 all_keys = team1_keys = team2_keys = team3_keys = team4_keys = dropped_keys = carrying_keys = 0;
3157 for(i = 0; i < 4; ++i)
3159 key_state = (bitshift(state, i * -5) & 31) - 1;
3172 case NUM_TEAM_1: ++team1_keys; break;
3173 case NUM_TEAM_2: ++team2_keys; break;
3174 case NUM_TEAM_3: ++team3_keys; break;
3175 case NUM_TEAM_4: ++team4_keys; break;
3176 case 29: ++dropped_keys; break;
3182 // Calculate slot measurements
3186 if(all_keys == 4 && mySize.x * 0.5 < mySize.y && mySize.y * 0.5 < mySize.x)
3188 // Quadratic arrangement
3189 slot_size = eX * mySize.x * 0.5 + eY * mySize.y * 0.5;
3191 KH_SLOTS[1] = pos + eX * slot_size.x;
3192 KH_SLOTS[2] = pos + eY * slot_size.y;
3193 KH_SLOTS[3] = pos + eX * slot_size.x + eY * slot_size.y;
3197 if(mySize.x > mySize.y)
3199 // Horizontal arrangement
3200 slot_size = eX * mySize.x / all_keys + eY * mySize.y;
3201 for(i = 0; i < all_keys; ++i)
3202 KH_SLOTS[i] = pos + eX * slot_size.x * i;
3206 // Vertical arrangement
3207 slot_size = eX * mySize.x + eY * mySize.y / all_keys;
3208 for(i = 0; i < all_keys; ++i)
3209 KH_SLOTS[i] = pos + eY * slot_size.y * i;
3213 // Make icons blink in case of RUN HERE
3215 float blink = 0.6 + sin(2*M_PI*time) / 2.5; // Oscillate between 0.2 and 1
3222 case NUM_TEAM_1: if(team1_keys == all_keys) alpha = blink; break;
3223 case NUM_TEAM_2: if(team2_keys == all_keys) alpha = blink; break;
3224 case NUM_TEAM_3: if(team3_keys == all_keys) alpha = blink; break;
3225 case NUM_TEAM_4: if(team4_keys == all_keys) alpha = blink; break;
3233 if(myteam == NUM_TEAM_1 && carrying_keys)
3235 drawpic_aspect_skin(KH_SLOTS[i++], "kh_red_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
3239 drawpic_aspect_skin(KH_SLOTS[i++], "kh_red_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
3242 if(myteam == NUM_TEAM_2 && carrying_keys)
3244 drawpic_aspect_skin(KH_SLOTS[i++], "kh_blue_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
3248 drawpic_aspect_skin(KH_SLOTS[i++], "kh_blue_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
3251 if(myteam == NUM_TEAM_3 && carrying_keys)
3253 drawpic_aspect_skin(KH_SLOTS[i++], "kh_yellow_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
3257 drawpic_aspect_skin(KH_SLOTS[i++], "kh_yellow_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
3260 if(myteam == NUM_TEAM_4 && carrying_keys)
3262 drawpic_aspect_skin(KH_SLOTS[i++], "kh_pink_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
3266 drawpic_aspect_skin(KH_SLOTS[i++], "kh_pink_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
3268 while(dropped_keys--)
3269 drawpic_aspect_skin(KH_SLOTS[i++], "kh_dropped", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
3272 // Keepaway HUD mod icon
3273 int kaball_prevstatus; // last remembered status
3274 float kaball_statuschange_time; // time when the status changed
3276 // we don't need to reset for keepaway since it immediately
3277 // autocorrects prevstatus as to if the player has the ball or not
3279 void HUD_Mod_Keepaway(vector pos, vector mySize)
3281 mod_active = 1; // keepaway should always show the mod HUD
3283 float BLINK_FACTOR = 0.15;
3284 float BLINK_BASE = 0.85;
3285 float BLINK_FREQ = 5;
3286 float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
3288 int stat_items = getstati(STAT_ITEMS, 0, 24);
3289 int kaball = (stat_items/IT_KEY1) & 1;
3291 if(kaball != kaball_prevstatus)
3293 kaball_statuschange_time = time;
3294 kaball_prevstatus = kaball;
3297 vector kaball_pos, kaball_size;
3299 if(mySize.x > mySize.y) {
3300 kaball_pos = pos + eX * 0.25 * mySize.x;
3301 kaball_size = eX * 0.5 * mySize.x + eY * mySize.y;
3303 kaball_pos = pos + eY * 0.25 * mySize.y;
3304 kaball_size = eY * 0.5 * mySize.y + eX * mySize.x;
3307 float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
3308 float f = bound(0, kaball_statuschange_elapsedtime*2, 1);
3310 if(kaball_prevstatus && f < 1)
3311 drawpic_aspect_skin_expanding(kaball_pos, "keepawayball_carrying", kaball_size, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f);
3314 drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
3318 // Nexball HUD mod icon
3319 void HUD_Mod_NexBall(vector pos, vector mySize)
3321 float nb_pb_starttime, dt, p;
3324 stat_items = getstati(STAT_ITEMS, 0, 24);
3325 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3327 if (stat_items & IT_KEY1)
3332 //Manage the progress bar if any
3333 if (nb_pb_starttime > 0)
3335 dt = (time - nb_pb_starttime) % nb_pb_period;
3336 // one period of positive triangle
3337 p = 2 * dt / nb_pb_period;
3341 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, (mySize.x <= mySize.y), 0, autocvar_hud_progressbar_nexball_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3344 if (stat_items & IT_KEY1)
3345 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3348 // Race/CTS HUD mod icons
3349 float crecordtime_prev; // last remembered crecordtime
3350 float crecordtime_change_time; // time when crecordtime last changed
3351 float srecordtime_prev; // last remembered srecordtime
3352 float srecordtime_change_time; // time when srecordtime last changed
3354 float race_status_time;
3355 int race_status_prev;
3356 string race_status_name_prev;
3357 void HUD_Mod_Race(vector pos, vector mySize)
3359 mod_active = 1; // race should never hide the mod icons panel
3361 me = playerslots[player_localnum];
3363 float f; // yet another function has this
3364 score = me.(scores[ps_primary]);
3366 if(!(scores_flags[ps_primary] & SFL_TIME) || teamplay) // race/cts record display on HUD
3367 return; // no records in the actual race
3369 // clientside personal record
3371 if(gametype == MAPINFO_TYPE_CTS)
3375 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3377 if(score && (score < t || !t)) {
3378 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3379 if(autocvar_cl_autodemo_delete_keeprecords)
3381 f = autocvar_cl_autodemo_delete;
3383 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3387 if(t != crecordtime_prev) {
3388 crecordtime_prev = t;
3389 crecordtime_change_time = time;
3392 vector textPos, medalPos;
3394 if(mySize.x > mySize.y) {
3395 // text on left side
3396 squareSize = min(mySize.y, mySize.x/2);
3397 textPos = pos + eX * 0.5 * max(0, mySize.x/2 - squareSize) + eY * 0.5 * (mySize.y - squareSize);
3398 medalPos = pos + eX * 0.5 * max(0, mySize.x/2 - squareSize) + eX * 0.5 * mySize.x + eY * 0.5 * (mySize.y - squareSize);
3401 squareSize = min(mySize.x, mySize.y/2);
3402 textPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eX * 0.5 * (mySize.x - squareSize);
3403 medalPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eY * 0.5 * mySize.y + eX * 0.5 * (mySize.x - squareSize);
3406 f = time - crecordtime_change_time;
3409 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3410 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);
3412 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3413 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);
3414 drawstring_aspect_expanding(pos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
3415 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);
3419 t = race_server_record;
3420 if(t != srecordtime_prev) {
3421 srecordtime_prev = t;
3422 srecordtime_change_time = time;
3424 f = time - srecordtime_change_time;
3427 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3428 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);
3430 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3431 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);
3432 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);
3433 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);
3436 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
3437 race_status_time = time + 5;
3438 race_status_prev = race_status;
3439 if (race_status_name_prev)
3440 strunzone(race_status_name_prev);
3441 race_status_name_prev = strzone(race_status_name);
3446 a = bound(0, race_status_time - time, 1);
3449 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
3453 rank = race_CheckName(race_status_name);
3457 rankname = count_ordinal(rank);
3460 namepos = medalPos + '0 0.8 0' * squareSize;
3462 rankpos = medalPos + '0 0.15 0' * squareSize;
3464 if(race_status == 0)
3465 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3466 else if(race_status == 1) {
3467 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);
3468 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3469 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3470 } else if(race_status == 2) {
3471 if(race_status_name == GetPlayerName(player_localnum) || !race_myrank || race_myrank < rank)
3472 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);
3474 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);
3475 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3476 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3477 } else if(race_status == 3) {
3478 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);
3479 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3480 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3483 if (race_status_time - time <= 0) {
3484 race_status_prev = -1;
3486 if(race_status_name)
3487 strunzone(race_status_name);
3488 race_status_name = string_null;
3489 if(race_status_name_prev)
3490 strunzone(race_status_name_prev);
3491 race_status_name_prev = string_null;
3495 void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, int layout, int i)
3499 vector color = '0 0 0';
3503 stat = getstatf(STAT_DOM_PPS_RED);
3504 pic = "dom_icon_red";
3508 stat = getstatf(STAT_DOM_PPS_BLUE);
3509 pic = "dom_icon_blue";
3513 stat = getstatf(STAT_DOM_PPS_YELLOW);
3514 pic = "dom_icon_yellow";
3519 stat = getstatf(STAT_DOM_PPS_PINK);
3520 pic = "dom_icon_pink";
3524 float pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS);
3526 if(mySize.x/mySize.y > aspect_ratio)
3528 i = aspect_ratio * mySize.y;
3529 myPos.x = myPos.x + (mySize.x - i) / 2;
3534 i = 1/aspect_ratio * mySize.x;
3535 myPos.y = myPos.y + (mySize.y - i) / 2;
3539 if (layout) // show text too
3542 color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
3543 if (layout == 2) // average pps
3544 drawstring_aspect(myPos + eX * mySize.y, ftos_decimals(stat, 2), eX * (2/3) * mySize.x + eY * mySize.y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
3545 else // percentage of average pps
3546 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);
3550 drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3553 drawsetcliparea(myPos.x, myPos.y + mySize.y * (1 - pps_ratio), mySize.y, mySize.y * pps_ratio);
3554 drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3555 drawresetcliparea();
3559 void HUD_Mod_Dom(vector myPos, vector mySize)
3561 mod_active = 1; // required in each mod function that always shows something
3563 int layout = autocvar_hud_panel_modicons_dom_layout;
3566 aspect_ratio = (layout) ? 3 : 1;
3567 rows = HUD_GetRowCount(team_count, mySize, aspect_ratio);
3568 columns = ceil(team_count/rows);
3571 float row = 0, column = 0;
3572 vector pos, itemSize;
3573 itemSize = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
3574 for(i=0; i<team_count; ++i)
3576 pos = myPos + eX * column * itemSize.x + eY * row * itemSize.y;
3578 DrawDomItem(pos, itemSize, aspect_ratio, layout, i);
3589 void HUD_ModIcons_SetFunc()
3593 case MAPINFO_TYPE_KEYHUNT: HUD_ModIcons_GameType = HUD_Mod_KH; break;
3594 case MAPINFO_TYPE_CTF: HUD_ModIcons_GameType = HUD_Mod_CTF; break;
3595 case MAPINFO_TYPE_NEXBALL: HUD_ModIcons_GameType = HUD_Mod_NexBall; break;
3596 case MAPINFO_TYPE_CTS:
3597 case MAPINFO_TYPE_RACE: HUD_ModIcons_GameType = HUD_Mod_Race; break;
3598 case MAPINFO_TYPE_CA:
3599 case MAPINFO_TYPE_FREEZETAG: HUD_ModIcons_GameType = HUD_Mod_CA; break;
3600 case MAPINFO_TYPE_DOMINATION: HUD_ModIcons_GameType = HUD_Mod_Dom; break;
3601 case MAPINFO_TYPE_KEEPAWAY: HUD_ModIcons_GameType = HUD_Mod_Keepaway; break;
3605 int mod_prev; // previous state of mod_active to check for a change
3607 float mod_change; // "time" when mod_active changed
3609 void HUD_ModIcons(void)
3611 if(intermission == 2) return;
3612 if(!autocvar__hud_configure)
3614 if(!autocvar_hud_panel_modicons) return;
3615 if(!HUD_ModIcons_GameType) return;
3618 HUD_Panel_UpdateCvars();
3620 draw_beginBoldFont();
3622 if(mod_active != mod_prev) {
3624 mod_prev = mod_active;
3627 if(mod_active || autocvar__hud_configure)
3628 mod_alpha = bound(0, (time - mod_change) * 2, 1);
3630 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
3633 HUD_Panel_DrawBg(mod_alpha);
3635 if(panel_bg_padding)
3637 panel_pos += '1 1 0' * panel_bg_padding;
3638 panel_size -= '2 2 0' * panel_bg_padding;
3641 if(autocvar__hud_configure)
3642 HUD_Mod_CTF(panel_pos, panel_size);
3644 HUD_ModIcons_GameType(panel_pos, panel_size);
3649 // Draw pressed keys (#11)
3651 void HUD_PressedKeys(void)
3653 if(intermission == 2) return;
3654 if(!autocvar__hud_configure)
3656 if(!autocvar_hud_panel_pressedkeys) return;
3657 if(spectatee_status <= 0 && autocvar_hud_panel_pressedkeys < 2) return;
3660 HUD_Panel_UpdateCvars();
3663 mySize = panel_size;
3665 HUD_Panel_DrawBg(1);
3666 if(panel_bg_padding)
3668 pos += '1 1 0' * panel_bg_padding;
3669 mySize -= '2 2 0' * panel_bg_padding;
3672 // force custom aspect
3673 float aspect = autocvar_hud_panel_pressedkeys_aspect;
3676 vector newSize = '0 0 0';
3677 if(mySize.x/mySize.y > aspect)
3679 newSize.x = aspect * mySize.y;
3680 newSize.y = mySize.y;
3682 pos.x = pos.x + (mySize.x - newSize.x) / 2;
3686 newSize.y = 1/aspect * mySize.x;
3687 newSize.x = mySize.x;
3689 pos.y = pos.y + (mySize.y - newSize.y) / 2;
3695 keysize = eX * mySize.x * (1/3.0) + eY * mySize.y * (1/(3.0 - !autocvar_hud_panel_pressedkeys_attack));
3697 pressedkeys = getstatf(STAT_PRESSED_KEYS);
3699 if(autocvar_hud_panel_pressedkeys_attack)
3701 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);
3702 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);
3706 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3707 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);
3708 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);
3710 drawpic_aspect_skin(pos, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3711 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);
3712 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);
3715 // Handle chat as a panel (#12)
3719 if(!autocvar__hud_configure)
3721 if (!autocvar_hud_panel_chat)
3723 if (!autocvar_con_chatrect)
3724 cvar_set("con_chatrect", "0");
3727 if(autocvar__con_chat_maximized)
3729 if(!hud_draw_maximized) return;
3731 else if(chat_panel_modified)
3733 panel.update_time = time; // forces reload of panel attributes
3734 chat_panel_modified = false;
3738 HUD_Panel_UpdateCvars();
3740 if(intermission == 2)
3742 // reserve some more space to the mapvote panel
3743 // by resizing and moving chat panel to the bottom
3744 panel_size.y = min(panel_size.y, vid_conheight * 0.2);
3745 panel_pos.y = vid_conheight - panel_size.y - panel_bg_border * 2;
3746 chat_posy = panel_pos.y;
3747 chat_sizey = panel_size.y;
3749 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
3751 panel_pos.y = panel_bg_border;
3752 panel_size.y = vid_conheight - panel_bg_border * 2;
3753 if(panel.current_panel_bg == "0") // force a border when maximized
3756 panel_bg = strcat(hud_skin_path, "/border_default");
3757 if(precache_pic(panel_bg) == "")
3758 panel_bg = "gfx/hud/default/border_default";
3759 if(panel.current_panel_bg)
3760 strunzone(panel.current_panel_bg);
3761 panel.current_panel_bg = strzone(panel_bg);
3762 chat_panel_modified = true;
3764 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an theAlpha of at least 0.75
3769 mySize = panel_size;
3771 HUD_Panel_DrawBg(1);
3773 if(panel_bg_padding)
3775 pos += '1 1 0' * panel_bg_padding;
3776 mySize -= '2 2 0' * panel_bg_padding;
3779 if (!autocvar_con_chatrect)
3780 cvar_set("con_chatrect", "1");
3782 cvar_set("con_chatrect_x", ftos(pos.x/vid_conwidth));
3783 cvar_set("con_chatrect_y", ftos(pos.y/vid_conheight));
3785 cvar_set("con_chatwidth", ftos(mySize.x/vid_conwidth));
3786 cvar_set("con_chat", ftos(floor(mySize.y/autocvar_con_chatsize - 0.5)));
3788 if(autocvar__hud_configure)
3791 chatsize = '1 1 0' * autocvar_con_chatsize;
3792 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over theAlpha and such
3794 for(i = 0; i < autocvar_con_chat; ++i)
3796 if(i == autocvar_con_chat - 1)
3799 a = panel_fg_alpha * floor(((i + 1) * 7 + autocvar_con_chattime)/45);
3800 drawcolorcodedstring(pos, textShortenToWidth(_("^3Player^7: This is the chat area."), mySize.x, chatsize, stringwidth_colors), chatsize, a, DRAWFLAG_NORMAL);
3801 pos.y += chatsize.y;
3806 // Engine info panel (#13)
3813 float frametimeavg1; // 1 frame ago
3814 float frametimeavg2; // 2 frames ago
3815 void HUD_EngineInfo(void)
3817 //if(intermission == 2) return;
3818 if(!autocvar__hud_configure)
3820 if(!autocvar_hud_panel_engineinfo) return;
3823 HUD_Panel_UpdateCvars();
3826 mySize = panel_size;
3828 HUD_Panel_DrawBg(1);
3829 if(panel_bg_padding)
3831 pos += '1 1 0' * panel_bg_padding;
3832 mySize -= '2 2 0' * panel_bg_padding;
3835 float currentTime = gettime(GETTIME_REALTIME);
3836 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
3838 float currentframetime = currentTime - prevfps_time;
3839 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
3840 frametimeavg2 = frametimeavg1;
3841 frametimeavg1 = frametimeavg;
3844 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
3845 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.
3847 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
3848 prevfps = (1/currentframetime);
3849 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"
3851 prevfps_time = currentTime;
3856 if(currentTime - prevfps_time > autocvar_hud_panel_engineinfo_framecounter_time)
3858 prevfps = framecounter/(currentTime - prevfps_time);
3860 prevfps_time = currentTime;
3865 color = HUD_Get_Num_Color (prevfps, 100);
3866 drawstring_aspect(pos, sprintf(_("FPS: %.*f"), autocvar_hud_panel_engineinfo_framecounter_decimals, prevfps), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
3869 // Info messages panel (#14)
3871 #define drawInfoMessage(s) do { \
3872 if(autocvar_hud_panel_infomessages_flip) \
3873 o.x = pos.x + mySize.x - stringwidth(s, true, fontsize); \
3874 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL); \
3875 o.y += fontsize.y; \
3877 void HUD_InfoMessages(void)
3879 if(intermission == 2) return;
3880 if(!autocvar__hud_configure)
3882 if(!autocvar_hud_panel_infomessages) return;
3885 HUD_Panel_UpdateCvars();
3888 mySize = panel_size;
3890 HUD_Panel_DrawBg(1);
3891 if(panel_bg_padding)
3893 pos += '1 1 0' * panel_bg_padding;
3894 mySize -= '2 2 0' * panel_bg_padding;
3897 // always force 5:1 aspect
3898 vector newSize = '0 0 0';
3899 if(mySize.x/mySize.y > 5)
3901 newSize.x = 5 * mySize.y;
3902 newSize.y = mySize.y;
3904 pos.x = pos.x + (mySize.x - newSize.x) / 2;
3908 newSize.y = 1/5 * mySize.x;
3909 newSize.x = mySize.x;
3911 pos.y = pos.y + (mySize.y - newSize.y) / 2;
3920 fontsize = '0.20 0.20 0' * mySize.y;
3926 if(!autocvar__hud_configure)
3928 if(spectatee_status && !intermission)
3931 if(spectatee_status == -1)
3932 s = _("^1Observing");
3934 s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(current_player));
3937 if(spectatee_status == -1)
3938 s = sprintf(_("^1Press ^3%s^1 to spectate"), getcommandkey("primary fire", "+fire"));
3940 s = sprintf(_("^1Press ^3%s^1 or ^3%s^1 for next or previous player"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
3943 if(spectatee_status == -1)
3944 s = sprintf(_("^1Use ^3%s^1 or ^3%s^1 to change the speed"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
3946 s = sprintf(_("^1Press ^3%s^1 to observe"), getcommandkey("secondary fire", "+fire2"));
3949 s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey("server info", "+show_info"));
3952 if(gametype == MAPINFO_TYPE_LMS)
3955 sk = playerslots[player_localnum];
3956 if(sk.(scores[ps_primary]) >= 666)
3957 s = _("^1Match has already begun");
3958 else if(sk.(scores[ps_primary]) > 0)
3959 s = _("^1You have no more lives left");
3961 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
3964 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
3967 //show restart countdown:
3968 if (time < getstatf(STAT_GAMESTARTTIME)) {
3970 //we need to ceil, otherwise the countdown would be off by .5 when using round()
3971 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
3972 s = sprintf(_("^1Game starts in ^3%d^1 seconds"), countdown);
3973 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
3977 if(warmup_stage && !intermission)
3979 s = _("^2Currently in ^1warmup^2 stage!");
3989 if(ready_waiting && !intermission && !spectatee_status)
3991 if(ready_waiting_for_me)
3994 s = sprintf(_("%sPress ^3%s%s to end warmup"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
3996 s = sprintf(_("%sPress ^3%s%s once you are ready"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
4001 s = _("^2Waiting for others to ready up to end warmup...");
4003 s = _("^2Waiting for others to ready up...");
4007 else if(warmup_stage && !intermission && !spectatee_status)
4009 s = sprintf(_("^2Press ^3%s^2 to end warmup"), getcommandkey("ready", "ready"));
4013 if(teamplay && !intermission && !spectatee_status && gametype != MAPINFO_TYPE_CA && teamnagger)
4015 float ts_min = 0, ts_max = 0;
4016 tm = teams.sort_next;
4019 for (; tm.sort_next; tm = tm.sort_next)
4021 if(!tm.team_size || tm.team == NUM_SPECTATOR)
4023 if(!ts_min) ts_min = tm.team_size;
4024 else ts_min = min(ts_min, tm.team_size);
4025 if(!ts_max) ts_max = tm.team_size;
4026 else ts_max = max(ts_max, tm.team_size);
4028 if ((ts_max - ts_min) > 1)
4030 s = strcat(blinkcolor, _("Teamnumbers are unbalanced!"));
4031 tm = GetTeam(myteam, false);
4033 if (tm.team != NUM_SPECTATOR)
4034 if (tm.team_size == ts_max)
4035 s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey("team menu", "menu_showteamselect"), blinkcolor));
4043 s = _("^7Press ^3ESC ^7to show HUD options.");
4045 s = _("^3Doubleclick ^7a panel for panel-specific options.");
4047 s = _("^3CTRL ^7to disable collision testing, ^3SHIFT ^7and");
4049 s = _("^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.");
4054 // Physics panel (#15)
4056 vector acc_prevspeed;
4057 float acc_prevtime, acc_avg, top_speed, top_speed_time;
4058 float physics_update_time, discrete_speed, discrete_acceleration;
4059 void HUD_Physics(void)
4061 if(intermission == 2) return;
4062 if(!autocvar__hud_configure)
4064 if(!autocvar_hud_panel_physics) return;
4065 if(spectatee_status == -1 && (autocvar_hud_panel_physics == 1 || autocvar_hud_panel_physics == 3)) return;
4066 if(autocvar_hud_panel_physics == 3 && !(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) return;
4069 HUD_Panel_UpdateCvars();
4071 draw_beginBoldFont();
4073 HUD_Panel_DrawBg(1);
4074 if(panel_bg_padding)
4076 panel_pos += '1 1 0' * panel_bg_padding;
4077 panel_size -= '2 2 0' * panel_bg_padding;
4080 float acceleration_progressbar_scale = 0;
4081 if(autocvar_hud_panel_physics_progressbar && autocvar_hud_panel_physics_acceleration_progressbar_scale > 1)
4082 acceleration_progressbar_scale = autocvar_hud_panel_physics_acceleration_progressbar_scale;
4085 if (autocvar_hud_panel_physics_text_scale <= 0)
4088 text_scale = min(autocvar_hud_panel_physics_text_scale, 1);
4091 float speed, conversion_factor;
4094 switch(autocvar_hud_panel_physics_speed_unit)
4099 conversion_factor = 1.0;
4103 conversion_factor = 0.0254;
4107 conversion_factor = 0.0254 * 3.6;
4111 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4115 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4119 vector vel = (csqcplayer ? csqcplayer.velocity : pmove_vel);
4121 float max_speed = floor( autocvar_hud_panel_physics_speed_max * conversion_factor + 0.5 );
4122 if (autocvar__hud_configure)
4123 speed = floor( max_speed * 0.65 + 0.5 );
4124 else if(autocvar_hud_panel_physics_speed_vertical)
4125 speed = floor( vlen(vel) * conversion_factor + 0.5 );
4127 speed = floor( vlen(vel - vel.z * '0 0 1') * conversion_factor + 0.5 );
4129 //compute acceleration
4130 float acceleration, f;
4131 if (autocvar__hud_configure)
4132 acceleration = autocvar_hud_panel_physics_acceleration_max * 0.3;
4135 // 1 m/s = 0.0254 qu/s; 1 g = 9.80665 m/s^2
4136 f = time - acc_prevtime;
4137 if(autocvar_hud_panel_physics_acceleration_vertical)
4138 acceleration = (vlen(vel) - vlen(acc_prevspeed));
4140 acceleration = (vlen(vel - '0 0 1' * vel.z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed.z));
4142 acceleration = acceleration * (1 / max(0.0001, f)) * (0.0254 / 9.80665);
4144 acc_prevspeed = vel;
4145 acc_prevtime = time;
4147 if(autocvar_hud_panel_physics_acceleration_movingaverage)
4149 f = bound(0, f * 10, 1);
4150 acc_avg = acc_avg * (1 - f) + acceleration * f;
4151 acceleration = acc_avg;
4155 int acc_decimals = 2;
4156 if(time > physics_update_time)
4158 // workaround for ftos_decimals returning a negative 0
4159 if(discrete_acceleration > -1 / pow(10, acc_decimals) && discrete_acceleration < 0)
4160 discrete_acceleration = 0;
4161 discrete_acceleration = acceleration;
4162 discrete_speed = speed;
4163 physics_update_time += autocvar_hud_panel_physics_update_interval;
4167 float panel_ar = panel_size.x/panel_size.y;
4168 vector speed_offset = '0 0 0', acceleration_offset = '0 0 0';
4169 if (panel_ar >= 5 && !acceleration_progressbar_scale)
4171 panel_size.x *= 0.5;
4172 if (autocvar_hud_panel_physics_flip)
4173 speed_offset.x = panel_size.x;
4175 acceleration_offset.x = panel_size.x;
4179 panel_size.y *= 0.5;
4180 if (autocvar_hud_panel_physics_flip)
4181 speed_offset.y = panel_size.y;
4183 acceleration_offset.y = panel_size.y;
4185 int speed_baralign, acceleration_baralign;
4186 if (autocvar_hud_panel_physics_baralign == 1)
4187 acceleration_baralign = speed_baralign = 1;
4188 else if(autocvar_hud_panel_physics_baralign == 4)
4189 acceleration_baralign = speed_baralign = 2;
4190 else if (autocvar_hud_panel_physics_flip)
4192 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 2);
4193 speed_baralign = (autocvar_hud_panel_physics_baralign == 3);
4197 speed_baralign = (autocvar_hud_panel_physics_baralign == 2);
4198 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 3);
4200 if (autocvar_hud_panel_physics_acceleration_progressbar_mode == 0)
4201 acceleration_baralign = 3; //override hud_panel_physics_baralign value for acceleration
4205 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
4206 HUD_Panel_DrawProgressBar(panel_pos + speed_offset, panel_size, "progressbar", speed/max_speed, 0, speed_baralign, autocvar_hud_progressbar_speed_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4207 vector tmp_offset = '0 0 0', tmp_size = '0 0 0';
4208 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
4210 tmp_size.x = panel_size.x * 0.75;
4211 tmp_size.y = panel_size.y * text_scale;
4213 tmp_offset.x = panel_size.x - tmp_size.x;
4216 tmp_offset.y = (panel_size.y - tmp_size.y) / 2;
4217 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(discrete_speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4223 tmp_offset.x = tmp_size.x;
4224 if (autocvar_hud_panel_physics_speed_unit_show)
4227 tmp_size.x = panel_size.x * (1 - 0.75);
4228 tmp_size.y = panel_size.y * 0.4 * text_scale;
4229 tmp_offset.y = (panel_size.y * 0.4 - tmp_size.y) / 2;
4230 drawstring_aspect(panel_pos + speed_offset + tmp_offset, unit, tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4234 //compute and draw top speed
4235 if (autocvar_hud_panel_physics_topspeed)
4236 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
4238 if (autocvar__hud_configure)
4240 top_speed = floor( max_speed * 0.75 + 0.5 );
4245 if (speed >= top_speed)
4248 top_speed_time = time;
4252 f = max(1, autocvar_hud_panel_physics_topspeed_time);
4253 // divide by f to make it start from 1
4254 f = cos( ((time - top_speed_time) / f) * PI/2 );
4256 else //hide top speed 0, it would be stupid
4261 //top speed progressbar peak
4262 if(speed < top_speed)
4263 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
4266 vector peak_size = '0 0 0';
4267 if (speed_baralign == 0)
4268 peak_offsetX = min(top_speed, max_speed)/max_speed * panel_size.x;
4269 else if (speed_baralign == 1)
4270 peak_offsetX = (1 - min(top_speed, max_speed)/max_speed) * panel_size.x;
4271 else // if (speed_baralign == 2)
4272 peak_offsetX = min(top_speed, max_speed)/max_speed * panel_size.x * 0.5;
4273 peak_size.x = floor(panel_size.x * 0.01 + 1.5);
4274 peak_size.y = panel_size.y;
4275 if (speed_baralign == 2) // draw two peaks, on both sides
4277 drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size.x + peak_offsetX - peak_size.x), peak_size, autocvar_hud_progressbar_speed_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4278 drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size.x - peak_offsetX + peak_size.x), peak_size, autocvar_hud_progressbar_speed_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4281 drawfill(panel_pos + speed_offset + eX * (peak_offsetX - peak_size.x), peak_size, autocvar_hud_progressbar_speed_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4285 tmp_offset.y = panel_size.y * 0.4;
4286 tmp_size.x = panel_size.x * (1 - 0.75);
4287 tmp_size.y = (panel_size.y - tmp_offset.y) * text_scale;
4288 tmp_offset.y += (panel_size.y - tmp_offset.y - tmp_size.y) / 2;
4289 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(top_speed), tmp_size, '1 0 0', f * panel_fg_alpha, DRAWFLAG_NORMAL);
4297 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 3)
4299 vector progressbar_color;
4300 if(acceleration < 0)
4301 progressbar_color = autocvar_hud_progressbar_acceleration_neg_color;
4303 progressbar_color = autocvar_hud_progressbar_acceleration_color;
4305 f = acceleration/autocvar_hud_panel_physics_acceleration_max;
4306 if (autocvar_hud_panel_physics_acceleration_progressbar_nonlinear)
4307 f = (f >= 0 ? sqrt(f) : -sqrt(-f));
4309 if (acceleration_progressbar_scale) // allow progressbar to go out of panel bounds
4311 tmp_size = acceleration_progressbar_scale * panel_size.x * eX + panel_size.y * eY;
4313 if (acceleration_baralign == 1)
4314 tmp_offset.x = panel_size.x - tmp_size.x;
4315 else if (acceleration_baralign == 2 || acceleration_baralign == 3)
4316 tmp_offset.x = (panel_size.x - tmp_size.x) / 2;
4323 tmp_size = panel_size;
4324 tmp_offset = '0 0 0';
4327 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);
4330 if(autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3)
4332 tmp_size.x = panel_size.x;
4333 tmp_size.y = panel_size.y * text_scale;
4335 tmp_offset.y = (panel_size.y - tmp_size.y) / 2;
4337 drawstring_aspect(panel_pos + acceleration_offset + tmp_offset, strcat(ftos_decimals(discrete_acceleration, acc_decimals), "g"), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4343 // CenterPrint (#16)
4345 const int CENTERPRINT_MAX_MSGS = 10;
4346 const int CENTERPRINT_MAX_ENTRIES = 50;
4347 const float CENTERPRINT_SPACING = 0.7;
4349 string centerprint_messages[CENTERPRINT_MAX_MSGS];
4350 int centerprint_msgID[CENTERPRINT_MAX_MSGS];
4351 float centerprint_time[CENTERPRINT_MAX_MSGS];
4352 float centerprint_expire_time[CENTERPRINT_MAX_MSGS];
4353 int centerprint_countdown_num[CENTERPRINT_MAX_MSGS];
4354 bool centerprint_showing;
4356 void centerprint_generic(int new_id, string strMessage, float duration, int countdown_num)
4358 //printf("centerprint_generic(%d, '%s^7', %d, %d);\n", new_id, strMessage, duration, countdown_num);
4361 if(strMessage == "" && new_id == 0)
4364 // strip trailing newlines
4365 j = strlen(strMessage) - 1;
4366 while(substring(strMessage, j, 1) == "\n" && j >= 0)
4368 if (j < strlen(strMessage) - 1)
4369 strMessage = substring(strMessage, 0, j + 1);
4371 if(strMessage == "" && new_id == 0)
4374 // strip leading newlines
4376 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
4379 strMessage = substring(strMessage, j, strlen(strMessage) - j);
4381 if(strMessage == "" && new_id == 0)
4384 if (!centerprint_showing)
4385 centerprint_showing = true;
4387 for (i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
4389 if (j == CENTERPRINT_MAX_MSGS)
4391 if (new_id && new_id == centerprint_msgID[j])
4393 if (strMessage == "" && centerprint_messages[j] != "" && centerprint_countdown_num[j] == 0)
4395 // fade out the current msg (duration and countdown_num are ignored)
4396 centerprint_time[j] = min(5, autocvar_hud_panel_centerprint_fade_out);
4397 if (centerprint_expire_time[j] > time + min(5, autocvar_hud_panel_centerprint_fade_out) || centerprint_expire_time[j] < time)
4398 centerprint_expire_time[j] = time + min(5, autocvar_hud_panel_centerprint_fade_out);
4401 break; // found a msg with the same id, at position j
4405 if (i == CENTERPRINT_MAX_MSGS)
4407 // a msg with the same id was not found, add the msg at the next position
4409 if (cpm_index == -1)
4410 cpm_index = CENTERPRINT_MAX_MSGS - 1;
4413 if(centerprint_messages[j])
4414 strunzone(centerprint_messages[j]);
4415 centerprint_messages[j] = strzone(strMessage);
4416 centerprint_msgID[j] = new_id;
4419 centerprint_time[j] = -1;
4420 centerprint_expire_time[j] = time;
4425 duration = max(1, autocvar_hud_panel_centerprint_time);
4426 centerprint_time[j] = duration;
4427 centerprint_expire_time[j] = time + duration;
4429 centerprint_countdown_num[j] = countdown_num;
4432 void centerprint_hud(string strMessage)
4434 centerprint_generic(0, strMessage, autocvar_hud_panel_centerprint_time, 0);
4437 void reset_centerprint_messages(void)
4440 for (i=0; i<CENTERPRINT_MAX_MSGS; ++i)
4442 centerprint_expire_time[i] = 0;
4443 centerprint_time[i] = 1;
4444 centerprint_msgID[i] = 0;
4445 if(centerprint_messages[i])
4446 strunzone(centerprint_messages[i]);
4447 centerprint_messages[i] = string_null;
4450 float hud_configure_cp_generation_time;
4451 void HUD_CenterPrint (void)
4453 if(intermission == 2) return;
4454 if(!autocvar__hud_configure)
4456 if(!autocvar_hud_panel_centerprint) return;
4458 if(hud_configure_prev)
4459 reset_centerprint_messages();
4463 if(!hud_configure_prev)
4464 reset_centerprint_messages();
4465 if (time > hud_configure_cp_generation_time)
4467 if(HUD_PANEL(CENTERPRINT) == highlightedPanel)
4472 centerprint_generic(floor(r*1000), strcat(sprintf("^3Countdown message at time %s", seconds_tostring(time)), ", seconds left: ^COUNT"), 1, 10);
4474 centerprint_generic(0, sprintf("^1Multiline message at time %s that\n^1lasts longer than normal", seconds_tostring(time)), 20, 0);
4476 centerprint_hud(sprintf("Message at time %s", seconds_tostring(time)));
4477 hud_configure_cp_generation_time = time + 1 + random()*4;
4481 centerprint_generic(0, sprintf("Centerprint message", seconds_tostring(time)), 10, 0);
4482 hud_configure_cp_generation_time = time + 10 - random()*3;
4487 // this panel fades only when the menu does
4488 float hud_fade_alpha_save = 0;
4489 if(scoreboard_fade_alpha)
4491 hud_fade_alpha_save = hud_fade_alpha;
4492 hud_fade_alpha = 1 - autocvar__menu_alpha;
4494 HUD_Panel_UpdateCvars();
4496 if ( HUD_Radar_Clickable() )
4498 if (hud_panel_radar_bottom >= 0.96 * vid_conheight)
4501 panel_pos = eY * hud_panel_radar_bottom + eX * 0.5 * (vid_conwidth - panel_size_x);
4502 panel_size_y = min(panel_size_y, vid_conheight - hud_panel_radar_bottom);
4504 else if(scoreboard_fade_alpha)
4506 hud_fade_alpha = hud_fade_alpha_save;
4508 // move the panel below the scoreboard
4509 if (scoreboard_bottom >= 0.96 * vid_conheight)
4513 target_pos = eY * scoreboard_bottom + eX * 0.5 * (vid_conwidth - panel_size.x);
4515 if(target_pos.y > panel_pos.y)
4517 panel_pos = panel_pos + (target_pos - panel_pos) * sqrt(scoreboard_fade_alpha);
4518 panel_size.y = min(panel_size.y, vid_conheight - scoreboard_bottom);
4522 HUD_Panel_DrawBg(1);
4524 if (!centerprint_showing)
4527 if(panel_bg_padding)
4529 panel_pos += '1 1 0' * panel_bg_padding;
4530 panel_size -= '2 2 0' * panel_bg_padding;
4536 // entries = bound(1, floor(CENTERPRINT_MAX_ENTRIES * 4 * panel_size_y/panel_size_x), CENTERPRINT_MAX_ENTRIES);
4537 // height = panel_size_y/entries;
4538 // fontsize = '1 1 0' * height;
4539 height = vid_conheight/50 * autocvar_hud_panel_centerprint_fontscale;
4540 fontsize = '1 1 0' * height;
4541 entries = bound(1, floor(panel_size.y/height), CENTERPRINT_MAX_ENTRIES);
4544 float a, sz, align, current_msg_posY = 0, msg_size;
4547 bool all_messages_expired = true;
4550 if (autocvar_hud_panel_centerprint_flip)
4551 pos.y += panel_size.y;
4552 align = bound(0, autocvar_hud_panel_centerprint_align, 1);
4553 for (g=0, i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
4555 if (j == CENTERPRINT_MAX_MSGS)
4557 if (centerprint_expire_time[j] <= time)
4559 if (centerprint_countdown_num[j] && centerprint_time[j] > 0)
4561 centerprint_countdown_num[j] = centerprint_countdown_num[j] - 1;
4562 if (centerprint_countdown_num[j] == 0)
4564 centerprint_expire_time[j] = centerprint_expire_time[j] + centerprint_time[j];
4566 else if(centerprint_time[j] != -1)
4570 all_messages_expired = false;
4572 // fade the centerprint_hud in/out
4573 if(centerprint_time[j] < 0) // Expired but forced. Expire time is the fade-in time.
4574 a = (time - centerprint_expire_time[j]) / max(0.0001, autocvar_hud_panel_centerprint_fade_in);
4575 else if(centerprint_expire_time[j] - autocvar_hud_panel_centerprint_fade_out > time) // Regularily printed. Not fading out yet.
4576 a = (time - (centerprint_expire_time[j] - centerprint_time[j])) / max(0.0001, autocvar_hud_panel_centerprint_fade_in);
4577 else // Expiring soon, so fade it out.
4578 a = (centerprint_expire_time[j] - time) / max(0.0001, autocvar_hud_panel_centerprint_fade_out);
4580 // while counting down show it anyway in order to hold the current message position
4581 if (a <= 0.5/255.0 && centerprint_countdown_num[j] == 0) // Guaranteed invisible - don't show.
4586 // set the size from fading in/out before subsequent fading
4587 sz = autocvar_hud_panel_centerprint_fade_minfontsize + a * (1 - autocvar_hud_panel_centerprint_fade_minfontsize);
4589 // also fade it based on positioning
4590 if(autocvar_hud_panel_centerprint_fade_subsequent)
4592 a = a * bound(autocvar_hud_panel_centerprint_fade_subsequent_passone_minalpha, (1 - (g / max(1, autocvar_hud_panel_centerprint_fade_subsequent_passone))), 1); // pass one: all messages after the first have half theAlpha
4593 a = a * bound(autocvar_hud_panel_centerprint_fade_subsequent_passtwo_minalpha, (1 - (g / max(1, autocvar_hud_panel_centerprint_fade_subsequent_passtwo))), 1); // pass two: after that, gradually lower theAlpha even more for each message
4595 a *= panel_fg_alpha;
4597 // finally set the size based on the new theAlpha from subsequent fading
4598 sz = sz * (autocvar_hud_panel_centerprint_fade_subsequent_minfontsize + a * (1 - autocvar_hud_panel_centerprint_fade_subsequent_minfontsize));
4599 drawfontscale = sz * '1 1 0';
4601 if (centerprint_countdown_num[j])
4602 n = tokenizebyseparator(strreplace("^COUNT", count_seconds(centerprint_countdown_num[j]), centerprint_messages[j]), "\n");
4604 n = tokenizebyseparator(centerprint_messages[j], "\n");
4606 if (autocvar_hud_panel_centerprint_flip)
4608 // check if the message can be entirely shown
4609 for(k = 0; k < n; ++k)
4611 getWrappedLine_remaining = argv(k);
4612 while(getWrappedLine_remaining)
4614 ts = getWrappedLine(panel_size.x * sz, fontsize, stringwidth_colors);
4616 pos.y -= fontsize.y;
4618 pos.y -= fontsize.y * CENTERPRINT_SPACING/2;
4621 current_msg_posY = pos.y; // save starting pos (first line) of the current message
4625 for(k = 0; k < n; ++k)
4627 getWrappedLine_remaining = argv(k);
4628 while(getWrappedLine_remaining)
4630 ts = getWrappedLine(panel_size.x * sz, fontsize, stringwidth_colors);
4634 pos.x = panel_pos.x + (panel_size.x - stringwidth(ts, true, fontsize)) * align;
4635 if (a > 0.5/255.0) // Otherwise guaranteed invisible - don't show. This is checked a second time after some multiplications with other factors were done so temporary changes of these cannot cause flicker.
4636 drawcolorcodedstring(pos + eY * 0.5 * (1 - sz) * fontsize.y, ts, fontsize, a, DRAWFLAG_NORMAL);
4637 pos.y += fontsize.y;
4640 pos.y += fontsize.y * CENTERPRINT_SPACING/2;
4644 ++g; // move next position number up
4646 msg_size = pos.y - msg_size;
4647 if (autocvar_hud_panel_centerprint_flip)
4649 pos.y = current_msg_posY - CENTERPRINT_SPACING * fontsize.y;
4650 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
4651 pos.y += (msg_size + CENTERPRINT_SPACING * fontsize.y) * (1 - sqrt(sz));
4653 if (pos.y < panel_pos.y) // check if the next message can be shown
4655 drawfontscale = '1 1 0';
4661 pos.y += CENTERPRINT_SPACING * fontsize.y;
4662 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
4663 pos.y -= (msg_size + CENTERPRINT_SPACING * fontsize.y) * (1 - sqrt(sz));
4665 if(pos.y > panel_pos.y + panel_size.y - fontsize.y) // check if the next message can be shown
4667 drawfontscale = '1 1 0';
4672 drawfontscale = '1 1 0';
4673 if (all_messages_expired)
4675 centerprint_showing = false;
4676 reset_centerprint_messages();
4683 #include "../common/minigames/cl_minigames_hud.qc"
4688 #include "quickmenu.qc"
4697 bool HUD_Panel_CheckFlags(int showflags)
4699 if ( HUD_Minigame_Showpanels() )
4700 return showflags & PANEL_SHOW_MINIGAME;
4701 return showflags & PANEL_SHOW_MAINGAME;
4704 void HUD_Panel_Draw(entity panent)
4707 if ( HUD_Panel_CheckFlags(panel.panel_showflags) )
4711 void HUD_Reset (void)
4713 // reset gametype specific icons
4714 if(gametype == MAPINFO_TYPE_CTF)
4715 HUD_Mod_CTF_Reset();
4718 void HUD_Main (void)
4721 // global hud theAlpha fade
4722 if(menu_enabled == 1)
4725 hud_fade_alpha = (1 - autocvar__menu_alpha);
4727 if(scoreboard_fade_alpha)
4728 hud_fade_alpha = (1 - scoreboard_fade_alpha);
4730 HUD_Configure_Frame();
4732 // panels that we want to be active together with the scoreboard
4733 // they must fade only when the menu does
4734 if(scoreboard_fade_alpha == 1)
4736 HUD_Panel_Draw(HUD_PANEL(CENTERPRINT));
4740 if(!autocvar__hud_configure && !hud_fade_alpha)
4743 HUD_Panel_Draw(HUD_PANEL(VOTE));
4749 if (hud_skin_prev != autocvar_hud_skin)
4752 strunzone(hud_skin_path);
4753 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
4755 strunzone(hud_skin_prev);
4756 hud_skin_prev = strzone(autocvar_hud_skin);
4760 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4764 float hud_dock_color_team = autocvar_hud_dock_color_team;
4765 if((teamplay) && hud_dock_color_team) {
4766 if(autocvar__hud_configure && myteam == NUM_SPECTATOR)
4767 color = '1 0 0' * hud_dock_color_team;
4769 color = myteamcolors * hud_dock_color_team;
4771 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
4772 color = '1 0 0' * hud_dock_color_team;
4776 string hud_dock_color = autocvar_hud_dock_color;
4777 if(hud_dock_color == "shirt") {
4778 f = stof(getplayerkeyvalue(current_player, "colors"));
4779 color = colormapPaletteColor(floor(f / 16), 0);
4781 else if(hud_dock_color == "pants") {
4782 f = stof(getplayerkeyvalue(current_player, "colors"));
4783 color = colormapPaletteColor(f % 16, 1);
4786 color = stov(hud_dock_color);
4790 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4791 if(precache_pic(pic) == "") {
4792 pic = strcat(hud_skin_path, "/dock_medium");
4793 if(precache_pic(pic) == "") {
4794 pic = "gfx/hud/default/dock_medium";
4797 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...
4800 // cache the panel order into the panel_order array
4801 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4802 for(i = 0; i < HUD_PANEL_NUM; ++i)
4803 panel_order[i] = -1;
4806 bool warning = false;
4807 int argc = tokenize_console(autocvar__hud_panelorder);
4808 if (argc > HUD_PANEL_NUM)
4810 //first detect wrong/missing panel numbers
4811 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4812 p_num = stoi(argv(i));
4813 if (p_num >= 0 && p_num < HUD_PANEL_NUM) { //correct panel number?
4814 if (panel_order[p_num] == -1) //found for the first time?
4815 s = strcat(s, ftos(p_num), " ");
4816 panel_order[p_num] = 1; //mark as found
4821 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4822 if (panel_order[i] == -1) {
4824 s = strcat(s, ftos(i), " "); //add missing panel number
4828 LOG_TRACE("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n");
4830 cvar_set("_hud_panelorder", s);
4831 if(hud_panelorder_prev)
4832 strunzone(hud_panelorder_prev);
4833 hud_panelorder_prev = strzone(s);
4835 //now properly set panel_order
4836 tokenize_console(s);
4837 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4838 panel_order[i] = stof(argv(i));
4842 hud_draw_maximized = 0;
4843 // draw panels in the order specified by panel_order array
4844 for(i = HUD_PANEL_NUM - 1; i >= 0; --i)
4845 HUD_Panel_Draw(hud_panel[panel_order[i]]);
4847 hud_draw_maximized = 1; // panels that may be maximized must check this var
4848 // draw maximized panels on top
4849 if(hud_panel_radar_maximized)
4850 HUD_Panel_Draw(HUD_PANEL(RADAR));
4851 if(autocvar__con_chat_maximized)
4852 HUD_Panel_Draw(HUD_PANEL(CHAT));
4853 if(hud_panel_quickmenu)
4854 HUD_Panel_Draw(HUD_PANEL(QUICKMENU));
4856 HUD_Configure_PostDraw();
4858 hud_configure_prev = autocvar__hud_configure;