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) // no border
19 // draw only the central part
20 drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
27 //pic = draw_UseSkinFor(pic);
28 width = eX * theSize_x;
29 height = eY * theSize_y;
30 if(theSize_x <= theBorderSize_x * 2)
32 // not wide enough... draw just left and right then
33 bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
34 if(theSize_y <= theBorderSize_y * 2)
36 // not high enough... draw just corners
37 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
38 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
39 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
40 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
41 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
45 dY = theBorderSize_x * eY;
46 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
47 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
48 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
49 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);
50 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
51 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);
56 if(theSize_y <= theBorderSize_y * 2)
58 // not high enough... draw just top and bottom then
59 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
60 dX = theBorderSize_x * eX;
61 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
62 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
63 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
64 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
65 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);
66 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);
70 dX = theBorderSize_x * eX;
71 dY = theBorderSize_x * eY;
72 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
73 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
74 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
75 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
76 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
77 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
78 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
79 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
80 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
85 vector HUD_Get_Num_Color (float x, float maxvalue)
93 else if(x > maxvalue * 0.75) {
94 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
95 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
98 else if(x > maxvalue * 0.5) {
99 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
100 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
101 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
103 else if(x > maxvalue * 0.25) {
106 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
108 else if(x > maxvalue * 0.1) {
110 color_y = (x-20)*90/27/100; // green value between 0 -> 1
111 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
121 float stringwidth_colors(string s, vector theSize)
123 return stringwidth(s, TRUE, theSize);
126 float stringwidth_nocolors(string s, vector theSize)
128 return stringwidth(s, FALSE, theSize);
131 #define CENTERPRINT_MAX_LINES 30
132 string centerprint_messages[CENTERPRINT_MAX_LINES];
133 float centerprint_width[CENTERPRINT_MAX_LINES];
134 float centerprint_time;
135 float centerprint_expire;
136 float centerprint_num;
137 float centerprint_offset_hint;
138 vector centerprint_fontsize;
140 void centerprint(string strMessage)
142 float i, j, n, hcount;
145 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
147 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
149 if(cvar("scr_centertime") <= 0)
155 // strip trailing newlines
156 j = strlen(strMessage) - 1;
157 while(substring(strMessage, j, 1) == "\n" && j >= 0)
159 strMessage = substring(strMessage, 0, j + 1);
164 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
166 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
168 strMessage = substring(strMessage, j, strlen(strMessage) - j);
169 centerprint_offset_hint = j;
174 // if we get here, we have a message. Initialize its height.
177 n = tokenizebyseparator(strMessage, "\n");
179 for(j = 0; j < n; ++j)
181 getWrappedLine_remaining = argv(j);
182 while(getWrappedLine_remaining)
184 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
185 if(centerprint_messages[i] != s) // don't fade the same message in, looks stupid
186 centerprint_time = time;
187 if(centerprint_messages[i])
188 strunzone(centerprint_messages[i]);
189 centerprint_messages[i] = strzone(s);
190 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
193 // half height for empty lines looks better
199 if(i >= CENTERPRINT_MAX_LINES)
205 h = centerprint_fontsize_y*hcount;
207 havail = vid_conheight;
208 if(cvar("con_chatpos") < 0)
209 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
210 if(havail > vid_conheight - 70)
211 havail = vid_conheight - 70; // avoid overlapping HUD
214 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
216 // here, the centerprint would cover the crosshair. REALLY BAD.
217 forbiddenmin = vid_conheight * 0.5 - h - 16;
218 forbiddenmax = vid_conheight * 0.5 + 16;
220 allowedmin = scoreboard_bottom;
221 allowedmax = havail - h;
222 preferred = (havail - h)/2;
225 // possible orderings (total: 4! / 4 = 6)
226 // allowedmin allowedmax forbiddenmin forbiddenmax
227 // forbiddenmin forbiddenmax allowedmin allowedmax
228 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
230 // forbidden doesn't matter in this case
231 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
233 // allowedmin forbiddenmin allowedmax forbiddenmax
234 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
236 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
238 // allowedmin forbiddenmin forbiddenmax allowedmax
239 else if(allowedmin < forbiddenmin)
241 // make sure the forbidden zone is not covered
242 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
243 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
245 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
247 // forbiddenmin allowedmin allowedmax forbiddenmax
248 else if(allowedmax < forbiddenmax)
250 // it's better to leave the allowed zone (overlap with scoreboard) than
251 // to cover the forbidden zone (crosshair)
252 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
253 centerprint_start_y = forbiddenmax;
255 centerprint_start_y = forbiddenmin;
257 // forbiddenmin allowedmin forbiddenmax allowedmax
260 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
267 centerprint_expire = time + cvar("scr_centertime");
270 void HUD_DrawCenterPrint (void)
277 if(time - centerprint_time < 0.25)
278 a = (time - centerprint_time) / 0.25;
280 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
287 if(centerprint_num * cvar("scr_centersize") > 24 && scoreboard_active) // 24 = height of Scoreboard text
288 centerprint_start_y = scoreboard_bottom + centerprint_fontsize_y;
290 pos = centerprint_start;
291 for (i=0; i<centerprint_num; i = i + 1)
293 ts = centerprint_messages[i];
294 drawfontscale = sz * '1 1 0';
295 drawfont = hud_bigfont;
296 pos_x = (vid_conwidth - stringwidth(ts, TRUE, centerprint_fontsize)) * 0.5;
299 drawcolorcodedstring(pos + '0 1 0' * (1 - sz) * 0.5 *centerprint_fontsize_y, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
300 pos_y = pos_y + centerprint_fontsize_y;
303 // half height for empty lines looks better
304 pos_y = pos_y + sz * centerprint_fontsize_y * 0.5;
305 drawfontscale = '1 1 0';
310 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
312 position_x -= 2 / 3 * strlen(text) * scale_x;
313 drawstring(position, text, scale, rgb, alpha, flag);
316 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
318 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
319 drawstring(position, text, scale, rgb, alpha, flag);
322 // return the string of the given race place
323 string race_PlaceName(float pos) {
331 return strcat(ftos(pos), "th");
334 // return the string of the onscreen race timer
335 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
343 if(histime == 0) // goal hit
347 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
357 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
363 lapstr = strcat(" (-", ftos(lapdelta), "L)");
366 else if(lapdelta < 0)
368 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
372 else if(histime > 0) // anticipation
374 if(mytime >= histime)
375 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
377 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
384 cpname = "Start line";
386 cpname = "Finish line";
388 cpname = strcat("Intermediate ", ftos(cp));
390 cpname = "Finish line";
393 return strcat(col, cpname);
394 else if(hisname == "")
395 return strcat(col, cpname, " (", timestr, ")");
397 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
400 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
401 float race_CheckName(string net_name) {
403 for (i=RANKINGS_CNT-1;i>=0;--i)
404 if(grecordholder[i] == net_name)
415 #define HUD_Write(s) fputs(fh, s)
416 // q: quoted, n: not quoted
417 #define HUD_Write_Cvar_n(cvar) HUD_Write(strcat("seta ", cvar, " ", cvar_string(cvar), "\n"))
418 #define HUD_Write_Cvar_q(cvar) HUD_Write(strcat("seta ", cvar, " \"", cvar_string(cvar), "\"\n"))
419 #define HUD_Write_PanelCvar_n(cvar_suf) HUD_Write_Cvar_n(strcat("hud_panel_", panel_name, cvar_suf))
420 #define HUD_Write_PanelCvar_q(cvar_suf) HUD_Write_Cvar_q(strcat("hud_panel_", panel_name, cvar_suf))
422 void HUD_Panel_ExportCfg(string cfgname)
425 string filename = strcat("hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg");
426 fh = fopen(filename, FILE_WRITE);
429 HUD_Write_Cvar_q("hud_skin");
430 HUD_Write_Cvar_q("hud_panel_bg");
431 HUD_Write_Cvar_q("hud_panel_bg_color");
432 HUD_Write_Cvar_q("hud_panel_bg_color_team");
433 HUD_Write_Cvar_q("hud_panel_bg_alpha");
434 HUD_Write_Cvar_q("hud_panel_bg_border");
435 HUD_Write_Cvar_q("hud_panel_bg_padding");
436 HUD_Write_Cvar_q("hud_panel_fg_alpha");
439 HUD_Write_Cvar_q("hud_dock");
440 HUD_Write_Cvar_q("hud_dock_color");
441 HUD_Write_Cvar_q("hud_dock_color_team");
442 HUD_Write_Cvar_q("hud_dock_alpha");
445 HUD_Write_Cvar_q("hud_progressbar_alpha");
446 HUD_Write_Cvar_q("hud_progressbar_strength_color");
447 HUD_Write_Cvar_q("hud_progressbar_shield_color");
448 HUD_Write_Cvar_q("hud_progressbar_health_color");
449 HUD_Write_Cvar_q("hud_progressbar_armor_color");
450 HUD_Write_Cvar_q("hud_progressbar_fuel_color");
451 HUD_Write_Cvar_q("hud_progressbar_nexball_color");
454 HUD_Write_Cvar_q("_hud_panelorder");
457 HUD_Write_Cvar_q("hud_configure_grid");
458 HUD_Write_Cvar_q("hud_configure_grid_xsize");
459 HUD_Write_Cvar_q("hud_configure_grid_ysize");
462 HUD_Write_Cvar_q("scr_centerpos");
465 // common cvars for all panels
467 for (i = 0; i < HUD_PANEL_NUM; ++i)
469 HUD_Panel_GetName(i);
471 HUD_Write_PanelCvar_n("");
472 HUD_Write_PanelCvar_q("_pos");
473 HUD_Write_PanelCvar_q("_size");
474 HUD_Write_PanelCvar_q("_bg");
475 HUD_Write_PanelCvar_q("_bg_color");
476 HUD_Write_PanelCvar_q("_bg_color_team");
477 HUD_Write_PanelCvar_q("_bg_alpha");
478 HUD_Write_PanelCvar_q("_bg_border");
479 HUD_Write_PanelCvar_q("_bg_padding");
481 case HUD_PANEL_WEAPONS:
482 HUD_Write_PanelCvar_q("_complainbubble");
483 HUD_Write_PanelCvar_q("_complainbubble_padding");
484 HUD_Write_PanelCvar_q("_complainbubble_color_outofammo");
485 HUD_Write_PanelCvar_q("_complainbubble_color_donthave");
486 HUD_Write_PanelCvar_q("_complainbubble_color_unavailable");
487 HUD_Write_PanelCvar_q("_ammo_color");
488 HUD_Write_PanelCvar_q("_ammo_alpha");
489 HUD_Write_PanelCvar_q("_aspect");
492 HUD_Write_PanelCvar_q("_onlycurrent");
493 HUD_Write_PanelCvar_q("_iconalign");
495 case HUD_PANEL_POWERUPS:
496 HUD_Write_PanelCvar_q("_flip");
497 HUD_Write_PanelCvar_q("_iconalign");
498 HUD_Write_PanelCvar_q("_baralign");
499 HUD_Write_PanelCvar_q("_progressbar");
501 case HUD_PANEL_HEALTHARMOR:
502 HUD_Write_PanelCvar_q("_flip");
503 HUD_Write_PanelCvar_q("_iconalign");
504 HUD_Write_PanelCvar_q("_baralign");
505 HUD_Write_PanelCvar_q("_progressbar");
507 case HUD_PANEL_NOTIFY:
508 HUD_Write_PanelCvar_q("_flip");
509 HUD_Write_PanelCvar_q("_print");
511 case HUD_PANEL_RADAR:
512 HUD_Write_PanelCvar_q("_foreground_alpha");
515 HUD_Write_PanelCvar_q("_alreadyvoted_alpha");
517 case HUD_PANEL_PRESSEDKEYS:
518 HUD_Write_PanelCvar_q("_aspect");
520 case HUD_PANEL_INFOMESSAGES:
521 HUD_Write_PanelCvar_q("_flip");
526 HUD_Write("menu_sync\n"); // force the menu to reread the cvars, so that the dialogs are updated
528 print("^2Successfully exported to ", filename, "! (Note: It's saved in data/data/)\n");
532 print("^1Couldn't write to ", filename, "\n");
535 const float hlBorderSize = 4;
536 const string hlBorder = "gfx/hud/default/border_highlighted";
537 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
538 void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
540 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
541 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);
542 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);
543 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);
544 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);
547 // draw the background/borders
548 #define HUD_Panel_DrawBg(alpha)\
550 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));\
551 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
553 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);\
554 } ENDS_WITH_CURLY_BRACE
556 void HUD_Panel_DrawProgressBar(vector pos, vector mySize, float lenght_ratio, float vertical, float right_align, vector color, float alpha, float drawflag)
563 pic = strcat(hud_skin_path, "/statusbar_vertical");
564 if(precache_pic(pic) == "") {
565 pic = "gfx/hud/default/statusbar_vertical";
569 pos_y += (1 - lenght_ratio) * mySize_y;
570 mySize_y *= lenght_ratio;
572 drawsubpic(pos, eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, pic, '0 0 0', '1 0.25 0', color, alpha, drawflag);
573 if(mySize_y/mySize_x > 2)
574 drawsubpic(pos + eY * mySize_x, eY * (mySize_y - 2 * mySize_x) + eX * mySize_x, pic, '0 0.25 0', '1 0.5 0', color, alpha, drawflag);
575 drawsubpic(pos + eY * mySize_y - eY * min(mySize_y * 0.5, mySize_x), eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, pic, '0 0.75 0', '1 0.25 0', color, alpha, drawflag);
577 pic = strcat(hud_skin_path, "/statusbar");
578 if(precache_pic(pic) == "") {
579 pic = "gfx/hud/default/statusbar";
583 pos_x += (1 - lenght_ratio) * mySize_x;
584 mySize_x *= lenght_ratio;
586 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
587 if(mySize_x/mySize_y > 2)
588 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);
589 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);
593 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
599 pic = strcat(hud_skin_path, "/num_leading");
600 if(precache_pic(pic) == "") {
601 pic = "gfx/hud/default/num_leading";
604 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
605 if(mySize_x/mySize_y > 2)
606 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);
607 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);
610 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
611 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
620 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
621 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
623 for (i = 0; i < HUD_PANEL_NUM; ++i) {
624 if(i == highlightedPanel || !panel_enabled)
627 HUD_Panel_UpdatePosSizeForId(i);
629 panel_pos -= '1 1 0' * panel_bg_border;
630 panel_size += '2 2 0' * panel_bg_border;
632 if(myPos_y + mySize_y < panel_pos_y)
634 if(myPos_y > panel_pos_y + panel_size_y)
637 if(myPos_x + mySize_x < panel_pos_x)
639 if(myPos_x > panel_pos_x + panel_size_x)
642 // OK, there IS a collision.
644 myCenter_x = myPos_x + 0.5 * mySize_x;
645 myCenter_y = myPos_y + 0.5 * mySize_y;
647 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
648 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
650 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
652 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
653 myTarget_x = panel_pos_x - mySize_x;
654 else // push it upwards
655 myTarget_y = panel_pos_y - mySize_y;
657 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
659 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
660 myTarget_x = panel_pos_x + panel_size_x;
661 else // push it upwards
662 myTarget_y = panel_pos_y - mySize_y;
664 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
666 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
667 myTarget_x = panel_pos_x - mySize_x;
668 else // push it downwards
669 myTarget_y = panel_pos_y + panel_size_y;
671 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
673 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
674 myTarget_x = panel_pos_x + panel_size_x;
675 else // push it downwards
676 myTarget_y = panel_pos_y + panel_size_y;
678 //if(cvar("hud_configure_checkcollisions_debug"))
679 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
685 void HUD_Panel_SetPos(vector pos)
687 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
691 //if(cvar("hud_configure_checkcollisions_debug"))
692 //drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
694 if(cvar("hud_configure_grid"))
696 pos_x = floor((pos_x/vid_conwidth)/hud_configure_gridSize_x + 0.5) * hud_configure_realGridSize_x;
697 pos_y = floor((pos_y/vid_conheight)/hud_configure_gridSize_y + 0.5) * hud_configure_realGridSize_y;
700 if(hud_configure_checkcollisions)
701 pos = HUD_Panel_CheckMove(pos, mySize);
703 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
704 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
707 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
709 HUD_Panel_GetName(highlightedPanel);
710 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
713 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
714 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
719 float dist_x, dist_y;
721 ratio = mySize_x/mySize_y;
723 for (i = 0; i < HUD_PANEL_NUM; ++i) {
724 if(i == highlightedPanel || !panel_enabled)
727 HUD_Panel_UpdatePosSizeForId(i);
729 panel_pos -= '1 1 0' * panel_bg_border;
730 panel_size += '2 2 0' * panel_bg_border;
732 targEndPos = panel_pos + panel_size;
734 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
735 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
738 if (resizeCorner == 1)
740 // check if this panel is on our way
741 if (resizeorigin_x <= panel_pos_x)
743 if (resizeorigin_y <= panel_pos_y)
745 if (targEndPos_x <= resizeorigin_x - mySize_x)
747 if (targEndPos_y <= resizeorigin_y - mySize_y)
750 // there is a collision:
751 // detect which side of the panel we are facing is actually limiting the resizing
752 // (which side the resize direction finds for first) and reduce the size up to there
754 // dist is the distance between resizeorigin and the "analogous" point of the panel
755 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
756 dist_x = resizeorigin_x - targEndPos_x;
757 dist_y = resizeorigin_y - targEndPos_y;
758 if (dist_y <= 0 || dist_x / dist_y > ratio)
759 mySize_x = min(mySize_x, dist_x);
761 mySize_y = min(mySize_y, dist_y);
763 else if (resizeCorner == 2)
765 if (resizeorigin_x >= targEndPos_x)
767 if (resizeorigin_y <= panel_pos_y)
769 if (panel_pos_x >= resizeorigin_x + mySize_x)
771 if (targEndPos_y <= resizeorigin_y - mySize_y)
774 dist_x = panel_pos_x - resizeorigin_x;
775 dist_y = resizeorigin_y - targEndPos_y;
776 if (dist_y <= 0 || dist_x / dist_y > ratio)
777 mySize_x = min(mySize_x, dist_x);
779 mySize_y = min(mySize_y, dist_y);
781 else if (resizeCorner == 3)
783 if (resizeorigin_x <= panel_pos_x)
785 if (resizeorigin_y >= targEndPos_y)
787 if (targEndPos_x <= resizeorigin_x - mySize_x)
789 if (panel_pos_y >= resizeorigin_y + mySize_y)
792 dist_x = resizeorigin_x - targEndPos_x;
793 dist_y = panel_pos_y - resizeorigin_y;
794 if (dist_y <= 0 || dist_x / dist_y > ratio)
795 mySize_x = min(mySize_x, dist_x);
797 mySize_y = min(mySize_y, dist_y);
799 else if (resizeCorner == 4)
801 if (resizeorigin_x >= targEndPos_x)
803 if (resizeorigin_y >= targEndPos_y)
805 if (panel_pos_x >= resizeorigin_x + mySize_x)
807 if (panel_pos_y >= resizeorigin_y + mySize_y)
810 dist_x = panel_pos_x - resizeorigin_x;
811 dist_y = panel_pos_y - resizeorigin_y;
812 if (dist_y <= 0 || dist_x / dist_y > ratio)
813 mySize_x = min(mySize_x, dist_x);
815 mySize_y = min(mySize_y, dist_y);
817 //if(cvar("hud_configure_checkcollisions_debug"))
818 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
824 void HUD_Panel_SetPosSize(vector mySize)
826 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
828 resizeorigin = panel_click_resizeorigin;
831 // minimum panel size cap
832 mySize_x = max(0.025 * vid_conwidth, mySize_x);
833 mySize_y = max(0.025 * vid_conheight, mySize_y);
835 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.
837 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
838 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
841 // collision testing|
842 // -----------------+
844 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
845 if(resizeCorner == 1) {
846 myPos_x = resizeorigin_x - mySize_x;
847 myPos_y = resizeorigin_y - mySize_y;
848 } else if(resizeCorner == 2) {
849 myPos_x = resizeorigin_x;
850 myPos_y = resizeorigin_y - mySize_y;
851 } else if(resizeCorner == 3) {
852 myPos_x = resizeorigin_x - mySize_x;
853 myPos_y = resizeorigin_y;
854 } else { // resizeCorner == 4
855 myPos_x = resizeorigin_x;
856 myPos_y = resizeorigin_y;
859 // left/top screen edges
861 mySize_x = mySize_x + myPos_x;
863 mySize_y = mySize_y + myPos_y;
865 // bottom/right screen edges
866 if(myPos_x + mySize_x > vid_conwidth)
867 mySize_x = vid_conwidth - myPos_x;
868 if(myPos_y + mySize_y > vid_conheight)
869 mySize_y = vid_conheight - myPos_y;
871 //if(cvar("hud_configure_checkcollisions_debug"))
872 //drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
874 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
875 if(cvar("hud_configure_grid"))
877 mySize_x = floor((mySize_x/vid_conwidth)/hud_configure_gridSize_x + 0.5) * hud_configure_realGridSize_x;
878 mySize_y = floor((mySize_y/vid_conheight)/hud_configure_gridSize_y + 0.5) * hud_configure_realGridSize_y;
881 if(hud_configure_checkcollisions)
882 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
884 // 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)
885 mySize_x = max(0.025 * vid_conwidth, mySize_x);
886 mySize_y = max(0.025 * vid_conheight, mySize_y);
888 // do another pos check, as size might have changed by now
889 if(resizeCorner == 1) {
890 myPos_x = resizeorigin_x - mySize_x;
891 myPos_y = resizeorigin_y - mySize_y;
892 } else if(resizeCorner == 2) {
893 myPos_x = resizeorigin_x;
894 myPos_y = resizeorigin_y - mySize_y;
895 } else if(resizeCorner == 3) {
896 myPos_x = resizeorigin_x - mySize_x;
897 myPos_y = resizeorigin_y;
898 } else { // resizeCorner == 4
899 myPos_x = resizeorigin_x;
900 myPos_y = resizeorigin_y;
903 //if(cvar("hud_configure_checkcollisions_debug"))
904 //drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
906 HUD_Panel_GetName(highlightedPanel);
908 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
909 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
911 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
912 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
916 float prevMouseClicked; // previous state
917 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
918 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
920 float pressed_key_time;
921 void HUD_Panel_Arrow_Action(float nPrimary)
923 if (highlightedPanel_prev == -1 || mouseClicked)
926 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
929 if(cvar("hud_configure_grid"))
931 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
933 if (hudShiftState & S_SHIFT)
934 step = hud_configure_realGridSize_y;
936 step = 2 * hud_configure_realGridSize_y;
940 if (hudShiftState & S_SHIFT)
941 step = hud_configure_realGridSize_x;
943 step = 2 * hud_configure_realGridSize_x;
948 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
949 step = vid_conheight;
952 if (hudShiftState & S_SHIFT)
953 step = (step / 256); // more precision
955 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
958 highlightedPanel = highlightedPanel_prev;
960 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
962 vector prev_pos, prev_size;
963 prev_pos = panel_pos;
964 prev_size = panel_size;
966 if (hudShiftState & S_ALT) // resize
968 highlightedAction = 1;
969 if(nPrimary == K_UPARROW)
971 else if(nPrimary == K_RIGHTARROW)
973 else if(nPrimary == K_LEFTARROW)
975 else // if(nPrimary == K_DOWNARROW)
978 // ctrl+arrow reduces the size, instead of increasing it
979 // Note that ctrl disables collisions check too, but it's fine
980 // since we don't collide with anything reducing the size
981 if (hudShiftState & S_CTRL) {
983 resizeCorner = 5 - resizeCorner;
988 panel_click_resizeorigin = panel_pos;
989 if(resizeCorner == 1) {
990 panel_click_resizeorigin += mySize;
992 } else if(resizeCorner == 2) {
993 panel_click_resizeorigin_y += mySize_y;
995 } else if(resizeCorner == 3) {
996 panel_click_resizeorigin_x += mySize_x;
998 } else { // resizeCorner == 4
1001 HUD_Panel_SetPosSize(mySize);
1005 highlightedAction = 2;
1008 if(nPrimary == K_UPARROW)
1010 else if(nPrimary == K_DOWNARROW)
1012 else if(nPrimary == K_LEFTARROW)
1014 else // if(nPrimary == K_RIGHTARROW)
1017 HUD_Panel_SetPos(pos);
1020 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
1022 if (prev_pos != panel_pos || prev_size != panel_size)
1025 panel_pos_backup = prev_pos;
1026 panel_size_backup = prev_size;
1027 highlightedPanel_backup = highlightedPanel;
1031 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1035 if(!autocvar__hud_configure)
1038 // allow console bind to work
1041 con_keys = findkeysforcommand("toggleconsole");
1042 keys = tokenize(con_keys);
1044 float hit_con_bind, i;
1045 for (i = 0; i < keys; ++i)
1047 if(nPrimary == stof(argv(i)))
1051 if(bInputType == 0) {
1052 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1053 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1054 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1056 else if(bInputType == 1) {
1057 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1058 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1059 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1062 if(nPrimary == K_MOUSE1)
1064 if(bInputType == 0) { // key pressed
1068 else if(bInputType == 1) {// key released
1073 else if(nPrimary == K_ESCAPE)
1075 if (bInputType == 1)
1078 menu_enabled_time = time;
1079 localcmd("menu_showhudexit\n");
1081 else if(nPrimary == K_SPACE && hudShiftState & S_CTRL) // enable/disable highlighted panel or dock
1083 if (bInputType == 1 || mouseClicked)
1086 if (highlightedPanel_prev != -1)
1087 cvar_set(strcat("hud_panel_", panel_name), ftos(!(panel_enabled)));
1089 cvar_set(strcat("hud_dock"), (autocvar_hud_dock == "") ? "dock" : "");
1091 else if(nPrimary == 'c' && hudShiftState & S_CTRL) // copy highlighted panel size
1093 if (bInputType == 1 || mouseClicked)
1096 if (highlightedPanel_prev != -1)
1098 panel_size_copied = panel_size;
1099 highlightedPanel_copied = highlightedPanel_prev;
1102 else if(nPrimary == 'v' && hudShiftState & S_CTRL) // past copied size on the highlighted panel
1104 if (bInputType == 1 || mouseClicked)
1107 if (highlightedPanel_copied == -1 || highlightedPanel_prev == -1)
1110 HUD_Panel_UpdatePosSizeForId(highlightedPanel_prev);
1112 // reduce size if it'd go beyond screen boundaries
1113 vector tmp_size = panel_size_copied;
1114 if (panel_pos_x + panel_size_copied_x > vid_conwidth)
1115 tmp_size_x = vid_conwidth - panel_pos_x;
1116 if (panel_pos_y + panel_size_copied_y > vid_conheight)
1117 tmp_size_y = vid_conheight - panel_pos_y;
1119 if (panel_size == tmp_size)
1123 panel_pos_backup = panel_pos;
1124 panel_size_backup = panel_size;
1125 highlightedPanel_backup = highlightedPanel_prev;
1127 s = strcat(ftos(tmp_size_x/vid_conwidth), " ", ftos(tmp_size_y/vid_conheight));
1128 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
1130 else if(nPrimary == 'z' && hudShiftState & S_CTRL) // undo last action
1132 if (bInputType == 1 || mouseClicked)
1134 //restore previous values
1135 if (highlightedPanel_backup != -1)
1137 HUD_Panel_GetName(highlightedPanel_backup);
1138 s = strcat(ftos(panel_pos_backup_x/vid_conwidth), " ", ftos(panel_pos_backup_y/vid_conheight));
1139 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
1140 s = strcat(ftos(panel_size_backup_x/vid_conwidth), " ", ftos(panel_size_backup_y/vid_conheight));
1141 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
1142 highlightedPanel_backup = -1;
1145 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1147 if (bInputType == 1)
1149 pressed_key_time = 0;
1152 else if (pressed_key_time == 0)
1153 pressed_key_time = time;
1155 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1157 else if(hit_con_bind)
1160 return true; // Suppress ALL other input
1163 float HUD_Panel_HighlightCheck()
1167 while(j < HUD_PANEL_NUM)
1172 HUD_Panel_UpdatePosSizeForId(i);
1174 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1177 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)
1181 // resize from topleft border
1182 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)
1186 // resize from topright border
1187 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)
1191 // resize from bottomleft border
1192 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)
1196 // resize from bottomright border
1197 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)
1205 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1206 void HUD_Panel_FirstInDrawQ(float id)
1209 var float place = -1;
1210 // find out where in the array our current id is, save into place
1211 for(i = 0; i < HUD_PANEL_NUM; ++i)
1213 if(panel_order[i] == id)
1219 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1221 place = HUD_PANEL_NUM - 1;
1223 // move all ids up by one step in the array until "place"
1224 for(i = place; i > 0; --i)
1226 panel_order[i] = panel_order[i-1];
1228 // now save the new top id
1229 panel_order[0] = id;
1231 // let's save them into the cvar by some strcat trickery
1233 for(i = 0; i < HUD_PANEL_NUM; ++i)
1235 s = strcat(s, ftos(panel_order[i]), " ");
1237 cvar_set("_hud_panelorder", s);
1238 if(hud_panelorder_prev)
1239 strunzone(hud_panelorder_prev);
1240 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1243 void HUD_Panel_Highlight()
1247 while(j < HUD_PANEL_NUM)
1252 HUD_Panel_UpdatePosSizeForId(i);
1254 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1257 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)
1259 highlightedPanel = i;
1260 HUD_Panel_FirstInDrawQ(i);
1261 highlightedAction = 1;
1262 panel_click_distance = mousepos - panel_pos;
1265 // resize from topleft border
1266 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)
1268 highlightedPanel = i;
1269 HUD_Panel_FirstInDrawQ(i);
1270 highlightedAction = 2;
1272 panel_click_distance = mousepos - panel_pos;
1273 panel_click_resizeorigin = panel_pos + panel_size;
1276 // resize from topright border
1277 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)
1279 highlightedPanel = i;
1280 HUD_Panel_FirstInDrawQ(i);
1281 highlightedAction = 2;
1283 panel_click_distance_x = panel_size_x - mousepos_x + panel_pos_x;
1284 panel_click_distance_y = mousepos_y - panel_pos_y;
1285 panel_click_resizeorigin = panel_pos + eY * panel_size_y;
1288 // resize from bottomleft border
1289 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)
1291 highlightedPanel = i;
1292 HUD_Panel_FirstInDrawQ(i);
1293 highlightedAction = 2;
1295 panel_click_distance_x = mousepos_x - panel_pos_x;
1296 panel_click_distance_y = panel_size_y - mousepos_y + panel_pos_y;
1297 panel_click_resizeorigin = panel_pos + eX * panel_size_x;
1300 // resize from bottomright border
1301 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)
1303 highlightedPanel = i;
1304 HUD_Panel_FirstInDrawQ(i);
1305 highlightedAction = 2;
1307 panel_click_distance = panel_size - mousepos + panel_pos;
1308 panel_click_resizeorigin = panel_pos;
1313 highlightedPanel_prev = -1;
1318 float highlightcheck;
1319 vector prev_pos, prev_size;
1320 void HUD_Panel_Mouse()
1322 // 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
1323 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1327 print("menu_enabled: ", ftos(menu_enabled), "\n");
1328 print("Highlighted: ", ftos(highlightedPanel), "\n");
1329 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1332 // instantly hide the editor cursor if we open the HUDExit dialog
1333 // as hud_fade_alpha doesn't decrease to 0 in this case
1334 // TODO: find a way to fade the cursor out even in this case
1335 if(menu_enabled == 1 || (menu_enabled == 2 && !hud_fade_alpha))
1338 if(mouseClicked == 0 && menu_enabled != 2 && highlightedPanel >= 0) { // don't reset these variables in menu_enabled mode 2!
1339 highlightedPanel = -1;
1340 highlightedAction = 0;
1342 if(highlightedPanel != -1)
1343 highlightedPanel_prev = highlightedPanel;
1345 mousepos = mousepos + getmousepos() * cvar("menu_mouse_speed");
1347 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1348 mousepos_y = bound(0, mousepos_y, vid_conheight);
1352 if(prevMouseClicked == 0)
1354 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1355 // and calls HUD_Panel_UpdatePosSizeForId() for the highlighted panel
1356 prev_pos = panel_pos;
1357 prev_size = panel_size;
1360 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
1362 if (prev_pos != panel_pos || prev_size != panel_size)
1364 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
1366 panel_pos_backup = prev_pos;
1367 panel_size_backup = prev_size;
1368 highlightedPanel_backup = highlightedPanel;
1371 // in case the clicked panel is inside another panel and we aren't
1372 // moving it, avoid the immediate "fix" of its position/size
1373 // (often unwanted and hateful) by disabling collisions check
1374 hud_configure_checkcollisions = false;
1376 if(highlightedAction == 1)
1377 HUD_Panel_SetPos(mousepos - panel_click_distance);
1378 else if(highlightedAction == 2)
1381 if(resizeCorner == 1) {
1382 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1383 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1384 } else if(resizeCorner == 2) {
1385 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1386 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1387 } else if(resizeCorner == 3) {
1388 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1389 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1390 } else { // resizeCorner == 4
1391 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1392 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1394 HUD_Panel_SetPosSize(mySize);
1397 // doubleclick check
1398 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1400 mouseClicked = 0; // to prevent spam, I guess.
1402 menu_enabled_time = time;
1403 HUD_Panel_GetName(highlightedPanel);
1404 localcmd("menu_showhudoptions ", panel_name, "\n");
1407 if(prevMouseClicked == 0)
1409 prevMouseClickedTime = time;
1410 prevMouseClickedPos = mousepos;
1415 highlightcheck = HUD_Panel_HighlightCheck();
1417 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1419 cursorsize = '32 32 0';
1421 if(highlightcheck == 0)
1422 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1423 else if(highlightcheck == 1)
1424 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1425 else if(highlightcheck == 2)
1426 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1428 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1430 prevMouseClicked = mouseClicked;
1433 // Weapon icons (#0)
1435 float weaponspace[10];
1436 #define HUD_Weapons_Clear()\
1438 for(idx = 0; idx < 10; ++idx)\
1439 weaponspace[idx] = 0
1441 entity weaponorder[WEP_MAXCOUNT];
1442 void weaponorder_swap(float i, float j, entity pass)
1446 weaponorder[i] = weaponorder[j];
1450 string weaponorder_cmp_str;
1451 float weaponorder_cmp(float i, float j, entity pass)
1454 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1455 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1456 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)
1459 float GetAmmoStat(float i)
1463 case 0: return STAT_SHELLS;
1464 case 1: return STAT_NAILS;
1465 case 2: return STAT_ROCKETS;
1466 case 3: return STAT_CELLS;
1467 case 4: return STAT_FUEL;
1472 float GetAmmoTypeForWep(float i)
1476 case WEP_SHOTGUN: return 0;
1477 case WEP_UZI: return 1;
1478 case WEP_GRENADE_LAUNCHER: return 2;
1479 case WEP_MINE_LAYER: return 2;
1480 case WEP_ELECTRO: return 3;
1481 case WEP_CRYLINK: return 3;
1482 case WEP_HLAC: return 3;
1483 case WEP_MINSTANEX: return 3;
1484 case WEP_NEX: return 3;
1485 case WEP_CAMPINGRIFLE: return 1;
1486 case WEP_HAGAR: return 2;
1487 case WEP_ROCKET_LAUNCHER: return 2;
1488 case WEP_SEEKER: return 2;
1489 case WEP_FIREBALL: return 4;
1490 case WEP_HOOK: return 3;
1495 void HUD_Weapons(void)
1498 float center_x, center_y;
1500 if(!autocvar__hud_configure)
1502 if(!autocvar_hud_panel_weapons) return;
1503 if(spectatee_status == -1) return;
1506 float timeout = cvar("hud_panel_weapons_timeout");
1507 float timeout_effect_length, timein_effect_length;
1508 if (cvar("hud_panel_weapons_timeout_effect") == 0)
1510 timeout_effect_length = 0;
1511 timein_effect_length = 0;
1515 timeout_effect_length = 0.75;
1516 timein_effect_length = 0.375;
1519 if (timeout && time >= weapontime + timeout + timeout_effect_length && !autocvar__hud_configure)
1521 weaponprevtime = time;
1525 active_panel = HUD_PANEL_WEAPONS;
1526 HUD_Panel_UpdateCvars(weapons);
1528 if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
1530 f = (time - (weapontime + timeout)) / timeout_effect_length;
1531 if (cvar("hud_panel_weapons_timeout_effect"))
1533 panel_bg_alpha *= (1 - f);
1534 panel_fg_alpha *= (1 - f);
1536 if (cvar("hud_panel_weapons_timeout_effect") == 1)
1538 f *= f; // for a cooler movement
1539 center_x = panel_pos_x + panel_size_x/2;
1540 center_y = panel_pos_y + panel_size_y/2;
1541 screen_ar = vid_conwidth/vid_conheight;
1542 if (center_x/center_y < screen_ar) //bottom left
1544 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
1545 panel_pos_y += f * (vid_conheight - panel_pos_y);
1547 panel_pos_x -= f * (panel_pos_x + panel_size_x);
1551 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
1552 panel_pos_x += f * (vid_conwidth - panel_pos_x);
1554 panel_pos_y -= f * (panel_pos_y + panel_size_y);
1557 weaponprevtime = time - (1 - f) * timein_effect_length;
1559 else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure)
1561 f = (time - weaponprevtime) / timein_effect_length;
1562 if (cvar("hud_panel_weapons_timeout_effect"))
1564 panel_bg_alpha *= (f);
1565 panel_fg_alpha *= (f);
1567 if (cvar("hud_panel_weapons_timeout_effect") == 1)
1569 f *= f; // for a cooler movement
1571 center_x = panel_pos_x + panel_size_x/2;
1572 center_y = panel_pos_y + panel_size_y/2;
1573 screen_ar = vid_conwidth/vid_conheight;
1574 if (center_x/center_y < screen_ar) //bottom left
1576 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
1577 panel_pos_y += f * (vid_conheight - panel_pos_y);
1579 panel_pos_x -= f * (panel_pos_x + panel_size_x);
1583 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
1584 panel_pos_x += f * (vid_conwidth - panel_pos_x);
1586 panel_pos_y -= f * (panel_pos_y + panel_size_y);
1591 float i, weapid, wpnalpha, weapon_cnt;
1593 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1595 self = get_weaponinfo(i);
1596 if(self.impulse >= 0)
1600 // TODO make this configurable
1601 if(weaponorder_bypriority != cvar_string("cl_weaponpriority"))
1603 if(weaponorder_bypriority)
1604 strunzone(weaponorder_bypriority);
1605 if(weaponorder_byimpulse)
1606 strunzone(weaponorder_byimpulse);
1608 weaponorder_bypriority = strzone(cvar_string("cl_weaponpriority"));
1609 weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
1610 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1613 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1615 self = get_weaponinfo(i);
1616 if(self.impulse >= 0)
1618 weaponorder[weapon_cnt] = self;
1622 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1624 weaponorder_cmp_str = string_null;
1627 HUD_Panel_DrawBg(1);
1628 if(panel_bg_padding)
1630 panel_pos += '1 1 0' * panel_bg_padding;
1631 panel_size -= '2 2 0' * panel_bg_padding;
1634 if(cvar_or("hud_panel_weapons_fade", 1))
1636 wpnalpha = 3.2 - 2 * (time - weapontime);
1637 wpnalpha = bound(0.7, wpnalpha, 1) * panel_fg_alpha;
1640 wpnalpha = panel_fg_alpha;
1642 HUD_Weapons_Clear();
1644 float rows, columns;
1645 float aspect = cvar("hud_panel_weapons_aspect");
1646 rows = panel_size_y/panel_size_x;
1647 rows = bound(1, floor((sqrt(4 * aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1649 columns = ceil(WEP_COUNT/rows);
1652 float a, type, fullammo;
1654 when = cvar("hud_panel_weapons_complainbubble_time");
1656 fadetime = cvar("hud_panel_weapons_complainbubble_fadetime");
1662 float fullammo_shells, fullammo_nails, fullammo_rockets, fullammo_cells, fullammo_fuel;
1665 wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
1666 float barsize_x, barsize_y, baroffset_x, baroffset_y;
1667 float show_ammo = cvar("hud_panel_weapons_ammo");
1670 fullammo_shells = cvar("hud_panel_weapons_ammo_full_shells");
1671 fullammo_nails = cvar("hud_panel_weapons_ammo_full_nails");
1672 fullammo_rockets = cvar("hud_panel_weapons_ammo_full_rockets");
1673 fullammo_cells = cvar("hud_panel_weapons_ammo_full_cells");
1674 fullammo_fuel = cvar("hud_panel_weapons_ammo_full_fuel");
1675 ammo_color = stov(cvar_string("hud_panel_weapons_ammo_color"));
1676 ammo_alpha = panel_fg_alpha * cvar("hud_panel_weapons_ammo_alpha");
1679 if(wpnsize_x/wpnsize_y > aspect)
1681 barsize_x = aspect * wpnsize_y;
1682 barsize_y = wpnsize_y;
1683 baroffset_x = (wpnsize_x - barsize_x) / 2;
1687 barsize_y = 1/aspect * wpnsize_x;
1688 barsize_x = wpnsize_x;
1689 baroffset_y = (wpnsize_y - barsize_y) / 2;
1693 float show_accuracy;
1694 float weapon_stats, weapon_number;
1695 if(cvar("hud_panel_weapons_accuracy") && acc_levels)
1697 show_accuracy = true;
1699 weapon_stats = getstati(STAT_DAMAGE_HITS);
1700 weapon_number = weapon_stats & 63;
1701 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1703 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1704 weapon_number = weapon_stats & 63;
1705 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1706 if (acc_col_x[0] == -1)
1707 for (i = 0; i < acc_levels; ++i)
1708 acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
1711 float weapons_st = getstati(STAT_WEAPONS);
1712 float label = cvar("hud_panel_weapons_label");
1714 for(i = 0; i < weapon_cnt; ++i)
1716 wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y;
1718 self = weaponorder[i];
1719 weapid = self.impulse;
1721 // draw background behind currently selected weapon
1722 if(self.weapon == activeweapon)
1723 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
1725 // draw the weapon accuracy
1728 float weapon_hit, weapon_damage;
1729 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1732 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1733 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1735 // find the max level lower than weapon_stats
1738 while ( j && weapon_stats < acc_lev[j] )
1741 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
1743 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
1745 color = color + factor * (acc_col[j+1] - color);
1747 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1751 // draw the weapon icon
1752 if((weapid >= 0) && (weapons_st & self.weapons))
1754 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
1756 if(label == 1) // weapon number
1757 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1758 else if(label == 2) // bind
1759 drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1761 // draw ammo status bar
1762 if(show_ammo && weapid != WEP_TUBA && weapid != WEP_LASER && weapid != WEP_PORTO)
1765 type = GetAmmoTypeForWep(weapid);
1767 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
1772 case 0: fullammo = fullammo_shells; break;
1773 case 1: fullammo = fullammo_nails; break;
1774 case 2: fullammo = fullammo_rockets; break;
1775 case 3: fullammo = fullammo_cells; break;
1776 case 4: fullammo = fullammo_fuel; break;
1777 default: fullammo = 60;
1781 wpnpos_x + baroffset_x,
1782 wpnpos_y + baroffset_y,
1783 barsize_x * bound(0, a/fullammo, 1),
1785 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, ammo_color, ammo_alpha, DRAWFLAG_NORMAL);
1786 drawresetcliparea();
1791 // draw a "ghost weapon icon" if you don't have the weapon
1794 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
1797 // draw the complain message
1798 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && cvar("hud_panel_weapons_complainbubble"))
1802 if(complain_weapon_time + when > time)
1805 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1809 if(complain_weapon_time + when > time)
1816 if(complain_weapon_type == 0) {
1818 color = stov(cvar_string("hud_panel_weapons_complainbubble_color_outofammo"));
1820 else if(complain_weapon_type == 1) {
1822 color = stov(cvar_string("hud_panel_weapons_complainbubble_color_donthave"));
1826 color = stov(cvar_string("hud_panel_weapons_complainbubble_color_unavailable"));
1828 float padding = cvar("hud_panel_weapons_complainbubble_padding");
1829 drawpic_aspect_skin(wpnpos + '1 1 0' * padding, "weapon_complainbubble", wpnsize - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
1830 drawstring_aspect(wpnpos + '1 1 0' * padding, s, wpnsize - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
1846 float GetAmmoItemCode(float i)
1850 case 0: return IT_SHELLS;
1851 case 1: return IT_NAILS;
1852 case 2: return IT_ROCKETS;
1853 case 3: return IT_CELLS;
1854 case 4: return IT_FUEL;
1859 string GetAmmoPicture(float i)
1863 case 0: return "ammo_shells";
1864 case 1: return "ammo_bullets";
1865 case 2: return "ammo_rockets";
1866 case 3: return "ammo_cells";
1867 case 4: return "ammo_fuel";
1872 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1875 if(autocvar__hud_configure)
1877 currently_selected = (itemcode == 2); //rockets always selected
1878 a = 31 + mod(itemcode*93, 128);
1881 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1890 if(currently_selected)
1895 vector picpos, numpos;
1896 if(autocvar_hud_panel_ammo_iconalign)
1899 picpos = myPos + eX * 2 * mySize_y;
1903 numpos = myPos + eX * mySize_y;
1907 if (currently_selected)
1908 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1911 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1912 else // "ghost" ammo count
1913 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1915 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1916 else // "ghost" ammo icon
1917 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1922 if(!autocvar__hud_configure)
1924 if(!autocvar_hud_panel_ammo) return;
1925 if(spectatee_status == -1) return;
1928 active_panel = HUD_PANEL_AMMO;
1929 HUD_Panel_UpdateCvars(ammo);
1932 mySize = panel_size;
1934 HUD_Panel_DrawBg(1);
1935 if(panel_bg_padding)
1937 pos += '1 1 0' * panel_bg_padding;
1938 mySize -= '2 2 0' * panel_bg_padding;
1941 float rows, columns, row, column;
1943 if (autocvar_hud_panel_ammo_onlycurrent)
1947 rows = mySize_y/mySize_x;
1948 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1949 // ^^^ ammo item aspect goes here
1951 columns = ceil(AMMO_COUNT/rows);
1953 ammo_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
1958 if(ammo_size_x/ammo_size_y > 3)
1960 newSize = 3 * ammo_size_y;
1961 offset_x = ammo_size_x - newSize;
1962 pos_x += offset_x/2;
1963 ammo_size_x = newSize;
1967 newSize = 1/3 * ammo_size_x;
1968 offset_y = ammo_size_y - newSize;
1969 pos_y += offset_y/2;
1970 ammo_size_y = newSize;
1973 drawfont = hud_bigfont;
1974 float i, stat_items, currently_selected;
1975 if (autocvar_hud_panel_ammo_onlycurrent)
1977 if(autocvar__hud_configure)
1979 DrawAmmoItem(pos, ammo_size, 2, true); //show rockets
1982 stat_items = getstati(STAT_ITEMS);
1983 for (i = 0; i < AMMO_COUNT; ++i) {
1984 currently_selected = stat_items & GetAmmoItemCode(i);
1985 if (currently_selected)
1987 DrawAmmoItem(pos, ammo_size, i, true);
1991 return; // nothing to display
1994 stat_items = getstati(STAT_ITEMS);
1995 for (i = 0; i < AMMO_COUNT; ++i) {
1996 currently_selected = stat_items & GetAmmoItemCode(i);
1997 DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected);
2002 column = column + 1;
2005 drawfont = hud_font;
2008 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float alpha)
2011 float newSize_x, newSize_y;
2012 if(mySize_x/mySize_y > 3)
2014 newSize_x = 3 * mySize_y;
2015 newSize_y = mySize_y;
2017 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
2022 newSize_y = 1/3 * mySize_x;
2023 newSize_x = mySize_x;
2025 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
2029 vector picpos, numpos;
2032 if(iconalign == 1 || iconalign == 3) // right align
2035 picpos = newPos + eX * 2 * newSize_y;
2039 numpos = newPos + eX * newSize_y;
2045 if(iconalign == 0 || iconalign == 3) // left align
2047 numpos = newPos + eX * newSize_y;
2053 picpos = newPos + eX * 2 * newSize_y;
2057 drawfont = hud_bigfont;
2058 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
2059 drawfont = hud_font;
2060 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
2063 void DrawNumIcon_expanding(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float fadelerp)
2066 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
2068 DrawNumIcon(iconalign, myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, left, color, (1 - fadelerp));
2073 void HUD_Powerups(void) {
2074 if(!autocvar__hud_configure)
2076 if(!autocvar_hud_panel_powerups) return;
2077 if(spectatee_status == -1) return;
2078 if not(getstati(STAT_ITEMS) & (IT_STRENGTH | IT_INVINCIBLE)) return;
2079 if (getstati(STAT_HEALTH) <= 0) return;
2082 active_panel = HUD_PANEL_POWERUPS;
2083 HUD_Panel_UpdateCvars(powerups);
2086 mySize = panel_size;
2088 float strength_time, shield_time;
2089 if(autocvar__hud_configure)
2096 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
2097 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
2100 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
2101 if(panel_bg_padding)
2103 pos += '1 1 0' * panel_bg_padding;
2104 mySize -= '2 2 0' * panel_bg_padding;
2107 vector barpos, barsize;
2111 string leftname, rightname;
2112 float leftcnt, rightcnt;
2113 float leftexact, rightexact;
2114 float flip = cvar("hud_panel_powerups_flip");
2116 leftname = "strength";
2117 leftcnt = ceil(strength_time);
2118 leftexact = strength_time;
2120 rightname = "shield";
2121 rightcnt = ceil(shield_time);
2122 rightexact = shield_time;
2124 leftname = "shield";
2125 leftcnt = ceil(shield_time);
2126 leftexact = shield_time;
2128 rightname = "strength";
2129 rightcnt = ceil(strength_time);
2130 rightexact = strength_time;
2133 drawfont = hud_bigfont;
2134 float baralign = cvar("hud_panel_powerups_baralign");
2135 float iconalign = cvar("hud_panel_powerups_iconalign");
2136 float progressbar = cvar("hud_panel_powerups_progressbar");
2137 if (mySize_x/mySize_y > 4)
2143 HUD_Panel_GetProgressBarColorForString(leftname);
2144 HUD_Panel_DrawProgressBar(pos, eX * 0.5 * mySize_x + eY * mySize_y, min(1, leftcnt/30), 0, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2147 DrawNumIcon(iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
2149 DrawNumIcon_expanding(iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
2156 HUD_Panel_GetProgressBarColorForString(rightname);
2157 HUD_Panel_DrawProgressBar(pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, min(1, rightcnt/30), 0, (baralign == 1 || baralign == 4), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2160 DrawNumIcon(iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
2162 DrawNumIcon_expanding(iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1));
2165 else if (mySize_x/mySize_y > 1.5)
2171 HUD_Panel_GetProgressBarColorForString(leftname);
2172 HUD_Panel_DrawProgressBar(pos, eX * mySize_x + eY * 0.5 * mySize_y, min(1, leftcnt/30), 0, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2175 DrawNumIcon(iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
2177 DrawNumIcon_expanding(iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
2184 HUD_Panel_GetProgressBarColorForString(rightname);
2185 HUD_Panel_DrawProgressBar(pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, min(1, rightcnt/30), 0, (baralign == 1 || baralign == 4), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2188 DrawNumIcon(iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
2190 DrawNumIcon_expanding(iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1));
2197 if(iconalign == 1 || iconalign == 3) { // down align
2198 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2199 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2200 } else { // up align
2201 picpos = pos + eX * 0.05 * mySize_x;
2202 numpos = pos + eY * 0.4 * mySize_x;
2207 HUD_Panel_GetProgressBarColorForString(leftname);
2208 HUD_Panel_DrawProgressBar(pos, eX * 0.5 * mySize_x + eY * mySize_y, min(1, leftcnt/30), 1, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2211 drawpic_aspect_skin_expanding(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, bound(0, (leftcnt - leftexact) / 0.5, 1));
2213 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2214 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2219 if(iconalign == 0 || iconalign == 3) { // up align
2220 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2221 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2222 } else { // down align
2223 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2224 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2229 HUD_Panel_GetProgressBarColorForString(rightname);
2230 HUD_Panel_DrawProgressBar(pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, min(1, rightcnt/30), 1, (baralign == 1 || baralign == 4), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2233 drawpic_aspect_skin_expanding(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, bound(0, (rightcnt - rightexact) / 0.5, 1));
2235 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2236 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2239 drawfont = hud_font;
2242 // Health/armor (#3)
2244 void HUD_HealthArmor(void)
2246 if(!autocvar__hud_configure)
2248 if(!autocvar_hud_panel_healtharmor) return;
2249 if(spectatee_status == -1) return;
2252 active_panel = HUD_PANEL_HEALTHARMOR;
2253 HUD_Panel_UpdateCvars(healtharmor);
2256 mySize = panel_size;
2258 HUD_Panel_DrawBg(1);
2259 if(panel_bg_padding)
2261 pos += '1 1 0' * panel_bg_padding;
2262 mySize -= '2 2 0' * panel_bg_padding;
2265 float armor, health, fuel;
2266 armor = getstati(STAT_ARMOR);
2267 health = getstati(STAT_HEALTH);
2268 fuel = getstati(STAT_FUEL);
2270 if(autocvar__hud_configure)
2280 vector barpos, barsize;
2284 drawfont = hud_bigfont;
2285 float baralign = cvar("hud_panel_healtharmor_baralign");
2286 float iconalign = cvar("hud_panel_healtharmor_iconalign");
2287 float progressbar = cvar("hud_panel_healtharmor_progressbar");
2288 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
2291 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2297 if(v_z) // NOT fully armored
2299 biggercount = "health";
2302 HUD_Panel_GetProgressBarColor(health);
2303 HUD_Panel_DrawProgressBar(pos, mySize, min(1, x/400), 0, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2306 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);
2310 biggercount = "armor";
2313 HUD_Panel_GetProgressBarColor(armor);
2314 HUD_Panel_DrawProgressBar(pos, mySize, min(1, x/400), 0, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2317 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);
2319 DrawNumIcon(iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200), 1);
2323 HUD_Panel_GetProgressBarColor(fuel);
2324 HUD_Panel_DrawProgressBar(pos, eX * mySize_x + eY * 0.2 * mySize_y, min(1, fuel/100), 0, (baralign == 1 || baralign == 4), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2329 string leftname, rightname;
2330 float leftcnt, rightcnt;
2331 float leftactive, rightactive;
2332 float leftalpha, rightalpha;
2333 float flip = cvar("hud_panel_healtharmor_flip");
2334 if (flip) { // old style layout with armor left/top of health
2339 leftalpha = min((armor+10)/55, 1);
2341 rightname = "health";
2346 leftname = "health";
2351 rightname = "armor";
2355 rightalpha = min((armor+10)/55, 1);
2358 if (mySize_x/mySize_y > 4)
2364 HUD_Panel_GetProgressBarColorForString(leftname);
2365 HUD_Panel_DrawProgressBar(pos, eX * 0.5 * mySize_x + eY * mySize_y, min(1, leftcnt/200), 0, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2367 DrawNumIcon(iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
2374 HUD_Panel_GetProgressBarColorForString(rightname);
2375 HUD_Panel_DrawProgressBar(pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, min(1, rightcnt/200), 0, (baralign == 1 || baralign == 4), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2377 DrawNumIcon(iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(rightcnt, 200), 1);
2382 HUD_Panel_GetProgressBarColor(fuel);
2383 HUD_Panel_DrawProgressBar(pos, eX * mySize_x + eY * 0.2 * mySize_y, min(1, fuel/100), 0, (baralign == 1 || baralign == 4), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2386 else if (mySize_x/mySize_y > 1.5)
2392 HUD_Panel_GetProgressBarColorForString(leftname);
2393 HUD_Panel_DrawProgressBar(pos, eX * mySize_x + eY * 0.5 * mySize_y, min(1, leftcnt/200), 0, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2395 DrawNumIcon(iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
2402 HUD_Panel_GetProgressBarColorForString(rightname);
2403 HUD_Panel_DrawProgressBar(pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, min(1, rightcnt/200), 0, (baralign == 1 || baralign == 4), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2405 DrawNumIcon(iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(rightcnt, 200), 1);
2410 HUD_Panel_GetProgressBarColor(fuel);
2411 HUD_Panel_DrawProgressBar(pos, eX * mySize_x + eY * 0.1 * mySize_y, min(1, fuel/100), 0, (baralign == 1 || baralign == 4), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2418 if(iconalign == 1 || iconalign == 3) { // down align
2419 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2420 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2421 } else { // up align
2422 picpos = pos + eX * 0.05 * mySize_x;
2423 numpos = pos + eY * 0.4 * mySize_x;
2428 HUD_Panel_GetProgressBarColorForString(leftname);
2429 HUD_Panel_DrawProgressBar(pos, eX * 0.5 * mySize_x + eY * mySize_y, min(1, leftcnt/200), 1, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2431 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2432 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, HUD_Get_Num_Color(leftcnt, 200), panel_fg_alpha, DRAWFLAG_NORMAL);
2437 if(iconalign == 0 || iconalign == 3) { // up align
2438 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2439 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2440 } else { // down align
2441 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2442 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2447 HUD_Panel_GetProgressBarColorForString(rightname);
2448 HUD_Panel_DrawProgressBar(pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, min(1, rightcnt/200), 1, (baralign == 1 || baralign == 4), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2450 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2451 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, HUD_Get_Num_Color(rightcnt, 200), panel_fg_alpha, DRAWFLAG_NORMAL);
2456 HUD_Panel_GetProgressBarColor(fuel);
2457 HUD_Panel_DrawProgressBar(pos, eX * 0.05 * mySize_x + eY * mySize_y, min(1, fuel/100), 1, (baralign == 1 || baralign == 4), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2461 drawfont = hud_font;
2464 // Notification area (#4)
2467 string Weapon_SuicideMessage(float deathtype)
2469 w_deathtype = deathtype;
2470 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2471 return w_deathtypestring;
2474 string Weapon_KillMessage(float deathtype)
2476 w_deathtype = deathtype;
2477 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2478 return w_deathtypestring;
2481 #define KN_MAX_ENTRIES 10
2483 float killnotify_times[KN_MAX_ENTRIES];
2484 float killnotify_deathtype[KN_MAX_ENTRIES];
2485 float killnotify_actiontype[KN_MAX_ENTRIES]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2486 string killnotify_attackers[KN_MAX_ENTRIES];
2487 string killnotify_victims[KN_MAX_ENTRIES];
2488 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2492 kn_index = KN_MAX_ENTRIES-1;
2493 killnotify_times[kn_index] = time;
2494 killnotify_deathtype[kn_index] = wpn;
2495 killnotify_actiontype[kn_index] = actiontype;
2496 if(killnotify_attackers[kn_index])
2497 strunzone(killnotify_attackers[kn_index]);
2498 killnotify_attackers[kn_index] = strzone(attacker);
2499 if(killnotify_victims[kn_index])
2500 strunzone(killnotify_victims[kn_index]);
2501 killnotify_victims[kn_index] = strzone(victim);
2504 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
2507 float alsoprint, gentle;
2508 alsoprint = (cvar("hud_panel_notify_print") || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2509 gentle = (cvar("cl_gentle") || cvar("cl_gentle_messages"));
2511 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
2514 if(msg == MSG_SUICIDE) {
2515 w = DEATH_WEAPONOF(type);
2517 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2519 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
2520 } else if (type == DEATH_KILL) {
2521 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2523 print ("^1",s1, "^1 couldn't take it anymore\n");
2524 } else if (type == DEATH_ROT) {
2525 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2527 print ("^1",s1, "^1 died\n");
2528 } else if (type == DEATH_NOAMMO) {
2529 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2531 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2532 } else if (type == DEATH_CAMP) {
2533 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2535 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2536 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2537 HUD_KillNotify_Push(s1, "", 0, type);
2539 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2540 } else if (type == DEATH_CHEAT) {
2541 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2543 print ("^1",s1, "^1 unfairly eliminated themself\n");
2544 } else if (type == DEATH_FIRE) {
2545 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2547 print ("^1",s1, "^1 burned to death\n");
2548 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2549 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2551 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2554 if (stof(s2) > 2) // killcount > 2
2555 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2556 } else if(msg == MSG_KILL) {
2557 w = DEATH_WEAPONOF(type);
2559 if((w == WEP_CAMPINGRIFLE || w == WEP_MINSTANEX) && type & HITTYPE_HEADSHOT) // all headshot weapons go here
2560 HUD_KillNotify_Push(s1, s2, 1, DEATH_HEADSHOT);
2562 HUD_KillNotify_Push(s1, s2, 1, type);
2565 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
2567 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2568 HUD_KillNotify_Push(s1, s2, 1, type);
2572 print ("^1", s1, "^1 took action against a team mate\n");
2574 print ("^1", s1, "^1 mows down a team mate\n");
2577 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2579 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2581 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2583 else if (stof(s2) > 2) {
2585 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2587 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2590 else if(type == KILL_FIRST_BLOOD)
2591 print("^1",s1, "^1 drew first blood", "\n");
2592 else if (type == DEATH_TELEFRAG) {
2593 HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
2595 print ("^1",s2, "^1 tried to occupy ", s1, "^1's teleport destination space\n");
2597 print ("^1",s2, "^1 was telefragged by ", s1, "\n");
2599 else if (type == DEATH_DROWN) {
2600 HUD_KillNotify_Push(s1, s2, 1, DEATH_DROWN);
2602 print ("^1",s2, "^1 was drowned by ", s1, "\n");
2604 else if (type == DEATH_SLIME) {
2605 HUD_KillNotify_Push(s1, s2, 1, DEATH_SLIME);
2607 print ("^1",s2, "^1 was slimed by ", s1, "\n");
2609 else if (type == DEATH_LAVA) {
2610 HUD_KillNotify_Push(s1, s2, 1, DEATH_LAVA);
2612 print ("^1",s2, "^1 was cooked by ", s1, "\n");
2614 else if (type == DEATH_FALL) {
2615 HUD_KillNotify_Push(s1, s2, 1, DEATH_FALL);
2617 print ("^1",s2, "^1 was grounded by ", s1, "\n");
2619 else if (type == DEATH_SHOOTING_STAR) {
2620 HUD_KillNotify_Push(s1, s2, 1, DEATH_SHOOTING_STAR);
2622 print ("^1",s2, "^1 was shot into space by ", s1, "\n");
2624 else if (type == DEATH_SWAMP) {
2625 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2627 print ("^1",s2, "^1 was conserved by ", s1, "\n");
2629 else if (type == DEATH_HURTTRIGGER)
2631 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
2633 print("^1",s2, "^1 was thrown into a world of hurt by ", s1, "\n");
2634 } else if(type == DEATH_SBCRUSH) {
2635 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2637 print ("^1",s2, "^1 was crushed by ^1", s1, "\n");
2638 } else if(type == DEATH_SBMINIGUN) {
2639 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2641 print ("^1",s2, "^1 got shredded by ^1", s1, "\n");
2642 } else if(type == DEATH_SBROCKET) {
2643 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2645 print ("^1",s2, "^1 was blased to bits by ^1", s1, "\n");
2646 } else if(type == DEATH_SBBLOWUP) {
2647 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2649 print ("^1",s2, "^1 got caught in the destruction of ^1", s1, "'s vehicle\n");
2650 } else if(type == DEATH_WAKIGUN) {
2651 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2653 print ("^1",s2, "^1 was bolted down by ^1", s1, "\n");
2654 } else if(type == DEATH_WAKIROCKET) {
2655 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2657 print ("^1",s2, "^1 could find no shelter from ^1", s1, "'s rockets\n");
2658 } else if(type == DEATH_WAKIBLOWUP) {
2659 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2661 print ("^1",s2, "^1 dies when ^1", s1, "'s wakizashi dies.\n");
2662 } else if(type == DEATH_TURRET) {
2663 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2665 print ("^1",s2, "^1 was pushed into the line of fire by ^1", s1, "\n");
2666 } else if(type == DEATH_TOUCHEXPLODE) {
2667 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2669 print ("^1",s2, "^1 was pushed into an accident by ^1", s1, "\n");
2670 } else if(type == DEATH_CHEAT) {
2671 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2673 print ("^1",s2, "^1 was unfairly eliminated by ^1", s1, "\n");
2674 } else if (type == DEATH_FIRE) {
2675 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2677 print ("^1",s2, "^1 was burnt to death by ^1", s1, "\n");
2678 } else if (type == DEATH_CUSTOM) {
2679 HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM);
2681 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
2682 } else if (type == DEATH_HURTTRIGGER) {
2683 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
2685 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
2687 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2689 print ("^1",s2, "^1 was fragged by ", s1, "\n");
2691 } else if(msg == MSG_SPREE) {
2692 if(type == KILL_END_SPREE) {
2694 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2696 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2697 } else if(type == KILL_SPREE) {
2699 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2701 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2702 } else if(type == KILL_SPREE_3) {
2704 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2706 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2707 } else if(type == KILL_SPREE_5) {
2709 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2711 print (s1,"^7 unleashes ^1RAGE\n");
2712 } else if(type == KILL_SPREE_10) {
2714 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2716 print (s1,"^7 starts the ^1MASSACRE!\n");
2717 } else if(type == KILL_SPREE_15) {
2719 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2721 print (s1,"^7 executes ^1MAYHEM!\n");
2722 } else if(type == KILL_SPREE_20) {
2724 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2726 print (s1,"^7 is a ^1BERSERKER!\n");
2727 } else if(type == KILL_SPREE_25) {
2729 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2731 print (s1,"^7 inflicts ^1CARNAGE!\n");
2732 } else if(type == KILL_SPREE_30) {
2734 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2736 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2738 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2739 if (type == DEATH_DROWN) {
2740 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2744 print ("^1",s1, "^1 was in the water for too long\n");
2746 print ("^1",s1, "^1 drowned\n");
2748 } else if (type == DEATH_SLIME) {
2749 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2751 print ("^1",s1, "^1 was slimed\n");
2752 } else if (type == DEATH_LAVA) {
2753 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2757 print ("^1",s1, "^1 found a hot place\n");
2759 print ("^1",s1, "^1 turned into hot slag\n");
2761 } else if (type == DEATH_FALL) {
2762 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2766 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2768 print ("^1",s1, "^1 hit the ground with a crunch\n");
2770 } else if (type == DEATH_SHOOTING_STAR) {
2771 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2773 print ("^1",s1, "^1 became a shooting star\n");
2774 } else if (type == DEATH_SWAMP) {
2775 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2779 print ("^1",s1, "^1 discovered a swamp\n");
2781 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2783 } else if(type == DEATH_TURRET) {
2784 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2786 print ("^1",s1, "^1 was mowed down by a turret \n");
2787 } else if (type == DEATH_CUSTOM) {
2788 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2790 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
2791 } else if (type == DEATH_HURTTRIGGER) {
2792 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2794 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
2795 } else if(type == DEATH_TOUCHEXPLODE) {
2796 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2798 print ("^1",s1, "^1 died in an accident\n");
2799 } else if(type == DEATH_CHEAT) {
2800 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2802 print ("^1",s1, "^1 was unfairly eliminated\n");
2803 } else if(type == DEATH_FIRE) {
2804 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2808 print ("^1",s1, "^1 felt a little hot\n");
2810 print ("^1",s1, "^1 burnt to death\n");
2813 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2817 print ("^1",s1, "^1 needs a restart\n");
2819 print ("^1",s1, "^1 died\n");
2822 } else if(msg == MSG_KILL_ACTION_SPREE) {
2824 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2826 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2827 } else if(msg == MSG_INFO) {
2828 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2829 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2830 print(s1, "^7 got the ", s2, "\n");
2831 } else if(type == INFO_LOSTFLAG) {
2832 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2833 print(s1, "^7 lost the ", s2, "\n");
2834 } else if(type == INFO_PICKUPFLAG) {
2835 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2836 print(s1, "^7 picked up the ", s2, "\n");
2837 } else if(type == INFO_RETURNFLAG) {
2838 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2839 print(s1, "^7 returned the ", s2, "\n");
2840 } else if(type == INFO_CAPTUREFLAG) {
2841 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
2842 print(s1, "^7 captured the ", s2, s3, "\n");
2844 } else if(msg == MSG_RACE) {
2845 if(type == RACE_SERVER_RECORD) {
2846 HUD_KillNotify_Push(s1, s2, 1, RACE_SERVER_RECORD);
2848 else if(type == RACE_NEW_RANK) {
2849 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_RANK);
2851 else if(type == RACE_NEW_TIME) {
2852 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_TIME);
2854 else if(type == RACE_FAIL) {
2855 HUD_KillNotify_Push(s1, s2, 1, RACE_FAIL);
2860 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2862 void HUD_Centerprint(string s1, string s2, float type, float msg)
2865 gentle = (cvar("cl_gentle") || cvar("cl_gentle_messages"));
2866 if(msg == MSG_SUICIDE) {
2867 if (type == DEATH_TEAMCHANGE) {
2868 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2869 } else if (type == DEATH_AUTOTEAMCHANGE) {
2870 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2871 } else if (type == DEATH_CAMP) {
2873 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2875 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2876 } else if (type == DEATH_NOAMMO) {
2878 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2880 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2881 } else if (type == DEATH_ROT) {
2883 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2885 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2886 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2888 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2890 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2891 } else if (type == DEATH_QUIET) {
2893 } else { // generic message
2895 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2897 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2899 } else if(msg == MSG_KILL) {
2900 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2902 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2904 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2906 } else if (type == KILL_FIRST_BLOOD) {
2908 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2910 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2912 } else if (type == KILL_FIRST_VICTIM) {
2914 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2916 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2918 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2920 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2922 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2924 } else if (type == KILL_TYPEFRAGGED) {
2926 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2928 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2930 } else if (type == KILL_FRAG) {
2932 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2934 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2936 } else { // generic message
2938 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2940 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2943 } else if(msg == MSG_KILL_ACTION) {
2944 // TODO: invent more centerprints here?
2945 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2949 void HUD_Notify (void)
2951 if(!autocvar_hud_panel_notify && !autocvar__hud_configure)
2954 active_panel = HUD_PANEL_NOTIFY;
2955 HUD_Panel_UpdateCvars(notify);
2958 mySize = panel_size;
2960 HUD_Panel_DrawBg(1);
2961 if(panel_bg_padding)
2963 pos += '1 1 0' * panel_bg_padding;
2964 mySize -= '2 2 0' * panel_bg_padding;
2967 float entries, height;
2968 entries = bound(1, floor(KN_MAX_ENTRIES * mySize_y/mySize_x), KN_MAX_ENTRIES);
2969 height = mySize_y/entries;
2972 fontsize = '0.5 0.5 0' * height;
2976 when = cvar("hud_panel_notify_time");
2978 fadetime = cvar("hud_panel_notify_fadetime");
2982 vector pos_attacker, pos_victim;
2984 float width_attacker;
2985 string attacker, victim;
2987 float i, j, w, step, limit;
2988 if(cvar("hud_panel_notify_flip")) //order items from the top down
2994 else //order items from the bottom up
3001 for(j = kn_index; i != limit; i += step, ++j)
3003 if(autocvar__hud_configure)
3007 else // inverse order
3008 a = entries - 1 - i;
3009 attacker = textShortenToWidth(strcat("Player", ftos(a+1)), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3010 victim = textShortenToWidth(strcat("Player", ftos(a+2)), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3011 s = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname);
3012 a = bound(0, (when - a) / 4, 1);
3013 goto hud_config_notifyprint;
3016 if (j == KN_MAX_ENTRIES)
3019 if(killnotify_times[j] + when > time)
3023 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
3037 w = DEATH_WEAPONOF(killnotify_deathtype[j]);
3039 // TODO: maybe print in team colors?
3042 if(killnotify_actiontype[j] == 0)
3044 if(killnotify_deathtype[j] == DEATH_GENERIC)
3048 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
3050 s = "notify_outofammo";
3052 else if(killnotify_deathtype[j] == DEATH_KILL)
3054 s = "notify_selfkill";
3056 else if(killnotify_deathtype[j] == DEATH_CAMP)
3058 s = "notify_camping";
3060 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
3062 s = "notify_teamkill_red";
3064 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
3066 s = "notify_teamkill_blue";
3068 else if(killnotify_deathtype[j] == DEATH_DROWN)
3072 else if(killnotify_deathtype[j] == DEATH_SLIME)
3076 else if(killnotify_deathtype[j] == DEATH_LAVA)
3080 else if(killnotify_deathtype[j] == DEATH_FALL)
3084 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
3086 s = "notify_shootingstar";
3088 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
3092 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
3094 if(killnotify_victims[j] == "^1RED^7 flag")
3096 s = "notify_red_taken";
3100 s = "notify_blue_taken";
3103 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
3105 if(killnotify_victims[j] == "^1RED^7 flag")
3107 s = "notify_red_returned";
3111 s = "notify_blue_returned";
3114 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
3116 if(killnotify_victims[j] == "^1RED^7 flag")
3118 s = "notify_red_lost";
3122 s = "notify_blue_lost";
3125 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
3127 if(killnotify_victims[j] == "^1RED^7 flag")
3129 s = "notify_red_captured";
3133 s = "notify_blue_captured";
3136 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3137 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
3138 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
3142 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3143 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3146 // X [did action to] Y
3149 if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
3151 s = "notify_melee_laser";
3153 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_SHOTGUN)
3155 s = "notify_melee_shotgun";
3157 else if(WEP_VALID(w))
3159 self = get_weaponinfo(w);
3160 s = strcat("weapon", self.netname);
3162 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
3164 s = "notify_teamkill_red";
3166 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
3168 s = "notify_teamkill_red";
3170 else if(killnotify_deathtype[j] == DEATH_TELEFRAG)
3172 s = "notify_telefrag";
3174 else if(killnotify_deathtype[j] == DEATH_DROWN)
3178 else if(killnotify_deathtype[j] == DEATH_SLIME)
3182 else if(killnotify_deathtype[j] == DEATH_LAVA)
3186 else if(killnotify_deathtype[j] == DEATH_FALL)
3190 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
3192 s = "notify_shootingstar";
3194 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
3198 else if(killnotify_deathtype[j] == DEATH_HEADSHOT)
3200 s = "notify_headshot";
3202 else if(killnotify_deathtype[j] == RACE_SERVER_RECORD)
3204 s = "race_newrecordserver";
3206 else if(killnotify_deathtype[j] == RACE_NEW_RANK)
3208 s = "race_newrankyellow";
3210 else if(killnotify_deathtype[j] == RACE_NEW_TIME)
3214 else if(killnotify_deathtype[j] == RACE_FAIL)
3219 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3220 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3221 :hud_config_notifyprint
3222 width_attacker = stringwidth(attacker, TRUE, fontsize);
3223 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
3224 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
3225 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
3229 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3230 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3231 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3240 string seconds_tostring(float sec)
3243 minutes = floor(sec / 60);
3245 sec -= minutes * 60;
3248 s = ftos(100 + sec);
3250 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3253 void HUD_Timer(void)
3255 if(!autocvar_hud_panel_timer && !autocvar__hud_configure)
3258 active_panel = HUD_PANEL_TIMER;
3259 HUD_Panel_UpdateCvars(timer);
3262 mySize = panel_size;
3264 HUD_Panel_DrawBg(1);
3265 if(panel_bg_padding)
3267 pos += '1 1 0' * panel_bg_padding;
3268 mySize -= '2 2 0' * panel_bg_padding;
3272 float timelimit, elapsedTime, timeleft, minutesLeft;
3274 timelimit = getstatf(STAT_TIMELIMIT);
3276 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3277 timeleft = ceil(timeleft);
3279 minutesLeft = floor(timeleft / 60);
3282 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3283 timer_color = '1 1 1'; //white
3284 else if(minutesLeft >= 1)
3285 timer_color = '1 1 0'; //yellow
3287 timer_color = '1 0 0'; //red
3289 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
3290 if (time < getstatf(STAT_GAMESTARTTIME)) {
3291 //while restart is still active, show 00:00
3292 timer = seconds_tostring(0);
3294 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3295 timer = seconds_tostring(elapsedTime);
3298 timer = seconds_tostring(timeleft);
3301 drawfont = hud_bigfont;
3302 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3303 drawfont = hud_font;
3308 void HUD_Radar(void)
3310 if ((autocvar_hud_panel_radar == 0 || (autocvar_hud_panel_radar != 2 && !teamplay)) && !autocvar__hud_configure)
3313 active_panel = HUD_PANEL_RADAR;
3314 HUD_Panel_UpdateCvars(radar);
3317 mySize = panel_size;
3319 HUD_Panel_DrawBg(1);
3320 if(panel_bg_padding)
3322 pos += '1 1 0' * panel_bg_padding;
3323 mySize -= '2 2 0' * panel_bg_padding;
3328 float scale2d, normalsize, bigsize;
3331 teamradar_origin2d = pos + 0.5 * mySize;
3332 teamradar_size2d = mySize;
3334 if(minimapname == "")
3337 teamradar_loadcvars();
3339 switch(hud_panel_radar_zoommode)
3343 f = current_zoomfraction;
3346 f = 1 - current_zoomfraction;
3356 switch(hud_panel_radar_rotation)
3359 teamradar_angle = view_angles_y - 90;
3362 teamradar_angle = 90 * hud_panel_radar_rotation;
3366 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3367 teamradar_size2d = mySize;
3369 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3371 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3372 if(hud_panel_radar_rotation == 0)
3374 // max-min distance must fit the radar in any rotation
3375 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3379 vector c0, c1, c2, c3, span;
3380 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3381 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3382 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3383 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3385 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3386 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3388 // max-min distance must fit the radar in x=x, y=y
3390 teamradar_size2d_x * scale2d / (1.05 * span_x),
3391 teamradar_size2d_y * scale2d / (1.05 * span_y)
3395 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
3396 if(bigsize > normalsize)
3397 normalsize = bigsize;
3401 + (1 - f) * normalsize;
3402 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3403 f * (mi_min + mi_max) * 0.5
3404 + (1 - f) * view_origin);
3413 draw_teamradar_background(hud_panel_radar_foreground_alpha);
3415 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3416 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3417 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3418 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3419 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3421 color2 = GetPlayerColor(tm.sv_entnum);
3422 //if(color == COLOR_SPECTATOR || color == color2)
3423 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3425 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3427 drawresetcliparea();
3432 void HUD_UpdatePlayerTeams();
3433 void HUD_Score(void)
3435 if(!autocvar__hud_configure && !autocvar_hud_panel_score)
3438 active_panel = HUD_PANEL_SCORE;
3439 HUD_Panel_UpdateCvars(score);
3442 mySize = panel_size;
3444 HUD_Panel_DrawBg(1);
3445 if(panel_bg_padding)
3447 pos += '1 1 0' * panel_bg_padding;
3448 mySize -= '2 2 0' * panel_bg_padding;
3451 float score, distribution;
3453 vector distribution_color;
3455 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3457 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3458 string timer, distrtimer;
3460 pl = players.sort_next;
3463 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3464 if(pl.scores[ps_primary] == 0)
3467 score = me.(scores[ps_primary]);
3468 timer = TIME_ENCODED_TOSTRING(score);
3470 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3471 // distribution display
3472 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3474 distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS);
3476 if (distribution <= 0) {
3477 distribution_color = '0 1 0';
3481 distribution_color = '1 0 0';
3484 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);
3486 // race record display
3487 if (distribution <= 0)
3488 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3489 drawfont = hud_bigfont;
3490 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3491 drawfont = hud_font;
3492 } else if (!teamplay) { // non-teamgames
3493 if ((spectatee_status == -1 && !autocvar__hud_configure) || cvar("hud_panel_score_rankings"))
3495 #define SCOREPANEL_MAX_ENTRIES 6
3496 #define SCOREPANEL_ASPECTRATIO 2
3497 float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
3498 float height = mySize_y/entries;
3499 vector fontsize = '0.9 0.9 0' * height;
3500 pos_y += height * (1 - 0.9) / 2;
3505 float name_size = mySize_x*0.75;
3506 float i, me_printed;
3508 if (autocvar__hud_configure)
3510 score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
3511 for (i=0; i<entries; ++i)
3513 //simulate my score is lower than all displayed players,
3514 //so that I don't appear at all showing pure rankings.
3515 //This is to better show the difference between the 2 ranking views
3516 if (i == entries-1 && cvar("hud_panel_score_rankings") == 1)
3519 drawfill(pos - eY * (height * (1 - 0.9) / 2), eX * mySize_x + eY * height, rgb, 0.3 * panel_fg_alpha, DRAWFLAG_NORMAL);
3520 s = GetPlayerName(pl.sv_entnum);
3525 s = strcat("Player", ftos(i+1));
3529 s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
3530 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3531 drawstring(pos + eX * mySize_x*0.79, ftos(score), fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3537 if (!scoreboard_fade_alpha) // the scoreboard too calls HUD_UpdatePlayerTeams
3538 HUD_UpdatePlayerTeams();
3540 for (pl = players.sort_next, i=0; pl && i<entries; pl = pl.sort_next, ++i)
3542 if (pl.team == COLOR_SPECTATOR)
3545 if (i == entries-1 && !me_printed && pl != me)
3546 if (cvar("hud_panel_score_rankings") == 1 && spectatee_status != -1)
3548 for (pl = me.sort_next; pl; pl = pl.sort_next)
3549 if (pl.team != COLOR_SPECTATOR)
3553 rgb = '1 1 0'; //not last but not among the leading players: yellow
3555 rgb = '1 0 0'; //last: red
3562 rgb = '0 1 0'; //first: green
3564 drawfill(pos - eY * (height * (1 - 0.9) / 2), eX * mySize_x + eY * height, rgb, 0.3 * panel_fg_alpha, DRAWFLAG_NORMAL);
3566 s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
3567 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3568 drawstring(pos + eX * mySize_x*0.79, ftos(pl.(scores[ps_primary])), fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3573 // me vector := [team/connected frags id]
3574 pl = players.sort_next;
3578 if(autocvar__hud_configure)
3581 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3585 score = me.(scores[ps_primary]);
3586 if(autocvar__hud_configure)
3589 if(distribution >= 5)
3590 distribution_color = eY;
3591 else if(distribution >= 0)
3592 distribution_color = '1 1 1';
3593 else if(distribution >= -5)
3594 distribution_color = '1 1 0';
3596 distribution_color = eX;
3598 string distribution_str;
3599 distribution_str = ftos(distribution);
3600 if (distribution >= 0)
3602 if (distribution > 0)
3603 distribution_str = strcat("+", distribution_str);
3604 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3606 drawfont = hud_bigfont;
3607 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3608 drawfont = hud_font;
3609 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);
3610 } else { // teamgames
3611 float max_fragcount;
3612 max_fragcount = -99;
3614 float scores_count, row, column, rows, columns;
3616 vector score_pos, score_size; //for scores other than myteam
3617 if (spectatee_status == -1)
3619 if (autocvar__hud_configure)
3621 else for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3622 if(tm.team == COLOR_SPECTATOR)
3626 rows = mySize_y/mySize_x;
3627 rows = bound(1, floor((sqrt(4 * (3/1) * rows * scores_count + rows * rows) + rows + 0.5) / 2), scores_count);
3628 // ^^^ ammo item aspect goes here
3630 columns = ceil(scores_count/rows);
3632 score_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
3635 if(score_size_x/score_size_y > 3)
3637 newSize = 3 * score_size_y;
3638 offset_x = score_size_x - newSize;
3639 pos_x += offset_x/2;
3640 score_size_x = newSize;
3644 newSize = 1/3 * score_size_x;
3645 offset_y = score_size_y - newSize;
3646 pos_y += offset_y/2;
3647 score_size_y = newSize;
3651 score_size = eX * mySize_x*(1/4) + eY * mySize_y*(1/3);
3652 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3653 if(tm.team == COLOR_SPECTATOR)
3655 score = tm.(teamscores[ts_primary]);
3656 if(autocvar__hud_configure)
3659 if (score > max_fragcount)
3660 max_fragcount = score;
3662 if (spectatee_status == -1)
3664 score_pos = pos + eX * column * (score_size_x + offset_x) + eY * row * (score_size_y + offset_y);
3665 if (max_fragcount == score)
3666 HUD_Panel_DrawHighlight(score_pos, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3667 drawfont = hud_bigfont;
3668 drawstring_aspect(score_pos, ftos(score), score_size, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3669 drawfont = hud_font;
3677 else if(tm.team == myteam) {
3678 if (max_fragcount == score)
3679 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3680 drawfont = hud_bigfont;
3681 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3682 drawfont = hud_font;
3684 if (max_fragcount == score)
3685 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);
3686 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);
3695 void HUD_RaceTimer (void) {
3696 if(!autocvar__hud_configure)
3698 if(!autocvar_hud_panel_racetimer) return;
3699 if(!(gametype == GAME_RACE || gametype == GAME_CTS)) return;
3700 if(spectatee_status == -1) return;
3703 active_panel = HUD_PANEL_RACETIMER;
3704 HUD_Panel_UpdateCvars(racetimer);
3707 mySize = panel_size;
3709 HUD_Panel_DrawBg(1);
3710 if(panel_bg_padding)
3712 pos += '1 1 0' * panel_bg_padding;
3713 mySize -= '2 2 0' * panel_bg_padding;
3716 // always force 4:1 aspect
3718 if(mySize_x/mySize_y > 4)
3720 newSize_x = 4 * mySize_y;
3721 newSize_y = mySize_y;
3723 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3727 newSize_y = 1/4 * mySize_x;
3728 newSize_x = mySize_x;
3730 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3734 drawfont = hud_bigfont;
3736 string s, forcetime;
3738 if(autocvar__hud_configure)
3741 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);
3742 s = "^1Intermediate 1 (+15.42)";
3743 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);
3744 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3745 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);
3747 else if(race_checkpointtime)
3749 a = bound(0, 2 - (time - race_checkpointtime), 1);
3752 if(a > 0) // just hit a checkpoint?
3754 if(race_checkpoint != 254)
3756 if(race_time && race_previousbesttime)
3757 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3759 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3761 forcetime = TIME_ENCODED_TOSTRING(race_time);
3766 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3768 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3769 if(a > 0) // next one?
3771 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3776 if(s != "" && a > 0)
3778 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);
3781 if(race_penaltytime)
3783 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3786 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3787 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);
3793 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3794 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);
3799 if(race_laptime && race_checkpoint != 255)
3801 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3802 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);
3807 if(race_mycheckpointtime)
3809 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3810 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3811 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);
3813 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3815 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3816 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3817 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);
3820 if(race_penaltytime && !race_penaltyaccumulator)
3822 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3823 a = bound(0, (1 + t - time), 1);
3827 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3829 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3830 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);
3835 drawfont = hud_font;
3840 float vote_yescount;
3843 float vote_highlighted; // currently selected vote
3845 float vote_active; // is there an active vote?
3846 float vote_prev; // previous state of vote_active to check for a change
3848 float vote_change; // "time" when vote_active changed
3850 void HUD_VoteWindow(void)
3852 if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
3855 vote_called_vote = strzone(strcat("^2Name ^7instead of \"^1Unregistered player\"", " ^7in stats"));
3858 if(!autocvar_hud_panel_vote && !autocvar__hud_configure)
3861 if(!autocvar__hud_configure)
3863 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
3864 panel_bg_alpha_str = cvar_string("hud_panel_vote_bg_alpha");
3866 if(panel_bg_alpha_str == "") {
3867 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
3869 panel_bg_alpha = stof(panel_bg_alpha_str);
3874 if(vote_active != vote_prev) {
3876 vote_prev = vote_active;
3879 if(vote_active || autocvar__hud_configure)
3880 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3882 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3884 if(autocvar__hud_configure)
3894 active_panel = HUD_PANEL_VOTE;
3895 HUD_Panel_UpdateCvars(vote);
3898 mySize = panel_size;
3900 if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
3902 panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight;
3903 panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight;
3906 a = vote_alpha * bound(cvar("hud_panel_vote_alreadyvoted_alpha"), 1 - vote_highlighted, 1);
3907 HUD_Panel_DrawBg(a);
3908 a = panel_fg_alpha * a;
3910 if(panel_bg_padding)
3912 pos += '1 1 0' * panel_bg_padding;
3913 mySize -= '2 2 0' * panel_bg_padding;
3916 // always force 3:1 aspect
3918 if(mySize_x/mySize_y > 3)
3920 newSize_x = 3 * mySize_y;
3921 newSize_y = mySize_y;
3923 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3927 newSize_y = 1/3 * mySize_x;
3928 newSize_x = mySize_x;
3930 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3934 s = "A vote has been called for:";
3935 if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
3936 s = "Allow servers to store and display your name?";
3937 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3938 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1/8), stringwidth_colors);
3939 if(autocvar__hud_configure)
3940 s = "^1Configure the HUD";
3941 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
3943 // print the yes/no counts
3944 s = strcat("Yes (", getcommandkey("vyes", "vyes"), "): ", ftos(vote_yescount));
3945 if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
3946 s = strcat("Yes: (press y)");
3947 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);
3948 s = strcat("No (", getcommandkey("vno", "vno"), "): ", ftos(vote_nocount));
3949 if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
3950 s = strcat("No: (press n)");
3951 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);
3953 // draw the progress bar backgrounds
3954 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3956 // draw the highlights
3957 if(vote_highlighted == 1) {
3958 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3959 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3961 else if(vote_highlighted == 2) {
3962 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3963 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3966 // draw the progress bars
3967 if(vote_yescount && vote_needed)
3969 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3970 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3973 if(vote_nocount && vote_needed)
3975 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3976 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3979 drawresetcliparea();
3982 vote_highlighted = 0;
3986 // Mod icons panel (#10)
3989 float mod_active; // is there any active mod icon?
3991 // Clan Arena HUD modicons
3992 void HUD_Mod_CA(vector pos, vector mySize)
3994 mod_active = 1; // CA should never hide the mod icons panel
3995 float redalive, bluealive;
3996 redalive = getstati(STAT_REDALIVE);
3997 bluealive = getstati(STAT_BLUEALIVE);
3999 drawfont = hud_bigfont;
4000 vector redpos, bluepos;
4001 if(mySize_x > mySize_y)
4004 bluepos = pos + eY * 0.5 * mySize_y;
4005 drawpic_aspect_skin(redpos, "player_red.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4006 drawstring_aspect(redpos + eX * 0.5 * mySize_x, ftos(redalive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4007 drawpic_aspect_skin(bluepos, "player_blue.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4008 drawstring_aspect(bluepos + eX * 0.5 * mySize_x, ftos(bluealive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4013 bluepos = pos + eY * 0.5 * mySize_y;
4014 drawpic_aspect_skin(redpos, "player_red.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4015 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);
4016 drawpic_aspect_skin(bluepos, "player_blue.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4017 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);
4019 drawfont = hud_font;
4022 // CTF HUD modicon section
4023 float redflag_prevframe, blueflag_prevframe; // status during previous frame
4024 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
4025 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
4027 void HUD_Mod_CTF_Reset(void)
4029 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
4032 void HUD_Mod_CTF(vector pos, vector mySize)
4034 vector redflag_pos, blueflag_pos;
4036 float f; // every function should have that
4038 float redflag, blueflag; // current status
4039 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
4042 stat_items = getstati(STAT_ITEMS);
4043 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
4044 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
4046 if(redflag || blueflag)
4051 if(autocvar__hud_configure)
4057 // when status CHANGES, set old status into prevstatus and current status into status
4058 if (redflag != redflag_prevframe)
4060 redflag_statuschange_time = time;
4061 redflag_prevstatus = redflag_prevframe;
4062 redflag_prevframe = redflag;
4065 if (blueflag != blueflag_prevframe)
4067 blueflag_statuschange_time = time;
4068 blueflag_prevstatus = blueflag_prevframe;
4069 blueflag_prevframe = blueflag;
4072 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
4073 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
4075 float BLINK_FACTOR = 0.15;
4076 float BLINK_BASE = 0.85;
4078 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
4080 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
4082 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
4084 string red_icon, red_icon_prevstatus;
4085 float red_alpha, red_alpha_prevstatus;
4086 red_alpha = red_alpha_prevstatus = 1;
4088 case 1: red_icon = "flag_red_taken"; break;
4089 case 2: red_icon = "flag_red_lost"; break;
4090 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4092 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
4093 red_icon = "flag_red_shielded";
4095 red_icon = string_null;
4098 switch(redflag_prevstatus) {
4099 case 1: red_icon_prevstatus = "flag_red_taken"; break;
4100 case 2: red_icon_prevstatus = "flag_red_lost"; break;
4101 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4104 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
4105 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
4106 red_icon_prevstatus = "flag_red_shielded";
4108 red_icon_prevstatus = string_null;
4112 string blue_icon, blue_icon_prevstatus;
4113 float blue_alpha, blue_alpha_prevstatus;
4114 blue_alpha = blue_alpha_prevstatus = 1;
4116 case 1: blue_icon = "flag_blue_taken"; break;
4117 case 2: blue_icon = "flag_blue_lost"; break;
4118 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4120 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
4121 blue_icon = "flag_blue_shielded";
4123 blue_icon = string_null;
4126 switch(blueflag_prevstatus) {
4127 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
4128 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
4129 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4132 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
4133 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
4134 blue_icon_prevstatus = "flag_blue_shielded";
4136 blue_icon_prevstatus = string_null;
4140 if(mySize_x > mySize_y) {
4141 if (myteam == COLOR_TEAM1) { // always draw own flag on left
4143 blueflag_pos = pos + eX * 0.5 * mySize_x;
4146 redflag_pos = pos + eX * 0.5 * mySize_x;
4148 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
4150 if (myteam == COLOR_TEAM1) { // always draw own flag on left
4152 blueflag_pos = pos + eY * 0.5 * mySize_y;
4155 redflag_pos = pos + eY * 0.5 * mySize_y;
4157 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
4160 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
4161 if(red_icon_prevstatus && f < 1)
4162 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
4164 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
4166 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
4167 if(blue_icon_prevstatus && f < 1)
4168 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
4170 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
4173 // Keyhunt HUD modicon section
4174 float kh_runheretime;
4176 void HUD_Mod_KH_Reset(void)
4181 void HUD_Mod_KH(vector pos, vector mySize)
4183 mod_active = 1; // keyhunt should never hide the mod icons panel
4187 vector p, pa, kh_size, kh_asize;
4189 kh_keys = getstati(STAT_KH_KEYS);
4192 if(mySize_x > mySize_y)
4194 p_y = pos_y + 0.25 * mySize_y;
4195 pa = p - eY * 0.25 * mySize_y;
4197 kh_size_x = mySize_x * 0.25;
4198 kh_size_y = 0.75 * mySize_y;
4199 kh_asize_x = mySize_x * 0.25;
4200 kh_asize_y = mySize_y * 0.25;
4204 p_y = pos_y + 0.125 * mySize_y;
4205 pa = p - eY * 0.125 * mySize_y;
4207 kh_size_x = mySize_x * 0.5;
4208 kh_size_y = 0.375 * mySize_y;
4209 kh_asize_x = mySize_x * 0.5;
4210 kh_asize_y = mySize_y * 0.125;
4217 for(i = 0; i < 4; ++i)
4219 key = floor(kh_keys / pow(32, i)) & 31;
4221 if(keyteam == 30 && keycount <= 4)
4223 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
4227 // this yields 8 exactly if "RUN HERE" shows
4232 kh_runheretime = time;
4233 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
4238 for(i = 0; i < 4; ++i)
4240 key = floor(kh_keys / pow(32, i)) & 31;
4253 default: // owned or dropped
4258 a = a * panel_fg_alpha;
4259 aa = aa * panel_fg_alpha;
4265 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4268 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4271 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4274 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4279 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
4282 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4285 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4288 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4291 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4295 if(mySize_x > mySize_y)
4297 p_x += 0.25 * mySize_x;
4298 pa_x += 0.25 * mySize_x;
4304 p_y = pos_y + 0.625 * mySize_y;
4305 pa_y = pos_y + 0.5 * mySize_y;
4311 p_x += 0.5 * mySize_x;
4312 pa_x += 0.5 * mySize_x;
4318 // Nexball HUD mod icon
4319 void HUD_Mod_NexBall(vector pos, vector mySize)
4321 float stat_items, nb_pb_starttime, dt, p;
4323 stat_items = getstati(STAT_ITEMS);
4324 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
4326 if (stat_items & IT_KEY1)
4331 //Manage the progress bar if any
4332 if (nb_pb_starttime > 0)
4334 dt = mod(time - nb_pb_starttime, nb_pb_period);
4335 // one period of positive triangle
4336 p = 2 * dt / nb_pb_period;
4343 HUD_Panel_GetProgressBarColor(nexball);
4344 if(mySize_x > mySize_y)
4346 HUD_Panel_DrawProgressBar(pos, mySize, p, 0, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4350 HUD_Panel_DrawProgressBar(pos, mySize, p, 1, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4354 if (stat_items & IT_KEY1)
4355 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4358 // Race/CTS HUD mod icons
4359 float crecordtime_prev; // last remembered crecordtime
4360 float crecordtime_change_time; // time when crecordtime last changed
4361 float srecordtime_prev; // last remembered srecordtime
4362 float srecordtime_change_time; // time when srecordtime last changed
4364 float race_status_time;
4365 float race_status_prev;
4366 string race_status_name_prev;
4367 void HUD_Mod_Race(vector pos, vector mySize)
4369 mod_active = 1; // race should never hide the mod icons panel
4371 me = playerslots[player_localentnum - 1];
4373 float f; // yet another function has this
4374 score = me.(scores[ps_primary]);
4376 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
4377 return; // no records in the actual race
4379 drawfont = hud_bigfont;
4381 // clientside personal record
4383 if(gametype == GAME_CTS)
4387 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4389 if(score && (score < t || !t)) {
4390 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4391 if(cvar("cl_autodemo_delete_keeprecords"))
4393 f = cvar("cl_autodemo_delete");
4395 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4399 if(t != crecordtime_prev) {
4400 crecordtime_prev = t;
4401 crecordtime_change_time = time;
4404 vector textPos, medalPos;
4406 if(mySize_x > mySize_y) {
4407 // text on left side
4408 squareSize = min(mySize_y, mySize_x/2);
4409 textPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eY * 0.5 * (mySize_y - squareSize);
4410 medalPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eX * 0.5 * mySize_x + eY * 0.5 * (mySize_y - squareSize);
4413 squareSize = min(mySize_x, mySize_y/2);
4414 textPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eX * 0.5 * (mySize_x - squareSize);
4415 medalPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eY * 0.5 * mySize_y + eX * 0.5 * (mySize_x - squareSize);
4418 f = time - crecordtime_change_time;
4421 drawstring_aspect(textPos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4422 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);
4424 drawstring_aspect(textPos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4425 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);
4426 drawstring_aspect_expanding(pos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4427 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);
4431 t = race_server_record;
4432 if(t != srecordtime_prev) {
4433 srecordtime_prev = t;
4434 srecordtime_change_time = time;
4436 f = time - srecordtime_change_time;
4439 drawstring_aspect(textPos + eY * 0.5 * squareSize, "Server best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4440 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);
4442 drawstring_aspect(textPos + eY * 0.5 * squareSize, "Server best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4443 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);
4444 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);
4445 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);
4448 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4449 race_status_time = time + 5;
4450 race_status_prev = race_status;
4451 if (race_status_name_prev)
4452 strunzone(race_status_name_prev);
4453 race_status_name_prev = strzone(race_status_name);
4458 a = bound(0, race_status_time - time, 1);
4461 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
4465 rank = race_CheckName(race_status_name);
4467 rankname = race_PlaceName(rank);
4470 namepos = medalPos + '0 0.8 0' * squareSize;
4472 rankpos = medalPos + '0 0.15 0' * squareSize;
4474 if(race_status == 0)
4475 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4476 else if(race_status == 1) {
4477 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);
4478 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4479 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4480 } else if(race_status == 2) {
4481 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4482 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);
4484 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);
4485 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4486 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4487 } else if(race_status == 3) {
4488 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);
4489 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4490 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4493 if (race_status_time - time <= 0) {
4494 race_status_prev = -1;
4496 if(race_status_name)
4497 strunzone(race_status_name);
4498 race_status_name = string_null;
4499 if(race_status_name_prev)
4500 strunzone(race_status_name_prev);
4501 race_status_name_prev = string_null;
4503 drawfont = hud_font;
4506 float mod_prev; // previous state of mod_active to check for a change
4508 float mod_change; // "time" when mod_active changed
4510 void HUD_ModIcons(void)
4512 if(!autocvar_hud_panel_modicons && !autocvar__hud_configure)
4515 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && gametype != GAME_CA && !autocvar__hud_configure)
4518 active_panel = HUD_PANEL_MODICONS;
4519 HUD_Panel_UpdateCvars(modicons);
4522 mySize = panel_size;
4524 if(mod_active != mod_prev) {
4526 mod_prev = mod_active;
4529 if(mod_active || autocvar__hud_configure)
4530 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4532 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4535 HUD_Panel_DrawBg(mod_alpha);
4537 if(panel_bg_padding)
4539 pos += '1 1 0' * panel_bg_padding;
4540 mySize -= '2 2 0' * panel_bg_padding;
4543 // these MUST be ran in order to update mod_active
4544 if(gametype == GAME_KEYHUNT)
4545 HUD_Mod_KH(pos, mySize);
4546 else if(gametype == GAME_CTF || autocvar__hud_configure)
4547 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4548 else if(gametype == GAME_NEXBALL)
4549 HUD_Mod_NexBall(pos, mySize);
4550 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4551 HUD_Mod_Race(pos, mySize);
4552 else if(gametype == GAME_CA)
4553 HUD_Mod_CA(pos, mySize);
4556 // Draw pressed keys (#11)
4558 void HUD_DrawPressedKeys(void)
4560 if(!autocvar_hud_panel_pressedkeys && !autocvar__hud_configure)
4563 if(!(spectatee_status > 0 || autocvar_hud_panel_pressedkeys >= 2 || autocvar__hud_configure))
4566 active_panel = HUD_PANEL_PRESSEDKEYS;
4567 HUD_Panel_UpdateCvars(pressedkeys);
4570 mySize = panel_size;
4572 HUD_Panel_DrawBg(1);
4573 if(panel_bg_padding)
4575 pos += '1 1 0' * panel_bg_padding;
4576 mySize -= '2 2 0' * panel_bg_padding;
4579 // force custom aspect
4580 float aspect = cvar("hud_panel_pressedkeys_aspect");
4584 if(mySize_x/mySize_y > aspect)
4586 newSize_x = aspect * mySize_y;
4587 newSize_y = mySize_y;
4589 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4593 newSize_y = 1/aspect * mySize_x;
4594 newSize_x = mySize_x;
4596 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4602 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4604 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4606 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4607 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);
4608 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);
4610 drawpic_aspect_skin(pos, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4611 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);
4612 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);
4615 // Handle chat as a panel (#12)
4619 if(!autocvar_hud_panel_chat && !autocvar__hud_configure)
4621 cvar_set("con_chatrect", "0");
4625 active_panel = HUD_PANEL_CHAT;
4626 HUD_Panel_UpdateCvars(chat);
4628 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
4630 panel_pos_y = panel_bg_border;
4631 panel_size_y = vid_conheight - panel_bg_border * 2;
4632 if(panel_bg == "0") // force a border when maximized
4634 if(precache_pic(panel_bg) == "") {
4635 panel_bg = strcat(hud_skin_path, "/border_default");
4636 if(precache_pic(panel_bg) == "") {
4637 panel_bg = "gfx/hud/default/border_default";
4641 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an alpha of at least 0.75
4646 mySize = panel_size;
4648 HUD_Panel_DrawBg(1);
4650 if(panel_bg_padding)
4652 pos += '1 1 0' * panel_bg_padding;
4653 mySize -= '2 2 0' * panel_bg_padding;
4656 cvar_set("con_chatrect", "1");
4658 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4659 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4661 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4662 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4664 if(autocvar__hud_configure)
4667 chatsize = cvar("con_chatsize");
4668 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4670 for(i = 0; i < cvar("con_chat"); ++i)
4672 if(i == cvar("con_chat") - 1)
4675 a = panel_fg_alpha * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4676 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);
4681 // Engine info panel (#13)
4688 float frametimeavg1; // 1 frame ago
4689 float frametimeavg2; // 2 frames ago
4690 void HUD_EngineInfo(void)
4692 if(!autocvar_hud_panel_engineinfo && !autocvar__hud_configure)
4695 active_panel = HUD_PANEL_ENGINEINFO;
4696 HUD_Panel_UpdateCvars(engineinfo);
4699 mySize = panel_size;
4701 HUD_Panel_DrawBg(1);
4702 if(panel_bg_padding)
4704 pos += '1 1 0' * panel_bg_padding;
4705 mySize -= '2 2 0' * panel_bg_padding;
4708 float currentTime = gettime(GETTIME_REALTIME);
4709 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
4711 float currentframetime = currentTime - prevfps_time;
4712 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4713 frametimeavg2 = frametimeavg1;
4714 frametimeavg1 = frametimeavg;
4717 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4718 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.
4720 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
4721 prevfps = (1/currentframetime);
4722 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"
4724 prevfps_time = currentTime;
4729 if(currentTime - prevfps_time > cvar("hud_panel_engineinfo_framecounter_time"))
4731 prevfps = framecounter/(currentTime - prevfps_time);
4733 prevfps_time = currentTime;
4738 color = HUD_Get_Num_Color (prevfps, 100);
4739 drawfont = hud_bigfont;
4740 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_panel_engineinfo_framecounter_decimals"))), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4741 drawfont = hud_font;
4744 // Info messages panel (#14)
4746 #define drawInfoMessage(s)\
4747 if(autocvar_hud_panel_infomessages_flip)\
4748 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);\
4749 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
4751 void HUD_InfoMessages(void)
4753 if(!autocvar_hud_panel_infomessages && !autocvar__hud_configure)
4756 active_panel = HUD_PANEL_INFOMESSAGES;
4757 HUD_Panel_UpdateCvars(infomessages);
4760 mySize = panel_size;
4762 HUD_Panel_DrawBg(1);
4763 if(panel_bg_padding)
4765 pos += '1 1 0' * panel_bg_padding;
4766 mySize -= '2 2 0' * panel_bg_padding;
4769 // always force 5:1 aspect
4771 if(mySize_x/mySize_y > 5)
4773 newSize_x = 5 * mySize_y;
4774 newSize_y = mySize_y;
4776 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4780 newSize_y = 1/5 * mySize_x;
4781 newSize_x = mySize_x;
4783 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4792 fontsize = '0.20 0.20 0' * mySize_y;
4795 if(spectatee_status != 0)
4801 if(!autocvar__hud_configure)
4803 if(spectatee_status && !intermission)
4805 if(spectatee_status == -1)
4808 s = strcat("^1Spectating: ^7", GetPlayerName(spectatee_status - 1));
4811 if(spectatee_status == -1)
4812 s = strcat("^1Press ^3", getcommandkey("primary fire", "+fire"), "^1 to spectate");
4814 s = strcat("^1Press ^3", getcommandkey("primary fire", "+fire"), "^1 for another player");
4817 if(spectatee_status == -1)
4818 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
4820 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+fire2"), "^1 to observe");
4823 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
4826 if(gametype == GAME_ARENA)
4827 s = "^1Wait for your turn to join";
4828 else if(gametype == GAME_LMS)
4831 sk = playerslots[player_localentnum - 1];
4832 if(sk.(scores[ps_primary]) >= 666)
4833 s = "^1Match has already begun";
4834 else if(sk.(scores[ps_primary]) > 0)
4835 s = "^1You have no more lives left";
4837 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4840 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4843 //show restart countdown:
4844 if (time < getstatf(STAT_GAMESTARTTIME)) {
4846 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4847 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4848 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
4849 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4853 if(warmup_stage && !intermission)
4855 s = "^2Currently in ^1warmup^2 stage!";
4860 if(mod(time, 1) >= 0.5)
4865 if(ready_waiting && !intermission && !spectatee_status)
4867 if(ready_waiting_for_me)
4870 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
4872 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
4877 s = strcat("^2Waiting for others to ready up to end warmup...");
4879 s = strcat("^2Waiting for others to ready up...");
4883 else if(warmup_stage && !intermission && !spectatee_status)
4885 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
4889 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4891 float ts_min, ts_max;
4892 tm = teams.sort_next;
4895 for(; tm.sort_next; tm = tm.sort_next)
4897 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4899 if(!ts_min) ts_min = tm.team_size;
4900 else ts_min = min(ts_min, tm.team_size);
4901 if(!ts_max) ts_max = tm.team_size;
4902 else ts_max = max(ts_max, tm.team_size);
4904 if ((ts_max - ts_min) > 1)
4906 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
4907 tm = GetTeam(myteam, false);
4909 if (tm.team != COLOR_SPECTATOR)
4910 if (tm.team_size == ts_max)
4911 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
4919 s = "^7Press ^3ESC ^7to show HUD options.";
4921 s = "^3Doubleclick ^7a panel for panel-specific options.";
4923 s = "^3CTRL ^7to disable collision testing, ^3SHIFT ^7and";
4925 s = "^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.";
4936 void HUD_ShowSpeed(void)
4939 float pos, conversion_factor;
4940 string speed, zspeed, unit;
4942 switch(cvar("cl_showspeed_unit"))
4947 conversion_factor = 1.0;
4951 conversion_factor = 1.0;
4955 conversion_factor = 0.0254;
4959 conversion_factor = 0.0254 * 3.6;
4963 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4967 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4971 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4973 numsize_x = numsize_y = cvar("cl_showspeed_size");
4974 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4976 drawfont = hud_bigfont;
4977 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
4979 if (cvar("cl_showspeed_z") == 1) {
4980 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4981 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
4984 drawfont = hud_font;
4987 vector acc_prevspeed;
4991 void HUD_ShowAcceleration(void)
4993 float acceleration, sz, scale, alpha, f;
4994 vector pos, mySize, rgb;
4996 f = time - acc_prevtime;
4997 if(cvar("cl_showacceleration_z"))
4998 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
5000 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
5001 acc_prevspeed = pmove_vel;
5002 acc_prevtime = time;
5004 f = bound(0, f * 10, 1);
5005 acc_avg = acc_avg * (1 - f) + acceleration * f;
5006 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
5007 if (acceleration == 0)
5010 sz = cvar("cl_showacceleration_size");
5011 scale = cvar("cl_showacceleration_scale");
5012 alpha = cvar("cl_showacceleration_alpha");
5013 if (cvar("cl_showacceleration_color_custom"))
5014 rgb = stov(cvar_string("cl_showacceleration_color"));
5016 if (acceleration < 0)
5017 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
5019 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
5022 mySize_x = vid_conwidth/2;
5024 pos_y = cvar("cl_showacceleration_position") * vid_conheight - sz/2;
5025 if (acceleration > 0)
5028 HUD_Panel_DrawProgressBar(pos, mySize, min(acceleration * scale, 1), 0, 0, rgb, alpha * autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
5033 HUD_Panel_DrawProgressBar(pos, mySize, min(-acceleration * scale, 1), 0, 1, rgb, alpha * autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
5037 void HUD_Reset (void)
5039 // reset gametype specific icons
5040 if(gametype == GAME_KEYHUNT)
5042 else if(gametype == GAME_CTF)
5043 HUD_Mod_CTF_Reset();
5046 #define HUD_DrawPanel(id)\
5048 case (HUD_PANEL_RADAR):\
5049 HUD_Radar(); break;\
5050 case (HUD_PANEL_WEAPONS):\
5051 HUD_Weapons(); break;\
5052 case (HUD_PANEL_AMMO):\
5054 case (HUD_PANEL_POWERUPS):\
5055 HUD_Powerups(); break;\
5056 case (HUD_PANEL_HEALTHARMOR):\
5057 HUD_HealthArmor(); break;\
5058 case (HUD_PANEL_NOTIFY):\
5059 HUD_Notify(); break;\
5060 case (HUD_PANEL_TIMER):\
5061 HUD_Timer(); break;\
5062 case (HUD_PANEL_SCORE):\
5063 HUD_Score(); break;\
5064 case (HUD_PANEL_RACETIMER):\
5065 HUD_RaceTimer(); break;\
5066 case (HUD_PANEL_VOTE):\
5067 HUD_VoteWindow(); break;\
5068 case (HUD_PANEL_MODICONS):\
5069 HUD_ModIcons(); break;\
5070 case (HUD_PANEL_PRESSEDKEYS):\
5071 HUD_DrawPressedKeys(); break;\
5072 case (HUD_PANEL_CHAT):\
5074 case (HUD_PANEL_ENGINEINFO):\
5075 HUD_EngineInfo(); break;\
5076 case (HUD_PANEL_INFOMESSAGES):\
5077 HUD_InfoMessages(); break;\
5078 } ENDS_WITH_CURLY_BRACE
5080 void HUD_Main (void)
5083 // global hud alpha fade
5084 if(menu_enabled == 1)
5087 hud_fade_alpha = (1 - autocvar__menu_alpha);
5089 if(scoreboard_fade_alpha)
5090 hud_fade_alpha = (1 - scoreboard_fade_alpha);
5092 if(intermission == 2) // no hud during mapvote
5094 else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
5097 if(!autocvar__hud_configure && !hud_fade_alpha)
5101 if (hud_skin_path != cvar_string("hud_skin"))
5104 strunzone(hud_skin_path);
5105 hud_skin_path = strzone(strcat("gfx/hud/", cvar_string("hud_skin")));
5108 // HUD configure visible grid
5109 float hud_configure_grid_alpha;
5110 if(autocvar__hud_configure && cvar("hud_configure_grid") && (hud_configure_grid_alpha = cvar("hud_configure_grid_alpha")))
5112 hud_configure_gridSize_x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
5113 hud_configure_gridSize_y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
5114 hud_configure_realGridSize_x = hud_configure_gridSize_x * vid_conwidth;
5115 hud_configure_realGridSize_y = hud_configure_gridSize_y * vid_conheight;
5117 for(i = 0; i < 1/hud_configure_gridSize_x; ++i)
5118 drawfill(eX * i * hud_configure_realGridSize_x, eX + eY * vid_conheight, '0.5 0.5 0.5', hud_configure_grid_alpha, DRAWFLAG_NORMAL);
5120 for(i = 0; i < 1/hud_configure_gridSize_y; ++i)
5121 drawfill(eY * i * hud_configure_realGridSize_y, eY + eX * vid_conwidth, '0.5 0.5 0.5', hud_configure_grid_alpha, DRAWFLAG_NORMAL);
5125 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
5129 float hud_dock_color_team = cvar("hud_dock_color_team");
5130 if((teamplay) && hud_dock_color_team) {
5131 f = stof(getplayerkey(player_localentnum - 1, "colors"));
5132 color = colormapPaletteColor(mod(f, 16), 1) * hud_dock_color_team;
5134 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
5135 color = '1 0 0' * hud_dock_color_team;
5139 string hud_dock_color = cvar_string("hud_dock_color");
5140 if(hud_dock_color == "shirt") {
5141 f = stof(getplayerkey(player_localentnum - 1, "colors"));
5142 color = colormapPaletteColor(floor(f / 16), 0);
5144 else if(hud_dock_color == "pants") {
5145 f = stof(getplayerkey(player_localentnum - 1, "colors"));
5146 color = colormapPaletteColor(mod(f, 16), 1);
5149 color = stov(hud_dock_color);
5153 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
5154 if(precache_pic(pic) == "") {
5155 pic = strcat(hud_skin_path, "/dock_medium");
5156 if(precache_pic(pic) == "") {
5157 pic = "gfx/hud/default/dock_medium";
5160 drawpic('0 0 0', pic, eX * vid_conwidth + eY * vid_conheight, color, cvar("hud_dock_alpha") * hud_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
5163 // cache the panel order into the panel_order array
5164 if(autocvar__hud_panelorder != hud_panelorder_prev) {
5165 if(hud_panelorder_prev)
5166 strunzone(hud_panelorder_prev);
5167 hud_panelorder_prev = strzone(autocvar__hud_panelorder);
5168 tokenize_console(autocvar__hud_panelorder);
5169 for(i = 0; i < HUD_PANEL_NUM; ++i) {
5170 panel_order[i] = stof(argv(i));
5173 // draw panels in order specified by panel_order array
5174 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
5175 if(i != HUD_PANEL_CHAT || !autocvar__con_chat_maximized) // don't draw maximized chat panel twice!
5176 HUD_DrawPanel(panel_order[i]);
5179 // draw chat panel on top if it is maximized
5180 if(autocvar__con_chat_maximized)
5181 HUD_Chat(); // HUD_DrawPanel(HUD_PANEL_CHAT);
5183 // TODO hud_'ify these
5184 if (cvar("cl_showspeed"))
5186 if (cvar("cl_showacceleration"))
5187 HUD_ShowAcceleration();
5189 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)
5190 localcmd("cmd selectteam auto; cmd join\n");
5192 hud_configure_prev = autocvar__hud_configure;
5194 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again