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 // drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
88 #define drawpic_aspect(pos,pic,mySize,color,alpha,drawflag)\
91 imgsize = drawgetimagesize(pic);\
92 imgaspect = imgsize_x/imgsize_y;\
96 if(aspect > imgaspect) {\
97 sz_x = sz_y * imgaspect;\
98 drawpic(pos + eX * (oldsz_x - sz_x) * 0.5, pic, sz, color, alpha, drawflag);\
100 sz_y = sz_x / imgaspect;\
101 drawpic(pos + eY * (oldsz_y - sz_y) * 0.5, pic, sz, color, alpha, drawflag);\
106 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
107 #define drawpic_aspect_skin(pos,pic,sz,color,alpha,drawflag)\
109 picpath = strcat(hud_skin_path, "/", pic);\
110 if(precache_pic(picpath) == "") {\
111 picpath = strcat("gfx/hud/default/", pic);\
113 drawpic_aspect(pos, picpath, sz, color, alpha, drawflag);\
116 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
117 #define drawpic_skin(pos,pic,sz,color,alpha,drawflag)\
119 picpath = strcat(hud_skin_path, "/", pic);\
120 if(precache_pic(picpath) == "") {\
121 picpath = strcat("gfx/hud/default/", pic);\
123 drawpic(pos, picpath, sz, color, alpha, drawflag);\
127 void drawpic_aspect_skin_expanding(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
129 //drawpic_aspect_expanding(pos, strcat("gfx/hud/", autocvar_hud_skin, "/", pic), sz, rgb, alpha, flag, fadelerp);
132 void drawpic_aspect_skin_expanding_two(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
134 //drawpic_aspect_expanding_two(pos, strcat("gfx/hud/", autocvar_hud_skin, "/", pic), sz, rgb, alpha, flag, fadelerp);
137 vector HUD_Get_Num_Color (float x, float maxvalue)
145 else if(x > maxvalue * 0.75) {
146 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
147 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
150 else if(x > maxvalue * 0.5) {
151 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
152 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
153 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
155 else if(x > maxvalue * 0.25) {
158 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
160 else if(x > maxvalue * 0.1) {
162 color_y = (x-20)*90/27/100; // green value between 0 -> 1
163 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
173 float stringwidth_colors(string s, vector theSize)
175 return stringwidth(s, TRUE, theSize);
178 float stringwidth_nocolors(string s, vector theSize)
180 return stringwidth(s, FALSE, theSize);
183 #define CENTERPRINT_MAX_LINES 30
184 string centerprint_messages[CENTERPRINT_MAX_LINES];
185 float centerprint_width[CENTERPRINT_MAX_LINES];
186 vector centerprint_start;
187 float centerprint_expire;
188 float centerprint_num;
189 float centerprint_offset_hint;
190 vector centerprint_fontsize;
192 void centerprint(string strMessage)
194 float i, j, n, hcount;
197 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
199 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
201 if(cvar("scr_centertime") <= 0)
207 // strip trailing newlines
208 j = strlen(strMessage) - 1;
209 while(substring(strMessage, j, 1) == "\n" && j >= 0)
211 strMessage = substring(strMessage, 0, j + 1);
216 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
218 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
220 strMessage = substring(strMessage, j, strlen(strMessage) - j);
221 centerprint_offset_hint = j;
226 // if we get here, we have a message. Initialize its height.
229 n = tokenizebyseparator(strMessage, "\n");
231 for(j = 0; j < n; ++j)
233 getWrappedLine_remaining = argv(j);
234 while(getWrappedLine_remaining)
236 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
237 if(centerprint_messages[i])
238 strunzone(centerprint_messages[i]);
239 centerprint_messages[i] = strzone(s);
240 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
243 // half height for empty lines looks better
249 if(i >= CENTERPRINT_MAX_LINES)
255 h = centerprint_fontsize_y*hcount;
257 havail = vid_conheight;
258 if(cvar("con_chatpos") < 0)
259 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
260 if(havail > vid_conheight - 70)
261 havail = vid_conheight - 70; // avoid overlapping HUD
263 centerprint_start_x = 0;
266 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
268 // here, the centerprint would cover the crosshair. REALLY BAD.
269 forbiddenmin = vid_conheight * 0.5 - h - 16;
270 forbiddenmax = vid_conheight * 0.5 + 16;
272 allowedmin = scoreboard_bottom;
273 allowedmax = havail - h;
274 preferred = (havail - h)/2;
277 // possible orderings (total: 4! / 4 = 6)
278 // allowedmin allowedmax forbiddenmin forbiddenmax
279 // forbiddenmin forbiddenmax allowedmin allowedmax
280 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
282 // forbidden doesn't matter in this case
283 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
285 // allowedmin forbiddenmin allowedmax forbiddenmax
286 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
288 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
290 // allowedmin forbiddenmin forbiddenmax allowedmax
291 else if(allowedmin < forbiddenmin)
293 // make sure the forbidden zone is not covered
294 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
295 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
297 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
299 // forbiddenmin allowedmin allowedmax forbiddenmax
300 else if(allowedmax < forbiddenmax)
302 // it's better to leave the allowed zone (overlap with scoreboard) than
303 // to cover the forbidden zone (crosshair)
304 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
305 centerprint_start_y = forbiddenmax;
307 centerprint_start_y = forbiddenmin;
309 // forbiddenmin allowedmin forbiddenmax allowedmax
312 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
315 centerprint_start_y =
318 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
326 centerprint_expire = time + cvar("scr_centertime");
329 void HUD_DrawCenterPrint (void)
336 //if(time > centerprint_expire)
339 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
340 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
341 //sz = 1.2 / (a + 0.2);
346 pos = centerprint_start;
347 for (i=0; i<centerprint_num; i = i + 1)
349 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
350 ts = centerprint_messages[i];
353 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
354 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
355 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
356 pos_y = pos_y + centerprint_fontsize_y;
359 // half height for empty lines looks better
360 pos_y = pos_y + centerprint_fontsize_y * 0.5;
364 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
366 position_x -= 2 / 3 * strlen(text) * scale_x;
367 drawstring(position, text, scale, rgb, alpha, flag);
370 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
372 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
373 drawstring(position, text, scale, rgb, alpha, flag);
376 // return the string of the given race place
377 string race_PlaceName(float pos) {
385 return strcat(ftos(pos), "th");
388 // return the string of the onscreen race timer
389 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
397 if(histime == 0) // goal hit
401 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
411 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
417 lapstr = strcat(" (-", ftos(lapdelta), "L)");
420 else if(lapdelta < 0)
422 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
426 else if(histime > 0) // anticipation
428 if(mytime >= histime)
429 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
431 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
438 cpname = "Start line";
440 cpname = "Finish line";
442 cpname = strcat("Intermediate ", ftos(cp));
444 cpname = "Finish line";
447 return strcat(col, cpname);
448 else if(hisname == "")
449 return strcat(col, cpname, " (", timestr, ")");
451 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
454 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
455 float race_CheckName(string net_name) {
457 for (i=RANKINGS_CNT-1;i>=0;--i)
458 if(grecordholder[i] == net_name)
470 void HUD_Panel_ExportCfg(string cfgname)
473 fh = fopen(strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg"), FILE_WRITE);
476 fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
477 fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
478 fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
479 fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
480 fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
481 fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
482 fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
483 fputs(fh, strcat("seta hud_fg_alpha \"", cvar_string("hud_fg_alpha"), "\"", "\n"));
486 fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
487 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
488 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
489 fputs(fh, strcat("seta hud_dock_alpha \"", cvar_string("hud_dock_alpha"), "\"", "\n"));
492 fputs(fh, strcat("seta hud_progressbar_alpha \"", cvar_string("hud_progressbar_alpha"), "\"", "\n"));
493 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
494 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
495 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
496 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
497 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
498 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
501 fputs(fh, strcat("seta _hud_panelorder \"", cvar_string("hud_nexball_color"), "\"", "\n"));
504 // common cvars for all panels
506 for (i = 0; i < HUD_PANEL_NUM; ++i)
510 fputs(fh, strcat("seta hud_", panel_name, " ", cvar_string(strcat("hud_", panel_name)), "\n"));
511 fputs(fh, strcat("seta hud_", panel_name, "_pos \"", cvar_string(strcat("hud_", panel_name, "_pos")), "\"", "\n"));
512 fputs(fh, strcat("seta hud_", panel_name, "_size \"", cvar_string(strcat("hud_", panel_name, "_size")), "\"", "\n"));
513 fputs(fh, strcat("seta hud_", panel_name, "_bg \"", cvar_string(strcat("hud_", panel_name, "_bg")), "\"", "\n"));
514 fputs(fh, strcat("seta hud_", panel_name, "_bg_color \"", cvar_string(strcat("hud_", panel_name, "_bg_color")), "\"", "\n"));
515 fputs(fh, strcat("seta hud_", panel_name, "_bg_color_team \"", cvar_string(strcat("hud_", panel_name, "_bg_color_team")), "\"", "\n"));
516 fputs(fh, strcat("seta hud_", panel_name, "_bg_alpha \"", cvar_string(strcat("hud_", panel_name, "_bg_alpha")), "\"", "\n"));
517 fputs(fh, strcat("seta hud_", panel_name, "_bg_border \"", cvar_string(strcat("hud_", panel_name, "_bg_border")), "\"", "\n"));
518 fputs(fh, strcat("seta hud_", panel_name, "_bg_padding \"", cvar_string(strcat("hud_", panel_name, "_bg_padding")), "\"", "\n"));
520 case HUD_PANEL_WEAPONICONS:
521 fputs(fh, strcat("seta hud_", panel_name, "_accuracy_yellow \"", cvar_string(strcat("hud_", panel_name, "_accuracy_yellow")), "\"", "\n"));
522 fputs(fh, strcat("seta hud_", panel_name, "_complainbubble \"", cvar_string(strcat("hud_", panel_name, "_complainbubble")), "\"", "\n"));
523 fputs(fh, strcat("seta hud_", panel_name, "_complainbubble_size \"", cvar_string(strcat("hud_", panel_name, "_complainbubble_size")), "\"", "\n"));
525 case HUD_PANEL_INVENTORY:
526 fputs(fh, strcat("seta hud_", panel_name, "_onlycurrent \"", cvar_string(strcat("hud_", panel_name, "_onlycurrent")), "\"", "\n"));
527 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
529 case HUD_PANEL_POWERUPS:
530 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\"", "\n"));
531 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
532 fputs(fh, strcat("seta hud_", panel_name, "_baralign \"", cvar_string(strcat("hud_", panel_name, "_baralign")), "\"", "\n"));
534 case HUD_PANEL_HEALTHARMOR:
535 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\n"));
536 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
537 fputs(fh, strcat("seta hud_", panel_name, "_baralign \"", cvar_string(strcat("hud_", panel_name, "_baralign")), "\"", "\n"));
539 case HUD_PANEL_NOTIFY:
540 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\"", "\n"));
541 fputs(fh, strcat("seta hud_", panel_name, "_info_top \"", cvar_string(strcat("hud_", panel_name, "_info_top")), "\"", "\n"));
543 case HUD_PANEL_RADAR:
544 fputs(fh, strcat("seta hud_", panel_name, "_foreground_alpha \"", cvar_string(strcat("hud_", panel_name, "_foreground_alpha")), "\"", "\n"));
547 fputs(fh, strcat("seta hud_", panel_name, "_alreadyvoted_alpha \"", cvar_string(strcat("hud_", panel_name, "_alreadyvoted_alpha")), "\"", "\n"));
553 print("^2Successfully exported to hud_", autocvar_hud_skin, "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
558 // return smoothly faded size of given panel when a dialog is active
559 vector HUD_Panel_GetMenuSize(float id)
564 mySize = eX * mySize_x * vid_conwidth + eY * mySize_y * vid_conheight;
566 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
568 vector menu_enable_maxsize, menu_enable_size;
569 menu_enable_maxsize = '0 0 0'; // shut up FTEQCC
570 menu_enable_maxsize_x = 0.3 * vid_conwidth;
571 menu_enable_maxsize_y = 0.18 * vid_conheight;
572 if(mySize_x > mySize_y)
574 if(mySize_y > menu_enable_maxsize_y)
576 menu_enable_size_y = menu_enable_maxsize_y;
577 menu_enable_size_x = mySize_x * (menu_enable_maxsize_y/mySize_y);
578 mySize = (1 - autocvar__menu_alpha) * mySize + (autocvar__menu_alpha) * menu_enable_size;
583 if(mySize_x > menu_enable_maxsize_x)
585 menu_enable_size_x = menu_enable_maxsize_x;
586 menu_enable_size_y = mySize_y * (menu_enable_maxsize_x/mySize_x);
587 mySize = (1 - autocvar__menu_alpha) * mySize + (autocvar__menu_alpha) * menu_enable_size;
594 // return smoothly faded pos of given panel when a dialog is active
595 vector HUD_Panel_GetMenuPos(float id)
600 pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
602 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
604 vector mySize, menu_enable_panelpos;
605 mySize = HUD_Panel_GetMenuSize(id);
606 if(mySize_x > mySize_y)
607 menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * mySize_x + eY * 0.82 * vid_conheight;
609 menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * mySize_y + eX * 0.7 * vid_conwidth;
610 pos = (1 - autocvar__menu_alpha) * pos + (autocvar__menu_alpha) * menu_enable_panelpos;
615 const float hlBorderSize = 4;
616 const string hlBorder = "gfx/hud/default/border_highlighted";
617 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
618 void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
620 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
621 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);
622 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);
623 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);
624 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);
627 // draw the background/borders
628 #define HUD_Panel_DrawBg(alpha)\
630 draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, strcat(hud_skin_path, "/", panel_bg), panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));\
631 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
632 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);
634 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
640 pic = strcat(hud_skin_path, "/");
642 drawsubpic(pos, eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, strcat(pic, "statusbar_vertical"), '0 0 0', '1 0.25 0', color, alpha, drawflag);
643 if(mySize_y/mySize_x > 2)
644 drawsubpic(pos + eY * mySize_x, eY * (mySize_y - 2 * mySize_x) + eX * mySize_x, strcat(pic, "statusbar_vertical"), '0 0.25 0', '1 0.5 0', color, alpha, drawflag);
645 drawsubpic(pos + eY * mySize_y - eY * min(mySize_y * 0.5, mySize_x), eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, strcat(pic, "statusbar_vertical"), '0 0.75 0', '1 0.25 0', color, alpha, drawflag);
647 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, strcat(pic, "statusbar"), '0 0 0', '0.25 1 0', color, alpha, drawflag);
648 if(mySize_x/mySize_y > 2)
649 drawsubpic(pos + eX * mySize_y, eX * (mySize_x - 2 * mySize_y) + eY * mySize_y, strcat(pic, "statusbar"), '0.25 0 0', '0.5 1 0', color, alpha, drawflag);
650 drawsubpic(pos + eX * mySize_x - eX * min(mySize_x * 0.5, mySize_y), eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, strcat(pic, "statusbar"), '0.75 0 0', '0.25 1 0', color, alpha, drawflag);
654 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
660 pic = strcat(hud_skin_path, "/");
661 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, strcat(pic, "num_leading"), '0 0 0', '0.25 1 0', color, alpha, drawflag);
662 if(mySize_x/mySize_y > 2)
663 drawsubpic(pos + eX * mySize_y, eX * (mySize_x - 2 * mySize_y) + eY * mySize_y, strcat(pic, "num_leading"), '0.25 0 0', '0.5 1 0', color, alpha, drawflag);
664 drawsubpic(pos + eX * mySize_x - eX * min(mySize_x * 0.5, mySize_y), eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, strcat(pic, "num_leading"), '0.75 0 0', '0.25 1 0', color, alpha, drawflag);
667 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
668 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
679 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
680 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
682 for (i = 0; i < HUD_PANEL_NUM; ++i) {
683 if(i == highlightedPanel || !panel_enabled)
686 HUD_Panel_UpdatePosSizeForId(i)
688 panel_pos -= '1 1 0' * panel_bg_border;
689 panel_size += '2 2 0' * panel_bg_border;
691 if(myPos_y + mySize_y < panel_pos_y)
693 if(myPos_y > panel_pos_y + panel_size_y)
696 if(myPos_x + mySize_x < panel_pos_x)
698 if(myPos_x > panel_pos_x + panel_size_x)
701 // OK, there IS a collision.
703 myCenter_x = myPos_x + 0.5 * mySize_x;
704 myCenter_y = myPos_y + 0.5 * mySize_y;
706 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
707 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
709 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
711 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
712 myTarget_x = panel_pos_x - mySize_x;
713 else // push it upwards
714 myTarget_y = panel_pos_y - mySize_y;
716 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
718 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
719 myTarget_x = panel_pos_x + panel_size_x;
720 else // push it upwards
721 myTarget_y = panel_pos_y - mySize_y;
723 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
725 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
726 myTarget_x = panel_pos_x - mySize_x;
727 else // push it downwards
728 myTarget_y = panel_pos_y + panel_size_y;
730 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
732 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
733 myTarget_x = panel_pos_x + panel_size_x;
734 else // push it downwards
735 myTarget_y = panel_pos_y + panel_size_y;
737 if(cvar("hud_configure_checkcollisions_debug"))
738 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
744 void HUD_Panel_SetPos(vector pos)
746 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
750 if(cvar("hud_configure_checkcollisions_debug"))
751 drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
753 if(autocvar_hud_configure_grid)
755 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;
756 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;
759 if(hud_configure_checkcollisions)
760 pos = HUD_Panel_CheckMove(pos, mySize);
762 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
763 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
766 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
768 HUD_Panel_GetName(highlightedPanel);
769 cvar_set(strcat("hud_", panel_name, "_pos"), s);
772 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
773 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
783 ratio = mySize_x/mySize_y;
785 for (i = 0; i < HUD_PANEL_NUM; ++i) {
786 if(i == highlightedPanel || !panel_enabled)
789 HUD_Panel_UpdatePosSizeForId(i)
791 panel_pos -= '1 1 0' * panel_bg_border;
792 panel_size += '2 2 0' * panel_bg_border;
794 targEndPos = panel_pos + panel_size;
796 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
797 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
800 if (resizeCorner == 1)
802 // check if this panel is on our way
803 if (resizeorigin_x <= panel_pos_x)
805 if (resizeorigin_y <= panel_pos_y)
807 if (targEndPos_x <= resizeorigin_x - mySize_x)
809 if (targEndPos_y <= resizeorigin_y - mySize_y)
812 // there is a collision:
813 // detect which side of the panel we are facing is actually limiting the resizing
814 // (which side the resize direction finds for first) and reduce the size up to there
816 // dist is the distance between resizeorigin and the "analogous" point of the panel
817 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
818 dist_x = resizeorigin_x - targEndPos_x;
819 dist_y = resizeorigin_y - targEndPos_y;
820 if (dist_y <= 0 || dist_x / dist_y > ratio)
821 mySize_x = min(mySize_x, dist_x);
823 mySize_y = min(mySize_y, dist_y);
825 else if (resizeCorner == 2)
827 if (resizeorigin_x >= targEndPos_x)
829 if (resizeorigin_y <= panel_pos_y)
831 if (panel_pos_x >= resizeorigin_x + mySize_x)
833 if (targEndPos_y <= resizeorigin_y - mySize_y)
836 dist_x = panel_pos_x - resizeorigin_x;
837 dist_y = resizeorigin_y - targEndPos_y;
838 if (dist_y <= 0 || dist_x / dist_y > ratio)
839 mySize_x = min(mySize_x, dist_x);
841 mySize_y = min(mySize_y, dist_y);
843 else if (resizeCorner == 3)
845 if (resizeorigin_x <= panel_pos_x)
847 if (resizeorigin_y >= targEndPos_y)
849 if (targEndPos_x <= resizeorigin_x - mySize_x)
851 if (panel_pos_y >= resizeorigin_y + mySize_y)
854 dist_x = resizeorigin_x - targEndPos_x;
855 dist_y = panel_pos_y - resizeorigin_y;
856 if (dist_y <= 0 || dist_x / dist_y > ratio)
857 mySize_x = min(mySize_x, dist_x);
859 mySize_y = min(mySize_y, dist_y);
861 else if (resizeCorner == 4)
863 if (resizeorigin_x >= targEndPos_x)
865 if (resizeorigin_y >= targEndPos_y)
867 if (panel_pos_x >= resizeorigin_x + mySize_x)
869 if (panel_pos_y >= resizeorigin_y + mySize_y)
872 dist_x = panel_pos_x - resizeorigin_x;
873 dist_y = panel_pos_y - resizeorigin_y;
874 if (dist_y <= 0 || dist_x / dist_y > ratio)
875 mySize_x = min(mySize_x, dist_x);
877 mySize_y = min(mySize_y, dist_y);
879 if(cvar("hud_configure_checkcollisions_debug"))
880 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
886 void HUD_Panel_SetPosSize(vector mySize)
888 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
890 resizeorigin = panel_click_resizeorigin;
893 // minimum panel size cap
894 mySize_x = max(0.025 * vid_conwidth, mySize_x);
895 mySize_y = max(0.025 * vid_conheight, mySize_y);
897 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.
899 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
900 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
903 // collision testing|
904 // -----------------+
906 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
907 if(resizeCorner == 1) {
908 myPos_x = resizeorigin_x - mySize_x;
909 myPos_y = resizeorigin_y - mySize_y;
910 } else if(resizeCorner == 2) {
911 myPos_x = resizeorigin_x;
912 myPos_y = resizeorigin_y - mySize_y;
913 } else if(resizeCorner == 3) {
914 myPos_x = resizeorigin_x - mySize_x;
915 myPos_y = resizeorigin_y;
916 } else { // resizeCorner == 4
917 myPos_x = resizeorigin_x;
918 myPos_y = resizeorigin_y;
921 // left/top screen edges
923 mySize_x = mySize_x + myPos_x;
925 mySize_y = mySize_y + myPos_y;
927 // bottom/right screen edges
928 if(myPos_x + mySize_x > vid_conwidth)
929 mySize_x = vid_conwidth - myPos_x;
930 if(myPos_y + mySize_y > vid_conheight)
931 mySize_y = vid_conheight - myPos_y;
933 if(cvar("hud_configure_checkcollisions_debug"))
934 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
936 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
937 if(autocvar_hud_configure_grid)
939 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;
940 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;
943 if(hud_configure_checkcollisions)
944 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
946 // 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)
947 mySize_x = max(0.025 * vid_conwidth, mySize_x);
948 mySize_y = max(0.025 * vid_conheight, mySize_y);
950 // do another pos check, as size might have changed by now
951 if(resizeCorner == 1) {
952 myPos_x = resizeorigin_x - mySize_x;
953 myPos_y = resizeorigin_y - mySize_y;
954 } else if(resizeCorner == 2) {
955 myPos_x = resizeorigin_x;
956 myPos_y = resizeorigin_y - mySize_y;
957 } else if(resizeCorner == 3) {
958 myPos_x = resizeorigin_x - mySize_x;
959 myPos_y = resizeorigin_y;
960 } else { // resizeCorner == 4
961 myPos_x = resizeorigin_x;
962 myPos_y = resizeorigin_y;
965 if(cvar("hud_configure_checkcollisions_debug"))
966 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
968 HUD_Panel_GetName(highlightedPanel);
970 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
971 cvar_set(strcat("hud_", panel_name, "_size"), s);
973 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
974 cvar_set(strcat("hud_", panel_name, "_pos"), s);
978 float prevMouseClicked; // previous state
979 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
980 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
983 float menu_enabled_time;
984 float pressed_key_time;
985 void HUD_Panel_Arrow_Action(float nPrimary)
987 if (highlightedPanel_prev == -1 || mouseClicked)
990 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
993 if(autocvar_hud_configure_grid)
995 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
997 if (hudShiftState & S_SHIFT)
998 step = bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
1000 step = 2 * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
1004 if (hudShiftState & S_SHIFT)
1005 step = bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
1007 step = 2 * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
1012 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
1013 step = vid_conheight;
1015 step = vid_conwidth;
1016 if (hudShiftState & S_SHIFT)
1017 step = (step / 256); // more precision
1019 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
1022 highlightedPanel = highlightedPanel_prev;
1024 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
1026 if (hudShiftState & S_ALT) // resize
1028 highlightedAction = 1;
1029 if(nPrimary == K_UPARROW)
1031 else if(nPrimary == K_RIGHTARROW)
1033 else if(nPrimary == K_LEFTARROW)
1035 else // if(nPrimary == K_DOWNARROW)
1038 // ctrl+arrow reduces the size, instead of increasing it
1039 // Note that ctrl disables collisions check too, but it's fine
1040 // since we don't collide with anything reducing the size
1041 if (hudShiftState & S_CTRL) {
1043 resizeCorner = 5 - resizeCorner;
1047 mySize = panel_size;
1048 panel_click_resizeorigin = panel_pos;
1049 if(resizeCorner == 1) {
1050 panel_click_resizeorigin += mySize;
1052 } else if(resizeCorner == 2) {
1053 panel_click_resizeorigin_y += mySize_y;
1055 } else if(resizeCorner == 3) {
1056 panel_click_resizeorigin_x += mySize_x;
1058 } else { // resizeCorner == 4
1061 HUD_Panel_SetPosSize(mySize);
1065 highlightedAction = 2;
1068 if(nPrimary == K_UPARROW)
1070 else if(nPrimary == K_DOWNARROW)
1072 else if(nPrimary == K_LEFTARROW)
1074 else // if(nPrimary == K_RIGHTARROW)
1077 HUD_Panel_SetPos(pos);
1081 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1083 if(!autocvar__hud_configure)
1086 // allow console bind to work
1089 con_keys = findkeysforcommand("toggleconsole");
1090 keys = tokenize(con_keys);
1092 float hit_con_bind, i;
1093 for (i = 0; i < keys; ++i)
1095 if(nPrimary == stof(argv(i)))
1099 if(bInputType == 0) {
1100 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1101 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1102 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1104 else if(bInputType == 1) {
1105 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1106 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1107 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1110 if(nPrimary == K_MOUSE1)
1112 if(bInputType == 0) { // key pressed
1116 else if(bInputType == 1) {// key released
1121 else if(nPrimary == K_ESCAPE)
1123 if (bInputType == 1)
1125 disable_menu_alphacheck = 1;
1127 menu_enabled_time = time;
1128 localcmd("menu_showhudexit\n");
1130 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1132 if (bInputType == 1)
1134 pressed_key_time = 0;
1137 else if (pressed_key_time == 0)
1138 pressed_key_time = time;
1140 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1142 else if(hit_con_bind)
1145 return true; // Suppress ALL other input
1148 float HUD_Panel_HighlightCheck()
1154 while(j <= HUD_PANEL_NUM)
1159 HUD_Panel_UpdatePosSizeForId(i)
1161 panelPos = panel_pos;
1162 panelSize = panel_size;
1163 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1166 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1170 // resize from topleft border
1171 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)
1175 // resize from topright border
1176 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)
1180 // resize from bottomleft border
1181 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)
1185 // resize from bottomright border
1186 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)
1194 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1195 void HUD_Panel_FirstInDrawQ(float id)
1198 var float place = -1;
1199 // find out where in the array our current id is, save into place
1200 for(i = 0; i < HUD_PANEL_NUM; ++i)
1202 if(panel_order[i] == id)
1208 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1210 place = HUD_PANEL_NUM - 1;
1212 // move all ids up by one step in the array until "place"
1213 for(i = place; i > 0; --i)
1215 panel_order[i] = panel_order[i-1];
1217 // now save the new top id
1218 panel_order[0] = id;
1220 // let's save them into the cvar by some strcat trickery
1222 for(i = 0; i < HUD_PANEL_NUM; ++i)
1224 s = strcat(s, ftos(panel_order[i]), " ");
1226 cvar_set("_hud_panelorder", s);
1227 if(hud_panelorder_prev)
1228 strunzone(hud_panelorder_prev);
1229 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1232 void HUD_Panel_Highlight()
1238 while(j <= HUD_PANEL_NUM)
1243 HUD_Panel_UpdatePosSizeForId(i)
1245 panelPos = panel_pos;
1246 panelSize = panel_size;
1247 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1250 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1252 highlightedPanel = i;
1253 HUD_Panel_FirstInDrawQ(i);
1254 highlightedAction = 1;
1255 panel_click_distance = mousepos - panelPos;
1258 // resize from topleft border
1259 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)
1261 highlightedPanel = i;
1262 HUD_Panel_FirstInDrawQ(i);
1263 highlightedAction = 2;
1265 panel_click_distance = mousepos - panelPos;
1266 panel_click_resizeorigin = panelPos + panelSize;
1269 // resize from topright border
1270 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)
1272 highlightedPanel = i;
1273 HUD_Panel_FirstInDrawQ(i);
1274 highlightedAction = 2;
1276 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1277 panel_click_distance_y = mousepos_y - panelPos_y;
1278 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1281 // resize from bottomleft border
1282 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)
1284 highlightedPanel = i;
1285 HUD_Panel_FirstInDrawQ(i);
1286 highlightedAction = 2;
1288 panel_click_distance_x = mousepos_x - panelPos_x;
1289 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1290 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1293 // resize from bottomright border
1294 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)
1296 highlightedPanel = i;
1297 HUD_Panel_FirstInDrawQ(i);
1298 highlightedAction = 2;
1300 panel_click_distance = panelSize - mousepos + panelPos;
1301 panel_click_resizeorigin = panelPos;
1306 highlightedPanel_prev = -1;
1311 float highlightcheck;
1312 void HUD_Panel_Mouse()
1314 // 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
1315 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1316 disable_menu_alphacheck = 0;
1317 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1321 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1322 print("Highlighted: ", ftos(highlightedPanel), "\n");
1323 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1326 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1327 highlightedPanel = -1;
1328 highlightedAction = 0;
1330 if(highlightedPanel != -1)
1331 highlightedPanel_prev = highlightedPanel;
1333 mousepos = mousepos + getmousepos();
1335 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1336 mousepos_y = bound(0, mousepos_y, vid_conheight);
1340 if(prevMouseClicked == 0)
1341 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1343 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1345 if(highlightedAction == 1)
1346 HUD_Panel_SetPos(mousepos - panel_click_distance);
1347 else if(highlightedAction == 2)
1350 if(resizeCorner == 1) {
1351 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1352 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1353 } else if(resizeCorner == 2) {
1354 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1355 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1356 } else if(resizeCorner == 3) {
1357 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1358 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1359 } else { // resizeCorner == 4
1360 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1361 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1363 HUD_Panel_SetPosSize(mySize);
1366 // doubleclick check
1367 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1369 mouseClicked = 0; // to prevent spam, I guess.
1370 disable_menu_alphacheck = 2;
1372 menu_enabled_time = time;
1373 HUD_Panel_GetName(highlightedPanel)
1374 localcmd("menu_showhudoptions ", panel_name, "\n");
1377 if(prevMouseClicked == 0)
1379 prevMouseClickedTime = time;
1380 prevMouseClickedPos = mousepos;
1385 highlightcheck = HUD_Panel_HighlightCheck();
1387 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1390 cursorsize = '32 32 0';
1392 if(highlightcheck == 0)
1393 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1394 else if(highlightcheck == 1)
1395 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1396 else if(highlightcheck == 2)
1397 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1399 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1401 prevMouseClicked = mouseClicked;
1404 // Weapon icons (#0)
1406 float weaponspace[10];
1407 #define HUD_WeaponIcons_Clear()\
1409 for(idx = 0; idx < 10; ++idx)\
1410 weaponspace[idx] = 0;
1412 entity weaponorder[WEP_MAXCOUNT];
1413 void weaponorder_swap(float i, float j, entity pass)
1417 weaponorder[i] = weaponorder[j];
1421 string weaponorder_cmp_str_save;
1422 string weaponorder_cmp_str;
1423 float weaponorder_cmp(float i, float j, entity pass)
1426 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1427 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1428 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)
1431 void HUD_WeaponIcons(void)
1433 if(!autocvar_hud_weaponicons && !autocvar__hud_configure)
1436 float id = HUD_PANEL_WEAPONICONS;
1437 HUD_Panel_UpdateCvarsForId(id);
1438 float alpha, stat_weapons; // "constants"
1440 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1443 mySize = panel_size;
1445 stat_weapons = getstati(STAT_WEAPONS);
1447 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1449 self = get_weaponinfo(i);
1450 if(self.impulse >= 0)
1454 // TODO make this configurable
1455 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1457 if(weaponorder_cmp_str != weaponorder_cmp_str_save)
1459 if(weaponorder_cmp_str_save)
1460 strunzone(weaponorder_cmp_str_save);
1461 weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
1463 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1465 self = get_weaponinfo(i);
1466 if(self.impulse >= 0)
1468 weaponorder[weapon_cnt] = self;
1472 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1475 HUD_Panel_DrawBg(1);
1476 if(panel_bg_padding)
1478 pos += '1 1 0' * panel_bg_padding;
1479 mySize -= '2 2 0' * panel_bg_padding;
1483 weapon_stats = getstati(STAT_DAMAGE_HITS);
1484 weapon_number = weapon_stats & 63;
1485 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1487 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1488 weapon_number = weapon_stats & 63;
1489 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1491 if(cvar_or("hud_weaponicons_fade", 1))
1493 fade = 3.2 - 2 * (time - weapontime);
1494 fade = bound(0.7, fade, 1);
1499 HUD_WeaponIcons_Clear();
1501 float rows, columns;
1502 rows = mySize_y/mySize_x;
1503 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1504 // ^^^ weapon icon aspect goes here
1506 columns = ceil(WEP_COUNT/rows);
1511 when = autocvar_hud_weaponicons_complainbubble_time;
1513 fadetime = autocvar_hud_weaponicons_complainbubble_fadetime;
1516 for(i = 0; i < weapon_cnt; ++i)
1518 self = weaponorder[i];
1519 weapid = self.impulse;
1521 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1523 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1524 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1526 // draw background behind currently selected weapon
1527 if(self.weapon == activeweapon)
1528 drawpic_aspect_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), "weapon_current_bg", eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1530 // draw the weapon accuracy on the HUD
1531 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1534 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1536 // yellow_accuracy = value at which accuracy becomes yellow
1537 if(weapon_stats >= 100) {
1541 else if(weapon_stats > autocvar_hud_weaponicons_accuracy_yellow) {
1542 color_x = 1 - (weapon_stats-autocvar_hud_weaponicons_accuracy_yellow)/(100-autocvar_hud_weaponicons_accuracy_yellow); // red value between 1 -> 0
1546 color_y = weapon_stats/autocvar_hud_weaponicons_accuracy_yellow; // green value between 0 -> 1
1550 drawpic_aspect_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), "weapon_accuracy", eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), color, panel_fg_alpha, DRAWFLAG_NORMAL);
1553 // draw the weapon icon
1554 if((self.impulse >= 0) && (stat_weapons & self.weapons))
1556 drawpic_aspect_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), strcat("weapon", self.netname), eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1558 if(autocvar_hud_weaponicons_number == 1) // weapon number
1559 drawstring(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), ftos(weapid), '1 1 0' * 0.5 * mySize_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1560 else if(autocvar_hud_weaponicons_number == 2) // bind
1561 drawstring(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * mySize_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1564 // draw a "ghost weapon icon" if you don't have the weapon
1567 drawpic_aspect_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), strcat("weapon", self.netname), eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
1570 // draw the complain message
1571 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_weaponicons_complainbubble)
1575 if(complain_weapon_time + when > time)
1578 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1582 if(complain_weapon_time + when > time)
1588 vector complain_bubble_size = '100 50 0' * bound(0.25, autocvar_hud_weaponicons_complainbubble_size, 2);
1589 drawpic_aspect_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows) - complain_bubble_size + 0.5 * (eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows)), "weapon_complainbubble", complain_bubble_size, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
1592 if(complain_weapon_type == 0) {
1593 s = "Out of ammo for the";
1596 else if(complain_weapon_type == 1) {
1597 s = "You don't have the";
1601 s = "Map doesn't have the";
1604 drawstring_aspect(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows) - complain_bubble_size + eX * 0.05 * complain_bubble_size_x + eY * (1/6) * complain_bubble_size_y + 0.5 * (eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows)), s, eX * 0.9 * complain_bubble_size_x + eY * 0.2 * complain_bubble_size_y, 0.2 * complain_bubble_size_y, color, panel_fg_alpha * a, DRAWFLAG_NORMAL);
1605 drawstring_aspect(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows) - complain_bubble_size + eX * 0.05 * complain_bubble_size_x + eY * (11/30) * complain_bubble_size_y + 0.5 * (eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows)), complain_weapon_name, eX * 0.9 * complain_bubble_size_x + eY * 0.25 * complain_bubble_size_y, 0.25 * complain_bubble_size_y, '1 0 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
1621 float GetAmmoStat(float i)
1625 case 0: return STAT_SHELLS;
1626 case 1: return STAT_NAILS;
1627 case 2: return STAT_ROCKETS;
1628 case 3: return STAT_CELLS;
1629 case 4: return STAT_FUEL;
1634 float GetAmmoItemCode(float i)
1638 case 0: return IT_SHELLS;
1639 case 1: return IT_NAILS;
1640 case 2: return IT_ROCKETS;
1641 case 3: return IT_CELLS;
1642 case 4: return IT_FUEL;
1647 string GetAmmoPicture(float i)
1651 case 0: return "ammo_shells";
1652 case 1: return "ammo_bullets";
1653 case 2: return "ammo_rockets";
1654 case 3: return "ammo_cells";
1655 case 4: return "ammo_fuel";
1660 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1663 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1664 if(autocvar__hud_configure)
1674 if(currently_selected)
1679 vector newSize, newPos;
1680 if(mySize_x/mySize_y > 3)
1682 newSize_x = 3 * mySize_y;
1683 newSize_y = mySize_y;
1685 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1690 newSize_y = 1/3 * mySize_x;
1691 newSize_x = mySize_x;
1693 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1697 vector picpos, numpos;
1698 if(autocvar_hud_inventory_iconalign)
1701 picpos = newPos + eX * 2 * newSize_y;
1705 numpos = newPos + eX * newSize_y;
1709 if (currently_selected)
1710 drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1712 drawfont = hud_bigfont;
1713 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1714 drawfont = hud_font;
1715 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1718 void HUD_Inventory(void)
1720 if(!autocvar_hud_inventory && !autocvar__hud_configure)
1723 float id = HUD_PANEL_INVENTORY;
1724 HUD_Panel_UpdateCvarsForId(id);
1725 float i, currently_selected;
1729 mySize = panel_size;
1731 HUD_Panel_DrawBg(1);
1732 if(panel_bg_padding)
1734 pos += '1 1 0' * panel_bg_padding;
1735 mySize -= '2 2 0' * panel_bg_padding;
1738 float rows, columns;
1739 rows = mySize_y/mySize_x;
1740 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1741 // ^^^ ammo item aspect goes here
1743 columns = ceil(AMMO_COUNT/rows);
1747 for (i = 0; i < AMMO_COUNT; ++i) {
1748 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1749 if(autocvar_hud_inventory_onlycurrent) {
1750 if(autocvar__hud_configure)
1752 if (currently_selected || autocvar__hud_configure)
1753 DrawAmmoItem(pos, mySize, i, currently_selected);
1756 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);
1761 column = column + 1;
1767 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color)
1769 vector newSize, newPos;
1770 if(mySize_x/mySize_y > 3)
1772 newSize_x = 3 * mySize_y;
1773 newSize_y = mySize_y;
1775 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1780 newSize_y = 1/3 * mySize_x;
1781 newSize_x = mySize_x;
1783 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1787 vector picpos, numpos;
1790 if(iconalign == 1 || iconalign == 3) // right align
1793 picpos = newPos + eX * 2 * newSize_y;
1797 numpos = newPos + eX * newSize_y;
1803 if(iconalign == 0 || iconalign == 3) // left align
1805 numpos = newPos + eX * newSize_y;
1811 picpos = newPos + eX * 2 * newSize_y;
1815 drawfont = hud_bigfont;
1816 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, newSize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1817 drawfont = hud_font;
1818 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1823 void HUD_Powerups(void) {
1824 if(!autocvar_hud_powerups && !autocvar__hud_configure)
1827 float id = HUD_PANEL_POWERUPS;
1828 HUD_Panel_UpdateCvarsForId(id);
1830 stat_items = getstati(STAT_ITEMS);
1832 if(!autocvar__hud_configure)
1834 if not(stat_items & IT_STRENGTH)
1835 if not(stat_items & IT_INVINCIBLE)
1838 if (getstati(STAT_HEALTH) <= 0)
1844 mySize = panel_size;
1846 HUD_Panel_DrawBg(1);
1847 if(panel_bg_padding)
1849 pos += '1 1 0' * panel_bg_padding;
1850 mySize -= '2 2 0' * panel_bg_padding;
1853 float strength_time, shield_time;
1855 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1856 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1858 if(autocvar__hud_configure)
1864 vector barpos, barsize;
1868 string leftname, rightname;
1869 float leftcnt, rightcnt;
1870 float leftexact, rightexact;
1871 float leftalpha, rightalpha;
1872 if (autocvar_hud_powerups_flip) {
1873 leftname = "strength";
1874 leftcnt = ceil(strength_time);
1875 leftexact = strength_time;
1877 rightname = "shield";
1878 rightcnt = ceil(shield_time);
1879 rightexact = shield_time;
1881 leftname = "shield";
1882 leftcnt = ceil(shield_time);
1883 leftexact = shield_time;
1885 rightname = "strength";
1886 rightcnt = ceil(strength_time);
1887 rightexact = strength_time;
1889 leftalpha = bound(0, leftexact, 1);
1890 rightalpha = bound(0, rightexact, 1);
1892 drawfont = hud_bigfont;
1893 if (mySize_x/mySize_y > 4)
1897 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1898 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1899 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1900 } else { // left align
1902 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1905 HUD_Panel_GetProgressBarColor(leftname)
1906 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1907 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1');
1910 // drawpic_aspect_skin_expanding_two(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_ADDITIVE, bound(0, (leftcnt - leftexact) / 0.5, 1));
1912 // drawpic_aspect_skin(picpos, leftname, eX * (1/6) * mySize_x + eY * mySize_y, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1917 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1918 barpos = pos + eX * 0.5 * mySize_x;
1919 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1920 } else { // right align
1921 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1922 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1925 HUD_Panel_GetProgressBarColor(rightname)
1926 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1927 DrawNumIcon(autocvar_hud_powerups_iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1');
1930 else if (mySize_x/mySize_y > 1.5)
1934 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1935 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1936 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1937 } else { // left align
1939 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1942 HUD_Panel_GetProgressBarColor(leftname)
1943 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1944 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1');
1949 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1950 barpos = pos + eY * 0.5 * mySize_y;
1951 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1952 } else { // right align
1953 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1954 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1957 HUD_Panel_GetProgressBarColor(rightname)
1958 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1959 DrawNumIcon(autocvar_hud_powerups_iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1');
1966 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // down align
1967 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1968 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1969 } else { // up align
1971 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1974 if(autocvar_hud_powerups_iconalign == 1 || autocvar_hud_powerups_iconalign == 3) { // down align
1975 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
1976 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
1977 } else { // up align
1978 picpos = pos + eX * 0.05 * mySize_x;
1979 numpos = pos + eY * 0.4 * mySize_x;
1982 HUD_Panel_GetProgressBarColor(leftname)
1983 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1985 //drawpic_aspect_skin_expanding_two(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_ADDITIVE, bound(0, (leftcnt - leftexact) / 0.5, 1));
1987 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1988 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1993 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // up align
1994 barpos = pos + eX * 0.5 * mySize_x;
1995 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1996 } else { // down align
1997 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1998 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2001 if(autocvar_hud_powerups_iconalign == 0 || autocvar_hud_powerups_iconalign == 3) { // up align
2002 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2003 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2004 } else { // down align
2005 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2006 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2009 HUD_Panel_GetProgressBarColor(rightname)
2010 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2012 // drawpic_aspect_skin_expanding_two(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_ADDITIVE, bound(0, (rightcnt - rightexact) / 0.5, 1));
2014 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2015 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2018 drawfont = hud_font;
2021 // Health/armor (#3)
2023 void HUD_HealthArmor(void)
2025 if(!autocvar_hud_healtharmor && !autocvar__hud_configure)
2028 float id = HUD_PANEL_HEALTHARMOR;
2029 HUD_Panel_UpdateCvarsForId(id);
2032 mySize = panel_size;
2034 HUD_Panel_DrawBg(1);
2035 if(panel_bg_padding)
2037 pos += '1 1 0' * panel_bg_padding;
2038 mySize -= '2 2 0' * panel_bg_padding;
2041 float armor, health;
2042 armor = getstati(STAT_ARMOR);
2043 health = getstati(STAT_HEALTH);
2046 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
2048 if(autocvar__hud_configure)
2058 vector barpos, barsize;
2062 drawfont = hud_bigfont;
2063 if(autocvar_hud_healtharmor == 2) // combined health and armor display
2066 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2071 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2072 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2073 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2074 } else { // left align
2076 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2080 if(v_z) // NOT fully armored
2082 biggercount = "health";
2083 HUD_Panel_GetProgressBarColor("health")
2084 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2086 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);
2090 biggercount = "armor";
2091 HUD_Panel_GetProgressBarColor("armor")
2092 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2094 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);
2096 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200));
2101 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2102 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2103 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2106 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2108 HUD_Panel_GetProgressBarColor("fuel")
2109 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2114 string leftname, rightname;
2115 float leftcnt, rightcnt;
2116 float leftactive, rightactive;
2117 float leftalpha, rightalpha;
2118 if (autocvar_hud_healtharmor_flip) { // old style layout with armor left/top of health
2123 leftalpha = min((armor+10)/55, 1);
2125 rightname = "health";
2130 leftname = "health";
2135 rightname = "armor";
2139 rightalpha = min((armor+10)/55, 1);
2142 if (mySize_x/mySize_y > 4)
2146 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2147 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2148 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2149 } else { // left align
2151 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2154 HUD_Panel_GetProgressBarColor(leftname)
2155 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2156 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2161 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2162 barpos = pos + eX * 0.5 * mySize_x;
2163 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2164 } else { // right align
2165 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2166 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2169 HUD_Panel_GetProgressBarColor(rightname)
2170 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2171 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(leftcnt, 200));
2176 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2177 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2178 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2181 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2183 HUD_Panel_GetProgressBarColor("fuel")
2184 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2187 else if (mySize_x/mySize_y > 1.5)
2191 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2192 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2193 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2194 } else { // left align
2196 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2199 HUD_Panel_GetProgressBarColor(leftname)
2200 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2201 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2206 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2207 barpos = pos + eY * 0.5 * mySize_y;
2208 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2209 } else { // right align
2210 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2211 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2214 HUD_Panel_GetProgressBarColor(rightname)
2215 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2216 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(leftcnt, 200));
2221 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2222 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2223 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2226 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2228 HUD_Panel_GetProgressBarColor("fuel")
2229 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2236 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // down align
2237 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2238 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2239 } else { // up align
2241 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2244 if(autocvar_hud_healtharmor_iconalign == 1 || autocvar_hud_healtharmor_iconalign == 3) { // down align
2245 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2246 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2247 } else { // up align
2248 picpos = pos + eX * 0.05 * mySize_x;
2249 numpos = pos + eY * 0.4 * mySize_x;
2252 HUD_Panel_GetProgressBarColor(leftname)
2253 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2254 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2255 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, 0.25 * mySize_x, HUD_Get_Num_Color(leftcnt, 200), panel_fg_alpha, DRAWFLAG_NORMAL);
2260 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // up align
2261 barpos = pos + eX * 0.5 * mySize_x;
2262 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2263 } else { // down align
2264 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2265 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2268 if(autocvar_hud_healtharmor_iconalign == 0 || autocvar_hud_healtharmor_iconalign == 3) { // up align
2269 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2270 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2271 } else { // down align
2272 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2273 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2276 HUD_Panel_GetProgressBarColor(rightname)
2277 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2278 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2279 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, 0.25 * mySize_x, HUD_Get_Num_Color(rightcnt, 200), panel_fg_alpha, DRAWFLAG_NORMAL);
2284 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2286 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2288 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2289 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2291 HUD_Panel_GetProgressBarColor("fuel")
2292 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2296 drawfont = hud_font;
2299 // Notification area (#4)
2302 string Weapon_SuicideMessage(float deathtype)
2304 w_deathtype = deathtype;
2305 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2306 return w_deathtypestring;
2309 string Weapon_KillMessage(float deathtype)
2311 w_deathtype = deathtype;
2312 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2313 return w_deathtypestring;
2316 float killnotify_times[10];
2317 float killnotify_deathtype[10];
2318 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2319 string killnotify_attackers[10];
2320 string killnotify_victims[10];
2321 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2324 for (i = 9; i > 0; --i) {
2325 killnotify_times[i] = killnotify_times[i-1];
2326 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2327 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2328 if(killnotify_attackers[i])
2329 strunzone(killnotify_attackers[i]);
2330 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2331 if(killnotify_victims[i])
2332 strunzone(killnotify_victims[i]);
2333 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2335 killnotify_times[0] = time;
2336 killnotify_deathtype[0] = wpn;
2337 killnotify_actiontype[0] = actiontype;
2338 if(killnotify_attackers[0])
2339 strunzone(killnotify_attackers[0]);
2340 killnotify_attackers[0] = strzone(attacker);
2341 if(killnotify_victims[0])
2342 strunzone(killnotify_victims[0]);
2343 killnotify_victims[0] = strzone(victim);
2346 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2350 alsoprint = (autocvar_hud_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2352 if(msg == MSG_SUICIDE) {
2354 w = DEATH_WEAPONOF(type);
2356 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2358 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2359 } else if (type == DEATH_KILL) {
2360 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2362 print ("^1",s1, "^1 couldn't take it anymore\n");
2363 } else if (type == DEATH_ROT) {
2364 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2366 print ("^1",s1, "^1 died\n");
2367 } else if (type == DEATH_NOAMMO) {
2368 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2370 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2371 } else if (type == DEATH_CAMP) {
2372 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2374 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2375 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2376 HUD_KillNotify_Push(s1, "", 0, type);
2378 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2379 } else if (type == DEATH_CHEAT) {
2380 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2382 print ("^1",s1, "^1 unfairly eliminated themself\n");
2383 } else if (type == DEATH_FIRE) {
2384 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2386 print ("^1",s1, "^1 burned to death\n");
2387 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2388 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2390 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2393 if (stof(s2) > 2) // killcount > 2
2394 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2395 } else if(msg == MSG_KILL) {
2396 w = DEATH_WEAPONOF(type);
2398 HUD_KillNotify_Push(s2, s1, 1, w);
2400 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2402 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2403 HUD_KillNotify_Push(s1, s2, 1, type);
2406 if(cvar("cl_gentle")) {
2407 print ("^1", s1, "^1 took action against a team mate\n");
2409 print ("^1", s1, "^1 mows down a team mate\n");
2412 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2413 if(cvar("cl_gentle"))
2414 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2416 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2418 else if (stof(s2) > 2) {
2419 if(cvar("cl_gentle"))
2420 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2422 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2425 else if(type == KILL_FIRST_BLOOD)
2426 print("^1",s1, "^1 drew first blood", "\n");
2428 else if (type == DEATH_TELEFRAG)
2429 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2430 else if (type == DEATH_DROWN) {
2431 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2433 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2435 else if (type == DEATH_SLIME) {
2436 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2438 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2440 else if (type == DEATH_LAVA) {
2441 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2443 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2445 else if (type == DEATH_FALL) {
2446 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2448 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2450 else if (type == DEATH_SHOOTING_STAR) {
2451 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2453 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2455 else if (type == DEATH_SWAMP) {
2456 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2458 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2460 else if (type == DEATH_HURTTRIGGER)
2462 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2464 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2465 } else if(type == DEATH_SBCRUSH) {
2466 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2468 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2469 } else if(type == DEATH_SBMINIGUN) {
2470 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2472 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2473 } else if(type == DEATH_SBROCKET) {
2474 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2476 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2477 } else if(type == DEATH_SBBLOWUP) {
2478 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2480 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2481 } else if(type == DEATH_WAKIGUN) {
2482 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2484 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2485 } else if(type == DEATH_WAKIROCKET) {
2486 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2488 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2489 } else if(type == DEATH_WAKIBLOWUP) {
2490 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2492 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2493 } else if(type == DEATH_TURRET) {
2494 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2496 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2497 } else if(type == DEATH_TOUCHEXPLODE) {
2498 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2500 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2501 } else if(type == DEATH_CHEAT) {
2502 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2504 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2505 } else if (type == DEATH_FIRE) {
2506 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2508 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2509 } else if (type == DEATH_CUSTOM) {
2510 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2512 print ("^1",s1, "^1 ", s2, "\n");
2514 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2516 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2518 } else if(msg == MSG_SPREE) {
2519 if(type == KILL_END_SPREE) {
2520 if(cvar("cl_gentle"))
2521 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2523 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2524 } else if(type == KILL_SPREE) {
2525 if(cvar("cl_gentle"))
2526 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2528 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2529 } else if(type == KILL_SPREE_3) {
2530 if(cvar("cl_gentle"))
2531 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2533 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2534 } else if(type == KILL_SPREE_5) {
2535 if(cvar("cl_gentle"))
2536 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2538 print (s1,"^7 unleashes ^1RAGE\n");
2539 } else if(type == KILL_SPREE_10) {
2540 if(cvar("cl_gentle"))
2541 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2543 print (s1,"^7 starts the ^1MASSACRE!\n");
2544 } else if(type == KILL_SPREE_15) {
2545 if(cvar("cl_gentle"))
2546 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2548 print (s1,"^7 executes ^1MAYHEM!\n");
2549 } else if(type == KILL_SPREE_20) {
2550 if(cvar("cl_gentle"))
2551 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2553 print (s1,"^7 is a ^1BERSERKER!\n");
2554 } else if(type == KILL_SPREE_25) {
2555 if(cvar("cl_gentle"))
2556 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2558 print (s1,"^7 inflicts ^1CARNAGE!\n");
2559 } else if(type == KILL_SPREE_30) {
2560 if(cvar("cl_gentle"))
2561 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2563 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2565 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2566 if (type == DEATH_DROWN) {
2567 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2570 if(cvar("cl_gentle"))
2571 print ("^1",s1, "^1 was in the water for too long\n");
2573 print ("^1",s1, "^1 drowned\n");
2575 } else if (type == DEATH_SLIME) {
2576 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2578 print ("^1",s1, "^1 was slimed\n");
2579 } else if (type == DEATH_LAVA) {
2580 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2583 if(cvar("cl_gentle"))
2584 print ("^1",s1, "^1 found a hot place\n");
2586 print ("^1",s1, "^1 turned into hot slag\n");
2588 } else if (type == DEATH_FALL) {
2589 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2592 if(cvar("cl_gentle"))
2593 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2595 print ("^1",s1, "^1 hit the ground with a crunch\n");
2597 } else if (type == DEATH_SHOOTING_STAR) {
2598 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2600 print ("^1",s1, "^1 became a shooting star\n");
2601 } else if (type == DEATH_SWAMP) {
2602 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2605 if(cvar("cl_gentle"))
2606 print ("^1",s1, "^1 discovered a swamp\n");
2608 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2610 } else if(type == DEATH_TURRET) {
2611 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2613 print ("^1",s1, "^1 was mowed down by a turret \n");
2614 } else if (type == DEATH_CUSTOM) {
2615 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2617 print ("^1",s1, "^1 ", s2, "\n");
2618 } else if (type == DEATH_HURTTRIGGER) {
2619 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2621 print ("^1",s1, "^1 was in the wrong place\n");
2622 } else if(type == DEATH_TOUCHEXPLODE) {
2623 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2625 print ("^1",s1, "^1 died in an accident\n");
2626 } else if(type == DEATH_CHEAT) {
2627 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2629 print ("^1",s1, "^1 was unfairly eliminated\n");
2630 } else if(type == DEATH_FIRE) {
2631 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2634 if(cvar("cl_gentle"))
2635 print ("^1",s1, "^1 felt a little hot\n");
2637 print ("^1",s1, "^1 burnt to death\n");
2640 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2643 if(cvar("cl_gentle"))
2644 print ("^1",s1, "^1 needs a restart\n");
2646 print ("^1",s1, "^1 died\n");
2649 } else if(msg == MSG_KILL_ACTION_SPREE) {
2650 if(cvar("cl_gentle"))
2651 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2653 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2654 } else if(msg == MSG_INFO) {
2655 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2656 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2657 print(s1, "^7 got the ", s2, "\n");
2658 } else if(type == INFO_LOSTFLAG) {
2659 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2660 print(s1, "^7 lost the ", s2, "\n");
2661 } else if(type == INFO_PICKUPFLAG) {
2662 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2663 print(s1, "^7 picked up the ", s2, "\n");
2664 } else if(type == INFO_RETURNFLAG) {
2665 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2666 print(s1, "^7 returned the ", s2, "\n");
2671 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2673 void HUD_Centerprint(string s1, string s2, float type, float msg)
2675 if(msg == MSG_SUICIDE) {
2676 if (type == DEATH_TEAMCHANGE) {
2677 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2678 } else if (type == DEATH_AUTOTEAMCHANGE) {
2679 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2680 } else if (type == DEATH_CAMP) {
2681 if(cvar("cl_gentle"))
2682 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2684 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2685 } else if (type == DEATH_NOAMMO) {
2686 if(cvar("cl_gentle"))
2687 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2689 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2690 } else if (type == DEATH_ROT) {
2691 if(cvar("cl_gentle"))
2692 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2694 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2695 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2696 if(cvar("cl_gentle"))
2697 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2699 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2700 } else if (type == DEATH_QUIET) {
2702 } else if (type == DEATH_KILL) {
2703 if(cvar("cl_gentle"))
2704 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2706 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2708 } else if(msg == MSG_KILL) {
2709 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2710 if(cvar("cl_gentle")) {
2711 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2713 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2715 } else if (type == KILL_FIRST_BLOOD) {
2716 if(cvar("cl_gentle")) {
2717 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2719 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2721 } else if (type == KILL_FIRST_VICTIM) {
2722 if(cvar("cl_gentle")) {
2723 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2725 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2727 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2728 if(cvar("cl_gentle")) {
2729 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2731 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2733 } else if (type == KILL_TYPEFRAGGED) {
2734 if(cvar("cl_gentle")) {
2735 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2737 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2739 } else if (type == KILL_FRAG) {
2740 if(cvar("cl_gentle")) {
2741 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2743 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2745 } else if (type == KILL_FRAGGED) {
2746 if(cvar("cl_gentle")) {
2747 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2749 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2752 } else if(msg == MSG_KILL_ACTION) {
2753 // TODO: invent more centerprints here?
2754 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2758 void HUD_Notify (void)
2760 if(!autocvar_hud_notify && !autocvar__hud_configure)
2763 float id = HUD_PANEL_NOTIFY;
2764 HUD_Panel_UpdateCvarsForId(id);
2767 mySize = panel_size;
2769 HUD_Panel_DrawBg(1);
2770 if(panel_bg_padding)
2772 pos += '1 1 0' * panel_bg_padding;
2773 mySize -= '2 2 0' * panel_bg_padding;
2776 float entries, height;
2777 entries = bound(1, floor(10 * mySize_y/mySize_x), 10);
2778 height = mySize_y/entries;
2781 fontsize = '0.5 0.5 0' * height;
2785 when = autocvar_hud_notify_time;
2787 fadetime = autocvar_hud_notify_fadetime;
2792 vector pos_attacker, pos_victim;
2794 float width_attacker;
2795 string attacker, victim;
2798 for(j = 0; j < entries; ++j)
2800 if(autocvar_hud_notify_flip)
2802 else // rather nasty hack for ordering items from the bottom up
2803 i = entries - j - 1;
2807 if(killnotify_times[j] + when > time)
2810 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2814 if(killnotify_times[j] + when > time)
2820 // TODO: maybe print in team colors?
2823 if(killnotify_actiontype[j] == 0 && !autocvar__hud_configure)
2825 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2826 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
2827 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2829 if(killnotify_deathtype[j] == DEATH_GENERIC)
2834 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2836 s = "notify_outofammo";
2839 else if(killnotify_deathtype[j] == DEATH_KILL)
2841 s = "notify_selfkill";
2844 else if(killnotify_deathtype[j] == DEATH_CAMP)
2846 s = "notify_camping";
2849 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2851 s = "notify_teamkill";
2854 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2856 s = "notify_teamkill";
2859 else if(killnotify_deathtype[j] == DEATH_DROWN)
2864 else if(killnotify_deathtype[j] == DEATH_SLIME)
2869 else if(killnotify_deathtype[j] == DEATH_LAVA)
2874 else if(killnotify_deathtype[j] == DEATH_FALL)
2879 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2884 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2889 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2891 if(killnotify_victims[j] == "^1RED^7 flag")
2893 s = "flag_red_carrying";
2898 s = "flag_blue_carrying";
2902 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2904 if(killnotify_victims[j] == "^1RED^7 flag")
2906 s = "flag_red_taken";
2911 s = "flag_blue_taken";
2915 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2917 if(killnotify_victims[j] == "^1RED^7 flag")
2919 s = "flag_red_lost";
2924 s = "flag_blue_lost";
2928 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, color, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2929 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2931 // X [did action to] Y
2934 if(autocvar__hud_configure)
2936 attacker = textShortenToWidth("Player1", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2937 victim = textShortenToWidth("Player2", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2938 a = bound(0, (when - j) / 4, 1);
2942 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2943 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2945 width_attacker = stringwidth(attacker, TRUE, fontsize);
2946 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
2947 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
2948 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2950 if(autocvar__hud_configure) // example actions for config mode
2952 s = "weaponelectro";
2955 else if(WEP_VALID(killnotify_deathtype[j]))
2957 self = get_weaponinfo(killnotify_deathtype[j]);
2958 s = strcat("weapon", self.netname);
2961 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2963 s = "notify_teamkill";
2966 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2968 s = "notify_teamkill";
2971 else if(killnotify_deathtype[j] == DEATH_DROWN)
2976 else if(killnotify_deathtype[j] == DEATH_SLIME)
2981 else if(killnotify_deathtype[j] == DEATH_LAVA)
2986 else if(killnotify_deathtype[j] == DEATH_FALL)
2991 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2993 s = "notify_shootingstar";
2996 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
3001 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, color, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3002 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3003 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3011 string seconds_tostring(float sec)
3014 minutes = floor(sec / 60);
3016 sec -= minutes * 60;
3019 s = ftos(100 + sec);
3021 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3024 void HUD_Timer(void)
3026 if(!autocvar_hud_timer && !autocvar__hud_configure)
3029 float id = HUD_PANEL_TIMER;
3030 HUD_Panel_UpdateCvarsForId(id);
3033 mySize = panel_size;
3035 HUD_Panel_DrawBg(1);
3036 if(panel_bg_padding)
3038 pos += '1 1 0' * panel_bg_padding;
3039 mySize -= '2 2 0' * panel_bg_padding;
3043 float timelimit, elapsedTime, timeleft, minutesLeft;
3045 timelimit = getstatf(STAT_TIMELIMIT);
3047 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3048 timeleft = ceil(timeleft);
3050 minutesLeft = floor(timeleft / 60);
3053 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3054 timer_color = '1 1 1'; //white
3055 else if(minutesLeft >= 1)
3056 timer_color = '1 1 0'; //yellow
3058 timer_color = '1 0 0'; //red
3060 if (autocvar_hud_timer_increment || timelimit == 0 || warmup_stage) {
3061 if (time < getstatf(STAT_GAMESTARTTIME)) {
3062 //while restart is still active, show 00:00
3063 timer = seconds_tostring(0);
3065 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3066 timer = seconds_tostring(elapsedTime);
3069 timer = seconds_tostring(timeleft);
3072 drawfont = hud_bigfont;
3073 drawstring_aspect(pos, timer, mySize, mySize_y, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3074 drawfont = hud_font;
3079 void HUD_Radar(void)
3081 if (!(autocvar_hud_radar != 0 && (autocvar_hud_radar == 2 || teamplay || autocvar__hud_configure)))
3084 float id = HUD_PANEL_RADAR;
3085 HUD_Panel_UpdateCvarsForId(id);
3088 mySize = panel_size;
3090 HUD_Panel_DrawBg(1);
3091 if(panel_bg_padding)
3093 pos += '1 1 0' * panel_bg_padding;
3094 mySize -= '2 2 0' * panel_bg_padding;
3097 local float color1, color2; // color already declared as a global in hud.qc
3100 float scale2d, normalsize, bigsize;
3103 teamradar_origin2d = pos + 0.5 * mySize;
3104 teamradar_size2d = mySize;
3106 if(minimapname == "")
3109 teamradar_loadcvars();
3111 switch(hud_radar_zoommode)
3115 f = current_zoomfraction;
3118 f = 1 - current_zoomfraction;
3128 switch(hud_radar_rotation)
3131 teamradar_angle = view_angles_y - 90;
3134 teamradar_angle = 90 * hud_radar_rotation;
3138 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3139 teamradar_size2d = mySize;
3141 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3143 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3144 if(hud_radar_rotation == 0)
3146 // max-min distance must fit the radar in any rotation
3147 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3151 vector c0, c1, c2, c3, span;
3152 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3153 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3154 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3155 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3157 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3158 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3160 // max-min distance must fit the radar in x=x, y=y
3162 teamradar_size2d_x * scale2d / (1.05 * span_x),
3163 teamradar_size2d_y * scale2d / (1.05 * span_y)
3167 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3168 if(bigsize > normalsize)
3169 normalsize = bigsize;
3173 + (1 - f) * normalsize;
3174 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3175 f * (mi_min + mi_max) * 0.5
3176 + (1 - f) * view_origin);
3178 color1 = GetPlayerColor(player_localentnum-1);
3179 rgb = GetTeamRGB(color1);
3188 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3190 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3191 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3192 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3193 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3194 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3196 color2 = GetPlayerColor(tm.sv_entnum);
3197 //if(color == COLOR_SPECTATOR || color == color2)
3198 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3200 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3202 drawresetcliparea();
3207 void HUD_Score(void)
3209 if(!autocvar_hud_score && !autocvar__hud_configure)
3212 float id = HUD_PANEL_SCORE;
3213 HUD_Panel_UpdateCvarsForId(id);
3216 mySize = panel_size;
3218 HUD_Panel_DrawBg(1);
3219 if(panel_bg_padding)
3221 pos += '1 1 0' * panel_bg_padding;
3222 mySize -= '2 2 0' * panel_bg_padding;
3225 float score, distribution, leader;
3227 vector distribution_color;
3229 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3231 // TODO... this (race part) still uses constant coordinates :/
3232 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3233 /*pl = players.sort_next;
3236 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3237 if(pl.scores[ps_primary] == 0)
3240 score = me.(scores[ps_primary]);
3242 float racemin, racesec, racemsec;
3243 float distsec, distmsec, minusplus;
3245 racemin = floor(score/(60 * TIME_FACTOR));
3246 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
3247 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
3249 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3250 // distribution display
3251 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3253 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
3254 distmsec = fabs(distribution);
3256 distsec = floor(fabs(distribution)/TIME_FACTOR);
3257 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
3258 if (distribution < 0)
3262 if (distribution <= 0) {
3263 distribution_color = eY;
3264 minusplus = 1; // minusplus 1: always prefix with minus sign
3267 distribution_color = eX;
3268 minusplus = 2; // minusplus 1: always prefix with plus sign
3270 //HUD_DrawXNum(bottomright - '0 48 0' - '16 0 0' * TIME_DECIMALS, distmsec, -TIME_DECIMALS, 0, 16, distribution_color, 0, 0, panel_fg_alpha, DRAWFLAG_NORMAL);
3271 //HUD_DrawXNum(bottomright - '68 48 0' - '16 0 0' * TIME_DECIMALS, distsec, 4, minusplus, 16, distribution_color, 0, 0, panel_fg_alpha, DRAWFLAG_NORMAL);
3272 drawpic_aspect_skin(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "num_dot", '16 16 0', distribution_color, panel_fg_alpha, DRAWFLAG_ADDITIVE);
3274 // race record display
3275 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
3276 drawpic_aspect_skin(bottomright - '0 32 0' - '32 0 0' * (4 + TIME_DECIMALS), "num_leading_4", '0 28 0' + '32 0 0' * (4 + TIME_DECIMALS), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3278 //HUD_DrawXNum(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0', racemsec, -TIME_DECIMALS, 0, 30, '1 1 1', 0, 0, panel_fg_alpha, DRAWFLAG_NORMAL);
3279 //HUD_DrawXNum(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '66 0 0', racesec, -2, 0, 30, '1 1 1', 0, 0, panel_fg_alpha, DRAWFLAG_NORMAL);
3280 drawpic_aspect_skin(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '18 0 0', "num_dot", '30 30 0', '1 1 1', panel_fg_alpha, DRAWFLAG_ADDITIVE);
3282 //HUD_DrawXNum(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '132 0 0', racemin, -2, 0, 30, '1 1 1', 0, 0, panel_fg_alpha, DRAWFLAG_NORMAL);
3283 drawpic_aspect_skin(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '84 0 0', "num_colon", '30 30 0', '1 1 1', panel_fg_alpha, DRAWFLAG_ADDITIVE);
3285 } else if (!teamplay) { // non-teamgames
3286 // me vector := [team/connected frags id]
3287 pl = players.sort_next;
3291 if(autocvar__hud_configure)
3294 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3298 score = me.(scores[ps_primary]);
3299 if(autocvar__hud_configure)
3302 if(distribution >= 5) {
3303 distribution_color = eY;
3305 } else if(distribution >= 0) {
3306 distribution_color = '1 1 1';
3308 } else if(distribution >= -5)
3309 distribution_color = '1 1 0';
3311 distribution_color = eX;
3313 score_len = strlen(ftos(score));
3315 drawstring_aspect(pos + eX * 0.75 * mySize_x, ftos(distribution), eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3317 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3318 drawfont = hud_bigfont;
3319 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3320 drawfont = hud_font;
3321 } else { // teamgames
3322 float max_fragcount;
3323 max_fragcount = -99;
3326 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3327 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !autocvar__hud_configure)) // no players? don't display
3329 score = tm.(teamscores[ts_primary]);
3330 if(autocvar__hud_configure)
3334 score_len = strlen(ftos(score));
3336 if (score > max_fragcount)
3337 max_fragcount = score;
3339 if(tm.team == myteam) {
3340 if (max_fragcount == score)
3343 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3344 drawfont = hud_bigfont;
3345 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3346 drawfont = hud_font;
3348 if (max_fragcount == score)
3351 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);
3352 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, (1/3) * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3361 void HUD_RaceTimer (void) {
3362 if(!autocvar_hud_racetimer && !(gametype == GAME_RACE || gametype == GAME_CTS) && !autocvar__hud_configure)
3365 float id = HUD_PANEL_RACETIMER;
3366 HUD_Panel_UpdateCvarsForId(id);
3369 mySize = panel_size;
3371 HUD_Panel_DrawBg(1);
3372 if(panel_bg_padding)
3374 pos += '1 1 0' * panel_bg_padding;
3375 mySize -= '2 2 0' * panel_bg_padding;
3378 // always force 4:1 aspect
3380 if(mySize_x/mySize_y > 4)
3382 newSize_x = 4 * mySize_y;
3383 newSize_y = mySize_y;
3385 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3389 newSize_y = 1/4 * mySize_x;
3390 newSize_x = mySize_x;
3392 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3396 drawfont = hud_bigfont;
3398 string s, forcetime;
3400 if(autocvar__hud_configure)
3403 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);
3404 s = "^1Intermediate 1 (+15.42)";
3405 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);
3406 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3407 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);
3409 else if(race_checkpointtime)
3411 a = bound(0, 2 - (time - race_checkpointtime), 1);
3414 if(a > 0) // just hit a checkpoint?
3416 if(race_checkpoint != 254)
3418 if(race_time && race_previousbesttime)
3419 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3421 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3423 forcetime = TIME_ENCODED_TOSTRING(race_time);
3428 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3430 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3431 if(a > 0) // next one?
3433 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3438 if(s != "" && a > 0)
3440 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3441 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3442 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);
3445 if(race_penaltytime)
3447 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3450 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3451 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3452 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3453 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);
3459 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3460 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', panel_fg_alpha, 0, a);
3461 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);
3466 if(race_laptime && race_checkpoint != 255)
3468 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3469 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3470 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);
3475 if(race_mycheckpointtime)
3477 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3478 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3479 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3480 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3481 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);
3483 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3485 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3486 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3487 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3488 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3489 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);
3492 if(race_penaltytime && !race_penaltyaccumulator)
3494 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3495 a = bound(0, (1 + t - time), 1);
3499 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3501 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3502 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3503 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3504 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);
3509 drawfont = hud_font;
3514 float vote_yescount;
3517 float vote_highlighted; // currently selected vote
3519 float vote_active; // is there an active vote?
3520 float vote_prev; // previous state of vote_active to check for a change
3522 float vote_change; // "time" when vote_active changed
3524 void HUD_VoteWindow(void)
3526 if(!autocvar_hud_vote && !autocvar__hud_configure)
3529 float id = HUD_PANEL_VOTE;
3530 HUD_Panel_UpdateCvarsForId(id);
3533 mySize = panel_size;
3537 if(vote_active != vote_prev) {
3539 vote_prev = vote_active;
3542 if(vote_active || autocvar__hud_configure)
3543 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3545 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3547 if(autocvar__hud_configure)
3557 a = vote_alpha * bound(autocvar_hud_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3559 HUD_Panel_DrawBg(a);
3560 if(panel_bg_padding)
3562 pos += '1 1 0' * panel_bg_padding;
3563 mySize -= '2 2 0' * panel_bg_padding;
3566 // always force 3:1 aspect
3568 if(mySize_x/mySize_y > 3)
3570 newSize_x = 3 * mySize_y;
3571 newSize_y = mySize_y;
3573 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3577 newSize_y = 1/3 * mySize_x;
3578 newSize_x = mySize_x;
3580 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3584 s = "A vote has been called for:";
3585 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, mySize_y*(2/8), '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3586 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1.75/8), stringwidth_colors);
3587 if(autocvar__hud_configure)
3588 s = "Configure the HUD";
3589 drawstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, mySize_y*(1.75/8), '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3591 // print the yes/no counts
3592 s = strcat("Yes (", getcommandkey("not bound", "vyes"), "): ", ftos(vote_yescount));
3593 drawstring_aspect(pos + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, mySize_y*(1.5/8) , '0 1 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3594 s = strcat("No (", getcommandkey("not bound", "vno"), "): ", ftos(vote_nocount));
3595 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, mySize_y*(1.5/8) , '1 0 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3597 // draw the progress bar backgrounds
3598 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3600 // draw the progress bars
3601 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3602 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '0 1 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3604 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3605 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 0 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3607 // draw the highlights
3608 if(vote_highlighted == 1) {
3609 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3610 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '0 1 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3612 else if(vote_highlighted == 2) {
3613 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3614 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '0 1 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3617 drawresetcliparea();
3620 vote_highlighted = 0;
3624 // Mod icons panel (#10)
3627 float mod_active; // is there any active mod icon?
3629 // CTF HUD modicon section
3630 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3631 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3632 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3634 void HUD_Mod_CTF_Reset(void)
3636 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3639 void HUD_Mod_CTF(vector pos, vector mySize)
3641 vector redflag_pos, blueflag_pos;
3643 float f; // every function should have that
3645 float redflag, blueflag; // current status
3646 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3649 stat_items = getstati(STAT_ITEMS);
3650 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3651 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3653 if(redflag || blueflag)
3658 if(autocvar__hud_configure)
3664 // when status CHANGES, set old status into prevstatus and current status into status
3665 if (redflag != redflag_prevframe)
3667 redflag_statuschange_time = time;
3668 redflag_prevstatus = redflag_prevframe;
3669 redflag_prevframe = redflag;
3672 if (blueflag != blueflag_prevframe)
3674 blueflag_statuschange_time = time;
3675 blueflag_prevstatus = blueflag_prevframe;
3676 blueflag_prevframe = blueflag;
3679 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3680 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3682 float BLINK_FACTOR = 0.15;
3683 float BLINK_BASE = 0.85;
3685 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3687 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3689 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3691 string red_icon, red_icon_prevstatus;
3692 float red_alpha, red_alpha_prevstatus;
3693 red_alpha = red_alpha_prevstatus = 1;
3695 case 1: red_icon = "flag_red_taken"; break;
3696 case 2: red_icon = "flag_red_lost"; break;
3697 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3699 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3700 red_icon = "flag_red_shielded";
3702 red_icon = string_null;
3705 switch(redflag_prevstatus) {
3706 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3707 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3708 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3711 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3712 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3713 red_icon_prevstatus = "flag_red_shielded";
3715 red_icon_prevstatus = string_null;
3719 string blue_icon, blue_icon_prevstatus;
3720 float blue_alpha, blue_alpha_prevstatus;
3721 blue_alpha = blue_alpha_prevstatus = 1;
3723 case 1: blue_icon = "flag_blue_taken"; break;
3724 case 2: blue_icon = "flag_blue_lost"; break;
3725 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3727 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3728 blue_icon = "flag_blue_shielded";
3730 blue_icon = string_null;
3733 switch(blueflag_prevstatus) {
3734 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3735 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3736 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3739 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3740 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3741 blue_icon_prevstatus = "flag_blue_shielded";
3743 blue_icon_prevstatus = string_null;
3747 if(mySize_x > mySize_y) {
3748 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3750 blueflag_pos = pos + eX * 0.5 * mySize_x;
3753 redflag_pos = pos + eX * 0.5 * mySize_x;
3755 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3757 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3759 blueflag_pos = pos + eY * 0.5 * mySize_y;
3762 redflag_pos = pos + eY * 0.5 * mySize_y;
3764 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3767 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3768 if(red_icon_prevstatus && f < 1)
3769 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3771 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3773 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3774 if(blue_icon_prevstatus && f < 1)
3775 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3777 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3780 // Keyhunt HUD modicon section
3781 float kh_runheretime;
3783 void HUD_Mod_KH_Reset(void)
3788 void HUD_Mod_KH(vector pos, vector mySize)
3790 mod_active = 1; // keyhunt should never hide the mod icons panel
3794 vector p, pa, kh_size, kh_asize;
3796 kh_keys = getstati(STAT_KH_KEYS);
3799 if(mySize_x > mySize_y)
3801 p_y = pos_y + 0.25 * mySize_y;
3802 pa = p - eY * 0.25 * mySize_y;
3804 kh_size_x = mySize_x * 0.25;
3805 kh_size_y = 0.75 * mySize_y;
3806 kh_asize_x = mySize_x * 0.25;
3807 kh_asize_y = mySize_y * 0.25;
3811 p_y = pos_y + 0.125 * mySize_y;
3812 pa = p - eY * 0.125 * mySize_y;
3814 kh_size_x = mySize_x * 0.5;
3815 kh_size_y = 0.375 * mySize_y;
3816 kh_asize_x = mySize_x * 0.5;
3817 kh_asize_y = mySize_y * 0.125;
3824 for(i = 0; i < 4; ++i)
3826 key = floor(kh_keys / pow(32, i)) & 31;
3828 if(keyteam == 30 && keycount <= 4)
3830 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3834 // this yields 8 exactly if "RUN HERE" shows
3839 kh_runheretime = time;
3840 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3845 for(i = 0; i < 4; ++i)
3847 key = floor(kh_keys / pow(32, i)) & 31;
3860 default: // owned or dropped
3865 a = a * panel_fg_alpha;
3866 aa = aa * panel_fg_alpha;
3872 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3875 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3878 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3881 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3886 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3889 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3892 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3895 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3898 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3902 if(mySize_x > mySize_y)
3904 p_x += 0.25 * mySize_x;
3905 pa_x += 0.25 * mySize_x;
3911 p_y = pos_y + 0.625 * mySize_y;
3912 pa_y = pos_y + 0.5 * mySize_y;
3918 p_x += 0.5 * mySize_x;
3919 pa_x += 0.5 * mySize_x;
3925 // Nexball HUD mod icon
3926 void HUD_Mod_NexBall(vector pos, vector mySize)
3928 float stat_items, nb_pb_starttime, dt, p;
3930 stat_items = getstati(STAT_ITEMS);
3931 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3933 if (stat_items & IT_KEY1)
3938 //Manage the progress bar if any
3939 if (nb_pb_starttime > 0)
3941 dt = mod(time - nb_pb_starttime, nb_pb_period);
3942 // one period of positive triangle
3943 p = 2 * dt / nb_pb_period;
3950 if(mySize_x > mySize_y)
3952 barsize = eX * p * mySize_x + eY * mySize_y;
3957 barsize = eX * mySize_x + eY * p * mySize_y;
3960 HUD_Panel_GetProgressBarColor("nexball")
3961 HUD_Panel_DrawProgressBar(pos, vertical, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3964 if (stat_items & IT_KEY1)
3965 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3968 // Race/CTS HUD mod icons
3969 float crecordtime_prev; // last remembered crecordtime
3970 float crecordtime_change_time; // time when crecordtime last changed
3971 float srecordtime_prev; // last remembered srecordtime
3972 float srecordtime_change_time; // time when srecordtime last changed
3974 float race_status_time;
3975 float race_status_prev;
3976 string race_status_name_prev;
3977 void HUD_Mod_Race(vector pos, vector mySize)
3979 mod_active = 1; // race should never hide the mod icons panel
3981 me = playerslots[player_localentnum - 1];
3983 float f; // yet another function has this
3984 score = me.(scores[ps_primary]);
3986 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3987 return; // no records in the actual race
3989 drawfont = hud_bigfont;
3991 // clientside personal record
3993 if(gametype == GAME_CTS)
3997 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3999 if(score && (score < t || !t)) {
4000 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4001 if(cvar("cl_autodemo_delete_keeprecords"))
4003 f = cvar("cl_autodemo_delete");
4005 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4009 if(t != crecordtime_prev) {
4010 crecordtime_prev = t;
4011 crecordtime_change_time = time;
4013 f = time - crecordtime_change_time;
4016 drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4017 drawstring_aspect(pos + eY * 0.25 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4019 drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4020 drawstring_aspect(pos + eY * 0.25 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4021 //drawstring_expanding(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4022 //drawstring_expanding(pos + eY * 0.2 * mySize_y, TIME_ENCODED_TOSTRING(t), '1 1 0' * 0.2 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4026 t = race_server_record;
4027 if(t != srecordtime_prev) {
4028 srecordtime_prev = t;
4029 srecordtime_change_time = time;
4031 f = time - srecordtime_change_time;
4034 drawstring_aspect(pos + eY * 0.5 * mySize_y, "Server best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4035 drawstring_aspect(pos + eY * 0.75 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4037 drawstring_aspect(pos + eY * 0.5 * mySize_y, "Server best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4038 drawstring_aspect(pos + eY * 0.75 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4039 //drawstring_expanding(pos + eY * 0.5 * mySize_y, "Server best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4040 //drawstring_expanding(pos + eY * 0.5 * mySize_y + eY * 0.2 * mySize_y, TIME_ENCODED_TOSTRING(t),'1 1 0' * 0.2 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4043 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4044 race_status_time = time + 5;
4045 race_status_prev = race_status;
4046 if (race_status_name_prev)
4047 strunzone(race_status_name_prev);
4048 race_status_name_prev = strzone(race_status_name);
4051 pos_x += mySize_x/2;
4054 a = bound(0, race_status_time - time, 1);
4057 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4061 rank = race_CheckName(race_status_name);
4063 rankname = race_PlaceName(rank);
4066 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4068 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4070 if(race_status == 0)
4071 drawpic_aspect_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4072 else if(race_status == 1) {
4073 drawpic_aspect_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4074 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4075 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4076 } else if(race_status == 2) {
4077 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4078 drawpic_aspect_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4080 drawpic_aspect_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4081 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4082 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4083 } else if(race_status == 3) {
4084 drawpic_aspect_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4085 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4086 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4089 if (race_status_time - time <= 0) {
4090 race_status_prev = -1;
4092 if(race_status_name)
4093 strunzone(race_status_name);
4094 race_status_name = string_null;
4095 if(race_status_name_prev)
4096 strunzone(race_status_name_prev);
4097 race_status_name_prev = string_null;
4099 drawfont = hud_font;
4102 float mod_prev; // previous state of mod_active to check for a change
4104 float mod_change; // "time" when mod_active changed
4106 void HUD_ModIcons(void)
4108 if(!autocvar_hud_modicons && !autocvar__hud_configure)
4111 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !autocvar__hud_configure)
4114 float id = HUD_PANEL_MODICONS;
4115 HUD_Panel_UpdateCvarsForId(id);
4118 mySize = panel_size;
4120 if(mod_active != mod_prev) {
4122 mod_prev = mod_active;
4125 if(mod_active || autocvar__hud_configure)
4126 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4128 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4131 HUD_Panel_DrawBg(mod_alpha);
4133 if(panel_bg_padding)
4135 pos += '1 1 0' * panel_bg_padding;
4136 mySize -= '2 2 0' * panel_bg_padding;
4139 // these MUST be ran in order to update mod_active
4140 if(gametype == GAME_KEYHUNT)
4141 HUD_Mod_KH(pos, mySize);
4142 else if(gametype == GAME_CTF || autocvar__hud_configure)
4143 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4144 else if(gametype == GAME_NEXBALL)
4145 HUD_Mod_NexBall(pos, mySize);
4146 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4147 HUD_Mod_Race(pos, mySize);
4150 // Draw pressed keys (#11)
4152 void HUD_DrawPressedKeys(void)
4154 if(!autocvar_hud_pressedkeys && !autocvar__hud_configure)
4157 if(!(spectatee_status > 0 || autocvar_hud_pressedkeys >= 2 || autocvar__hud_configure))
4160 float id = HUD_PANEL_PRESSEDKEYS;
4161 HUD_Panel_UpdateCvarsForId(id);
4164 mySize = panel_size;
4166 HUD_Panel_DrawBg(1);
4167 if(panel_bg_padding)
4169 pos += '1 1 0' * panel_bg_padding;
4170 mySize -= '2 2 0' * panel_bg_padding;
4173 // always force 2:1 aspect
4175 if(mySize_x/mySize_y > 2)
4177 newSize_x = 2 * mySize_y;
4178 newSize_y = mySize_y;
4180 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4184 newSize_y = 1/2 * mySize_x;
4185 newSize_x = mySize_x;
4187 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4192 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4195 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4196 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4197 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);
4198 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);
4199 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);
4200 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);
4201 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);
4204 // Handle chat as a panel (#12)
4208 if(!autocvar_hud_chat && !autocvar__hud_configure)
4210 cvar_set("con_chatrect", "0");
4214 float id = HUD_PANEL_CHAT;
4215 HUD_Panel_UpdateCvarsForId(id);
4218 mySize = panel_size;
4220 HUD_Panel_DrawBg(1);
4221 if(panel_bg_padding)
4223 pos += '1 1 0' * panel_bg_padding;
4224 mySize -= '2 2 0' * panel_bg_padding;
4227 cvar_set("con_chatrect", "1");
4229 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4230 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4232 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4233 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4235 if(autocvar__hud_configure)
4238 chatsize = cvar("con_chatsize");
4239 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4241 for(i = 0; i < cvar("con_chat"); ++i)
4243 if(i == cvar("con_chat") - 1)
4246 a = panel_fg_alpha * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4247 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);
4252 // Engine info panel (#13)
4259 float frametimeavg1; // 1 frame ago
4260 float frametimeavg2; // 2 frames ago
4261 void HUD_EngineInfo(void)
4263 if(!autocvar_hud_engineinfo && !autocvar__hud_configure)
4266 float id = HUD_PANEL_ENGINEINFO;
4267 HUD_Panel_UpdateCvarsForId(id);
4270 mySize = panel_size;
4272 HUD_Panel_DrawBg(1);
4273 if(panel_bg_padding)
4275 pos += '1 1 0' * panel_bg_padding;
4276 mySize -= '2 2 0' * panel_bg_padding;
4279 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4281 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4282 frametimeavg2 = frametimeavg1;
4283 frametimeavg1 = frametimeavg;
4286 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4287 if(frametime > 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.
4289 if(fabs(prevfps - (1/frametimeavg)) > prevfps * cvar("hud_engineinfo_framecounter_exponentialmovingaverage_instantupdate_change_threshold")) // if there was a big jump in fps, just force prevfps at current (1/frametime) to make big updates instant
4290 prevfps = (1/frametime);
4291 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"
4297 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4299 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4301 prevfps_time = time;
4306 color = HUD_Get_Num_Color (prevfps, 100);
4307 drawfont = hud_bigfont;
4308 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), mySize, mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4309 drawfont = hud_font;
4312 // Info messages panel (#14)
4314 void HUD_InfoMessages(void)
4316 if(!autocvar_hud_infomessages && !autocvar__hud_configure)
4319 float id = HUD_PANEL_INFOMESSAGES;
4320 HUD_Panel_UpdateCvarsForId(id);
4323 mySize = panel_size;
4325 HUD_Panel_DrawBg(1);
4326 if(panel_bg_padding)
4328 pos += '1 1 0' * panel_bg_padding;
4329 mySize -= '2 2 0' * panel_bg_padding;
4332 // always force 6:1 aspect
4334 if(mySize_x/mySize_y > 6)
4336 newSize_x = 6 * mySize_y;
4337 newSize_y = mySize_y;
4339 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4343 newSize_y = 1/6 * mySize_x;
4344 newSize_x = mySize_x;
4346 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4355 fontsize = '0.25 0.25 0' * mySize_y;
4358 if(spectatee_status && !intermission)
4360 //drawfont = hud_bigfont;
4361 if(spectatee_status == -1)
4364 s = GetPlayerName(spectatee_status - 1);
4366 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
4367 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, panel_fg_alpha, DRAWFLAG_NORMAL);
4368 //drawfont = hud_font;
4370 // spectator text in the upper right corner
4371 if(spectatee_status == -1)
4372 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
4374 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
4375 if(autocvar_hud_infomessages_flip)
4376 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4377 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4378 o += eY * fontsize_y;
4380 if(spectatee_status == -1)
4381 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
4383 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
4384 if(autocvar_hud_infomessages_flip)
4385 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4386 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4387 o += eY * fontsize_y;
4389 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
4390 if(autocvar_hud_infomessages_flip)
4391 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4392 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4393 o += eY * fontsize_y;
4395 if(gametype == GAME_ARENA)
4396 s = "^1Wait for your turn to join";
4397 else if(gametype == GAME_LMS)
4400 sk = playerslots[player_localentnum - 1];
4401 if(sk.(scores[ps_primary]) >= 666)
4402 s = "^1Match has already begun";
4403 else if(sk.(scores[ps_primary]) > 0)
4404 s = "^1You have no more lives left";
4406 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4409 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4410 if(autocvar_hud_infomessages_flip)
4411 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4412 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4413 o += eY * fontsize_y;
4415 //show restart countdown:
4416 if (time < getstatf(STAT_GAMESTARTTIME)) {
4418 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4419 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4420 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
4421 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4422 o += eY * fontsize_y;
4425 if(warmup_stage && !intermission)
4427 s = "^2Currently in ^1warmup^2 stage!";
4428 if(autocvar_hud_infomessages_flip)
4429 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4430 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4431 o += eY * fontsize_y;
4435 if(mod(time, 1) >= 0.5)
4440 if(ready_waiting && !intermission && !spectatee_status)
4442 if(ready_waiting_for_me)
4445 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
4447 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
4452 s = strcat("^2Waiting for others to ready up to end warmup...");
4454 s = strcat("^2Waiting for others to ready up...");
4456 if(autocvar_hud_infomessages_flip)
4457 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4458 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4459 o += eY * fontsize_y;
4461 else if(warmup_stage && !intermission && !spectatee_status)
4463 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
4464 if(autocvar_hud_infomessages_flip)
4465 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4466 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4467 o += eY * fontsize_y;
4470 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4472 float ts_min, ts_max;
4473 tm = teams.sort_next;
4476 for(; tm.sort_next; tm = tm.sort_next)
4478 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4480 if(!ts_min) ts_min = tm.team_size;
4481 else ts_min = min(ts_min, tm.team_size);
4482 if(!ts_max) ts_max = tm.team_size;
4483 else ts_max = max(ts_max, tm.team_size);
4485 if ((ts_max - ts_min) > 1)
4487 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
4488 tm = GetTeam(myteam, false);
4490 if (tm.team != COLOR_SPECTATOR)
4491 if (tm.team_size == ts_max)
4492 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
4494 if(autocvar_hud_infomessages_flip)
4495 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4496 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4497 o += eY * fontsize_y;
4501 if(autocvar__hud_configure)
4503 s = "^7Press ^3ESC ^7to show HUD options.";
4504 if(autocvar_hud_infomessages_flip)
4505 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4506 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4507 o += eY * fontsize_y;
4508 s = "^3Doubleclick a panel for panel-specific options.";
4509 if(autocvar_hud_infomessages_flip)
4510 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4511 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4512 o += eY * fontsize_y;
4522 void HUD_ShowSpeed(void)
4525 float pos, conversion_factor;
4526 string speed, zspeed, unit;
4528 switch(cvar("cl_showspeed_unit"))
4533 conversion_factor = 1.0;
4537 conversion_factor = 1.0;
4541 conversion_factor = 0.0254;
4545 conversion_factor = 0.0254 * 3.6;
4549 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4553 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4557 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4559 numsize_x = numsize_y = cvar("cl_showspeed_size");
4560 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4562 drawfont = hud_bigfont;
4563 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4565 if (cvar("cl_showspeed_z") == 1) {
4566 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4567 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4570 drawfont = hud_font;
4573 vector acc_prevspeed;
4577 void HUD_ShowAcceleration(void)
4579 float acceleration, sz, scale, alpha, f;
4580 vector pos, top, rgb;
4581 top_x = vid_conwidth/2;
4584 f = time - acc_prevtime;
4585 if(cvar("cl_showacceleration_z"))
4586 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4588 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4589 acc_prevspeed = pmove_vel;
4590 acc_prevtime = time;
4592 f = bound(0, f * 10, 1);
4593 acc_avg = acc_avg * (1 - f) + acceleration * f;
4594 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4596 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4598 sz = cvar("cl_showacceleration_size");
4599 scale = cvar("cl_showacceleration_scale");
4600 alpha = cvar("cl_showacceleration_alpha");
4601 if (cvar("cl_showacceleration_color_custom"))
4602 rgb = stov(cvar_string("cl_showacceleration_color"));
4605 if (acceleration < 0) {
4606 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4607 } else if (acceleration > 0) {
4608 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4612 if (acceleration > 0)
4613 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4614 else if (acceleration < 0)
4615 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4618 void HUD_Reset (void)
4620 // reset gametype specific icons
4621 if(gametype == GAME_KEYHUNT)
4623 else if(gametype == GAME_CTF)
4624 HUD_Mod_CTF_Reset();
4627 #define HUD_DrawPanel(id)\
4629 case (HUD_PANEL_RADAR):\
4630 HUD_Radar(); break;\
4631 case (HUD_PANEL_WEAPONICONS):\
4632 HUD_WeaponIcons(); break;\
4633 case (HUD_PANEL_INVENTORY):\
4634 HUD_Inventory(); break;\
4635 case (HUD_PANEL_POWERUPS):\
4636 HUD_Powerups(); break;\
4637 case (HUD_PANEL_HEALTHARMOR):\
4638 HUD_HealthArmor(); break;\
4639 case (HUD_PANEL_NOTIFY):\
4640 HUD_Notify(); break;\
4641 case (HUD_PANEL_TIMER):\
4642 HUD_Timer(); break;\
4643 case (HUD_PANEL_SCORE):\
4644 HUD_Score(); break;\
4645 case (HUD_PANEL_RACETIMER):\
4646 HUD_RaceTimer(); break;\
4647 case (HUD_PANEL_VOTE):\
4648 HUD_VoteWindow(); break;\
4649 case (HUD_PANEL_MODICONS):\
4650 HUD_ModIcons(); break;\
4651 case (HUD_PANEL_PRESSEDKEYS):\
4652 HUD_DrawPressedKeys(); break;\
4653 case (HUD_PANEL_CHAT):\
4655 case (HUD_PANEL_ENGINEINFO):\
4656 HUD_EngineInfo(); break;\
4657 case (HUD_PANEL_INFOMESSAGES):\
4658 HUD_InfoMessages(); break;\
4661 void HUD_Main (void)
4663 hud_skin_path = strcat("gfx/hud/", autocvar_hud_skin);
4665 if(disable_menu_alphacheck == 1)
4666 menu_fade_alpha = 1;
4668 menu_fade_alpha = (1 - autocvar__menu_alpha);
4669 hud_fg_alpha = cvar("hud_fg_alpha");
4671 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4672 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4673 hud_color_bg_team = cvar("hud_color_bg_team");
4675 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4676 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4680 // HUD configure visible grid
4681 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4685 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2); ++i)
4687 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);
4690 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2); ++i)
4692 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);
4698 if(teamplay && autocvar_hud_dock_color_team) {
4699 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4700 color = colormapPaletteColor(mod(f, 16), 1) * autocvar_hud_dock_color_team;
4702 else if(autocvar_hud_dock_color == "shirt") {
4703 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4704 color = colormapPaletteColor(floor(f / 16), 0);
4706 else if(autocvar_hud_dock_color == "pants") {
4707 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4708 color = colormapPaletteColor(mod(f, 16), 1);
4711 color = stov(autocvar_hud_dock_color);
4713 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4714 drawpic('0 0 0', strcat("gfx/hud/", autocvar_hud_skin, "/", autocvar_hud_dock), eX * vid_conwidth + eY * vid_conheight, color, autocvar_hud_dock_alpha * menu_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
4716 // cache the panel order into the panel_order array
4717 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4718 if(hud_panelorder_prev)
4719 strunzone(hud_panelorder_prev);
4720 hud_panelorder_prev = strzone(autocvar__hud_panelorder);
4721 tokenize_console(autocvar__hud_panelorder);
4722 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4723 panel_order[i] = stof(argv(i));
4726 // draw panels in order specified by panel_order array
4727 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
4728 HUD_DrawPanel(panel_order[i]);
4731 // TODO hud_'ify these
4732 if (cvar("cl_showspeed"))
4734 if (cvar("cl_showacceleration"))
4735 HUD_ShowAcceleration();
4737 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)
4738 localcmd("cmd selectteam auto; cmd join\n");
4740 hud_configure_prev = autocvar__hud_configure;
4742 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again
4743 disable_menu_alphacheck = 0;