7 // a border picture is a texture containing nine parts:
8 // 1/4 width: left part
9 // 1/2 width: middle part (stretched)
10 // 1/4 width: right part
12 // 1/4 height: top part
13 // 1/2 height: middle part (stretched)
14 // 1/4 height: bottom part
15 void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize)
17 if (theBorderSize_x < 0 && theBorderSize_y < 0) // draw whole image as it is
19 drawpic(theOrigin, pic, theSize, theColor, theAlpha, 0);
22 if (theBorderSize_x == 0 && theBorderSize_y == 0) // no border
24 // draw only the central part
25 drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
32 //pic = draw_UseSkinFor(pic);
33 width = eX * theSize_x;
34 height = eY * theSize_y;
35 if(theSize_x <= theBorderSize_x * 2)
37 // not wide enough... draw just left and right then
38 bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
39 if(theSize_y <= theBorderSize_y * 2)
41 // not high enough... draw just corners
42 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
43 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
44 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
45 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
46 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
50 dY = theBorderSize_x * eY;
51 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
52 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
53 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
54 drawsubpic(theOrigin + width * 0.5 + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0' + eX - bW, '0 0.5 0' + bW, theColor, theAlpha, 0);
55 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
56 drawsubpic(theOrigin + width * 0.5 + height - dY, width * 0.5 + dY, pic, '0 0.75 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
61 if(theSize_y <= theBorderSize_y * 2)
63 // not high enough... draw just top and bottom then
64 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
65 dX = theBorderSize_x * eX;
66 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
67 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
68 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
69 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
70 drawsubpic(theOrigin + dX + height * 0.5, width - 2 * dX + height * 0.5, pic, '0.25 0 0' + eY - bH, '0.5 0 0' + bH, theColor, theAlpha, 0);
71 drawsubpic(theOrigin + width - dX + height * 0.5, dX + height * 0.5, pic, '0.75 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
75 dX = theBorderSize_x * eX;
76 dY = theBorderSize_x * eY;
77 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
78 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
79 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
80 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
81 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
82 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
83 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
84 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
85 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
90 vector HUD_Get_Num_Color (float x, float maxvalue)
98 else if(x > maxvalue * 0.75) {
99 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
100 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
103 else if(x > maxvalue * 0.5) {
104 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
105 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
106 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
108 else if(x > maxvalue * 0.25) {
111 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
113 else if(x > maxvalue * 0.1) {
115 color_y = (x-20)*90/27/100; // green value between 0 -> 1
116 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
126 float stringwidth_colors(string s, vector theSize)
128 return stringwidth(s, TRUE, theSize);
131 float stringwidth_nocolors(string s, vector theSize)
133 return stringwidth(s, FALSE, theSize);
136 #define CENTERPRINT_MAX_LINES 30
137 string centerprint_messages[CENTERPRINT_MAX_LINES];
138 float centerprint_width[CENTERPRINT_MAX_LINES];
139 float centerprint_time;
140 float centerprint_expire;
141 float centerprint_num;
142 float centerprint_offset_hint;
143 vector centerprint_fontsize;
145 void centerprint(string strMessage)
147 float i, j, n, hcount;
150 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
152 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
154 if(autocvar_scr_centertime <= 0)
160 // strip trailing newlines
161 j = strlen(strMessage) - 1;
162 while(substring(strMessage, j, 1) == "\n" && j >= 0)
164 strMessage = substring(strMessage, 0, j + 1);
169 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
171 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
173 strMessage = substring(strMessage, j, strlen(strMessage) - j);
174 centerprint_offset_hint = j;
179 // if we get here, we have a message. Initialize its height.
182 n = tokenizebyseparator(strMessage, "\n");
184 for(j = 0; j < n; ++j)
186 getWrappedLine_remaining = argv(j);
187 while(getWrappedLine_remaining)
189 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
190 if(centerprint_messages[i] != s) // don't fade the same message in, looks stupid
191 centerprint_time = time;
192 if(centerprint_messages[i])
193 strunzone(centerprint_messages[i]);
194 centerprint_messages[i] = strzone(s);
195 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
198 // half height for empty lines looks better
204 if(i >= CENTERPRINT_MAX_LINES)
210 h = centerprint_fontsize_y*hcount;
212 havail = vid_conheight;
213 if(autocvar_con_chatpos < 0)
214 havail -= (-autocvar_con_chatpos + autocvar_con_chat) * autocvar_con_chatsize; // avoid overlapping chat
215 if(havail > vid_conheight - 70)
216 havail = vid_conheight - 70; // avoid overlapping HUD
219 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
221 // here, the centerprint would cover the crosshair. REALLY BAD.
222 forbiddenmin = vid_conheight * 0.5 - h - 16;
223 forbiddenmax = vid_conheight * 0.5 + 16;
225 allowedmin = scoreboard_bottom;
226 allowedmax = havail - h;
227 preferred = (havail - h)/2;
230 // possible orderings (total: 4! / 4 = 6)
231 // allowedmin allowedmax forbiddenmin forbiddenmax
232 // forbiddenmin forbiddenmax allowedmin allowedmax
233 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
235 // forbidden doesn't matter in this case
236 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
238 // allowedmin forbiddenmin allowedmax forbiddenmax
239 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
241 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
243 // allowedmin forbiddenmin forbiddenmax allowedmax
244 else if(allowedmin < forbiddenmin)
246 // make sure the forbidden zone is not covered
247 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
248 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
250 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
252 // forbiddenmin allowedmin allowedmax forbiddenmax
253 else if(allowedmax < forbiddenmax)
255 // it's better to leave the allowed zone (overlap with scoreboard) than
256 // to cover the forbidden zone (crosshair)
257 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
258 centerprint_start_y = forbiddenmax;
260 centerprint_start_y = forbiddenmin;
262 // forbiddenmin allowedmin forbiddenmax allowedmax
265 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
272 centerprint_expire = time + autocvar_scr_centertime;
275 void HUD_DrawCenterPrint (void)
282 if(time - centerprint_time < 0.25)
283 a = (time - centerprint_time) / 0.25;
285 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
292 if(centerprint_num * autocvar_scr_centersize > 24 && scoreboard_active) // 24 = height of Scoreboard text
293 centerprint_start_y = scoreboard_bottom + centerprint_fontsize_y;
295 pos = centerprint_start;
296 for (i=0; i<centerprint_num; i = i + 1)
298 ts = centerprint_messages[i];
299 drawfontscale = sz * '1 1 0';
300 drawfont = hud_bigfont;
301 pos_x = (vid_conwidth - stringwidth(ts, TRUE, centerprint_fontsize)) * 0.5;
304 drawcolorcodedstring(pos + '0 1 0' * (1 - sz) * 0.5 *centerprint_fontsize_y, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
305 pos_y = pos_y + centerprint_fontsize_y;
308 // half height for empty lines looks better
309 pos_y = pos_y + sz * centerprint_fontsize_y * 0.5;
310 drawfontscale = '1 1 0';
315 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
317 position_x -= 2 / 3 * strlen(text) * scale_x;
318 drawstring(position, text, scale, rgb, alpha, flag);
321 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
323 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
324 drawstring(position, text, scale, rgb, alpha, flag);
327 // return the string of the given race place
328 string race_PlaceName(float pos) {
336 return strcat(ftos(pos), "th");
339 // return the string of the onscreen race timer
340 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
348 if(histime == 0) // goal hit
352 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
362 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
368 lapstr = strcat(" (-", ftos(lapdelta), "L)");
371 else if(lapdelta < 0)
373 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
377 else if(histime > 0) // anticipation
379 if(mytime >= histime)
380 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
382 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
389 cpname = "Start line";
391 cpname = "Finish line";
393 cpname = strcat("Intermediate ", ftos(cp));
395 cpname = "Finish line";
398 return strcat(col, cpname);
399 else if(hisname == "")
400 return strcat(col, cpname, " (", timestr, ")");
402 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
405 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
406 float race_CheckName(string net_name) {
408 for (i=RANKINGS_CNT-1;i>=0;--i)
409 if(grecordholder[i] == net_name)
420 // draw the background/borders
421 #define HUD_Panel_DrawBg(alpha)\
423 draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * alpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));\
424 if(highlightedPanel == hud_configure_active_panel && autocvar__hud_configure)\
426 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);\
427 } ENDS_WITH_CURLY_BRACE
429 //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
430 void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, float vertical, float baralign, vector theColor, float theAlpha, float drawflag)
432 if(length_ratio <= 0 || !theAlpha)
438 vector width, height;
440 pic = strcat(hud_skin_path, "/", pic, "_vertical");
441 if(precache_pic(pic) == "") {
442 pic = "gfx/hud/default/statusbar_vertical";
445 if (baralign == 1) // bottom align
446 theOrigin_y += (1 - length_ratio) * theSize_y;
447 else if (baralign == 2) // center align
448 theOrigin_y += 0.5 * (1 - length_ratio) * theSize_y;
449 theSize_y *= length_ratio;
452 width = eX * theSize_x;
453 height = eY * theSize_y;
454 if(theSize_y <= theSize_x * 2)
456 // button not high enough
457 // draw just upper and lower part then
458 square = eY * theSize_y * 0.5;
459 bH = eY * (0.25 * theSize_y / (theSize_x * 2));
460 drawsubpic(theOrigin, square + width, pic, '0 0 0', eX + bH, theColor, theAlpha, drawflag);
461 drawsubpic(theOrigin + square, square + width, pic, eY - bH, eX + bH, theColor, theAlpha, drawflag);
465 square = eY * theSize_x;
466 drawsubpic(theOrigin, width + square, pic, '0 0 0', '1 0.25 0', theColor, theAlpha, drawflag);
467 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0 0.25 0', '1 0.5 0', theColor, theAlpha, drawflag);
468 drawsubpic(theOrigin + height - square, width + square, pic, '0 0.75 0', '1 0.25 0', theColor, theAlpha, drawflag);
471 pic = strcat(hud_skin_path, "/", pic);
472 if(precache_pic(pic) == "") {
473 pic = "gfx/hud/default/statusbar";
476 if (baralign == 1) // right align
477 theOrigin_x += (1 - length_ratio) * theSize_x;
478 else if (baralign == 2) // center align
479 theOrigin_x += 0.5 * (1 - length_ratio) * theSize_x;
480 theSize_x *= length_ratio;
483 width = eX * theSize_x;
484 height = eY * theSize_y;
485 if(theSize_x <= theSize_y * 2)
487 // button not wide enough
488 // draw just left and right part then
489 square = eX * theSize_x * 0.5;
490 bW = eX * (0.25 * theSize_x / (theSize_y * 2));
491 drawsubpic(theOrigin, square + height, pic, '0 0 0', eY + bW, theColor, theAlpha, drawflag);
492 drawsubpic(theOrigin + square, square + height, pic, eX - bW, eY + bW, theColor, theAlpha, drawflag);
496 square = eX * theSize_y;
497 drawsubpic(theOrigin, height + square, pic, '0 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
498 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0.25 0 0', '0.5 1 0', theColor, theAlpha, drawflag);
499 drawsubpic(theOrigin + width - square, height + square, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
504 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
510 pic = strcat(hud_skin_path, "/num_leading");
511 if(precache_pic(pic) == "") {
512 pic = "gfx/hud/default/num_leading";
515 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
516 if(mySize_x/mySize_y > 2)
517 drawsubpic(pos + eX * mySize_y, eX * (mySize_x - 2 * mySize_y) + eY * mySize_y, pic, '0.25 0 0', '0.5 1 0', color, alpha, drawflag);
518 drawsubpic(pos + eX * mySize_x - eX * min(mySize_x * 0.5, mySize_y), eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0.75 0 0', '0.25 1 0', color, alpha, drawflag);
523 entity weaponorder[WEP_MAXCOUNT];
524 void weaponorder_swap(float i, float j, entity pass)
528 weaponorder[i] = weaponorder[j];
532 string weaponorder_cmp_str;
533 float weaponorder_cmp(float i, float j, entity pass)
536 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
537 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
538 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)
541 float GetAmmoStat(float i)
545 case 0: return STAT_SHELLS;
546 case 1: return STAT_NAILS;
547 case 2: return STAT_ROCKETS;
548 case 3: return STAT_CELLS;
549 case 4: return STAT_FUEL;
554 float GetAmmoTypeForWep(float i)
558 case WEP_SHOTGUN: return 0;
559 case WEP_UZI: return 1;
560 case WEP_GRENADE_LAUNCHER: return 2;
561 case WEP_MINE_LAYER: return 2;
562 case WEP_ELECTRO: return 3;
563 case WEP_CRYLINK: return 3;
564 case WEP_HLAC: return 3;
565 case WEP_MINSTANEX: return 3;
566 case WEP_NEX: return 3;
567 case WEP_CAMPINGRIFLE: return 1;
568 case WEP_HAGAR: return 2;
569 case WEP_ROCKET_LAUNCHER: return 2;
570 case WEP_SEEKER: return 2;
571 case WEP_FIREBALL: return 4;
572 case WEP_HOOK: return 3;
577 void HUD_Weapons(void)
580 float center_x, center_y;
582 if(!autocvar__hud_configure)
584 if(!autocvar_hud_panel_weapons) return;
585 if(spectatee_status == -1) return;
588 hud_configure_active_panel = HUD_PANEL_WEAPONS;
590 float timeout = autocvar_hud_panel_weapons_timeout;
591 float timeout_effect_length, timein_effect_length;
592 if (autocvar_hud_panel_weapons_timeout_effect == 0)
594 timeout_effect_length = 0;
595 timein_effect_length = 0;
599 timeout_effect_length = 0.75;
600 timein_effect_length = 0.375;
603 if (timeout && time >= weapontime + timeout + timeout_effect_length && !autocvar__hud_configure)
605 weaponprevtime = time;
609 HUD_Panel_UpdateCvars(weapons);
611 if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
613 f = (time - (weapontime + timeout)) / timeout_effect_length;
614 if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3)
616 panel_bg_alpha *= (1 - f);
617 panel_fg_alpha *= (1 - f);
619 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
621 f *= f; // for a cooler movement
622 center_x = panel_pos_x + panel_size_x/2;
623 center_y = panel_pos_y + panel_size_y/2;
624 screen_ar = vid_conwidth/vid_conheight;
625 if (center_x/center_y < screen_ar) //bottom left
627 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
628 panel_pos_y += f * (vid_conheight - panel_pos_y);
630 panel_pos_x -= f * (panel_pos_x + panel_size_x);
634 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
635 panel_pos_x += f * (vid_conwidth - panel_pos_x);
637 panel_pos_y -= f * (panel_pos_y + panel_size_y);
640 weaponprevtime = time - (1 - f) * timein_effect_length;
642 else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure)
644 f = (time - weaponprevtime) / timein_effect_length;
645 if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3)
647 panel_bg_alpha *= (f);
648 panel_fg_alpha *= (f);
650 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
652 f *= f; // for a cooler movement
654 center_x = panel_pos_x + panel_size_x/2;
655 center_y = panel_pos_y + panel_size_y/2;
656 screen_ar = vid_conwidth/vid_conheight;
657 if (center_x/center_y < screen_ar) //bottom left
659 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
660 panel_pos_y += f * (vid_conheight - panel_pos_y);
662 panel_pos_x -= f * (panel_pos_x + panel_size_x);
666 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
667 panel_pos_x += f * (vid_conwidth - panel_pos_x);
669 panel_pos_y -= f * (panel_pos_y + panel_size_y);
674 float i, weapid, wpnalpha, weapon_cnt;
676 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
678 self = get_weaponinfo(i);
679 if(self.impulse >= 0)
683 // TODO make this configurable
684 if(weaponorder_bypriority != autocvar_cl_weaponpriority)
686 if(weaponorder_bypriority)
687 strunzone(weaponorder_bypriority);
688 if(weaponorder_byimpulse)
689 strunzone(weaponorder_byimpulse);
691 weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
692 weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
693 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
696 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
698 self = get_weaponinfo(i);
699 if(self.impulse >= 0)
701 weaponorder[weapon_cnt] = self;
705 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
707 weaponorder_cmp_str = string_null;
713 panel_pos += '1 1 0' * panel_bg_padding;
714 panel_size -= '2 2 0' * panel_bg_padding;
717 if(autocvar_hud_panel_weapons_fade)
719 wpnalpha = 3.2 - 2 * (time - weapontime);
720 wpnalpha = bound(0.7, wpnalpha, 1) * panel_fg_alpha;
723 wpnalpha = panel_fg_alpha;
726 float aspect = autocvar_hud_panel_weapons_aspect;
727 rows = panel_size_y/panel_size_x;
728 rows = bound(1, floor((sqrt(4 * aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
730 columns = ceil(WEP_COUNT/rows);
733 float a, type, fullammo;
735 when = autocvar_hud_panel_weapons_complainbubble_time;
737 fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
745 wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
746 float barsize_x, barsize_y, baroffset_x, baroffset_y;
747 if (autocvar_hud_panel_weapons_ammo)
749 ammo_color = stov(autocvar_hud_panel_weapons_ammo_color);
750 ammo_alpha = panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha;
753 if(wpnsize_x/wpnsize_y > aspect)
755 barsize_x = aspect * wpnsize_y;
756 barsize_y = wpnsize_y;
757 baroffset_x = (wpnsize_x - barsize_x) / 2;
761 barsize_y = 1/aspect * wpnsize_x;
762 barsize_x = wpnsize_x;
763 baroffset_y = (wpnsize_y - barsize_y) / 2;
769 if(autocvar_hud_panel_weapons_accuracy && acc_levels)
771 show_accuracy = true;
772 if (acc_col_x[0] == -1)
773 for (i = 0; i < acc_levels; ++i)
774 acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
777 float weapons_st = getstati(STAT_WEAPONS);
778 float label = autocvar_hud_panel_weapons_label;
780 for(i = 0; i < weapon_cnt; ++i)
782 wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y;
784 self = weaponorder[i];
785 weapid = self.impulse;
787 // draw background behind currently selected weapon
788 if(self.weapon == activeweapon)
789 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
791 // draw the weapon accuracy
794 weapon_stats = weapon_accuracy[self.weapon-WEP_FIRST];
795 if(weapon_stats >= 0)
797 // find the max level lower than weapon_stats
800 while ( j && weapon_stats < acc_lev[j] )
803 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
805 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
807 color = color + factor * (acc_col[j+1] - color);
809 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
813 // draw the weapon icon
814 if((weapid >= 0) && (weapons_st & self.weapons))
816 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
818 if(label == 1) // weapon number
819 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
820 else if(label == 2) // bind
821 drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
823 // draw ammo status bar
824 if(autocvar_hud_panel_weapons_ammo && weapid != WEP_TUBA && weapid != WEP_LASER && weapid != WEP_PORTO)
827 type = GetAmmoTypeForWep(weapid);
829 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
834 case 0: fullammo = autocvar_hud_panel_weapons_ammo_full_shells; break;
835 case 1: fullammo = autocvar_hud_panel_weapons_ammo_full_nails; break;
836 case 2: fullammo = autocvar_hud_panel_weapons_ammo_full_rockets; break;
837 case 3: fullammo = autocvar_hud_panel_weapons_ammo_full_cells; break;
838 case 4: fullammo = autocvar_hud_panel_weapons_ammo_full_fuel; break;
839 default: fullammo = 60;
843 wpnpos_x + baroffset_x,
844 wpnpos_y + baroffset_y,
845 barsize_x * bound(0, a/fullammo, 1),
847 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, ammo_color, ammo_alpha, DRAWFLAG_NORMAL);
853 // draw a "ghost weapon icon" if you don't have the weapon
856 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
859 // draw the complain message
860 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
864 if(complain_weapon_time + when > time)
867 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
871 if(complain_weapon_time + when > time)
878 if(complain_weapon_type == 0) {
880 color = stov(autocvar_hud_panel_weapons_complainbubble_color_outofammo);
882 else if(complain_weapon_type == 1) {
884 color = stov(autocvar_hud_panel_weapons_complainbubble_color_donthave);
888 color = stov(autocvar_hud_panel_weapons_complainbubble_color_unavailable);
890 float padding = autocvar_hud_panel_weapons_complainbubble_padding;
891 drawpic_aspect_skin(wpnpos + '1 1 0' * padding, "weapon_complainbubble", wpnsize - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
892 drawstring_aspect(wpnpos + '1 1 0' * padding, s, wpnsize - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
908 float GetAmmoItemCode(float i)
912 case 0: return IT_SHELLS;
913 case 1: return IT_NAILS;
914 case 2: return IT_ROCKETS;
915 case 3: return IT_CELLS;
916 case 4: return IT_FUEL;
921 string GetAmmoPicture(float i)
925 case 0: return "ammo_shells";
926 case 1: return "ammo_bullets";
927 case 2: return "ammo_rockets";
928 case 3: return "ammo_cells";
929 case 4: return "ammo_fuel";
934 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
937 if(autocvar__hud_configure)
939 currently_selected = (itemcode == 2); //rockets always selected
940 a = 31 + mod(itemcode*93, 128);
943 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
952 if(currently_selected)
957 vector picpos, numpos;
958 if(autocvar_hud_panel_ammo_iconalign)
961 picpos = myPos + eX * 2 * mySize_y;
965 numpos = myPos + eX * mySize_y;
969 if (currently_selected)
970 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
972 if(a > 0 && autocvar_hud_panel_ammo_progressbar)
973 HUD_Panel_DrawProgressBar(myPos + eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize_x, mySize - eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize_x, autocvar_hud_panel_ammo_progressbar_name, 0, 0, a/autocvar_hud_panel_ammo_maxammo, color, autocvar_hud_progressbar_alpha * panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
975 if(autocvar_hud_panel_ammo_text)
978 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
979 else // "ghost" ammo count
980 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
983 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
984 else // "ghost" ammo icon
985 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
990 if(!autocvar__hud_configure)
992 if(!autocvar_hud_panel_ammo) return;
993 if(spectatee_status == -1) return;
996 hud_configure_active_panel = HUD_PANEL_AMMO;
998 HUD_Panel_UpdateCvars(ammo);
1001 mySize = panel_size;
1003 HUD_Panel_DrawBg(1);
1004 if(panel_bg_padding)
1006 pos += '1 1 0' * panel_bg_padding;
1007 mySize -= '2 2 0' * panel_bg_padding;
1010 float rows, columns, row, column;
1012 if (autocvar_hud_panel_ammo_onlycurrent)
1016 rows = mySize_y/mySize_x;
1017 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1018 // ^^^ ammo item aspect goes here
1020 columns = ceil(AMMO_COUNT/rows);
1022 ammo_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
1027 if(ammo_size_x/ammo_size_y > 3)
1029 newSize = 3 * ammo_size_y;
1030 offset_x = ammo_size_x - newSize;
1031 pos_x += offset_x/2;
1032 ammo_size_x = newSize;
1036 newSize = 1/3 * ammo_size_x;
1037 offset_y = ammo_size_y - newSize;
1038 pos_y += offset_y/2;
1039 ammo_size_y = newSize;
1042 drawfont = hud_bigfont;
1043 float i, stat_items, currently_selected;
1044 if (autocvar_hud_panel_ammo_onlycurrent)
1046 if(autocvar__hud_configure)
1048 DrawAmmoItem(pos, ammo_size, 2, true); //show rockets
1051 stat_items = getstati(STAT_ITEMS);
1052 for (i = 0; i < AMMO_COUNT; ++i) {
1053 currently_selected = stat_items & GetAmmoItemCode(i);
1054 if (currently_selected)
1056 DrawAmmoItem(pos, ammo_size, i, true);
1060 return; // nothing to display
1063 stat_items = getstati(STAT_ITEMS);
1064 for (i = 0; i < AMMO_COUNT; ++i) {
1065 currently_selected = stat_items & GetAmmoItemCode(i);
1066 DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected);
1071 column = column + 1;
1074 drawfont = hud_font;
1077 void DrawNumIcon(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float alpha)
1079 vector newPos, newSize;
1080 vector picpos, numpos;
1084 if(mySize_y/mySize_x > 2)
1086 newSize_y = 2 * mySize_x;
1087 newSize_x = mySize_x;
1089 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1094 newSize_x = 1/2 * mySize_y;
1095 newSize_y = mySize_y;
1097 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1101 if(icon_right_align)
1104 picpos = newPos + eY * newSize_x;
1109 numpos = newPos + eY * newSize_x;
1113 drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1114 // make number smaller than icon, it looks better
1115 // reduce only y to draw numbers with different number of digits with the same y size
1116 numpos_y += newSize_y * ((1 - 0.7) / 2);
1118 drawstring_aspect(numpos, ftos(x), newSize, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1122 if(mySize_x/mySize_y > 3)
1124 newSize_x = 3 * mySize_y;
1125 newSize_y = mySize_y;
1127 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1132 newSize_y = 1/3 * mySize_x;
1133 newSize_x = mySize_x;
1135 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1139 if(icon_right_align) // right align
1142 picpos = newPos + eX * 2 * newSize_y;
1146 numpos = newPos + eX * newSize_y;
1150 drawstring_aspect(numpos, ftos(x), '2 1 0' * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1151 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1154 void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float fadelerp)
1157 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
1159 DrawNumIcon(myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, vertical, icon_right_align, color, (1 - fadelerp));
1164 void HUD_Powerups(void)
1166 float strength_time, shield_time;
1167 if(!autocvar__hud_configure)
1169 if(!autocvar_hud_panel_powerups) return;
1170 if(spectatee_status == -1) return;
1171 if not(getstati(STAT_ITEMS) & (IT_STRENGTH | IT_INVINCIBLE)) return;
1172 if (getstati(STAT_HEALTH) <= 0) return;
1174 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1175 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1179 hud_configure_active_panel = HUD_PANEL_POWERUPS;
1185 HUD_Panel_UpdateCvars(powerups);
1188 mySize = panel_size;
1190 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
1191 if(panel_bg_padding)
1193 pos += '1 1 0' * panel_bg_padding;
1194 mySize -= '2 2 0' * panel_bg_padding;
1201 string leftname, rightname;
1202 string leftprogressname, rightprogressname;
1203 float leftcnt, rightcnt;
1204 float leftexact, rightexact;
1205 if (autocvar_hud_panel_powerups_flip) {
1206 leftname = "strength";
1207 leftprogressname = autocvar_hud_panel_powerups_progressbar_strength;
1208 leftcnt = ceil(strength_time);
1209 leftexact = strength_time;
1211 rightname = "shield";
1212 rightprogressname = autocvar_hud_panel_powerups_progressbar_shield;
1213 rightcnt = ceil(shield_time);
1214 rightexact = shield_time;
1216 leftname = "shield";
1217 leftprogressname = autocvar_hud_panel_powerups_progressbar_shield;
1218 leftcnt = ceil(shield_time);
1219 leftexact = shield_time;
1221 rightname = "strength";
1222 rightprogressname = autocvar_hud_panel_powerups_progressbar_strength;
1223 rightcnt = ceil(strength_time);
1224 rightexact = strength_time;
1227 drawfont = hud_bigfont;
1228 float baralign = autocvar_hud_panel_powerups_baralign;
1229 float iconalign = autocvar_hud_panel_powerups_iconalign;
1231 float panel_ar = mySize_x/mySize_y;
1232 float is_vertical = (panel_ar < 1);
1233 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1235 barsize = eX * 0.5 * mySize_x + eY * mySize_y;
1238 if(autocvar_hud_panel_powerups_progressbar)
1240 HUD_Panel_GetProgressBarColorForString(leftname);
1241 HUD_Panel_DrawProgressBar(pos, barsize, leftprogressname, leftcnt/30, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
1243 if(autocvar_hud_panel_powerups_text)
1246 DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', 1);
1248 DrawNumIcon_expanding(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
1255 if(autocvar_hud_panel_powerups_progressbar)
1257 HUD_Panel_GetProgressBarColorForString(rightname);
1258 HUD_Panel_DrawProgressBar(pos, barsize, rightprogressname, rightcnt/30, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
1260 if(autocvar_hud_panel_powerups_text)
1263 DrawNumIcon(pos, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', 1);
1265 DrawNumIcon_expanding(pos, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1));
1271 barsize = eX * mySize_x + eY * 0.5 * mySize_y;
1274 if(autocvar_hud_panel_powerups_progressbar)
1276 HUD_Panel_GetProgressBarColorForString(leftname);
1277 HUD_Panel_DrawProgressBar(pos, barsize, leftprogressname, leftcnt/30, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
1279 if(autocvar_hud_panel_powerups_text)
1282 DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', 1);
1284 DrawNumIcon_expanding(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
1291 if(autocvar_hud_panel_powerups_progressbar)
1293 HUD_Panel_GetProgressBarColorForString(rightname);
1294 HUD_Panel_DrawProgressBar(pos, barsize, rightprogressname, rightcnt/30, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
1296 if(autocvar_hud_panel_powerups_text)
1299 DrawNumIcon(pos, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', 1);
1301 DrawNumIcon_expanding(pos, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1));
1305 drawfont = hud_font;
1308 // Health/armor (#3)
1310 void HUD_HealthArmor(void)
1312 float armor, health, fuel;
1313 if(!autocvar__hud_configure)
1315 if(!autocvar_hud_panel_healtharmor) return;
1316 if(spectatee_status == -1) return;
1318 health = getstati(STAT_HEALTH);
1321 armor = getstati(STAT_ARMOR);
1322 fuel = getstati(STAT_FUEL);
1326 hud_configure_active_panel = HUD_PANEL_HEALTHARMOR;
1333 HUD_Panel_UpdateCvars(healtharmor);
1336 mySize = panel_size;
1338 HUD_Panel_DrawBg(1);
1339 if(panel_bg_padding)
1341 pos += '1 1 0' * panel_bg_padding;
1342 mySize -= '2 2 0' * panel_bg_padding;
1346 vector picpos, numpos;
1348 drawfont = hud_bigfont;
1349 float baralign = autocvar_hud_panel_healtharmor_baralign;
1350 float iconalign = autocvar_hud_panel_healtharmor_iconalign;
1352 float maxhealth = autocvar_hud_panel_healtharmor_maxhealth;
1353 float maxarmor = autocvar_hud_panel_healtharmor_maxarmor;
1354 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
1357 v = healtharmor_maxdamage(health, armor, armorblockpercent);
1362 float maxtotal = maxhealth + maxarmor;
1364 if(v_z) // NOT fully armored
1366 biggercount = "health";
1367 if(autocvar_hud_panel_healtharmor_progressbar)
1369 HUD_Panel_GetProgressBarColor(health);
1370 HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_health, x/maxtotal, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1373 if(autocvar_hud_panel_healtharmor_text)
1374 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);
1378 biggercount = "armor";
1379 if(autocvar_hud_panel_healtharmor_progressbar)
1381 HUD_Panel_GetProgressBarColor(armor);
1382 HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, x/maxtotal, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1385 if(autocvar_hud_panel_healtharmor_text)
1386 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);
1388 if(autocvar_hud_panel_healtharmor_text)
1389 DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, maxtotal), 1);
1393 HUD_Panel_GetProgressBarColor(fuel);
1394 HUD_Panel_DrawProgressBar(pos, eX * mySize_x + eY * 0.2 * mySize_y, "progressbar", fuel/100, 0, (baralign == 1 || baralign == 3), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
1399 string leftname, rightname;
1400 string leftprogressname, rightprogressname;
1401 float leftcnt, rightcnt;
1402 float leftmax, rightmax;
1403 float leftactive, rightactive;
1404 float leftalpha, rightalpha;
1405 if (autocvar_hud_panel_healtharmor_flip) { // old style layout with armor left/top of health
1407 leftprogressname = autocvar_hud_panel_healtharmor_progressbar_armor;
1411 leftalpha = min((armor+10)/55, 1);
1414 rightname = "health";
1415 rightprogressname = autocvar_hud_panel_healtharmor_progressbar_health;
1419 rightmax = maxhealth;
1421 leftname = "health";
1422 leftprogressname = autocvar_hud_panel_healtharmor_progressbar_health;
1426 leftmax = maxhealth;
1428 rightname = "armor";
1429 rightprogressname = autocvar_hud_panel_healtharmor_progressbar_armor;
1433 rightalpha = min((armor+10)/55, 1);
1434 rightmax = maxarmor;
1437 float panel_ar = mySize_x/mySize_y;
1438 float is_vertical = (panel_ar < 1);
1439 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1441 barsize = eX * 0.5 * mySize_x + eY * mySize_y;
1444 if(autocvar_hud_panel_healtharmor_progressbar)
1446 HUD_Panel_GetProgressBarColorForString(leftname);
1447 HUD_Panel_DrawProgressBar(pos, barsize, leftprogressname, leftcnt/leftmax, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1449 if(autocvar_hud_panel_healtharmor_text)
1450 DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), HUD_Get_Num_Color(leftcnt, leftmax), 1);
1455 if(autocvar_hud_panel_healtharmor_progressbar)
1457 HUD_Panel_GetProgressBarColorForString(rightname);
1458 HUD_Panel_DrawProgressBar(pos + eX * 0.5 * mySize_x, barsize, rightprogressname, rightcnt/rightmax, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1460 if(autocvar_hud_panel_healtharmor_text)
1461 DrawNumIcon(pos + eX * 0.5 * mySize_x, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), HUD_Get_Num_Color(rightcnt, rightmax), 1);
1466 HUD_Panel_GetProgressBarColor(fuel);
1467 if (is_vertical) //if vertical always halve x to not cover too much numbers with 3 digits
1468 mySize_x *= 0.2 * 0.5 / 2;
1471 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
1476 barsize = eX * mySize_x + eY * 0.5 * mySize_y;
1479 if(autocvar_hud_panel_healtharmor_progressbar)
1481 HUD_Panel_GetProgressBarColorForString(leftname);
1482 HUD_Panel_DrawProgressBar(pos, barsize, leftprogressname, leftcnt/leftmax, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1484 if(autocvar_hud_panel_healtharmor_text)
1485 DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), HUD_Get_Num_Color(leftcnt, leftmax), 1);
1490 if(autocvar_hud_panel_healtharmor_progressbar)
1492 HUD_Panel_GetProgressBarColorForString(rightname);
1493 HUD_Panel_DrawProgressBar(pos + eY * 0.5 * mySize_y, barsize, rightprogressname, rightcnt/rightmax, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1495 if(autocvar_hud_panel_healtharmor_text)
1496 DrawNumIcon(pos + eY * 0.5 * mySize_y, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), HUD_Get_Num_Color(rightcnt, rightmax), 1);
1501 HUD_Panel_GetProgressBarColor(fuel);
1502 if (is_vertical) //if vertical always halve x to not cover numbers with 3 digits
1503 mySize_x *= 0.2 / 2;
1505 mySize_y *= 0.2 * 0.5;
1506 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
1510 drawfont = hud_font;
1513 // Notification area (#4)
1516 string Weapon_SuicideMessage(float deathtype)
1518 w_deathtype = deathtype;
1519 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
1520 return w_deathtypestring;
1523 string Weapon_KillMessage(float deathtype)
1525 w_deathtype = deathtype;
1526 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
1527 return w_deathtypestring;
1530 #define KN_MAX_ENTRIES 10
1532 float killnotify_times[KN_MAX_ENTRIES];
1533 float killnotify_deathtype[KN_MAX_ENTRIES];
1534 float killnotify_actiontype[KN_MAX_ENTRIES]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
1535 string killnotify_attackers[KN_MAX_ENTRIES];
1536 string killnotify_victims[KN_MAX_ENTRIES];
1537 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
1541 kn_index = KN_MAX_ENTRIES-1;
1542 killnotify_times[kn_index] = time;
1543 killnotify_deathtype[kn_index] = wpn;
1544 killnotify_actiontype[kn_index] = actiontype;
1545 if(killnotify_attackers[kn_index])
1546 strunzone(killnotify_attackers[kn_index]);
1547 killnotify_attackers[kn_index] = strzone(attacker);
1548 if(killnotify_victims[kn_index])
1549 strunzone(killnotify_victims[kn_index]);
1550 killnotify_victims[kn_index] = strzone(victim);
1553 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
1556 float alsoprint, gentle;
1557 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
1558 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
1560 if ((msg == MSG_SUICIDE || msg == MSG_KILL || msg == MSG_KILL_ACTION) && gametype == GAME_CTS) // selfkill isn't interesting in CTS and only spams up the notify panel
1563 if(msg == MSG_SUICIDE) {
1564 w = DEATH_WEAPONOF(type);
1566 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1568 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
1569 } else if (type == DEATH_KILL) {
1570 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
1572 print ("^1",s1, "^1 couldn't take it anymore\n");
1573 } else if (type == DEATH_ROT) {
1574 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1576 print ("^1",s1, "^1 died\n");
1577 } else if (type == DEATH_NOAMMO) {
1578 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
1580 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
1581 } else if (type == DEATH_CAMP) {
1582 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
1584 print ("^1",s1, "^1 thought they found a nice camping ground\n");
1585 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
1586 HUD_KillNotify_Push(s1, "", 0, type);
1588 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
1589 } else if (type == DEATH_CHEAT) {
1590 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1592 print ("^1",s1, "^1 unfairly eliminated themself\n");
1593 } else if (type == DEATH_FIRE) {
1594 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1596 print ("^1",s1, "^1 burned to death\n");
1597 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
1598 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1600 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
1603 if (stof(s2) > 2) // killcount > 2
1604 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
1605 } else if(msg == MSG_KILL) {
1606 w = DEATH_WEAPONOF(type);
1608 if((w == WEP_CAMPINGRIFLE || w == WEP_MINSTANEX) && type & HITTYPE_HEADSHOT) // all headshot weapons go here
1609 HUD_KillNotify_Push(s1, s2, 1, DEATH_HEADSHOT);
1611 HUD_KillNotify_Push(s1, s2, 1, type);
1614 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
1616 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
1617 HUD_KillNotify_Push(s1, s2, 1, type);
1621 print ("^1", s1, "^1 took action against a team mate\n");
1623 print ("^1", s1, "^1 mows down a team mate\n");
1626 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
1628 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
1630 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
1632 else if (stof(s2) > 2) {
1634 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
1636 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
1639 else if(type == KILL_FIRST_BLOOD)
1640 print("^1",s1, "^1 drew first blood", "\n");
1641 else if (type == DEATH_TELEFRAG) {
1642 HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
1644 print ("^1",s2, "^1 tried to occupy ", s1, "^1's teleport destination space\n");
1646 print ("^1",s2, "^1 was telefragged by ", s1, "\n");
1648 else if (type == DEATH_DROWN) {
1649 HUD_KillNotify_Push(s1, s2, 1, DEATH_DROWN);
1651 print ("^1",s2, "^1 was drowned by ", s1, "\n");
1653 else if (type == DEATH_SLIME) {
1654 HUD_KillNotify_Push(s1, s2, 1, DEATH_SLIME);
1656 print ("^1",s2, "^1 was slimed by ", s1, "\n");
1658 else if (type == DEATH_LAVA) {
1659 HUD_KillNotify_Push(s1, s2, 1, DEATH_LAVA);
1661 print ("^1",s2, "^1 was cooked by ", s1, "\n");
1663 else if (type == DEATH_FALL) {
1664 HUD_KillNotify_Push(s1, s2, 1, DEATH_FALL);
1666 print ("^1",s2, "^1 was grounded by ", s1, "\n");
1668 else if (type == DEATH_SHOOTING_STAR) {
1669 HUD_KillNotify_Push(s1, s2, 1, DEATH_SHOOTING_STAR);
1671 print ("^1",s2, "^1 was shot into space by ", s1, "\n");
1673 else if (type == DEATH_SWAMP) {
1674 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1676 print ("^1",s2, "^1 was conserved by ", s1, "\n");
1678 else if (type == DEATH_HURTTRIGGER)
1680 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1682 print("^1",s2, "^1 was thrown into a world of hurt by ", s1, "\n");
1683 } else if(type == DEATH_SBCRUSH) {
1684 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1686 print ("^1",s2, "^1 was crushed by ^1", s1, "\n");
1687 } else if(type == DEATH_SBMINIGUN) {
1688 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1690 print ("^1",s2, "^1 got shredded by ^1", s1, "\n");
1691 } else if(type == DEATH_SBROCKET) {
1692 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1694 print ("^1",s2, "^1 was blased to bits by ^1", s1, "\n");
1695 } else if(type == DEATH_SBBLOWUP) {
1696 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1698 print ("^1",s2, "^1 got caught in the destruction of ^1", s1, "'s vehicle\n");
1699 } else if(type == DEATH_WAKIGUN) {
1700 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1702 print ("^1",s2, "^1 was bolted down by ^1", s1, "\n");
1703 } else if(type == DEATH_WAKIROCKET) {
1704 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1706 print ("^1",s2, "^1 could find no shelter from ^1", s1, "'s rockets\n");
1707 } else if(type == DEATH_WAKIBLOWUP) {
1708 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1710 print ("^1",s2, "^1 dies when ^1", s1, "'s wakizashi dies.\n");
1711 } else if(type == DEATH_TURRET) {
1712 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1714 print ("^1",s2, "^1 was pushed into the line of fire by ^1", s1, "\n");
1715 } else if(type == DEATH_TOUCHEXPLODE) {
1716 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1718 print ("^1",s2, "^1 was pushed into an accident by ^1", s1, "\n");
1719 } else if(type == DEATH_CHEAT) {
1720 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1722 print ("^1",s2, "^1 was unfairly eliminated by ^1", s1, "\n");
1723 } else if (type == DEATH_FIRE) {
1724 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1726 print ("^1",s2, "^1 was burnt to death by ^1", s1, "\n");
1727 } else if (type == DEATH_CUSTOM) {
1728 HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM);
1730 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1731 } else if (type == DEATH_HURTTRIGGER) {
1732 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1734 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1736 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1738 print ("^1",s2, "^1 was fragged by ", s1, "\n");
1740 } else if(msg == MSG_SPREE) {
1741 if(type == KILL_END_SPREE) {
1743 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
1745 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
1746 } else if(type == KILL_SPREE) {
1748 print ("^1",s1,"^1 made ",s2," scores in a row\n");
1750 print ("^1",s1,"^1 has ",s2," frags in a row\n");
1751 } else if(type == KILL_SPREE_3) {
1753 print (s1,"^7 made a ^1TRIPLE SCORE\n");
1755 print (s1,"^7 made a ^1TRIPLE FRAG\n");
1756 } else if(type == KILL_SPREE_5) {
1758 print (s1,"^7 unleashes ^1SCORING RAGE\n");
1760 print (s1,"^7 unleashes ^1RAGE\n");
1761 } else if(type == KILL_SPREE_10) {
1763 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
1765 print (s1,"^7 starts the ^1MASSACRE!\n");
1766 } else if(type == KILL_SPREE_15) {
1768 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
1770 print (s1,"^7 executes ^1MAYHEM!\n");
1771 } else if(type == KILL_SPREE_20) {
1773 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
1775 print (s1,"^7 is a ^1BERSERKER!\n");
1776 } else if(type == KILL_SPREE_25) {
1778 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
1780 print (s1,"^7 inflicts ^1CARNAGE!\n");
1781 } else if(type == KILL_SPREE_30) {
1783 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
1785 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
1787 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
1788 if (type == DEATH_DROWN) {
1789 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
1793 print ("^1",s1, "^1 was in the water for too long\n");
1795 print ("^1",s1, "^1 drowned\n");
1797 } else if (type == DEATH_SLIME) {
1798 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
1800 print ("^1",s1, "^1 was slimed\n");
1801 } else if (type == DEATH_LAVA) {
1802 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
1806 print ("^1",s1, "^1 found a hot place\n");
1808 print ("^1",s1, "^1 turned into hot slag\n");
1810 } else if (type == DEATH_FALL) {
1811 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1815 print ("^1",s1, "^1 tested gravity (and it worked)\n");
1817 print ("^1",s1, "^1 hit the ground with a crunch\n");
1819 } else if (type == DEATH_SHOOTING_STAR) {
1820 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
1822 print ("^1",s1, "^1 became a shooting star\n");
1823 } else if (type == DEATH_SWAMP) {
1824 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1828 print ("^1",s1, "^1 discovered a swamp\n");
1830 print ("^1",s1, "^1 is now conserved for centuries to come\n");
1832 } else if(type == DEATH_TURRET) {
1833 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1835 print ("^1",s1, "^1 was mowed down by a turret \n");
1836 } else if (type == DEATH_CUSTOM) {
1837 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
1839 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1840 } else if (type == DEATH_HURTTRIGGER) {
1841 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
1843 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1844 } else if(type == DEATH_TOUCHEXPLODE) {
1845 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1847 print ("^1",s1, "^1 died in an accident\n");
1848 } else if(type == DEATH_CHEAT) {
1849 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1851 print ("^1",s1, "^1 was unfairly eliminated\n");
1852 } else if(type == DEATH_FIRE) {
1853 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1857 print ("^1",s1, "^1 felt a little hot\n");
1859 print ("^1",s1, "^1 burnt to death\n");
1862 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1866 print ("^1",s1, "^1 needs a restart\n");
1868 print ("^1",s1, "^1 died\n");
1871 } else if(msg == MSG_KILL_ACTION_SPREE) {
1873 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
1875 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
1876 } else if(msg == MSG_INFO) {
1877 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
1878 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
1879 print(s1, "^7 got the ", s2, "\n");
1880 } else if(type == INFO_LOSTFLAG) {
1881 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
1882 print(s1, "^7 lost the ", s2, "\n");
1883 } else if(type == INFO_PICKUPFLAG) {
1884 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
1885 print(s1, "^7 picked up the ", s2, "\n");
1886 } else if(type == INFO_RETURNFLAG) {
1887 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
1888 print(s1, "^7 returned the ", s2, "\n");
1889 } else if(type == INFO_CAPTUREFLAG) {
1890 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
1891 print(s1, "^7 captured the ", s2, s3, "\n");
1893 } else if(msg == MSG_RACE) {
1894 if(type == RACE_SERVER_RECORD) {
1895 HUD_KillNotify_Push(s1, s2, 1, RACE_SERVER_RECORD);
1897 else if(type == RACE_NEW_RANK) {
1898 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_RANK);
1900 else if(type == RACE_NEW_TIME) {
1901 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_TIME);
1903 else if(type == RACE_FAIL) {
1904 HUD_KillNotify_Push(s1, s2, 1, RACE_FAIL);
1906 } else if(msg == MSG_KA) {
1907 if(type == KA_PICKUPBALL) {
1908 HUD_KillNotify_Push(s1, s2, 0, KA_PICKUPBALL);
1910 print (s1, "^7 has picked up the ball!\n");
1912 else if(type == KA_DROPBALL) {
1913 HUD_KillNotify_Push(s1, s2, 0, KA_DROPBALL);
1915 print(s1, "^7 has dropped the ball!\n");
1920 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
1922 void HUD_Centerprint(string s1, string s2, float type, float msg)
1925 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
1926 if(msg == MSG_SUICIDE) {
1927 if (type == DEATH_TEAMCHANGE) {
1928 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
1929 } else if (type == DEATH_AUTOTEAMCHANGE) {
1930 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
1931 } else if (type == DEATH_CAMP) {
1933 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
1935 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
1936 } else if (type == DEATH_NOAMMO) {
1938 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
1940 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
1941 } else if (type == DEATH_ROT) {
1943 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
1945 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
1946 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
1948 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
1950 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
1951 } else if (type == DEATH_QUIET) {
1953 } else { // generic message
1955 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
1957 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
1959 } else if(msg == MSG_KILL) {
1960 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
1962 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
1964 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
1966 } else if (type == KILL_FIRST_BLOOD) {
1968 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
1970 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
1972 } else if (type == KILL_FIRST_VICTIM) {
1974 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
1976 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
1978 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
1980 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
1982 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
1984 } else if (type == KILL_TYPEFRAGGED) {
1986 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
1988 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
1990 } else if (type == KILL_FRAG) {
1992 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
1994 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
1996 } else { // generic message
1998 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2000 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2003 } else if(msg == MSG_KILL_ACTION) {
2004 // TODO: invent more centerprints here?
2005 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2009 void HUD_Notify (void)
2011 if(!autocvar__hud_configure)
2013 if(!autocvar_hud_panel_notify) return;
2016 hud_configure_active_panel = HUD_PANEL_NOTIFY;
2018 HUD_Panel_UpdateCvars(notify);
2021 mySize = panel_size;
2023 HUD_Panel_DrawBg(1);
2024 if(panel_bg_padding)
2026 pos += '1 1 0' * panel_bg_padding;
2027 mySize -= '2 2 0' * panel_bg_padding;
2030 float entries, height;
2031 entries = bound(1, floor(KN_MAX_ENTRIES * mySize_y/mySize_x), KN_MAX_ENTRIES);
2032 height = mySize_y/entries;
2035 fontsize = '0.5 0.5 0' * height;
2039 when = autocvar_hud_panel_notify_time;
2041 fadetime = autocvar_hud_panel_notify_fadetime;
2045 vector pos_attacker, pos_victim;
2047 float width_attacker;
2048 string attacker, victim;
2050 float i, j, w, step, limit;
2051 if(autocvar_hud_panel_notify_flip) //order items from the top down
2057 else //order items from the bottom up
2064 for(j = kn_index; i != limit; i += step, ++j)
2066 if(autocvar__hud_configure)
2070 else // inverse order
2071 a = entries - 1 - i;
2072 attacker = textShortenToWidth(strcat("Player", ftos(a+1)), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2073 victim = textShortenToWidth(strcat("Player", ftos(a+2)), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2074 s = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname);
2075 a = bound(0, (when - a) / 4, 1);
2076 goto hud_config_notifyprint;
2079 if (j == KN_MAX_ENTRIES)
2082 if(killnotify_times[j] + when > time)
2086 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2100 w = DEATH_WEAPONOF(killnotify_deathtype[j]);
2102 // TODO: maybe print in team colors?
2105 if(killnotify_actiontype[j] == 0)
2107 if(killnotify_deathtype[j] == DEATH_GENERIC)
2111 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2113 s = "notify_outofammo";
2115 else if(killnotify_deathtype[j] == DEATH_KILL)
2117 s = "notify_selfkill";
2119 else if(killnotify_deathtype[j] == DEATH_CAMP)
2121 s = "notify_camping";
2123 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2125 s = "notify_teamkill_red";
2127 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2129 s = "notify_teamkill_blue";
2131 else if(killnotify_deathtype[j] == DEATH_DROWN)
2135 else if(killnotify_deathtype[j] == DEATH_SLIME)
2139 else if(killnotify_deathtype[j] == DEATH_LAVA)
2143 else if(killnotify_deathtype[j] == DEATH_FALL)
2147 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2149 s = "notify_shootingstar";
2151 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2155 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2157 if(killnotify_victims[j] == "^1RED^7 flag")
2159 s = "notify_red_taken";
2163 s = "notify_blue_taken";
2166 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2168 if(killnotify_victims[j] == "^1RED^7 flag")
2170 s = "notify_red_returned";
2174 s = "notify_blue_returned";
2177 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2179 if(killnotify_victims[j] == "^1RED^7 flag")
2181 s = "notify_red_lost";
2185 s = "notify_blue_lost";
2188 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
2190 if(killnotify_victims[j] == "^1RED^7 flag")
2192 s = "notify_red_captured";
2196 s = "notify_blue_captured";
2199 else if(killnotify_deathtype[j] == KA_DROPBALL)
2201 s = "notify_balldropped";
2203 else if(killnotify_deathtype[j] == KA_PICKUPBALL)
2205 s = "notify_ballpickedup";
2208 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2209 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
2210 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2214 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2215 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2218 // X [did action to] Y
2221 if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
2223 s = "notify_melee_laser";
2225 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_SHOTGUN)
2227 s = "notify_melee_shotgun";
2229 else if(WEP_VALID(w))
2231 self = get_weaponinfo(w);
2232 s = strcat("weapon", self.netname);
2234 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2236 s = "notify_teamkill_red";
2238 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2240 s = "notify_teamkill_red";
2242 else if(killnotify_deathtype[j] == DEATH_TELEFRAG)
2244 s = "notify_telefrag";
2246 else if(killnotify_deathtype[j] == DEATH_DROWN)
2250 else if(killnotify_deathtype[j] == DEATH_SLIME)
2254 else if(killnotify_deathtype[j] == DEATH_LAVA)
2258 else if(killnotify_deathtype[j] == DEATH_FALL)
2262 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2264 s = "notify_shootingstar";
2266 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2270 else if(killnotify_deathtype[j] == DEATH_HEADSHOT)
2272 s = "notify_headshot";
2274 else if(killnotify_deathtype[j] == RACE_SERVER_RECORD)
2276 s = "race_newrecordserver";
2278 else if(killnotify_deathtype[j] == RACE_NEW_RANK)
2280 s = "race_newrankyellow";
2282 else if(killnotify_deathtype[j] == RACE_NEW_TIME)
2286 else if(killnotify_deathtype[j] == RACE_FAIL)
2291 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2292 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2293 :hud_config_notifyprint
2294 width_attacker = stringwidth(attacker, TRUE, fontsize);
2295 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
2296 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
2297 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2301 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2302 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2303 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2312 string seconds_tostring(float sec)
2315 minutes = floor(sec / 60);
2317 sec -= minutes * 60;
2320 s = ftos(100 + sec);
2322 return strcat(ftos(minutes), ":", substring(s, 1, 3));
2325 void HUD_Timer(void)
2327 if(!autocvar__hud_configure)
2329 if(!autocvar_hud_panel_timer) return;
2332 hud_configure_active_panel = HUD_PANEL_TIMER;
2334 HUD_Panel_UpdateCvars(timer);
2337 mySize = panel_size;
2339 HUD_Panel_DrawBg(1);
2340 if(panel_bg_padding)
2342 pos += '1 1 0' * panel_bg_padding;
2343 mySize -= '2 2 0' * panel_bg_padding;
2347 float timelimit, elapsedTime, timeleft, minutesLeft;
2349 timelimit = getstatf(STAT_TIMELIMIT);
2351 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
2352 timeleft = ceil(timeleft);
2354 minutesLeft = floor(timeleft / 60);
2357 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
2358 timer_color = '1 1 1'; //white
2359 else if(minutesLeft >= 1)
2360 timer_color = '1 1 0'; //yellow
2362 timer_color = '1 0 0'; //red
2364 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
2365 if (time < getstatf(STAT_GAMESTARTTIME)) {
2366 //while restart is still active, show 00:00
2367 timer = seconds_tostring(0);
2369 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
2370 timer = seconds_tostring(elapsedTime);
2373 timer = seconds_tostring(timeleft);
2376 drawfont = hud_bigfont;
2377 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2378 drawfont = hud_font;
2383 void HUD_Radar(void)
2385 if (!autocvar__hud_configure)
2387 if (autocvar_hud_panel_radar == 0) return;
2388 if (autocvar_hud_panel_radar != 2 && !teamplay) return;
2391 hud_configure_active_panel = HUD_PANEL_RADAR;
2393 HUD_Panel_UpdateCvars(radar);
2396 mySize = panel_size;
2398 HUD_Panel_DrawBg(1);
2399 if(panel_bg_padding)
2401 pos += '1 1 0' * panel_bg_padding;
2402 mySize -= '2 2 0' * panel_bg_padding;
2407 float scale2d, normalsize, bigsize;
2410 teamradar_origin2d = pos + 0.5 * mySize;
2411 teamradar_size2d = mySize;
2413 if(minimapname == "")
2416 teamradar_loadcvars();
2418 switch(hud_panel_radar_zoommode)
2422 f = current_zoomfraction;
2425 f = 1 - current_zoomfraction;
2435 switch(hud_panel_radar_rotation)
2438 teamradar_angle = view_angles_y - 90;
2441 teamradar_angle = 90 * hud_panel_radar_rotation;
2445 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
2446 teamradar_size2d = mySize;
2448 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
2450 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
2451 if(hud_panel_radar_rotation == 0)
2453 // max-min distance must fit the radar in any rotation
2454 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_scale));
2458 vector c0, c1, c2, c3, span;
2459 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
2460 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
2461 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
2462 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
2464 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
2465 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
2467 // max-min distance must fit the radar in x=x, y=y
2469 teamradar_size2d_x * scale2d / (1.05 * span_x),
2470 teamradar_size2d_y * scale2d / (1.05 * span_y)
2474 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
2475 if(bigsize > normalsize)
2476 normalsize = bigsize;
2480 + (1 - f) * normalsize;
2481 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
2483 + (1 - f) * view_origin);
2492 draw_teamradar_background(hud_panel_radar_foreground_alpha);
2494 for(tm = world; (tm = find(tm, classname, "radarlink")); )
2495 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
2496 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
2497 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
2498 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
2500 color2 = GetPlayerColor(tm.sv_entnum);
2501 //if(color == COLOR_SPECTATOR || color == color2)
2502 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
2504 draw_teamradar_player(view_origin, view_angles, '1 1 1');
2506 drawresetcliparea();
2511 void HUD_UpdatePlayerTeams();
2512 void HUD_Score(void)
2514 if(!autocvar__hud_configure)
2516 if(!autocvar_hud_panel_score) return;
2517 if(spectatee_status == -1 && (gametype == GAME_RACE || gametype == GAME_CTS)) return;
2520 hud_configure_active_panel = HUD_PANEL_SCORE;
2522 HUD_Panel_UpdateCvars(score);
2525 mySize = panel_size;
2527 HUD_Panel_DrawBg(1);
2528 if(panel_bg_padding)
2530 pos += '1 1 0' * panel_bg_padding;
2531 mySize -= '2 2 0' * panel_bg_padding;
2534 float score, distribution;
2536 vector distribution_color;
2538 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
2540 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
2541 string timer, distrtimer;
2543 pl = players.sort_next;
2546 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
2547 if(pl.scores[ps_primary] == 0)
2550 score = me.(scores[ps_primary]);
2551 timer = TIME_ENCODED_TOSTRING(score);
2553 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
2554 // distribution display
2555 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2557 distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS);
2559 if (distribution <= 0) {
2560 distribution_color = '0 1 0';
2564 distribution_color = '1 0 0';
2567 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);
2569 // race record display
2570 if (distribution <= 0)
2571 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2572 drawfont = hud_bigfont;
2573 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2574 drawfont = hud_font;
2575 } else if (!teamplay) { // non-teamgames
2576 if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings)
2578 #define SCOREPANEL_MAX_ENTRIES 6
2579 #define SCOREPANEL_ASPECTRATIO 2
2580 const float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
2581 const float height = mySize_y/entries;
2582 const vector fontsize = '0.9 0.9 0' * height;
2583 pos_y += height * (1 - 0.9) / 2;
2588 const float name_size = mySize_x*0.75;
2589 const float highlight_alpha = 0.2;
2590 float i, me_printed;
2592 if (autocvar__hud_configure)
2594 score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
2595 for (i=0; i<entries; ++i)
2597 //simulate my score is lower than all displayed players,
2598 //so that I don't appear at all showing pure rankings.
2599 //This is to better show the difference between the 2 ranking views
2600 if (i == entries-1 && autocvar_hud_panel_score_rankings == 1)
2603 drawfill(pos - eY * (height * (1 - 0.9) / 2), eX * mySize_x + eY * height, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2604 s = GetPlayerName(pl.sv_entnum);
2609 s = strcat("Player", ftos(i+1));
2613 s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
2614 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2615 drawstring(pos + eX * mySize_x*0.79, ftos(score), fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2621 if (!scoreboard_fade_alpha) // the scoreboard too calls HUD_UpdatePlayerTeams
2622 HUD_UpdatePlayerTeams();
2624 for (pl = players.sort_next, i=0; pl && i<entries; pl = pl.sort_next, ++i)
2626 if (pl.team == COLOR_SPECTATOR)
2629 if (i == entries-1 && !me_printed && pl != me)
2630 if (autocvar_hud_panel_score_rankings == 1 && spectatee_status != -1)
2632 for (pl = me.sort_next; pl; pl = pl.sort_next)
2633 if (pl.team != COLOR_SPECTATOR)
2637 rgb = '1 1 0'; //not last but not among the leading players: yellow
2639 rgb = '1 0 0'; //last: red
2646 rgb = '0 1 0'; //first: green
2648 drawfill(pos - eY * (height * (1 - 0.9) / 2), eX * mySize_x + eY * height, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2650 s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
2651 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2652 drawstring(pos + eX * mySize_x*0.79, ftos(pl.(scores[ps_primary])), fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2657 // me vector := [team/connected frags id]
2658 pl = players.sort_next;
2662 if(autocvar__hud_configure)
2665 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2669 score = me.(scores[ps_primary]);
2670 if(autocvar__hud_configure)
2673 if(distribution >= 5)
2674 distribution_color = eY;
2675 else if(distribution >= 0)
2676 distribution_color = '1 1 1';
2677 else if(distribution >= -5)
2678 distribution_color = '1 1 0';
2680 distribution_color = eX;
2682 string distribution_str;
2683 distribution_str = ftos(distribution);
2684 if (distribution >= 0)
2686 if (distribution > 0)
2687 distribution_str = strcat("+", distribution_str);
2688 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2690 drawfont = hud_bigfont;
2691 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2692 drawfont = hud_font;
2693 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);
2694 } else { // teamgames
2695 float max_fragcount;
2696 max_fragcount = -99;
2698 float scores_count, row, column, rows, columns;
2700 vector score_pos, score_size; //for scores other than myteam
2701 if (spectatee_status == -1)
2703 if (autocvar__hud_configure)
2705 else for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2706 if(tm.team == COLOR_SPECTATOR)
2710 rows = mySize_y/mySize_x;
2711 rows = bound(1, floor((sqrt(4 * (3/1) * rows * scores_count + rows * rows) + rows + 0.5) / 2), scores_count);
2712 // ^^^ ammo item aspect goes here
2714 columns = ceil(scores_count/rows);
2716 score_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
2719 if(score_size_x/score_size_y > 3)
2721 newSize = 3 * score_size_y;
2722 offset_x = score_size_x - newSize;
2723 pos_x += offset_x/2;
2724 score_size_x = newSize;
2728 newSize = 1/3 * score_size_x;
2729 offset_y = score_size_y - newSize;
2730 pos_y += offset_y/2;
2731 score_size_y = newSize;
2735 score_size = eX * mySize_x*(1/4) + eY * mySize_y*(1/3);
2736 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2737 if(tm.team == COLOR_SPECTATOR)
2739 score = tm.(teamscores[ts_primary]);
2740 if(autocvar__hud_configure)
2743 if (score > max_fragcount)
2744 max_fragcount = score;
2746 if (spectatee_status == -1)
2748 score_pos = pos + eX * column * (score_size_x + offset_x) + eY * row * (score_size_y + offset_y);
2749 if (max_fragcount == score)
2750 HUD_Panel_DrawHighlight(score_pos, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2751 drawfont = hud_bigfont;
2752 drawstring_aspect(score_pos, ftos(score), score_size, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2753 drawfont = hud_font;
2761 else if(tm.team == myteam) {
2762 if (max_fragcount == score)
2763 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2764 drawfont = hud_bigfont;
2765 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2766 drawfont = hud_font;
2768 if (max_fragcount == score)
2769 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);
2770 drawstring_aspect(pos + eX * 0.75 * mySize_x + eY * (1/3) * rows * mySize_y, ftos(score), score_size, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2779 void HUD_RaceTimer (void)
2781 if(!autocvar__hud_configure)
2783 if(!autocvar_hud_panel_racetimer) return;
2784 if(!(gametype == GAME_RACE || gametype == GAME_CTS)) return;
2785 if(spectatee_status == -1) return;
2788 hud_configure_active_panel = HUD_PANEL_RACETIMER;
2790 HUD_Panel_UpdateCvars(racetimer);
2793 mySize = panel_size;
2795 HUD_Panel_DrawBg(1);
2796 if(panel_bg_padding)
2798 pos += '1 1 0' * panel_bg_padding;
2799 mySize -= '2 2 0' * panel_bg_padding;
2802 // always force 4:1 aspect
2804 if(mySize_x/mySize_y > 4)
2806 newSize_x = 4 * mySize_y;
2807 newSize_y = mySize_y;
2809 pos_x = pos_x + (mySize_x - newSize_x) / 2;
2813 newSize_y = 1/4 * mySize_x;
2814 newSize_x = mySize_x;
2816 pos_y = pos_y + (mySize_y - newSize_y) / 2;
2820 drawfont = hud_bigfont;
2822 string s, forcetime;
2824 if(autocvar__hud_configure)
2827 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);
2828 s = "^1Intermediate 1 (+15.42)";
2829 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);
2830 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
2831 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);
2833 else if(race_checkpointtime)
2835 a = bound(0, 2 - (time - race_checkpointtime), 1);
2838 if(a > 0) // just hit a checkpoint?
2840 if(race_checkpoint != 254)
2842 if(race_time && race_previousbesttime)
2843 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
2845 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
2847 forcetime = TIME_ENCODED_TOSTRING(race_time);
2852 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
2854 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
2855 if(a > 0) // next one?
2857 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
2862 if(s != "" && a > 0)
2864 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);
2867 if(race_penaltytime)
2869 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
2872 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
2873 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);
2879 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
2880 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);
2885 if(race_laptime && race_checkpoint != 255)
2887 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
2888 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);
2893 if(race_mycheckpointtime)
2895 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
2896 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
2897 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2899 if(race_othercheckpointtime && race_othercheckpointenemy != "")
2901 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
2902 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
2903 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);
2906 if(race_penaltytime && !race_penaltyaccumulator)
2908 t = race_penaltytime * 0.1 + race_penaltyeventtime;
2909 a = bound(0, (1 + t - time), 1);
2913 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
2915 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
2916 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);
2921 drawfont = hud_font;
2926 float vote_yescount;
2929 float vote_highlighted; // currently selected vote
2931 float vote_active; // is there an active vote?
2932 float vote_prev; // previous state of vote_active to check for a change
2934 float vote_change; // "time" when vote_active changed
2936 void HUD_VoteWindow(void)
2938 if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
2941 if (autocvar__hud_configure)
2945 print("^1You have to answer before entering hud configure mode\n");
2946 cvar_set("_hud_configure", "0");
2948 vote_called_vote = strzone("^2Name ^7instead of \"^1Unregistered player^7\" in stats");
2949 uid2name_dialog = 1;
2952 if(!autocvar__hud_configure)
2954 if(!autocvar_hud_panel_vote) return;
2956 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
2957 panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha;
2959 if(panel_bg_alpha_str == "") {
2960 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
2962 panel_bg_alpha = stof(panel_bg_alpha_str);
2966 hud_configure_active_panel = HUD_PANEL_VOTE;
2975 if(vote_active != vote_prev) {
2977 vote_prev = vote_active;
2980 if(vote_active || autocvar__hud_configure)
2981 vote_alpha = bound(0, (time - vote_change) * 2, 1);
2983 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
2988 HUD_Panel_UpdateCvars(vote);
2992 panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight;
2993 panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight;
2996 // these must be below above block
2999 mySize = panel_size;
3001 a = vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3002 HUD_Panel_DrawBg(a);
3003 a = panel_fg_alpha * a;
3005 if(panel_bg_padding)
3007 pos += '1 1 0' * panel_bg_padding;
3008 mySize -= '2 2 0' * panel_bg_padding;
3011 // always force 3:1 aspect
3013 if(mySize_x/mySize_y > 3)
3015 newSize_x = 3 * mySize_y;
3016 newSize_y = mySize_y;
3018 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3022 newSize_y = 1/3 * mySize_x;
3023 newSize_x = mySize_x;
3025 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3029 s = "A vote has been called for:";
3031 s = "Allow servers to store and display your name?";
3032 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3033 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1/8), stringwidth_colors);
3034 if(autocvar__hud_configure)
3035 s = "^1Configure the HUD";
3036 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
3038 // print the yes/no counts
3039 s = strcat("Yes (", getcommandkey("vyes", "vyes"), "): ", ftos(vote_yescount));
3040 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);
3041 s = strcat("No (", getcommandkey("vno", "vno"), "): ", ftos(vote_nocount));
3042 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);
3044 // draw the progress bar backgrounds
3045 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3047 // draw the highlights
3048 if(vote_highlighted == 1) {
3049 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3050 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3052 else if(vote_highlighted == 2) {
3053 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3054 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3057 // draw the progress bars
3058 if(vote_yescount && vote_needed)
3060 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3061 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3064 if(vote_nocount && vote_needed)
3066 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3067 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3070 drawresetcliparea();
3073 vote_highlighted = 0;
3077 // Mod icons panel (#10)
3080 float mod_active; // is there any active mod icon?
3082 // Clan Arena HUD modicons
3083 void HUD_Mod_CA(vector pos, vector mySize)
3085 mod_active = 1; // CA should never hide the mod icons panel
3086 float redalive, bluealive;
3087 redalive = getstati(STAT_REDALIVE);
3088 bluealive = getstati(STAT_BLUEALIVE);
3090 drawfont = hud_bigfont;
3091 vector redpos, bluepos;
3092 if(mySize_x > mySize_y)
3095 bluepos = pos + eY * 0.5 * mySize_y;
3096 drawpic_aspect_skin(redpos, "player_red.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3097 drawstring_aspect(redpos + eX * 0.5 * mySize_x, ftos(redalive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3098 drawpic_aspect_skin(bluepos, "player_blue.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3099 drawstring_aspect(bluepos + eX * 0.5 * mySize_x, ftos(bluealive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3104 bluepos = pos + eY * 0.5 * mySize_y;
3105 drawpic_aspect_skin(redpos, "player_red.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3106 drawstring_aspect(redpos + eY * 0.3 * mySize_y, ftos(redalive), eX * mySize_x + eY * 0.2 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3107 drawpic_aspect_skin(bluepos, "player_blue.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3108 drawstring_aspect(bluepos + eY * 0.3 * mySize_y, ftos(bluealive), eX * mySize_x + eY * 0.2 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3110 drawfont = hud_font;
3113 // CTF HUD modicon section
3114 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3115 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3116 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3118 void HUD_Mod_CTF_Reset(void)
3120 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3123 void HUD_Mod_CTF(vector pos, vector mySize)
3125 vector redflag_pos, blueflag_pos;
3127 float f; // every function should have that
3129 float redflag, blueflag; // current status
3130 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3133 stat_items = getstati(STAT_ITEMS);
3134 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3135 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3137 if(redflag || blueflag)
3142 if(autocvar__hud_configure)
3148 // when status CHANGES, set old status into prevstatus and current status into status
3149 if (redflag != redflag_prevframe)
3151 redflag_statuschange_time = time;
3152 redflag_prevstatus = redflag_prevframe;
3153 redflag_prevframe = redflag;
3156 if (blueflag != blueflag_prevframe)
3158 blueflag_statuschange_time = time;
3159 blueflag_prevstatus = blueflag_prevframe;
3160 blueflag_prevframe = blueflag;
3163 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3164 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3166 float BLINK_FACTOR = 0.15;
3167 float BLINK_BASE = 0.85;
3169 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3171 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3173 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3175 string red_icon, red_icon_prevstatus;
3176 float red_alpha, red_alpha_prevstatus;
3177 red_alpha = red_alpha_prevstatus = 1;
3179 case 1: red_icon = "flag_red_taken"; break;
3180 case 2: red_icon = "flag_red_lost"; break;
3181 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3183 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3184 red_icon = "flag_red_shielded";
3186 red_icon = string_null;
3189 switch(redflag_prevstatus) {
3190 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3191 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3192 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3195 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3196 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3197 red_icon_prevstatus = "flag_red_shielded";
3199 red_icon_prevstatus = string_null;
3203 string blue_icon, blue_icon_prevstatus;
3204 float blue_alpha, blue_alpha_prevstatus;
3205 blue_alpha = blue_alpha_prevstatus = 1;
3207 case 1: blue_icon = "flag_blue_taken"; break;
3208 case 2: blue_icon = "flag_blue_lost"; break;
3209 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3211 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3212 blue_icon = "flag_blue_shielded";
3214 blue_icon = string_null;
3217 switch(blueflag_prevstatus) {
3218 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3219 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3220 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3223 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3224 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3225 blue_icon_prevstatus = "flag_blue_shielded";
3227 blue_icon_prevstatus = string_null;
3231 if(mySize_x > mySize_y) {
3232 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3234 blueflag_pos = pos + eX * 0.5 * mySize_x;
3237 redflag_pos = pos + eX * 0.5 * mySize_x;
3239 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3241 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3243 blueflag_pos = pos + eY * 0.5 * mySize_y;
3246 redflag_pos = pos + eY * 0.5 * mySize_y;
3248 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3251 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3252 if(red_icon_prevstatus && f < 1)
3253 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3255 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3257 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3258 if(blue_icon_prevstatus && f < 1)
3259 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3261 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3264 // Keyhunt HUD modicon section
3265 float kh_runheretime;
3267 void HUD_Mod_KH_Reset(void)
3272 void HUD_Mod_KH(vector pos, vector mySize)
3274 mod_active = 1; // keyhunt should never hide the mod icons panel
3278 vector p, pa, kh_size, kh_asize;
3280 kh_keys = getstati(STAT_KH_KEYS);
3283 if(mySize_x > mySize_y)
3285 p_y = pos_y + 0.25 * mySize_y;
3286 pa = p - eY * 0.25 * mySize_y;
3288 kh_size_x = mySize_x * 0.25;
3289 kh_size_y = 0.75 * mySize_y;
3290 kh_asize_x = mySize_x * 0.25;
3291 kh_asize_y = mySize_y * 0.25;
3295 p_y = pos_y + 0.125 * mySize_y;
3296 pa = p - eY * 0.125 * mySize_y;
3298 kh_size_x = mySize_x * 0.5;
3299 kh_size_y = 0.375 * mySize_y;
3300 kh_asize_x = mySize_x * 0.5;
3301 kh_asize_y = mySize_y * 0.125;
3308 for(i = 0; i < 4; ++i)
3310 key = floor(kh_keys / pow(32, i)) & 31;
3312 if(keyteam == 30 && keycount <= 4)
3314 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3318 // this yields 8 exactly if "RUN HERE" shows
3323 kh_runheretime = time;
3324 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3329 for(i = 0; i < 4; ++i)
3331 key = floor(kh_keys / pow(32, i)) & 31;
3344 default: // owned or dropped
3349 a = a * panel_fg_alpha;
3350 aa = aa * panel_fg_alpha;
3356 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3359 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3362 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3365 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3370 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3373 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3376 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3379 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3382 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3386 if(mySize_x > mySize_y)
3388 p_x += 0.25 * mySize_x;
3389 pa_x += 0.25 * mySize_x;
3395 p_y = pos_y + 0.625 * mySize_y;
3396 pa_y = pos_y + 0.5 * mySize_y;
3402 p_x += 0.5 * mySize_x;
3403 pa_x += 0.5 * mySize_x;
3409 // Keepaway HUD mod icon
3410 float kaball_prevstatus; // last remembered status
3411 float kaball_statuschange_time; // time when the status changed
3413 // we don't need to reset for keepaway since it immediately
3414 // autocorrects prevstatus as to if the player has the ball or not
3416 void HUD_Mod_Keepaway(vector pos, vector mySize)
3418 mod_active = 1; // keepaway should always show the mod HUD
3420 float BLINK_FACTOR = 0.15;
3421 float BLINK_BASE = 0.85;
3422 float BLINK_FREQ = 5;
3423 float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
3425 float stat_items = getstati(STAT_ITEMS);
3426 float kaball = (stat_items/IT_KEY1) & 1;
3428 if(kaball != kaball_prevstatus)
3430 kaball_statuschange_time = time;
3431 kaball_prevstatus = kaball;
3434 // todo: Fix the sizing with the expanding image
3436 float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
3437 float f = bound(0, kaball_statuschange_elapsedtime*2, 1);
3439 if(kaball_prevstatus && f < 1)
3440 drawpic_aspect_skin_expanding(pos + eY * 0.25 * mySize_y, "keepawayball_carrying", eX * mySize_x + eY * mySize_y * 0.5, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f);
3443 drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
3447 // Nexball HUD mod icon
3448 void HUD_Mod_NexBall(vector pos, vector mySize)
3450 float stat_items, nb_pb_starttime, dt, p;
3452 stat_items = getstati(STAT_ITEMS);
3453 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3455 if (stat_items & IT_KEY1)
3460 //Manage the progress bar if any
3461 if (nb_pb_starttime > 0)
3463 dt = mod(time - nb_pb_starttime, nb_pb_period);
3464 // one period of positive triangle
3465 p = 2 * dt / nb_pb_period;
3470 HUD_Panel_GetProgressBarColor(nexball);
3471 if(mySize_x > mySize_y)
3472 HUD_Panel_DrawProgressBar(pos, mySize, "statusbar", p, 0, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3474 HUD_Panel_DrawProgressBar(pos, mySize, "statusbar", p, 1, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3477 if (stat_items & IT_KEY1)
3478 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3481 // Race/CTS HUD mod icons
3482 float crecordtime_prev; // last remembered crecordtime
3483 float crecordtime_change_time; // time when crecordtime last changed
3484 float srecordtime_prev; // last remembered srecordtime
3485 float srecordtime_change_time; // time when srecordtime last changed
3487 float race_status_time;
3488 float race_status_prev;
3489 string race_status_name_prev;
3490 void HUD_Mod_Race(vector pos, vector mySize)
3492 mod_active = 1; // race should never hide the mod icons panel
3494 me = playerslots[player_localentnum - 1];
3496 float f; // yet another function has this
3497 score = me.(scores[ps_primary]);
3499 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3500 return; // no records in the actual race
3502 drawfont = hud_bigfont;
3504 // clientside personal record
3506 if(gametype == GAME_CTS)
3510 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3512 if(score && (score < t || !t)) {
3513 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3514 if(autocvar_cl_autodemo_delete_keeprecords)
3516 f = autocvar_cl_autodemo_delete;
3518 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3522 if(t != crecordtime_prev) {
3523 crecordtime_prev = t;
3524 crecordtime_change_time = time;
3527 vector textPos, medalPos;
3529 if(mySize_x > mySize_y) {
3530 // text on left side
3531 squareSize = min(mySize_y, mySize_x/2);
3532 textPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eY * 0.5 * (mySize_y - squareSize);
3533 medalPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eX * 0.5 * mySize_x + eY * 0.5 * (mySize_y - squareSize);
3536 squareSize = min(mySize_x, mySize_y/2);
3537 textPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eX * 0.5 * (mySize_x - squareSize);
3538 medalPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eY * 0.5 * mySize_y + eX * 0.5 * (mySize_x - squareSize);
3541 f = time - crecordtime_change_time;
3544 drawstring_aspect(textPos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3545 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);
3547 drawstring_aspect(textPos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3548 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);
3549 drawstring_aspect_expanding(pos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
3550 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);
3554 t = race_server_record;
3555 if(t != srecordtime_prev) {
3556 srecordtime_prev = t;
3557 srecordtime_change_time = time;
3559 f = time - srecordtime_change_time;
3562 drawstring_aspect(textPos + eY * 0.5 * squareSize, "Server best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3563 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);
3565 drawstring_aspect(textPos + eY * 0.5 * squareSize, "Server best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3566 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);
3567 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);
3568 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);
3571 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
3572 race_status_time = time + 5;
3573 race_status_prev = race_status;
3574 if (race_status_name_prev)
3575 strunzone(race_status_name_prev);
3576 race_status_name_prev = strzone(race_status_name);
3581 a = bound(0, race_status_time - time, 1);
3584 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
3588 rank = race_CheckName(race_status_name);
3590 rankname = race_PlaceName(rank);
3593 namepos = medalPos + '0 0.8 0' * squareSize;
3595 rankpos = medalPos + '0 0.15 0' * squareSize;
3597 if(race_status == 0)
3598 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3599 else if(race_status == 1) {
3600 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);
3601 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3602 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3603 } else if(race_status == 2) {
3604 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
3605 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);
3607 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);
3608 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3609 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3610 } else if(race_status == 3) {
3611 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);
3612 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3613 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3616 if (race_status_time - time <= 0) {
3617 race_status_prev = -1;
3619 if(race_status_name)
3620 strunzone(race_status_name);
3621 race_status_name = string_null;
3622 if(race_status_name_prev)
3623 strunzone(race_status_name_prev);
3624 race_status_name_prev = string_null;
3626 drawfont = hud_font;
3629 void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, float layout, float i)
3631 float stat, pps_ratio;
3637 stat = getstatf(STAT_DOM_PPS_RED);
3638 pic = "dom_icon_red";
3642 stat = getstatf(STAT_DOM_PPS_BLUE);
3643 pic = "dom_icon_blue";
3647 stat = getstatf(STAT_DOM_PPS_YELLOW);
3648 pic = "dom_icon_yellow";
3652 stat = getstatf(STAT_DOM_PPS_PINK);
3653 pic = "dom_icon_pink";
3656 pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS);
3658 if(mySize_x/mySize_y > aspect_ratio)
3660 i = aspect_ratio * mySize_y;
3661 myPos_x = myPos_x + (mySize_x - i) / 2;
3666 i = 1/aspect_ratio * mySize_x;
3667 myPos_y = myPos_y + (mySize_y - i) / 2;
3671 if (layout) // show text too
3674 color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
3675 if (layout == 2) // average pps
3676 drawstring_aspect(myPos + eX * mySize_y, ftos_decimals(stat, 2), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
3677 else // percentage of average pps
3678 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);
3682 drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3685 drawsetcliparea(myPos_x, myPos_y + mySize_y * (1 - pps_ratio), mySize_y, mySize_y * pps_ratio);
3686 drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3687 drawresetcliparea();
3691 void HUD_Mod_Dom(vector myPos, vector mySize)
3693 mod_active = 1; // required in each mod function that always shows something
3696 for(tm = teams.sort_next; tm; tm = tm.sort_next)
3697 if(tm.team != COLOR_SPECTATOR)
3700 float layout = autocvar_hud_panel_modicons_dom_layout;
3701 float rows, columns, aspect_ratio;
3702 rows = mySize_y/mySize_x;
3703 aspect_ratio = (layout) ? 3 : 1;
3704 rows = bound(1, floor((sqrt((4 * aspect_ratio * teams_count + rows) * rows) + rows + 0.5) / 2), teams_count);
3705 columns = ceil(teams_count/rows);
3707 drawfont = hud_bigfont;
3710 for(i=0; i<teams_count; ++i)
3712 vector pos, itemSize;
3713 pos = myPos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows);
3714 itemSize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
3716 DrawDomItem(pos, itemSize, aspect_ratio, layout, i);
3725 drawfont = hud_font;
3728 float mod_prev; // previous state of mod_active to check for a change
3730 float mod_change; // "time" when mod_active changed
3732 void HUD_ModIcons(void)
3734 if(!autocvar__hud_configure)
3736 if(!autocvar_hud_panel_modicons) return;
3737 if (gametype != GAME_CTF && gametype != GAME_KEYHUNT && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && gametype != GAME_CA && gametype != GAME_FREEZETAG && gametype != GAME_KEEPAWAY && gametype != GAME_DOMINATION) return;
3740 hud_configure_active_panel = HUD_PANEL_MODICONS;
3742 HUD_Panel_UpdateCvars(modicons);
3745 mySize = panel_size;
3747 if(mod_active != mod_prev) {
3749 mod_prev = mod_active;
3752 if(mod_active || autocvar__hud_configure)
3753 mod_alpha = bound(0, (time - mod_change) * 2, 1);
3755 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
3758 HUD_Panel_DrawBg(mod_alpha);
3760 if(panel_bg_padding)
3762 pos += '1 1 0' * panel_bg_padding;
3763 mySize -= '2 2 0' * panel_bg_padding;
3766 // these MUST be ran in order to update mod_active
3767 if(gametype == GAME_KEYHUNT)
3768 HUD_Mod_KH(pos, mySize);
3769 else if(gametype == GAME_CTF || autocvar__hud_configure)
3770 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
3771 else if(gametype == GAME_NEXBALL)
3772 HUD_Mod_NexBall(pos, mySize);
3773 else if(gametype == GAME_CTS || gametype == GAME_RACE)
3774 HUD_Mod_Race(pos, mySize);
3775 else if(gametype == GAME_CA || gametype == GAME_FREEZETAG)
3776 HUD_Mod_CA(pos, mySize);
3777 else if(gametype == GAME_DOMINATION)
3778 HUD_Mod_Dom(pos, mySize);
3779 else if(gametype == GAME_KEEPAWAY)
3780 HUD_Mod_Keepaway(pos, mySize);
3783 // Draw pressed keys (#11)
3785 void HUD_DrawPressedKeys(void)
3787 if(!autocvar__hud_configure)
3789 if(!autocvar_hud_panel_pressedkeys) return;
3790 if(spectatee_status <= 0 && autocvar_hud_panel_pressedkeys < 2) return;
3793 hud_configure_active_panel = HUD_PANEL_PRESSEDKEYS;
3796 HUD_Panel_UpdateCvars(pressedkeys);
3799 mySize = panel_size;
3801 HUD_Panel_DrawBg(1);
3802 if(panel_bg_padding)
3804 pos += '1 1 0' * panel_bg_padding;
3805 mySize -= '2 2 0' * panel_bg_padding;
3808 // force custom aspect
3809 float aspect = autocvar_hud_panel_pressedkeys_aspect;
3813 if(mySize_x/mySize_y > aspect)
3815 newSize_x = aspect * mySize_y;
3816 newSize_y = mySize_y;
3818 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3822 newSize_y = 1/aspect * mySize_x;
3823 newSize_x = mySize_x;
3825 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3831 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
3833 pressedkeys = getstatf(STAT_PRESSED_KEYS);
3835 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3836 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);
3837 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);
3839 drawpic_aspect_skin(pos, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3840 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);
3841 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);
3844 // Handle chat as a panel (#12)
3848 if(!autocvar__hud_configure)
3850 if (!autocvar_hud_panel_chat)
3852 if (!autocvar_con_chatrect)
3853 cvar_set("con_chatrect", "0");
3858 hud_configure_active_panel = HUD_PANEL_CHAT;
3860 HUD_Panel_UpdateCvars(chat);
3862 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
3864 panel_pos_y = panel_bg_border;
3865 panel_size_y = vid_conheight - panel_bg_border * 2;
3866 if(panel_bg == "0") // force a border when maximized
3868 if(precache_pic(panel_bg) == "") {
3869 panel_bg = strcat(hud_skin_path, "/border_default");
3870 if(precache_pic(panel_bg) == "") {
3871 panel_bg = "gfx/hud/default/border_default";
3875 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an alpha of at least 0.75
3880 mySize = panel_size;
3882 HUD_Panel_DrawBg(1);
3884 if(panel_bg_padding)
3886 pos += '1 1 0' * panel_bg_padding;
3887 mySize -= '2 2 0' * panel_bg_padding;
3890 if (!autocvar_con_chatrect)
3891 cvar_set("con_chatrect", "1");
3893 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
3894 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
3896 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
3897 cvar_set("con_chat", ftos(floor(mySize_y/autocvar_con_chatsize - 0.5)));
3899 if(autocvar__hud_configure)
3902 chatsize = '1 1 0' * autocvar_con_chatsize;
3903 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
3905 for(i = 0; i < autocvar_con_chat; ++i)
3907 if(i == autocvar_con_chat - 1)
3910 a = panel_fg_alpha * floor(((i + 1) * 7 + autocvar_con_chattime)/45);
3911 drawcolorcodedstring(pos, textShortenToWidth("^3Player^7: This is the chat area.", mySize_x, chatsize, stringwidth_colors), chatsize, a, DRAWFLAG_NORMAL);
3912 pos_y += chatsize_y;
3917 // Engine info panel (#13)
3924 float frametimeavg1; // 1 frame ago
3925 float frametimeavg2; // 2 frames ago
3926 void HUD_EngineInfo(void)
3928 if(!autocvar__hud_configure)
3930 if(!autocvar_hud_panel_engineinfo) return;
3933 hud_configure_active_panel = HUD_PANEL_ENGINEINFO;
3935 HUD_Panel_UpdateCvars(engineinfo);
3938 mySize = panel_size;
3940 HUD_Panel_DrawBg(1);
3941 if(panel_bg_padding)
3943 pos += '1 1 0' * panel_bg_padding;
3944 mySize -= '2 2 0' * panel_bg_padding;
3947 float currentTime = gettime(GETTIME_REALTIME);
3948 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
3950 float currentframetime = currentTime - prevfps_time;
3951 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
3952 frametimeavg2 = frametimeavg1;
3953 frametimeavg1 = frametimeavg;
3956 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
3957 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.
3959 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
3960 prevfps = (1/currentframetime);
3961 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"
3963 prevfps_time = currentTime;
3968 if(currentTime - prevfps_time > autocvar_hud_panel_engineinfo_framecounter_time)
3970 prevfps = framecounter/(currentTime - prevfps_time);
3972 prevfps_time = currentTime;
3977 color = HUD_Get_Num_Color (prevfps, 100);
3978 drawfont = hud_bigfont;
3979 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, autocvar_hud_panel_engineinfo_framecounter_decimals)), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
3980 drawfont = hud_font;
3983 // Info messages panel (#14)
3985 #define drawInfoMessage(s)\
3986 if(autocvar_hud_panel_infomessages_flip)\
3987 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);\
3988 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
3990 void HUD_InfoMessages(void)
3992 if(!autocvar__hud_configure)
3994 if(!autocvar_hud_panel_infomessages) return;
3997 hud_configure_active_panel = HUD_PANEL_INFOMESSAGES;
3999 HUD_Panel_UpdateCvars(infomessages);
4002 mySize = panel_size;
4004 HUD_Panel_DrawBg(1);
4005 if(panel_bg_padding)
4007 pos += '1 1 0' * panel_bg_padding;
4008 mySize -= '2 2 0' * panel_bg_padding;
4011 // always force 5:1 aspect
4013 if(mySize_x/mySize_y > 5)
4015 newSize_x = 5 * mySize_y;
4016 newSize_y = mySize_y;
4018 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4022 newSize_y = 1/5 * mySize_x;
4023 newSize_x = mySize_x;
4025 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4034 fontsize = '0.20 0.20 0' * mySize_y;
4037 if(spectatee_status != 0)
4043 if(!autocvar__hud_configure)
4045 if(spectatee_status && !intermission)
4047 if(spectatee_status == -1)
4050 s = strcat("^1Spectating: ^7", GetPlayerName(spectatee_status - 1));
4053 if(spectatee_status == -1)
4054 s = strcat("^1Press ^3", getcommandkey("primary fire", "+fire"), "^1 to spectate");
4056 s = strcat("^1Press ^3", getcommandkey("primary fire", "+fire"), "^1 for another player");
4059 if(spectatee_status == -1)
4060 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
4062 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+fire2"), "^1 to observe");
4065 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
4068 if(gametype == GAME_ARENA)
4069 s = "^1Wait for your turn to join";
4070 else if(gametype == GAME_LMS)
4073 sk = playerslots[player_localentnum - 1];
4074 if(sk.(scores[ps_primary]) >= 666)
4075 s = "^1Match has already begun";
4076 else if(sk.(scores[ps_primary]) > 0)
4077 s = "^1You have no more lives left";
4079 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4082 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4085 //show restart countdown:
4086 if (time < getstatf(STAT_GAMESTARTTIME)) {
4088 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4089 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4090 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
4091 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4095 if(warmup_stage && !intermission)
4097 s = "^2Currently in ^1warmup^2 stage!";
4102 if(mod(time, 1) >= 0.5)
4107 if(ready_waiting && !intermission && !spectatee_status)
4109 if(ready_waiting_for_me)
4112 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
4114 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
4119 s = strcat("^2Waiting for others to ready up to end warmup...");
4121 s = strcat("^2Waiting for others to ready up...");
4125 else if(warmup_stage && !intermission && !spectatee_status)
4127 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
4131 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4133 float ts_min, ts_max;
4134 tm = teams.sort_next;
4137 for(; tm.sort_next; tm = tm.sort_next)
4139 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4141 if(!ts_min) ts_min = tm.team_size;
4142 else ts_min = min(ts_min, tm.team_size);
4143 if(!ts_max) ts_max = tm.team_size;
4144 else ts_max = max(ts_max, tm.team_size);
4146 if ((ts_max - ts_min) > 1)
4148 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
4149 tm = GetTeam(myteam, false);
4151 if (tm.team != COLOR_SPECTATOR)
4152 if (tm.team_size == ts_max)
4153 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
4161 s = "^7Press ^3ESC ^7to show HUD options.";
4163 s = "^3Doubleclick ^7a panel for panel-specific options.";
4165 s = "^3CTRL ^7to disable collision testing, ^3SHIFT ^7and";
4167 s = "^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.";
4172 // Physics panel (#15)
4174 vector acc_prevspeed;
4175 float acc_prevtime, acc_avg, top_speed, top_speed_time;
4177 void HUD_Physics(void)
4179 if(!autocvar_hud_panel_physics)
4181 if(!autocvar__hud_configure) return;
4182 if(spectatee_status <= 0 && autocvar_hud_panel_physics < 2) return;
4185 hud_configure_active_panel = HUD_PANEL_PHYSICS;
4187 HUD_Panel_UpdateCvars(physics);
4189 HUD_Panel_DrawBg(1);
4190 if(panel_bg_padding)
4192 panel_pos += '1 1 0' * panel_bg_padding;
4193 panel_size -= '2 2 0' * panel_bg_padding;
4197 float speed, conversion_factor;
4200 switch(autocvar_hud_panel_physics_speed_unit)
4205 conversion_factor = 1.0;
4209 conversion_factor = 0.0254;
4213 conversion_factor = 0.0254 * 3.6;
4217 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4221 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4225 float max_speed = floor( autocvar_hud_panel_physics_speed_max * conversion_factor + 0.5 );
4226 if (autocvar__hud_configure)
4227 speed = floor( max_speed * 0.65 + 0.5 );
4228 else if(autocvar_hud_panel_physics_speed_z)
4229 speed = floor( vlen(pmove_vel) * conversion_factor + 0.5 );
4231 speed = floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 );
4233 //compute acceleration
4234 float acceleration, f;
4235 if (autocvar__hud_configure)
4236 acceleration = autocvar_hud_panel_physics_acceleration_max * 0.3;
4239 f = time - acc_prevtime;
4240 if(autocvar_hud_panel_physics_acceleration_z)
4241 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4243 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4244 acc_prevspeed = pmove_vel;
4245 acc_prevtime = time;
4247 f = bound(0, f * 10, 1);
4248 acc_avg = acc_avg * (1 - f) + acceleration * f;
4249 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4253 drawfont = hud_bigfont;
4254 float panel_ar = panel_size_x/panel_size_y;
4255 vector speed_offset, acceleration_offset;
4258 panel_size_x *= 0.5;
4259 if (autocvar_hud_panel_physics_flip)
4260 speed_offset_x = panel_size_x;
4262 acceleration_offset_x = panel_size_x;
4266 panel_size_y *= 0.5;
4267 if (autocvar_hud_panel_physics_flip)
4268 speed_offset_y = panel_size_y;
4270 acceleration_offset_y = panel_size_y;
4272 float speed_baralign, acceleration_baralign;
4273 if (autocvar_hud_panel_physics_baralign == 1)
4274 acceleration_baralign = speed_baralign = 1;
4275 else if(autocvar_hud_panel_physics_baralign == 4)
4276 acceleration_baralign = speed_baralign = 2;
4277 else if (autocvar_hud_panel_physics_flip)
4279 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 2);
4280 speed_baralign = (autocvar_hud_panel_physics_baralign == 3);
4284 speed_baralign = (autocvar_hud_panel_physics_baralign == 2);
4285 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 3);
4289 if(speed && autocvar_hud_panel_physics_progressbar)
4291 HUD_Panel_GetProgressBarColor(speed);
4292 HUD_Panel_DrawProgressBar(panel_pos + speed_offset, panel_size, "progressbar", speed/max_speed, 0, speed_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4295 vector tmp_offset, tmp_size;
4296 tmp_size_x = panel_size_x * 0.75;
4297 tmp_size_y = panel_size_y;
4299 tmp_offset_x = panel_size_x - tmp_size_x;
4302 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4308 tmp_offset_x = tmp_size_x;
4309 if (autocvar_hud_panel_physics_speed_unit_show)
4312 tmp_size_x = panel_size_x * (1 - 0.75);
4313 tmp_size_y = panel_size_y * 0.4;
4314 drawstring_aspect(panel_pos + speed_offset + tmp_offset, unit, tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4317 //compute and draw top speed
4318 if (autocvar_hud_panel_physics_topspeed)
4320 if (autocvar__hud_configure)
4322 top_speed = floor( max_speed * 0.75 + 0.5 );
4327 if (speed >= top_speed)
4330 top_speed_time = time;
4333 else if (top_speed != 0)
4335 f = max(1, autocvar_hud_panel_physics_topspeed_time);
4336 // divide by f to make it start from 1
4337 f = cos( ((time - top_speed_time) / f) * PI/2 );
4339 else //hide top speed 0, it would be stupid
4344 //top speed progressbar peak
4345 if(autocvar_hud_panel_physics_progressbar && speed < top_speed)
4347 float peak_offset_x;
4349 if (speed_baralign == 0)
4350 peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x;
4351 else if (speed_baralign == 1)
4352 peak_offset_x = (1 - min(top_speed, max_speed)/max_speed) * panel_size_x;
4353 else if (speed_baralign == 2)
4354 peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x * 0.5;
4355 //if speed is not 0 the speed progressbar already fetched the color
4357 HUD_Panel_GetProgressBarColor(speed);
4358 peak_size_x = floor(panel_size_x * 0.01 + 1.5);
4359 peak_size_y = panel_size_y;
4360 if (speed_baralign == 2) // draw two peaks, on both sides
4362 drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size_x + peak_offset_x - peak_size_x), peak_size, progressbar_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4363 drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size_x - peak_offset_x + peak_size_x), peak_size, progressbar_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4366 drawfill(panel_pos + speed_offset + eX * (peak_offset_x - peak_size_x), peak_size, progressbar_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4370 tmp_offset_y = panel_size_y * 0.4;
4371 tmp_size_x = panel_size_x * (1 - 0.75);
4372 tmp_size_y = panel_size_y - tmp_offset_y;
4373 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(top_speed), tmp_size, '1 0 0', f * panel_fg_alpha, DRAWFLAG_NORMAL);
4380 if(acceleration && autocvar_hud_panel_physics_progressbar)
4382 if (acceleration < 0)
4383 HUD_Panel_GetProgressBarColor(acceleration_neg);
4385 HUD_Panel_GetProgressBarColor(acceleration);
4386 HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset, panel_size, "progressbar", fabs(acceleration)/autocvar_hud_panel_physics_acceleration_max, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4388 drawstring_aspect(panel_pos + acceleration_offset, ftos_decimals(acceleration, 3), panel_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4389 drawfont = hud_font;
4398 void HUD_Reset (void)
4400 // reset gametype specific icons
4401 if(gametype == GAME_KEYHUNT)
4403 else if(gametype == GAME_CTF)
4404 HUD_Mod_CTF_Reset();
4407 #define HUD_DrawPanel(id)\
4409 case (HUD_PANEL_RADAR):\
4410 HUD_Radar(); break;\
4411 case (HUD_PANEL_WEAPONS):\
4412 HUD_Weapons(); break;\
4413 case (HUD_PANEL_AMMO):\
4415 case (HUD_PANEL_POWERUPS):\
4416 HUD_Powerups(); break;\
4417 case (HUD_PANEL_HEALTHARMOR):\
4418 HUD_HealthArmor(); break;\
4419 case (HUD_PANEL_NOTIFY):\
4420 HUD_Notify(); break;\
4421 case (HUD_PANEL_TIMER):\
4422 HUD_Timer(); break;\
4423 case (HUD_PANEL_SCORE):\
4424 HUD_Score(); break;\
4425 case (HUD_PANEL_RACETIMER):\
4426 HUD_RaceTimer(); break;\
4427 case (HUD_PANEL_VOTE):\
4428 HUD_VoteWindow(); break;\
4429 case (HUD_PANEL_MODICONS):\
4430 HUD_ModIcons(); break;\
4431 case (HUD_PANEL_PRESSEDKEYS):\
4432 HUD_DrawPressedKeys(); break;\
4433 case (HUD_PANEL_CHAT):\
4435 case (HUD_PANEL_ENGINEINFO):\
4436 HUD_EngineInfo(); break;\
4437 case (HUD_PANEL_INFOMESSAGES):\
4438 HUD_InfoMessages(); break;\
4439 case (HUD_PANEL_PHYSICS):\
4440 HUD_Physics(); break;\
4441 } ENDS_WITH_CURLY_BRACE
4443 void HUD_Main (void)
4446 // global hud alpha fade
4447 if(menu_enabled == 1)
4450 hud_fade_alpha = (1 - autocvar__menu_alpha);
4452 if(scoreboard_fade_alpha)
4453 hud_fade_alpha = (1 - scoreboard_fade_alpha);
4455 if(intermission == 2) // no hud during mapvote
4457 else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
4460 if(!autocvar__hud_configure && !hud_fade_alpha)
4464 if (hud_skin_path != autocvar_hud_skin)
4467 strunzone(hud_skin_path);
4468 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
4471 // HUD configure visible grid
4472 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4474 hud_configure_gridSize_x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
4475 hud_configure_gridSize_y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
4476 hud_configure_realGridSize_x = hud_configure_gridSize_x * vid_conwidth;
4477 hud_configure_realGridSize_y = hud_configure_gridSize_y * vid_conheight;
4479 for(i = 0; i < 1/hud_configure_gridSize_x; ++i)
4480 drawfill(eX * i * hud_configure_realGridSize_x, eX + eY * vid_conheight, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4482 for(i = 0; i < 1/hud_configure_gridSize_y; ++i)
4483 drawfill(eY * i * hud_configure_realGridSize_y, eY + eX * vid_conwidth, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4487 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4491 float hud_dock_color_team = autocvar_hud_dock_color_team;
4492 if((teamplay) && hud_dock_color_team) {
4493 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4494 color = colormapPaletteColor(mod(f, 16), 1) * hud_dock_color_team;
4496 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
4497 color = '1 0 0' * hud_dock_color_team;
4501 string hud_dock_color = autocvar_hud_dock_color;
4502 if(hud_dock_color == "shirt") {
4503 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4504 color = colormapPaletteColor(floor(f / 16), 0);
4506 else if(hud_dock_color == "pants") {
4507 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4508 color = colormapPaletteColor(mod(f, 16), 1);
4511 color = stov(hud_dock_color);
4515 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4516 if(precache_pic(pic) == "") {
4517 pic = strcat(hud_skin_path, "/dock_medium");
4518 if(precache_pic(pic) == "") {
4519 pic = "gfx/hud/default/dock_medium";
4522 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...
4525 // cache the panel order into the panel_order array
4526 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4527 for(i = 0; i < HUD_PANEL_NUM; ++i)
4528 panel_order[i] = -1;
4530 float p_num, warning;
4531 float argc = tokenize_console(autocvar__hud_panelorder);
4532 if (argc > HUD_PANEL_NUM)
4534 //first detect wrong/missing panel numbers
4535 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4536 p_num = stof(argv(i));
4537 if (p_num >= 0 && p_num < HUD_PANEL_NUM) { //correct panel number?
4538 if (panel_order[p_num] == -1) //found for the first time?
4539 s = strcat(s, ftos(p_num), " ");
4540 panel_order[p_num] = 1; //mark as found
4545 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4546 if (panel_order[i] == -1) {
4548 s = strcat(s, ftos(i), " "); //add missing panel number
4552 print("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n");
4554 cvar_set("_hud_panelorder", s);
4555 if(hud_panelorder_prev)
4556 strunzone(hud_panelorder_prev);
4557 hud_panelorder_prev = strzone(s);
4559 //now properly set panel_order
4560 tokenize_console(s);
4561 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4562 panel_order[i] = stof(argv(i));
4566 // draw panels in order specified by panel_order array
4567 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
4568 if(i != HUD_PANEL_CHAT || !autocvar__con_chat_maximized) // don't draw maximized chat panel twice!
4569 HUD_DrawPanel(panel_order[i]);
4572 // draw chat panel on top if it is maximized
4573 if(autocvar__con_chat_maximized)
4574 HUD_Chat(); // HUD_DrawPanel(HUD_PANEL_CHAT);
4576 if (autocvar__hud_configure && spectatee_status && hud_configure_prev == -1) // try to join if we are in hud_configure mode, but still spectating, and in the first frame (in order to get rid of motd when launching a server via the menu "HUD Setup" button)
4577 localcmd("cmd selectteam auto; cmd join\n");
4579 if(autocvar__hud_configure && tab_panel != -1)
4581 HUD_Panel_UpdatePosSizeForId(tab_panel)
4582 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
4585 hud_configure_prev = autocvar__hud_configure;
4587 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again