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, float vertical, vector mySize, 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";
567 drawsubpic(pos, eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, pic, '0 0 0', '1 0.25 0', color, alpha, drawflag);
568 if(mySize_y/mySize_x > 2)
569 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);
570 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);
572 pic = strcat(hud_skin_path, "/statusbar");
573 if(precache_pic(pic) == "") {
574 pic = "gfx/hud/default/statusbar";
576 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
577 if(mySize_x/mySize_y > 2)
578 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);
579 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);
583 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
589 pic = strcat(hud_skin_path, "/num_leading");
590 if(precache_pic(pic) == "") {
591 pic = "gfx/hud/default/num_leading";
594 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
595 if(mySize_x/mySize_y > 2)
596 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);
597 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);
600 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
601 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
610 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
611 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
613 for (i = 0; i < HUD_PANEL_NUM; ++i) {
614 if(i == highlightedPanel || !panel_enabled)
617 HUD_Panel_UpdatePosSizeForId(i);
619 panel_pos -= '1 1 0' * panel_bg_border;
620 panel_size += '2 2 0' * panel_bg_border;
622 if(myPos_y + mySize_y < panel_pos_y)
624 if(myPos_y > panel_pos_y + panel_size_y)
627 if(myPos_x + mySize_x < panel_pos_x)
629 if(myPos_x > panel_pos_x + panel_size_x)
632 // OK, there IS a collision.
634 myCenter_x = myPos_x + 0.5 * mySize_x;
635 myCenter_y = myPos_y + 0.5 * mySize_y;
637 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
638 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
640 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
642 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
643 myTarget_x = panel_pos_x - mySize_x;
644 else // push it upwards
645 myTarget_y = panel_pos_y - mySize_y;
647 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
649 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
650 myTarget_x = panel_pos_x + panel_size_x;
651 else // push it upwards
652 myTarget_y = panel_pos_y - mySize_y;
654 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
656 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
657 myTarget_x = panel_pos_x - mySize_x;
658 else // push it downwards
659 myTarget_y = panel_pos_y + panel_size_y;
661 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
663 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
664 myTarget_x = panel_pos_x + panel_size_x;
665 else // push it downwards
666 myTarget_y = panel_pos_y + panel_size_y;
668 //if(cvar("hud_configure_checkcollisions_debug"))
669 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
675 void HUD_Panel_SetPos(vector pos)
677 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
681 //if(cvar("hud_configure_checkcollisions_debug"))
682 //drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
684 if(autocvar_hud_configure_grid)
686 pos_x = floor((pos_x/vid_conwidth)/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
687 pos_y = floor((pos_y/vid_conheight)/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
690 if(hud_configure_checkcollisions)
691 pos = HUD_Panel_CheckMove(pos, mySize);
693 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
694 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
697 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
699 HUD_Panel_GetName(highlightedPanel);
700 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
703 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
704 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
709 float dist_x, dist_y;
711 ratio = mySize_x/mySize_y;
713 for (i = 0; i < HUD_PANEL_NUM; ++i) {
714 if(i == highlightedPanel || !panel_enabled)
717 HUD_Panel_UpdatePosSizeForId(i);
719 panel_pos -= '1 1 0' * panel_bg_border;
720 panel_size += '2 2 0' * panel_bg_border;
722 targEndPos = panel_pos + panel_size;
724 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
725 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
728 if (resizeCorner == 1)
730 // check if this panel is on our way
731 if (resizeorigin_x <= panel_pos_x)
733 if (resizeorigin_y <= panel_pos_y)
735 if (targEndPos_x <= resizeorigin_x - mySize_x)
737 if (targEndPos_y <= resizeorigin_y - mySize_y)
740 // there is a collision:
741 // detect which side of the panel we are facing is actually limiting the resizing
742 // (which side the resize direction finds for first) and reduce the size up to there
744 // dist is the distance between resizeorigin and the "analogous" point of the panel
745 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
746 dist_x = resizeorigin_x - targEndPos_x;
747 dist_y = resizeorigin_y - targEndPos_y;
748 if (dist_y <= 0 || dist_x / dist_y > ratio)
749 mySize_x = min(mySize_x, dist_x);
751 mySize_y = min(mySize_y, dist_y);
753 else if (resizeCorner == 2)
755 if (resizeorigin_x >= targEndPos_x)
757 if (resizeorigin_y <= panel_pos_y)
759 if (panel_pos_x >= resizeorigin_x + mySize_x)
761 if (targEndPos_y <= resizeorigin_y - mySize_y)
764 dist_x = panel_pos_x - resizeorigin_x;
765 dist_y = resizeorigin_y - targEndPos_y;
766 if (dist_y <= 0 || dist_x / dist_y > ratio)
767 mySize_x = min(mySize_x, dist_x);
769 mySize_y = min(mySize_y, dist_y);
771 else if (resizeCorner == 3)
773 if (resizeorigin_x <= panel_pos_x)
775 if (resizeorigin_y >= targEndPos_y)
777 if (targEndPos_x <= resizeorigin_x - mySize_x)
779 if (panel_pos_y >= resizeorigin_y + mySize_y)
782 dist_x = resizeorigin_x - targEndPos_x;
783 dist_y = panel_pos_y - resizeorigin_y;
784 if (dist_y <= 0 || dist_x / dist_y > ratio)
785 mySize_x = min(mySize_x, dist_x);
787 mySize_y = min(mySize_y, dist_y);
789 else if (resizeCorner == 4)
791 if (resizeorigin_x >= targEndPos_x)
793 if (resizeorigin_y >= targEndPos_y)
795 if (panel_pos_x >= resizeorigin_x + mySize_x)
797 if (panel_pos_y >= resizeorigin_y + mySize_y)
800 dist_x = panel_pos_x - resizeorigin_x;
801 dist_y = panel_pos_y - resizeorigin_y;
802 if (dist_y <= 0 || dist_x / dist_y > ratio)
803 mySize_x = min(mySize_x, dist_x);
805 mySize_y = min(mySize_y, dist_y);
807 //if(cvar("hud_configure_checkcollisions_debug"))
808 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
814 void HUD_Panel_SetPosSize(vector mySize)
816 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
818 resizeorigin = panel_click_resizeorigin;
821 // minimum panel size cap
822 mySize_x = max(0.025 * vid_conwidth, mySize_x);
823 mySize_y = max(0.025 * vid_conheight, mySize_y);
825 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.
827 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
828 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
831 // collision testing|
832 // -----------------+
834 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
835 if(resizeCorner == 1) {
836 myPos_x = resizeorigin_x - mySize_x;
837 myPos_y = resizeorigin_y - mySize_y;
838 } else if(resizeCorner == 2) {
839 myPos_x = resizeorigin_x;
840 myPos_y = resizeorigin_y - mySize_y;
841 } else if(resizeCorner == 3) {
842 myPos_x = resizeorigin_x - mySize_x;
843 myPos_y = resizeorigin_y;
844 } else { // resizeCorner == 4
845 myPos_x = resizeorigin_x;
846 myPos_y = resizeorigin_y;
849 // left/top screen edges
851 mySize_x = mySize_x + myPos_x;
853 mySize_y = mySize_y + myPos_y;
855 // bottom/right screen edges
856 if(myPos_x + mySize_x > vid_conwidth)
857 mySize_x = vid_conwidth - myPos_x;
858 if(myPos_y + mySize_y > vid_conheight)
859 mySize_y = vid_conheight - myPos_y;
861 //if(cvar("hud_configure_checkcollisions_debug"))
862 //drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
864 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
865 if(autocvar_hud_configure_grid)
867 mySize_x = floor((mySize_x/vid_conwidth)/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
868 mySize_y = floor((mySize_y/vid_conheight)/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
871 if(hud_configure_checkcollisions)
872 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
874 // 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)
875 mySize_x = max(0.025 * vid_conwidth, mySize_x);
876 mySize_y = max(0.025 * vid_conheight, mySize_y);
878 // do another pos check, as size might have changed by now
879 if(resizeCorner == 1) {
880 myPos_x = resizeorigin_x - mySize_x;
881 myPos_y = resizeorigin_y - mySize_y;
882 } else if(resizeCorner == 2) {
883 myPos_x = resizeorigin_x;
884 myPos_y = resizeorigin_y - mySize_y;
885 } else if(resizeCorner == 3) {
886 myPos_x = resizeorigin_x - mySize_x;
887 myPos_y = resizeorigin_y;
888 } else { // resizeCorner == 4
889 myPos_x = resizeorigin_x;
890 myPos_y = resizeorigin_y;
893 //if(cvar("hud_configure_checkcollisions_debug"))
894 //drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
896 HUD_Panel_GetName(highlightedPanel);
898 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
899 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
901 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
902 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
906 float prevMouseClicked; // previous state
907 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
908 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
910 float pressed_key_time;
911 void HUD_Panel_Arrow_Action(float nPrimary)
913 if (highlightedPanel_prev == -1 || mouseClicked)
916 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
919 if(autocvar_hud_configure_grid)
921 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
923 if (hudShiftState & S_SHIFT)
924 step = bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
926 step = 2 * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
930 if (hudShiftState & S_SHIFT)
931 step = bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
933 step = 2 * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
938 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
939 step = vid_conheight;
942 if (hudShiftState & S_SHIFT)
943 step = (step / 256); // more precision
945 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
948 highlightedPanel = highlightedPanel_prev;
950 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
952 vector prev_pos, prev_size;
953 prev_pos = panel_pos;
954 prev_size = panel_size;
956 if (hudShiftState & S_ALT) // resize
958 highlightedAction = 1;
959 if(nPrimary == K_UPARROW)
961 else if(nPrimary == K_RIGHTARROW)
963 else if(nPrimary == K_LEFTARROW)
965 else // if(nPrimary == K_DOWNARROW)
968 // ctrl+arrow reduces the size, instead of increasing it
969 // Note that ctrl disables collisions check too, but it's fine
970 // since we don't collide with anything reducing the size
971 if (hudShiftState & S_CTRL) {
973 resizeCorner = 5 - resizeCorner;
978 panel_click_resizeorigin = panel_pos;
979 if(resizeCorner == 1) {
980 panel_click_resizeorigin += mySize;
982 } else if(resizeCorner == 2) {
983 panel_click_resizeorigin_y += mySize_y;
985 } else if(resizeCorner == 3) {
986 panel_click_resizeorigin_x += mySize_x;
988 } else { // resizeCorner == 4
991 HUD_Panel_SetPosSize(mySize);
995 highlightedAction = 2;
998 if(nPrimary == K_UPARROW)
1000 else if(nPrimary == K_DOWNARROW)
1002 else if(nPrimary == K_LEFTARROW)
1004 else // if(nPrimary == K_RIGHTARROW)
1007 HUD_Panel_SetPos(pos);
1010 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
1012 if (prev_pos != panel_pos || prev_size != panel_size)
1015 panel_pos_backup = prev_pos;
1016 panel_size_backup = prev_size;
1017 highlightedPanel_backup = highlightedPanel;
1021 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1025 if(!autocvar__hud_configure)
1028 // allow console bind to work
1031 con_keys = findkeysforcommand("toggleconsole");
1032 keys = tokenize(con_keys);
1034 float hit_con_bind, i;
1035 for (i = 0; i < keys; ++i)
1037 if(nPrimary == stof(argv(i)))
1041 if(bInputType == 0) {
1042 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1043 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1044 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1046 else if(bInputType == 1) {
1047 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1048 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1049 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1052 if(nPrimary == K_MOUSE1)
1054 if(bInputType == 0) { // key pressed
1058 else if(bInputType == 1) {// key released
1063 else if(nPrimary == K_ESCAPE)
1065 if (bInputType == 1)
1068 menu_enabled_time = time;
1069 localcmd("menu_showhudexit\n");
1071 else if(hudShiftState & S_CTRL)
1076 if(nPrimary == K_SPACE) // enable/disable highlighted panel or dock
1078 if (bInputType == 1)
1081 if (highlightedPanel_prev != -1)
1082 cvar_set(strcat("hud_panel_", panel_name), ftos(!(panel_enabled)));
1084 cvar_set(strcat("hud_dock"), (autocvar_hud_dock == "") ? "dock" : "");
1086 if(nPrimary == 'c') // copy highlighted panel size
1088 if (bInputType == 1)
1091 if (highlightedPanel_prev != -1)
1093 panel_size_copied = panel_size;
1094 highlightedPanel_copied = highlightedPanel_prev;
1097 else if(nPrimary == 'v') // past copied size on the highlighted panel
1099 if (bInputType == 1)
1102 if (highlightedPanel_copied == -1 || highlightedPanel_prev == -1)
1105 HUD_Panel_UpdatePosSizeForId(highlightedPanel_prev);
1107 // reduce size if it'd go beyond screen boundaries
1108 vector tmp_size = panel_size_copied;
1109 if (panel_pos_x + panel_size_copied_x > vid_conwidth)
1110 tmp_size_x = vid_conwidth - panel_pos_x;
1111 if (panel_pos_y + panel_size_copied_y > vid_conheight)
1112 tmp_size_y = vid_conheight - panel_pos_y;
1114 if (panel_size == tmp_size)
1118 panel_pos_backup = panel_pos;
1119 panel_size_backup = panel_size;
1120 highlightedPanel_backup = highlightedPanel_prev;
1122 s = strcat(ftos(tmp_size_x/vid_conwidth), " ", ftos(tmp_size_y/vid_conheight));
1123 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
1125 else if(nPrimary == 'z') // undo last action
1127 if (bInputType == 1)
1129 //restore previous values
1130 if (highlightedPanel_backup != -1)
1132 HUD_Panel_GetName(highlightedPanel_backup);
1133 s = strcat(ftos(panel_pos_backup_x/vid_conwidth), " ", ftos(panel_pos_backup_y/vid_conheight));
1134 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
1135 s = strcat(ftos(panel_size_backup_x/vid_conwidth), " ", ftos(panel_size_backup_y/vid_conheight));
1136 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
1137 highlightedPanel_backup = -1;
1141 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1143 if (bInputType == 1)
1145 pressed_key_time = 0;
1148 else if (pressed_key_time == 0)
1149 pressed_key_time = time;
1151 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1153 else if(hit_con_bind)
1156 return true; // Suppress ALL other input
1159 float HUD_Panel_HighlightCheck()
1165 while(j <= HUD_PANEL_NUM)
1170 HUD_Panel_UpdatePosSizeForId(i);
1172 panelPos = panel_pos;
1173 panelSize = panel_size;
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 >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1181 // resize from topleft border
1182 else if(mousepos_x >= panelPos_x - border && mousepos_y >= panelPos_y - border && mousepos_x <= panelPos_x + 0.5 * panelSize_x && mousepos_y <= panelPos_y + 0.5 * panelSize_y)
1186 // resize from topright border
1187 else if(mousepos_x >= panelPos_x + 0.5 * panelSize_x && mousepos_y >= panelPos_y - border && mousepos_x <= panelPos_x + panelSize_x + border && mousepos_y <= panelPos_y + 0.5 * panelSize_y)
1191 // resize from bottomleft border
1192 else if(mousepos_x >= panelPos_x - border && mousepos_y >= panelPos_y + 0.5 * panelSize_y && mousepos_x <= panelPos_x + 0.5 * panelSize_x && mousepos_y <= panelPos_y + panelSize_y + border)
1196 // resize from bottomright border
1197 else if(mousepos_x >= panelPos_x + 0.5 * panelSize_x && mousepos_y >= panelPos_y + 0.5 * panelSize_y && mousepos_x <= panelPos_x + panelSize_x + border && mousepos_y <= panelPos_y + panelSize_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()
1249 while(j <= HUD_PANEL_NUM)
1254 HUD_Panel_UpdatePosSizeForId(i);
1256 panelPos = panel_pos;
1257 panelSize = panel_size;
1258 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1261 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1263 highlightedPanel = i;
1264 HUD_Panel_FirstInDrawQ(i);
1265 highlightedAction = 1;
1266 panel_click_distance = mousepos - panelPos;
1269 // resize from topleft border
1270 else if(mousepos_x >= panelPos_x - border && mousepos_y >= panelPos_y - border && mousepos_x <= panelPos_x + 0.5 * panelSize_x && mousepos_y <= panelPos_y + 0.5 * panelSize_y)
1272 highlightedPanel = i;
1273 HUD_Panel_FirstInDrawQ(i);
1274 highlightedAction = 2;
1276 panel_click_distance = mousepos - panelPos;
1277 panel_click_resizeorigin = panelPos + panelSize;
1280 // resize from topright border
1281 else if(mousepos_x >= panelPos_x + 0.5 * panelSize_x && mousepos_y >= panelPos_y - border && mousepos_x <= panelPos_x + panelSize_x + border && mousepos_y <= panelPos_y + 0.5 * panelSize_y)
1283 highlightedPanel = i;
1284 HUD_Panel_FirstInDrawQ(i);
1285 highlightedAction = 2;
1287 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1288 panel_click_distance_y = mousepos_y - panelPos_y;
1289 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1292 // resize from bottomleft border
1293 else if(mousepos_x >= panelPos_x - border && mousepos_y >= panelPos_y + 0.5 * panelSize_y && mousepos_x <= panelPos_x + 0.5 * panelSize_x && mousepos_y <= panelPos_y + panelSize_y + border)
1295 highlightedPanel = i;
1296 HUD_Panel_FirstInDrawQ(i);
1297 highlightedAction = 2;
1299 panel_click_distance_x = mousepos_x - panelPos_x;
1300 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1301 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1304 // resize from bottomright border
1305 else if(mousepos_x >= panelPos_x + 0.5 * panelSize_x && mousepos_y >= panelPos_y + 0.5 * panelSize_y && mousepos_x <= panelPos_x + panelSize_x + border && mousepos_y <= panelPos_y + panelSize_y + border)
1307 highlightedPanel = i;
1308 HUD_Panel_FirstInDrawQ(i);
1309 highlightedAction = 2;
1311 panel_click_distance = panelSize - mousepos + panelPos;
1312 panel_click_resizeorigin = panelPos;
1317 highlightedPanel_prev = -1;
1322 float highlightcheck;
1323 vector prev_pos, prev_size;
1324 void HUD_Panel_Mouse()
1326 // 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
1327 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1331 print("menu_enabled: ", ftos(menu_enabled), "\n");
1332 print("Highlighted: ", ftos(highlightedPanel), "\n");
1333 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1336 // instantly hide the editor cursor if we open the HUDExit dialog
1337 // as hud_fade_alpha doesn't decrease to 0 in this case
1338 // TODO: find a way to fade the cursor out even in this case
1339 if(menu_enabled == 1 || (menu_enabled == 2 && !hud_fade_alpha))
1342 if(mouseClicked == 0 && menu_enabled != 2 && highlightedPanel >= 0) { // don't reset these variables in menu_enabled mode 2!
1343 highlightedPanel = -1;
1344 highlightedAction = 0;
1346 if(highlightedPanel != -1)
1347 highlightedPanel_prev = highlightedPanel;
1349 mousepos = mousepos + getmousepos() * cvar("menu_mouse_speed");
1351 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1352 mousepos_y = bound(0, mousepos_y, vid_conheight);
1356 if(prevMouseClicked == 0)
1358 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1359 // and calls HUD_Panel_UpdatePosSizeForId() for the highlighted panel
1360 prev_pos = panel_pos;
1361 prev_size = panel_size;
1364 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
1366 if (prev_pos != panel_pos || prev_size != panel_size)
1368 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
1370 panel_pos_backup = prev_pos;
1371 panel_size_backup = prev_size;
1372 highlightedPanel_backup = highlightedPanel;
1375 // in case the clicked panel is inside another panel and we aren't
1376 // moving it, avoid the immediate "fix" of its position/size
1377 // (often unwanted and hateful) by disabling collisions check
1378 hud_configure_checkcollisions = false;
1380 if(highlightedAction == 1)
1381 HUD_Panel_SetPos(mousepos - panel_click_distance);
1382 else if(highlightedAction == 2)
1385 if(resizeCorner == 1) {
1386 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1387 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1388 } else if(resizeCorner == 2) {
1389 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1390 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1391 } else if(resizeCorner == 3) {
1392 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1393 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1394 } else { // resizeCorner == 4
1395 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1396 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1398 HUD_Panel_SetPosSize(mySize);
1401 // doubleclick check
1402 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1404 mouseClicked = 0; // to prevent spam, I guess.
1406 menu_enabled_time = time;
1407 HUD_Panel_GetName(highlightedPanel);
1408 localcmd("menu_showhudoptions ", panel_name, "\n");
1411 if(prevMouseClicked == 0)
1413 prevMouseClickedTime = time;
1414 prevMouseClickedPos = mousepos;
1419 highlightcheck = HUD_Panel_HighlightCheck();
1421 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1423 cursorsize = '32 32 0';
1425 if(highlightcheck == 0)
1426 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1427 else if(highlightcheck == 1)
1428 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1429 else if(highlightcheck == 2)
1430 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1432 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1434 prevMouseClicked = mouseClicked;
1437 // Weapon icons (#0)
1439 float weaponspace[10];
1440 #define HUD_Weapons_Clear()\
1442 for(idx = 0; idx < 10; ++idx)\
1443 weaponspace[idx] = 0
1445 entity weaponorder[WEP_MAXCOUNT];
1446 void weaponorder_swap(float i, float j, entity pass)
1450 weaponorder[i] = weaponorder[j];
1454 string weaponorder_cmp_str;
1455 float weaponorder_cmp(float i, float j, entity pass)
1458 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1459 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1460 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)
1463 float GetAmmoStat(float i)
1467 case 0: return STAT_SHELLS;
1468 case 1: return STAT_NAILS;
1469 case 2: return STAT_ROCKETS;
1470 case 3: return STAT_CELLS;
1471 case 4: return STAT_FUEL;
1476 float GetAmmoTypeForWep(float i)
1480 case WEP_SHOTGUN: return 0;
1481 case WEP_UZI: return 1;
1482 case WEP_GRENADE_LAUNCHER: return 2;
1483 case WEP_MINE_LAYER: return 2;
1484 case WEP_ELECTRO: return 3;
1485 case WEP_CRYLINK: return 3;
1486 case WEP_HLAC: return 3;
1487 case WEP_MINSTANEX: return 3;
1488 case WEP_NEX: return 3;
1489 case WEP_CAMPINGRIFLE: return 1;
1490 case WEP_HAGAR: return 2;
1491 case WEP_ROCKET_LAUNCHER: return 2;
1492 case WEP_SEEKER: return 2;
1493 case WEP_FIREBALL: return 4;
1494 case WEP_HOOK: return 3;
1499 void HUD_Weapons(void)
1502 float center_x, center_y;
1504 if(!autocvar_hud_panel_weapons && !autocvar__hud_configure)
1507 float timeout = cvar("hud_panel_weapons_timeout");
1508 float timeout_effect_length, timein_effect_length;
1509 if (cvar("hud_panel_weapons_timeout_effect") == 0)
1511 timeout_effect_length = 0;
1512 timein_effect_length = 0;
1516 timeout_effect_length = 0.75;
1517 timein_effect_length = 0.375;
1520 if (timeout && time >= weapontime + timeout + timeout_effect_length && !autocvar__hud_configure)
1522 weaponprevtime = time;
1526 active_panel = HUD_PANEL_WEAPONS;
1527 HUD_Panel_UpdateCvars(weapons);
1529 if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
1531 f = (time - (weapontime + timeout)) / timeout_effect_length;
1532 if (cvar("hud_panel_weapons_timeout_effect"))
1534 panel_bg_alpha *= (1 - f);
1535 panel_fg_alpha *= (1 - f);
1537 if (cvar("hud_panel_weapons_timeout_effect") == 1)
1539 f *= f; // for a cooler movement
1540 center_x = panel_pos_x + panel_size_x/2;
1541 center_y = panel_pos_y + panel_size_y/2;
1542 screen_ar = vid_conwidth/vid_conheight;
1543 if (center_x/center_y < screen_ar) //bottom left
1545 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
1546 panel_pos_y += f * (vid_conheight - panel_pos_y);
1548 panel_pos_x -= f * (panel_pos_x + panel_size_x);
1552 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
1553 panel_pos_x += f * (vid_conwidth - panel_pos_x);
1555 panel_pos_y -= f * (panel_pos_y + panel_size_y);
1558 weaponprevtime = time - (1 - f) * timein_effect_length;
1560 else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure)
1562 f = (time - weaponprevtime) / timein_effect_length;
1563 if (cvar("hud_panel_weapons_timeout_effect"))
1565 panel_bg_alpha *= (f);
1566 panel_fg_alpha *= (f);
1568 if (cvar("hud_panel_weapons_timeout_effect") == 1)
1570 f *= f; // for a cooler movement
1572 center_x = panel_pos_x + panel_size_x/2;
1573 center_y = panel_pos_y + panel_size_y/2;
1574 screen_ar = vid_conwidth/vid_conheight;
1575 if (center_x/center_y < screen_ar) //bottom left
1577 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
1578 panel_pos_y += f * (vid_conheight - panel_pos_y);
1580 panel_pos_x -= f * (panel_pos_x + panel_size_x);
1584 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
1585 panel_pos_x += f * (vid_conwidth - panel_pos_x);
1587 panel_pos_y -= f * (panel_pos_y + panel_size_y);
1592 float i, weapid, wpnalpha, weapon_cnt;
1594 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1596 self = get_weaponinfo(i);
1597 if(self.impulse >= 0)
1601 // TODO make this configurable
1602 if(weaponorder_bypriority != cvar_string("cl_weaponpriority"))
1604 if(weaponorder_bypriority)
1605 strunzone(weaponorder_bypriority);
1606 if(weaponorder_byimpulse)
1607 strunzone(weaponorder_byimpulse);
1609 weaponorder_bypriority = strzone(cvar_string("cl_weaponpriority"));
1610 weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
1611 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1614 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1616 self = get_weaponinfo(i);
1617 if(self.impulse >= 0)
1619 weaponorder[weapon_cnt] = self;
1623 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1625 weaponorder_cmp_str = string_null;
1628 HUD_Panel_DrawBg(1);
1629 if(panel_bg_padding)
1631 panel_pos += '1 1 0' * panel_bg_padding;
1632 panel_size -= '2 2 0' * panel_bg_padding;
1635 if(cvar_or("hud_panel_weapons_fade", 1))
1637 wpnalpha = 3.2 - 2 * (time - weapontime);
1638 wpnalpha = bound(0.7, wpnalpha, 1) * panel_fg_alpha;
1641 wpnalpha = panel_fg_alpha;
1643 HUD_Weapons_Clear();
1645 float rows, columns;
1646 float aspect = cvar("hud_panel_weapons_aspect");
1647 rows = panel_size_y/panel_size_x;
1648 rows = bound(1, floor((sqrt(4 * aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1650 columns = ceil(WEP_COUNT/rows);
1653 float a, type, fullammo;
1655 when = cvar("hud_panel_weapons_complainbubble_time");
1657 fadetime = cvar("hud_panel_weapons_complainbubble_fadetime");
1663 float fullammo_shells, fullammo_nails, fullammo_rockets, fullammo_cells, fullammo_fuel;
1666 float barsize_x, barsize_y;
1667 wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
1668 float show_ammo = cvar("hud_panel_weapons_ammo");
1671 fullammo_shells = cvar("hud_panel_weapons_ammo_full_shells");
1672 fullammo_nails = cvar("hud_panel_weapons_ammo_full_nails");
1673 fullammo_rockets = cvar("hud_panel_weapons_ammo_full_rockets");
1674 fullammo_cells = cvar("hud_panel_weapons_ammo_full_cells");
1675 fullammo_fuel = cvar("hud_panel_weapons_ammo_full_fuel");
1676 ammo_color = stov(cvar_string("hud_panel_weapons_ammo_color"));
1677 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;
1686 barsize_y = 1/aspect * wpnsize_x;
1687 barsize_x = wpnsize_x;
1691 float show_accuracy;
1692 float weapon_stats, weapon_number;
1693 if(cvar("hud_panel_weapons_accuracy") && acc_levels)
1695 show_accuracy = true;
1697 weapon_stats = getstati(STAT_DAMAGE_HITS);
1698 weapon_number = weapon_stats & 63;
1699 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1701 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1702 weapon_number = weapon_stats & 63;
1703 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1704 if (acc_col_x[0] == -1)
1705 for (i = 0; i < acc_levels; ++i)
1706 acc_col[i] = stov(cvar_string(strcat("hud_panel_weapons_accuracy_color", ftos(i))));
1708 float label = cvar("hud_panel_weapons_label");
1710 for(i = 0; i < weapon_cnt; ++i)
1712 wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y;
1714 self = weaponorder[i];
1715 weapid = self.impulse;
1717 // draw background behind currently selected weapon
1718 if(self.weapon == activeweapon)
1719 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
1721 // draw the weapon accuracy
1724 float weapon_hit, weapon_damage;
1725 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1728 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1729 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1731 // find the max level lower than weapon_stats
1734 while ( j && weapon_stats < acc_lev[j] )
1737 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
1739 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
1741 color = color + factor * (acc_col[j+1] - color);
1743 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1747 // draw the weapon icon
1748 if((self.impulse >= 0) && (getstati(STAT_WEAPONS) & self.weapons))
1750 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
1752 if(label == 1) // weapon number
1753 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1754 else if(label == 2) // bind
1755 drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1757 // draw ammo status bar
1758 if(show_ammo && weapid != WEP_TUBA && weapid != WEP_LASER && weapid != WEP_PORTO)
1761 type = GetAmmoTypeForWep(weapid);
1763 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
1768 case 0: fullammo = fullammo_shells; break;
1769 case 1: fullammo = fullammo_nails; break;
1770 case 2: fullammo = fullammo_rockets; break;
1771 case 3: fullammo = fullammo_cells; break;
1772 case 4: fullammo = fullammo_fuel; break;
1773 default: fullammo = 60;
1776 float barpos_x, barpos_y;
1777 if(wpnsize_x/wpnsize_y > aspect)
1779 barpos_x = wpnpos_x + (wpnsize_x - barsize_x) / 2;
1780 barpos_y = wpnpos_y;
1784 barpos_y = wpnpos_y + (wpnsize_y - barsize_y) / 2;
1785 barpos_x = wpnpos_x;
1791 barsize_x * bound(0, a/fullammo, 1),
1793 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, ammo_color, ammo_alpha, DRAWFLAG_NORMAL);
1794 drawresetcliparea();
1799 // draw a "ghost weapon icon" if you don't have the weapon
1802 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
1805 // draw the complain message
1806 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && cvar("hud_panel_weapons_complainbubble"))
1810 if(complain_weapon_time + when > time)
1813 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1817 if(complain_weapon_time + when > time)
1824 if(complain_weapon_type == 0) {
1826 color = stov(cvar_string("hud_panel_weapons_complainbubble_color_outofammo"));
1828 else if(complain_weapon_type == 1) {
1830 color = stov(cvar_string("hud_panel_weapons_complainbubble_color_donthave"));
1834 color = stov(cvar_string("hud_panel_weapons_complainbubble_color_unavailable"));
1836 float padding = cvar("hud_panel_weapons_complainbubble_padding");
1837 drawpic_aspect_skin(wpnpos + '1 1 0' * padding, "weapon_complainbubble", wpnsize - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
1838 drawstring_aspect(wpnpos + '1 1 0' * padding, s, wpnsize - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
1854 float GetAmmoItemCode(float i)
1858 case 0: return IT_SHELLS;
1859 case 1: return IT_NAILS;
1860 case 2: return IT_ROCKETS;
1861 case 3: return IT_CELLS;
1862 case 4: return IT_FUEL;
1867 string GetAmmoPicture(float i)
1871 case 0: return "ammo_shells";
1872 case 1: return "ammo_bullets";
1873 case 2: return "ammo_rockets";
1874 case 3: return "ammo_cells";
1875 case 4: return "ammo_fuel";
1880 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1883 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1884 if(autocvar__hud_configure)
1894 if(currently_selected)
1899 vector newSize, newPos;
1900 if(mySize_x/mySize_y > 3)
1902 newSize_x = 3 * mySize_y;
1903 newSize_y = mySize_y;
1905 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1910 newSize_y = 1/3 * mySize_x;
1911 newSize_x = mySize_x;
1913 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1917 vector picpos, numpos;
1918 if(autocvar_hud_panel_ammo_iconalign)
1921 picpos = newPos + eX * 2 * newSize_y;
1925 numpos = newPos + eX * newSize_y;
1929 if (currently_selected)
1930 drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1932 drawfont = hud_bigfont;
1934 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1935 else // "ghost" ammo count
1936 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1937 drawfont = hud_font;
1939 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1940 else // "ghost" ammo icon
1941 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1946 if(!autocvar_hud_panel_ammo && !autocvar__hud_configure)
1949 active_panel = HUD_PANEL_AMMO;
1950 HUD_Panel_UpdateCvars(ammo);
1951 float i, currently_selected;
1955 mySize = panel_size;
1957 HUD_Panel_DrawBg(1);
1958 if(panel_bg_padding)
1960 pos += '1 1 0' * panel_bg_padding;
1961 mySize -= '2 2 0' * panel_bg_padding;
1964 float rows, columns;
1965 rows = mySize_y/mySize_x;
1966 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1967 // ^^^ ammo item aspect goes here
1969 columns = ceil(AMMO_COUNT/rows);
1973 for (i = 0; i < AMMO_COUNT; ++i) {
1974 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1975 if(autocvar_hud_panel_ammo_onlycurrent) {
1976 if(autocvar__hud_configure)
1978 if (currently_selected || autocvar__hud_configure)
1980 DrawAmmoItem(pos, mySize, i, currently_selected);
1984 DrawAmmoItem(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), i, currently_selected);
1989 column = column + 1;
1995 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float alpha)
1998 float newSize_x, newSize_y;
1999 if(mySize_x/mySize_y > 3)
2001 newSize_x = 3 * mySize_y;
2002 newSize_y = mySize_y;
2004 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
2009 newSize_y = 1/3 * mySize_x;
2010 newSize_x = mySize_x;
2012 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
2016 vector picpos, numpos;
2019 if(iconalign == 1 || iconalign == 3) // right align
2022 picpos = newPos + eX * 2 * newSize_y;
2026 numpos = newPos + eX * newSize_y;
2032 if(iconalign == 0 || iconalign == 3) // left align
2034 numpos = newPos + eX * newSize_y;
2040 picpos = newPos + eX * 2 * newSize_y;
2044 drawfont = hud_bigfont;
2045 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
2046 drawfont = hud_font;
2047 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
2050 void DrawNumIcon_expanding(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float fadelerp)
2053 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
2055 DrawNumIcon(iconalign, myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, left, color, (1 - fadelerp));
2060 void HUD_Powerups(void) {
2061 if(!autocvar_hud_panel_powerups && !autocvar__hud_configure)
2064 if(!autocvar__hud_configure)
2066 if not(getstati(STAT_ITEMS) & (IT_STRENGTH | IT_INVINCIBLE))
2069 if (getstati(STAT_HEALTH) <= 0)
2073 active_panel = HUD_PANEL_POWERUPS;
2074 HUD_Panel_UpdateCvars(powerups);
2077 mySize = panel_size;
2079 float strength_time, shield_time;
2080 if(autocvar__hud_configure)
2087 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
2088 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
2091 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
2092 if(panel_bg_padding)
2094 pos += '1 1 0' * panel_bg_padding;
2095 mySize -= '2 2 0' * panel_bg_padding;
2098 vector barpos, barsize;
2102 string leftname, rightname;
2103 float leftcnt, rightcnt;
2104 float leftexact, rightexact;
2105 float flip = cvar("hud_panel_powerups_flip");
2107 leftname = "strength";
2108 leftcnt = ceil(strength_time);
2109 leftexact = strength_time;
2111 rightname = "shield";
2112 rightcnt = ceil(shield_time);
2113 rightexact = shield_time;
2115 leftname = "shield";
2116 leftcnt = ceil(shield_time);
2117 leftexact = shield_time;
2119 rightname = "strength";
2120 rightcnt = ceil(strength_time);
2121 rightexact = strength_time;
2124 drawfont = hud_bigfont;
2125 float baralign = cvar("hud_panel_powerups_baralign");
2126 float iconalign = cvar("hud_panel_powerups_iconalign");
2127 float progressbar = cvar("hud_panel_powerups_progressbar");
2128 if (mySize_x/mySize_y > 4)
2132 if(baralign == 1 || baralign == 3) { // right align
2133 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
2134 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
2135 } else { // left align
2137 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
2142 HUD_Panel_GetProgressBarColorForString(leftname);
2143 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2146 DrawNumIcon(iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
2148 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));
2153 if(baralign == 0 || baralign == 3) { // left align
2154 barpos = pos + eX * 0.5 * mySize_x;
2155 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
2156 } else { // right align
2157 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
2158 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
2163 HUD_Panel_GetProgressBarColorForString(rightname);
2164 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2167 DrawNumIcon(iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
2169 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));
2172 else if (mySize_x/mySize_y > 1.5)
2176 if(baralign == 1 || baralign == 3) { // right align
2177 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
2178 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
2179 } else { // left align
2181 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
2186 HUD_Panel_GetProgressBarColorForString(leftname);
2187 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2190 DrawNumIcon(iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
2192 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));
2197 if(baralign == 0 || baralign == 3) { // left align
2198 barpos = pos + eY * 0.5 * mySize_y;
2199 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
2200 } else { // right align
2201 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
2202 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
2207 HUD_Panel_GetProgressBarColorForString(rightname);
2208 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2211 DrawNumIcon(iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
2213 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));
2220 if(baralign == 1 || baralign == 3) { // down align
2221 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
2222 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
2223 } else { // up align
2225 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
2228 if(iconalign == 1 || iconalign == 3) { // down align
2229 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2230 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2231 } else { // up align
2232 picpos = pos + eX * 0.05 * mySize_x;
2233 numpos = pos + eY * 0.4 * mySize_x;
2238 HUD_Panel_GetProgressBarColorForString(leftname);
2239 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2242 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));
2244 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2245 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2250 if(baralign == 0 || baralign == 3) { // up align
2251 barpos = pos + eX * 0.5 * mySize_x;
2252 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2253 } else { // down align
2254 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
2255 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2258 if(iconalign == 0 || iconalign == 3) { // up align
2259 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2260 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2261 } else { // down align
2262 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2263 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2268 HUD_Panel_GetProgressBarColorForString(rightname);
2269 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2272 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));
2274 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2275 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2278 drawfont = hud_font;
2281 // Health/armor (#3)
2283 void HUD_HealthArmor(void)
2285 if(!autocvar_hud_panel_healtharmor && !autocvar__hud_configure)
2288 active_panel = HUD_PANEL_HEALTHARMOR;
2289 HUD_Panel_UpdateCvars(healtharmor);
2292 mySize = panel_size;
2294 HUD_Panel_DrawBg(1);
2295 if(panel_bg_padding)
2297 pos += '1 1 0' * panel_bg_padding;
2298 mySize -= '2 2 0' * panel_bg_padding;
2301 float armor, health, fuel;
2302 armor = getstati(STAT_ARMOR);
2303 health = getstati(STAT_HEALTH);
2304 fuel = getstati(STAT_FUEL);
2306 if(autocvar__hud_configure)
2316 vector barpos, barsize;
2320 drawfont = hud_bigfont;
2321 float baralign = cvar("hud_panel_healtharmor_baralign");
2322 float iconalign = cvar("hud_panel_healtharmor_iconalign");
2323 float progressbar = cvar("hud_panel_healtharmor_progressbar");
2324 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
2327 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2332 if(baralign == 1 || baralign == 3) { // right align
2333 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2334 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2335 } else { // left align
2337 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2341 if(v_z) // NOT fully armored
2343 biggercount = "health";
2346 HUD_Panel_GetProgressBarColor(health);
2347 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2350 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);
2354 biggercount = "armor";
2357 HUD_Panel_GetProgressBarColor(armor);
2358 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2361 drawpic_aspect_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "health", '0.5 0.5 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2363 DrawNumIcon(iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200), 1);
2368 if(baralign == 0 || baralign == 3) { // left align
2369 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2370 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2373 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2375 HUD_Panel_GetProgressBarColor(fuel);
2376 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2381 string leftname, rightname;
2382 float leftcnt, rightcnt;
2383 float leftactive, rightactive;
2384 float leftalpha, rightalpha;
2385 float flip = cvar("hud_panel_healtharmor_flip");
2386 if (flip) { // old style layout with armor left/top of health
2391 leftalpha = min((armor+10)/55, 1);
2393 rightname = "health";
2398 leftname = "health";
2403 rightname = "armor";
2407 rightalpha = min((armor+10)/55, 1);
2410 if (mySize_x/mySize_y > 4)
2414 if(baralign == 1 || baralign == 3) { // right align
2415 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2416 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2417 } else { // left align
2419 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2424 HUD_Panel_GetProgressBarColorForString(leftname);
2425 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2427 DrawNumIcon(iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
2432 if(baralign == 0 || baralign == 3) { // left align
2433 barpos = pos + eX * 0.5 * mySize_x;
2434 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2435 } else { // right align
2436 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2437 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2442 HUD_Panel_GetProgressBarColorForString(rightname);
2443 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2445 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);
2450 if(baralign == 0 || baralign == 3) { // left align
2451 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2452 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2455 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2457 HUD_Panel_GetProgressBarColor(fuel);
2458 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2461 else if (mySize_x/mySize_y > 1.5)
2465 if(baralign == 1 || baralign == 3) { // right align
2466 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2467 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2468 } else { // left align
2470 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2475 HUD_Panel_GetProgressBarColorForString(leftname);
2476 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2478 DrawNumIcon(iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
2483 if(baralign == 0 || baralign == 3) { // left align
2484 barpos = pos + eY * 0.5 * mySize_y;
2485 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2486 } else { // right align
2487 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2488 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2493 HUD_Panel_GetProgressBarColorForString(rightname);
2494 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2496 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);
2501 if(baralign == 0 || baralign == 3) { // left align
2502 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2503 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2506 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2508 HUD_Panel_GetProgressBarColor(fuel);
2509 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2516 if(baralign == 1 || baralign == 3) { // down align
2517 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2518 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2519 } else { // up align
2521 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2524 if(iconalign == 1 || iconalign == 3) { // down align
2525 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2526 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2527 } else { // up align
2528 picpos = pos + eX * 0.05 * mySize_x;
2529 numpos = pos + eY * 0.4 * mySize_x;
2534 HUD_Panel_GetProgressBarColorForString(leftname);
2535 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2537 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2538 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);
2543 if(baralign == 0 || baralign == 3) { // up align
2544 barpos = pos + eX * 0.5 * mySize_x;
2545 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2546 } else { // down align
2547 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2548 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2551 if(iconalign == 0 || iconalign == 3) { // up align
2552 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2553 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2554 } else { // down align
2555 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2556 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2561 HUD_Panel_GetProgressBarColorForString(rightname);
2562 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2564 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2565 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);
2570 if(baralign == 0 || baralign == 3) { // left align
2572 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2574 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2575 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2577 HUD_Panel_GetProgressBarColor(fuel);
2578 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2582 drawfont = hud_font;
2585 // Notification area (#4)
2588 string Weapon_SuicideMessage(float deathtype)
2590 w_deathtype = deathtype;
2591 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2592 return w_deathtypestring;
2595 string Weapon_KillMessage(float deathtype)
2597 w_deathtype = deathtype;
2598 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2599 return w_deathtypestring;
2602 float killnotify_times[10];
2603 float killnotify_deathtype[10];
2604 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2605 string killnotify_attackers[10];
2606 string killnotify_victims[10];
2607 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2610 for (i = 9; i > 0; --i) {
2611 killnotify_times[i] = killnotify_times[i-1];
2612 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2613 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2614 if(killnotify_attackers[i])
2615 strunzone(killnotify_attackers[i]);
2616 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2617 if(killnotify_victims[i])
2618 strunzone(killnotify_victims[i]);
2619 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2621 killnotify_times[0] = time;
2622 killnotify_deathtype[0] = wpn;
2623 killnotify_actiontype[0] = actiontype;
2624 if(killnotify_attackers[0])
2625 strunzone(killnotify_attackers[0]);
2626 killnotify_attackers[0] = strzone(attacker);
2627 if(killnotify_victims[0])
2628 strunzone(killnotify_victims[0]);
2629 killnotify_victims[0] = strzone(victim);
2632 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
2635 float alsoprint, gentle;
2636 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2637 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2639 if(msg == MSG_SUICIDE) {
2640 w = DEATH_WEAPONOF(type);
2642 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2644 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
2645 } else if (type == DEATH_KILL) {
2646 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2648 print ("^1",s1, "^1 couldn't take it anymore\n");
2649 } else if (type == DEATH_ROT) {
2650 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2652 print ("^1",s1, "^1 died\n");
2653 } else if (type == DEATH_NOAMMO) {
2654 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2656 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2657 } else if (type == DEATH_CAMP) {
2658 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2660 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2661 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2662 HUD_KillNotify_Push(s1, "", 0, type);
2664 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2665 } else if (type == DEATH_CHEAT) {
2666 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2668 print ("^1",s1, "^1 unfairly eliminated themself\n");
2669 } else if (type == DEATH_FIRE) {
2670 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2672 print ("^1",s1, "^1 burned to death\n");
2673 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2674 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2676 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2679 if (stof(s2) > 2) // killcount > 2
2680 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2681 } else if(msg == MSG_KILL) {
2682 w = DEATH_WEAPONOF(type);
2684 HUD_KillNotify_Push(s1, s2, 1, type);
2686 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
2688 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2689 HUD_KillNotify_Push(s1, s2, 1, type);
2693 print ("^1", s1, "^1 took action against a team mate\n");
2695 print ("^1", s1, "^1 mows down a team mate\n");
2698 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2700 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2702 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2704 else if (stof(s2) > 2) {
2706 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2708 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2711 else if(type == KILL_FIRST_BLOOD)
2712 print("^1",s1, "^1 drew first blood", "\n");
2713 else if (type == DEATH_TELEFRAG) {
2714 HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
2716 print ("^1",s2, "^1 tried to occupy ", s1, "^1's teleport destination space\n");
2718 print ("^1",s2, "^1 was telefragged by ", s1, "\n");
2720 else if (type == DEATH_DROWN) {
2721 HUD_KillNotify_Push(s1, s2, 1, DEATH_DROWN);
2723 print ("^1",s2, "^1 was drowned by ", s1, "\n");
2725 else if (type == DEATH_SLIME) {
2726 HUD_KillNotify_Push(s1, s2, 1, DEATH_SLIME);
2728 print ("^1",s2, "^1 was slimed by ", s1, "\n");
2730 else if (type == DEATH_LAVA) {
2731 HUD_KillNotify_Push(s1, s2, 1, DEATH_LAVA);
2733 print ("^1",s2, "^1 was cooked by ", s1, "\n");
2735 else if (type == DEATH_FALL) {
2736 HUD_KillNotify_Push(s1, s2, 1, DEATH_FALL);
2738 print ("^1",s2, "^1 was grounded by ", s1, "\n");
2740 else if (type == DEATH_SHOOTING_STAR) {
2741 HUD_KillNotify_Push(s1, s2, 1, DEATH_SHOOTING_STAR);
2743 print ("^1",s2, "^1 was shot into space by ", s1, "\n");
2745 else if (type == DEATH_SWAMP) {
2746 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2748 print ("^1",s2, "^1 was conserved by ", s1, "\n");
2750 else if (type == DEATH_HURTTRIGGER)
2752 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
2754 print("^1",s2, "^1 was thrown into a world of hurt by ", s1, "\n");
2755 } else if(type == DEATH_SBCRUSH) {
2756 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2758 print ("^1",s2, "^1 was crushed by ^1", s1, "\n");
2759 } else if(type == DEATH_SBMINIGUN) {
2760 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2762 print ("^1",s2, "^1 got shredded by ^1", s1, "\n");
2763 } else if(type == DEATH_SBROCKET) {
2764 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2766 print ("^1",s2, "^1 was blased to bits by ^1", s1, "\n");
2767 } else if(type == DEATH_SBBLOWUP) {
2768 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2770 print ("^1",s2, "^1 got caught in the destruction of ^1", s1, "'s vehicle\n");
2771 } else if(type == DEATH_WAKIGUN) {
2772 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2774 print ("^1",s2, "^1 was bolted down by ^1", s1, "\n");
2775 } else if(type == DEATH_WAKIROCKET) {
2776 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2778 print ("^1",s2, "^1 could find no shelter from ^1", s1, "'s rockets\n");
2779 } else if(type == DEATH_WAKIBLOWUP) {
2780 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2782 print ("^1",s2, "^1 dies when ^1", s1, "'s wakizashi dies.\n");
2783 } else if(type == DEATH_TURRET) {
2784 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2786 print ("^1",s2, "^1 was pushed into the line of fire by ^1", s1, "\n");
2787 } else if(type == DEATH_TOUCHEXPLODE) {
2788 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2790 print ("^1",s2, "^1 was pushed into an accident by ^1", s1, "\n");
2791 } else if(type == DEATH_CHEAT) {
2792 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2794 print ("^1",s2, "^1 was unfairly eliminated by ^1", s1, "\n");
2795 } else if (type == DEATH_FIRE) {
2796 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2798 print ("^1",s2, "^1 was burnt to death by ^1", s1, "\n");
2799 } else if (type == DEATH_CUSTOM) {
2800 HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM);
2802 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
2803 } else if (type == DEATH_HURTTRIGGER) {
2804 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
2806 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
2808 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2810 print ("^1",s2, "^1 was fragged by ", s1, "\n");
2812 } else if(msg == MSG_SPREE) {
2813 if(type == KILL_END_SPREE) {
2815 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2817 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2818 } else if(type == KILL_SPREE) {
2820 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2822 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2823 } else if(type == KILL_SPREE_3) {
2825 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2827 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2828 } else if(type == KILL_SPREE_5) {
2830 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2832 print (s1,"^7 unleashes ^1RAGE\n");
2833 } else if(type == KILL_SPREE_10) {
2835 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2837 print (s1,"^7 starts the ^1MASSACRE!\n");
2838 } else if(type == KILL_SPREE_15) {
2840 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2842 print (s1,"^7 executes ^1MAYHEM!\n");
2843 } else if(type == KILL_SPREE_20) {
2845 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2847 print (s1,"^7 is a ^1BERSERKER!\n");
2848 } else if(type == KILL_SPREE_25) {
2850 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2852 print (s1,"^7 inflicts ^1CARNAGE!\n");
2853 } else if(type == KILL_SPREE_30) {
2855 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2857 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2859 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2860 if (type == DEATH_DROWN) {
2861 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2865 print ("^1",s1, "^1 was in the water for too long\n");
2867 print ("^1",s1, "^1 drowned\n");
2869 } else if (type == DEATH_SLIME) {
2870 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2872 print ("^1",s1, "^1 was slimed\n");
2873 } else if (type == DEATH_LAVA) {
2874 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2878 print ("^1",s1, "^1 found a hot place\n");
2880 print ("^1",s1, "^1 turned into hot slag\n");
2882 } else if (type == DEATH_FALL) {
2883 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2887 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2889 print ("^1",s1, "^1 hit the ground with a crunch\n");
2891 } else if (type == DEATH_SHOOTING_STAR) {
2892 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2894 print ("^1",s1, "^1 became a shooting star\n");
2895 } else if (type == DEATH_SWAMP) {
2896 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2900 print ("^1",s1, "^1 discovered a swamp\n");
2902 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2904 } else if(type == DEATH_TURRET) {
2905 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2907 print ("^1",s1, "^1 was mowed down by a turret \n");
2908 } else if (type == DEATH_CUSTOM) {
2909 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2911 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
2912 } else if (type == DEATH_HURTTRIGGER) {
2913 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2915 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
2916 } else if(type == DEATH_TOUCHEXPLODE) {
2917 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2919 print ("^1",s1, "^1 died in an accident\n");
2920 } else if(type == DEATH_CHEAT) {
2921 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2923 print ("^1",s1, "^1 was unfairly eliminated\n");
2924 } else if(type == DEATH_FIRE) {
2925 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2929 print ("^1",s1, "^1 felt a little hot\n");
2931 print ("^1",s1, "^1 burnt to death\n");
2934 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2938 print ("^1",s1, "^1 needs a restart\n");
2940 print ("^1",s1, "^1 died\n");
2943 } else if(msg == MSG_KILL_ACTION_SPREE) {
2945 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2947 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2948 } else if(msg == MSG_INFO) {
2949 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2950 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2951 print(s1, "^7 got the ", s2, "\n");
2952 } else if(type == INFO_LOSTFLAG) {
2953 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2954 print(s1, "^7 lost the ", s2, "\n");
2955 } else if(type == INFO_PICKUPFLAG) {
2956 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2957 print(s1, "^7 picked up the ", s2, "\n");
2958 } else if(type == INFO_RETURNFLAG) {
2959 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2960 print(s1, "^7 returned the ", s2, "\n");
2961 } else if(type == INFO_CAPTUREFLAG) {
2962 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
2963 print(s1, "^7 captured the ", s2, s3, "\n");
2968 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2970 void HUD_Centerprint(string s1, string s2, float type, float msg)
2973 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2974 if(msg == MSG_SUICIDE) {
2975 if (type == DEATH_TEAMCHANGE) {
2976 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2977 } else if (type == DEATH_AUTOTEAMCHANGE) {
2978 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2979 } else if (type == DEATH_CAMP) {
2981 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2983 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2984 } else if (type == DEATH_NOAMMO) {
2986 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2988 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2989 } else if (type == DEATH_ROT) {
2991 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2993 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2994 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2996 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2998 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2999 } else if (type == DEATH_QUIET) {
3001 } else { // generic message
3003 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
3005 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
3007 } else if(msg == MSG_KILL) {
3008 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
3010 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
3012 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
3014 } else if (type == KILL_FIRST_BLOOD) {
3016 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
3018 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
3020 } else if (type == KILL_FIRST_VICTIM) {
3022 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
3024 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
3026 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
3028 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
3030 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
3032 } else if (type == KILL_TYPEFRAGGED) {
3034 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
3036 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
3038 } else if (type == KILL_FRAG) {
3040 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
3042 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
3044 } else { // generic message
3046 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
3048 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
3051 } else if(msg == MSG_KILL_ACTION) {
3052 // TODO: invent more centerprints here?
3053 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
3057 void HUD_Notify (void)
3059 if(!autocvar_hud_panel_notify && !autocvar__hud_configure)
3062 active_panel = HUD_PANEL_NOTIFY;
3063 HUD_Panel_UpdateCvars(notify);
3066 mySize = panel_size;
3068 HUD_Panel_DrawBg(1);
3069 if(panel_bg_padding)
3071 pos += '1 1 0' * panel_bg_padding;
3072 mySize -= '2 2 0' * panel_bg_padding;
3075 float entries, height;
3076 entries = bound(1, floor(10 * mySize_y/mySize_x), 10);
3077 height = mySize_y/entries;
3080 fontsize = '0.5 0.5 0' * height;
3084 when = autocvar_hud_panel_notify_time;
3086 fadetime = autocvar_hud_panel_notify_fadetime;
3090 vector pos_attacker, pos_victim;
3092 float width_attacker;
3093 string attacker, victim;
3096 for(j = 0; j < entries; ++j)
3099 if(autocvar_hud_panel_notify_flip)
3101 else // rather nasty hack for ordering items from the bottom up
3102 i = entries - j - 1;
3106 if(killnotify_times[j] + when > time)
3109 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
3113 if(killnotify_times[j] + when > time)
3120 w = DEATH_WEAPONOF(killnotify_deathtype[j]);
3122 // TODO: maybe print in team colors?
3125 if(killnotify_actiontype[j] == 0 && !autocvar__hud_configure)
3127 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3128 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
3129 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
3131 if(killnotify_deathtype[j] == DEATH_GENERIC)
3135 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
3137 s = "notify_outofammo";
3139 else if(killnotify_deathtype[j] == DEATH_KILL)
3141 s = "notify_selfkill";
3143 else if(killnotify_deathtype[j] == DEATH_CAMP)
3145 s = "notify_camping";
3147 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
3149 s = "notify_teamkill_red";
3151 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
3153 s = "notify_teamkill_blue";
3155 else if(killnotify_deathtype[j] == DEATH_DROWN)
3159 else if(killnotify_deathtype[j] == DEATH_SLIME)
3163 else if(killnotify_deathtype[j] == DEATH_LAVA)
3167 else if(killnotify_deathtype[j] == DEATH_FALL)
3171 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
3173 s = "notify_shootingstar";
3175 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
3179 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
3181 if(killnotify_victims[j] == "^1RED^7 flag")
3183 s = "notify_red_taken";
3187 s = "notify_blue_taken";
3190 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
3192 if(killnotify_victims[j] == "^1RED^7 flag")
3194 s = "notify_red_returned";
3198 s = "notify_blue_returned";
3201 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
3203 if(killnotify_victims[j] == "^1RED^7 flag")
3205 s = "notify_red_lost";
3209 s = "notify_blue_lost";
3212 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
3214 if(killnotify_victims[j] == "^1RED^7 flag")
3216 s = "notify_red_captured";
3220 s = "notify_blue_captured";
3225 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3226 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3229 // X [did action to] Y
3232 if(autocvar__hud_configure)
3234 attacker = textShortenToWidth("Player1", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3235 victim = textShortenToWidth("Player2", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3236 a = bound(0, (when - j) / 4, 1);
3240 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3241 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3243 width_attacker = stringwidth(attacker, TRUE, fontsize);
3244 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
3245 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
3246 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
3248 if(autocvar__hud_configure) // example actions for config mode
3250 s = "weaponelectro";
3252 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
3254 s = "notify_melee_laser";
3256 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_SHOTGUN)
3258 s = "notify_melee_shotgun";
3260 else if(WEP_VALID(w))
3262 self = get_weaponinfo(w);
3263 s = strcat("weapon", self.netname);
3265 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
3267 s = "notify_teamkill_red";
3269 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
3271 s = "notify_teamkill_red";
3273 else if(killnotify_deathtype[j] == DEATH_TELEFRAG)
3275 s = "notify_telefrag";
3277 else if(killnotify_deathtype[j] == DEATH_DROWN)
3281 else if(killnotify_deathtype[j] == DEATH_SLIME)
3285 else if(killnotify_deathtype[j] == DEATH_LAVA)
3289 else if(killnotify_deathtype[j] == DEATH_FALL)
3293 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
3295 s = "notify_shootingstar";
3297 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
3303 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3304 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3305 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3314 string seconds_tostring(float sec)
3317 minutes = floor(sec / 60);
3319 sec -= minutes * 60;
3322 s = ftos(100 + sec);
3324 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3327 void HUD_Timer(void)
3329 if(!autocvar_hud_panel_timer && !autocvar__hud_configure)
3332 active_panel = HUD_PANEL_TIMER;
3333 HUD_Panel_UpdateCvars(timer);
3336 mySize = panel_size;
3338 HUD_Panel_DrawBg(1);
3339 if(panel_bg_padding)
3341 pos += '1 1 0' * panel_bg_padding;
3342 mySize -= '2 2 0' * panel_bg_padding;
3346 float timelimit, elapsedTime, timeleft, minutesLeft;
3348 timelimit = getstatf(STAT_TIMELIMIT);
3350 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3351 timeleft = ceil(timeleft);
3353 minutesLeft = floor(timeleft / 60);
3356 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3357 timer_color = '1 1 1'; //white
3358 else if(minutesLeft >= 1)
3359 timer_color = '1 1 0'; //yellow
3361 timer_color = '1 0 0'; //red
3363 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
3364 if (time < getstatf(STAT_GAMESTARTTIME)) {
3365 //while restart is still active, show 00:00
3366 timer = seconds_tostring(0);
3368 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3369 timer = seconds_tostring(elapsedTime);
3372 timer = seconds_tostring(timeleft);
3375 drawfont = hud_bigfont;
3376 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3377 drawfont = hud_font;
3382 void HUD_Radar(void)
3384 if ((autocvar_hud_panel_radar == 0 || (autocvar_hud_panel_radar != 2 && !teamplay)) && !autocvar__hud_configure)
3387 active_panel = HUD_PANEL_RADAR;
3388 HUD_Panel_UpdateCvars(radar);
3391 mySize = panel_size;
3393 HUD_Panel_DrawBg(1);
3394 if(panel_bg_padding)
3396 pos += '1 1 0' * panel_bg_padding;
3397 mySize -= '2 2 0' * panel_bg_padding;
3400 local float color1, color2; // color already declared as a global in hud.qc
3403 float scale2d, normalsize, bigsize;
3406 teamradar_origin2d = pos + 0.5 * mySize;
3407 teamradar_size2d = mySize;
3409 if(minimapname == "")
3412 teamradar_loadcvars();
3414 switch(hud_panel_radar_zoommode)
3418 f = current_zoomfraction;
3421 f = 1 - current_zoomfraction;
3431 switch(hud_panel_radar_rotation)
3434 teamradar_angle = view_angles_y - 90;
3437 teamradar_angle = 90 * hud_panel_radar_rotation;
3441 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3442 teamradar_size2d = mySize;
3444 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3446 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3447 if(hud_panel_radar_rotation == 0)
3449 // max-min distance must fit the radar in any rotation
3450 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3454 vector c0, c1, c2, c3, span;
3455 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3456 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3457 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3458 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3460 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3461 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3463 // max-min distance must fit the radar in x=x, y=y
3465 teamradar_size2d_x * scale2d / (1.05 * span_x),
3466 teamradar_size2d_y * scale2d / (1.05 * span_y)
3470 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
3471 if(bigsize > normalsize)
3472 normalsize = bigsize;
3476 + (1 - f) * normalsize;
3477 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3478 f * (mi_min + mi_max) * 0.5
3479 + (1 - f) * view_origin);
3481 color1 = GetPlayerColor(player_localentnum-1);
3482 rgb = GetTeamRGB(color1);
3491 draw_teamradar_background(hud_panel_radar_foreground_alpha);
3493 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3494 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3495 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3496 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3497 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3499 color2 = GetPlayerColor(tm.sv_entnum);
3500 //if(color == COLOR_SPECTATOR || color == color2)
3501 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3503 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3505 drawresetcliparea();
3510 void HUD_Score(void)
3512 if(!autocvar_hud_panel_score && !autocvar__hud_configure)
3515 active_panel = HUD_PANEL_SCORE;
3516 HUD_Panel_UpdateCvars(score);
3519 mySize = panel_size;
3521 HUD_Panel_DrawBg(1);
3522 if(panel_bg_padding)
3524 pos += '1 1 0' * panel_bg_padding;
3525 mySize -= '2 2 0' * panel_bg_padding;
3528 float score, distribution, leader;
3529 vector distribution_color;
3531 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3533 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3534 string timer, distrtimer;
3536 pl = players.sort_next;
3539 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3540 if(pl.scores[ps_primary] == 0)
3543 score = me.(scores[ps_primary]);
3544 timer = TIME_ENCODED_TOSTRING(score);
3546 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3547 // distribution display
3548 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3550 distrtimer = ftos(distribution/pow(10, TIME_DECIMALS));
3552 if (distribution <= 0) {
3553 distribution_color = '0 1 0';
3556 distribution_color = '1 0 0';
3558 drawstring_aspect(pos + eX * 0.75 * mySize_x, distrtimer, eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3560 // race record display
3561 if (distribution <= 0)
3562 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3563 drawfont = hud_bigfont;
3564 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3565 drawfont = hud_font;
3566 } else if (!teamplay) { // non-teamgames
3567 // me vector := [team/connected frags id]
3568 pl = players.sort_next;
3572 if(autocvar__hud_configure)
3575 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3579 score = me.(scores[ps_primary]);
3580 if(autocvar__hud_configure)
3583 if(distribution >= 5) {
3584 distribution_color = eY;
3586 } else if(distribution >= 0) {
3587 distribution_color = '1 1 1';
3589 } else if(distribution >= -5)
3590 distribution_color = '1 1 0';
3592 distribution_color = eX;
3594 drawstring_aspect(pos + eX * 0.75 * mySize_x, ftos(distribution), eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3596 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3597 drawfont = hud_bigfont;
3598 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3599 drawfont = hud_font;
3600 } else { // teamgames
3601 float max_fragcount;
3602 max_fragcount = -99;
3605 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3606 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !autocvar__hud_configure)) // no players? don't display
3608 score = tm.(teamscores[ts_primary]);
3609 if(autocvar__hud_configure)
3613 if (score > max_fragcount)
3614 max_fragcount = score;
3616 if(tm.team == myteam) {
3617 if (max_fragcount == score)
3620 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3621 drawfont = hud_bigfont;
3622 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3623 drawfont = hud_font;
3625 if (max_fragcount == score)
3628 HUD_Panel_DrawHighlight(pos + eX * 0.75 * mySize_x + eY * (1/3) * teamnum * mySize_y, eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3629 drawstring_aspect(pos + eX * 0.75 * mySize_x + eY * (1/3) * teamnum * mySize_y, ftos(score), eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3638 void HUD_RaceTimer (void) {
3639 if(!autocvar_hud_panel_racetimer && !(gametype == GAME_RACE || gametype == GAME_CTS) && !autocvar__hud_configure)
3642 active_panel = HUD_PANEL_RACETIMER;
3643 HUD_Panel_UpdateCvars(racetimer);
3646 mySize = panel_size;
3648 HUD_Panel_DrawBg(1);
3649 if(panel_bg_padding)
3651 pos += '1 1 0' * panel_bg_padding;
3652 mySize -= '2 2 0' * panel_bg_padding;
3655 // always force 4:1 aspect
3657 if(mySize_x/mySize_y > 4)
3659 newSize_x = 4 * mySize_y;
3660 newSize_y = mySize_y;
3662 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3666 newSize_y = 1/4 * mySize_x;
3667 newSize_x = mySize_x;
3669 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3673 drawfont = hud_bigfont;
3675 string s, forcetime;
3677 if(autocvar__hud_configure)
3680 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);
3681 s = "^1Intermediate 1 (+15.42)";
3682 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);
3683 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3684 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);
3686 else if(race_checkpointtime)
3688 a = bound(0, 2 - (time - race_checkpointtime), 1);
3691 if(a > 0) // just hit a checkpoint?
3693 if(race_checkpoint != 254)
3695 if(race_time && race_previousbesttime)
3696 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3698 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3700 forcetime = TIME_ENCODED_TOSTRING(race_time);
3705 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3707 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3708 if(a > 0) // next one?
3710 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3715 if(s != "" && a > 0)
3717 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);
3720 if(race_penaltytime)
3722 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3725 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3726 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);
3732 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3733 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);
3738 if(race_laptime && race_checkpoint != 255)
3740 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3741 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);
3746 if(race_mycheckpointtime)
3748 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3749 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3750 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);
3752 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3754 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3755 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3756 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);
3759 if(race_penaltytime && !race_penaltyaccumulator)
3761 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3762 a = bound(0, (1 + t - time), 1);
3766 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3768 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3769 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);
3774 drawfont = hud_font;
3779 float vote_yescount;
3782 float vote_highlighted; // currently selected vote
3784 float vote_active; // is there an active vote?
3785 float vote_prev; // previous state of vote_active to check for a change
3787 float vote_change; // "time" when vote_active changed
3789 void HUD_VoteWindow(void)
3791 if(!autocvar_hud_panel_vote && !autocvar__hud_configure)
3794 if(!autocvar__hud_configure)
3796 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
3797 panel_bg_alpha_str = cvar_string("hud_panel_vote_bg_alpha");
3799 if(panel_bg_alpha_str == "") {
3800 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
3802 panel_bg_alpha = stof(panel_bg_alpha_str);
3807 if(vote_active != vote_prev) {
3809 vote_prev = vote_active;
3812 if(vote_active || autocvar__hud_configure)
3813 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3815 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3817 if(autocvar__hud_configure)
3827 active_panel = HUD_PANEL_VOTE;
3828 HUD_Panel_UpdateCvars(vote);
3831 mySize = panel_size;
3833 a = vote_alpha * bound(cvar("hud_panel_vote_alreadyvoted_alpha"), 1 - vote_highlighted, 1);
3834 HUD_Panel_DrawBg(a);
3835 a = panel_fg_alpha * a;
3837 if(panel_bg_padding)
3839 pos += '1 1 0' * panel_bg_padding;
3840 mySize -= '2 2 0' * panel_bg_padding;
3843 // always force 3:1 aspect
3845 if(mySize_x/mySize_y > 3)
3847 newSize_x = 3 * mySize_y;
3848 newSize_y = mySize_y;
3850 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3854 newSize_y = 1/3 * mySize_x;
3855 newSize_x = mySize_x;
3857 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3861 s = "A vote has been called for:";
3862 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3863 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1.75/8), stringwidth_colors);
3864 if(autocvar__hud_configure)
3865 s = "^1Configure the HUD";
3866 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
3868 // print the yes/no counts
3869 s = strcat("Yes (", getcommandkey("vyes", "vyes"), "): ", ftos(vote_yescount));
3870 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);
3871 s = strcat("No (", getcommandkey("vno", "vno"), "): ", ftos(vote_nocount));
3872 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);
3874 // draw the progress bar backgrounds
3875 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3877 // draw the highlights
3878 if(vote_highlighted == 1) {
3879 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3880 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3882 else if(vote_highlighted == 2) {
3883 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3884 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3887 // draw the progress bars
3888 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3889 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3891 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3892 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3894 drawresetcliparea();
3897 vote_highlighted = 0;
3901 // Mod icons panel (#10)
3904 float mod_active; // is there any active mod icon?
3906 // Clan Arena HUD modicons
3907 void HUD_Mod_CA(vector pos, vector mySize)
3909 mod_active = 1; // CA should never hide the mod icons panel
3910 float redalive, bluealive;
3911 redalive = getstati(STAT_REDALIVE);
3912 bluealive = getstati(STAT_BLUEALIVE);
3914 drawfont = hud_bigfont;
3915 vector redpos, bluepos;
3916 if(mySize_x > mySize_y)
3919 bluepos = pos + eY * 0.5 * mySize_y;
3920 drawpic_aspect_skin(redpos, "player_red.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3921 drawstring_aspect(redpos + eX * 0.5 * mySize_x, ftos(redalive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3922 drawpic_aspect_skin(bluepos, "player_blue.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3923 drawstring_aspect(bluepos + eX * 0.5 * mySize_x, ftos(bluealive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3928 bluepos = pos + eY * 0.5 * mySize_y;
3929 drawpic_aspect_skin(redpos, "player_red.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3930 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);
3931 drawpic_aspect_skin(bluepos, "player_blue.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3932 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);
3934 drawfont = hud_font;
3937 // CTF HUD modicon section
3938 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3939 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3940 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3942 void HUD_Mod_CTF_Reset(void)
3944 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3947 void HUD_Mod_CTF(vector pos, vector mySize)
3949 vector redflag_pos, blueflag_pos;
3951 float f; // every function should have that
3953 float redflag, blueflag; // current status
3954 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3957 stat_items = getstati(STAT_ITEMS);
3958 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3959 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3961 if(redflag || blueflag)
3966 if(autocvar__hud_configure)
3972 // when status CHANGES, set old status into prevstatus and current status into status
3973 if (redflag != redflag_prevframe)
3975 redflag_statuschange_time = time;
3976 redflag_prevstatus = redflag_prevframe;
3977 redflag_prevframe = redflag;
3980 if (blueflag != blueflag_prevframe)
3982 blueflag_statuschange_time = time;
3983 blueflag_prevstatus = blueflag_prevframe;
3984 blueflag_prevframe = blueflag;
3987 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3988 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3990 float BLINK_FACTOR = 0.15;
3991 float BLINK_BASE = 0.85;
3993 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3995 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3997 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3999 string red_icon, red_icon_prevstatus;
4000 float red_alpha, red_alpha_prevstatus;
4001 red_alpha = red_alpha_prevstatus = 1;
4003 case 1: red_icon = "flag_red_taken"; break;
4004 case 2: red_icon = "flag_red_lost"; break;
4005 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4007 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
4008 red_icon = "flag_red_shielded";
4010 red_icon = string_null;
4013 switch(redflag_prevstatus) {
4014 case 1: red_icon_prevstatus = "flag_red_taken"; break;
4015 case 2: red_icon_prevstatus = "flag_red_lost"; break;
4016 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4019 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
4020 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
4021 red_icon_prevstatus = "flag_red_shielded";
4023 red_icon_prevstatus = string_null;
4027 string blue_icon, blue_icon_prevstatus;
4028 float blue_alpha, blue_alpha_prevstatus;
4029 blue_alpha = blue_alpha_prevstatus = 1;
4031 case 1: blue_icon = "flag_blue_taken"; break;
4032 case 2: blue_icon = "flag_blue_lost"; break;
4033 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4035 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
4036 blue_icon = "flag_blue_shielded";
4038 blue_icon = string_null;
4041 switch(blueflag_prevstatus) {
4042 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
4043 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
4044 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
4047 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
4048 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
4049 blue_icon_prevstatus = "flag_blue_shielded";
4051 blue_icon_prevstatus = string_null;
4055 if(mySize_x > mySize_y) {
4056 if (myteam == COLOR_TEAM1) { // always draw own flag on left
4058 blueflag_pos = pos + eX * 0.5 * mySize_x;
4061 redflag_pos = pos + eX * 0.5 * mySize_x;
4063 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
4065 if (myteam == COLOR_TEAM1) { // always draw own flag on left
4067 blueflag_pos = pos + eY * 0.5 * mySize_y;
4070 redflag_pos = pos + eY * 0.5 * mySize_y;
4072 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
4075 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
4076 if(red_icon_prevstatus && f < 1)
4077 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
4079 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
4081 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
4082 if(blue_icon_prevstatus && f < 1)
4083 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
4085 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
4088 // Keyhunt HUD modicon section
4089 float kh_runheretime;
4091 void HUD_Mod_KH_Reset(void)
4096 void HUD_Mod_KH(vector pos, vector mySize)
4098 mod_active = 1; // keyhunt should never hide the mod icons panel
4102 vector p, pa, kh_size, kh_asize;
4104 kh_keys = getstati(STAT_KH_KEYS);
4107 if(mySize_x > mySize_y)
4109 p_y = pos_y + 0.25 * mySize_y;
4110 pa = p - eY * 0.25 * mySize_y;
4112 kh_size_x = mySize_x * 0.25;
4113 kh_size_y = 0.75 * mySize_y;
4114 kh_asize_x = mySize_x * 0.25;
4115 kh_asize_y = mySize_y * 0.25;
4119 p_y = pos_y + 0.125 * mySize_y;
4120 pa = p - eY * 0.125 * mySize_y;
4122 kh_size_x = mySize_x * 0.5;
4123 kh_size_y = 0.375 * mySize_y;
4124 kh_asize_x = mySize_x * 0.5;
4125 kh_asize_y = mySize_y * 0.125;
4132 for(i = 0; i < 4; ++i)
4134 key = floor(kh_keys / pow(32, i)) & 31;
4136 if(keyteam == 30 && keycount <= 4)
4138 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
4142 // this yields 8 exactly if "RUN HERE" shows
4147 kh_runheretime = time;
4148 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
4153 for(i = 0; i < 4; ++i)
4155 key = floor(kh_keys / pow(32, i)) & 31;
4168 default: // owned or dropped
4173 a = a * panel_fg_alpha;
4174 aa = aa * panel_fg_alpha;
4180 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4183 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4186 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4189 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4194 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
4197 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4200 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4203 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4206 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4210 if(mySize_x > mySize_y)
4212 p_x += 0.25 * mySize_x;
4213 pa_x += 0.25 * mySize_x;
4219 p_y = pos_y + 0.625 * mySize_y;
4220 pa_y = pos_y + 0.5 * mySize_y;
4226 p_x += 0.5 * mySize_x;
4227 pa_x += 0.5 * mySize_x;
4233 // Nexball HUD mod icon
4234 void HUD_Mod_NexBall(vector pos, vector mySize)
4236 float stat_items, nb_pb_starttime, dt, p;
4238 stat_items = getstati(STAT_ITEMS);
4239 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
4241 if (stat_items & IT_KEY1)
4246 //Manage the progress bar if any
4247 if (nb_pb_starttime > 0)
4249 dt = mod(time - nb_pb_starttime, nb_pb_period);
4250 // one period of positive triangle
4251 p = 2 * dt / nb_pb_period;
4258 if(mySize_x > mySize_y)
4260 barsize = eX * p * mySize_x + eY * mySize_y;
4265 barsize = eX * mySize_x + eY * p * mySize_y;
4268 HUD_Panel_GetProgressBarColor(nexball);
4269 HUD_Panel_DrawProgressBar(pos, vertical, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4272 if (stat_items & IT_KEY1)
4273 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4276 // Race/CTS HUD mod icons
4277 float crecordtime_prev; // last remembered crecordtime
4278 float crecordtime_change_time; // time when crecordtime last changed
4279 float srecordtime_prev; // last remembered srecordtime
4280 float srecordtime_change_time; // time when srecordtime last changed
4282 float race_status_time;
4283 float race_status_prev;
4284 string race_status_name_prev;
4285 void HUD_Mod_Race(vector pos, vector mySize)
4287 mod_active = 1; // race should never hide the mod icons panel
4289 me = playerslots[player_localentnum - 1];
4291 float f; // yet another function has this
4292 score = me.(scores[ps_primary]);
4294 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
4295 return; // no records in the actual race
4297 drawfont = hud_bigfont;
4299 // clientside personal record
4301 if(gametype == GAME_CTS)
4305 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4307 if(score && (score < t || !t)) {
4308 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4309 if(cvar("cl_autodemo_delete_keeprecords"))
4311 f = cvar("cl_autodemo_delete");
4313 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4317 if(t != crecordtime_prev) {
4318 crecordtime_prev = t;
4319 crecordtime_change_time = time;
4322 vector textPos, medalPos;
4324 if(mySize_x > mySize_y) {
4325 // text on left side
4326 squareSize = min(mySize_y, mySize_x/2);
4327 textPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eY * 0.5 * (mySize_y - squareSize);
4328 medalPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eX * 0.5 * mySize_x + eY * 0.5 * (mySize_y - squareSize);
4331 squareSize = min(mySize_x, mySize_y/2);
4332 textPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eX * 0.5 * (mySize_x - squareSize);
4333 medalPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eY * 0.5 * mySize_y + eX * 0.5 * (mySize_x - squareSize);
4336 f = time - crecordtime_change_time;
4339 drawstring_aspect(textPos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4340 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);
4342 drawstring_aspect(textPos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4343 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);
4344 drawstring_aspect_expanding(pos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4345 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);
4349 t = race_server_record;
4350 if(t != srecordtime_prev) {
4351 srecordtime_prev = t;
4352 srecordtime_change_time = time;
4354 f = time - srecordtime_change_time;
4357 drawstring_aspect(textPos + eY * 0.5 * squareSize, "Server best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4358 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);
4360 drawstring_aspect(textPos + eY * 0.5 * squareSize, "Server best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4361 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);
4362 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);
4363 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);
4366 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4367 race_status_time = time + 5;
4368 race_status_prev = race_status;
4369 if (race_status_name_prev)
4370 strunzone(race_status_name_prev);
4371 race_status_name_prev = strzone(race_status_name);
4376 a = bound(0, race_status_time - time, 1);
4379 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
4383 rank = race_CheckName(race_status_name);
4385 rankname = race_PlaceName(rank);
4388 namepos = medalPos + '0 0.8 0' * squareSize;
4390 rankpos = medalPos + '0 0.15 0' * squareSize;
4392 if(race_status == 0)
4393 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4394 else if(race_status == 1) {
4395 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);
4396 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4397 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4398 } else if(race_status == 2) {
4399 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4400 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);
4402 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);
4403 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4404 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4405 } else if(race_status == 3) {
4406 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);
4407 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4408 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4411 if (race_status_time - time <= 0) {
4412 race_status_prev = -1;
4414 if(race_status_name)
4415 strunzone(race_status_name);
4416 race_status_name = string_null;
4417 if(race_status_name_prev)
4418 strunzone(race_status_name_prev);
4419 race_status_name_prev = string_null;
4421 drawfont = hud_font;
4424 float mod_prev; // previous state of mod_active to check for a change
4426 float mod_change; // "time" when mod_active changed
4428 void HUD_ModIcons(void)
4430 if(!autocvar_hud_panel_modicons && !autocvar__hud_configure)
4433 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && gametype != GAME_CA && !autocvar__hud_configure)
4436 active_panel = HUD_PANEL_MODICONS;
4437 HUD_Panel_UpdateCvars(modicons);
4440 mySize = panel_size;
4442 if(mod_active != mod_prev) {
4444 mod_prev = mod_active;
4447 if(mod_active || autocvar__hud_configure)
4448 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4450 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4453 HUD_Panel_DrawBg(mod_alpha);
4455 if(panel_bg_padding)
4457 pos += '1 1 0' * panel_bg_padding;
4458 mySize -= '2 2 0' * panel_bg_padding;
4461 // these MUST be ran in order to update mod_active
4462 if(gametype == GAME_KEYHUNT)
4463 HUD_Mod_KH(pos, mySize);
4464 else if(gametype == GAME_CTF || autocvar__hud_configure)
4465 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4466 else if(gametype == GAME_NEXBALL)
4467 HUD_Mod_NexBall(pos, mySize);
4468 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4469 HUD_Mod_Race(pos, mySize);
4470 else if(gametype == GAME_CA)
4471 HUD_Mod_CA(pos, mySize);
4474 // Draw pressed keys (#11)
4476 void HUD_DrawPressedKeys(void)
4478 if(!autocvar_hud_panel_pressedkeys && !autocvar__hud_configure)
4481 if(!(spectatee_status > 0 || autocvar_hud_panel_pressedkeys >= 2 || autocvar__hud_configure))
4484 active_panel = HUD_PANEL_PRESSEDKEYS;
4485 HUD_Panel_UpdateCvars(pressedkeys);
4488 mySize = panel_size;
4490 HUD_Panel_DrawBg(1);
4491 if(panel_bg_padding)
4493 pos += '1 1 0' * panel_bg_padding;
4494 mySize -= '2 2 0' * panel_bg_padding;
4497 // force custom aspect
4498 float aspect = cvar("hud_panel_pressedkeys_aspect");
4502 if(mySize_x/mySize_y > aspect)
4504 newSize_x = aspect * mySize_y;
4505 newSize_y = mySize_y;
4507 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4511 newSize_y = 1/aspect * mySize_x;
4512 newSize_x = mySize_x;
4514 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4520 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4523 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4524 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4525 drawpic_aspect_skin(pos + eX * mySize_x * (1/3), ((pressedkeys & KEY_FORWARD) ? "key_forward_inv.tga" : "key_forward.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4526 drawpic_aspect_skin(pos + eX * mySize_x * (2/3), ((pressedkeys & KEY_JUMP) ? "key_jump_inv.tga" : "key_jump.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4527 drawpic_aspect_skin(pos + eY * 0.5 * mySize_y, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4528 drawpic_aspect_skin(pos + eY * 0.5 * mySize_y + eX * mySize_x * (1/3), ((pressedkeys & KEY_BACKWARD) ? "key_backward_inv.tga" : "key_backward.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4529 drawpic_aspect_skin(pos + eY * 0.5 * mySize_y + eX * mySize_x * (2/3), ((pressedkeys & KEY_RIGHT) ? "key_right_inv.tga" : "key_right.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4532 // Handle chat as a panel (#12)
4536 if(!autocvar_hud_panel_chat && !autocvar__hud_configure)
4538 cvar_set("con_chatrect", "0");
4542 active_panel = HUD_PANEL_CHAT;
4543 HUD_Panel_UpdateCvars(chat);
4545 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
4547 panel_pos_y = panel_bg_border;
4548 panel_size_y = vid_conheight - panel_bg_border * 2;
4549 if(panel_bg == "0") // force a border when maximized
4551 if(precache_pic(panel_bg) == "") {
4552 panel_bg = strcat(hud_skin_path, "/border_default");
4553 if(precache_pic(panel_bg) == "") {
4554 panel_bg = "gfx/hud/default/border_default";
4558 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an alpha of at least 0.75
4563 mySize = panel_size;
4565 HUD_Panel_DrawBg(1);
4567 if(panel_bg_padding)
4569 pos += '1 1 0' * panel_bg_padding;
4570 mySize -= '2 2 0' * panel_bg_padding;
4573 cvar_set("con_chatrect", "1");
4575 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4576 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4578 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4579 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4581 if(autocvar__hud_configure)
4584 chatsize = cvar("con_chatsize");
4585 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4587 for(i = 0; i < cvar("con_chat"); ++i)
4589 if(i == cvar("con_chat") - 1)
4592 a = panel_fg_alpha * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4593 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);
4598 // Engine info panel (#13)
4605 float frametimeavg1; // 1 frame ago
4606 float frametimeavg2; // 2 frames ago
4607 void HUD_EngineInfo(void)
4609 if(!autocvar_hud_panel_engineinfo && !autocvar__hud_configure)
4612 active_panel = HUD_PANEL_ENGINEINFO;
4613 HUD_Panel_UpdateCvars(engineinfo);
4616 mySize = panel_size;
4618 HUD_Panel_DrawBg(1);
4619 if(panel_bg_padding)
4621 pos += '1 1 0' * panel_bg_padding;
4622 mySize -= '2 2 0' * panel_bg_padding;
4625 float currentTime = gettime(GETTIME_REALTIME);
4626 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
4628 float currentframetime = currentTime - prevfps_time;
4629 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4630 frametimeavg2 = frametimeavg1;
4631 frametimeavg1 = frametimeavg;
4634 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4635 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.
4637 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
4638 prevfps = (1/currentframetime);
4639 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"
4641 prevfps_time = currentTime;
4646 if(currentTime - prevfps_time > cvar("hud_panel_engineinfo_framecounter_time"))
4648 prevfps = framecounter/(currentTime - prevfps_time);
4650 prevfps_time = currentTime;
4655 color = HUD_Get_Num_Color (prevfps, 100);
4656 drawfont = hud_bigfont;
4657 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_panel_engineinfo_framecounter_decimals"))), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4658 drawfont = hud_font;
4661 // Info messages panel (#14)
4663 #define drawInfoMessage(s)\
4664 if(autocvar_hud_panel_infomessages_flip)\
4665 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);\
4666 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
4668 void HUD_InfoMessages(void)
4670 if(!autocvar_hud_panel_infomessages && !autocvar__hud_configure)
4673 active_panel = HUD_PANEL_INFOMESSAGES;
4674 HUD_Panel_UpdateCvars(infomessages);
4677 mySize = panel_size;
4679 HUD_Panel_DrawBg(1);
4680 if(panel_bg_padding)
4682 pos += '1 1 0' * panel_bg_padding;
4683 mySize -= '2 2 0' * panel_bg_padding;
4686 // always force 5:1 aspect
4688 if(mySize_x/mySize_y > 5)
4690 newSize_x = 5 * mySize_y;
4691 newSize_y = mySize_y;
4693 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4697 newSize_y = 1/5 * mySize_x;
4698 newSize_x = mySize_x;
4700 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4709 fontsize = '0.20 0.20 0' * mySize_y;
4712 if(spectatee_status != 0)
4718 if(!autocvar__hud_configure)
4720 if(spectatee_status && !intermission)
4722 if(spectatee_status == -1)
4725 s = strcat("^1Spectating: ^7", GetPlayerName(spectatee_status - 1));
4728 if(spectatee_status == -1)
4729 s = strcat("^1Press ^3", getcommandkey("primary fire", "+fire"), "^1 to spectate");
4731 s = strcat("^1Press ^3", getcommandkey("primary fire", "+fire"), "^1 for another player");
4734 if(spectatee_status == -1)
4735 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
4737 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+fire2"), "^1 to observe");
4740 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
4743 if(gametype == GAME_ARENA)
4744 s = "^1Wait for your turn to join";
4745 else if(gametype == GAME_LMS)
4748 sk = playerslots[player_localentnum - 1];
4749 if(sk.(scores[ps_primary]) >= 666)
4750 s = "^1Match has already begun";
4751 else if(sk.(scores[ps_primary]) > 0)
4752 s = "^1You have no more lives left";
4754 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4757 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4760 //show restart countdown:
4761 if (time < getstatf(STAT_GAMESTARTTIME)) {
4763 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4764 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4765 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
4766 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4770 if(warmup_stage && !intermission)
4772 s = "^2Currently in ^1warmup^2 stage!";
4777 if(mod(time, 1) >= 0.5)
4782 if(ready_waiting && !intermission && !spectatee_status)
4784 if(ready_waiting_for_me)
4787 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
4789 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
4794 s = strcat("^2Waiting for others to ready up to end warmup...");
4796 s = strcat("^2Waiting for others to ready up...");
4800 else if(warmup_stage && !intermission && !spectatee_status)
4802 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
4806 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4808 float ts_min, ts_max;
4809 tm = teams.sort_next;
4812 for(; tm.sort_next; tm = tm.sort_next)
4814 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4816 if(!ts_min) ts_min = tm.team_size;
4817 else ts_min = min(ts_min, tm.team_size);
4818 if(!ts_max) ts_max = tm.team_size;
4819 else ts_max = max(ts_max, tm.team_size);
4821 if ((ts_max - ts_min) > 1)
4823 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
4824 tm = GetTeam(myteam, false);
4826 if (tm.team != COLOR_SPECTATOR)
4827 if (tm.team_size == ts_max)
4828 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
4836 s = "^7Press ^3ESC ^7to show HUD options.";
4838 s = "^3Doubleclick ^7a panel for panel-specific options.";
4840 s = "^3CTRL ^7to disable collision testing, ^3SHIFT ^7and";
4842 s = "^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.";
4853 void HUD_ShowSpeed(void)
4856 float pos, conversion_factor;
4857 string speed, zspeed, unit;
4859 switch(cvar("cl_showspeed_unit"))
4864 conversion_factor = 1.0;
4868 conversion_factor = 1.0;
4872 conversion_factor = 0.0254;
4876 conversion_factor = 0.0254 * 3.6;
4880 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4884 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4888 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4890 numsize_x = numsize_y = cvar("cl_showspeed_size");
4891 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4893 drawfont = hud_bigfont;
4894 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
4896 if (cvar("cl_showspeed_z") == 1) {
4897 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4898 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
4901 drawfont = hud_font;
4904 vector acc_prevspeed;
4908 void HUD_ShowAcceleration(void)
4910 float acceleration, sz, scale, alpha, f;
4911 vector pos, top, rgb;
4912 top_x = vid_conwidth/2;
4915 f = time - acc_prevtime;
4916 if(cvar("cl_showacceleration_z"))
4917 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4919 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4920 acc_prevspeed = pmove_vel;
4921 acc_prevtime = time;
4923 f = bound(0, f * 10, 1);
4924 acc_avg = acc_avg * (1 - f) + acceleration * f;
4925 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4926 if (acceleration == 0)
4929 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4931 sz = cvar("cl_showacceleration_size");
4932 scale = cvar("cl_showacceleration_scale");
4933 alpha = cvar("cl_showacceleration_alpha");
4934 if (cvar("cl_showacceleration_color_custom"))
4935 rgb = stov(cvar_string("cl_showacceleration_color"));
4937 if (acceleration < 0)
4938 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4940 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4943 if (acceleration > 0)
4944 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
4946 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
4949 void HUD_Reset (void)
4951 // reset gametype specific icons
4952 if(gametype == GAME_KEYHUNT)
4954 else if(gametype == GAME_CTF)
4955 HUD_Mod_CTF_Reset();
4958 #define HUD_DrawPanel(id)\
4960 case (HUD_PANEL_RADAR):\
4961 HUD_Radar(); break;\
4962 case (HUD_PANEL_WEAPONS):\
4963 HUD_Weapons(); break;\
4964 case (HUD_PANEL_AMMO):\
4966 case (HUD_PANEL_POWERUPS):\
4967 HUD_Powerups(); break;\
4968 case (HUD_PANEL_HEALTHARMOR):\
4969 HUD_HealthArmor(); break;\
4970 case (HUD_PANEL_NOTIFY):\
4971 HUD_Notify(); break;\
4972 case (HUD_PANEL_TIMER):\
4973 HUD_Timer(); break;\
4974 case (HUD_PANEL_SCORE):\
4975 HUD_Score(); break;\
4976 case (HUD_PANEL_RACETIMER):\
4977 HUD_RaceTimer(); break;\
4978 case (HUD_PANEL_VOTE):\
4979 HUD_VoteWindow(); break;\
4980 case (HUD_PANEL_MODICONS):\
4981 HUD_ModIcons(); break;\
4982 case (HUD_PANEL_PRESSEDKEYS):\
4983 HUD_DrawPressedKeys(); break;\
4984 case (HUD_PANEL_CHAT):\
4986 case (HUD_PANEL_ENGINEINFO):\
4987 HUD_EngineInfo(); break;\
4988 case (HUD_PANEL_INFOMESSAGES):\
4989 HUD_InfoMessages(); break;\
4990 } ENDS_WITH_CURLY_BRACE
4992 void HUD_Main (void)
4994 // global hud alpha fade
4995 if(menu_enabled == 1)
4998 hud_fade_alpha = (1 - autocvar__menu_alpha);
5000 if(scoreboard_fade_alpha)
5001 hud_fade_alpha = (1 - scoreboard_fade_alpha);
5003 if(intermission == 2) // no hud during mapvote
5005 else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
5008 hud_fontsize = HUD_GetFontsize("hud_fontsize");
5010 if(!autocvar__hud_configure && !hud_fade_alpha)
5014 if (hud_skin_path != cvar_string("hud_skin"))
5017 strunzone(hud_skin_path);
5018 hud_skin_path = strzone(strcat("gfx/hud/", cvar_string("hud_skin")));
5021 // HUD configure visible grid
5022 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
5026 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2); ++i)
5028 drawfill(eX * i * vid_conwidth * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2), eX + eY * vid_conheight, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
5031 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2); ++i)
5033 drawfill(eY * i * vid_conheight * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2), eY + eX * vid_conwidth, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
5038 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
5042 float hud_dock_color_team = cvar("hud_dock_color_team");
5043 if((teamplay) && hud_dock_color_team) {
5044 f = stof(getplayerkey(player_localentnum - 1, "colors"));
5045 color = colormapPaletteColor(mod(f, 16), 1) * hud_dock_color_team;
5047 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
5048 color = '1 0 0' * hud_dock_color_team;
5052 string hud_dock_color = cvar_string("hud_dock_color");
5053 if(hud_dock_color == "shirt") {
5054 f = stof(getplayerkey(player_localentnum - 1, "colors"));
5055 color = colormapPaletteColor(floor(f / 16), 0);
5057 else if(hud_dock_color == "pants") {
5058 f = stof(getplayerkey(player_localentnum - 1, "colors"));
5059 color = colormapPaletteColor(mod(f, 16), 1);
5062 color = stov(hud_dock_color);
5066 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
5067 if(precache_pic(pic) == "") {
5068 pic = strcat(hud_skin_path, "/dock_medium");
5069 if(precache_pic(pic) == "") {
5070 pic = "gfx/hud/default/dock_medium";
5073 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...
5076 // cache the panel order into the panel_order array
5077 if(autocvar__hud_panelorder != hud_panelorder_prev) {
5078 if(hud_panelorder_prev)
5079 strunzone(hud_panelorder_prev);
5080 hud_panelorder_prev = strzone(autocvar__hud_panelorder);
5081 tokenize_console(autocvar__hud_panelorder);
5082 for(i = 0; i < HUD_PANEL_NUM; ++i) {
5083 panel_order[i] = stof(argv(i));
5086 // draw panels in order specified by panel_order array
5087 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
5088 if(i != HUD_PANEL_CHAT || !autocvar__con_chat_maximized) // don't draw maximized chat panel twice!
5089 HUD_DrawPanel(panel_order[i]);
5092 // draw chat panel on top if it is maximized
5093 if(autocvar__con_chat_maximized)
5094 HUD_Chat(); // HUD_DrawPanel(HUD_PANEL_CHAT);
5096 // TODO hud_'ify these
5097 if (cvar("cl_showspeed"))
5099 if (cvar("cl_showacceleration"))
5100 HUD_ShowAcceleration();
5102 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)
5103 localcmd("cmd selectteam auto; cmd join\n");
5105 hud_configure_prev = autocvar__hud_configure;
5107 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again