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 #define HUD_Write(s) fputs(fh, s)
421 // q: quoted, n: not quoted
422 #define HUD_Write_Cvar_n(cvar) HUD_Write(strcat("seta ", cvar, " ", cvar_string(cvar), "\n"))
423 #define HUD_Write_Cvar_q(cvar) HUD_Write(strcat("seta ", cvar, " \"", cvar_string(cvar), "\"\n"))
424 #define HUD_Write_PanelCvar_n(cvar_suf) HUD_Write_Cvar_n(strcat("hud_panel_", panel_name, cvar_suf))
425 #define HUD_Write_PanelCvar_q(cvar_suf) HUD_Write_Cvar_q(strcat("hud_panel_", panel_name, cvar_suf))
427 void HUD_Panel_ExportCfg(string cfgname)
430 string filename = strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg");
431 fh = fopen(filename, FILE_WRITE);
434 HUD_Write_Cvar_q("hud_skin");
435 HUD_Write_Cvar_q("hud_panel_bg");
436 HUD_Write_Cvar_q("hud_panel_bg_color");
437 HUD_Write_Cvar_q("hud_panel_bg_color_team");
438 HUD_Write_Cvar_q("hud_panel_bg_alpha");
439 HUD_Write_Cvar_q("hud_panel_bg_border");
440 HUD_Write_Cvar_q("hud_panel_bg_padding");
441 HUD_Write_Cvar_q("hud_panel_fg_alpha");
444 HUD_Write_Cvar_q("hud_dock");
445 HUD_Write_Cvar_q("hud_dock_color");
446 HUD_Write_Cvar_q("hud_dock_color_team");
447 HUD_Write_Cvar_q("hud_dock_alpha");
450 HUD_Write_Cvar_q("hud_progressbar_alpha");
451 HUD_Write_Cvar_q("hud_progressbar_strength_color");
452 HUD_Write_Cvar_q("hud_progressbar_shield_color");
453 HUD_Write_Cvar_q("hud_progressbar_health_color");
454 HUD_Write_Cvar_q("hud_progressbar_armor_color");
455 HUD_Write_Cvar_q("hud_progressbar_fuel_color");
456 HUD_Write_Cvar_q("hud_progressbar_nexball_color");
459 HUD_Write_Cvar_q("_hud_panelorder");
462 HUD_Write_Cvar_q("hud_configure_grid");
463 HUD_Write_Cvar_q("hud_configure_grid_xsize");
464 HUD_Write_Cvar_q("hud_configure_grid_ysize");
467 HUD_Write_Cvar_q("scr_centerpos");
470 // common cvars for all panels
472 for (i = 0; i < HUD_PANEL_NUM; ++i)
474 HUD_Panel_GetName(i);
476 HUD_Write_PanelCvar_n("");
477 HUD_Write_PanelCvar_q("_pos");
478 HUD_Write_PanelCvar_q("_size");
479 HUD_Write_PanelCvar_q("_bg");
480 HUD_Write_PanelCvar_q("_bg_color");
481 HUD_Write_PanelCvar_q("_bg_color_team");
482 HUD_Write_PanelCvar_q("_bg_alpha");
483 HUD_Write_PanelCvar_q("_bg_border");
484 HUD_Write_PanelCvar_q("_bg_padding");
486 case HUD_PANEL_WEAPONS:
487 HUD_Write_PanelCvar_q("_complainbubble");
488 HUD_Write_PanelCvar_q("_complainbubble_padding");
489 HUD_Write_PanelCvar_q("_complainbubble_color_outofammo");
490 HUD_Write_PanelCvar_q("_complainbubble_color_donthave");
491 HUD_Write_PanelCvar_q("_complainbubble_color_unavailable");
492 HUD_Write_PanelCvar_q("_ammo_color");
493 HUD_Write_PanelCvar_q("_ammo_alpha");
494 HUD_Write_PanelCvar_q("_aspect");
497 HUD_Write_PanelCvar_q("_onlycurrent");
498 HUD_Write_PanelCvar_q("_iconalign");
499 HUD_Write_PanelCvar_q("_progressbar");
500 HUD_Write_PanelCvar_q("_progressbar_name");
501 HUD_Write_PanelCvar_q("_text");
503 case HUD_PANEL_POWERUPS:
504 HUD_Write_PanelCvar_q("_flip");
505 HUD_Write_PanelCvar_q("_iconalign");
506 HUD_Write_PanelCvar_q("_baralign");
507 HUD_Write_PanelCvar_q("_progressbar");
508 HUD_Write_PanelCvar_q("_progressbar_strength");
509 HUD_Write_PanelCvar_q("_progressbar_shield");
511 case HUD_PANEL_HEALTHARMOR:
512 HUD_Write_PanelCvar_q("_flip");
513 HUD_Write_PanelCvar_q("_iconalign");
514 HUD_Write_PanelCvar_q("_baralign");
515 HUD_Write_PanelCvar_q("_progressbar");
516 HUD_Write_PanelCvar_q("_progressbar_health");
517 HUD_Write_PanelCvar_q("_progressbar_armor");
518 HUD_Write_PanelCvar_q("_text");
520 case HUD_PANEL_NOTIFY:
521 HUD_Write_PanelCvar_q("_flip");
522 HUD_Write_PanelCvar_q("_print");
524 case HUD_PANEL_RADAR:
525 HUD_Write_PanelCvar_q("_foreground_alpha");
528 HUD_Write_PanelCvar_q("_alreadyvoted_alpha");
530 case HUD_PANEL_PRESSEDKEYS:
531 HUD_Write_PanelCvar_q("_aspect");
533 case HUD_PANEL_INFOMESSAGES:
534 HUD_Write_PanelCvar_q("_flip");
539 HUD_Write("menu_sync\n"); // force the menu to reread the cvars, so that the dialogs are updated
541 print("^2Successfully exported to ", filename, "! (Note: It's saved in data/data/)\n");
545 print("^1Couldn't write to ", filename, "\n");
548 const float hlBorderSize = 4;
549 const string hlBorder = "gfx/hud/default/border_highlighted";
550 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
551 void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
553 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
554 drawpic_tiled(panel_pos - '1 1 0' * myBorder, hlBorder, '8 1 0' * hlBorderSize, eX * (panel_size_x + 2 * myBorder) + eY * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
555 drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * (panel_size_y + 2 * myBorder - hlBorderSize), hlBorder, '8 1 0' * hlBorderSize, eX * (panel_size_x + 2 * myBorder) + eY * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
556 drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * hlBorderSize, hlBorder2, '1 8 0' * hlBorderSize, eY * (panel_size_y + 2 * myBorder - 2 * hlBorderSize) + eX * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
557 drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * hlBorderSize + eX * (panel_size_x + 2 * myBorder - hlBorderSize), hlBorder2, '1 8 0' * hlBorderSize, eY * (panel_size_y + 2 * myBorder - 2 * hlBorderSize) + eX * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
560 // draw the background/borders
561 #define HUD_Panel_DrawBg(alpha)\
563 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));\
564 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
566 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);\
567 } ENDS_WITH_CURLY_BRACE
569 //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
570 void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float lenght_ratio, float vertical, float right_align, vector theColor, float theAlpha, float drawflag)
572 if(lenght_ratio <= 0 || !theAlpha)
578 vector width, height;
580 pic = strcat(hud_skin_path, "/", pic, "_vertical");
581 if(precache_pic(pic) == "") {
582 pic = "gfx/hud/default/statusbar_vertical";
586 theOrigin_y += (1 - lenght_ratio) * theSize_y;
587 theSize_y *= lenght_ratio;
590 width = eX * theSize_x;
591 height = eY * theSize_y;
592 if(theSize_y <= theSize_x * 2)
594 // button not high enough
595 // draw just upper and lower part then
596 square = eY * theSize_y * 0.5;
597 bH = eY * (0.25 * theSize_y / (theSize_x * 2));
598 drawsubpic(theOrigin, square + width, pic, '0 0 0', eX + bH, theColor, theAlpha, drawflag);
599 drawsubpic(theOrigin + square, square + width, pic, eY - bH, eX + bH, theColor, theAlpha, drawflag);
603 square = eY * theSize_x;
604 drawsubpic(theOrigin, width + square, pic, '0 0 0', '1 0.25 0', theColor, theAlpha, drawflag);
605 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0 0.25 0', '1 0.5 0', theColor, theAlpha, drawflag);
606 drawsubpic(theOrigin + height - square, width + square, pic, '0 0.75 0', '1 0.25 0', theColor, theAlpha, drawflag);
609 pic = strcat(hud_skin_path, "/", pic);
610 if(precache_pic(pic) == "") {
611 pic = "gfx/hud/default/statusbar";
615 theOrigin_x += (1 - lenght_ratio) * theSize_x;
616 theSize_x *= lenght_ratio;
619 width = eX * theSize_x;
620 height = eY * theSize_y;
621 if(theSize_x <= theSize_y * 2)
623 // button not wide enough
624 // draw just left and right part then
625 square = eX * theSize_x * 0.5;
626 bW = eX * (0.25 * theSize_x / (theSize_y * 2));
627 drawsubpic(theOrigin, square + height, pic, '0 0 0', eY + bW, theColor, theAlpha, drawflag);
628 drawsubpic(theOrigin + square, square + height, pic, eX - bW, eY + bW, theColor, theAlpha, drawflag);
632 square = eX * theSize_y;
633 drawsubpic(theOrigin, height + square, pic, '0 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
634 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0.25 0 0', '0.5 1 0', theColor, theAlpha, drawflag);
635 drawsubpic(theOrigin + width - square, height + square, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
640 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
646 pic = strcat(hud_skin_path, "/num_leading");
647 if(precache_pic(pic) == "") {
648 pic = "gfx/hud/default/num_leading";
651 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
652 if(mySize_x/mySize_y > 2)
653 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);
654 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);
657 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
658 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
667 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
668 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
670 for (i = 0; i < HUD_PANEL_NUM; ++i) {
671 if(i == highlightedPanel || !panel_enabled)
674 HUD_Panel_UpdatePosSizeForId(i);
676 panel_pos -= '1 1 0' * panel_bg_border;
677 panel_size += '2 2 0' * panel_bg_border;
679 if(myPos_y + mySize_y < panel_pos_y)
681 if(myPos_y > panel_pos_y + panel_size_y)
684 if(myPos_x + mySize_x < panel_pos_x)
686 if(myPos_x > panel_pos_x + panel_size_x)
689 // OK, there IS a collision.
691 myCenter_x = myPos_x + 0.5 * mySize_x;
692 myCenter_y = myPos_y + 0.5 * mySize_y;
694 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
695 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
697 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
699 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
700 myTarget_x = panel_pos_x - mySize_x;
701 else // push it upwards
702 myTarget_y = panel_pos_y - mySize_y;
704 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
706 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
707 myTarget_x = panel_pos_x + panel_size_x;
708 else // push it upwards
709 myTarget_y = panel_pos_y - mySize_y;
711 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
713 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
714 myTarget_x = panel_pos_x - mySize_x;
715 else // push it downwards
716 myTarget_y = panel_pos_y + panel_size_y;
718 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
720 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
721 myTarget_x = panel_pos_x + panel_size_x;
722 else // push it downwards
723 myTarget_y = panel_pos_y + panel_size_y;
725 //if(cvar("hud_configure_checkcollisions_debug"))
726 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
732 void HUD_Panel_SetPos(vector pos)
734 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
738 //if(cvar("hud_configure_checkcollisions_debug"))
739 //drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
741 if(cvar("hud_configure_grid"))
743 pos_x = floor((pos_x/vid_conwidth)/hud_configure_gridSize_x + 0.5) * hud_configure_realGridSize_x;
744 pos_y = floor((pos_y/vid_conheight)/hud_configure_gridSize_y + 0.5) * hud_configure_realGridSize_y;
747 if(hud_configure_checkcollisions)
748 pos = HUD_Panel_CheckMove(pos, mySize);
750 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
751 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
754 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
756 HUD_Panel_GetName(highlightedPanel);
757 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
760 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
761 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
766 float dist_x, dist_y;
768 ratio = mySize_x/mySize_y;
770 for (i = 0; i < HUD_PANEL_NUM; ++i) {
771 if(i == highlightedPanel || !panel_enabled)
774 HUD_Panel_UpdatePosSizeForId(i);
776 panel_pos -= '1 1 0' * panel_bg_border;
777 panel_size += '2 2 0' * panel_bg_border;
779 targEndPos = panel_pos + panel_size;
781 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
782 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
785 if (resizeCorner == 1)
787 // check if this panel is on our way
788 if (resizeorigin_x <= panel_pos_x)
790 if (resizeorigin_y <= panel_pos_y)
792 if (targEndPos_x <= resizeorigin_x - mySize_x)
794 if (targEndPos_y <= resizeorigin_y - mySize_y)
797 // there is a collision:
798 // detect which side of the panel we are facing is actually limiting the resizing
799 // (which side the resize direction finds for first) and reduce the size up to there
801 // dist is the distance between resizeorigin and the "analogous" point of the panel
802 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
803 dist_x = resizeorigin_x - targEndPos_x;
804 dist_y = resizeorigin_y - targEndPos_y;
805 if (dist_y <= 0 || dist_x / dist_y > ratio)
806 mySize_x = min(mySize_x, dist_x);
808 mySize_y = min(mySize_y, dist_y);
810 else if (resizeCorner == 2)
812 if (resizeorigin_x >= targEndPos_x)
814 if (resizeorigin_y <= panel_pos_y)
816 if (panel_pos_x >= resizeorigin_x + mySize_x)
818 if (targEndPos_y <= resizeorigin_y - mySize_y)
821 dist_x = panel_pos_x - resizeorigin_x;
822 dist_y = resizeorigin_y - targEndPos_y;
823 if (dist_y <= 0 || dist_x / dist_y > ratio)
824 mySize_x = min(mySize_x, dist_x);
826 mySize_y = min(mySize_y, dist_y);
828 else if (resizeCorner == 3)
830 if (resizeorigin_x <= panel_pos_x)
832 if (resizeorigin_y >= targEndPos_y)
834 if (targEndPos_x <= resizeorigin_x - mySize_x)
836 if (panel_pos_y >= resizeorigin_y + mySize_y)
839 dist_x = resizeorigin_x - targEndPos_x;
840 dist_y = panel_pos_y - resizeorigin_y;
841 if (dist_y <= 0 || dist_x / dist_y > ratio)
842 mySize_x = min(mySize_x, dist_x);
844 mySize_y = min(mySize_y, dist_y);
846 else if (resizeCorner == 4)
848 if (resizeorigin_x >= targEndPos_x)
850 if (resizeorigin_y >= targEndPos_y)
852 if (panel_pos_x >= resizeorigin_x + mySize_x)
854 if (panel_pos_y >= resizeorigin_y + mySize_y)
857 dist_x = panel_pos_x - resizeorigin_x;
858 dist_y = panel_pos_y - resizeorigin_y;
859 if (dist_y <= 0 || dist_x / dist_y > ratio)
860 mySize_x = min(mySize_x, dist_x);
862 mySize_y = min(mySize_y, dist_y);
864 //if(cvar("hud_configure_checkcollisions_debug"))
865 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
871 void HUD_Panel_SetPosSize(vector mySize)
873 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
875 resizeorigin = panel_click_resizeorigin;
878 // minimum panel size cap
879 mySize_x = max(0.025 * vid_conwidth, mySize_x);
880 mySize_y = max(0.025 * vid_conheight, mySize_y);
882 if(highlightedPanel == HUD_PANEL_CHAT) // some panels have their own restrictions, like the chat panel (which actually only moves the engine chat print around). Looks bad if it's too small.
884 mySize_x = max(17 * autocvar_con_chatsize, mySize_x);
885 mySize_y = max(2 * autocvar_con_chatsize + 2 * panel_bg_padding, mySize_y);
888 // collision testing|
889 // -----------------+
891 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
892 if(resizeCorner == 1) {
893 myPos_x = resizeorigin_x - mySize_x;
894 myPos_y = resizeorigin_y - mySize_y;
895 } else if(resizeCorner == 2) {
896 myPos_x = resizeorigin_x;
897 myPos_y = resizeorigin_y - mySize_y;
898 } else if(resizeCorner == 3) {
899 myPos_x = resizeorigin_x - mySize_x;
900 myPos_y = resizeorigin_y;
901 } else { // resizeCorner == 4
902 myPos_x = resizeorigin_x;
903 myPos_y = resizeorigin_y;
906 // left/top screen edges
908 mySize_x = mySize_x + myPos_x;
910 mySize_y = mySize_y + myPos_y;
912 // bottom/right screen edges
913 if(myPos_x + mySize_x > vid_conwidth)
914 mySize_x = vid_conwidth - myPos_x;
915 if(myPos_y + mySize_y > vid_conheight)
916 mySize_y = vid_conheight - myPos_y;
918 //if(cvar("hud_configure_checkcollisions_debug"))
919 //drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
921 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
922 if(cvar("hud_configure_grid"))
924 mySize_x = floor((mySize_x/vid_conwidth)/hud_configure_gridSize_x + 0.5) * hud_configure_realGridSize_x;
925 mySize_y = floor((mySize_y/vid_conheight)/hud_configure_gridSize_y + 0.5) * hud_configure_realGridSize_y;
928 if(hud_configure_checkcollisions)
929 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
931 // minimum panel size cap, do this once more so we NEVER EVER EVER have a panel smaller than this, JUST IN CASE above code still makes the panel eg negative (impossible to resize back without changing cvars manually then)
932 mySize_x = max(0.025 * vid_conwidth, mySize_x);
933 mySize_y = max(0.025 * vid_conheight, mySize_y);
935 // do another pos check, as size might have changed by now
936 if(resizeCorner == 1) {
937 myPos_x = resizeorigin_x - mySize_x;
938 myPos_y = resizeorigin_y - mySize_y;
939 } else if(resizeCorner == 2) {
940 myPos_x = resizeorigin_x;
941 myPos_y = resizeorigin_y - mySize_y;
942 } else if(resizeCorner == 3) {
943 myPos_x = resizeorigin_x - mySize_x;
944 myPos_y = resizeorigin_y;
945 } else { // resizeCorner == 4
946 myPos_x = resizeorigin_x;
947 myPos_y = resizeorigin_y;
950 //if(cvar("hud_configure_checkcollisions_debug"))
951 //drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
953 HUD_Panel_GetName(highlightedPanel);
955 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
956 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
958 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
959 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
963 float prevMouseClicked; // previous state
964 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
965 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
967 float pressed_key_time;
968 void HUD_Panel_Arrow_Action(float nPrimary)
970 if (highlightedPanel_prev == -1 || mouseClicked)
973 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
976 if(cvar("hud_configure_grid"))
978 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
980 if (hudShiftState & S_SHIFT)
981 step = hud_configure_realGridSize_y;
983 step = 2 * hud_configure_realGridSize_y;
987 if (hudShiftState & S_SHIFT)
988 step = hud_configure_realGridSize_x;
990 step = 2 * hud_configure_realGridSize_x;
995 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
996 step = vid_conheight;
999 if (hudShiftState & S_SHIFT)
1000 step = (step / 256); // more precision
1002 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
1005 highlightedPanel = highlightedPanel_prev;
1007 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
1009 vector prev_pos, prev_size;
1010 prev_pos = panel_pos;
1011 prev_size = panel_size;
1013 if (hudShiftState & S_ALT) // resize
1015 highlightedAction = 1;
1016 if(nPrimary == K_UPARROW)
1018 else if(nPrimary == K_RIGHTARROW)
1020 else if(nPrimary == K_LEFTARROW)
1022 else // if(nPrimary == K_DOWNARROW)
1025 // ctrl+arrow reduces the size, instead of increasing it
1026 // Note that ctrl disables collisions check too, but it's fine
1027 // since we don't collide with anything reducing the size
1028 if (hudShiftState & S_CTRL) {
1030 resizeCorner = 5 - resizeCorner;
1034 mySize = panel_size;
1035 panel_click_resizeorigin = panel_pos;
1036 if(resizeCorner == 1) {
1037 panel_click_resizeorigin += mySize;
1039 } else if(resizeCorner == 2) {
1040 panel_click_resizeorigin_y += mySize_y;
1042 } else if(resizeCorner == 3) {
1043 panel_click_resizeorigin_x += mySize_x;
1045 } else { // resizeCorner == 4
1048 HUD_Panel_SetPosSize(mySize);
1052 highlightedAction = 2;
1055 if(nPrimary == K_UPARROW)
1057 else if(nPrimary == K_DOWNARROW)
1059 else if(nPrimary == K_LEFTARROW)
1061 else // if(nPrimary == K_RIGHTARROW)
1064 HUD_Panel_SetPos(pos);
1067 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
1069 if (prev_pos != panel_pos || prev_size != panel_size)
1072 panel_pos_backup = prev_pos;
1073 panel_size_backup = prev_size;
1074 highlightedPanel_backup = highlightedPanel;
1078 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1082 if(!autocvar__hud_configure)
1085 // allow console bind to work
1088 con_keys = findkeysforcommand("toggleconsole");
1089 keys = tokenize(con_keys);
1091 float hit_con_bind, i;
1092 for (i = 0; i < keys; ++i)
1094 if(nPrimary == stof(argv(i)))
1098 if(bInputType == 0) {
1099 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1100 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1101 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1103 else if(bInputType == 1) {
1104 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1105 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1106 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1109 if(nPrimary == K_MOUSE1)
1111 if(bInputType == 0) { // key pressed
1115 else if(bInputType == 1) {// key released
1120 else if(nPrimary == K_ESCAPE)
1122 if (bInputType == 1)
1125 menu_enabled_time = time;
1126 localcmd("menu_showhudexit\n");
1128 else if(nPrimary == K_SPACE && hudShiftState & S_CTRL) // enable/disable highlighted panel or dock
1130 if (bInputType == 1 || mouseClicked)
1133 if (highlightedPanel_prev != -1)
1134 cvar_set(strcat("hud_panel_", panel_name), ftos(!(panel_enabled)));
1136 cvar_set(strcat("hud_dock"), (autocvar_hud_dock == "") ? "dock" : "");
1138 else if(nPrimary == 'c' && hudShiftState & S_CTRL) // copy highlighted panel size
1140 if (bInputType == 1 || mouseClicked)
1143 if (highlightedPanel_prev != -1)
1145 panel_size_copied = panel_size;
1146 highlightedPanel_copied = highlightedPanel_prev;
1149 else if(nPrimary == 'v' && hudShiftState & S_CTRL) // past copied size on the highlighted panel
1151 if (bInputType == 1 || mouseClicked)
1154 if (highlightedPanel_copied == -1 || highlightedPanel_prev == -1)
1157 HUD_Panel_UpdatePosSizeForId(highlightedPanel_prev);
1159 // reduce size if it'd go beyond screen boundaries
1160 vector tmp_size = panel_size_copied;
1161 if (panel_pos_x + panel_size_copied_x > vid_conwidth)
1162 tmp_size_x = vid_conwidth - panel_pos_x;
1163 if (panel_pos_y + panel_size_copied_y > vid_conheight)
1164 tmp_size_y = vid_conheight - panel_pos_y;
1166 if (panel_size == tmp_size)
1170 panel_pos_backup = panel_pos;
1171 panel_size_backup = panel_size;
1172 highlightedPanel_backup = highlightedPanel_prev;
1174 s = strcat(ftos(tmp_size_x/vid_conwidth), " ", ftos(tmp_size_y/vid_conheight));
1175 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
1177 else if(nPrimary == 'z' && hudShiftState & S_CTRL) // undo last action
1179 if (bInputType == 1 || mouseClicked)
1181 //restore previous values
1182 if (highlightedPanel_backup != -1)
1184 HUD_Panel_GetName(highlightedPanel_backup);
1185 s = strcat(ftos(panel_pos_backup_x/vid_conwidth), " ", ftos(panel_pos_backup_y/vid_conheight));
1186 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
1187 s = strcat(ftos(panel_size_backup_x/vid_conwidth), " ", ftos(panel_size_backup_y/vid_conheight));
1188 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
1189 highlightedPanel_backup = -1;
1192 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1194 if (bInputType == 1)
1196 pressed_key_time = 0;
1199 else if (pressed_key_time == 0)
1200 pressed_key_time = time;
1202 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1204 else if(hit_con_bind)
1207 return true; // Suppress ALL other input
1210 float HUD_Panel_HighlightCheck()
1214 while(j < HUD_PANEL_NUM)
1219 HUD_Panel_UpdatePosSizeForId(i);
1221 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1224 if(mousepos_x >= panel_pos_x && mousepos_y >= panel_pos_y && mousepos_x <= panel_pos_x + panel_size_x && mousepos_y <= panel_pos_y + panel_size_y)
1228 // resize from topleft border
1229 else if(mousepos_x >= panel_pos_x - border && mousepos_y >= panel_pos_y - border && mousepos_x <= panel_pos_x + 0.5 * panel_size_x && mousepos_y <= panel_pos_y + 0.5 * panel_size_y)
1233 // resize from topright border
1234 else if(mousepos_x >= panel_pos_x + 0.5 * panel_size_x && mousepos_y >= panel_pos_y - border && mousepos_x <= panel_pos_x + panel_size_x + border && mousepos_y <= panel_pos_y + 0.5 * panel_size_y)
1238 // resize from bottomleft border
1239 else if(mousepos_x >= panel_pos_x - border && mousepos_y >= panel_pos_y + 0.5 * panel_size_y && mousepos_x <= panel_pos_x + 0.5 * panel_size_x && mousepos_y <= panel_pos_y + panel_size_y + border)
1243 // resize from bottomright border
1244 else if(mousepos_x >= panel_pos_x + 0.5 * panel_size_x && mousepos_y >= panel_pos_y + 0.5 * panel_size_y && mousepos_x <= panel_pos_x + panel_size_x + border && mousepos_y <= panel_pos_y + panel_size_y + border)
1252 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1253 void HUD_Panel_FirstInDrawQ(float id)
1256 var float place = -1;
1257 // find out where in the array our current id is, save into place
1258 for(i = 0; i < HUD_PANEL_NUM; ++i)
1260 if(panel_order[i] == id)
1266 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1268 place = HUD_PANEL_NUM - 1;
1270 // move all ids up by one step in the array until "place"
1271 for(i = place; i > 0; --i)
1273 panel_order[i] = panel_order[i-1];
1275 // now save the new top id
1276 panel_order[0] = id;
1278 // let's save them into the cvar by some strcat trickery
1280 for(i = 0; i < HUD_PANEL_NUM; ++i)
1282 s = strcat(s, ftos(panel_order[i]), " ");
1284 cvar_set("_hud_panelorder", s);
1285 if(hud_panelorder_prev)
1286 strunzone(hud_panelorder_prev);
1287 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1290 void HUD_Panel_Highlight()
1294 while(j < HUD_PANEL_NUM)
1299 HUD_Panel_UpdatePosSizeForId(i);
1301 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1304 if(mousepos_x >= panel_pos_x && mousepos_y >= panel_pos_y && mousepos_x <= panel_pos_x + panel_size_x && mousepos_y <= panel_pos_y + panel_size_y)
1306 highlightedPanel = i;
1307 HUD_Panel_FirstInDrawQ(i);
1308 highlightedAction = 1;
1309 panel_click_distance = mousepos - panel_pos;
1312 // resize from topleft border
1313 else if(mousepos_x >= panel_pos_x - border && mousepos_y >= panel_pos_y - border && mousepos_x <= panel_pos_x + 0.5 * panel_size_x && mousepos_y <= panel_pos_y + 0.5 * panel_size_y)
1315 highlightedPanel = i;
1316 HUD_Panel_FirstInDrawQ(i);
1317 highlightedAction = 2;
1319 panel_click_distance = mousepos - panel_pos;
1320 panel_click_resizeorigin = panel_pos + panel_size;
1323 // resize from topright border
1324 else if(mousepos_x >= panel_pos_x + 0.5 * panel_size_x && mousepos_y >= panel_pos_y - border && mousepos_x <= panel_pos_x + panel_size_x + border && mousepos_y <= panel_pos_y + 0.5 * panel_size_y)
1326 highlightedPanel = i;
1327 HUD_Panel_FirstInDrawQ(i);
1328 highlightedAction = 2;
1330 panel_click_distance_x = panel_size_x - mousepos_x + panel_pos_x;
1331 panel_click_distance_y = mousepos_y - panel_pos_y;
1332 panel_click_resizeorigin = panel_pos + eY * panel_size_y;
1335 // resize from bottomleft border
1336 else if(mousepos_x >= panel_pos_x - border && mousepos_y >= panel_pos_y + 0.5 * panel_size_y && mousepos_x <= panel_pos_x + 0.5 * panel_size_x && mousepos_y <= panel_pos_y + panel_size_y + border)
1338 highlightedPanel = i;
1339 HUD_Panel_FirstInDrawQ(i);
1340 highlightedAction = 2;
1342 panel_click_distance_x = mousepos_x - panel_pos_x;
1343 panel_click_distance_y = panel_size_y - mousepos_y + panel_pos_y;
1344 panel_click_resizeorigin = panel_pos + eX * panel_size_x;
1347 // resize from bottomright border
1348 else if(mousepos_x >= panel_pos_x + 0.5 * panel_size_x && mousepos_y >= panel_pos_y + 0.5 * panel_size_y && mousepos_x <= panel_pos_x + panel_size_x + border && mousepos_y <= panel_pos_y + panel_size_y + border)
1350 highlightedPanel = i;
1351 HUD_Panel_FirstInDrawQ(i);
1352 highlightedAction = 2;
1354 panel_click_distance = panel_size - mousepos + panel_pos;
1355 panel_click_resizeorigin = panel_pos;
1360 highlightedPanel_prev = -1;
1365 float highlightcheck;
1366 vector prev_pos, prev_size;
1367 void HUD_Panel_Mouse()
1369 // TODO: needs better check... is there any float that contains the current state of the menu? _menu_alpha isn't apparently updated the frame the menu gets enabled
1370 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1374 print("menu_enabled: ", ftos(menu_enabled), "\n");
1375 print("Highlighted: ", ftos(highlightedPanel), "\n");
1376 print("Menu alpha: ", ftos(autocvar__menu_alpha), "\n");
1379 // instantly hide the editor cursor if we open the HUDExit dialog
1380 // as hud_fade_alpha doesn't decrease to 0 in this case
1381 // TODO: find a way to fade the cursor out even in this case
1382 if(menu_enabled == 1 || (menu_enabled == 2 && !hud_fade_alpha))
1385 if(mouseClicked == 0 && menu_enabled != 2 && highlightedPanel >= 0) { // don't reset these variables in menu_enabled mode 2!
1386 highlightedPanel = -1;
1387 highlightedAction = 0;
1389 if(highlightedPanel != -1)
1390 highlightedPanel_prev = highlightedPanel;
1392 mousepos = mousepos + getmousepos() * autocvar_menu_mouse_speed;
1394 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1395 mousepos_y = bound(0, mousepos_y, vid_conheight);
1399 if(prevMouseClicked == 0)
1401 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1402 // and calls HUD_Panel_UpdatePosSizeForId() for the highlighted panel
1403 prev_pos = panel_pos;
1404 prev_size = panel_size;
1407 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
1409 if (prev_pos != panel_pos || prev_size != panel_size)
1411 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1413 panel_pos_backup = prev_pos;
1414 panel_size_backup = prev_size;
1415 highlightedPanel_backup = highlightedPanel;
1418 // in case the clicked panel is inside another panel and we aren't
1419 // moving it, avoid the immediate "fix" of its position/size
1420 // (often unwanted and hateful) by disabling collisions check
1421 hud_configure_checkcollisions = false;
1423 if(highlightedAction == 1)
1424 HUD_Panel_SetPos(mousepos - panel_click_distance);
1425 else if(highlightedAction == 2)
1428 if(resizeCorner == 1) {
1429 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1430 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1431 } else if(resizeCorner == 2) {
1432 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1433 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1434 } else if(resizeCorner == 3) {
1435 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1436 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1437 } else { // resizeCorner == 4
1438 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1439 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1441 HUD_Panel_SetPosSize(mySize);
1444 // doubleclick check
1445 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1447 mouseClicked = 0; // to prevent spam, I guess.
1449 menu_enabled_time = time;
1450 HUD_Panel_GetName(highlightedPanel);
1451 localcmd("menu_showhudoptions ", panel_name, "\n");
1454 if(prevMouseClicked == 0)
1456 prevMouseClickedTime = time;
1457 prevMouseClickedPos = mousepos;
1462 highlightcheck = HUD_Panel_HighlightCheck();
1464 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1466 cursorsize = '32 32 0';
1468 if(highlightcheck == 0)
1469 drawpic(mousepos, strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1470 else if(highlightcheck == 1)
1471 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_move.tga"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1472 else if(highlightcheck == 2)
1473 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_resize.tga"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1475 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_resize2.tga"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1477 prevMouseClicked = mouseClicked;
1480 // Weapon icons (#0)
1482 float weaponspace[10];
1483 #define HUD_Weapons_Clear()\
1485 for(idx = 0; idx < 10; ++idx)\
1486 weaponspace[idx] = 0
1488 entity weaponorder[WEP_MAXCOUNT];
1489 void weaponorder_swap(float i, float j, entity pass)
1493 weaponorder[i] = weaponorder[j];
1497 string weaponorder_cmp_str;
1498 float weaponorder_cmp(float i, float j, entity pass)
1501 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1502 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1503 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)
1506 float GetAmmoStat(float i)
1510 case 0: return STAT_SHELLS;
1511 case 1: return STAT_NAILS;
1512 case 2: return STAT_ROCKETS;
1513 case 3: return STAT_CELLS;
1514 case 4: return STAT_FUEL;
1519 float GetAmmoTypeForWep(float i)
1523 case WEP_SHOTGUN: return 0;
1524 case WEP_UZI: return 1;
1525 case WEP_GRENADE_LAUNCHER: return 2;
1526 case WEP_MINE_LAYER: return 2;
1527 case WEP_ELECTRO: return 3;
1528 case WEP_CRYLINK: return 3;
1529 case WEP_HLAC: return 3;
1530 case WEP_MINSTANEX: return 3;
1531 case WEP_NEX: return 3;
1532 case WEP_CAMPINGRIFLE: return 1;
1533 case WEP_HAGAR: return 2;
1534 case WEP_ROCKET_LAUNCHER: return 2;
1535 case WEP_SEEKER: return 2;
1536 case WEP_FIREBALL: return 4;
1537 case WEP_HOOK: return 3;
1542 void HUD_Weapons(void)
1545 float center_x, center_y;
1547 if(!autocvar__hud_configure)
1549 if(!autocvar_hud_panel_weapons) return;
1550 if(spectatee_status == -1) return;
1553 float timeout = autocvar_hud_panel_weapons_timeout;
1554 float timeout_effect_length, timein_effect_length;
1555 if (autocvar_hud_panel_weapons_timeout_effect == 0)
1557 timeout_effect_length = 0;
1558 timein_effect_length = 0;
1562 timeout_effect_length = 0.75;
1563 timein_effect_length = 0.375;
1566 if (timeout && time >= weapontime + timeout + timeout_effect_length && !autocvar__hud_configure)
1568 weaponprevtime = time;
1572 active_panel = HUD_PANEL_WEAPONS;
1573 HUD_Panel_UpdateCvars(weapons);
1575 if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
1577 f = (time - (weapontime + timeout)) / timeout_effect_length;
1578 if (autocvar_hud_panel_weapons_timeout_effect)
1580 panel_bg_alpha *= (1 - f);
1581 panel_fg_alpha *= (1 - f);
1583 if (autocvar_hud_panel_weapons_timeout_effect == 1)
1585 f *= f; // for a cooler movement
1586 center_x = panel_pos_x + panel_size_x/2;
1587 center_y = panel_pos_y + panel_size_y/2;
1588 screen_ar = vid_conwidth/vid_conheight;
1589 if (center_x/center_y < screen_ar) //bottom left
1591 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
1592 panel_pos_y += f * (vid_conheight - panel_pos_y);
1594 panel_pos_x -= f * (panel_pos_x + panel_size_x);
1598 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
1599 panel_pos_x += f * (vid_conwidth - panel_pos_x);
1601 panel_pos_y -= f * (panel_pos_y + panel_size_y);
1604 weaponprevtime = time - (1 - f) * timein_effect_length;
1606 else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure)
1608 f = (time - weaponprevtime) / timein_effect_length;
1609 if (autocvar_hud_panel_weapons_timeout_effect)
1611 panel_bg_alpha *= (f);
1612 panel_fg_alpha *= (f);
1614 if (autocvar_hud_panel_weapons_timeout_effect == 1)
1616 f *= f; // for a cooler movement
1618 center_x = panel_pos_x + panel_size_x/2;
1619 center_y = panel_pos_y + panel_size_y/2;
1620 screen_ar = vid_conwidth/vid_conheight;
1621 if (center_x/center_y < screen_ar) //bottom left
1623 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
1624 panel_pos_y += f * (vid_conheight - panel_pos_y);
1626 panel_pos_x -= f * (panel_pos_x + panel_size_x);
1630 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
1631 panel_pos_x += f * (vid_conwidth - panel_pos_x);
1633 panel_pos_y -= f * (panel_pos_y + panel_size_y);
1638 float i, weapid, wpnalpha, weapon_cnt;
1640 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1642 self = get_weaponinfo(i);
1643 if(self.impulse >= 0)
1647 // TODO make this configurable
1648 if(weaponorder_bypriority != autocvar_cl_weaponpriority)
1650 if(weaponorder_bypriority)
1651 strunzone(weaponorder_bypriority);
1652 if(weaponorder_byimpulse)
1653 strunzone(weaponorder_byimpulse);
1655 weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
1656 weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
1657 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1660 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1662 self = get_weaponinfo(i);
1663 if(self.impulse >= 0)
1665 weaponorder[weapon_cnt] = self;
1669 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1671 weaponorder_cmp_str = string_null;
1674 HUD_Panel_DrawBg(1);
1675 if(panel_bg_padding)
1677 panel_pos += '1 1 0' * panel_bg_padding;
1678 panel_size -= '2 2 0' * panel_bg_padding;
1681 if(autocvar_hud_panel_weapons_fade)
1683 wpnalpha = 3.2 - 2 * (time - weapontime);
1684 wpnalpha = bound(0.7, wpnalpha, 1) * panel_fg_alpha;
1687 wpnalpha = panel_fg_alpha;
1689 HUD_Weapons_Clear();
1691 float rows, columns;
1692 float aspect = autocvar_hud_panel_weapons_aspect;
1693 rows = panel_size_y/panel_size_x;
1694 rows = bound(1, floor((sqrt(4 * aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1696 columns = ceil(WEP_COUNT/rows);
1699 float a, type, fullammo;
1701 when = autocvar_hud_panel_weapons_complainbubble_time;
1703 fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
1709 float fullammo_shells, fullammo_nails, fullammo_rockets, fullammo_cells, fullammo_fuel;
1712 wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
1713 float barsize_x, barsize_y, baroffset_x, baroffset_y;
1714 float show_ammo = autocvar_hud_panel_weapons_ammo;
1717 fullammo_shells = autocvar_hud_panel_weapons_ammo_full_shells;
1718 fullammo_nails = autocvar_hud_panel_weapons_ammo_full_nails;
1719 fullammo_rockets = autocvar_hud_panel_weapons_ammo_full_rockets;
1720 fullammo_cells = autocvar_hud_panel_weapons_ammo_full_cells;
1721 fullammo_fuel = autocvar_hud_panel_weapons_ammo_full_fuel;
1722 ammo_color = stov(autocvar_hud_panel_weapons_ammo_color);
1723 ammo_alpha = panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha;
1726 if(wpnsize_x/wpnsize_y > aspect)
1728 barsize_x = aspect * wpnsize_y;
1729 barsize_y = wpnsize_y;
1730 baroffset_x = (wpnsize_x - barsize_x) / 2;
1734 barsize_y = 1/aspect * wpnsize_x;
1735 barsize_x = wpnsize_x;
1736 baroffset_y = (wpnsize_y - barsize_y) / 2;
1740 float show_accuracy;
1742 if(autocvar_hud_panel_weapons_accuracy && acc_levels)
1744 show_accuracy = true;
1745 if (acc_col_x[0] == -1)
1746 for (i = 0; i < acc_levels; ++i)
1747 acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
1750 float weapons_st = getstati(STAT_WEAPONS);
1751 float label = autocvar_hud_panel_weapons_label;
1753 for(i = 0; i < weapon_cnt; ++i)
1755 wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y;
1757 self = weaponorder[i];
1758 weapid = self.impulse;
1760 // draw background behind currently selected weapon
1761 if(self.weapon == activeweapon)
1762 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
1764 // draw the weapon accuracy
1767 weapon_stats = weapon_accuracy[self.weapon-WEP_FIRST];
1768 if(weapon_stats >= 0)
1770 // find the max level lower than weapon_stats
1773 while ( j && weapon_stats < acc_lev[j] )
1776 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
1778 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
1780 color = color + factor * (acc_col[j+1] - color);
1782 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1786 // draw the weapon icon
1787 if((weapid >= 0) && (weapons_st & self.weapons))
1789 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
1791 if(label == 1) // weapon number
1792 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1793 else if(label == 2) // bind
1794 drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1796 // draw ammo status bar
1797 if(show_ammo && weapid != WEP_TUBA && weapid != WEP_LASER && weapid != WEP_PORTO)
1800 type = GetAmmoTypeForWep(weapid);
1802 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
1807 case 0: fullammo = fullammo_shells; break;
1808 case 1: fullammo = fullammo_nails; break;
1809 case 2: fullammo = fullammo_rockets; break;
1810 case 3: fullammo = fullammo_cells; break;
1811 case 4: fullammo = fullammo_fuel; break;
1812 default: fullammo = 60;
1816 wpnpos_x + baroffset_x,
1817 wpnpos_y + baroffset_y,
1818 barsize_x * bound(0, a/fullammo, 1),
1820 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, ammo_color, ammo_alpha, DRAWFLAG_NORMAL);
1821 drawresetcliparea();
1826 // draw a "ghost weapon icon" if you don't have the weapon
1829 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
1832 // draw the complain message
1833 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
1837 if(complain_weapon_time + when > time)
1840 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1844 if(complain_weapon_time + when > time)
1851 if(complain_weapon_type == 0) {
1853 color = stov(autocvar_hud_panel_weapons_complainbubble_color_outofammo);
1855 else if(complain_weapon_type == 1) {
1857 color = stov(autocvar_hud_panel_weapons_complainbubble_color_donthave);
1861 color = stov(autocvar_hud_panel_weapons_complainbubble_color_unavailable);
1863 float padding = autocvar_hud_panel_weapons_complainbubble_padding;
1864 drawpic_aspect_skin(wpnpos + '1 1 0' * padding, "weapon_complainbubble", wpnsize - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
1865 drawstring_aspect(wpnpos + '1 1 0' * padding, s, wpnsize - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
1881 float GetAmmoItemCode(float i)
1885 case 0: return IT_SHELLS;
1886 case 1: return IT_NAILS;
1887 case 2: return IT_ROCKETS;
1888 case 3: return IT_CELLS;
1889 case 4: return IT_FUEL;
1894 string GetAmmoPicture(float i)
1898 case 0: return "ammo_shells";
1899 case 1: return "ammo_bullets";
1900 case 2: return "ammo_rockets";
1901 case 3: return "ammo_cells";
1902 case 4: return "ammo_fuel";
1907 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1910 if(autocvar__hud_configure)
1912 currently_selected = (itemcode == 2); //rockets always selected
1913 a = 31 + mod(itemcode*93, 128);
1916 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1925 if(currently_selected)
1930 vector picpos, numpos;
1931 if(autocvar_hud_panel_ammo_iconalign)
1934 picpos = myPos + eX * 2 * mySize_y;
1938 numpos = myPos + eX * mySize_y;
1942 if (currently_selected)
1943 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1945 if(a > 0 && autocvar_hud_panel_ammo_progressbar)
1946 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);
1948 if(autocvar_hud_panel_ammo_text)
1951 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1952 else // "ghost" ammo count
1953 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1956 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1957 else // "ghost" ammo icon
1958 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1963 if(!autocvar__hud_configure)
1965 if(!autocvar_hud_panel_ammo) return;
1966 if(spectatee_status == -1) return;
1969 active_panel = HUD_PANEL_AMMO;
1970 HUD_Panel_UpdateCvars(ammo);
1973 mySize = panel_size;
1975 HUD_Panel_DrawBg(1);
1976 if(panel_bg_padding)
1978 pos += '1 1 0' * panel_bg_padding;
1979 mySize -= '2 2 0' * panel_bg_padding;
1982 float rows, columns, row, column;
1984 if (autocvar_hud_panel_ammo_onlycurrent)
1988 rows = mySize_y/mySize_x;
1989 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1990 // ^^^ ammo item aspect goes here
1992 columns = ceil(AMMO_COUNT/rows);
1994 ammo_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
1999 if(ammo_size_x/ammo_size_y > 3)
2001 newSize = 3 * ammo_size_y;
2002 offset_x = ammo_size_x - newSize;
2003 pos_x += offset_x/2;
2004 ammo_size_x = newSize;
2008 newSize = 1/3 * ammo_size_x;
2009 offset_y = ammo_size_y - newSize;
2010 pos_y += offset_y/2;
2011 ammo_size_y = newSize;
2014 drawfont = hud_bigfont;
2015 float i, stat_items, currently_selected;
2016 if (autocvar_hud_panel_ammo_onlycurrent)
2018 if(autocvar__hud_configure)
2020 DrawAmmoItem(pos, ammo_size, 2, true); //show rockets
2023 stat_items = getstati(STAT_ITEMS);
2024 for (i = 0; i < AMMO_COUNT; ++i) {
2025 currently_selected = stat_items & GetAmmoItemCode(i);
2026 if (currently_selected)
2028 DrawAmmoItem(pos, ammo_size, i, true);
2032 return; // nothing to display
2035 stat_items = getstati(STAT_ITEMS);
2036 for (i = 0; i < AMMO_COUNT; ++i) {
2037 currently_selected = stat_items & GetAmmoItemCode(i);
2038 DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected);
2043 column = column + 1;
2046 drawfont = hud_font;
2049 void DrawNumIcon(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float alpha)
2051 vector newPos, newSize;
2052 vector picpos, numpos;
2056 if(mySize_y/mySize_x > 2)
2058 newSize_y = 2 * mySize_x;
2059 newSize_x = mySize_x;
2061 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
2066 newSize_x = 1/2 * mySize_y;
2067 newSize_y = mySize_y;
2069 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
2073 if(icon_right_align)
2076 picpos = newPos + eY * newSize_x;
2081 numpos = newPos + eY * newSize_x;
2085 drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
2086 // make number smaller than icon, it looks better
2087 // reduce only y to draw numbers with different number of digits with the same y size
2088 numpos_y += newSize_y * ((1 - 0.7) / 2);
2090 drawstring_aspect(numpos, ftos(x), newSize, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
2094 if(mySize_x/mySize_y > 3)
2096 newSize_x = 3 * mySize_y;
2097 newSize_y = mySize_y;
2099 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
2104 newSize_y = 1/3 * mySize_x;
2105 newSize_x = mySize_x;
2107 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
2111 if(icon_right_align) // right align
2114 picpos = newPos + eX * 2 * newSize_y;
2118 numpos = newPos + eX * newSize_y;
2122 drawstring_aspect(numpos, ftos(x), '2 1 0' * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
2123 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
2126 void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float fadelerp)
2129 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
2131 DrawNumIcon(myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, vertical, icon_right_align, color, (1 - fadelerp));
2136 void HUD_Powerups(void) {
2137 if(!autocvar__hud_configure)
2139 if(!autocvar_hud_panel_powerups) return;
2140 if(spectatee_status == -1) return;
2141 if not(getstati(STAT_ITEMS) & (IT_STRENGTH | IT_INVINCIBLE)) return;
2142 if (getstati(STAT_HEALTH) <= 0) return;
2145 active_panel = HUD_PANEL_POWERUPS;
2146 HUD_Panel_UpdateCvars(powerups);
2149 mySize = panel_size;
2151 float strength_time, shield_time;
2152 if(autocvar__hud_configure)
2159 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
2160 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
2163 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
2164 if(panel_bg_padding)
2166 pos += '1 1 0' * panel_bg_padding;
2167 mySize -= '2 2 0' * panel_bg_padding;
2174 string leftname, rightname;
2175 string leftprogressname, rightprogressname;
2176 float leftcnt, rightcnt;
2177 float leftexact, rightexact;
2178 if (autocvar_hud_panel_powerups_flip) {
2179 leftname = "strength";
2180 leftprogressname = autocvar_hud_panel_powerups_progressbar_strength;
2181 leftcnt = ceil(strength_time);
2182 leftexact = strength_time;
2184 rightname = "shield";
2185 rightprogressname = autocvar_hud_panel_powerups_progressbar_shield;
2186 rightcnt = ceil(shield_time);
2187 rightexact = shield_time;
2189 leftname = "shield";
2190 leftprogressname = autocvar_hud_panel_powerups_progressbar_shield;
2191 leftcnt = ceil(shield_time);
2192 leftexact = shield_time;
2194 rightname = "strength";
2195 rightprogressname = autocvar_hud_panel_powerups_progressbar_strength;
2196 rightcnt = ceil(strength_time);
2197 rightexact = strength_time;
2200 drawfont = hud_bigfont;
2201 float baralign = autocvar_hud_panel_powerups_baralign;
2202 float iconalign = autocvar_hud_panel_powerups_iconalign;
2203 float progressbar = autocvar_hud_panel_powerups_progressbar;
2204 float panel_ar = mySize_x/mySize_y;
2205 float is_vertical = (panel_ar < 1);
2206 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
2208 barsize = eX * 0.5 * mySize_x + eY * mySize_y;
2213 HUD_Panel_GetProgressBarColorForString(leftname);
2214 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);
2216 if(autocvar_hud_panel_powerups_text)
2219 DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', 1);
2221 DrawNumIcon_expanding(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
2230 HUD_Panel_GetProgressBarColorForString(rightname);
2231 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);
2233 if(autocvar_hud_panel_powerups_text)
2236 DrawNumIcon(pos, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', 1);
2238 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));
2244 barsize = eX * mySize_x + eY * 0.5 * mySize_y;
2249 HUD_Panel_GetProgressBarColorForString(leftname);
2250 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);
2252 if(autocvar_hud_panel_powerups_text)
2255 DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', 1);
2257 DrawNumIcon_expanding(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
2266 HUD_Panel_GetProgressBarColorForString(rightname);
2267 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);
2269 if(autocvar_hud_panel_powerups_text)
2272 DrawNumIcon(pos, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', 1);
2274 DrawNumIcon_expanding(pos, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1));
2278 drawfont = hud_font;
2281 // Health/armor (#3)
2283 void HUD_HealthArmor(void)
2285 if(!autocvar__hud_configure)
2287 if(!autocvar_hud_panel_healtharmor) return;
2288 if(spectatee_status == -1) return;
2291 active_panel = HUD_PANEL_HEALTHARMOR;
2292 HUD_Panel_UpdateCvars(healtharmor);
2295 mySize = panel_size;
2297 HUD_Panel_DrawBg(1);
2298 if(panel_bg_padding)
2300 pos += '1 1 0' * panel_bg_padding;
2301 mySize -= '2 2 0' * panel_bg_padding;
2304 float armor, health, fuel;
2305 armor = getstati(STAT_ARMOR);
2306 health = getstati(STAT_HEALTH);
2307 fuel = getstati(STAT_FUEL);
2309 if(autocvar__hud_configure)
2320 vector picpos, numpos;
2322 drawfont = hud_bigfont;
2323 float baralign = autocvar_hud_panel_healtharmor_baralign;
2324 float iconalign = autocvar_hud_panel_healtharmor_iconalign;
2325 float progressbar = autocvar_hud_panel_healtharmor_progressbar;
2327 float maxhealth = autocvar_hud_panel_healtharmor_maxhealth;
2328 float maxarmor = autocvar_hud_panel_healtharmor_maxarmor;
2329 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
2332 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2337 float maxtotal = maxhealth + maxarmor;
2339 if(v_z) // NOT fully armored
2341 biggercount = "health";
2344 HUD_Panel_GetProgressBarColor(health);
2345 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);
2348 if(autocvar_hud_panel_healtharmor_text)
2349 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);
2353 biggercount = "armor";
2356 HUD_Panel_GetProgressBarColor(armor);
2357 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);
2360 if(autocvar_hud_panel_healtharmor_text)
2361 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);
2363 if(autocvar_hud_panel_healtharmor_text)
2364 DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, maxtotal), 1);
2368 HUD_Panel_GetProgressBarColor(fuel);
2369 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);
2374 string leftname, rightname;
2375 string leftprogressname, rightprogressname;
2376 float leftcnt, rightcnt;
2377 float leftmax, rightmax;
2378 float leftactive, rightactive;
2379 float leftalpha, rightalpha;
2380 if (autocvar_hud_panel_healtharmor_flip) { // old style layout with armor left/top of health
2382 leftprogressname = autocvar_hud_panel_healtharmor_progressbar_armor;
2386 leftalpha = min((armor+10)/55, 1);
2389 rightname = "health";
2390 rightprogressname = autocvar_hud_panel_healtharmor_progressbar_health;
2394 rightmax = maxhealth;
2396 leftname = "health";
2397 leftprogressname = autocvar_hud_panel_healtharmor_progressbar_health;
2401 leftmax = maxhealth;
2403 rightname = "armor";
2404 rightprogressname = autocvar_hud_panel_healtharmor_progressbar_armor;
2408 rightalpha = min((armor+10)/55, 1);
2409 rightmax = maxarmor;
2412 float panel_ar = mySize_x/mySize_y;
2413 float is_vertical = (panel_ar < 1);
2414 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
2416 barsize = eX * 0.5 * mySize_x + eY * mySize_y;
2421 HUD_Panel_GetProgressBarColorForString(leftname);
2422 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);
2424 if(autocvar_hud_panel_healtharmor_text)
2425 DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), HUD_Get_Num_Color(leftcnt, leftmax), 1);
2432 HUD_Panel_GetProgressBarColorForString(rightname);
2433 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);
2435 if(autocvar_hud_panel_healtharmor_text)
2436 DrawNumIcon(pos + eX * 0.5 * mySize_x, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), HUD_Get_Num_Color(rightcnt, rightmax), 1);
2441 HUD_Panel_GetProgressBarColor(fuel);
2442 if (is_vertical) //if vertical always halve x to not cover too much numbers with 3 digits
2443 mySize_x *= 0.2 * 0.5 / 2;
2446 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2451 barsize = eX * mySize_x + eY * 0.5 * mySize_y;
2456 HUD_Panel_GetProgressBarColorForString(leftname);
2457 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);
2459 if(autocvar_hud_panel_healtharmor_text)
2460 DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), HUD_Get_Num_Color(leftcnt, leftmax), 1);
2467 HUD_Panel_GetProgressBarColorForString(rightname);
2468 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);
2470 if(autocvar_hud_panel_healtharmor_text)
2471 DrawNumIcon(pos + eY * 0.5 * mySize_y, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), HUD_Get_Num_Color(rightcnt, rightmax), 1);
2476 HUD_Panel_GetProgressBarColor(fuel);
2477 if (is_vertical) //if vertical always halve x to not cover numbers with 3 digits
2478 mySize_x *= 0.2 / 2;
2480 mySize_y *= 0.2 * 0.5;
2481 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2485 drawfont = hud_font;
2488 // Notification area (#4)
2491 string Weapon_SuicideMessage(float deathtype)
2493 w_deathtype = deathtype;
2494 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2495 return w_deathtypestring;
2498 string Weapon_KillMessage(float deathtype)
2500 w_deathtype = deathtype;
2501 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2502 return w_deathtypestring;
2505 #define KN_MAX_ENTRIES 10
2507 float killnotify_times[KN_MAX_ENTRIES];
2508 float killnotify_deathtype[KN_MAX_ENTRIES];
2509 float killnotify_actiontype[KN_MAX_ENTRIES]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2510 string killnotify_attackers[KN_MAX_ENTRIES];
2511 string killnotify_victims[KN_MAX_ENTRIES];
2512 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2516 kn_index = KN_MAX_ENTRIES-1;
2517 killnotify_times[kn_index] = time;
2518 killnotify_deathtype[kn_index] = wpn;
2519 killnotify_actiontype[kn_index] = actiontype;
2520 if(killnotify_attackers[kn_index])
2521 strunzone(killnotify_attackers[kn_index]);
2522 killnotify_attackers[kn_index] = strzone(attacker);
2523 if(killnotify_victims[kn_index])
2524 strunzone(killnotify_victims[kn_index]);
2525 killnotify_victims[kn_index] = strzone(victim);
2528 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
2531 float alsoprint, gentle;
2532 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2533 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2535 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
2538 if(msg == MSG_SUICIDE) {
2539 w = DEATH_WEAPONOF(type);
2541 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2543 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
2544 } else if (type == DEATH_KILL) {
2545 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2547 print ("^1",s1, "^1 couldn't take it anymore\n");
2548 } else if (type == DEATH_ROT) {
2549 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2551 print ("^1",s1, "^1 died\n");
2552 } else if (type == DEATH_NOAMMO) {
2553 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2555 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2556 } else if (type == DEATH_CAMP) {
2557 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2559 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2560 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2561 HUD_KillNotify_Push(s1, "", 0, type);
2563 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2564 } else if (type == DEATH_CHEAT) {
2565 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2567 print ("^1",s1, "^1 unfairly eliminated themself\n");
2568 } else if (type == DEATH_FIRE) {
2569 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2571 print ("^1",s1, "^1 burned to death\n");
2572 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2573 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2575 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2578 if (stof(s2) > 2) // killcount > 2
2579 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2580 } else if(msg == MSG_KILL) {
2581 w = DEATH_WEAPONOF(type);
2583 if((w == WEP_CAMPINGRIFLE || w == WEP_MINSTANEX) && type & HITTYPE_HEADSHOT) // all headshot weapons go here
2584 HUD_KillNotify_Push(s1, s2, 1, DEATH_HEADSHOT);
2586 HUD_KillNotify_Push(s1, s2, 1, type);
2589 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
2591 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2592 HUD_KillNotify_Push(s1, s2, 1, type);
2596 print ("^1", s1, "^1 took action against a team mate\n");
2598 print ("^1", s1, "^1 mows down a team mate\n");
2601 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2603 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2605 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2607 else if (stof(s2) > 2) {
2609 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2611 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2614 else if(type == KILL_FIRST_BLOOD)
2615 print("^1",s1, "^1 drew first blood", "\n");
2616 else if (type == DEATH_TELEFRAG) {
2617 HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
2619 print ("^1",s2, "^1 tried to occupy ", s1, "^1's teleport destination space\n");
2621 print ("^1",s2, "^1 was telefragged by ", s1, "\n");
2623 else if (type == DEATH_DROWN) {
2624 HUD_KillNotify_Push(s1, s2, 1, DEATH_DROWN);
2626 print ("^1",s2, "^1 was drowned by ", s1, "\n");
2628 else if (type == DEATH_SLIME) {
2629 HUD_KillNotify_Push(s1, s2, 1, DEATH_SLIME);
2631 print ("^1",s2, "^1 was slimed by ", s1, "\n");
2633 else if (type == DEATH_LAVA) {
2634 HUD_KillNotify_Push(s1, s2, 1, DEATH_LAVA);
2636 print ("^1",s2, "^1 was cooked by ", s1, "\n");
2638 else if (type == DEATH_FALL) {
2639 HUD_KillNotify_Push(s1, s2, 1, DEATH_FALL);
2641 print ("^1",s2, "^1 was grounded by ", s1, "\n");
2643 else if (type == DEATH_SHOOTING_STAR) {
2644 HUD_KillNotify_Push(s1, s2, 1, DEATH_SHOOTING_STAR);
2646 print ("^1",s2, "^1 was shot into space by ", s1, "\n");
2648 else if (type == DEATH_SWAMP) {
2649 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2651 print ("^1",s2, "^1 was conserved by ", s1, "\n");
2653 else if (type == DEATH_HURTTRIGGER)
2655 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
2657 print("^1",s2, "^1 was thrown into a world of hurt by ", s1, "\n");
2658 } else if(type == DEATH_SBCRUSH) {
2659 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2661 print ("^1",s2, "^1 was crushed by ^1", s1, "\n");
2662 } else if(type == DEATH_SBMINIGUN) {
2663 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2665 print ("^1",s2, "^1 got shredded by ^1", s1, "\n");
2666 } else if(type == DEATH_SBROCKET) {
2667 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2669 print ("^1",s2, "^1 was blased to bits by ^1", s1, "\n");
2670 } else if(type == DEATH_SBBLOWUP) {
2671 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2673 print ("^1",s2, "^1 got caught in the destruction of ^1", s1, "'s vehicle\n");
2674 } else if(type == DEATH_WAKIGUN) {
2675 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2677 print ("^1",s2, "^1 was bolted down by ^1", s1, "\n");
2678 } else if(type == DEATH_WAKIROCKET) {
2679 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2681 print ("^1",s2, "^1 could find no shelter from ^1", s1, "'s rockets\n");
2682 } else if(type == DEATH_WAKIBLOWUP) {
2683 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2685 print ("^1",s2, "^1 dies when ^1", s1, "'s wakizashi dies.\n");
2686 } else if(type == DEATH_TURRET) {
2687 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2689 print ("^1",s2, "^1 was pushed into the line of fire by ^1", s1, "\n");
2690 } else if(type == DEATH_TOUCHEXPLODE) {
2691 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2693 print ("^1",s2, "^1 was pushed into an accident by ^1", s1, "\n");
2694 } else if(type == DEATH_CHEAT) {
2695 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2697 print ("^1",s2, "^1 was unfairly eliminated by ^1", s1, "\n");
2698 } else if (type == DEATH_FIRE) {
2699 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2701 print ("^1",s2, "^1 was burnt to death by ^1", s1, "\n");
2702 } else if (type == DEATH_CUSTOM) {
2703 HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM);
2705 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
2706 } else if (type == DEATH_HURTTRIGGER) {
2707 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
2709 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
2711 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2713 print ("^1",s2, "^1 was fragged by ", s1, "\n");
2715 } else if(msg == MSG_SPREE) {
2716 if(type == KILL_END_SPREE) {
2718 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2720 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2721 } else if(type == KILL_SPREE) {
2723 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2725 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2726 } else if(type == KILL_SPREE_3) {
2728 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2730 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2731 } else if(type == KILL_SPREE_5) {
2733 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2735 print (s1,"^7 unleashes ^1RAGE\n");
2736 } else if(type == KILL_SPREE_10) {
2738 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2740 print (s1,"^7 starts the ^1MASSACRE!\n");
2741 } else if(type == KILL_SPREE_15) {
2743 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2745 print (s1,"^7 executes ^1MAYHEM!\n");
2746 } else if(type == KILL_SPREE_20) {
2748 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2750 print (s1,"^7 is a ^1BERSERKER!\n");
2751 } else if(type == KILL_SPREE_25) {
2753 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2755 print (s1,"^7 inflicts ^1CARNAGE!\n");
2756 } else if(type == KILL_SPREE_30) {
2758 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2760 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2762 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2763 if (type == DEATH_DROWN) {
2764 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2768 print ("^1",s1, "^1 was in the water for too long\n");
2770 print ("^1",s1, "^1 drowned\n");
2772 } else if (type == DEATH_SLIME) {
2773 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2775 print ("^1",s1, "^1 was slimed\n");
2776 } else if (type == DEATH_LAVA) {
2777 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2781 print ("^1",s1, "^1 found a hot place\n");
2783 print ("^1",s1, "^1 turned into hot slag\n");
2785 } else if (type == DEATH_FALL) {
2786 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2790 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2792 print ("^1",s1, "^1 hit the ground with a crunch\n");
2794 } else if (type == DEATH_SHOOTING_STAR) {
2795 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2797 print ("^1",s1, "^1 became a shooting star\n");
2798 } else if (type == DEATH_SWAMP) {
2799 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2803 print ("^1",s1, "^1 discovered a swamp\n");
2805 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2807 } else if(type == DEATH_TURRET) {
2808 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2810 print ("^1",s1, "^1 was mowed down by a turret \n");
2811 } else if (type == DEATH_CUSTOM) {
2812 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2814 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
2815 } else if (type == DEATH_HURTTRIGGER) {
2816 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2818 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
2819 } else if(type == DEATH_TOUCHEXPLODE) {
2820 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2822 print ("^1",s1, "^1 died in an accident\n");
2823 } else if(type == DEATH_CHEAT) {
2824 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2826 print ("^1",s1, "^1 was unfairly eliminated\n");
2827 } else if(type == DEATH_FIRE) {
2828 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2832 print ("^1",s1, "^1 felt a little hot\n");
2834 print ("^1",s1, "^1 burnt to death\n");
2837 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2841 print ("^1",s1, "^1 needs a restart\n");
2843 print ("^1",s1, "^1 died\n");
2846 } else if(msg == MSG_KILL_ACTION_SPREE) {
2848 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2850 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2851 } else if(msg == MSG_INFO) {
2852 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2853 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2854 print(s1, "^7 got the ", s2, "\n");
2855 } else if(type == INFO_LOSTFLAG) {
2856 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2857 print(s1, "^7 lost the ", s2, "\n");
2858 } else if(type == INFO_PICKUPFLAG) {
2859 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2860 print(s1, "^7 picked up the ", s2, "\n");
2861 } else if(type == INFO_RETURNFLAG) {
2862 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2863 print(s1, "^7 returned the ", s2, "\n");
2864 } else if(type == INFO_CAPTUREFLAG) {
2865 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
2866 print(s1, "^7 captured the ", s2, s3, "\n");
2868 } else if(msg == MSG_RACE) {
2869 if(type == RACE_SERVER_RECORD) {
2870 HUD_KillNotify_Push(s1, s2, 1, RACE_SERVER_RECORD);
2872 else if(type == RACE_NEW_RANK) {
2873 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_RANK);
2875 else if(type == RACE_NEW_TIME) {
2876 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_TIME);
2878 else if(type == RACE_FAIL) {
2879 HUD_KillNotify_Push(s1, s2, 1, RACE_FAIL);
2881 } else if(msg == MSG_KA) {
2882 if(type == KA_PICKUPBALL) {
2883 HUD_KillNotify_Push(s1, s2, 0, KA_PICKUPBALL);
2885 print (s1, "^7 has picked up the ball!\n");
2887 else if(type == KA_DROPBALL) {
2888 HUD_KillNotify_Push(s1, s2, 0, KA_DROPBALL);
2890 print(s1, "^7 has dropped the ball!\n");
2895 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2897 void HUD_Centerprint(string s1, string s2, float type, float msg)
2900 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2901 if(msg == MSG_SUICIDE) {
2902 if (type == DEATH_TEAMCHANGE) {
2903 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2904 } else if (type == DEATH_AUTOTEAMCHANGE) {
2905 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2906 } else if (type == DEATH_CAMP) {
2908 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2910 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2911 } else if (type == DEATH_NOAMMO) {
2913 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2915 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2916 } else if (type == DEATH_ROT) {
2918 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2920 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2921 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2923 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2925 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2926 } else if (type == DEATH_QUIET) {
2928 } else { // generic message
2930 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2932 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2934 } else if(msg == MSG_KILL) {
2935 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2937 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2939 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2941 } else if (type == KILL_FIRST_BLOOD) {
2943 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2945 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2947 } else if (type == KILL_FIRST_VICTIM) {
2949 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2951 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2953 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2955 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2957 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2959 } else if (type == KILL_TYPEFRAGGED) {
2961 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2963 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2965 } else if (type == KILL_FRAG) {
2967 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2969 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2971 } else { // generic message
2973 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2975 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2978 } else if(msg == MSG_KILL_ACTION) {
2979 // TODO: invent more centerprints here?
2980 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2984 void HUD_Notify (void)
2986 if(!autocvar_hud_panel_notify && !autocvar__hud_configure)
2989 active_panel = HUD_PANEL_NOTIFY;
2990 HUD_Panel_UpdateCvars(notify);
2993 mySize = panel_size;
2995 HUD_Panel_DrawBg(1);
2996 if(panel_bg_padding)
2998 pos += '1 1 0' * panel_bg_padding;
2999 mySize -= '2 2 0' * panel_bg_padding;
3002 float entries, height;
3003 entries = bound(1, floor(KN_MAX_ENTRIES * mySize_y/mySize_x), KN_MAX_ENTRIES);
3004 height = mySize_y/entries;
3007 fontsize = '0.5 0.5 0' * height;
3011 when = autocvar_hud_panel_notify_time;
3013 fadetime = autocvar_hud_panel_notify_fadetime;
3017 vector pos_attacker, pos_victim;
3019 float width_attacker;
3020 string attacker, victim;
3022 float i, j, w, step, limit;
3023 if(autocvar_hud_panel_notify_flip) //order items from the top down
3029 else //order items from the bottom up
3036 for(j = kn_index; i != limit; i += step, ++j)
3038 if(autocvar__hud_configure)
3042 else // inverse order
3043 a = entries - 1 - i;
3044 attacker = textShortenToWidth(strcat("Player", ftos(a+1)), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3045 victim = textShortenToWidth(strcat("Player", ftos(a+2)), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3046 s = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname);
3047 a = bound(0, (when - a) / 4, 1);
3048 goto hud_config_notifyprint;
3051 if (j == KN_MAX_ENTRIES)
3054 if(killnotify_times[j] + when > time)
3058 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
3072 w = DEATH_WEAPONOF(killnotify_deathtype[j]);
3074 // TODO: maybe print in team colors?
3077 if(killnotify_actiontype[j] == 0)
3079 if(killnotify_deathtype[j] == DEATH_GENERIC)
3083 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
3085 s = "notify_outofammo";
3087 else if(killnotify_deathtype[j] == DEATH_KILL)
3089 s = "notify_selfkill";
3091 else if(killnotify_deathtype[j] == DEATH_CAMP)
3093 s = "notify_camping";
3095 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
3097 s = "notify_teamkill_red";
3099 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
3101 s = "notify_teamkill_blue";
3103 else if(killnotify_deathtype[j] == DEATH_DROWN)
3107 else if(killnotify_deathtype[j] == DEATH_SLIME)
3111 else if(killnotify_deathtype[j] == DEATH_LAVA)
3115 else if(killnotify_deathtype[j] == DEATH_FALL)
3119 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
3121 s = "notify_shootingstar";
3123 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
3127 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
3129 if(killnotify_victims[j] == "^1RED^7 flag")
3131 s = "notify_red_taken";
3135 s = "notify_blue_taken";
3138 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
3140 if(killnotify_victims[j] == "^1RED^7 flag")
3142 s = "notify_red_returned";
3146 s = "notify_blue_returned";
3149 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
3151 if(killnotify_victims[j] == "^1RED^7 flag")
3153 s = "notify_red_lost";
3157 s = "notify_blue_lost";
3160 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
3162 if(killnotify_victims[j] == "^1RED^7 flag")
3164 s = "notify_red_captured";
3168 s = "notify_blue_captured";
3171 else if(killnotify_deathtype[j] == KA_DROPBALL)
3173 s = "notify_balldropped";
3175 else if(killnotify_deathtype[j] == KA_PICKUPBALL)
3177 s = "notify_ballpickedup";
3180 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3181 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
3182 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
3186 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3187 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3190 // X [did action to] Y
3193 if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
3195 s = "notify_melee_laser";
3197 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_SHOTGUN)
3199 s = "notify_melee_shotgun";
3201 else if(WEP_VALID(w))
3203 self = get_weaponinfo(w);
3204 s = strcat("weapon", self.netname);
3206 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
3208 s = "notify_teamkill_red";
3210 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
3212 s = "notify_teamkill_red";
3214 else if(killnotify_deathtype[j] == DEATH_TELEFRAG)
3216 s = "notify_telefrag";
3218 else if(killnotify_deathtype[j] == DEATH_DROWN)
3222 else if(killnotify_deathtype[j] == DEATH_SLIME)
3226 else if(killnotify_deathtype[j] == DEATH_LAVA)
3230 else if(killnotify_deathtype[j] == DEATH_FALL)
3234 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
3236 s = "notify_shootingstar";
3238 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
3242 else if(killnotify_deathtype[j] == DEATH_HEADSHOT)
3244 s = "notify_headshot";
3246 else if(killnotify_deathtype[j] == RACE_SERVER_RECORD)
3248 s = "race_newrecordserver";
3250 else if(killnotify_deathtype[j] == RACE_NEW_RANK)
3252 s = "race_newrankyellow";
3254 else if(killnotify_deathtype[j] == RACE_NEW_TIME)
3258 else if(killnotify_deathtype[j] == RACE_FAIL)
3263 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3264 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3265 :hud_config_notifyprint
3266 width_attacker = stringwidth(attacker, TRUE, fontsize);
3267 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
3268 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
3269 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
3273 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3274 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3275 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3284 string seconds_tostring(float sec)
3287 minutes = floor(sec / 60);
3289 sec -= minutes * 60;
3292 s = ftos(100 + sec);
3294 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3297 void HUD_Timer(void)
3299 if(!autocvar_hud_panel_timer && !autocvar__hud_configure)
3302 active_panel = HUD_PANEL_TIMER;
3303 HUD_Panel_UpdateCvars(timer);
3306 mySize = panel_size;
3308 HUD_Panel_DrawBg(1);
3309 if(panel_bg_padding)
3311 pos += '1 1 0' * panel_bg_padding;
3312 mySize -= '2 2 0' * panel_bg_padding;
3316 float timelimit, elapsedTime, timeleft, minutesLeft;
3318 timelimit = getstatf(STAT_TIMELIMIT);
3320 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3321 timeleft = ceil(timeleft);
3323 minutesLeft = floor(timeleft / 60);
3326 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3327 timer_color = '1 1 1'; //white
3328 else if(minutesLeft >= 1)
3329 timer_color = '1 1 0'; //yellow
3331 timer_color = '1 0 0'; //red
3333 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
3334 if (time < getstatf(STAT_GAMESTARTTIME)) {
3335 //while restart is still active, show 00:00
3336 timer = seconds_tostring(0);
3338 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3339 timer = seconds_tostring(elapsedTime);
3342 timer = seconds_tostring(timeleft);
3345 drawfont = hud_bigfont;
3346 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3347 drawfont = hud_font;
3352 void HUD_Radar(void)
3354 if ((autocvar_hud_panel_radar == 0 || (autocvar_hud_panel_radar != 2 && !teamplay)) && !autocvar__hud_configure)
3357 active_panel = HUD_PANEL_RADAR;
3358 HUD_Panel_UpdateCvars(radar);
3361 mySize = panel_size;
3363 HUD_Panel_DrawBg(1);
3364 if(panel_bg_padding)
3366 pos += '1 1 0' * panel_bg_padding;
3367 mySize -= '2 2 0' * panel_bg_padding;
3372 float scale2d, normalsize, bigsize;
3375 teamradar_origin2d = pos + 0.5 * mySize;
3376 teamradar_size2d = mySize;
3378 if(minimapname == "")
3381 teamradar_loadcvars();
3383 switch(hud_panel_radar_zoommode)
3387 f = current_zoomfraction;
3390 f = 1 - current_zoomfraction;
3400 switch(hud_panel_radar_rotation)
3403 teamradar_angle = view_angles_y - 90;
3406 teamradar_angle = 90 * hud_panel_radar_rotation;
3410 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3411 teamradar_size2d = mySize;
3413 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3415 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3416 if(hud_panel_radar_rotation == 0)
3418 // max-min distance must fit the radar in any rotation
3419 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3423 vector c0, c1, c2, c3, span;
3424 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3425 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3426 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3427 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3429 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3430 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3432 // max-min distance must fit the radar in x=x, y=y
3434 teamradar_size2d_x * scale2d / (1.05 * span_x),
3435 teamradar_size2d_y * scale2d / (1.05 * span_y)
3439 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
3440 if(bigsize > normalsize)
3441 normalsize = bigsize;
3445 + (1 - f) * normalsize;
3446 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3447 f * (mi_min + mi_max) * 0.5
3448 + (1 - f) * view_origin);
3457 draw_teamradar_background(hud_panel_radar_foreground_alpha);
3459 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3460 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3461 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3462 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3463 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3465 color2 = GetPlayerColor(tm.sv_entnum);
3466 //if(color == COLOR_SPECTATOR || color == color2)
3467 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3469 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3471 drawresetcliparea();
3476 void HUD_UpdatePlayerTeams();
3477 void HUD_Score(void)
3479 if(!autocvar__hud_configure && !autocvar_hud_panel_score)
3482 active_panel = HUD_PANEL_SCORE;
3483 HUD_Panel_UpdateCvars(score);
3486 mySize = panel_size;
3488 HUD_Panel_DrawBg(1);
3489 if(panel_bg_padding)
3491 pos += '1 1 0' * panel_bg_padding;
3492 mySize -= '2 2 0' * panel_bg_padding;
3495 float score, distribution;
3497 vector distribution_color;
3499 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3501 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3502 string timer, distrtimer;
3504 pl = players.sort_next;
3507 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3508 if(pl.scores[ps_primary] == 0)
3511 score = me.(scores[ps_primary]);
3512 timer = TIME_ENCODED_TOSTRING(score);
3514 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3515 // distribution display
3516 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3518 distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS);
3520 if (distribution <= 0) {
3521 distribution_color = '0 1 0';
3525 distribution_color = '1 0 0';
3528 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);
3530 // race record display
3531 if (distribution <= 0)
3532 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3533 drawfont = hud_bigfont;
3534 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3535 drawfont = hud_font;
3536 } else if (!teamplay) { // non-teamgames
3537 if ((spectatee_status == -1 && !autocvar__hud_configure) || cvar("hud_panel_score_rankings"))
3539 #define SCOREPANEL_MAX_ENTRIES 6
3540 #define SCOREPANEL_ASPECTRATIO 2
3541 float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
3542 float height = mySize_y/entries;
3543 vector fontsize = '0.9 0.9 0' * height;
3544 pos_y += height * (1 - 0.9) / 2;
3549 float name_size = mySize_x*0.75;
3550 float i, me_printed;
3552 if (autocvar__hud_configure)
3554 score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
3555 for (i=0; i<entries; ++i)
3557 //simulate my score is lower than all displayed players,
3558 //so that I don't appear at all showing pure rankings.
3559 //This is to better show the difference between the 2 ranking views
3560 if (i == entries-1 && cvar("hud_panel_score_rankings") == 1)
3563 drawfill(pos - eY * (height * (1 - 0.9) / 2), eX * mySize_x + eY * height, rgb, 0.3 * panel_fg_alpha, DRAWFLAG_NORMAL);
3564 s = GetPlayerName(pl.sv_entnum);
3569 s = strcat("Player", ftos(i+1));
3573 s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
3574 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3575 drawstring(pos + eX * mySize_x*0.79, ftos(score), fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3581 if (!scoreboard_fade_alpha) // the scoreboard too calls HUD_UpdatePlayerTeams
3582 HUD_UpdatePlayerTeams();
3584 for (pl = players.sort_next, i=0; pl && i<entries; pl = pl.sort_next, ++i)
3586 if (pl.team == COLOR_SPECTATOR)
3589 if (i == entries-1 && !me_printed && pl != me)
3590 if (cvar("hud_panel_score_rankings") == 1 && spectatee_status != -1)
3592 for (pl = me.sort_next; pl; pl = pl.sort_next)
3593 if (pl.team != COLOR_SPECTATOR)
3597 rgb = '1 1 0'; //not last but not among the leading players: yellow
3599 rgb = '1 0 0'; //last: red
3606 rgb = '0 1 0'; //first: green
3608 drawfill(pos - eY * (height * (1 - 0.9) / 2), eX * mySize_x + eY * height, rgb, 0.3 * panel_fg_alpha, DRAWFLAG_NORMAL);
3610 s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
3611 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3612 drawstring(pos + eX * mySize_x*0.79, ftos(pl.(scores[ps_primary])), fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3617 // me vector := [team/connected frags id]
3618 pl = players.sort_next;
3622 if(autocvar__hud_configure)
3625 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3629 score = me.(scores[ps_primary]);
3630 if(autocvar__hud_configure)
3633 if(distribution >= 5)
3634 distribution_color = eY;
3635 else if(distribution >= 0)
3636 distribution_color = '1 1 1';
3637 else if(distribution >= -5)
3638 distribution_color = '1 1 0';
3640 distribution_color = eX;
3642 string distribution_str;
3643 distribution_str = ftos(distribution);
3644 if (distribution >= 0)
3646 if (distribution > 0)
3647 distribution_str = strcat("+", distribution_str);
3648 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3650 drawfont = hud_bigfont;
3651 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3652 drawfont = hud_font;
3653 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);
3654 } else { // teamgames
3655 float max_fragcount;
3656 max_fragcount = -99;
3658 float scores_count, row, column, rows, columns;
3660 vector score_pos, score_size; //for scores other than myteam
3661 if (spectatee_status == -1)
3663 if (autocvar__hud_configure)
3665 else for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3666 if(tm.team == COLOR_SPECTATOR)
3670 rows = mySize_y/mySize_x;
3671 rows = bound(1, floor((sqrt(4 * (3/1) * rows * scores_count + rows * rows) + rows + 0.5) / 2), scores_count);
3672 // ^^^ ammo item aspect goes here
3674 columns = ceil(scores_count/rows);
3676 score_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
3679 if(score_size_x/score_size_y > 3)
3681 newSize = 3 * score_size_y;
3682 offset_x = score_size_x - newSize;
3683 pos_x += offset_x/2;
3684 score_size_x = newSize;
3688 newSize = 1/3 * score_size_x;
3689 offset_y = score_size_y - newSize;
3690 pos_y += offset_y/2;
3691 score_size_y = newSize;
3695 score_size = eX * mySize_x*(1/4) + eY * mySize_y*(1/3);
3696 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3697 if(tm.team == COLOR_SPECTATOR)
3699 score = tm.(teamscores[ts_primary]);
3700 if(autocvar__hud_configure)
3703 if (score > max_fragcount)
3704 max_fragcount = score;
3706 if (spectatee_status == -1)
3708 score_pos = pos + eX * column * (score_size_x + offset_x) + eY * row * (score_size_y + offset_y);
3709 if (max_fragcount == score)
3710 HUD_Panel_DrawHighlight(score_pos, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3711 drawfont = hud_bigfont;
3712 drawstring_aspect(score_pos, ftos(score), score_size, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3713 drawfont = hud_font;
3721 else if(tm.team == myteam) {
3722 if (max_fragcount == score)
3723 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3724 drawfont = hud_bigfont;
3725 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3726 drawfont = hud_font;
3728 if (max_fragcount == score)
3729 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);
3730 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);
3739 void HUD_RaceTimer (void) {
3740 if(!autocvar__hud_configure)
3742 if(!autocvar_hud_panel_racetimer) return;
3743 if(!(gametype == GAME_RACE || gametype == GAME_CTS)) return;
3744 if(spectatee_status == -1) return;
3747 active_panel = HUD_PANEL_RACETIMER;
3748 HUD_Panel_UpdateCvars(racetimer);
3751 mySize = panel_size;
3753 HUD_Panel_DrawBg(1);
3754 if(panel_bg_padding)
3756 pos += '1 1 0' * panel_bg_padding;
3757 mySize -= '2 2 0' * panel_bg_padding;
3760 // always force 4:1 aspect
3762 if(mySize_x/mySize_y > 4)
3764 newSize_x = 4 * mySize_y;
3765 newSize_y = mySize_y;
3767 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3771 newSize_y = 1/4 * mySize_x;
3772 newSize_x = mySize_x;
3774 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3778 drawfont = hud_bigfont;
3780 string s, forcetime;
3782 if(autocvar__hud_configure)
3785 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);
3786 s = "^1Intermediate 1 (+15.42)";
3787 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);
3788 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3789 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);
3791 else if(race_checkpointtime)
3793 a = bound(0, 2 - (time - race_checkpointtime), 1);
3796 if(a > 0) // just hit a checkpoint?
3798 if(race_checkpoint != 254)
3800 if(race_time && race_previousbesttime)
3801 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3803 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3805 forcetime = TIME_ENCODED_TOSTRING(race_time);
3810 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3812 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3813 if(a > 0) // next one?
3815 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3820 if(s != "" && a > 0)
3822 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);
3825 if(race_penaltytime)
3827 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3830 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3831 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);
3837 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3838 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);
3843 if(race_laptime && race_checkpoint != 255)
3845 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3846 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);
3851 if(race_mycheckpointtime)
3853 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3854 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3855 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);
3857 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3859 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3860 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3861 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);
3864 if(race_penaltytime && !race_penaltyaccumulator)
3866 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3867 a = bound(0, (1 + t - time), 1);
3871 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3873 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3874 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);
3879 drawfont = hud_font;
3884 float vote_yescount;
3887 float vote_highlighted; // currently selected vote
3889 float vote_active; // is there an active vote?
3890 float vote_prev; // previous state of vote_active to check for a change
3892 float vote_change; // "time" when vote_active changed
3894 void HUD_VoteWindow(void)
3896 uid2name_dialog = 0;
3897 if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
3900 vote_called_vote = strzone(strcat("^2Name ^7instead of \"^1Unregistered player\"", " ^7in stats"));
3901 uid2name_dialog = 1;
3904 if(!autocvar_hud_panel_vote && !autocvar__hud_configure)
3907 if(!autocvar__hud_configure)
3909 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
3910 panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha;
3912 if(panel_bg_alpha_str == "") {
3913 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
3915 panel_bg_alpha = stof(panel_bg_alpha_str);
3920 if(vote_active != vote_prev) {
3922 vote_prev = vote_active;
3925 if(vote_active || autocvar__hud_configure)
3926 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3928 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3930 if(autocvar__hud_configure)
3940 active_panel = HUD_PANEL_VOTE;
3941 HUD_Panel_UpdateCvars(vote);
3945 panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight;
3946 panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight;
3949 // these must be below above block
3952 mySize = panel_size;
3954 a = vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3955 HUD_Panel_DrawBg(a);
3956 a = panel_fg_alpha * a;
3958 if(panel_bg_padding)
3960 pos += '1 1 0' * panel_bg_padding;
3961 mySize -= '2 2 0' * panel_bg_padding;
3964 // always force 3:1 aspect
3966 if(mySize_x/mySize_y > 3)
3968 newSize_x = 3 * mySize_y;
3969 newSize_y = mySize_y;
3971 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3975 newSize_y = 1/3 * mySize_x;
3976 newSize_x = mySize_x;
3978 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3982 s = "A vote has been called for:";
3984 s = "Allow servers to store and display your name?";
3985 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3986 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1/8), stringwidth_colors);
3987 if(autocvar__hud_configure)
3988 s = "^1Configure the HUD";
3989 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
3991 // print the yes/no counts
3992 s = strcat("Yes (", getcommandkey("vyes", "vyes"), "): ", ftos(vote_yescount));
3993 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);
3994 s = strcat("No (", getcommandkey("vno", "vno"), "): ", ftos(vote_nocount));
3995 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);
3997 // draw the progress bar backgrounds
3998 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
4000 // draw the highlights
4001 if(vote_highlighted == 1) {
4002 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
4003 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
4005 else if(vote_highlighted == 2) {
4006 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
4007 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
4010 // draw the progress bars
4011 if(vote_yescount && vote_needed)
4013 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
4014 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
4017 if(vote_nocount && vote_needed)
4019 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
4020 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
4023 drawresetcliparea();
4026 vote_highlighted = 0;
4030 // Mod icons panel (#10)
4033 float mod_active; // is there any active mod icon?
4035 // Clan Arena HUD modicons
4036 void HUD_Mod_CA(vector pos, vector mySize)
4038 mod_active = 1; // CA should never hide the mod icons panel
4039 float redalive, bluealive;
4040 redalive = getstati(STAT_REDALIVE);
4041 bluealive = getstati(STAT_BLUEALIVE);
4043 drawfont = hud_bigfont;
4044 vector redpos, bluepos;
4045 if(mySize_x > mySize_y)
4048 bluepos = pos + eY * 0.5 * mySize_y;
4049 drawpic_aspect_skin(redpos, "player_red.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4050 drawstring_aspect(redpos + eX * 0.5 * mySize_x, ftos(redalive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4051 drawpic_aspect_skin(bluepos, "player_blue.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4052 drawstring_aspect(bluepos + eX * 0.5 * mySize_x, ftos(bluealive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4057 bluepos = pos + eY * 0.5 * mySize_y;
4058 drawpic_aspect_skin(redpos, "player_red.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4059 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);
4060 drawpic_aspect_skin(bluepos, "player_blue.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4061 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);
4063 drawfont = hud_font;
4066 // CTF HUD modicon section
4067 float redflag_prevframe, blueflag_prevframe; // status during previous frame
4068 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
4069 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
4071 void HUD_Mod_CTF_Reset(void)
4073 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
4076 void HUD_Mod_CTF(vector pos, vector mySize)
4078 vector redflag_pos, blueflag_pos;
4080 float f; // every function should have that
4082 float redflag, blueflag; // current status
4083 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
4086 stat_items = getstati(STAT_ITEMS);
4087 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
4088 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
4090 if(redflag || blueflag)
4095 if(autocvar__hud_configure)
4101 // when status CHANGES, set old status into prevstatus and current status into status
4102 if (redflag != redflag_prevframe)
4104 redflag_statuschange_time = time;
4105 redflag_prevstatus = redflag_prevframe;
4106 redflag_prevframe = redflag;
4109 if (blueflag != blueflag_prevframe)
4111 blueflag_statuschange_time = time;
4112 blueflag_prevstatus = blueflag_prevframe;
4113 blueflag_prevframe = blueflag;
4116 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
4117 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
4119 float BLINK_FACTOR = 0.15;
4120 float BLINK_BASE = 0.85;
4122 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
4124 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
4126 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
4128 string red_icon, red_icon_prevstatus;
4129 float red_alpha, red_alpha_prevstatus;
4130 red_alpha = red_alpha_prevstatus = 1;
4132 case 1: red_icon = "flag_red_taken"; break;
4133 case 2: red_icon = "flag_red_lost"; break;
4134 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4136 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
4137 red_icon = "flag_red_shielded";
4139 red_icon = string_null;
4142 switch(redflag_prevstatus) {
4143 case 1: red_icon_prevstatus = "flag_red_taken"; break;
4144 case 2: red_icon_prevstatus = "flag_red_lost"; break;
4145 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4148 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
4149 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
4150 red_icon_prevstatus = "flag_red_shielded";
4152 red_icon_prevstatus = string_null;
4156 string blue_icon, blue_icon_prevstatus;
4157 float blue_alpha, blue_alpha_prevstatus;
4158 blue_alpha = blue_alpha_prevstatus = 1;
4160 case 1: blue_icon = "flag_blue_taken"; break;
4161 case 2: blue_icon = "flag_blue_lost"; break;
4162 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4164 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
4165 blue_icon = "flag_blue_shielded";
4167 blue_icon = string_null;
4170 switch(blueflag_prevstatus) {
4171 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
4172 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
4173 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4176 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
4177 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
4178 blue_icon_prevstatus = "flag_blue_shielded";
4180 blue_icon_prevstatus = string_null;
4184 if(mySize_x > mySize_y) {
4185 if (myteam == COLOR_TEAM1) { // always draw own flag on left
4187 blueflag_pos = pos + eX * 0.5 * mySize_x;
4190 redflag_pos = pos + eX * 0.5 * mySize_x;
4192 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
4194 if (myteam == COLOR_TEAM1) { // always draw own flag on left
4196 blueflag_pos = pos + eY * 0.5 * mySize_y;
4199 redflag_pos = pos + eY * 0.5 * mySize_y;
4201 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
4204 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
4205 if(red_icon_prevstatus && f < 1)
4206 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
4208 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
4210 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
4211 if(blue_icon_prevstatus && f < 1)
4212 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
4214 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
4217 // Keyhunt HUD modicon section
4218 float kh_runheretime;
4220 void HUD_Mod_KH_Reset(void)
4225 void HUD_Mod_KH(vector pos, vector mySize)
4227 mod_active = 1; // keyhunt should never hide the mod icons panel
4231 vector p, pa, kh_size, kh_asize;
4233 kh_keys = getstati(STAT_KH_KEYS);
4236 if(mySize_x > mySize_y)
4238 p_y = pos_y + 0.25 * mySize_y;
4239 pa = p - eY * 0.25 * mySize_y;
4241 kh_size_x = mySize_x * 0.25;
4242 kh_size_y = 0.75 * mySize_y;
4243 kh_asize_x = mySize_x * 0.25;
4244 kh_asize_y = mySize_y * 0.25;
4248 p_y = pos_y + 0.125 * mySize_y;
4249 pa = p - eY * 0.125 * mySize_y;
4251 kh_size_x = mySize_x * 0.5;
4252 kh_size_y = 0.375 * mySize_y;
4253 kh_asize_x = mySize_x * 0.5;
4254 kh_asize_y = mySize_y * 0.125;
4261 for(i = 0; i < 4; ++i)
4263 key = floor(kh_keys / pow(32, i)) & 31;
4265 if(keyteam == 30 && keycount <= 4)
4267 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
4271 // this yields 8 exactly if "RUN HERE" shows
4276 kh_runheretime = time;
4277 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
4282 for(i = 0; i < 4; ++i)
4284 key = floor(kh_keys / pow(32, i)) & 31;
4297 default: // owned or dropped
4302 a = a * panel_fg_alpha;
4303 aa = aa * panel_fg_alpha;
4309 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4312 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4315 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4318 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4323 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
4326 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4329 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4332 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4335 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4339 if(mySize_x > mySize_y)
4341 p_x += 0.25 * mySize_x;
4342 pa_x += 0.25 * mySize_x;
4348 p_y = pos_y + 0.625 * mySize_y;
4349 pa_y = pos_y + 0.5 * mySize_y;
4355 p_x += 0.5 * mySize_x;
4356 pa_x += 0.5 * mySize_x;
4362 // Keepaway HUD mod icon
4363 float kaball_prevstatus; // last remembered status
4364 float kaball_statuschange_time; // time when the status changed
4366 // we don't need to reset for keepaway since it immediately
4367 // autocorrects prevstatus as to if the player has the ball or not
4369 void HUD_Mod_Keepaway(vector pos, vector mySize)
4371 mod_active = 1; // keepaway should always show the mod HUD
4373 float BLINK_FACTOR = 0.15;
4374 float BLINK_BASE = 0.85;
4375 float BLINK_FREQ = 5;
4376 float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
4378 float stat_items = getstati(STAT_ITEMS);
4379 float kaball = (stat_items/IT_KEY1) & 1;
4381 if(kaball != kaball_prevstatus)
4383 kaball_statuschange_time = time;
4384 kaball_prevstatus = kaball;
4387 // todo: Fix the sizing with the expanding image
4389 float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
4390 float f = bound(0, kaball_statuschange_elapsedtime*2, 1);
4392 if(kaball_prevstatus && f < 1)
4393 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);
4396 drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
4400 // Nexball HUD mod icon
4401 void HUD_Mod_NexBall(vector pos, vector mySize)
4403 float stat_items, nb_pb_starttime, dt, p;
4405 stat_items = getstati(STAT_ITEMS);
4406 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
4408 if (stat_items & IT_KEY1)
4413 //Manage the progress bar if any
4414 if (nb_pb_starttime > 0)
4416 dt = mod(time - nb_pb_starttime, nb_pb_period);
4417 // one period of positive triangle
4418 p = 2 * dt / nb_pb_period;
4423 HUD_Panel_GetProgressBarColor(nexball);
4424 if(mySize_x > mySize_y)
4425 HUD_Panel_DrawProgressBar(pos, mySize, "statusbar", p, 0, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4427 HUD_Panel_DrawProgressBar(pos, mySize, "statusbar", p, 1, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4430 if (stat_items & IT_KEY1)
4431 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4434 // Race/CTS HUD mod icons
4435 float crecordtime_prev; // last remembered crecordtime
4436 float crecordtime_change_time; // time when crecordtime last changed
4437 float srecordtime_prev; // last remembered srecordtime
4438 float srecordtime_change_time; // time when srecordtime last changed
4440 float race_status_time;
4441 float race_status_prev;
4442 string race_status_name_prev;
4443 void HUD_Mod_Race(vector pos, vector mySize)
4445 mod_active = 1; // race should never hide the mod icons panel
4447 me = playerslots[player_localentnum - 1];
4449 float f; // yet another function has this
4450 score = me.(scores[ps_primary]);
4452 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
4453 return; // no records in the actual race
4455 drawfont = hud_bigfont;
4457 // clientside personal record
4459 if(gametype == GAME_CTS)
4463 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4465 if(score && (score < t || !t)) {
4466 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4467 if(autocvar_cl_autodemo_delete_keeprecords)
4469 f = autocvar_cl_autodemo_delete;
4471 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4475 if(t != crecordtime_prev) {
4476 crecordtime_prev = t;
4477 crecordtime_change_time = time;
4480 vector textPos, medalPos;
4482 if(mySize_x > mySize_y) {
4483 // text on left side
4484 squareSize = min(mySize_y, mySize_x/2);
4485 textPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eY * 0.5 * (mySize_y - squareSize);
4486 medalPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eX * 0.5 * mySize_x + eY * 0.5 * (mySize_y - squareSize);
4489 squareSize = min(mySize_x, mySize_y/2);
4490 textPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eX * 0.5 * (mySize_x - squareSize);
4491 medalPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eY * 0.5 * mySize_y + eX * 0.5 * (mySize_x - squareSize);
4494 f = time - crecordtime_change_time;
4497 drawstring_aspect(textPos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4498 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);
4500 drawstring_aspect(textPos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4501 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);
4502 drawstring_aspect_expanding(pos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4503 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);
4507 t = race_server_record;
4508 if(t != srecordtime_prev) {
4509 srecordtime_prev = t;
4510 srecordtime_change_time = time;
4512 f = time - srecordtime_change_time;
4515 drawstring_aspect(textPos + eY * 0.5 * squareSize, "Server best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4516 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);
4518 drawstring_aspect(textPos + eY * 0.5 * squareSize, "Server best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4519 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);
4520 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);
4521 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);
4524 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4525 race_status_time = time + 5;
4526 race_status_prev = race_status;
4527 if (race_status_name_prev)
4528 strunzone(race_status_name_prev);
4529 race_status_name_prev = strzone(race_status_name);
4534 a = bound(0, race_status_time - time, 1);
4537 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
4541 rank = race_CheckName(race_status_name);
4543 rankname = race_PlaceName(rank);
4546 namepos = medalPos + '0 0.8 0' * squareSize;
4548 rankpos = medalPos + '0 0.15 0' * squareSize;
4550 if(race_status == 0)
4551 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4552 else if(race_status == 1) {
4553 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);
4554 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4555 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4556 } else if(race_status == 2) {
4557 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4558 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);
4560 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);
4561 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4562 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4563 } else if(race_status == 3) {
4564 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);
4565 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4566 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4569 if (race_status_time - time <= 0) {
4570 race_status_prev = -1;
4572 if(race_status_name)
4573 strunzone(race_status_name);
4574 race_status_name = string_null;
4575 if(race_status_name_prev)
4576 strunzone(race_status_name_prev);
4577 race_status_name_prev = string_null;
4579 drawfont = hud_font;
4582 float mod_prev; // previous state of mod_active to check for a change
4584 float mod_change; // "time" when mod_active changed
4586 void HUD_ModIcons(void)
4588 if(!autocvar_hud_panel_modicons && !autocvar__hud_configure)
4591 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && gametype != GAME_CA && gametype != GAME_FREEZETAG && gametype != GAME_KEEPAWAY && !autocvar__hud_configure)
4594 active_panel = HUD_PANEL_MODICONS;
4595 HUD_Panel_UpdateCvars(modicons);
4598 mySize = panel_size;
4600 if(mod_active != mod_prev) {
4602 mod_prev = mod_active;
4605 if(mod_active || autocvar__hud_configure)
4606 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4608 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4611 HUD_Panel_DrawBg(mod_alpha);
4613 if(panel_bg_padding)
4615 pos += '1 1 0' * panel_bg_padding;
4616 mySize -= '2 2 0' * panel_bg_padding;
4619 // these MUST be ran in order to update mod_active
4620 if(gametype == GAME_KEYHUNT)
4621 HUD_Mod_KH(pos, mySize);
4622 else if(gametype == GAME_CTF || autocvar__hud_configure)
4623 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4624 else if(gametype == GAME_NEXBALL)
4625 HUD_Mod_NexBall(pos, mySize);
4626 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4627 HUD_Mod_Race(pos, mySize);
4628 else if(gametype == GAME_CA || gametype == GAME_FREEZETAG)
4629 HUD_Mod_CA(pos, mySize);
4630 else if(gametype == GAME_KEEPAWAY)
4631 HUD_Mod_Keepaway(pos, mySize);
4634 // Draw pressed keys (#11)
4636 void HUD_DrawPressedKeys(void)
4638 if(!autocvar_hud_panel_pressedkeys && !autocvar__hud_configure)
4641 if(!(spectatee_status > 0 || autocvar_hud_panel_pressedkeys >= 2 || autocvar__hud_configure))
4644 active_panel = HUD_PANEL_PRESSEDKEYS;
4645 HUD_Panel_UpdateCvars(pressedkeys);
4648 mySize = panel_size;
4650 HUD_Panel_DrawBg(1);
4651 if(panel_bg_padding)
4653 pos += '1 1 0' * panel_bg_padding;
4654 mySize -= '2 2 0' * panel_bg_padding;
4657 // force custom aspect
4658 float aspect = autocvar_hud_panel_pressedkeys_aspect;
4662 if(mySize_x/mySize_y > aspect)
4664 newSize_x = aspect * mySize_y;
4665 newSize_y = mySize_y;
4667 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4671 newSize_y = 1/aspect * mySize_x;
4672 newSize_x = mySize_x;
4674 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4680 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4682 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4684 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4685 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);
4686 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);
4688 drawpic_aspect_skin(pos, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4689 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);
4690 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);
4693 // Handle chat as a panel (#12)
4697 if(!autocvar_hud_panel_chat && !autocvar__hud_configure)
4699 cvar_set("con_chatrect", "0");
4703 active_panel = HUD_PANEL_CHAT;
4704 HUD_Panel_UpdateCvars(chat);
4706 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
4708 panel_pos_y = panel_bg_border;
4709 panel_size_y = vid_conheight - panel_bg_border * 2;
4710 if(panel_bg == "0") // force a border when maximized
4712 if(precache_pic(panel_bg) == "") {
4713 panel_bg = strcat(hud_skin_path, "/border_default");
4714 if(precache_pic(panel_bg) == "") {
4715 panel_bg = "gfx/hud/default/border_default";
4719 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an alpha of at least 0.75
4724 mySize = panel_size;
4726 HUD_Panel_DrawBg(1);
4728 if(panel_bg_padding)
4730 pos += '1 1 0' * panel_bg_padding;
4731 mySize -= '2 2 0' * panel_bg_padding;
4734 cvar_set("con_chatrect", "1");
4736 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4737 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4739 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4740 cvar_set("con_chat", ftos(floor(mySize_y/autocvar_con_chatsize - 0.5)));
4742 if(autocvar__hud_configure)
4745 chatsize = autocvar_con_chatsize;
4746 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4748 for(i = 0; i < autocvar_con_chat; ++i)
4750 if(i == autocvar_con_chat - 1)
4753 a = panel_fg_alpha * floor(((i + 1) * 7 + autocvar_con_chattime)/45);
4754 drawcolorcodedstring(pos + eY * i * chatsize, textShortenToWidth("^3Player^7: This is the chat area.", mySize_x, '1 1 0' * chatsize, stringwidth_colors), '1 1 0' * chatsize, a, DRAWFLAG_NORMAL);
4759 // Engine info panel (#13)
4766 float frametimeavg1; // 1 frame ago
4767 float frametimeavg2; // 2 frames ago
4768 void HUD_EngineInfo(void)
4770 if(!autocvar_hud_panel_engineinfo && !autocvar__hud_configure)
4773 active_panel = HUD_PANEL_ENGINEINFO;
4774 HUD_Panel_UpdateCvars(engineinfo);
4777 mySize = panel_size;
4779 HUD_Panel_DrawBg(1);
4780 if(panel_bg_padding)
4782 pos += '1 1 0' * panel_bg_padding;
4783 mySize -= '2 2 0' * panel_bg_padding;
4786 float currentTime = gettime(GETTIME_REALTIME);
4787 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
4789 float currentframetime = currentTime - prevfps_time;
4790 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4791 frametimeavg2 = frametimeavg1;
4792 frametimeavg1 = frametimeavg;
4795 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4796 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.
4798 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
4799 prevfps = (1/currentframetime);
4800 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"
4802 prevfps_time = currentTime;
4807 if(currentTime - prevfps_time > autocvar_hud_panel_engineinfo_framecounter_time)
4809 prevfps = framecounter/(currentTime - prevfps_time);
4811 prevfps_time = currentTime;
4816 color = HUD_Get_Num_Color (prevfps, 100);
4817 drawfont = hud_bigfont;
4818 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, autocvar_hud_panel_engineinfo_framecounter_decimals)), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4819 drawfont = hud_font;
4822 // Info messages panel (#14)
4824 #define drawInfoMessage(s)\
4825 if(autocvar_hud_panel_infomessages_flip)\
4826 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);\
4827 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
4829 void HUD_InfoMessages(void)
4831 if(!autocvar_hud_panel_infomessages && !autocvar__hud_configure)
4834 active_panel = HUD_PANEL_INFOMESSAGES;
4835 HUD_Panel_UpdateCvars(infomessages);
4838 mySize = panel_size;
4840 HUD_Panel_DrawBg(1);
4841 if(panel_bg_padding)
4843 pos += '1 1 0' * panel_bg_padding;
4844 mySize -= '2 2 0' * panel_bg_padding;
4847 // always force 5:1 aspect
4849 if(mySize_x/mySize_y > 5)
4851 newSize_x = 5 * mySize_y;
4852 newSize_y = mySize_y;
4854 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4858 newSize_y = 1/5 * mySize_x;
4859 newSize_x = mySize_x;
4861 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4870 fontsize = '0.20 0.20 0' * mySize_y;
4873 if(spectatee_status != 0)
4879 if(!autocvar__hud_configure)
4881 if(spectatee_status && !intermission)
4883 if(spectatee_status == -1)
4886 s = strcat("^1Spectating: ^7", GetPlayerName(spectatee_status - 1));
4889 if(spectatee_status == -1)
4890 s = strcat("^1Press ^3", getcommandkey("primary fire", "+fire"), "^1 to spectate");
4892 s = strcat("^1Press ^3", getcommandkey("primary fire", "+fire"), "^1 for another player");
4895 if(spectatee_status == -1)
4896 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
4898 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+fire2"), "^1 to observe");
4901 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
4904 if(gametype == GAME_ARENA)
4905 s = "^1Wait for your turn to join";
4906 else if(gametype == GAME_LMS)
4909 sk = playerslots[player_localentnum - 1];
4910 if(sk.(scores[ps_primary]) >= 666)
4911 s = "^1Match has already begun";
4912 else if(sk.(scores[ps_primary]) > 0)
4913 s = "^1You have no more lives left";
4915 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4918 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4921 //show restart countdown:
4922 if (time < getstatf(STAT_GAMESTARTTIME)) {
4924 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4925 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4926 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
4927 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4931 if(warmup_stage && !intermission)
4933 s = "^2Currently in ^1warmup^2 stage!";
4938 if(mod(time, 1) >= 0.5)
4943 if(ready_waiting && !intermission && !spectatee_status)
4945 if(ready_waiting_for_me)
4948 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
4950 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
4955 s = strcat("^2Waiting for others to ready up to end warmup...");
4957 s = strcat("^2Waiting for others to ready up...");
4961 else if(warmup_stage && !intermission && !spectatee_status)
4963 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
4967 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4969 float ts_min, ts_max;
4970 tm = teams.sort_next;
4973 for(; tm.sort_next; tm = tm.sort_next)
4975 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4977 if(!ts_min) ts_min = tm.team_size;
4978 else ts_min = min(ts_min, tm.team_size);
4979 if(!ts_max) ts_max = tm.team_size;
4980 else ts_max = max(ts_max, tm.team_size);
4982 if ((ts_max - ts_min) > 1)
4984 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
4985 tm = GetTeam(myteam, false);
4987 if (tm.team != COLOR_SPECTATOR)
4988 if (tm.team_size == ts_max)
4989 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
4997 s = "^7Press ^3ESC ^7to show HUD options.";
4999 s = "^3Doubleclick ^7a panel for panel-specific options.";
5001 s = "^3CTRL ^7to disable collision testing, ^3SHIFT ^7and";
5003 s = "^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.";
5014 void HUD_ShowSpeed(void)
5017 float pos, conversion_factor;
5018 string speed, zspeed, unit;
5020 switch(autocvar_cl_showspeed_unit)
5025 conversion_factor = 1.0;
5029 conversion_factor = 1.0;
5033 conversion_factor = 0.0254;
5037 conversion_factor = 0.0254 * 3.6;
5041 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
5045 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
5049 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
5051 numsize_x = numsize_y = autocvar_cl_showspeed_size;
5052 pos = (vid_conheight - numsize_y) * autocvar_cl_showspeed_position;
5054 drawfont = hud_bigfont;
5055 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
5057 if (autocvar_cl_showspeed_z == 1) {
5058 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
5059 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
5062 drawfont = hud_font;
5065 vector acc_prevspeed;
5069 void HUD_ShowAcceleration(void)
5071 float acceleration, sz, scale, alpha, f;
5072 vector pos, mySize, rgb;
5074 f = time - acc_prevtime;
5075 if(autocvar_cl_showacceleration_z)
5076 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
5078 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
5079 acc_prevspeed = pmove_vel;
5080 acc_prevtime = time;
5082 f = bound(0, f * 10, 1);
5083 acc_avg = acc_avg * (1 - f) + acceleration * f;
5084 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
5085 if (acceleration == 0)
5088 sz = autocvar_cl_showacceleration_size;
5089 scale = autocvar_cl_showacceleration_scale;
5090 alpha = autocvar_cl_showacceleration_alpha;
5091 if (autocvar_cl_showacceleration_color_custom)
5092 rgb = stov(autocvar_cl_showacceleration_color);
5094 if (acceleration < 0)
5095 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
5097 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
5100 mySize_x = vid_conwidth/2;
5102 pos_y = autocvar_cl_showacceleration_position * vid_conheight - sz/2;
5103 if (acceleration > 0)
5106 HUD_Panel_DrawProgressBar(pos, mySize, "statusbar", acceleration * scale, 0, 0, rgb, alpha * autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
5111 HUD_Panel_DrawProgressBar(pos, mySize, "statusbar", -acceleration * scale, 0, 1, rgb, alpha * autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
5115 void HUD_Reset (void)
5117 // reset gametype specific icons
5118 if(gametype == GAME_KEYHUNT)
5120 else if(gametype == GAME_CTF)
5121 HUD_Mod_CTF_Reset();
5124 #define HUD_DrawPanel(id)\
5126 case (HUD_PANEL_RADAR):\
5127 HUD_Radar(); break;\
5128 case (HUD_PANEL_WEAPONS):\
5129 HUD_Weapons(); break;\
5130 case (HUD_PANEL_AMMO):\
5132 case (HUD_PANEL_POWERUPS):\
5133 HUD_Powerups(); break;\
5134 case (HUD_PANEL_HEALTHARMOR):\
5135 HUD_HealthArmor(); break;\
5136 case (HUD_PANEL_NOTIFY):\
5137 HUD_Notify(); break;\
5138 case (HUD_PANEL_TIMER):\
5139 HUD_Timer(); break;\
5140 case (HUD_PANEL_SCORE):\
5141 HUD_Score(); break;\
5142 case (HUD_PANEL_RACETIMER):\
5143 HUD_RaceTimer(); break;\
5144 case (HUD_PANEL_VOTE):\
5145 HUD_VoteWindow(); break;\
5146 case (HUD_PANEL_MODICONS):\
5147 HUD_ModIcons(); break;\
5148 case (HUD_PANEL_PRESSEDKEYS):\
5149 HUD_DrawPressedKeys(); break;\
5150 case (HUD_PANEL_CHAT):\
5152 case (HUD_PANEL_ENGINEINFO):\
5153 HUD_EngineInfo(); break;\
5154 case (HUD_PANEL_INFOMESSAGES):\
5155 HUD_InfoMessages(); break;\
5156 } ENDS_WITH_CURLY_BRACE
5158 void HUD_Main (void)
5161 // global hud alpha fade
5162 if(menu_enabled == 1)
5165 hud_fade_alpha = (1 - autocvar__menu_alpha);
5167 if(scoreboard_fade_alpha)
5168 hud_fade_alpha = (1 - scoreboard_fade_alpha);
5170 if(intermission == 2) // no hud during mapvote
5172 else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
5175 if(!autocvar__hud_configure && !hud_fade_alpha)
5179 if (hud_skin_path != autocvar_hud_skin)
5182 strunzone(hud_skin_path);
5183 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
5186 // HUD configure visible grid
5187 float hud_configure_grid_alpha;
5188 if(autocvar__hud_configure && cvar("hud_configure_grid") && (hud_configure_grid_alpha = cvar("hud_configure_grid_alpha")))
5190 hud_configure_gridSize_x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
5191 hud_configure_gridSize_y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
5192 hud_configure_realGridSize_x = hud_configure_gridSize_x * vid_conwidth;
5193 hud_configure_realGridSize_y = hud_configure_gridSize_y * vid_conheight;
5195 for(i = 0; i < 1/hud_configure_gridSize_x; ++i)
5196 drawfill(eX * i * hud_configure_realGridSize_x, eX + eY * vid_conheight, '0.5 0.5 0.5', hud_configure_grid_alpha, DRAWFLAG_NORMAL);
5198 for(i = 0; i < 1/hud_configure_gridSize_y; ++i)
5199 drawfill(eY * i * hud_configure_realGridSize_y, eY + eX * vid_conwidth, '0.5 0.5 0.5', hud_configure_grid_alpha, DRAWFLAG_NORMAL);
5203 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
5207 float hud_dock_color_team = autocvar_hud_dock_color_team;
5208 if((teamplay) && hud_dock_color_team) {
5209 f = stof(getplayerkey(player_localentnum - 1, "colors"));
5210 color = colormapPaletteColor(mod(f, 16), 1) * hud_dock_color_team;
5212 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
5213 color = '1 0 0' * hud_dock_color_team;
5217 string hud_dock_color = autocvar_hud_dock_color;
5218 if(hud_dock_color == "shirt") {
5219 f = stof(getplayerkey(player_localentnum - 1, "colors"));
5220 color = colormapPaletteColor(floor(f / 16), 0);
5222 else if(hud_dock_color == "pants") {
5223 f = stof(getplayerkey(player_localentnum - 1, "colors"));
5224 color = colormapPaletteColor(mod(f, 16), 1);
5227 color = stov(hud_dock_color);
5231 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
5232 if(precache_pic(pic) == "") {
5233 pic = strcat(hud_skin_path, "/dock_medium");
5234 if(precache_pic(pic) == "") {
5235 pic = "gfx/hud/default/dock_medium";
5238 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...
5241 // cache the panel order into the panel_order array
5242 if(autocvar__hud_panelorder != hud_panelorder_prev) {
5243 for(i = 0; i < HUD_PANEL_NUM; ++i)
5244 panel_order[i] = -1;
5246 float p_num, warning;
5247 float argc = tokenize_console(autocvar__hud_panelorder);
5248 if (argc > HUD_PANEL_NUM)
5250 //first detect wrong/missing panel numbers
5251 for(i = 0; i < HUD_PANEL_NUM; ++i) {
5252 p_num = stof(argv(i));
5253 if (p_num >= 0 && p_num < HUD_PANEL_NUM) { //correct panel number?
5254 if (panel_order[p_num] == -1) //found for the first time?
5255 s = strcat(s, ftos(p_num), " ");
5256 panel_order[p_num] = 1; //mark as found
5261 for(i = 0; i < HUD_PANEL_NUM; ++i) {
5262 if (panel_order[i] == -1) {
5264 s = strcat(s, ftos(i), " "); //add missing panel number
5268 print("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n");
5270 cvar_set("_hud_panelorder", s);
5271 if(hud_panelorder_prev)
5272 strunzone(hud_panelorder_prev);
5273 hud_panelorder_prev = strzone(s);
5275 //now properly set panel_order
5276 tokenize_console(s);
5277 for(i = 0; i < HUD_PANEL_NUM; ++i) {
5278 panel_order[i] = stof(argv(i));
5281 // draw panels in order specified by panel_order array
5282 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
5283 if(i != HUD_PANEL_CHAT || !autocvar__con_chat_maximized) // don't draw maximized chat panel twice!
5284 HUD_DrawPanel(panel_order[i]);
5287 // draw chat panel on top if it is maximized
5288 if(autocvar__con_chat_maximized)
5289 HUD_Chat(); // HUD_DrawPanel(HUD_PANEL_CHAT);
5291 // TODO hud_'ify these
5292 if (autocvar_cl_showspeed)
5294 if (autocvar_cl_showacceleration)
5295 HUD_ShowAcceleration();
5297 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)
5298 localcmd("cmd selectteam auto; cmd join\n");
5300 hud_configure_prev = autocvar__hud_configure;
5302 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again