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/all.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/all.qh"
19 #include "../common/mutators/mutator/waypoints/all.qh"
20 #include "../server/mutators/gamemode_ctf.qh"
22 #include "../common/stats.qh"
24 #include "../csqcmodellib/cl_player.qh"
33 vector HUD_Get_Num_Color (float x, float maxvalue)
38 color.x = sin(2*M_PI*time);
40 color.z = sin(2*M_PI*time);
42 else if(x > maxvalue * 0.75) {
43 color.x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
44 color.y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
47 else if(x > maxvalue * 0.5) {
48 color.x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
49 color.y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
50 color.z = 1 - (x-100)*0.02; // blue value between 1 -> 0
52 else if(x > maxvalue * 0.25) {
55 color.z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
57 else if(x > maxvalue * 0.1) {
59 color.y = (x-20)*90/27/100; // green value between 0 -> 1
60 color.z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
68 blinkingamt = (1 - x/maxvalue/0.25);
71 color.x = color.x - color.x * blinkingamt * sin(2*M_PI*time);
72 color.y = color.y - color.y * blinkingamt * sin(2*M_PI*time);
73 color.z = color.z - color.z * blinkingamt * sin(2*M_PI*time);
78 float HUD_GetRowCount(int item_count, vector size, float item_aspect)
80 float aspect = size_y / size_x;
81 return bound(1, floor((sqrt(4 * item_aspect * aspect * item_count + aspect * aspect) + aspect + 0.5) / 2), item_count);
84 vector HUD_GetTableSize_BestItemAR(int item_count, vector psize, float item_aspect)
87 float ratio, best_ratio = 0;
88 float best_columns = 1, best_rows = 1;
89 bool vertical = (psize.x / psize.y >= item_aspect);
92 psize = eX * psize.y + eY * psize.x;
93 item_aspect = 1 / item_aspect;
96 rows = ceil(sqrt(item_count));
97 columns = ceil(item_count/rows);
100 ratio = (psize.x/columns) / (psize.y/rows);
101 if(ratio > item_aspect)
102 ratio = item_aspect * item_aspect / ratio;
104 if(ratio <= best_ratio)
105 break; // ratio starts decreasing by now, skip next configurations
107 best_columns = columns;
115 rows = ceil(item_count/columns);
119 return eX * best_rows + eY * best_columns;
121 return eX * best_columns + eY * best_rows;
124 // return the string of the onscreen race timer
125 string MakeRaceString(int cp, float mytime, float theirtime, float lapdelta, string theirname)
133 if(theirtime == 0) // goal hit
137 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
147 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
153 lapstr = sprintf(_(" (-%dL)"), lapdelta);
156 else if(lapdelta < 0)
158 lapstr = sprintf(_(" (+%dL)"), -lapdelta);
162 else if(theirtime > 0) // anticipation
164 if(mytime >= theirtime)
165 timestr = strcat("+", ftos_decimals(mytime - theirtime, TIME_DECIMALS));
167 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(theirtime));
177 cpname = _("Start line");
179 cpname = _("Finish line");
181 cpname = sprintf(_("Intermediate %d"), cp);
183 cpname = _("Finish line");
186 return strcat(col, cpname);
187 else if(theirname == "")
188 return strcat(col, sprintf("%s (%s)", cpname, timestr));
190 return strcat(col, sprintf("%s (%s %s)", cpname, timestr, strcat(theirname, col, lapstr)));
193 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
194 int race_CheckName(string net_name)
197 for (i=RANKINGS_CNT-1;i>=0;--i)
198 if(grecordholder[i] == net_name)
209 // draw the background/borders
210 #define HUD_Panel_DrawBg(theAlpha) do { \
211 if(panel.current_panel_bg != "0" && panel.current_panel_bg != "") \
212 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));\
215 //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
216 void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, bool vertical, float baralign, vector theColor, float theAlpha, int drawflag)
218 if(!length_ratio || !theAlpha)
224 if(length_ratio < -1)
227 else if(length_ratio < 0)
231 vector width, height;
233 pic = strcat(hud_skin_path, "/", pic, "_vertical");
234 if(precache_pic(pic) == "") {
235 pic = "gfx/hud/default/progressbar_vertical";
238 if (baralign == 1) // bottom align
239 theOrigin.y += (1 - length_ratio) * theSize.y;
240 else if (baralign == 2) // center align
241 theOrigin.y += 0.5 * (1 - length_ratio) * theSize.y;
242 else if (baralign == 3) // center align, positive values down, negative up
245 if (length_ratio > 0)
246 theOrigin.y += theSize.y;
249 theOrigin.y += (1 + length_ratio) * theSize.y;
250 length_ratio = -length_ratio;
253 theSize.y *= length_ratio;
256 width = eX * theSize.x;
257 height = eY * theSize.y;
258 if(theSize.y <= theSize.x * 2)
260 // button not high enough
261 // draw just upper and lower part then
262 square = eY * theSize.y * 0.5;
263 bH = eY * (0.25 * theSize.y / (theSize.x * 2));
264 drawsubpic(theOrigin, square + width, pic, '0 0 0', eX + bH, theColor, theAlpha, drawflag);
265 drawsubpic(theOrigin + square, square + width, pic, eY - bH, eX + bH, theColor, theAlpha, drawflag);
269 square = eY * theSize.x;
270 drawsubpic(theOrigin, width + square, pic, '0 0 0', '1 0.25 0', theColor, theAlpha, drawflag);
271 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0 0.25 0', '1 0.5 0', theColor, theAlpha, drawflag);
272 drawsubpic(theOrigin + height - square, width + square, pic, '0 0.75 0', '1 0.25 0', theColor, theAlpha, drawflag);
275 pic = strcat(hud_skin_path, "/", pic);
276 if(precache_pic(pic) == "") {
277 pic = "gfx/hud/default/progressbar";
280 if (baralign == 1) // right align
281 theOrigin.x += (1 - length_ratio) * theSize.x;
282 else if (baralign == 2) // center align
283 theOrigin.x += 0.5 * (1 - length_ratio) * theSize.x;
284 else if (baralign == 3) // center align, positive values on the right, negative on the left
287 if (length_ratio > 0)
288 theOrigin.x += theSize.x;
291 theOrigin.x += (1 + length_ratio) * theSize.x;
292 length_ratio = -length_ratio;
295 theSize.x *= length_ratio;
298 width = eX * theSize.x;
299 height = eY * theSize.y;
300 if(theSize.x <= theSize.y * 2)
302 // button not wide enough
303 // draw just left and right part then
304 square = eX * theSize.x * 0.5;
305 bW = eX * (0.25 * theSize.x / (theSize.y * 2));
306 drawsubpic(theOrigin, square + height, pic, '0 0 0', eY + bW, theColor, theAlpha, drawflag);
307 drawsubpic(theOrigin + square, square + height, pic, eX - bW, eY + bW, theColor, theAlpha, drawflag);
311 square = eX * theSize.y;
312 drawsubpic(theOrigin, height + square, pic, '0 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
313 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0.25 0 0', '0.5 1 0', theColor, theAlpha, drawflag);
314 drawsubpic(theOrigin + width - square, height + square, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
319 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float theAlpha, int drawflag)
325 pic = strcat(hud_skin_path, "/num_leading");
326 if(precache_pic(pic) == "") {
327 pic = "gfx/hud/default/num_leading";
330 drawsubpic(pos, eX * min(mySize.x * 0.5, mySize.y) + eY * mySize.y, pic, '0 0 0', '0.25 1 0', color, theAlpha, drawflag);
331 if(mySize.x/mySize.y > 2)
332 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);
333 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);
338 entity weaponorder[Weapons_MAX];
339 void weaponorder_swap(int i, int j, entity pass)
341 entity h = weaponorder[i];
342 weaponorder[i] = weaponorder[j];
346 string weaponorder_cmp_str;
347 int weaponorder_cmp(int i, int j, entity pass)
350 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
351 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
352 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)
355 void HUD_Weapons(void)
358 WepSet weapons_stat = WepSet_GetFromStat();
362 vector center = '0 0 0';
363 int weapon_count, weapon_id;
364 int row, column, rows = 0, columns = 0;
365 bool vertical_order = true;
366 float aspect = autocvar_hud_panel_weapons_aspect;
368 float timeout = autocvar_hud_panel_weapons_timeout;
369 float timein_effect_length = autocvar_hud_panel_weapons_timeout_speed_in; //? 0.375 : 0);
370 float timeout_effect_length = autocvar_hud_panel_weapons_timeout_speed_out; //? 0.75 : 0);
372 vector barsize = '0 0 0', baroffset = '0 0 0';
373 vector ammo_color = '1 0 1';
374 float ammo_alpha = 1;
376 float when = max(1, autocvar_hud_panel_weapons_complainbubble_time);
377 float fadetime = max(0, autocvar_hud_panel_weapons_complainbubble_fadetime);
379 vector weapon_pos, weapon_size = '0 0 0';
382 // check to see if we want to continue
383 if(intermission == 2) return;
384 if(hud != HUD_NORMAL) return;
386 if(!autocvar__hud_configure)
388 if((!autocvar_hud_panel_weapons) || (spectatee_status == -1))
390 if(timeout && time >= weapontime + timeout + timeout_effect_length)
391 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)))
393 weaponprevtime = time;
398 // update generic hud functions
399 HUD_Panel_UpdateCvars();
401 // figure out weapon order (how the weapons are sorted) // TODO make this configurable
402 if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
405 if(weaponorder_bypriority)
406 strunzone(weaponorder_bypriority);
407 if(weaponorder_byimpulse)
408 strunzone(weaponorder_byimpulse);
410 weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
411 weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
412 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
415 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
417 setself(get_weaponinfo(i));
418 if(self.impulse >= 0)
420 weaponorder[weapon_cnt] = self;
424 for(i = weapon_cnt; i < Weapons_MAX; ++i)
425 weaponorder[i] = world;
426 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
428 weaponorder_cmp_str = string_null;
431 if(!autocvar_hud_panel_weapons_complainbubble || autocvar__hud_configure || time - complain_weapon_time >= when + fadetime)
434 if(autocvar__hud_configure)
437 for(i = WEP_FIRST; i <= WEP_LAST; i += floor((WEP_LAST-WEP_FIRST)/5))
438 weapons_stat |= WepSet_FromWeapon(i);
444 weapons_stat = '0 0 0';
445 float countw = 1 + floor((floor(time * cvar("wep_add"))) % (Weapons_COUNT - 1));
446 for(i = WEP_FIRST; i <= countw; ++i)
447 weapons_stat |= WepSet_FromWeapon(i);
452 // determine which weapons are going to be shown
453 if (autocvar_hud_panel_weapons_onlyowned)
455 if(autocvar__hud_configure)
457 if(menu_enabled != 2)
458 HUD_Panel_DrawBg(1); // also draw the bg of the entire panel
461 // do we own this weapon?
463 for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
464 if((weapons_stat & WepSet_FromWeapon(weaponorder[i].weapon)) || (weaponorder[i].weapon == complain_weapon))
468 // might as well commit suicide now, no reason to live ;)
469 if (weapon_count == 0)
472 vector old_panel_size = panel_size;
473 vector padded_panel_size = panel_size - '2 2 0' * panel_bg_padding;
475 // get the all-weapons layout
477 WepSet weapons_stat = WepSet_GetFromStat();
478 for (int i = WEP_FIRST; i <= WEP_LAST; ++i) {
479 WepSet weapons_wep = WepSet_FromWeapon(i);
480 if (weapons_stat & weapons_wep) continue;
481 Weapon w = get_weaponinfo(i);
482 if (w.spawnflags & WEP_FLAG_MUTATORBLOCKED) nHidden += 1;
484 vector table_size = HUD_GetTableSize_BestItemAR((Weapons_COUNT - 1) - nHidden, padded_panel_size, aspect);
485 columns = table_size.x;
487 weapon_size.x = padded_panel_size.x / columns;
488 weapon_size.y = padded_panel_size.y / rows;
490 // NOTE: although weapons should aways look the same even if onlyowned is enabled,
491 // we enlarge them a bit when possible to better match the desired aspect ratio
492 if(padded_panel_size.x / padded_panel_size.y < aspect)
494 // maximum number of rows that allows to display items with the desired aspect ratio
495 int max_rows = floor(padded_panel_size.y / (weapon_size.x / aspect));
496 columns = min(columns, ceil(weapon_count / max_rows));
497 rows = ceil(weapon_count / columns);
498 weapon_size.y = min(padded_panel_size.y / rows, weapon_size.x / aspect);
499 weapon_size.x = min(padded_panel_size.x / columns, aspect * weapon_size.y);
500 vertical_order = false;
504 int max_columns = floor(padded_panel_size.x / (weapon_size.y * aspect));
505 rows = min(rows, ceil(weapon_count / max_columns));
506 columns = ceil(weapon_count / rows);
507 weapon_size.x = min(padded_panel_size.x / columns, aspect * weapon_size.y);
508 weapon_size.y = min(padded_panel_size.y / rows, weapon_size.x / aspect);
509 vertical_order = true;
512 // reduce size of the panel
513 panel_size.x = columns * weapon_size.x;
514 panel_size.y = rows * weapon_size.y;
515 panel_size += '2 2 0' * panel_bg_padding;
517 // center the resized panel, or snap it to the screen edge when close enough
518 if(panel_pos.x > vid_conwidth * 0.001)
520 if(panel_pos.x + old_panel_size.x > vid_conwidth * 0.999)
521 panel_pos.x += old_panel_size.x - panel_size.x;
523 panel_pos.x += (old_panel_size.x - panel_size.x) / 2;
525 else if(old_panel_size.x > vid_conwidth * 0.999)
526 panel_pos.x += (old_panel_size.x - panel_size.x) / 2;
528 if(panel_pos.y > vid_conheight * 0.001)
530 if(panel_pos.y + old_panel_size.y > vid_conheight * 0.999)
531 panel_pos.y += old_panel_size.y - panel_size.y;
533 panel_pos.y += (old_panel_size.y - panel_size.y) / 2;
535 else if(old_panel_size.y > vid_conheight * 0.999)
536 panel_pos.y += (old_panel_size.y - panel_size.y) / 2;
539 weapon_count = (Weapons_COUNT - 1);
541 // animation for fading in/out the panel respectively when not in use
542 if(!autocvar__hud_configure)
544 if (timeout && time >= weapontime + timeout) // apply timeout effect if needed
546 f = bound(0, (time - (weapontime + timeout)) / timeout_effect_length, 1);
548 // fade the panel alpha
549 if(autocvar_hud_panel_weapons_timeout_effect == 1)
551 panel_bg_alpha *= (autocvar_hud_panel_weapons_timeout_fadebgmin * f + (1 - f));
552 panel_fg_alpha *= (autocvar_hud_panel_weapons_timeout_fadefgmin * f + (1 - f));
554 else if(autocvar_hud_panel_weapons_timeout_effect == 3)
556 panel_bg_alpha *= (1 - f);
557 panel_fg_alpha *= (1 - f);
560 // move the panel off the screen
561 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
563 f *= f; // for a cooler movement
564 center.x = panel_pos.x + panel_size.x/2;
565 center.y = panel_pos.y + panel_size.y/2;
566 screen_ar = vid_conwidth/vid_conheight;
567 if (center.x/center.y < screen_ar) //bottom left
569 if ((vid_conwidth - center.x)/center.y < screen_ar) //bottom
570 panel_pos.y += f * (vid_conheight - panel_pos.y);
572 panel_pos.x -= f * (panel_pos.x + panel_size.x);
576 if ((vid_conwidth - center.x)/center.y < screen_ar) //right
577 panel_pos.x += f * (vid_conwidth - panel_pos.x);
579 panel_pos.y -= f * (panel_pos.y + panel_size.y);
582 center.x = -1; // mark the panel as off screen
584 weaponprevtime = time - (1 - f) * timein_effect_length;
586 else if (timeout && time < weaponprevtime + timein_effect_length) // apply timein effect if needed
588 f = bound(0, (time - weaponprevtime) / timein_effect_length, 1);
590 // fade the panel alpha
591 if(autocvar_hud_panel_weapons_timeout_effect == 1)
593 panel_bg_alpha *= (autocvar_hud_panel_weapons_timeout_fadebgmin * (1 - f) + f);
594 panel_fg_alpha *= (autocvar_hud_panel_weapons_timeout_fadefgmin * (1 - f) + f);
596 else if(autocvar_hud_panel_weapons_timeout_effect == 3)
598 panel_bg_alpha *= (f);
599 panel_fg_alpha *= (f);
602 // move the panel back on screen
603 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
605 f *= f; // for a cooler movement
607 center.x = panel_pos.x + panel_size.x/2;
608 center.y = panel_pos.y + panel_size.y/2;
609 screen_ar = vid_conwidth/vid_conheight;
610 if (center.x/center.y < screen_ar) //bottom left
612 if ((vid_conwidth - center.x)/center.y < screen_ar) //bottom
613 panel_pos.y += f * (vid_conheight - panel_pos.y);
615 panel_pos.x -= f * (panel_pos.x + panel_size.x);
619 if ((vid_conwidth - center.x)/center.y < screen_ar) //right
620 panel_pos.x += f * (vid_conwidth - panel_pos.x);
622 panel_pos.y -= f * (panel_pos.y + panel_size.y);
628 // draw the background, then change the virtual size of it to better fit other items inside
636 panel_pos += '1 1 0' * panel_bg_padding;
637 panel_size -= '2 2 0' * panel_bg_padding;
640 // after the sizing and animations are done, update the other values
642 if(!rows) // if rows is > 0 onlyowned code has already updated these vars
644 vector table_size = HUD_GetTableSize_BestItemAR((Weapons_COUNT - 1), panel_size, aspect);
645 columns = table_size.x;
647 weapon_size.x = panel_size.x / columns;
648 weapon_size.y = panel_size.y / rows;
649 vertical_order = (panel_size.x / panel_size.y >= aspect);
652 // calculate position/size for visual bar displaying ammount of ammo status
653 if (autocvar_hud_panel_weapons_ammo)
655 ammo_color = stov(autocvar_hud_panel_weapons_ammo_color);
656 ammo_alpha = panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha;
658 if(weapon_size.x/weapon_size.y > aspect)
660 barsize.x = aspect * weapon_size.y;
661 barsize.y = weapon_size.y;
662 baroffset.x = (weapon_size.x - barsize.x) / 2;
666 barsize.y = 1/aspect * weapon_size.x;
667 barsize.x = weapon_size.x;
668 baroffset.y = (weapon_size.y - barsize.y) / 2;
671 if(autocvar_hud_panel_weapons_accuracy)
672 Accuracy_LoadColors();
676 vector label_size = '1 1 0' * min(weapon_size.x, weapon_size.y) * bound(0, autocvar_hud_panel_weapons_label_scale, 1);
677 vector noncurrent_pos = '0 0 0';
678 vector noncurrent_size = weapon_size * bound(0, autocvar_hud_panel_weapons_noncurrent_scale, 1);
679 float noncurrent_alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_weapons_noncurrent_alpha, 1);
682 for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
684 // retrieve information about the current weapon to be drawn
685 setself(weaponorder[i]);
686 weapon_id = self.impulse;
687 isCurrent = (self.weapon == switchweapon);
689 // skip if this weapon doesn't exist
690 if(!self || weapon_id < 0) { continue; }
692 // skip this weapon if we don't own it (and onlyowned is enabled)-- or if weapons_complainbubble is showing for this weapon
693 if(autocvar_hud_panel_weapons_onlyowned)
694 if (!((weapons_stat & WepSet_FromWeapon(self.weapon)) || (self.weapon == complain_weapon)))
697 // figure out the drawing position of weapon
698 weapon_pos = (panel_pos + eX * column * weapon_size.x + eY * row * weapon_size.y);
699 noncurrent_pos.x = weapon_pos.x + (weapon_size.x - noncurrent_size.x) / 2;
700 noncurrent_pos.y = weapon_pos.y + (weapon_size.y - noncurrent_size.y) / 2;
702 // draw background behind currently selected weapon
704 drawpic_aspect_skin(weapon_pos, "weapon_current_bg", weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
706 // draw the weapon accuracy
707 if(autocvar_hud_panel_weapons_accuracy)
709 float panel_weapon_accuracy = weapon_accuracy[self.weapon-WEP_FIRST];
710 if(panel_weapon_accuracy >= 0)
712 color = Accuracy_GetColor(panel_weapon_accuracy);
713 drawpic_aspect_skin(weapon_pos, "weapon_accuracy", weapon_size, color, panel_fg_alpha, DRAWFLAG_NORMAL);
717 // drawing all the weapon items
718 if(weapons_stat & WepSet_FromWeapon(self.weapon))
720 // draw the weapon image
722 drawpic_aspect_skin(weapon_pos, self.model2, weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
724 drawpic_aspect_skin(noncurrent_pos, self.model2, noncurrent_size, '1 1 1', noncurrent_alpha, DRAWFLAG_NORMAL);
726 // draw weapon label string
727 switch(autocvar_hud_panel_weapons_label)
729 case 1: // weapon number
730 drawstring(weapon_pos, ftos(weapon_id), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
734 drawstring(weapon_pos, getcommandkey(ftos(weapon_id), strcat("weapon_group_", ftos(weapon_id))), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
737 case 3: // weapon name
738 drawstring(weapon_pos, strtolower(self.message), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
745 // draw ammo status bar
746 if(autocvar_hud_panel_weapons_ammo && (self.ammo_field != ammo_none))
749 a = getstati(GetAmmoStat(self.ammo_field)); // how much ammo do we have?
753 switch(self.ammo_field)
755 case ammo_shells: ammo_full = autocvar_hud_panel_weapons_ammo_full_shells; break;
756 case ammo_nails: ammo_full = autocvar_hud_panel_weapons_ammo_full_nails; break;
757 case ammo_rockets: ammo_full = autocvar_hud_panel_weapons_ammo_full_rockets; break;
758 case ammo_cells: ammo_full = autocvar_hud_panel_weapons_ammo_full_cells; break;
759 case ammo_plasma: ammo_full = autocvar_hud_panel_weapons_ammo_full_plasma; break;
760 case ammo_fuel: ammo_full = autocvar_hud_panel_weapons_ammo_full_fuel; break;
761 default: ammo_full = 60;
765 weapon_pos.x + baroffset.x,
766 weapon_pos.y + baroffset.y,
767 barsize.x * bound(0, a/ammo_full, 1),
784 else // draw a "ghost weapon icon" if you don't have the weapon
786 drawpic_aspect_skin(noncurrent_pos, self.model2, noncurrent_size, '0.2 0.2 0.2', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
789 // draw the complain message
790 if(self.weapon == complain_weapon)
793 a = ((complain_weapon_time + when > time) ? 1 : bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1));
795 a = ((complain_weapon_time + when > time) ? 1 : 0);
798 if(complain_weapon_type == 0) {
799 s = _("Out of ammo");
800 color = stov(autocvar_hud_panel_weapons_complainbubble_color_outofammo);
802 else if(complain_weapon_type == 1) {
804 color = stov(autocvar_hud_panel_weapons_complainbubble_color_donthave);
807 s = _("Unavailable");
808 color = stov(autocvar_hud_panel_weapons_complainbubble_color_unavailable);
810 float padding = autocvar_hud_panel_weapons_complainbubble_padding;
811 drawpic_aspect_skin(weapon_pos + '1 1 0' * padding, "weapon_complainbubble", weapon_size - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
812 drawstring_aspect(weapon_pos + '1 1 0' * padding, s, weapon_size - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
817 if(!autocvar_hud_panel_weapons_onlyowned)
819 drawfill(weapon_pos + '1 1 0', weapon_size - '2 2 0', '1 1 1', panel_fg_alpha * 0.2, DRAWFLAG_NORMAL);
820 drawstring(weapon_pos, ftos(i + 1), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
824 // continue with new position for the next weapon
828 if(column >= columns)
847 void DrawNadeProgressBar(vector myPos, vector mySize, float progress, vector color)
849 HUD_Panel_DrawProgressBar(
850 myPos + eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize.x,
851 mySize - eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize.x,
852 autocvar_hud_panel_ammo_progressbar_name,
853 progress, 0, 0, color,
854 autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
857 void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expand_time)
859 float bonusNades = getstatf(STAT_NADE_BONUS);
860 float bonusProgress = getstatf(STAT_NADE_BONUS_SCORE);
861 float bonusType = getstati(STAT_NADE_BONUS_TYPE);
862 vector nadeColor = Nades[bonusType].m_color;
863 string nadeIcon = Nades[bonusType].m_icon;
865 vector iconPos, textPos;
867 if(autocvar_hud_panel_ammo_iconalign)
869 iconPos = myPos + eX * 2 * mySize.y;
875 textPos = myPos + eX * mySize.y;
878 if(bonusNades > 0 || bonusProgress > 0)
880 DrawNadeProgressBar(myPos, mySize, bonusProgress, nadeColor);
882 if(autocvar_hud_panel_ammo_text)
883 drawstring_aspect(textPos, ftos(bonusNades), eX * (2/3) * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
886 drawpic_aspect_skin_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, expand_time);
888 drawpic_aspect_skin(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
892 void DrawAmmoItem(vector myPos, vector mySize, .int ammoType, bool isCurrent, bool isInfinite)
894 if(ammoType == ammo_none)
897 // Initialize variables
900 if(autocvar__hud_configure)
902 isCurrent = (ammoType == ammo_rockets); // Rockets always current
906 ammo = getstati(GetAmmoStat(ammoType));
910 float scale = bound(0, autocvar_hud_panel_ammo_noncurrent_scale, 1);
911 myPos = myPos + (mySize - mySize * scale) * 0.5;
912 mySize = mySize * scale;
915 vector iconPos, textPos;
916 if(autocvar_hud_panel_ammo_iconalign)
918 iconPos = myPos + eX * 2 * mySize.y;
924 textPos = myPos + eX * mySize.y;
927 bool isShadowed = (ammo <= 0 && !isCurrent && !isInfinite);
929 vector iconColor = isShadowed ? '0 0 0' : '1 1 1';
932 textColor = '0.2 0.95 0';
936 textColor = '0.8 0.04 0';
942 alpha = panel_fg_alpha;
944 alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_ammo_noncurrent_alpha, 1) * 0.5;
946 alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_ammo_noncurrent_alpha, 1);
948 string text = isInfinite ? "\xE2\x88\x9E" : ftos(ammo); // Use infinity symbol (U+221E)
953 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
955 if(ammo > 0 && autocvar_hud_panel_ammo_progressbar)
956 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);
958 if(autocvar_hud_panel_ammo_text)
959 drawstring_aspect(textPos, text, eX * (2/3) * mySize.x + eY * mySize.y, textColor, alpha, DRAWFLAG_NORMAL);
961 drawpic_aspect_skin(iconPos, GetAmmoPicture(ammoType), '1 1 0' * mySize.y, iconColor, alpha, DRAWFLAG_NORMAL);
966 float nade_statuschange_time;
969 if(intermission == 2) return;
970 if(hud != HUD_NORMAL) return;
971 if(!autocvar__hud_configure)
973 if(!autocvar_hud_panel_ammo) return;
974 if(spectatee_status == -1) return;
977 HUD_Panel_UpdateCvars();
979 draw_beginBoldFont();
988 pos += '1 1 0' * panel_bg_padding;
989 mySize -= '2 2 0' * panel_bg_padding;
992 int rows = 0, columns, row, column;
993 float nade_cnt = getstatf(STAT_NADE_BONUS), nade_score = getstatf(STAT_NADE_BONUS_SCORE);
994 bool draw_nades = (nade_cnt > 0 || nade_score > 0);
995 float nade_statuschange_elapsedtime;
996 int total_ammo_count;
999 if (autocvar_hud_panel_ammo_onlycurrent)
1000 total_ammo_count = 1;
1002 total_ammo_count = AMMO_COUNT;
1007 if (nade_cnt != nade_prevframe)
1009 nade_statuschange_time = time;
1010 nade_prevstatus = nade_prevframe;
1011 nade_prevframe = nade_cnt;
1015 nade_prevstatus = nade_prevframe = nade_statuschange_time = 0;
1017 rows = HUD_GetRowCount(total_ammo_count, mySize, 3);
1018 columns = ceil((total_ammo_count)/rows);
1019 ammo_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
1021 vector offset = '0 0 0'; // fteqcc sucks
1023 if(ammo_size.x/ammo_size.y > 3)
1025 newSize = 3 * ammo_size.y;
1026 offset.x = ammo_size.x - newSize;
1027 pos.x += offset.x/2;
1028 ammo_size.x = newSize;
1032 newSize = 1/3 * ammo_size.x;
1033 offset.y = ammo_size.y - newSize;
1034 pos.y += offset.y/2;
1035 ammo_size.y = newSize;
1039 bool infinite_ammo = (getstati(STAT_ITEMS, 0, 24) & IT_UNLIMITED_WEAPON_AMMO);
1041 if(autocvar_hud_panel_ammo_onlycurrent)
1043 if(autocvar__hud_configure)
1045 DrawAmmoItem(pos, ammo_size, ammo_rockets, true, false);
1052 (get_weaponinfo(switchweapon)).ammo_field,
1062 column = column + 1;
1069 for(i = 0; i < AMMO_COUNT; ++i)
1071 ammotype = GetAmmoFieldFromNum(i);
1073 pos + eX * column * (ammo_size.x + offset.x) + eY * row * (ammo_size.y + offset.y),
1076 ((get_weaponinfo(switchweapon)).ammo_field == ammotype),
1084 column = column + 1;
1091 nade_statuschange_elapsedtime = time - nade_statuschange_time;
1093 float f = bound(0, nade_statuschange_elapsedtime*2, 1);
1095 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);
1101 void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, bool vertical, bool icon_right_align, vector color, float theAlpha, float fadelerp)
1103 vector newPos = '0 0 0', newSize = '0 0 0';
1104 vector picpos, numpos;
1108 if(mySize.y/mySize.x > 2)
1110 newSize.y = 2 * mySize.x;
1111 newSize.x = mySize.x;
1113 newPos.y = myPos.y + (mySize.y - newSize.y) / 2;
1118 newSize.x = 1/2 * mySize.y;
1119 newSize.y = mySize.y;
1121 newPos.x = myPos.x + (mySize.x - newSize.x) / 2;
1125 if(icon_right_align)
1128 picpos = newPos + eY * newSize.x;
1133 numpos = newPos + eY * newSize.x;
1137 drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
1138 // make number smaller than icon, it looks better
1139 // reduce only y to draw numbers with different number of digits with the same y size
1140 numpos.y += newSize.y * ((1 - 0.7) / 2);
1142 drawstring_aspect(numpos, ftos(x), newSize, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
1146 if(mySize.x/mySize.y > 3)
1148 newSize.x = 3 * mySize.y;
1149 newSize.y = mySize.y;
1151 newPos.x = myPos.x + (mySize.x - newSize.x) / 2;
1156 newSize.y = 1/3 * mySize.x;
1157 newSize.x = mySize.x;
1159 newPos.y = myPos.y + (mySize.y - newSize.y) / 2;
1163 if(icon_right_align) // right align
1166 picpos = newPos + eX * 2 * newSize.y;
1170 numpos = newPos + eX * newSize.y;
1174 // NOTE: newSize_x is always equal to 3 * mySize_y so we can use
1175 // '2 1 0' * newSize_y instead of eX * (2/3) * newSize_x + eY * newSize_y
1176 drawstring_aspect_expanding(numpos, ftos(x), '2 1 0' * newSize.y, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
1177 drawpic_aspect_skin_expanding(picpos, icon, '1 1 0' * newSize.y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
1180 void DrawNumIcon(vector myPos, vector mySize, float x, string icon, bool vertical, bool icon_right_align, vector color, float theAlpha)
1182 DrawNumIcon_expanding(myPos, mySize, x, icon, vertical, icon_right_align, color, theAlpha, 0);
1188 // Powerup item fields (reusing existing fields)
1189 .string message; // Human readable name
1190 .string netname; // Icon name
1191 .vector colormod; // Color
1192 .float count; // Time left
1193 .float lifetime; // Maximum time
1195 entity powerupItems;
1196 int powerupItemsCount;
1198 void resetPowerupItems()
1201 for(item = powerupItems; item; item = item.chain)
1204 powerupItemsCount = 0;
1207 void addPowerupItem(string name, string icon, vector color, float currentTime, float lifeTime)
1210 powerupItems = spawn();
1213 for(item = powerupItems; item.count; item = item.chain)
1215 item.chain = spawn();
1217 item.message = name;
1218 item.netname = icon;
1219 item.colormod = color;
1220 item.count = currentTime;
1221 item.lifetime = lifeTime;
1223 ++powerupItemsCount;
1226 int getPowerupItemAlign(int align, int column, int row, int columns, int rows, bool isVertical)
1231 bool isTop = isVertical && rows > 1 && row == 0;
1232 bool isBottom = isVertical && rows > 1 && row == rows-1;
1233 bool isLeft = !isVertical && columns > 1 && column == 0;
1234 bool isRight = !isVertical && columns > 1 && column == columns-1;
1236 if(isTop || isLeft) return (align == 2) ? 1 : 0;
1237 if(isBottom || isRight) return (align == 2) ? 0 : 1;
1244 if(intermission == 2) return;
1246 int allItems = getstati(STAT_ITEMS, 0, 24);
1247 int allBuffs = getstati(STAT_BUFFS, 0, 24);
1248 int strengthTime, shieldTime, superTime;
1251 if(!autocvar__hud_configure)
1253 if(!autocvar_hud_panel_powerups) return;
1254 if(spectatee_status == -1) return;
1255 if(getstati(STAT_HEALTH) <= 0) return;
1256 if(!(allItems & (ITEM_Strength.m_itemid | ITEM_Shield.m_itemid | IT_SUPERWEAPON)) && !allBuffs) return;
1258 strengthTime = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1259 shieldTime = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1260 superTime = bound(0, getstatf(STAT_SUPERWEAPONS_FINISHED) - time, 99);
1262 if(allItems & IT_UNLIMITED_SUPERWEAPONS)
1265 // Prevent stuff to show up on mismatch that will be fixed next frame
1266 if(!(allItems & IT_SUPERWEAPON))
1277 // Add items to linked list
1278 resetPowerupItems();
1281 addPowerupItem("Strength", "strength", autocvar_hud_progressbar_strength_color, strengthTime, 30);
1283 addPowerupItem("Shield", "shield", autocvar_hud_progressbar_shield_color, shieldTime, 30);
1285 addPowerupItem("Superweapons", "superweapons", autocvar_hud_progressbar_superweapons_color, superTime, 30);
1287 FOREACH(Buffs, it.m_itemid & allBuffs, LAMBDA(
1288 addPowerupItem(it.m_prettyName, strcat("buff_", it.m_name), it.m_color, bound(0, getstatf(STAT_BUFF_TIME) - time, 99), 60);
1291 if(!powerupItemsCount)
1294 // Draw panel background
1295 HUD_Panel_UpdateCvars();
1296 HUD_Panel_DrawBg(1);
1299 vector pos = panel_pos;
1300 vector size = panel_size;
1301 bool isVertical = size.y > size.x;
1303 if(panel_bg_padding)
1305 pos += '1 1 0' * panel_bg_padding;
1306 size -= '2 2 0' * panel_bg_padding;
1309 // Find best partitioning of the drawing area
1310 const float DESIRED_ASPECT = 6;
1311 float aspect = 0, a;
1318 c = floor(powerupItemsCount / i);
1319 r = ceil(powerupItemsCount / c);
1320 a = isVertical ? (size.y/r) / (size.x/c) : (size.x/c) / (size.y/r);
1322 if(i == 1 || fabs(DESIRED_ASPECT - a) < fabs(DESIRED_ASPECT - aspect))
1329 while(++i <= powerupItemsCount);
1331 // Prevent single items from getting too wide
1332 if(powerupItemsCount == 1 && aspect > DESIRED_ASPECT)
1337 pos.y += size.y * 0.5;
1342 pos.x += size.x * 0.5;
1346 // Draw items from linked list
1347 vector itemPos = pos;
1348 vector itemSize = eX * (size.x / columns) + eY * (size.y / rows);
1349 vector textColor = '1 1 1';
1351 int fullSeconds = 0;
1356 draw_beginBoldFont();
1357 for(entity item = powerupItems; item.count; item = item.chain)
1359 itemPos = eX * (pos.x + column * itemSize.x) + eY * (pos.y + row * itemSize.y);
1362 if(autocvar_hud_panel_powerups_progressbar)
1364 align = getPowerupItemAlign(autocvar_hud_panel_powerups_baralign, column, row, columns, rows, isVertical);
1365 HUD_Panel_DrawProgressBar(itemPos, itemSize, "progressbar", item.count / item.lifetime, isVertical, align, item.colormod, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1368 // Draw icon and text
1369 if(autocvar_hud_panel_powerups_text)
1371 align = getPowerupItemAlign(autocvar_hud_panel_powerups_iconalign, column, row, columns, rows, isVertical);
1372 fullSeconds = ceil(item.count);
1373 textColor = '0.6 0.6 0.6' + (item.colormod * 0.4);
1376 DrawNumIcon(itemPos, itemSize, fullSeconds, item.netname, isVertical, align, textColor, panel_fg_alpha);
1378 DrawNumIcon_expanding(itemPos, itemSize, fullSeconds, item.netname, isVertical, align, textColor, panel_fg_alpha, bound(0, (fullSeconds - item.count) / 0.5, 1));
1381 // Determine next section
1384 if(++column >= columns)
1402 // Health/armor (#3)
1406 void HUD_HealthArmor(void)
1408 int armor, health, fuel;
1409 if(intermission == 2) return;
1410 if(!autocvar__hud_configure)
1412 if(!autocvar_hud_panel_healtharmor) return;
1413 if(hud != HUD_NORMAL) return;
1414 if(spectatee_status == -1) return;
1416 health = getstati(STAT_HEALTH);
1422 armor = getstati(STAT_ARMOR);
1424 // code to check for spectatee_status changes is in Ent_ClientData()
1425 // prev_p_health and prev_health can be set to -1 there
1427 if (prev_p_health == -1)
1430 health_beforedamage = 0;
1431 armor_beforedamage = 0;
1432 health_damagetime = 0;
1433 armor_damagetime = 0;
1434 prev_health = health;
1436 old_p_health = health;
1437 old_p_armor = armor;
1438 prev_p_health = health;
1439 prev_p_armor = armor;
1441 else if (prev_health == -1)
1443 //start the load effect
1444 health_damagetime = 0;
1445 armor_damagetime = 0;
1449 fuel = getstati(STAT_FUEL);
1458 HUD_Panel_UpdateCvars();
1460 draw_beginBoldFont();
1464 mySize = panel_size;
1466 HUD_Panel_DrawBg(1);
1467 if(panel_bg_padding)
1469 pos += '1 1 0' * panel_bg_padding;
1470 mySize -= '2 2 0' * panel_bg_padding;
1473 int baralign = autocvar_hud_panel_healtharmor_baralign;
1474 int iconalign = autocvar_hud_panel_healtharmor_iconalign;
1476 int maxhealth = autocvar_hud_panel_healtharmor_maxhealth;
1477 int maxarmor = autocvar_hud_panel_healtharmor_maxarmor;
1478 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
1481 v = healtharmor_maxdamage(health, armor, armorblockpercent, DEATH_WEAPON);
1486 float maxtotal = maxhealth + maxarmor;
1488 if(v.z) // NOT fully armored
1490 biggercount = "health";
1491 if(autocvar_hud_panel_healtharmor_progressbar)
1492 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);
1494 if(autocvar_hud_panel_healtharmor_text)
1495 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);
1499 biggercount = "armor";
1500 if(autocvar_hud_panel_healtharmor_progressbar)
1501 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);
1503 if(autocvar_hud_panel_healtharmor_text)
1504 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);
1506 if(autocvar_hud_panel_healtharmor_text)
1507 DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, maxtotal), 1);
1510 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);
1514 float panel_ar = mySize.x/mySize.y;
1515 bool is_vertical = (panel_ar < 1);
1516 vector health_offset = '0 0 0', armor_offset = '0 0 0';
1517 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1520 if (autocvar_hud_panel_healtharmor_flip)
1521 health_offset.x = mySize.x;
1523 armor_offset.x = mySize.x;
1528 if (autocvar_hud_panel_healtharmor_flip)
1529 health_offset.y = mySize.y;
1531 armor_offset.y = mySize.y;
1534 bool health_baralign, armor_baralign, fuel_baralign;
1535 bool health_iconalign, armor_iconalign;
1536 if (autocvar_hud_panel_healtharmor_flip)
1538 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1539 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1540 fuel_baralign = health_baralign;
1541 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1542 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1546 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1547 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1548 fuel_baralign = armor_baralign;
1549 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1550 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1555 if(autocvar_hud_panel_healtharmor_progressbar)
1557 float p_health, pain_health_alpha;
1559 pain_health_alpha = 1;
1560 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1562 if (autocvar_hud_panel_healtharmor_progressbar_gfx_smooth > 0)
1564 if (fabs(prev_health - health) >= autocvar_hud_panel_healtharmor_progressbar_gfx_smooth)
1566 if (time - old_p_healthtime < 1)
1567 old_p_health = prev_p_health;
1569 old_p_health = prev_health;
1570 old_p_healthtime = time;
1572 if (time - old_p_healthtime < 1)
1574 p_health += (old_p_health - health) * (1 - (time - old_p_healthtime));
1575 prev_p_health = p_health;
1578 if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0)
1580 if (prev_health - health >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
1582 if (time - health_damagetime >= 1)
1583 health_beforedamage = prev_health;
1584 health_damagetime = time;
1586 if (time - health_damagetime < 1)
1588 float health_damagealpha = 1 - (time - health_damagetime)*(time - health_damagetime);
1589 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);
1592 prev_health = health;
1594 if (health <= autocvar_hud_panel_healtharmor_progressbar_gfx_lowhealth)
1596 float BLINK_FACTOR = 0.15;
1597 float BLINK_BASE = 0.85;
1598 float BLINK_FREQ = 9;
1599 pain_health_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
1602 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);
1604 if(autocvar_hud_panel_healtharmor_text)
1605 DrawNumIcon(pos + health_offset, mySize, health, "health", is_vertical, health_iconalign, HUD_Get_Num_Color(health, maxhealth), 1);
1610 if(autocvar_hud_panel_healtharmor_progressbar)
1614 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1616 if (autocvar_hud_panel_healtharmor_progressbar_gfx_smooth > 0)
1618 if (fabs(prev_armor - armor) >= autocvar_hud_panel_healtharmor_progressbar_gfx_smooth)
1620 if (time - old_p_armortime < 1)
1621 old_p_armor = prev_p_armor;
1623 old_p_armor = prev_armor;
1624 old_p_armortime = time;
1626 if (time - old_p_armortime < 1)
1628 p_armor += (old_p_armor - armor) * (1 - (time - old_p_armortime));
1629 prev_p_armor = p_armor;
1632 if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0)
1634 if (prev_armor - armor >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
1636 if (time - armor_damagetime >= 1)
1637 armor_beforedamage = prev_armor;
1638 armor_damagetime = time;
1640 if (time - armor_damagetime < 1)
1642 float armor_damagealpha = 1 - (time - armor_damagetime)*(time - armor_damagetime);
1643 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);
1648 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);
1650 if(autocvar_hud_panel_healtharmor_text)
1651 DrawNumIcon(pos + armor_offset, mySize, armor, "armor", is_vertical, armor_iconalign, HUD_Get_Num_Color(armor, maxarmor), 1);
1657 mySize.x *= 0.2 / 2; //if vertical always halve x to not cover too much numbers with 3 digits
1661 mySize.x *= 2; //restore full panel size
1662 else if (panel_ar < 1/4)
1663 mySize.y *= 2; //restore full panel size
1664 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
1671 // Notification area (#4)
1674 void HUD_Notify_Push(string icon, string attacker, string victim)
1682 if (notify_index == -1)
1683 notify_index = NOTIFY_MAX_ENTRIES-1;
1686 if (notify_attackers[notify_index])
1687 strunzone(notify_attackers[notify_index]);
1689 if (notify_victims[notify_index])
1690 strunzone(notify_victims[notify_index]);
1692 if (notify_icons[notify_index])
1693 strunzone(notify_icons[notify_index]);
1695 // Allocate new strings
1698 notify_attackers[notify_index] = strzone(attacker);
1699 notify_victims[notify_index] = strzone(victim);
1703 // In case of a notification without a victim, the attacker
1704 // is displayed on the victim's side. Instead of special
1705 // treatment later on, we can simply switch them here.
1706 notify_attackers[notify_index] = string_null;
1707 notify_victims[notify_index] = strzone(attacker);
1710 notify_icons[notify_index] = strzone(icon);
1711 notify_times[notify_index] = time;
1714 void HUD_Notify(void)
1716 if(intermission == 2) return;
1717 if (!autocvar__hud_configure)
1718 if (!autocvar_hud_panel_notify)
1721 HUD_Panel_UpdateCvars();
1722 HUD_Panel_DrawBg(1);
1724 if (!autocvar__hud_configure)
1725 if (notify_count == 0)
1732 if (panel_bg_padding)
1734 pos += '1 1 0' * panel_bg_padding;
1735 size -= '2 2 0' * panel_bg_padding;
1738 float fade_start = max(0, autocvar_hud_panel_notify_time);
1739 float fade_time = max(0, autocvar_hud_panel_notify_fadetime);
1740 float icon_aspect = max(1, autocvar_hud_panel_notify_icon_aspect);
1742 int entry_count = bound(1, floor(NOTIFY_MAX_ENTRIES * size.y / size.x), NOTIFY_MAX_ENTRIES);
1743 float entry_height = size.y / entry_count;
1745 float panel_width_half = size.x * 0.5;
1746 float icon_width_half = entry_height * icon_aspect / 2;
1747 float name_maxwidth = panel_width_half - icon_width_half - size.x * NOTIFY_ICON_MARGIN;
1749 vector font_size = '0.5 0.5 0' * entry_height * autocvar_hud_panel_notify_fontsize;
1750 vector icon_size = (eX * icon_aspect + eY) * entry_height;
1751 vector icon_left = eX * (panel_width_half - icon_width_half);
1752 vector attacker_right = eX * name_maxwidth;
1753 vector victim_left = eX * (size.x - name_maxwidth);
1755 vector attacker_pos, victim_pos, icon_pos;
1756 string attacker, victim, icon;
1757 int i, j, count, step, limit;
1760 if (autocvar_hud_panel_notify_flip)
1762 // Order items from the top down
1765 limit = entry_count;
1769 // Order items from the bottom up
1770 i = entry_count - 1;
1775 for (j = notify_index, count = 0; i != limit; i += step, ++j, ++count)
1777 if(autocvar__hud_configure)
1779 attacker = sprintf(_("Player %d"), count + 1);
1780 victim = sprintf(_("Player %d"), count + 2);
1781 icon = get_weaponinfo(min(WEP_FIRST + count * 2, WEP_LAST)).model2;
1782 alpha = bound(0, 1.2 - count / entry_count, 1);
1786 if (j == NOTIFY_MAX_ENTRIES)
1789 if (notify_times[j] + fade_start > time)
1791 else if (fade_time != 0)
1793 alpha = bound(0, (notify_times[j] + fade_start + fade_time - time) / fade_time, 1);
1800 attacker = notify_attackers[j];
1801 victim = notify_victims[j];
1802 icon = notify_icons[j];
1805 if (icon != "" && victim != "")
1807 vector name_top = eY * (i * entry_height + 0.5 * (entry_height - font_size.y));
1809 icon_pos = pos + icon_left + eY * i * entry_height;
1810 drawpic_aspect_skin(icon_pos, icon, icon_size, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1812 victim = textShortenToWidth(victim, name_maxwidth, font_size, stringwidth_colors);
1813 victim_pos = pos + victim_left + name_top;
1814 drawcolorcodedstring(victim_pos, victim, font_size, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1818 attacker = textShortenToWidth(attacker, name_maxwidth, font_size, stringwidth_colors);
1819 attacker_pos = pos + attacker_right - eX * stringwidth(attacker, true, font_size) + name_top;
1820 drawcolorcodedstring(attacker_pos, attacker, font_size, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1825 notify_count = count;
1828 void HUD_Timer(void)
1830 if(intermission == 2) return;
1831 if(!autocvar__hud_configure)
1833 if(!autocvar_hud_panel_timer) return;
1836 HUD_Panel_UpdateCvars();
1838 draw_beginBoldFont();
1842 mySize = panel_size;
1844 HUD_Panel_DrawBg(1);
1845 if(panel_bg_padding)
1847 pos += '1 1 0' * panel_bg_padding;
1848 mySize -= '2 2 0' * panel_bg_padding;
1852 float timelimit, elapsedTime, timeleft, minutesLeft;
1854 timelimit = getstatf(STAT_TIMELIMIT);
1856 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
1857 timeleft = ceil(timeleft);
1859 minutesLeft = floor(timeleft / 60);
1862 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
1863 timer_color = '1 1 1'; //white
1864 else if(minutesLeft >= 1)
1865 timer_color = '1 1 0'; //yellow
1867 timer_color = '1 0 0'; //red
1869 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
1870 if (time < getstatf(STAT_GAMESTARTTIME)) {
1871 //while restart is still active, show 00:00
1872 timer = seconds_tostring(0);
1874 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
1875 timer = seconds_tostring(elapsedTime);
1878 timer = seconds_tostring(timeleft);
1881 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
1889 float HUD_Radar_Clickable()
1891 return hud_panel_radar_mouse && !hud_panel_radar_temp_hidden;
1894 void HUD_Radar_Show_Maximized(bool doshow,float clickable)
1896 hud_panel_radar_maximized = doshow;
1897 hud_panel_radar_temp_hidden = 0;
1903 if(autocvar_hud_cursormode)
1905 hud_panel_radar_mouse = 1;
1908 else if ( hud_panel_radar_mouse )
1910 hud_panel_radar_mouse = 0;
1912 if(autocvar_hud_cursormode)
1917 void HUD_Radar_Hide_Maximized()
1919 HUD_Radar_Show_Maximized(false,false);
1923 float HUD_Radar_InputEvent(float bInputType, float nPrimary, float nSecondary)
1925 if(!hud_panel_radar_maximized || !hud_panel_radar_mouse ||
1926 autocvar__hud_configure || mv_active)
1931 mousepos_x = nPrimary;
1932 mousepos_y = nSecondary;
1936 if(nPrimary == K_MOUSE1)
1938 if(bInputType == 0) // key pressed
1939 mouseClicked |= S_MOUSE1;
1940 else if(bInputType == 1) // key released
1941 mouseClicked -= (mouseClicked & S_MOUSE1);
1943 else if(nPrimary == K_MOUSE2)
1945 if(bInputType == 0) // key pressed
1946 mouseClicked |= S_MOUSE2;
1947 else if(bInputType == 1) // key released
1948 mouseClicked -= (mouseClicked & S_MOUSE2);
1950 else if ( nPrimary == K_ESCAPE && bInputType == 0 )
1952 HUD_Radar_Hide_Maximized();
1956 // allow console/use binds to work without hiding the map
1960 con_keys = strcat(findkeysforcommand("toggleconsole", 0)," ",findkeysforcommand("+use", 0)) ;
1961 keys = tokenize(con_keys); // findkeysforcommand returns data for this
1962 for (i = 0; i < keys; ++i)
1964 if(nPrimary == stof(argv(i)))
1968 if ( getstati(STAT_HEALTH) <= 0 )
1971 if ( bInputType < 2 )
1973 con_keys = findkeysforcommand("+showscores", 0);
1974 keys = tokenize(con_keys);
1975 for (i = 0; i < keys; ++i)
1977 if ( nPrimary == stof(argv(i)) )
1979 hud_panel_radar_temp_hidden = bInputType == 0;
1985 else if ( bInputType == 0 )
1986 HUD_Radar_Hide_Maximized();
1994 void HUD_Radar_Mouse()
1996 if ( !hud_panel_radar_mouse ) return;
1997 if(mv_active) return;
2001 HUD_Radar_Hide_Maximized();
2005 if(mouseClicked & S_MOUSE2)
2007 HUD_Radar_Hide_Maximized();
2011 if(!autocvar_hud_cursormode)
2013 mousepos = mousepos + getmousepos() * autocvar_menu_mouse_speed;
2015 mousepos_x = bound(0, mousepos_x, vid_conwidth);
2016 mousepos_y = bound(0, mousepos_y, vid_conheight);
2019 HUD_Panel_UpdateCvars();
2022 panel_size = autocvar_hud_panel_radar_maximized_size;
2023 panel_size_x = bound(0.2, panel_size_x, 1) * vid_conwidth;
2024 panel_size_y = bound(0.2, panel_size_y, 1) * vid_conheight;
2025 panel_pos_x = (vid_conwidth - panel_size_x) / 2;
2026 panel_pos_y = (vid_conheight - panel_size_y) / 2;
2028 if(mouseClicked & S_MOUSE1)
2031 if ( mousepos_x < panel_pos_x || mousepos_x > panel_pos_x + panel_size_x ||
2032 mousepos_y < panel_pos_y || mousepos_y > panel_pos_y + panel_size_y )
2034 HUD_Radar_Hide_Maximized();
2037 vector pos = teamradar_texcoord_to_3dcoord(teamradar_2dcoord_to_texcoord(mousepos),view_origin_z);
2038 localcmd(sprintf("cmd ons_spawn %f %f %f",pos_x,pos_y,pos_z));
2040 HUD_Radar_Hide_Maximized();
2045 const vector cursor_size = '32 32 0';
2046 drawpic(mousepos-'8 4 0', strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursor_size, '1 1 1', 0.8, DRAWFLAG_NORMAL);
2049 void HUD_Radar(void)
2051 if(intermission == 2) return;
2052 if (!autocvar__hud_configure)
2054 if (hud_panel_radar_maximized)
2056 if (!hud_draw_maximized) return;
2060 if (autocvar_hud_panel_radar == 0) return;
2061 if (autocvar_hud_panel_radar != 2 && !teamplay) return;
2062 if(radar_panel_modified)
2064 panel.update_time = time; // forces reload of panel attributes
2065 radar_panel_modified = false;
2070 if ( hud_panel_radar_temp_hidden )
2073 HUD_Panel_UpdateCvars();
2077 if (hud_panel_radar_maximized && !autocvar__hud_configure)
2079 panel_size = autocvar_hud_panel_radar_maximized_size;
2080 panel_size.x = bound(0.2, panel_size.x, 1) * vid_conwidth;
2081 panel_size.y = bound(0.2, panel_size.y, 1) * vid_conheight;
2082 panel_pos.x = (vid_conwidth - panel_size.x) / 2;
2083 panel_pos.y = (vid_conheight - panel_size.y) / 2;
2086 panel_bg = strcat(hud_skin_path, "/border_default"); // always use the default border when maximized
2087 if(precache_pic(panel_bg) == "")
2088 panel_bg = "gfx/hud/default/border_default"; // fallback
2089 if(!radar_panel_modified && panel_bg != panel.current_panel_bg)
2090 radar_panel_modified = true;
2091 if(panel.current_panel_bg)
2092 strunzone(panel.current_panel_bg);
2093 panel.current_panel_bg = strzone(panel_bg);
2095 switch(hud_panel_radar_maximized_zoommode)
2099 f = current_zoomfraction;
2102 f = 1 - current_zoomfraction;
2112 switch(hud_panel_radar_maximized_rotation)
2115 teamradar_angle = view_angles.y - 90;
2118 teamradar_angle = 90 * hud_panel_radar_maximized_rotation;
2122 if (!hud_panel_radar_maximized && !autocvar__hud_configure)
2124 switch(hud_panel_radar_zoommode)
2128 f = current_zoomfraction;
2131 f = 1 - current_zoomfraction;
2141 switch(hud_panel_radar_rotation)
2144 teamradar_angle = view_angles.y - 90;
2147 teamradar_angle = 90 * hud_panel_radar_rotation;
2154 mySize = panel_size;
2156 HUD_Panel_DrawBg(1);
2157 if(panel_bg_padding)
2159 pos += '1 1 0' * panel_bg_padding;
2160 mySize -= '2 2 0' * panel_bg_padding;
2165 float scale2d, normalsize, bigsize;
2167 teamradar_origin2d = pos + 0.5 * mySize;
2168 teamradar_size2d = mySize;
2170 if(minimapname == "")
2173 teamradar_loadcvars();
2175 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
2176 teamradar_size2d = mySize;
2178 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
2180 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
2181 if((hud_panel_radar_rotation == 0 && !hud_panel_radar_maximized) || (hud_panel_radar_maximized_rotation == 0 && hud_panel_radar_maximized))
2183 // max-min distance must fit the radar in any rotation
2184 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_scale));
2188 vector c0, c1, c2, c3, span;
2189 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
2190 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
2191 c2 = rotate('1 0 0' * mi_min.x + '0 1 0' * mi_max.y, teamradar_angle * DEG2RAD);
2192 c3 = rotate('1 0 0' * mi_max.x + '0 1 0' * mi_min.y, teamradar_angle * DEG2RAD);
2194 span.x = max(c0_x, c1_x, c2_x, c3_x) - min(c0_x, c1_x, c2_x, c3_x);
2195 span.y = max(c0_y, c1_y, c2_y, c3_y) - min(c0_y, c1_y, c2_y, c3_y);
2197 // max-min distance must fit the radar in x=x, y=y
2199 teamradar_size2d.x * scale2d / (1.05 * span.x),
2200 teamradar_size2d.y * scale2d / (1.05 * span.y)
2204 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
2205 if(bigsize > normalsize)
2206 normalsize = bigsize;
2210 + (1 - f) * normalsize;
2211 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
2213 + (1 - f) * view_origin);
2222 draw_teamradar_background(hud_panel_radar_foreground_alpha);
2224 for(tm = world; (tm = find(tm, classname, "radarlink")); )
2225 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
2229 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
2231 if ( hud_panel_radar_mouse )
2232 if ( tm.health > 0 )
2233 if ( tm.team == myteam+1 )
2235 coord = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(tm.origin));
2236 if ( vlen(mousepos-coord) < 8 )
2238 brightcolor_x = min(1,tm.teamradar_color_x*1.5);
2239 brightcolor_y = min(1,tm.teamradar_color_y*1.5);
2240 brightcolor_z = min(1,tm.teamradar_color_z*1.5);
2241 drawpic(coord - '8 8 0', "gfx/teamradar_icon_glow", '16 16 0', brightcolor, panel_fg_alpha, 0);
2244 entity icon = RadarIcons[tm.teamradar_icon];
2245 draw_teamradar_icon(tm.origin, icon, tm, spritelookupcolor(tm, icon.netname, tm.teamradar_color), panel_fg_alpha);
2247 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
2249 color2 = GetPlayerColor(tm.sv_entnum);
2250 //if(color == NUM_SPECTATOR || color == color2)
2251 draw_teamradar_player(tm.origin, tm.angles, Team_ColorRGB(color2));
2253 draw_teamradar_player(view_origin, view_angles, '1 1 1');
2255 drawresetcliparea();
2257 if ( hud_panel_radar_mouse )
2259 string message = "Click to select teleport destination";
2261 if ( getstati(STAT_HEALTH) <= 0 )
2263 message = "Click to select spawn location";
2266 drawcolorcodedstring(pos + '0.5 0 0' * (mySize_x - stringwidth(message, true, hud_fontsize)) - '0 1 0' * hud_fontsize_y * 2,
2267 message, hud_fontsize, hud_panel_radar_foreground_alpha, DRAWFLAG_NORMAL);
2269 hud_panel_radar_bottom = pos_y + mySize_y + hud_fontsize_y;
2275 void HUD_UpdatePlayerTeams();
2276 void HUD_Score_Rankings(vector pos, vector mySize, entity me)
2279 entity tm = world, pl;
2280 int SCOREPANEL_MAX_ENTRIES = 6;
2281 float SCOREPANEL_ASPECTRATIO = 2;
2282 int entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize.y/mySize.x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
2283 vector fontsize = '1 1 0' * (mySize.y/entries);
2285 vector rgb, score_color;
2287 score_color = '1 1 1';
2289 float name_size = mySize.x*0.75;
2290 float spacing_size = mySize.x*0.04;
2291 const float highlight_alpha = 0.2;
2292 int i = 0, first_pl = 0;
2293 bool me_printed = false;
2295 if (autocvar__hud_configure)
2297 float players_per_team = 0;
2300 // show team scores in the first line
2301 float score_size = mySize.x / team_count;
2302 players_per_team = max(2, ceil((entries - 1) / team_count));
2303 for(i=0; i<team_count; ++i) {
2304 if (i == floor((entries - 2) / players_per_team) || (entries == 1 && i == 0))
2305 HUD_Panel_DrawHighlight(pos + eX * score_size * i, eX * score_size + eY * fontsize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2306 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);
2309 pos.y += fontsize.y;
2311 score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
2312 for (i=first_pl; i<entries; ++i)
2314 //simulate my score is lower than all displayed players,
2315 //so that I don't appear at all showing pure rankings.
2316 //This is to better show the difference between the 2 ranking views
2317 if (i == entries-1 && autocvar_hud_panel_score_rankings == 1)
2320 drawfill(pos, eX * mySize.x + eY * fontsize.y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2321 s = GetPlayerName(player_localnum);
2326 s = sprintf(_("Player %d"), i + 1 - first_pl);
2331 score_color = Team_ColorRGB(ColorByTeam(floor((i - first_pl) / players_per_team))) * 0.8;
2332 s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
2333 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, true, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2334 drawstring(pos + eX * (name_size + spacing_size), ftos(score), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2335 pos.y += fontsize.y;
2340 if (!scoreboard_fade_alpha) // the scoreboard too calls HUD_UpdatePlayerTeams
2341 HUD_UpdatePlayerTeams();
2344 // show team scores in the first line
2345 float score_size = mySize.x / team_count;
2346 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2347 if(tm.team == NUM_SPECTATOR)
2349 if (tm.team == myteam)
2350 drawfill(pos + eX * score_size * i, eX * score_size + eY * fontsize.y, '1 1 1', highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2351 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);
2355 pos.y += fontsize.y;
2356 tm = teams.sort_next;
2361 for (pl = players.sort_next; pl && i<entries; pl = pl.sort_next)
2363 if ((team_count && pl.team != tm.team) || pl.team == NUM_SPECTATOR)
2366 if (i == entries-1 && !me_printed && pl != me)
2367 if (autocvar_hud_panel_score_rankings == 1 && spectatee_status != -1)
2369 for (pl = me.sort_next; pl; pl = pl.sort_next)
2370 if (pl.team != NUM_SPECTATOR)
2374 rgb = '1 1 0'; //not last but not among the leading players: yellow
2376 rgb = '1 0 0'; //last: red
2383 rgb = '0 1 0'; //first: green
2385 drawfill(pos, eX * mySize.x + eY * fontsize.y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2388 score_color = Team_ColorRGB(pl.team) * 0.8;
2389 s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
2390 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, true, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2391 drawstring(pos + eX * (name_size + spacing_size), ftos(pl.(scores[ps_primary])), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2392 pos.y += fontsize.y;
2395 while (i<entries && team_count && (tm = tm.sort_next) && (tm.team != NUM_SPECTATOR || (tm = tm.sort_next)));
2398 void HUD_Score(void)
2400 if(intermission == 2) return;
2401 if(!autocvar__hud_configure)
2403 if(!autocvar_hud_panel_score) return;
2404 if(spectatee_status == -1 && (gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) return;
2407 HUD_Panel_UpdateCvars();
2410 mySize = panel_size;
2412 HUD_Panel_DrawBg(1);
2413 if(panel_bg_padding)
2415 pos += '1 1 0' * panel_bg_padding;
2416 mySize -= '2 2 0' * panel_bg_padding;
2419 float score, distribution = 0;
2421 vector distribution_color;
2424 me = playerslots[current_player];
2426 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
2427 string timer, distrtimer;
2429 pl = players.sort_next;
2432 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
2433 if(pl.scores[ps_primary] == 0)
2436 score = me.(scores[ps_primary]);
2437 timer = TIME_ENCODED_TOSTRING(score);
2439 draw_beginBoldFont();
2440 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
2441 // distribution display
2442 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2444 distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS);
2446 if (distribution <= 0) {
2447 distribution_color = '0 1 0';
2451 distribution_color = '1 0 0';
2454 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);
2456 // race record display
2457 if (distribution <= 0)
2458 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2459 drawstring_aspect(pos, timer, eX * 0.75 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2461 } else if (!teamplay) { // non-teamgames
2462 if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings)
2464 HUD_Score_Rankings(pos, mySize, me);
2467 // me vector := [team/connected frags id]
2468 pl = players.sort_next;
2472 if(autocvar__hud_configure)
2475 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2479 score = me.(scores[ps_primary]);
2480 if(autocvar__hud_configure)
2483 if(distribution >= 5)
2484 distribution_color = eY;
2485 else if(distribution >= 0)
2486 distribution_color = '1 1 1';
2487 else if(distribution >= -5)
2488 distribution_color = '1 1 0';
2490 distribution_color = eX;
2492 string distribution_str;
2493 distribution_str = ftos(distribution);
2494 draw_beginBoldFont();
2495 if (distribution >= 0)
2497 if (distribution > 0)
2498 distribution_str = strcat("+", distribution_str);
2499 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2501 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize.x + eY * mySize.y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2502 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);
2504 } else { // teamgames
2505 float row, column, rows = 0, columns = 0;
2506 vector offset = '0 0 0';
2507 vector score_pos, score_size; //for scores other than myteam
2508 if(autocvar_hud_panel_score_rankings)
2510 HUD_Score_Rankings(pos, mySize, me);
2513 if(spectatee_status == -1)
2515 rows = HUD_GetRowCount(team_count, mySize, 3);
2516 columns = ceil(team_count/rows);
2517 score_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
2520 if(score_size.x/score_size.y > 3)
2522 newSize = 3 * score_size.y;
2523 offset.x = score_size.x - newSize;
2524 pos.x += offset.x/2;
2525 score_size.x = newSize;
2529 newSize = 1/3 * score_size.x;
2530 offset.y = score_size.y - newSize;
2531 pos.y += offset.y/2;
2532 score_size.y = newSize;
2536 score_size = eX * mySize.x*(1/4) + eY * mySize.y*(1/3);
2538 float max_fragcount;
2539 max_fragcount = -99;
2540 draw_beginBoldFont();
2542 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2543 if(tm.team == NUM_SPECTATOR)
2545 score = tm.(teamscores[ts_primary]);
2546 if(autocvar__hud_configure)
2549 if (score > max_fragcount)
2550 max_fragcount = score;
2552 if (spectatee_status == -1)
2554 score_pos = pos + eX * column * (score_size.x + offset.x) + eY * row * (score_size.y + offset.y);
2555 if (max_fragcount == score)
2556 HUD_Panel_DrawHighlight(score_pos, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2557 drawstring_aspect(score_pos, ftos(score), score_size, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2565 else if(tm.team == myteam) {
2566 if (max_fragcount == score)
2567 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2568 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize.x + eY * mySize.y, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2570 if (max_fragcount == score)
2571 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);
2572 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);
2582 void HUD_RaceTimer (void)
2584 if(intermission == 2) return;
2585 if(!autocvar__hud_configure)
2587 if(!autocvar_hud_panel_racetimer) return;
2588 if(!(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) return;
2589 if(spectatee_status == -1) return;
2592 HUD_Panel_UpdateCvars();
2596 mySize = panel_size;
2598 HUD_Panel_DrawBg(1);
2599 if(panel_bg_padding)
2601 pos += '1 1 0' * panel_bg_padding;
2602 mySize -= '2 2 0' * panel_bg_padding;
2605 // always force 4:1 aspect
2606 vector newSize = '0 0 0';
2607 if(mySize.x/mySize.y > 4)
2609 newSize.x = 4 * mySize.y;
2610 newSize.y = mySize.y;
2612 pos.x = pos.x + (mySize.x - newSize.x) / 2;
2616 newSize.y = 1/4 * mySize.x;
2617 newSize.x = mySize.x;
2619 pos.y = pos.y + (mySize.y - newSize.y) / 2;
2624 string s, forcetime;
2626 if(autocvar__hud_configure)
2629 draw_beginBoldFont();
2630 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);
2632 s = _("^1Intermediate 1 (+15.42)");
2633 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);
2634 s = sprintf(_("^1PENALTY: %.1f (%s)"), 2, "missing a checkpoint");
2635 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);
2637 else if(race_checkpointtime)
2639 a = bound(0, 2 - (time - race_checkpointtime), 1);
2642 if(a > 0) // just hit a checkpoint?
2644 if(race_checkpoint != 254)
2646 if(race_time && race_previousbesttime)
2647 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
2649 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
2651 forcetime = TIME_ENCODED_TOSTRING(race_time);
2656 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
2658 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
2659 if(a > 0) // next one?
2661 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
2666 if(s != "" && a > 0)
2668 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);
2671 if(race_penaltytime)
2673 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
2676 s = sprintf(_("^1PENALTY: %.1f (%s)"), race_penaltytime * 0.1, race_penaltyreason);
2677 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);
2681 draw_beginBoldFont();
2685 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
2686 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);
2691 if(race_laptime && race_checkpoint != 255)
2693 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
2694 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);
2701 if(race_mycheckpointtime)
2703 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
2704 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -(race_mycheckpointenemy == ""), race_mycheckpointlapsdelta, race_mycheckpointenemy);
2705 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);
2707 if(race_othercheckpointtime && race_othercheckpointenemy != "")
2709 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
2710 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -(race_othercheckpointenemy == ""), race_othercheckpointlapsdelta, race_othercheckpointenemy);
2711 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);
2714 if(race_penaltytime && !race_penaltyaccumulator)
2716 t = race_penaltytime * 0.1 + race_penaltyeventtime;
2717 a = bound(0, (1 + t - time), 1);
2721 s = sprintf(_("^1PENALTY: %.1f (%s)"), (t - time) * 0.1, race_penaltyreason);
2723 s = sprintf(_("^2PENALTY: %.1f (%s)"), 0, race_penaltyreason);
2724 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);
2735 if(intermission == 2) return;
2736 if(autocvar_cl_allow_uid2name == -1 && (gametype == MAPINFO_TYPE_CTS || gametype == MAPINFO_TYPE_RACE || (serverflags & SERVERFLAG_PLAYERSTATS)))
2739 if (autocvar__hud_configure)
2743 LOG_INFO(_("^1You must answer before entering hud configure mode\n"));
2744 cvar_set("_hud_configure", "0");
2746 if(vote_called_vote)
2747 strunzone(vote_called_vote);
2748 vote_called_vote = strzone(_("^2Name ^7instead of \"^1Anonymous player^7\" in stats"));
2749 uid2name_dialog = 1;
2752 if(!autocvar__hud_configure)
2754 if(!autocvar_hud_panel_vote) return;
2756 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
2757 panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha;
2759 if(panel_bg_alpha_str == "") {
2760 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
2762 panel_bg_alpha = stof(panel_bg_alpha_str);
2773 if(vote_active != vote_prev) {
2775 vote_prev = vote_active;
2778 if(vote_active || autocvar__hud_configure)
2779 vote_alpha = bound(0, (time - vote_change) * 2, 1);
2781 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
2786 HUD_Panel_UpdateCvars();
2790 panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight;
2791 panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight;
2794 // these must be below above block
2797 mySize = panel_size;
2799 a = vote_alpha * (vote_highlighted ? autocvar_hud_panel_vote_alreadyvoted_alpha : 1);
2800 HUD_Panel_DrawBg(a);
2801 a = panel_fg_alpha * a;
2803 if(panel_bg_padding)
2805 pos += '1 1 0' * panel_bg_padding;
2806 mySize -= '2 2 0' * panel_bg_padding;
2809 // always force 3:1 aspect
2810 vector newSize = '0 0 0';
2811 if(mySize.x/mySize.y > 3)
2813 newSize.x = 3 * mySize.y;
2814 newSize.y = mySize.y;
2816 pos.x = pos.x + (mySize.x - newSize.x) / 2;
2820 newSize.y = 1/3 * mySize.x;
2821 newSize.x = mySize.x;
2823 pos.y = pos.y + (mySize.y - newSize.y) / 2;
2827 s = _("A vote has been called for:");
2829 s = _("Allow servers to store and display your name?");
2830 drawstring_aspect(pos, s, eX * mySize.x + eY * (2/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
2831 s = textShortenToWidth(vote_called_vote, mySize.x, '1 1 0' * mySize.y * (1/8), stringwidth_colors);
2832 if(autocvar__hud_configure)
2833 s = _("^1Configure the HUD");
2834 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize.y, s, eX * mySize.x + eY * (1.75/8) * mySize.y, a, DRAWFLAG_NORMAL);
2836 // print the yes/no counts
2837 s = sprintf(_("Yes (%s): %d"), getcommandkey("vyes", "vyes"), vote_yescount);
2838 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);
2839 s = sprintf(_("No (%s): %d"), getcommandkey("vno", "vno"), vote_nocount);
2840 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);
2842 // draw the progress bar backgrounds
2843 drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_back", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
2845 // draw the highlights
2846 if(vote_highlighted == 1) {
2847 drawsetcliparea(pos.x, pos.y, mySize.x * 0.5, mySize.y);
2848 drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_voted", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
2850 else if(vote_highlighted == -1) {
2851 drawsetcliparea(pos.x + 0.5 * mySize.x, pos.y, mySize.x * 0.5, mySize.y);
2852 drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_voted", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
2855 // draw the progress bars
2856 if(vote_yescount && vote_needed)
2858 drawsetcliparea(pos.x, pos.y, mySize.x * 0.5 * (vote_yescount/vote_needed), mySize.y);
2859 drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_prog", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
2862 if(vote_nocount && vote_needed)
2864 drawsetcliparea(pos.x + mySize.x - mySize.x * 0.5 * (vote_nocount/vote_needed), pos.y, mySize.x * 0.5, mySize.y);
2865 drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_prog", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
2868 drawresetcliparea();
2871 // Mod icons panel (#10)
2874 bool mod_active; // is there any active mod icon?
2876 void DrawCAItem(vector myPos, vector mySize, float aspect_ratio, int layout, int i)
2880 vector color = '0 0 0';
2884 stat = getstati(STAT_REDALIVE);
2885 pic = "player_red.tga";
2889 stat = getstati(STAT_BLUEALIVE);
2890 pic = "player_blue.tga";
2894 stat = getstati(STAT_YELLOWALIVE);
2895 pic = "player_yellow.tga";
2900 stat = getstati(STAT_PINKALIVE);
2901 pic = "player_pink.tga";
2906 if(mySize.x/mySize.y > aspect_ratio)
2908 i = aspect_ratio * mySize.y;
2909 myPos.x = myPos.x + (mySize.x - i) / 2;
2914 i = 1/aspect_ratio * mySize.x;
2915 myPos.y = myPos.y + (mySize.y - i) / 2;
2921 drawpic_aspect_skin(myPos, pic, eX * 0.7 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2922 drawstring_aspect(myPos + eX * 0.7 * mySize.x, ftos(stat), eX * 0.3 * mySize.x + eY * mySize.y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
2925 drawstring_aspect(myPos, ftos(stat), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
2928 // Clan Arena and Freeze Tag HUD modicons
2929 void HUD_Mod_CA(vector myPos, vector mySize)
2931 mod_active = 1; // required in each mod function that always shows something
2934 if(gametype == MAPINFO_TYPE_CA)
2935 layout = autocvar_hud_panel_modicons_ca_layout;
2936 else //if(gametype == MAPINFO_TYPE_FREEZETAG)
2937 layout = autocvar_hud_panel_modicons_freezetag_layout;
2940 aspect_ratio = (layout) ? 2 : 1;
2941 rows = HUD_GetRowCount(team_count, mySize, aspect_ratio);
2942 columns = ceil(team_count/rows);
2945 float row = 0, column = 0;
2946 vector pos, itemSize;
2947 itemSize = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
2948 for(i=0; i<team_count; ++i)
2950 pos = myPos + eX * column * itemSize.x + eY * row * itemSize.y;
2952 DrawCAItem(pos, itemSize, aspect_ratio, layout, i);
2963 // CTF HUD modicon section
2964 int redflag_prevframe, blueflag_prevframe, yellowflag_prevframe, pinkflag_prevframe, neutralflag_prevframe; // status during previous frame
2965 int redflag_prevstatus, blueflag_prevstatus, yellowflag_prevstatus, pinkflag_prevstatus, neutralflag_prevstatus; // last remembered status
2966 float redflag_statuschange_time, blueflag_statuschange_time, yellowflag_statuschange_time, pinkflag_statuschange_time, neutralflag_statuschange_time; // time when the status changed
2968 void HUD_Mod_CTF_Reset(void)
2970 redflag_prevstatus = blueflag_prevstatus = yellowflag_prevstatus = pinkflag_prevstatus = neutralflag_prevstatus = 0;
2971 redflag_prevframe = blueflag_prevframe = yellowflag_prevframe = pinkflag_prevframe = neutralflag_prevframe = 0;
2972 redflag_statuschange_time = blueflag_statuschange_time = yellowflag_statuschange_time = pinkflag_statuschange_time = neutralflag_statuschange_time = 0;
2975 void HUD_Mod_CTF(vector pos, vector mySize)
2977 vector redflag_pos, blueflag_pos, yellowflag_pos, pinkflag_pos, neutralflag_pos;
2979 float f; // every function should have that
2981 int redflag, blueflag, yellowflag, pinkflag, neutralflag; // current status
2982 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime, yellowflag_statuschange_elapsedtime, pinkflag_statuschange_elapsedtime, neutralflag_statuschange_elapsedtime; // time since the status changed
2983 bool ctf_oneflag; // one-flag CTF mode enabled/disabled
2984 int stat_items = getstati(STAT_CTF_FLAGSTATUS, 0, 24);
2985 float fs, fs2, fs3, size1, size2;
2988 redflag = (stat_items/CTF_RED_FLAG_TAKEN) & 3;
2989 blueflag = (stat_items/CTF_BLUE_FLAG_TAKEN) & 3;
2990 yellowflag = (stat_items/CTF_YELLOW_FLAG_TAKEN) & 3;
2991 pinkflag = (stat_items/CTF_PINK_FLAG_TAKEN) & 3;
2992 neutralflag = (stat_items/CTF_NEUTRAL_FLAG_TAKEN) & 3;
2994 ctf_oneflag = (stat_items & CTF_FLAG_NEUTRAL);
2996 mod_active = (redflag || blueflag || yellowflag || pinkflag || neutralflag);
2998 if (autocvar__hud_configure) {
3001 if (team_count >= 3)
3003 if (team_count >= 4)
3005 ctf_oneflag = neutralflag = 0; // disable neutral flag in hud editor?
3008 // when status CHANGES, set old status into prevstatus and current status into status
3009 #define X(team) do { \
3010 if (team##flag != team##flag_prevframe) { \
3011 team##flag_statuschange_time = time; \
3012 team##flag_prevstatus = team##flag_prevframe; \
3013 team##flag_prevframe = team##flag; \
3015 team##flag_statuschange_elapsedtime = time - team##flag_statuschange_time; \
3024 const float BLINK_FACTOR = 0.15;
3025 const float BLINK_BASE = 0.85;
3027 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3029 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3031 const float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3033 #define X(team, cond) \
3034 string team##_icon, team##_icon_prevstatus; \
3035 int team##_alpha, team##_alpha_prevstatus; \
3036 team##_alpha = team##_alpha_prevstatus = 1; \
3038 switch (team##flag) { \
3039 case 1: team##_icon = "flag_" #team "_taken"; break; \
3040 case 2: team##_icon = "flag_" #team "_lost"; break; \
3041 case 3: team##_icon = "flag_" #team "_carrying"; team##_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; \
3043 if ((stat_items & CTF_SHIELDED) && (cond)) { \
3044 team##_icon = "flag_" #team "_shielded"; \
3046 team##_icon = string_null; \
3050 switch (team##flag_prevstatus) { \
3051 case 1: team##_icon_prevstatus = "flag_" #team "_taken"; break; \
3052 case 2: team##_icon_prevstatus = "flag_" #team "_lost"; break; \
3053 case 3: team##_icon_prevstatus = "flag_" #team "_carrying"; team##_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; \
3055 if (team##flag == 3) { \
3056 team##_icon_prevstatus = "flag_" #team "_carrying"; /* make it more visible */\
3057 } else if((stat_items & CTF_SHIELDED) && (cond)) { \
3058 team##_icon_prevstatus = "flag_" #team "_shielded"; \
3060 team##_icon_prevstatus = string_null; \
3065 X(red, myteam != NUM_TEAM_1);
3066 X(blue, myteam != NUM_TEAM_2);
3067 X(yellow, myteam != NUM_TEAM_3);
3068 X(pink, myteam != NUM_TEAM_4);
3073 // hacky, but these aren't needed
3074 red_icon = red_icon_prevstatus = blue_icon = blue_icon_prevstatus = yellow_icon = yellow_icon_prevstatus = pink_icon = pink_icon_prevstatus = string_null;
3076 } else switch (team_count) {
3078 case 2: fs = 0.5; fs2 = 0.5; fs3 = 0.5; break;
3079 case 3: fs = 1; fs2 = 0.35; fs3 = 0.35; break;
3080 case 4: fs = 0.75; fs2 = 0.25; fs3 = 0.5; break;
3083 if (mySize_x > mySize_y) {
3099 blueflag_pos = pos + eX * fs2 * size1;
3100 yellowflag_pos = pos - eX * fs2 * size1;
3101 pinkflag_pos = pos + eX * fs3 * size1;
3105 redflag_pos = pos + eX * fs2 * size1;
3107 yellowflag_pos = pos - eX * fs2 * size1;
3108 pinkflag_pos = pos + eX * fs3 * size1;
3112 redflag_pos = pos + eX * fs3 * size1;
3113 blueflag_pos = pos - eX * fs2 * size1;
3114 yellowflag_pos = pos;
3115 pinkflag_pos = pos + eX * fs2 * size1;
3119 redflag_pos = pos - eX * fs2 * size1;
3120 blueflag_pos = pos + eX * fs3 * size1;
3121 yellowflag_pos = pos + eX * fs2 * size1;
3126 neutralflag_pos = pos;
3127 flag_size = e1 * fs * size1 + e2 * size2;
3129 #define X(team) do { \
3130 f = bound(0, team##flag_statuschange_elapsedtime * 2, 1); \
3131 if (team##_icon_prevstatus && f < 1) \
3132 drawpic_aspect_skin_expanding(team##flag_pos, team##_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * team##_alpha_prevstatus, DRAWFLAG_NORMAL, f); \
3134 drawpic_aspect_skin(team##flag_pos, team##_icon, flag_size, '1 1 1', panel_fg_alpha * team##_alpha * f, DRAWFLAG_NORMAL); \
3144 // Keyhunt HUD modicon section
3147 void HUD_Mod_KH(vector pos, vector mySize)
3149 mod_active = 1; // keyhunt should never hide the mod icons panel
3151 // Read current state
3153 int state = getstati(STAT_KH_KEYS);
3155 int all_keys, team1_keys, team2_keys, team3_keys, team4_keys, dropped_keys, carrying_keys;
3156 all_keys = team1_keys = team2_keys = team3_keys = team4_keys = dropped_keys = carrying_keys = 0;
3158 for(i = 0; i < 4; ++i)
3160 key_state = (bitshift(state, i * -5) & 31) - 1;
3173 case NUM_TEAM_1: ++team1_keys; break;
3174 case NUM_TEAM_2: ++team2_keys; break;
3175 case NUM_TEAM_3: ++team3_keys; break;
3176 case NUM_TEAM_4: ++team4_keys; break;
3177 case 29: ++dropped_keys; break;
3183 // Calculate slot measurements
3187 if(all_keys == 4 && mySize.x * 0.5 < mySize.y && mySize.y * 0.5 < mySize.x)
3189 // Quadratic arrangement
3190 slot_size = eX * mySize.x * 0.5 + eY * mySize.y * 0.5;
3192 KH_SLOTS[1] = pos + eX * slot_size.x;
3193 KH_SLOTS[2] = pos + eY * slot_size.y;
3194 KH_SLOTS[3] = pos + eX * slot_size.x + eY * slot_size.y;
3198 if(mySize.x > mySize.y)
3200 // Horizontal arrangement
3201 slot_size = eX * mySize.x / all_keys + eY * mySize.y;
3202 for(i = 0; i < all_keys; ++i)
3203 KH_SLOTS[i] = pos + eX * slot_size.x * i;
3207 // Vertical arrangement
3208 slot_size = eX * mySize.x + eY * mySize.y / all_keys;
3209 for(i = 0; i < all_keys; ++i)
3210 KH_SLOTS[i] = pos + eY * slot_size.y * i;
3214 // Make icons blink in case of RUN HERE
3216 float blink = 0.6 + sin(2*M_PI*time) / 2.5; // Oscillate between 0.2 and 1
3223 case NUM_TEAM_1: if(team1_keys == all_keys) alpha = blink; break;
3224 case NUM_TEAM_2: if(team2_keys == all_keys) alpha = blink; break;
3225 case NUM_TEAM_3: if(team3_keys == all_keys) alpha = blink; break;
3226 case NUM_TEAM_4: if(team4_keys == all_keys) alpha = blink; break;
3234 if(myteam == NUM_TEAM_1 && carrying_keys)
3236 drawpic_aspect_skin(KH_SLOTS[i++], "kh_red_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
3240 drawpic_aspect_skin(KH_SLOTS[i++], "kh_red_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
3243 if(myteam == NUM_TEAM_2 && carrying_keys)
3245 drawpic_aspect_skin(KH_SLOTS[i++], "kh_blue_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
3249 drawpic_aspect_skin(KH_SLOTS[i++], "kh_blue_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
3252 if(myteam == NUM_TEAM_3 && carrying_keys)
3254 drawpic_aspect_skin(KH_SLOTS[i++], "kh_yellow_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
3258 drawpic_aspect_skin(KH_SLOTS[i++], "kh_yellow_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
3261 if(myteam == NUM_TEAM_4 && carrying_keys)
3263 drawpic_aspect_skin(KH_SLOTS[i++], "kh_pink_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
3267 drawpic_aspect_skin(KH_SLOTS[i++], "kh_pink_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
3269 while(dropped_keys--)
3270 drawpic_aspect_skin(KH_SLOTS[i++], "kh_dropped", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
3273 // Keepaway HUD mod icon
3274 int kaball_prevstatus; // last remembered status
3275 float kaball_statuschange_time; // time when the status changed
3277 // we don't need to reset for keepaway since it immediately
3278 // autocorrects prevstatus as to if the player has the ball or not
3280 void HUD_Mod_Keepaway(vector pos, vector mySize)
3282 mod_active = 1; // keepaway should always show the mod HUD
3284 float BLINK_FACTOR = 0.15;
3285 float BLINK_BASE = 0.85;
3286 float BLINK_FREQ = 5;
3287 float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
3289 int stat_items = getstati(STAT_ITEMS, 0, 24);
3290 int kaball = (stat_items/IT_KEY1) & 1;
3292 if(kaball != kaball_prevstatus)
3294 kaball_statuschange_time = time;
3295 kaball_prevstatus = kaball;
3298 vector kaball_pos, kaball_size;
3300 if(mySize.x > mySize.y) {
3301 kaball_pos = pos + eX * 0.25 * mySize.x;
3302 kaball_size = eX * 0.5 * mySize.x + eY * mySize.y;
3304 kaball_pos = pos + eY * 0.25 * mySize.y;
3305 kaball_size = eY * 0.5 * mySize.y + eX * mySize.x;
3308 float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
3309 float f = bound(0, kaball_statuschange_elapsedtime*2, 1);
3311 if(kaball_prevstatus && f < 1)
3312 drawpic_aspect_skin_expanding(kaball_pos, "keepawayball_carrying", kaball_size, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f);
3315 drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
3319 // Nexball HUD mod icon
3320 void HUD_Mod_NexBall(vector pos, vector mySize)
3322 float nb_pb_starttime, dt, p;
3325 stat_items = getstati(STAT_ITEMS, 0, 24);
3326 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3328 if (stat_items & IT_KEY1)
3333 //Manage the progress bar if any
3334 if (nb_pb_starttime > 0)
3336 dt = (time - nb_pb_starttime) % nb_pb_period;
3337 // one period of positive triangle
3338 p = 2 * dt / nb_pb_period;
3342 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);
3345 if (stat_items & IT_KEY1)
3346 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3349 // Race/CTS HUD mod icons
3350 float crecordtime_prev; // last remembered crecordtime
3351 float crecordtime_change_time; // time when crecordtime last changed
3352 float srecordtime_prev; // last remembered srecordtime
3353 float srecordtime_change_time; // time when srecordtime last changed
3355 float race_status_time;
3356 int race_status_prev;
3357 string race_status_name_prev;
3358 void HUD_Mod_Race(vector pos, vector mySize)
3360 mod_active = 1; // race should never hide the mod icons panel
3362 me = playerslots[player_localnum];
3364 float f; // yet another function has this
3365 score = me.(scores[ps_primary]);
3367 if(!(scores_flags[ps_primary] & SFL_TIME) || teamplay) // race/cts record display on HUD
3368 return; // no records in the actual race
3370 // clientside personal record
3372 if(gametype == MAPINFO_TYPE_CTS)
3376 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3378 if(score && (score < t || !t)) {
3379 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3380 if(autocvar_cl_autodemo_delete_keeprecords)
3382 f = autocvar_cl_autodemo_delete;
3384 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3388 if(t != crecordtime_prev) {
3389 crecordtime_prev = t;
3390 crecordtime_change_time = time;
3393 vector textPos, medalPos;
3395 if(mySize.x > mySize.y) {
3396 // text on left side
3397 squareSize = min(mySize.y, mySize.x/2);
3398 textPos = pos + eX * 0.5 * max(0, mySize.x/2 - squareSize) + eY * 0.5 * (mySize.y - squareSize);
3399 medalPos = pos + eX * 0.5 * max(0, mySize.x/2 - squareSize) + eX * 0.5 * mySize.x + eY * 0.5 * (mySize.y - squareSize);
3402 squareSize = min(mySize.x, mySize.y/2);
3403 textPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eX * 0.5 * (mySize.x - squareSize);
3404 medalPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eY * 0.5 * mySize.y + eX * 0.5 * (mySize.x - squareSize);
3407 f = time - crecordtime_change_time;
3410 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3411 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);
3413 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3414 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);
3415 drawstring_aspect_expanding(pos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
3416 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);
3420 t = race_server_record;
3421 if(t != srecordtime_prev) {
3422 srecordtime_prev = t;
3423 srecordtime_change_time = time;
3425 f = time - srecordtime_change_time;
3428 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3429 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);
3431 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3432 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);
3433 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);
3434 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);
3437 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
3438 race_status_time = time + 5;
3439 race_status_prev = race_status;
3440 if (race_status_name_prev)
3441 strunzone(race_status_name_prev);
3442 race_status_name_prev = strzone(race_status_name);
3447 a = bound(0, race_status_time - time, 1);
3450 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
3454 rank = race_CheckName(race_status_name);
3458 rankname = count_ordinal(rank);
3461 namepos = medalPos + '0 0.8 0' * squareSize;
3463 rankpos = medalPos + '0 0.15 0' * squareSize;
3465 if(race_status == 0)
3466 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3467 else if(race_status == 1) {
3468 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);
3469 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3470 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3471 } else if(race_status == 2) {
3472 if(race_status_name == GetPlayerName(player_localnum) || !race_myrank || race_myrank < rank)
3473 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);
3475 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);
3476 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3477 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3478 } else if(race_status == 3) {
3479 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);
3480 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3481 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3484 if (race_status_time - time <= 0) {
3485 race_status_prev = -1;
3487 if(race_status_name)
3488 strunzone(race_status_name);
3489 race_status_name = string_null;
3490 if(race_status_name_prev)
3491 strunzone(race_status_name_prev);
3492 race_status_name_prev = string_null;
3496 void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, int layout, int i)
3500 vector color = '0 0 0';
3504 stat = getstatf(STAT_DOM_PPS_RED);
3505 pic = "dom_icon_red";
3509 stat = getstatf(STAT_DOM_PPS_BLUE);
3510 pic = "dom_icon_blue";
3514 stat = getstatf(STAT_DOM_PPS_YELLOW);
3515 pic = "dom_icon_yellow";
3520 stat = getstatf(STAT_DOM_PPS_PINK);
3521 pic = "dom_icon_pink";
3525 float pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS);
3527 if(mySize.x/mySize.y > aspect_ratio)
3529 i = aspect_ratio * mySize.y;
3530 myPos.x = myPos.x + (mySize.x - i) / 2;
3535 i = 1/aspect_ratio * mySize.x;
3536 myPos.y = myPos.y + (mySize.y - i) / 2;
3540 if (layout) // show text too
3543 color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
3544 if (layout == 2) // average pps
3545 drawstring_aspect(myPos + eX * mySize.y, ftos_decimals(stat, 2), eX * (2/3) * mySize.x + eY * mySize.y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
3546 else // percentage of average pps
3547 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);
3551 drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3554 drawsetcliparea(myPos.x, myPos.y + mySize.y * (1 - pps_ratio), mySize.y, mySize.y * pps_ratio);
3555 drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3556 drawresetcliparea();
3560 void HUD_Mod_Dom(vector myPos, vector mySize)
3562 mod_active = 1; // required in each mod function that always shows something
3564 int layout = autocvar_hud_panel_modicons_dom_layout;
3567 aspect_ratio = (layout) ? 3 : 1;
3568 rows = HUD_GetRowCount(team_count, mySize, aspect_ratio);
3569 columns = ceil(team_count/rows);
3572 float row = 0, column = 0;
3573 vector pos, itemSize;
3574 itemSize = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
3575 for(i=0; i<team_count; ++i)
3577 pos = myPos + eX * column * itemSize.x + eY * row * itemSize.y;
3579 DrawDomItem(pos, itemSize, aspect_ratio, layout, i);
3590 void HUD_ModIcons_SetFunc()
3594 case MAPINFO_TYPE_KEYHUNT: HUD_ModIcons_GameType = HUD_Mod_KH; break;
3595 case MAPINFO_TYPE_CTF: HUD_ModIcons_GameType = HUD_Mod_CTF; break;
3596 case MAPINFO_TYPE_NEXBALL: HUD_ModIcons_GameType = HUD_Mod_NexBall; break;
3597 case MAPINFO_TYPE_CTS:
3598 case MAPINFO_TYPE_RACE: HUD_ModIcons_GameType = HUD_Mod_Race; break;
3599 case MAPINFO_TYPE_CA:
3600 case MAPINFO_TYPE_FREEZETAG: HUD_ModIcons_GameType = HUD_Mod_CA; break;
3601 case MAPINFO_TYPE_DOMINATION: HUD_ModIcons_GameType = HUD_Mod_Dom; break;
3602 case MAPINFO_TYPE_KEEPAWAY: HUD_ModIcons_GameType = HUD_Mod_Keepaway; break;
3606 int mod_prev; // previous state of mod_active to check for a change
3608 float mod_change; // "time" when mod_active changed
3610 void HUD_ModIcons(void)
3612 if(intermission == 2) return;
3613 if(!autocvar__hud_configure)
3615 if(!autocvar_hud_panel_modicons) return;
3616 if(!HUD_ModIcons_GameType) return;
3619 HUD_Panel_UpdateCvars();
3621 draw_beginBoldFont();
3623 if(mod_active != mod_prev) {
3625 mod_prev = mod_active;
3628 if(mod_active || autocvar__hud_configure)
3629 mod_alpha = bound(0, (time - mod_change) * 2, 1);
3631 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
3634 HUD_Panel_DrawBg(mod_alpha);
3636 if(panel_bg_padding)
3638 panel_pos += '1 1 0' * panel_bg_padding;
3639 panel_size -= '2 2 0' * panel_bg_padding;
3642 if(autocvar__hud_configure)
3643 HUD_Mod_CTF(panel_pos, panel_size);
3645 HUD_ModIcons_GameType(panel_pos, panel_size);
3650 // Draw pressed keys (#11)
3652 void HUD_PressedKeys(void)
3654 if(intermission == 2) return;
3655 if(!autocvar__hud_configure)
3657 if(!autocvar_hud_panel_pressedkeys) return;
3658 if(spectatee_status <= 0 && autocvar_hud_panel_pressedkeys < 2) return;
3661 HUD_Panel_UpdateCvars();
3664 mySize = panel_size;
3666 HUD_Panel_DrawBg(1);
3667 if(panel_bg_padding)
3669 pos += '1 1 0' * panel_bg_padding;
3670 mySize -= '2 2 0' * panel_bg_padding;
3673 // force custom aspect
3674 float aspect = autocvar_hud_panel_pressedkeys_aspect;
3677 vector newSize = '0 0 0';
3678 if(mySize.x/mySize.y > aspect)
3680 newSize.x = aspect * mySize.y;
3681 newSize.y = mySize.y;
3683 pos.x = pos.x + (mySize.x - newSize.x) / 2;
3687 newSize.y = 1/aspect * mySize.x;
3688 newSize.x = mySize.x;
3690 pos.y = pos.y + (mySize.y - newSize.y) / 2;
3696 keysize = eX * mySize.x * (1/3.0) + eY * mySize.y * (1/(3.0 - !autocvar_hud_panel_pressedkeys_attack));
3698 pressedkeys = getstatf(STAT_PRESSED_KEYS);
3700 if(autocvar_hud_panel_pressedkeys_attack)
3702 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);
3703 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);
3707 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3708 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);
3709 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);
3711 drawpic_aspect_skin(pos, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3712 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);
3713 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);
3716 // Handle chat as a panel (#12)
3720 if(!autocvar__hud_configure)
3722 if (!autocvar_hud_panel_chat)
3724 if (!autocvar_con_chatrect)
3725 cvar_set("con_chatrect", "0");
3728 if(autocvar__con_chat_maximized)
3730 if(!hud_draw_maximized) return;
3732 else if(chat_panel_modified)
3734 panel.update_time = time; // forces reload of panel attributes
3735 chat_panel_modified = false;
3739 HUD_Panel_UpdateCvars();
3741 if(intermission == 2)
3743 // reserve some more space to the mapvote panel
3744 // by resizing and moving chat panel to the bottom
3745 panel_size.y = min(panel_size.y, vid_conheight * 0.2);
3746 panel_pos.y = vid_conheight - panel_size.y - panel_bg_border * 2;
3747 chat_posy = panel_pos.y;
3748 chat_sizey = panel_size.y;
3750 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
3752 panel_pos.y = panel_bg_border;
3753 panel_size.y = vid_conheight - panel_bg_border * 2;
3754 if(panel.current_panel_bg == "0") // force a border when maximized
3757 panel_bg = strcat(hud_skin_path, "/border_default");
3758 if(precache_pic(panel_bg) == "")
3759 panel_bg = "gfx/hud/default/border_default";
3760 if(panel.current_panel_bg)
3761 strunzone(panel.current_panel_bg);
3762 panel.current_panel_bg = strzone(panel_bg);
3763 chat_panel_modified = true;
3765 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an theAlpha of at least 0.75
3770 mySize = panel_size;
3772 HUD_Panel_DrawBg(1);
3774 if(panel_bg_padding)
3776 pos += '1 1 0' * panel_bg_padding;
3777 mySize -= '2 2 0' * panel_bg_padding;
3780 if (!autocvar_con_chatrect)
3781 cvar_set("con_chatrect", "1");
3783 cvar_set("con_chatrect_x", ftos(pos.x/vid_conwidth));
3784 cvar_set("con_chatrect_y", ftos(pos.y/vid_conheight));
3786 cvar_set("con_chatwidth", ftos(mySize.x/vid_conwidth));
3787 cvar_set("con_chat", ftos(floor(mySize.y/autocvar_con_chatsize - 0.5)));
3789 if(autocvar__hud_configure)
3792 chatsize = '1 1 0' * autocvar_con_chatsize;
3793 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over theAlpha and such
3795 for(i = 0; i < autocvar_con_chat; ++i)
3797 if(i == autocvar_con_chat - 1)
3800 a = panel_fg_alpha * floor(((i + 1) * 7 + autocvar_con_chattime)/45);
3801 drawcolorcodedstring(pos, textShortenToWidth(_("^3Player^7: This is the chat area."), mySize.x, chatsize, stringwidth_colors), chatsize, a, DRAWFLAG_NORMAL);
3802 pos.y += chatsize.y;
3807 // Engine info panel (#13)
3814 float frametimeavg1; // 1 frame ago
3815 float frametimeavg2; // 2 frames ago
3816 void HUD_EngineInfo(void)
3818 //if(intermission == 2) return;
3819 if(!autocvar__hud_configure)
3821 if(!autocvar_hud_panel_engineinfo) return;
3824 HUD_Panel_UpdateCvars();
3827 mySize = panel_size;
3829 HUD_Panel_DrawBg(1);
3830 if(panel_bg_padding)
3832 pos += '1 1 0' * panel_bg_padding;
3833 mySize -= '2 2 0' * panel_bg_padding;
3836 float currentTime = gettime(GETTIME_REALTIME);
3837 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
3839 float currentframetime = currentTime - prevfps_time;
3840 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
3841 frametimeavg2 = frametimeavg1;
3842 frametimeavg1 = frametimeavg;
3845 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
3846 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.
3848 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
3849 prevfps = (1/currentframetime);
3850 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"
3852 prevfps_time = currentTime;
3857 if(currentTime - prevfps_time > autocvar_hud_panel_engineinfo_framecounter_time)
3859 prevfps = framecounter/(currentTime - prevfps_time);
3861 prevfps_time = currentTime;
3866 color = HUD_Get_Num_Color (prevfps, 100);
3867 drawstring_aspect(pos, sprintf(_("FPS: %.*f"), autocvar_hud_panel_engineinfo_framecounter_decimals, prevfps), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
3870 // Info messages panel (#14)
3872 #define drawInfoMessage(s) do { \
3873 if(autocvar_hud_panel_infomessages_flip) \
3874 o.x = pos.x + mySize.x - stringwidth(s, true, fontsize); \
3875 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL); \
3876 o.y += fontsize.y; \
3878 void HUD_InfoMessages(void)
3880 if(intermission == 2) return;
3881 if(!autocvar__hud_configure)
3883 if(!autocvar_hud_panel_infomessages) return;
3886 HUD_Panel_UpdateCvars();
3889 mySize = panel_size;
3891 HUD_Panel_DrawBg(1);
3892 if(panel_bg_padding)
3894 pos += '1 1 0' * panel_bg_padding;
3895 mySize -= '2 2 0' * panel_bg_padding;
3898 // always force 5:1 aspect
3899 vector newSize = '0 0 0';
3900 if(mySize.x/mySize.y > 5)
3902 newSize.x = 5 * mySize.y;
3903 newSize.y = mySize.y;
3905 pos.x = pos.x + (mySize.x - newSize.x) / 2;
3909 newSize.y = 1/5 * mySize.x;
3910 newSize.x = mySize.x;
3912 pos.y = pos.y + (mySize.y - newSize.y) / 2;
3921 fontsize = '0.20 0.20 0' * mySize.y;
3927 if(!autocvar__hud_configure)
3929 if(spectatee_status && !intermission)
3932 if(spectatee_status == -1)
3933 s = _("^1Observing");
3935 s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(current_player));
3938 if(spectatee_status == -1)
3939 s = sprintf(_("^1Press ^3%s^1 to spectate"), getcommandkey("primary fire", "+fire"));
3941 s = sprintf(_("^1Press ^3%s^1 or ^3%s^1 for next or previous player"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
3944 if(spectatee_status == -1)
3945 s = sprintf(_("^1Use ^3%s^1 or ^3%s^1 to change the speed"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
3947 s = sprintf(_("^1Press ^3%s^1 to observe"), getcommandkey("secondary fire", "+fire2"));
3950 s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey("server info", "+show_info"));
3953 if(gametype == MAPINFO_TYPE_LMS)
3956 sk = playerslots[player_localnum];
3957 if(sk.(scores[ps_primary]) >= 666)
3958 s = _("^1Match has already begun");
3959 else if(sk.(scores[ps_primary]) > 0)
3960 s = _("^1You have no more lives left");
3962 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
3965 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
3968 //show restart countdown:
3969 if (time < getstatf(STAT_GAMESTARTTIME)) {
3971 //we need to ceil, otherwise the countdown would be off by .5 when using round()
3972 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
3973 s = sprintf(_("^1Game starts in ^3%d^1 seconds"), countdown);
3974 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
3978 if(warmup_stage && !intermission)
3980 s = _("^2Currently in ^1warmup^2 stage!");
3990 if(ready_waiting && !intermission && !spectatee_status)
3992 if(ready_waiting_for_me)
3995 s = sprintf(_("%sPress ^3%s%s to end warmup"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
3997 s = sprintf(_("%sPress ^3%s%s once you are ready"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
4002 s = _("^2Waiting for others to ready up to end warmup...");
4004 s = _("^2Waiting for others to ready up...");
4008 else if(warmup_stage && !intermission && !spectatee_status)
4010 s = sprintf(_("^2Press ^3%s^2 to end warmup"), getcommandkey("ready", "ready"));
4014 if(teamplay && !intermission && !spectatee_status && gametype != MAPINFO_TYPE_CA && teamnagger)
4016 float ts_min = 0, ts_max = 0;
4017 tm = teams.sort_next;
4020 for (; tm.sort_next; tm = tm.sort_next)
4022 if(!tm.team_size || tm.team == NUM_SPECTATOR)
4024 if(!ts_min) ts_min = tm.team_size;
4025 else ts_min = min(ts_min, tm.team_size);
4026 if(!ts_max) ts_max = tm.team_size;
4027 else ts_max = max(ts_max, tm.team_size);
4029 if ((ts_max - ts_min) > 1)
4031 s = strcat(blinkcolor, _("Teamnumbers are unbalanced!"));
4032 tm = GetTeam(myteam, false);
4034 if (tm.team != NUM_SPECTATOR)
4035 if (tm.team_size == ts_max)
4036 s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey("team menu", "menu_showteamselect"), blinkcolor));
4044 s = _("^7Press ^3ESC ^7to show HUD options.");
4046 s = _("^3Doubleclick ^7a panel for panel-specific options.");
4048 s = _("^3CTRL ^7to disable collision testing, ^3SHIFT ^7and");
4050 s = _("^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.");
4055 // Physics panel (#15)
4057 vector acc_prevspeed;
4058 float acc_prevtime, acc_avg, top_speed, top_speed_time;
4059 float physics_update_time, discrete_speed, discrete_acceleration;
4060 void HUD_Physics(void)
4062 if(intermission == 2) return;
4063 if(!autocvar__hud_configure)
4065 if(!autocvar_hud_panel_physics) return;
4066 if(spectatee_status == -1 && (autocvar_hud_panel_physics == 1 || autocvar_hud_panel_physics == 3)) return;
4067 if(autocvar_hud_panel_physics == 3 && !(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) return;
4070 HUD_Panel_UpdateCvars();
4072 draw_beginBoldFont();
4074 HUD_Panel_DrawBg(1);
4075 if(panel_bg_padding)
4077 panel_pos += '1 1 0' * panel_bg_padding;
4078 panel_size -= '2 2 0' * panel_bg_padding;
4081 float acceleration_progressbar_scale = 0;
4082 if(autocvar_hud_panel_physics_progressbar && autocvar_hud_panel_physics_acceleration_progressbar_scale > 1)
4083 acceleration_progressbar_scale = autocvar_hud_panel_physics_acceleration_progressbar_scale;
4086 if (autocvar_hud_panel_physics_text_scale <= 0)
4089 text_scale = min(autocvar_hud_panel_physics_text_scale, 1);
4092 float speed, conversion_factor;
4095 switch(autocvar_hud_panel_physics_speed_unit)
4100 conversion_factor = 1.0;
4104 conversion_factor = 0.0254;
4108 conversion_factor = 0.0254 * 3.6;
4112 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4116 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4120 vector vel = (csqcplayer ? csqcplayer.velocity : pmove_vel);
4122 float max_speed = floor( autocvar_hud_panel_physics_speed_max * conversion_factor + 0.5 );
4123 if (autocvar__hud_configure)
4124 speed = floor( max_speed * 0.65 + 0.5 );
4125 else if(autocvar_hud_panel_physics_speed_vertical)
4126 speed = floor( vlen(vel) * conversion_factor + 0.5 );
4128 speed = floor( vlen(vel - vel.z * '0 0 1') * conversion_factor + 0.5 );
4130 //compute acceleration
4131 float acceleration, f;
4132 if (autocvar__hud_configure)
4133 acceleration = autocvar_hud_panel_physics_acceleration_max * 0.3;
4136 // 1 m/s = 0.0254 qu/s; 1 g = 9.80665 m/s^2
4137 f = time - acc_prevtime;
4138 if(autocvar_hud_panel_physics_acceleration_vertical)
4139 acceleration = (vlen(vel) - vlen(acc_prevspeed));
4141 acceleration = (vlen(vel - '0 0 1' * vel.z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed.z));
4143 acceleration = acceleration * (1 / max(0.0001, f)) * (0.0254 / 9.80665);
4145 acc_prevspeed = vel;
4146 acc_prevtime = time;
4148 if(autocvar_hud_panel_physics_acceleration_movingaverage)
4150 f = bound(0, f * 10, 1);
4151 acc_avg = acc_avg * (1 - f) + acceleration * f;
4152 acceleration = acc_avg;
4156 int acc_decimals = 2;
4157 if(time > physics_update_time)
4159 // workaround for ftos_decimals returning a negative 0
4160 if(discrete_acceleration > -1 / pow(10, acc_decimals) && discrete_acceleration < 0)
4161 discrete_acceleration = 0;
4162 discrete_acceleration = acceleration;
4163 discrete_speed = speed;
4164 physics_update_time += autocvar_hud_panel_physics_update_interval;
4168 float panel_ar = panel_size.x/panel_size.y;
4169 vector speed_offset = '0 0 0', acceleration_offset = '0 0 0';
4170 if (panel_ar >= 5 && !acceleration_progressbar_scale)
4172 panel_size.x *= 0.5;
4173 if (autocvar_hud_panel_physics_flip)
4174 speed_offset.x = panel_size.x;
4176 acceleration_offset.x = panel_size.x;
4180 panel_size.y *= 0.5;
4181 if (autocvar_hud_panel_physics_flip)
4182 speed_offset.y = panel_size.y;
4184 acceleration_offset.y = panel_size.y;
4186 int speed_baralign, acceleration_baralign;
4187 if (autocvar_hud_panel_physics_baralign == 1)
4188 acceleration_baralign = speed_baralign = 1;
4189 else if(autocvar_hud_panel_physics_baralign == 4)
4190 acceleration_baralign = speed_baralign = 2;
4191 else if (autocvar_hud_panel_physics_flip)
4193 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 2);
4194 speed_baralign = (autocvar_hud_panel_physics_baralign == 3);
4198 speed_baralign = (autocvar_hud_panel_physics_baralign == 2);
4199 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 3);
4201 if (autocvar_hud_panel_physics_acceleration_progressbar_mode == 0)
4202 acceleration_baralign = 3; //override hud_panel_physics_baralign value for acceleration
4206 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
4207 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);
4208 vector tmp_offset = '0 0 0', tmp_size = '0 0 0';
4209 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
4211 tmp_size.x = panel_size.x * 0.75;
4212 tmp_size.y = panel_size.y * text_scale;
4214 tmp_offset.x = panel_size.x - tmp_size.x;
4217 tmp_offset.y = (panel_size.y - tmp_size.y) / 2;
4218 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(discrete_speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4224 tmp_offset.x = tmp_size.x;
4225 if (autocvar_hud_panel_physics_speed_unit_show)
4228 tmp_size.x = panel_size.x * (1 - 0.75);
4229 tmp_size.y = panel_size.y * 0.4 * text_scale;
4230 tmp_offset.y = (panel_size.y * 0.4 - tmp_size.y) / 2;
4231 drawstring_aspect(panel_pos + speed_offset + tmp_offset, unit, tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4235 //compute and draw top speed
4236 if (autocvar_hud_panel_physics_topspeed)
4237 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
4239 if (autocvar__hud_configure)
4241 top_speed = floor( max_speed * 0.75 + 0.5 );
4246 if (speed >= top_speed)
4249 top_speed_time = time;
4253 f = max(1, autocvar_hud_panel_physics_topspeed_time);
4254 // divide by f to make it start from 1
4255 f = cos( ((time - top_speed_time) / f) * PI/2 );
4257 else //hide top speed 0, it would be stupid
4262 //top speed progressbar peak
4263 if(speed < top_speed)
4264 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
4267 vector peak_size = '0 0 0';
4268 if (speed_baralign == 0)
4269 peak_offsetX = min(top_speed, max_speed)/max_speed * panel_size.x;
4270 else if (speed_baralign == 1)
4271 peak_offsetX = (1 - min(top_speed, max_speed)/max_speed) * panel_size.x;
4272 else // if (speed_baralign == 2)
4273 peak_offsetX = min(top_speed, max_speed)/max_speed * panel_size.x * 0.5;
4274 peak_size.x = floor(panel_size.x * 0.01 + 1.5);
4275 peak_size.y = panel_size.y;
4276 if (speed_baralign == 2) // draw two peaks, on both sides
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);
4279 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);
4282 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);
4286 tmp_offset.y = panel_size.y * 0.4;
4287 tmp_size.x = panel_size.x * (1 - 0.75);
4288 tmp_size.y = (panel_size.y - tmp_offset.y) * text_scale;
4289 tmp_offset.y += (panel_size.y - tmp_offset.y - tmp_size.y) / 2;
4290 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(top_speed), tmp_size, '1 0 0', f * panel_fg_alpha, DRAWFLAG_NORMAL);
4298 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 3)
4300 vector progressbar_color;
4301 if(acceleration < 0)
4302 progressbar_color = autocvar_hud_progressbar_acceleration_neg_color;
4304 progressbar_color = autocvar_hud_progressbar_acceleration_color;
4306 f = acceleration/autocvar_hud_panel_physics_acceleration_max;
4307 if (autocvar_hud_panel_physics_acceleration_progressbar_nonlinear)
4308 f = (f >= 0 ? sqrt(f) : -sqrt(-f));
4310 if (acceleration_progressbar_scale) // allow progressbar to go out of panel bounds
4312 tmp_size = acceleration_progressbar_scale * panel_size.x * eX + panel_size.y * eY;
4314 if (acceleration_baralign == 1)
4315 tmp_offset.x = panel_size.x - tmp_size.x;
4316 else if (acceleration_baralign == 2 || acceleration_baralign == 3)
4317 tmp_offset.x = (panel_size.x - tmp_size.x) / 2;
4324 tmp_size = panel_size;
4325 tmp_offset = '0 0 0';
4328 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);
4331 if(autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3)
4333 tmp_size.x = panel_size.x;
4334 tmp_size.y = panel_size.y * text_scale;
4336 tmp_offset.y = (panel_size.y - tmp_size.y) / 2;
4338 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);
4344 // CenterPrint (#16)
4346 const int CENTERPRINT_MAX_MSGS = 10;
4347 const int CENTERPRINT_MAX_ENTRIES = 50;
4348 const float CENTERPRINT_SPACING = 0.7;
4350 string centerprint_messages[CENTERPRINT_MAX_MSGS];
4351 int centerprint_msgID[CENTERPRINT_MAX_MSGS];
4352 float centerprint_time[CENTERPRINT_MAX_MSGS];
4353 float centerprint_expire_time[CENTERPRINT_MAX_MSGS];
4354 int centerprint_countdown_num[CENTERPRINT_MAX_MSGS];
4355 bool centerprint_showing;
4357 void centerprint_generic(int new_id, string strMessage, float duration, int countdown_num)
4359 //printf("centerprint_generic(%d, '%s^7', %d, %d);\n", new_id, strMessage, duration, countdown_num);
4362 if(strMessage == "" && new_id == 0)
4365 // strip trailing newlines
4366 j = strlen(strMessage) - 1;
4367 while(substring(strMessage, j, 1) == "\n" && j >= 0)
4369 if (j < strlen(strMessage) - 1)
4370 strMessage = substring(strMessage, 0, j + 1);
4372 if(strMessage == "" && new_id == 0)
4375 // strip leading newlines
4377 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
4380 strMessage = substring(strMessage, j, strlen(strMessage) - j);
4382 if(strMessage == "" && new_id == 0)
4385 if (!centerprint_showing)
4386 centerprint_showing = true;
4388 for (i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
4390 if (j == CENTERPRINT_MAX_MSGS)
4392 if (new_id && new_id == centerprint_msgID[j])
4394 if (strMessage == "" && centerprint_messages[j] != "" && centerprint_countdown_num[j] == 0)
4396 // fade out the current msg (duration and countdown_num are ignored)
4397 centerprint_time[j] = min(5, autocvar_hud_panel_centerprint_fade_out);
4398 if (centerprint_expire_time[j] > time + min(5, autocvar_hud_panel_centerprint_fade_out) || centerprint_expire_time[j] < time)
4399 centerprint_expire_time[j] = time + min(5, autocvar_hud_panel_centerprint_fade_out);
4402 break; // found a msg with the same id, at position j
4406 if (i == CENTERPRINT_MAX_MSGS)
4408 // a msg with the same id was not found, add the msg at the next position
4410 if (cpm_index == -1)
4411 cpm_index = CENTERPRINT_MAX_MSGS - 1;
4414 if(centerprint_messages[j])
4415 strunzone(centerprint_messages[j]);
4416 centerprint_messages[j] = strzone(strMessage);
4417 centerprint_msgID[j] = new_id;
4420 centerprint_time[j] = -1;
4421 centerprint_expire_time[j] = time;
4426 duration = max(1, autocvar_hud_panel_centerprint_time);
4427 centerprint_time[j] = duration;
4428 centerprint_expire_time[j] = time + duration;
4430 centerprint_countdown_num[j] = countdown_num;
4433 void centerprint_hud(string strMessage)
4435 centerprint_generic(0, strMessage, autocvar_hud_panel_centerprint_time, 0);
4438 void reset_centerprint_messages(void)
4441 for (i=0; i<CENTERPRINT_MAX_MSGS; ++i)
4443 centerprint_expire_time[i] = 0;
4444 centerprint_time[i] = 1;
4445 centerprint_msgID[i] = 0;
4446 if(centerprint_messages[i])
4447 strunzone(centerprint_messages[i]);
4448 centerprint_messages[i] = string_null;
4451 float hud_configure_cp_generation_time;
4452 void HUD_CenterPrint (void)
4454 if(intermission == 2) return;
4455 if(!autocvar__hud_configure)
4457 if(!autocvar_hud_panel_centerprint) return;
4459 if(hud_configure_prev)
4460 reset_centerprint_messages();
4464 if(!hud_configure_prev)
4465 reset_centerprint_messages();
4466 if (time > hud_configure_cp_generation_time)
4468 if(highlightedPanel == HUD_PANEL(CENTERPRINT))
4473 centerprint_generic(floor(r*1000), strcat(sprintf("^3Countdown message at time %s", seconds_tostring(time)), ", seconds left: ^COUNT"), 1, 10);
4475 centerprint_generic(0, sprintf("^1Multiline message at time %s that\n^1lasts longer than normal", seconds_tostring(time)), 20, 0);
4477 centerprint_hud(sprintf("Message at time %s", seconds_tostring(time)));
4478 hud_configure_cp_generation_time = time + 1 + random()*4;
4482 centerprint_generic(0, sprintf("Centerprint message", seconds_tostring(time)), 10, 0);
4483 hud_configure_cp_generation_time = time + 10 - random()*3;
4488 // this panel fades only when the menu does
4489 float hud_fade_alpha_save = 0;
4490 if(scoreboard_fade_alpha)
4492 hud_fade_alpha_save = hud_fade_alpha;
4493 hud_fade_alpha = 1 - autocvar__menu_alpha;
4495 HUD_Panel_UpdateCvars();
4497 if ( HUD_Radar_Clickable() )
4499 if (hud_panel_radar_bottom >= 0.96 * vid_conheight)
4502 panel_pos = eY * hud_panel_radar_bottom + eX * 0.5 * (vid_conwidth - panel_size_x);
4503 panel_size_y = min(panel_size_y, vid_conheight - hud_panel_radar_bottom);
4505 else if(scoreboard_fade_alpha)
4507 hud_fade_alpha = hud_fade_alpha_save;
4509 // move the panel below the scoreboard
4510 if (scoreboard_bottom >= 0.96 * vid_conheight)
4514 target_pos = eY * scoreboard_bottom + eX * 0.5 * (vid_conwidth - panel_size.x);
4516 if(target_pos.y > panel_pos.y)
4518 panel_pos = panel_pos + (target_pos - panel_pos) * sqrt(scoreboard_fade_alpha);
4519 panel_size.y = min(panel_size.y, vid_conheight - scoreboard_bottom);
4523 HUD_Panel_DrawBg(1);
4525 if (!centerprint_showing)
4528 if(panel_bg_padding)
4530 panel_pos += '1 1 0' * panel_bg_padding;
4531 panel_size -= '2 2 0' * panel_bg_padding;
4537 // entries = bound(1, floor(CENTERPRINT_MAX_ENTRIES * 4 * panel_size_y/panel_size_x), CENTERPRINT_MAX_ENTRIES);
4538 // height = panel_size_y/entries;
4539 // fontsize = '1 1 0' * height;
4540 height = vid_conheight/50 * autocvar_hud_panel_centerprint_fontscale;
4541 fontsize = '1 1 0' * height;
4542 entries = bound(1, floor(panel_size.y/height), CENTERPRINT_MAX_ENTRIES);
4545 float a, sz, align, current_msg_posY = 0, msg_size;
4548 bool all_messages_expired = true;
4551 if (autocvar_hud_panel_centerprint_flip)
4552 pos.y += panel_size.y;
4553 align = bound(0, autocvar_hud_panel_centerprint_align, 1);
4554 for (g=0, i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
4556 if (j == CENTERPRINT_MAX_MSGS)
4558 if (centerprint_expire_time[j] <= time)
4560 if (centerprint_countdown_num[j] && centerprint_time[j] > 0)
4562 centerprint_countdown_num[j] = centerprint_countdown_num[j] - 1;
4563 if (centerprint_countdown_num[j] == 0)
4565 centerprint_expire_time[j] = centerprint_expire_time[j] + centerprint_time[j];
4567 else if(centerprint_time[j] != -1)
4571 all_messages_expired = false;
4573 // fade the centerprint_hud in/out
4574 if(centerprint_time[j] < 0) // Expired but forced. Expire time is the fade-in time.
4575 a = (time - centerprint_expire_time[j]) / max(0.0001, autocvar_hud_panel_centerprint_fade_in);
4576 else if(centerprint_expire_time[j] - autocvar_hud_panel_centerprint_fade_out > time) // Regularily printed. Not fading out yet.
4577 a = (time - (centerprint_expire_time[j] - centerprint_time[j])) / max(0.0001, autocvar_hud_panel_centerprint_fade_in);
4578 else // Expiring soon, so fade it out.
4579 a = (centerprint_expire_time[j] - time) / max(0.0001, autocvar_hud_panel_centerprint_fade_out);
4581 // while counting down show it anyway in order to hold the current message position
4582 if (a <= 0.5/255.0 && centerprint_countdown_num[j] == 0) // Guaranteed invisible - don't show.
4587 // set the size from fading in/out before subsequent fading
4588 sz = autocvar_hud_panel_centerprint_fade_minfontsize + a * (1 - autocvar_hud_panel_centerprint_fade_minfontsize);
4590 // also fade it based on positioning
4591 if(autocvar_hud_panel_centerprint_fade_subsequent)
4593 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
4594 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
4596 a *= panel_fg_alpha;
4598 // finally set the size based on the new theAlpha from subsequent fading
4599 sz = sz * (autocvar_hud_panel_centerprint_fade_subsequent_minfontsize + a * (1 - autocvar_hud_panel_centerprint_fade_subsequent_minfontsize));
4600 drawfontscale = sz * '1 1 0';
4602 if (centerprint_countdown_num[j])
4603 n = tokenizebyseparator(strreplace("^COUNT", count_seconds(centerprint_countdown_num[j]), centerprint_messages[j]), "\n");
4605 n = tokenizebyseparator(centerprint_messages[j], "\n");
4607 if (autocvar_hud_panel_centerprint_flip)
4609 // check if the message can be entirely shown
4610 for(k = 0; k < n; ++k)
4612 getWrappedLine_remaining = argv(k);
4613 while(getWrappedLine_remaining)
4615 ts = getWrappedLine(panel_size.x * sz, fontsize, stringwidth_colors);
4617 pos.y -= fontsize.y;
4619 pos.y -= fontsize.y * CENTERPRINT_SPACING/2;
4622 current_msg_posY = pos.y; // save starting pos (first line) of the current message
4626 for(k = 0; k < n; ++k)
4628 getWrappedLine_remaining = argv(k);
4629 while(getWrappedLine_remaining)
4631 ts = getWrappedLine(panel_size.x * sz, fontsize, stringwidth_colors);
4635 pos.x = panel_pos.x + (panel_size.x - stringwidth(ts, true, fontsize)) * align;
4636 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.
4637 drawcolorcodedstring(pos + eY * 0.5 * (1 - sz) * fontsize.y, ts, fontsize, a, DRAWFLAG_NORMAL);
4638 pos.y += fontsize.y;
4641 pos.y += fontsize.y * CENTERPRINT_SPACING/2;
4645 ++g; // move next position number up
4647 msg_size = pos.y - msg_size;
4648 if (autocvar_hud_panel_centerprint_flip)
4650 pos.y = current_msg_posY - CENTERPRINT_SPACING * fontsize.y;
4651 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
4652 pos.y += (msg_size + CENTERPRINT_SPACING * fontsize.y) * (1 - sqrt(sz));
4654 if (pos.y < panel_pos.y) // check if the next message can be shown
4656 drawfontscale = '1 1 0';
4662 pos.y += CENTERPRINT_SPACING * fontsize.y;
4663 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
4664 pos.y -= (msg_size + CENTERPRINT_SPACING * fontsize.y) * (1 - sqrt(sz));
4666 if(pos.y > panel_pos.y + panel_size.y - fontsize.y) // check if the next message can be shown
4668 drawfontscale = '1 1 0';
4673 drawfontscale = '1 1 0';
4674 if (all_messages_expired)
4676 centerprint_showing = false;
4677 reset_centerprint_messages();
4684 #include "../common/minigames/cl_minigames_hud.qc"
4689 #include "quickmenu.qc"
4698 bool HUD_Panel_CheckFlags(int showflags)
4700 if ( HUD_Minigame_Showpanels() )
4701 return showflags & PANEL_SHOW_MINIGAME;
4702 return showflags & PANEL_SHOW_MAINGAME;
4705 void HUD_Panel_Draw(entity panent)
4708 if ( HUD_Panel_CheckFlags(panel.panel_showflags) )
4712 void HUD_Reset (void)
4714 // reset gametype specific icons
4715 if(gametype == MAPINFO_TYPE_CTF)
4716 HUD_Mod_CTF_Reset();
4719 void HUD_Main (void)
4722 // global hud theAlpha fade
4723 if(menu_enabled == 1)
4726 hud_fade_alpha = (1 - autocvar__menu_alpha);
4728 if(scoreboard_fade_alpha)
4729 hud_fade_alpha = (1 - scoreboard_fade_alpha);
4731 HUD_Configure_Frame();
4733 // panels that we want to be active together with the scoreboard
4734 // they must fade only when the menu does
4735 if(scoreboard_fade_alpha == 1)
4737 HUD_Panel_Draw(HUD_PANEL(CENTERPRINT));
4741 if(!autocvar__hud_configure && !hud_fade_alpha)
4744 HUD_Panel_Draw(HUD_PANEL(VOTE));
4750 if (hud_skin_prev != autocvar_hud_skin)
4753 strunzone(hud_skin_path);
4754 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
4756 strunzone(hud_skin_prev);
4757 hud_skin_prev = strzone(autocvar_hud_skin);
4761 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4765 float hud_dock_color_team = autocvar_hud_dock_color_team;
4766 if((teamplay) && hud_dock_color_team) {
4767 if(autocvar__hud_configure && myteam == NUM_SPECTATOR)
4768 color = '1 0 0' * hud_dock_color_team;
4770 color = myteamcolors * hud_dock_color_team;
4772 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
4773 color = '1 0 0' * hud_dock_color_team;
4777 string hud_dock_color = autocvar_hud_dock_color;
4778 if(hud_dock_color == "shirt") {
4779 f = stof(getplayerkeyvalue(current_player, "colors"));
4780 color = colormapPaletteColor(floor(f / 16), 0);
4782 else if(hud_dock_color == "pants") {
4783 f = stof(getplayerkeyvalue(current_player, "colors"));
4784 color = colormapPaletteColor(f % 16, 1);
4787 color = stov(hud_dock_color);
4791 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4792 if(precache_pic(pic) == "") {
4793 pic = strcat(hud_skin_path, "/dock_medium");
4794 if(precache_pic(pic) == "") {
4795 pic = "gfx/hud/default/dock_medium";
4798 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...
4801 // cache the panel order into the panel_order array
4802 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4803 for(i = 0; i < hud_panels_COUNT; ++i)
4804 panel_order[i] = -1;
4807 bool warning = false;
4808 int argc = tokenize_console(autocvar__hud_panelorder);
4809 if (argc > hud_panels_COUNT)
4811 //first detect wrong/missing panel numbers
4812 for(i = 0; i < hud_panels_COUNT; ++i) {
4813 p_num = stoi(argv(i));
4814 if (p_num >= 0 && p_num < hud_panels_COUNT) { //correct panel number?
4815 if (panel_order[p_num] == -1) //found for the first time?
4816 s = strcat(s, ftos(p_num), " ");
4817 panel_order[p_num] = 1; //mark as found
4822 for(i = 0; i < hud_panels_COUNT; ++i) {
4823 if (panel_order[i] == -1) {
4825 s = strcat(s, ftos(i), " "); //add missing panel number
4829 LOG_TRACE("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n");
4831 cvar_set("_hud_panelorder", s);
4832 if(hud_panelorder_prev)
4833 strunzone(hud_panelorder_prev);
4834 hud_panelorder_prev = strzone(s);
4836 //now properly set panel_order
4837 tokenize_console(s);
4838 for(i = 0; i < hud_panels_COUNT; ++i) {
4839 panel_order[i] = stof(argv(i));
4843 hud_draw_maximized = 0;
4844 // draw panels in the order specified by panel_order array
4845 for(i = hud_panels_COUNT - 1; i >= 0; --i)
4846 HUD_Panel_Draw(hud_panels[panel_order[i]]);
4848 hud_draw_maximized = 1; // panels that may be maximized must check this var
4849 // draw maximized panels on top
4850 if(hud_panel_radar_maximized)
4851 HUD_Panel_Draw(HUD_PANEL(RADAR));
4852 if(autocvar__con_chat_maximized)
4853 HUD_Panel_Draw(HUD_PANEL(CHAT));
4854 if(hud_panel_quickmenu)
4855 HUD_Panel_Draw(HUD_PANEL(QUICKMENU));
4857 HUD_Configure_PostDraw();
4859 hud_configure_prev = autocvar__hud_configure;