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);\
105 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
106 #define drawpic_aspect_skin(pos,pic,sz,color,alpha,drawflag)\
108 picpath = strcat(hud_skin_path, "/", pic);\
109 if(precache_pic(picpath) == "") {\
110 picpath = strcat("gfx/hud/default/", pic);\
112 drawpic_aspect(pos, picpath, sz, color, alpha, drawflag);\
115 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
116 #define drawpic_skin(pos,pic,sz,color,alpha,drawflag)\
118 picpath = strcat(hud_skin_path, "/", pic);\
119 if(precache_pic(picpath) == "") {\
120 picpath = strcat("gfx/hud/default/", pic);\
122 drawpic(pos, picpath, sz, color, alpha, drawflag);\
126 void drawpic_aspect_skin_expanding(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
128 //drawpic_aspect_expanding(pos, strcat("gfx/hud/", autocvar_hud_skin, "/", pic), sz, rgb, alpha, flag, fadelerp);
131 void drawpic_aspect_skin_expanding_two(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
133 //drawpic_aspect_expanding_two(pos, strcat("gfx/hud/", autocvar_hud_skin, "/", pic), sz, rgb, alpha, flag, fadelerp);
136 vector HUD_Get_Num_Color (float x, float maxvalue)
144 else if(x > maxvalue * 0.75) {
145 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
146 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
149 else if(x > maxvalue * 0.5) {
150 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
151 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
152 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
154 else if(x > maxvalue * 0.25) {
157 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
159 else if(x > maxvalue * 0.1) {
161 color_y = (x-20)*90/27/100; // green value between 0 -> 1
162 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
172 float stringwidth_colors(string s, vector theSize)
174 return stringwidth(s, TRUE, theSize);
177 float stringwidth_nocolors(string s, vector theSize)
179 return stringwidth(s, FALSE, theSize);
182 #define CENTERPRINT_MAX_LINES 30
183 string centerprint_messages[CENTERPRINT_MAX_LINES];
184 float centerprint_width[CENTERPRINT_MAX_LINES];
185 vector centerprint_start;
186 float centerprint_expire;
187 float centerprint_num;
188 float centerprint_offset_hint;
189 vector centerprint_fontsize;
191 void centerprint(string strMessage)
193 float i, j, n, hcount;
196 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
198 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
200 if(cvar("scr_centertime") <= 0)
206 // strip trailing newlines
207 j = strlen(strMessage) - 1;
208 while(substring(strMessage, j, 1) == "\n" && j >= 0)
210 strMessage = substring(strMessage, 0, j + 1);
215 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
217 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
219 strMessage = substring(strMessage, j, strlen(strMessage) - j);
220 centerprint_offset_hint = j;
225 // if we get here, we have a message. Initialize its height.
228 n = tokenizebyseparator(strMessage, "\n");
230 for(j = 0; j < n; ++j)
232 getWrappedLine_remaining = argv(j);
233 while(getWrappedLine_remaining)
235 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
236 if(centerprint_messages[i])
237 strunzone(centerprint_messages[i]);
238 centerprint_messages[i] = strzone(s);
239 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
242 // half height for empty lines looks better
248 if(i >= CENTERPRINT_MAX_LINES)
254 h = centerprint_fontsize_y*hcount;
256 havail = vid_conheight;
257 if(cvar("con_chatpos") < 0)
258 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
259 if(havail > vid_conheight - 70)
260 havail = vid_conheight - 70; // avoid overlapping HUD
262 centerprint_start_x = 0;
265 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
267 // here, the centerprint would cover the crosshair. REALLY BAD.
268 forbiddenmin = vid_conheight * 0.5 - h - 16;
269 forbiddenmax = vid_conheight * 0.5 + 16;
271 allowedmin = scoreboard_bottom;
272 allowedmax = havail - h;
273 preferred = (havail - h)/2;
276 // possible orderings (total: 4! / 4 = 6)
277 // allowedmin allowedmax forbiddenmin forbiddenmax
278 // forbiddenmin forbiddenmax allowedmin allowedmax
279 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
281 // forbidden doesn't matter in this case
282 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
284 // allowedmin forbiddenmin allowedmax forbiddenmax
285 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
287 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
289 // allowedmin forbiddenmin forbiddenmax allowedmax
290 else if(allowedmin < forbiddenmin)
292 // make sure the forbidden zone is not covered
293 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
294 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
296 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
298 // forbiddenmin allowedmin allowedmax forbiddenmax
299 else if(allowedmax < forbiddenmax)
301 // it's better to leave the allowed zone (overlap with scoreboard) than
302 // to cover the forbidden zone (crosshair)
303 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
304 centerprint_start_y = forbiddenmax;
306 centerprint_start_y = forbiddenmin;
308 // forbiddenmin allowedmin forbiddenmax allowedmax
311 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
314 centerprint_start_y =
317 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
325 centerprint_expire = time + cvar("scr_centertime");
328 void HUD_DrawCenterPrint (void)
335 //if(time > centerprint_expire)
338 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
339 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
340 //sz = 1.2 / (a + 0.2);
345 pos = centerprint_start;
346 for (i=0; i<centerprint_num; i = i + 1)
348 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
349 ts = centerprint_messages[i];
352 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
353 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
354 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
355 pos_y = pos_y + centerprint_fontsize_y;
358 // half height for empty lines looks better
359 pos_y = pos_y + centerprint_fontsize_y * 0.5;
363 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
365 position_x -= 2 / 3 * strlen(text) * scale_x;
366 drawstring(position, text, scale, rgb, alpha, flag);
369 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
371 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
372 drawstring(position, text, scale, rgb, alpha, flag);
375 // return the string of the given race place
376 string race_PlaceName(float pos) {
384 return strcat(ftos(pos), "th");
387 // return the string of the onscreen race timer
388 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
396 if(histime == 0) // goal hit
400 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
410 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
416 lapstr = strcat(" (-", ftos(lapdelta), "L)");
419 else if(lapdelta < 0)
421 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
425 else if(histime > 0) // anticipation
427 if(mytime >= histime)
428 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
430 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
437 cpname = "Start line";
439 cpname = "Finish line";
441 cpname = strcat("Intermediate ", ftos(cp));
443 cpname = "Finish line";
446 return strcat(col, cpname);
447 else if(hisname == "")
448 return strcat(col, cpname, " (", timestr, ")");
450 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
453 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
454 float race_CheckName(string net_name) {
456 for (i=RANKINGS_CNT-1;i>=0;--i)
457 if(grecordholder[i] == net_name)
469 void HUD_Panel_ExportCfg(string cfgname)
472 fh = fopen(strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg"), FILE_WRITE);
475 fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
476 fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
477 fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
478 fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
479 fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
480 fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
481 fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
482 fputs(fh, strcat("seta hud_fg_alpha \"", cvar_string("hud_fg_alpha"), "\"", "\n"));
485 fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
486 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
487 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
488 fputs(fh, strcat("seta hud_dock_alpha \"", cvar_string("hud_dock_alpha"), "\"", "\n"));
491 fputs(fh, strcat("seta hud_progressbar_alpha \"", cvar_string("hud_progressbar_alpha"), "\"", "\n"));
492 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
493 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
494 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
495 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
496 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
497 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
500 fputs(fh, strcat("seta _hud_panelorder \"", cvar_string("_hud_panelorder"), "\"", "\n"));
503 // common cvars for all panels
505 for (i = 0; i < HUD_PANEL_NUM; ++i)
509 fputs(fh, strcat("seta hud_", panel_name, " ", cvar_string(strcat("hud_", panel_name)), "\n"));
510 fputs(fh, strcat("seta hud_", panel_name, "_pos \"", cvar_string(strcat("hud_", panel_name, "_pos")), "\"", "\n"));
511 fputs(fh, strcat("seta hud_", panel_name, "_size \"", cvar_string(strcat("hud_", panel_name, "_size")), "\"", "\n"));
512 fputs(fh, strcat("seta hud_", panel_name, "_bg \"", cvar_string(strcat("hud_", panel_name, "_bg")), "\"", "\n"));
513 fputs(fh, strcat("seta hud_", panel_name, "_bg_color \"", cvar_string(strcat("hud_", panel_name, "_bg_color")), "\"", "\n"));
514 fputs(fh, strcat("seta hud_", panel_name, "_bg_color_team \"", cvar_string(strcat("hud_", panel_name, "_bg_color_team")), "\"", "\n"));
515 fputs(fh, strcat("seta hud_", panel_name, "_bg_alpha \"", cvar_string(strcat("hud_", panel_name, "_bg_alpha")), "\"", "\n"));
516 fputs(fh, strcat("seta hud_", panel_name, "_bg_border \"", cvar_string(strcat("hud_", panel_name, "_bg_border")), "\"", "\n"));
517 fputs(fh, strcat("seta hud_", panel_name, "_bg_padding \"", cvar_string(strcat("hud_", panel_name, "_bg_padding")), "\"", "\n"));
519 case HUD_PANEL_WEAPONICONS:
520 fputs(fh, strcat("seta hud_", panel_name, "_accuracy_yellow \"", cvar_string(strcat("hud_", panel_name, "_accuracy_yellow")), "\"", "\n"));
521 fputs(fh, strcat("seta hud_", panel_name, "_complainbubble \"", cvar_string(strcat("hud_", panel_name, "_complainbubble")), "\"", "\n"));
522 fputs(fh, strcat("seta hud_", panel_name, "_complainbubble_size \"", cvar_string(strcat("hud_", panel_name, "_complainbubble_size")), "\"", "\n"));
524 case HUD_PANEL_INVENTORY:
525 fputs(fh, strcat("seta hud_", panel_name, "_onlycurrent \"", cvar_string(strcat("hud_", panel_name, "_onlycurrent")), "\"", "\n"));
526 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
528 case HUD_PANEL_POWERUPS:
529 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\"", "\n"));
530 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
531 fputs(fh, strcat("seta hud_", panel_name, "_baralign \"", cvar_string(strcat("hud_", panel_name, "_baralign")), "\"", "\n"));
533 case HUD_PANEL_HEALTHARMOR:
534 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\n"));
535 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
536 fputs(fh, strcat("seta hud_", panel_name, "_baralign \"", cvar_string(strcat("hud_", panel_name, "_baralign")), "\"", "\n"));
538 case HUD_PANEL_NOTIFY:
539 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\"", "\n"));
540 fputs(fh, strcat("seta hud_", panel_name, "_info_top \"", cvar_string(strcat("hud_", panel_name, "_info_top")), "\"", "\n"));
542 case HUD_PANEL_RADAR:
543 fputs(fh, strcat("seta hud_", panel_name, "_foreground_alpha \"", cvar_string(strcat("hud_", panel_name, "_foreground_alpha")), "\"", "\n"));
546 fputs(fh, strcat("seta hud_", panel_name, "_alreadyvoted_alpha \"", cvar_string(strcat("hud_", panel_name, "_alreadyvoted_alpha")), "\"", "\n"));
552 print("^2Successfully exported to hud_", autocvar_hud_skin, "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
557 // return smoothly faded size of given panel when a dialog is active
558 vector HUD_Panel_GetMenuSize(float id)
563 mySize = eX * mySize_x * vid_conwidth + eY * mySize_y * vid_conheight;
565 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
567 vector menu_enable_maxsize, menu_enable_size;
568 menu_enable_maxsize = '0 0 0'; // shut up FTEQCC
569 menu_enable_maxsize_x = 0.3 * vid_conwidth;
570 menu_enable_maxsize_y = 0.18 * vid_conheight;
571 if(mySize_x > mySize_y)
573 if(mySize_y > menu_enable_maxsize_y)
575 menu_enable_size_y = menu_enable_maxsize_y;
576 menu_enable_size_x = mySize_x * (menu_enable_maxsize_y/mySize_y);
577 mySize = (1 - autocvar__menu_alpha) * mySize + (autocvar__menu_alpha) * menu_enable_size;
582 if(mySize_x > menu_enable_maxsize_x)
584 menu_enable_size_x = menu_enable_maxsize_x;
585 menu_enable_size_y = mySize_y * (menu_enable_maxsize_x/mySize_x);
586 mySize = (1 - autocvar__menu_alpha) * mySize + (autocvar__menu_alpha) * menu_enable_size;
593 // return smoothly faded pos of given panel when a dialog is active
594 vector HUD_Panel_GetMenuPos(float id)
599 pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
601 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
603 vector mySize, menu_enable_panelpos;
604 mySize = HUD_Panel_GetMenuSize(id);
605 if(mySize_x > mySize_y)
606 menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * mySize_x + eY * 0.82 * vid_conheight;
608 menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * mySize_y + eX * 0.7 * vid_conwidth;
609 pos = (1 - autocvar__menu_alpha) * pos + (autocvar__menu_alpha) * menu_enable_panelpos;
614 const float hlBorderSize = 4;
615 const string hlBorder = "gfx/hud/default/border_highlighted";
616 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
617 void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
619 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
620 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);
621 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);
622 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);
623 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);
626 // draw the background/borders
627 #define HUD_Panel_DrawBg(alpha)\
629 draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));\
630 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
631 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);
633 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
640 pic = strcat(hud_skin_path, "/statusbar_vertical");
641 if(precache_pic(pic) == "") {
642 pic = "gfx/hud/default/statusbar_vertical";
644 drawsubpic(pos, eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, pic, '0 0 0', '1 0.25 0', color, alpha, drawflag);
645 if(mySize_y/mySize_x > 2)
646 drawsubpic(pos + eY * mySize_x, eY * (mySize_y - 2 * mySize_x) + eX * mySize_x, pic, '0 0.25 0', '1 0.5 0', color, alpha, drawflag);
647 drawsubpic(pos + eY * mySize_y - eY * min(mySize_y * 0.5, mySize_x), eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, pic, '0 0.75 0', '1 0.25 0', color, alpha, drawflag);
649 pic = strcat(hud_skin_path, "/statusbar");
650 if(precache_pic(pic) == "") {
651 pic = "gfx/hud/default/statusbar";
653 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
654 if(mySize_x/mySize_y > 2)
655 drawsubpic(pos + eX * mySize_y, eX * (mySize_x - 2 * mySize_y) + eY * mySize_y, pic, '0.25 0 0', '0.5 1 0', color, alpha, drawflag);
656 drawsubpic(pos + eX * mySize_x - eX * min(mySize_x * 0.5, mySize_y), eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0.75 0 0', '0.25 1 0', color, alpha, drawflag);
660 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
666 pic = strcat(hud_skin_path, "/num_leading");
667 if(precache_pic(pic) == "") {
668 pic = "gfx/hud/default/num_leading";
671 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
672 if(mySize_x/mySize_y > 2)
673 drawsubpic(pos + eX * mySize_y, eX * (mySize_x - 2 * mySize_y) + eY * mySize_y, pic, '0.25 0 0', '0.5 1 0', color, alpha, drawflag);
674 drawsubpic(pos + eX * mySize_x - eX * min(mySize_x * 0.5, mySize_y), eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0.75 0 0', '0.25 1 0', color, alpha, drawflag);
677 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
678 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
689 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
690 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
692 for (i = 0; i < HUD_PANEL_NUM; ++i) {
693 if(i == highlightedPanel || !panel_enabled)
696 HUD_Panel_UpdatePosSizeForId(i)
698 panel_pos -= '1 1 0' * panel_bg_border;
699 panel_size += '2 2 0' * panel_bg_border;
701 if(myPos_y + mySize_y < panel_pos_y)
703 if(myPos_y > panel_pos_y + panel_size_y)
706 if(myPos_x + mySize_x < panel_pos_x)
708 if(myPos_x > panel_pos_x + panel_size_x)
711 // OK, there IS a collision.
713 myCenter_x = myPos_x + 0.5 * mySize_x;
714 myCenter_y = myPos_y + 0.5 * mySize_y;
716 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
717 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
719 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
721 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
722 myTarget_x = panel_pos_x - mySize_x;
723 else // push it upwards
724 myTarget_y = panel_pos_y - mySize_y;
726 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
728 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
729 myTarget_x = panel_pos_x + panel_size_x;
730 else // push it upwards
731 myTarget_y = panel_pos_y - mySize_y;
733 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
735 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
736 myTarget_x = panel_pos_x - mySize_x;
737 else // push it downwards
738 myTarget_y = panel_pos_y + panel_size_y;
740 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
742 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
743 myTarget_x = panel_pos_x + panel_size_x;
744 else // push it downwards
745 myTarget_y = panel_pos_y + panel_size_y;
747 if(cvar("hud_configure_checkcollisions_debug"))
748 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
754 void HUD_Panel_SetPos(vector pos)
756 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
760 if(cvar("hud_configure_checkcollisions_debug"))
761 drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
763 if(autocvar_hud_configure_grid)
765 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;
766 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;
769 if(hud_configure_checkcollisions)
770 pos = HUD_Panel_CheckMove(pos, mySize);
772 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
773 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
776 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
778 HUD_Panel_GetName(highlightedPanel);
779 cvar_set(strcat("hud_", panel_name, "_pos"), s);
782 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
783 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
793 ratio = mySize_x/mySize_y;
795 for (i = 0; i < HUD_PANEL_NUM; ++i) {
796 if(i == highlightedPanel || !panel_enabled)
799 HUD_Panel_UpdatePosSizeForId(i)
801 panel_pos -= '1 1 0' * panel_bg_border;
802 panel_size += '2 2 0' * panel_bg_border;
804 targEndPos = panel_pos + panel_size;
806 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
807 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
810 if (resizeCorner == 1)
812 // check if this panel is on our way
813 if (resizeorigin_x <= panel_pos_x)
815 if (resizeorigin_y <= panel_pos_y)
817 if (targEndPos_x <= resizeorigin_x - mySize_x)
819 if (targEndPos_y <= resizeorigin_y - mySize_y)
822 // there is a collision:
823 // detect which side of the panel we are facing is actually limiting the resizing
824 // (which side the resize direction finds for first) and reduce the size up to there
826 // dist is the distance between resizeorigin and the "analogous" point of the panel
827 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
828 dist_x = resizeorigin_x - targEndPos_x;
829 dist_y = resizeorigin_y - targEndPos_y;
830 if (dist_y <= 0 || dist_x / dist_y > ratio)
831 mySize_x = min(mySize_x, dist_x);
833 mySize_y = min(mySize_y, dist_y);
835 else if (resizeCorner == 2)
837 if (resizeorigin_x >= targEndPos_x)
839 if (resizeorigin_y <= panel_pos_y)
841 if (panel_pos_x >= resizeorigin_x + mySize_x)
843 if (targEndPos_y <= resizeorigin_y - mySize_y)
846 dist_x = panel_pos_x - resizeorigin_x;
847 dist_y = resizeorigin_y - targEndPos_y;
848 if (dist_y <= 0 || dist_x / dist_y > ratio)
849 mySize_x = min(mySize_x, dist_x);
851 mySize_y = min(mySize_y, dist_y);
853 else if (resizeCorner == 3)
855 if (resizeorigin_x <= panel_pos_x)
857 if (resizeorigin_y >= targEndPos_y)
859 if (targEndPos_x <= resizeorigin_x - mySize_x)
861 if (panel_pos_y >= resizeorigin_y + mySize_y)
864 dist_x = resizeorigin_x - targEndPos_x;
865 dist_y = panel_pos_y - resizeorigin_y;
866 if (dist_y <= 0 || dist_x / dist_y > ratio)
867 mySize_x = min(mySize_x, dist_x);
869 mySize_y = min(mySize_y, dist_y);
871 else if (resizeCorner == 4)
873 if (resizeorigin_x >= targEndPos_x)
875 if (resizeorigin_y >= targEndPos_y)
877 if (panel_pos_x >= resizeorigin_x + mySize_x)
879 if (panel_pos_y >= resizeorigin_y + mySize_y)
882 dist_x = panel_pos_x - resizeorigin_x;
883 dist_y = panel_pos_y - resizeorigin_y;
884 if (dist_y <= 0 || dist_x / dist_y > ratio)
885 mySize_x = min(mySize_x, dist_x);
887 mySize_y = min(mySize_y, dist_y);
889 if(cvar("hud_configure_checkcollisions_debug"))
890 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
896 void HUD_Panel_SetPosSize(vector mySize)
898 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
900 resizeorigin = panel_click_resizeorigin;
903 // minimum panel size cap
904 mySize_x = max(0.025 * vid_conwidth, mySize_x);
905 mySize_y = max(0.025 * vid_conheight, mySize_y);
907 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.
909 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
910 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
913 // collision testing|
914 // -----------------+
916 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
917 if(resizeCorner == 1) {
918 myPos_x = resizeorigin_x - mySize_x;
919 myPos_y = resizeorigin_y - mySize_y;
920 } else if(resizeCorner == 2) {
921 myPos_x = resizeorigin_x;
922 myPos_y = resizeorigin_y - mySize_y;
923 } else if(resizeCorner == 3) {
924 myPos_x = resizeorigin_x - mySize_x;
925 myPos_y = resizeorigin_y;
926 } else { // resizeCorner == 4
927 myPos_x = resizeorigin_x;
928 myPos_y = resizeorigin_y;
931 // left/top screen edges
933 mySize_x = mySize_x + myPos_x;
935 mySize_y = mySize_y + myPos_y;
937 // bottom/right screen edges
938 if(myPos_x + mySize_x > vid_conwidth)
939 mySize_x = vid_conwidth - myPos_x;
940 if(myPos_y + mySize_y > vid_conheight)
941 mySize_y = vid_conheight - myPos_y;
943 if(cvar("hud_configure_checkcollisions_debug"))
944 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
946 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
947 if(autocvar_hud_configure_grid)
949 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;
950 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;
953 if(hud_configure_checkcollisions)
954 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
956 // 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)
957 mySize_x = max(0.025 * vid_conwidth, mySize_x);
958 mySize_y = max(0.025 * vid_conheight, mySize_y);
960 // do another pos check, as size might have changed by now
961 if(resizeCorner == 1) {
962 myPos_x = resizeorigin_x - mySize_x;
963 myPos_y = resizeorigin_y - mySize_y;
964 } else if(resizeCorner == 2) {
965 myPos_x = resizeorigin_x;
966 myPos_y = resizeorigin_y - mySize_y;
967 } else if(resizeCorner == 3) {
968 myPos_x = resizeorigin_x - mySize_x;
969 myPos_y = resizeorigin_y;
970 } else { // resizeCorner == 4
971 myPos_x = resizeorigin_x;
972 myPos_y = resizeorigin_y;
975 if(cvar("hud_configure_checkcollisions_debug"))
976 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
978 HUD_Panel_GetName(highlightedPanel);
980 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
981 cvar_set(strcat("hud_", panel_name, "_size"), s);
983 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
984 cvar_set(strcat("hud_", panel_name, "_pos"), s);
988 float prevMouseClicked; // previous state
989 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
990 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
993 float menu_enabled_time;
994 float pressed_key_time;
995 void HUD_Panel_Arrow_Action(float nPrimary)
997 if (highlightedPanel_prev == -1 || mouseClicked)
1000 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
1003 if(autocvar_hud_configure_grid)
1005 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
1007 if (hudShiftState & S_SHIFT)
1008 step = bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
1010 step = 2 * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
1014 if (hudShiftState & S_SHIFT)
1015 step = bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
1017 step = 2 * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
1022 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
1023 step = vid_conheight;
1025 step = vid_conwidth;
1026 if (hudShiftState & S_SHIFT)
1027 step = (step / 256); // more precision
1029 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
1032 highlightedPanel = highlightedPanel_prev;
1034 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
1036 if (hudShiftState & S_ALT) // resize
1038 highlightedAction = 1;
1039 if(nPrimary == K_UPARROW)
1041 else if(nPrimary == K_RIGHTARROW)
1043 else if(nPrimary == K_LEFTARROW)
1045 else // if(nPrimary == K_DOWNARROW)
1048 // ctrl+arrow reduces the size, instead of increasing it
1049 // Note that ctrl disables collisions check too, but it's fine
1050 // since we don't collide with anything reducing the size
1051 if (hudShiftState & S_CTRL) {
1053 resizeCorner = 5 - resizeCorner;
1057 mySize = panel_size;
1058 panel_click_resizeorigin = panel_pos;
1059 if(resizeCorner == 1) {
1060 panel_click_resizeorigin += mySize;
1062 } else if(resizeCorner == 2) {
1063 panel_click_resizeorigin_y += mySize_y;
1065 } else if(resizeCorner == 3) {
1066 panel_click_resizeorigin_x += mySize_x;
1068 } else { // resizeCorner == 4
1071 HUD_Panel_SetPosSize(mySize);
1075 highlightedAction = 2;
1078 if(nPrimary == K_UPARROW)
1080 else if(nPrimary == K_DOWNARROW)
1082 else if(nPrimary == K_LEFTARROW)
1084 else // if(nPrimary == K_RIGHTARROW)
1087 HUD_Panel_SetPos(pos);
1091 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1093 if(!autocvar__hud_configure)
1096 // allow console bind to work
1099 con_keys = findkeysforcommand("toggleconsole");
1100 keys = tokenize(con_keys);
1102 float hit_con_bind, i;
1103 for (i = 0; i < keys; ++i)
1105 if(nPrimary == stof(argv(i)))
1109 if(bInputType == 0) {
1110 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1111 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1112 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1114 else if(bInputType == 1) {
1115 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1116 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1117 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1120 if(nPrimary == K_MOUSE1)
1122 if(bInputType == 0) { // key pressed
1126 else if(bInputType == 1) {// key released
1131 else if(nPrimary == K_ESCAPE)
1133 if (bInputType == 1)
1135 disable_menu_alphacheck = 1;
1137 menu_enabled_time = time;
1138 localcmd("menu_showhudexit\n");
1140 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1142 if (bInputType == 1)
1144 pressed_key_time = 0;
1147 else if (pressed_key_time == 0)
1148 pressed_key_time = time;
1150 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1152 else if(hit_con_bind)
1155 return true; // Suppress ALL other input
1158 float HUD_Panel_HighlightCheck()
1164 while(j <= HUD_PANEL_NUM)
1169 HUD_Panel_UpdatePosSizeForId(i)
1171 panelPos = panel_pos;
1172 panelSize = panel_size;
1173 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1176 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1180 // resize from topleft border
1181 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)
1185 // resize from topright border
1186 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)
1190 // resize from bottomleft border
1191 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)
1195 // resize from bottomright border
1196 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)
1204 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1205 void HUD_Panel_FirstInDrawQ(float id)
1208 var float place = -1;
1209 // find out where in the array our current id is, save into place
1210 for(i = 0; i < HUD_PANEL_NUM; ++i)
1212 if(panel_order[i] == id)
1218 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1220 place = HUD_PANEL_NUM - 1;
1222 // move all ids up by one step in the array until "place"
1223 for(i = place; i > 0; --i)
1225 panel_order[i] = panel_order[i-1];
1227 // now save the new top id
1228 panel_order[0] = id;
1230 // let's save them into the cvar by some strcat trickery
1232 for(i = 0; i < HUD_PANEL_NUM; ++i)
1234 s = strcat(s, ftos(panel_order[i]), " ");
1236 cvar_set("_hud_panelorder", s);
1237 if(hud_panelorder_prev)
1238 strunzone(hud_panelorder_prev);
1239 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1242 void HUD_Panel_Highlight()
1248 while(j <= HUD_PANEL_NUM)
1253 HUD_Panel_UpdatePosSizeForId(i)
1255 panelPos = panel_pos;
1256 panelSize = panel_size;
1257 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1260 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1262 highlightedPanel = i;
1263 HUD_Panel_FirstInDrawQ(i);
1264 highlightedAction = 1;
1265 panel_click_distance = mousepos - panelPos;
1268 // resize from topleft border
1269 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)
1271 highlightedPanel = i;
1272 HUD_Panel_FirstInDrawQ(i);
1273 highlightedAction = 2;
1275 panel_click_distance = mousepos - panelPos;
1276 panel_click_resizeorigin = panelPos + panelSize;
1279 // resize from topright border
1280 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)
1282 highlightedPanel = i;
1283 HUD_Panel_FirstInDrawQ(i);
1284 highlightedAction = 2;
1286 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1287 panel_click_distance_y = mousepos_y - panelPos_y;
1288 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1291 // resize from bottomleft border
1292 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)
1294 highlightedPanel = i;
1295 HUD_Panel_FirstInDrawQ(i);
1296 highlightedAction = 2;
1298 panel_click_distance_x = mousepos_x - panelPos_x;
1299 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1300 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1303 // resize from bottomright border
1304 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)
1306 highlightedPanel = i;
1307 HUD_Panel_FirstInDrawQ(i);
1308 highlightedAction = 2;
1310 panel_click_distance = panelSize - mousepos + panelPos;
1311 panel_click_resizeorigin = panelPos;
1316 highlightedPanel_prev = -1;
1321 float highlightcheck;
1322 void HUD_Panel_Mouse()
1324 // 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
1325 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1326 disable_menu_alphacheck = 0;
1327 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1331 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1332 print("Highlighted: ", ftos(highlightedPanel), "\n");
1333 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1336 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1337 highlightedPanel = -1;
1338 highlightedAction = 0;
1340 if(highlightedPanel != -1)
1341 highlightedPanel_prev = highlightedPanel;
1343 mousepos = mousepos + getmousepos();
1345 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1346 mousepos_y = bound(0, mousepos_y, vid_conheight);
1350 if(prevMouseClicked == 0)
1351 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1353 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1355 if(highlightedAction == 1)
1356 HUD_Panel_SetPos(mousepos - panel_click_distance);
1357 else if(highlightedAction == 2)
1360 if(resizeCorner == 1) {
1361 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1362 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1363 } else if(resizeCorner == 2) {
1364 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1365 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1366 } else if(resizeCorner == 3) {
1367 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1368 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1369 } else { // resizeCorner == 4
1370 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1371 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1373 HUD_Panel_SetPosSize(mySize);
1376 // doubleclick check
1377 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1379 mouseClicked = 0; // to prevent spam, I guess.
1380 disable_menu_alphacheck = 2;
1382 menu_enabled_time = time;
1383 HUD_Panel_GetName(highlightedPanel)
1384 localcmd("menu_showhudoptions ", panel_name, "\n");
1387 if(prevMouseClicked == 0)
1389 prevMouseClickedTime = time;
1390 prevMouseClickedPos = mousepos;
1395 highlightcheck = HUD_Panel_HighlightCheck();
1397 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1400 cursorsize = '32 32 0';
1402 if(highlightcheck == 0)
1403 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1404 else if(highlightcheck == 1)
1405 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1406 else if(highlightcheck == 2)
1407 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1409 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1411 prevMouseClicked = mouseClicked;
1414 // Weapon icons (#0)
1416 float weaponspace[10];
1417 #define HUD_WeaponIcons_Clear()\
1419 for(idx = 0; idx < 10; ++idx)\
1420 weaponspace[idx] = 0;
1422 entity weaponorder[WEP_MAXCOUNT];
1423 void weaponorder_swap(float i, float j, entity pass)
1427 weaponorder[i] = weaponorder[j];
1431 string weaponorder_cmp_str_save;
1432 string weaponorder_cmp_str;
1433 float weaponorder_cmp(float i, float j, entity pass)
1436 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1437 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1438 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)
1441 void HUD_WeaponIcons(void)
1443 if(!autocvar_hud_weaponicons && !autocvar__hud_configure)
1446 float id = HUD_PANEL_WEAPONICONS;
1447 HUD_Panel_UpdateCvarsForId(id);
1448 float alpha, stat_weapons; // "constants"
1450 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1453 mySize = panel_size;
1455 stat_weapons = getstati(STAT_WEAPONS);
1457 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1459 self = get_weaponinfo(i);
1460 if(self.impulse >= 0)
1464 // TODO make this configurable
1465 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1467 if(weaponorder_cmp_str != weaponorder_cmp_str_save)
1469 if(weaponorder_cmp_str_save)
1470 strunzone(weaponorder_cmp_str_save);
1471 weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
1473 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1475 self = get_weaponinfo(i);
1476 if(self.impulse >= 0)
1478 weaponorder[weapon_cnt] = self;
1482 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1485 HUD_Panel_DrawBg(1);
1486 if(panel_bg_padding)
1488 pos += '1 1 0' * panel_bg_padding;
1489 mySize -= '2 2 0' * panel_bg_padding;
1493 weapon_stats = getstati(STAT_DAMAGE_HITS);
1494 weapon_number = weapon_stats & 63;
1495 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1497 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1498 weapon_number = weapon_stats & 63;
1499 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1501 if(cvar_or("hud_weaponicons_fade", 1))
1503 fade = 3.2 - 2 * (time - weapontime);
1504 fade = bound(0.7, fade, 1);
1509 HUD_WeaponIcons_Clear();
1511 float rows, columns;
1512 rows = mySize_y/mySize_x;
1513 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1514 // ^^^ weapon icon aspect goes here
1516 columns = ceil(WEP_COUNT/rows);
1521 when = autocvar_hud_weaponicons_complainbubble_time;
1523 fadetime = autocvar_hud_weaponicons_complainbubble_fadetime;
1526 for(i = 0; i < weapon_cnt; ++i)
1528 self = weaponorder[i];
1529 weapid = self.impulse;
1531 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1533 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1534 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1536 // draw background behind currently selected weapon
1537 if(self.weapon == activeweapon)
1538 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);
1540 // draw the weapon accuracy on the HUD
1541 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1544 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1546 // yellow_accuracy = value at which accuracy becomes yellow
1547 if(weapon_stats >= 100) {
1551 else if(weapon_stats > autocvar_hud_weaponicons_accuracy_yellow) {
1552 color_x = 1 - (weapon_stats-autocvar_hud_weaponicons_accuracy_yellow)/(100-autocvar_hud_weaponicons_accuracy_yellow); // red value between 1 -> 0
1556 color_y = weapon_stats/autocvar_hud_weaponicons_accuracy_yellow; // green value between 0 -> 1
1560 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);
1563 // draw the weapon icon
1564 if((self.impulse >= 0) && (stat_weapons & self.weapons))
1566 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);
1568 if(autocvar_hud_weaponicons_number == 1) // weapon number
1569 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);
1570 else if(autocvar_hud_weaponicons_number == 2) // bind
1571 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);
1574 // draw a "ghost weapon icon" if you don't have the weapon
1577 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);
1580 // draw the complain message
1581 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_weaponicons_complainbubble)
1585 if(complain_weapon_time + when > time)
1588 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1592 if(complain_weapon_time + when > time)
1599 if(complain_weapon_type == 0) {
1603 else if(complain_weapon_type == 1) {
1611 drawpic_aspect_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows) + '1 1 0' * autocvar_hud_weaponicons_complainbubble_padding, "weapon_complainbubble", eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows) - '2 2 0' * autocvar_hud_weaponicons_complainbubble_padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
1612 drawstring_aspect(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows) + '1 1 0' * autocvar_hud_weaponicons_complainbubble_padding, s, eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows) - '2 2 0' * autocvar_hud_weaponicons_complainbubble_padding, mySize_y*(1/rows), '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
1628 float GetAmmoStat(float i)
1632 case 0: return STAT_SHELLS;
1633 case 1: return STAT_NAILS;
1634 case 2: return STAT_ROCKETS;
1635 case 3: return STAT_CELLS;
1636 case 4: return STAT_FUEL;
1641 float GetAmmoItemCode(float i)
1645 case 0: return IT_SHELLS;
1646 case 1: return IT_NAILS;
1647 case 2: return IT_ROCKETS;
1648 case 3: return IT_CELLS;
1649 case 4: return IT_FUEL;
1654 string GetAmmoPicture(float i)
1658 case 0: return "ammo_shells";
1659 case 1: return "ammo_bullets";
1660 case 2: return "ammo_rockets";
1661 case 3: return "ammo_cells";
1662 case 4: return "ammo_fuel";
1667 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1670 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1671 if(autocvar__hud_configure)
1681 if(currently_selected)
1686 vector newSize, newPos;
1687 if(mySize_x/mySize_y > 3)
1689 newSize_x = 3 * mySize_y;
1690 newSize_y = mySize_y;
1692 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1697 newSize_y = 1/3 * mySize_x;
1698 newSize_x = mySize_x;
1700 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1704 vector picpos, numpos;
1705 if(autocvar_hud_inventory_iconalign)
1708 picpos = newPos + eX * 2 * newSize_y;
1712 numpos = newPos + eX * newSize_y;
1716 if (currently_selected)
1717 drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1719 drawfont = hud_bigfont;
1720 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1721 drawfont = hud_font;
1722 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1725 void HUD_Inventory(void)
1727 if(!autocvar_hud_inventory && !autocvar__hud_configure)
1730 float id = HUD_PANEL_INVENTORY;
1731 HUD_Panel_UpdateCvarsForId(id);
1732 float i, currently_selected;
1736 mySize = panel_size;
1738 HUD_Panel_DrawBg(1);
1739 if(panel_bg_padding)
1741 pos += '1 1 0' * panel_bg_padding;
1742 mySize -= '2 2 0' * panel_bg_padding;
1745 float rows, columns;
1746 rows = mySize_y/mySize_x;
1747 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1748 // ^^^ ammo item aspect goes here
1750 columns = ceil(AMMO_COUNT/rows);
1754 for (i = 0; i < AMMO_COUNT; ++i) {
1755 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1756 if(autocvar_hud_inventory_onlycurrent) {
1757 if(autocvar__hud_configure)
1759 if (currently_selected || autocvar__hud_configure)
1761 DrawAmmoItem(pos, mySize, i, currently_selected);
1765 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);
1770 column = column + 1;
1776 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color)
1778 vector newSize, newPos;
1779 if(mySize_x/mySize_y > 3)
1781 newSize_x = 3 * mySize_y;
1782 newSize_y = mySize_y;
1784 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1789 newSize_y = 1/3 * mySize_x;
1790 newSize_x = mySize_x;
1792 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1796 vector picpos, numpos;
1799 if(iconalign == 1 || iconalign == 3) // right align
1802 picpos = newPos + eX * 2 * newSize_y;
1806 numpos = newPos + eX * newSize_y;
1812 if(iconalign == 0 || iconalign == 3) // left align
1814 numpos = newPos + eX * newSize_y;
1820 picpos = newPos + eX * 2 * newSize_y;
1824 drawfont = hud_bigfont;
1825 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, newSize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1826 drawfont = hud_font;
1827 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1832 void HUD_Powerups(void) {
1833 if(!autocvar_hud_powerups && !autocvar__hud_configure)
1836 float id = HUD_PANEL_POWERUPS;
1837 HUD_Panel_UpdateCvarsForId(id);
1839 stat_items = getstati(STAT_ITEMS);
1841 if(!autocvar__hud_configure)
1843 if not(stat_items & IT_STRENGTH)
1844 if not(stat_items & IT_INVINCIBLE)
1847 if (getstati(STAT_HEALTH) <= 0)
1853 mySize = panel_size;
1855 HUD_Panel_DrawBg(1);
1856 if(panel_bg_padding)
1858 pos += '1 1 0' * panel_bg_padding;
1859 mySize -= '2 2 0' * panel_bg_padding;
1862 float strength_time, shield_time;
1864 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1865 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1867 if(autocvar__hud_configure)
1873 vector barpos, barsize;
1877 string leftname, rightname;
1878 float leftcnt, rightcnt;
1879 float leftexact, rightexact;
1880 float leftalpha, rightalpha;
1881 if (autocvar_hud_powerups_flip) {
1882 leftname = "strength";
1883 leftcnt = ceil(strength_time);
1884 leftexact = strength_time;
1886 rightname = "shield";
1887 rightcnt = ceil(shield_time);
1888 rightexact = shield_time;
1890 leftname = "shield";
1891 leftcnt = ceil(shield_time);
1892 leftexact = shield_time;
1894 rightname = "strength";
1895 rightcnt = ceil(strength_time);
1896 rightexact = strength_time;
1898 leftalpha = bound(0, leftexact, 1);
1899 rightalpha = bound(0, rightexact, 1);
1901 drawfont = hud_bigfont;
1902 if (mySize_x/mySize_y > 4)
1906 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1907 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1908 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1909 } else { // left align
1911 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1914 HUD_Panel_GetProgressBarColor(leftname)
1915 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1916 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1');
1919 // 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));
1921 // drawpic_aspect_skin(picpos, leftname, eX * (1/6) * mySize_x + eY * mySize_y, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1926 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1927 barpos = pos + eX * 0.5 * mySize_x;
1928 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1929 } else { // right align
1930 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1931 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1934 HUD_Panel_GetProgressBarColor(rightname)
1935 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1936 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');
1939 else if (mySize_x/mySize_y > 1.5)
1943 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1944 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1945 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1946 } else { // left align
1948 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1951 HUD_Panel_GetProgressBarColor(leftname)
1952 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1953 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1');
1958 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1959 barpos = pos + eY * 0.5 * mySize_y;
1960 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1961 } else { // right align
1962 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1963 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1966 HUD_Panel_GetProgressBarColor(rightname)
1967 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1968 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');
1975 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // down align
1976 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1977 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1978 } else { // up align
1980 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1983 if(autocvar_hud_powerups_iconalign == 1 || autocvar_hud_powerups_iconalign == 3) { // down align
1984 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
1985 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
1986 } else { // up align
1987 picpos = pos + eX * 0.05 * mySize_x;
1988 numpos = pos + eY * 0.4 * mySize_x;
1991 HUD_Panel_GetProgressBarColor(leftname)
1992 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1994 //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));
1996 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1997 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);
2002 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // up align
2003 barpos = pos + eX * 0.5 * mySize_x;
2004 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2005 } else { // down align
2006 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
2007 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2010 if(autocvar_hud_powerups_iconalign == 0 || autocvar_hud_powerups_iconalign == 3) { // up align
2011 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2012 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2013 } else { // down align
2014 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2015 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2018 HUD_Panel_GetProgressBarColor(rightname)
2019 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2021 // 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));
2023 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2024 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);
2027 drawfont = hud_font;
2030 // Health/armor (#3)
2032 void HUD_HealthArmor(void)
2034 if(!autocvar_hud_healtharmor && !autocvar__hud_configure)
2037 float id = HUD_PANEL_HEALTHARMOR;
2038 HUD_Panel_UpdateCvarsForId(id);
2041 mySize = panel_size;
2043 HUD_Panel_DrawBg(1);
2044 if(panel_bg_padding)
2046 pos += '1 1 0' * panel_bg_padding;
2047 mySize -= '2 2 0' * panel_bg_padding;
2050 float armor, health;
2051 armor = getstati(STAT_ARMOR);
2052 health = getstati(STAT_HEALTH);
2055 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
2057 if(autocvar__hud_configure)
2067 vector barpos, barsize;
2071 drawfont = hud_bigfont;
2072 if(autocvar_hud_healtharmor == 2) // combined health and armor display
2075 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2080 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2081 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2082 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2083 } else { // left align
2085 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2089 if(v_z) // NOT fully armored
2091 biggercount = "health";
2092 HUD_Panel_GetProgressBarColor("health")
2093 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2095 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);
2099 biggercount = "armor";
2100 HUD_Panel_GetProgressBarColor("armor")
2101 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2103 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);
2105 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200));
2110 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2111 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2112 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2115 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2117 HUD_Panel_GetProgressBarColor("fuel")
2118 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2123 string leftname, rightname;
2124 float leftcnt, rightcnt;
2125 float leftactive, rightactive;
2126 float leftalpha, rightalpha;
2127 if (autocvar_hud_healtharmor_flip) { // old style layout with armor left/top of health
2132 leftalpha = min((armor+10)/55, 1);
2134 rightname = "health";
2139 leftname = "health";
2144 rightname = "armor";
2148 rightalpha = min((armor+10)/55, 1);
2151 if (mySize_x/mySize_y > 4)
2155 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2156 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2157 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2158 } else { // left align
2160 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2163 HUD_Panel_GetProgressBarColor(leftname)
2164 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2165 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2170 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2171 barpos = pos + eX * 0.5 * mySize_x;
2172 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2173 } else { // right align
2174 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2175 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2178 HUD_Panel_GetProgressBarColor(rightname)
2179 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2180 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));
2185 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2186 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2187 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2190 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2192 HUD_Panel_GetProgressBarColor("fuel")
2193 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2196 else if (mySize_x/mySize_y > 1.5)
2200 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2201 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2202 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2203 } else { // left align
2205 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2208 HUD_Panel_GetProgressBarColor(leftname)
2209 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2210 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2215 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2216 barpos = pos + eY * 0.5 * mySize_y;
2217 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2218 } else { // right align
2219 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2220 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2223 HUD_Panel_GetProgressBarColor(rightname)
2224 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2225 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));
2230 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2231 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2232 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2235 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2237 HUD_Panel_GetProgressBarColor("fuel")
2238 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2245 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // down align
2246 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2247 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2248 } else { // up align
2250 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2253 if(autocvar_hud_healtharmor_iconalign == 1 || autocvar_hud_healtharmor_iconalign == 3) { // down align
2254 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2255 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2256 } else { // up align
2257 picpos = pos + eX * 0.05 * mySize_x;
2258 numpos = pos + eY * 0.4 * mySize_x;
2261 HUD_Panel_GetProgressBarColor(leftname)
2262 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2263 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2264 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);
2269 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // up align
2270 barpos = pos + eX * 0.5 * mySize_x;
2271 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2272 } else { // down align
2273 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2274 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2277 if(autocvar_hud_healtharmor_iconalign == 0 || autocvar_hud_healtharmor_iconalign == 3) { // up align
2278 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2279 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2280 } else { // down align
2281 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2282 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2285 HUD_Panel_GetProgressBarColor(rightname)
2286 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2287 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2288 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);
2293 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2295 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2297 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2298 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2300 HUD_Panel_GetProgressBarColor("fuel")
2301 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2305 drawfont = hud_font;
2308 // Notification area (#4)
2311 string Weapon_SuicideMessage(float deathtype)
2313 w_deathtype = deathtype;
2314 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2315 return w_deathtypestring;
2318 string Weapon_KillMessage(float deathtype)
2320 w_deathtype = deathtype;
2321 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2322 return w_deathtypestring;
2325 float killnotify_times[10];
2326 float killnotify_deathtype[10];
2327 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2328 string killnotify_attackers[10];
2329 string killnotify_victims[10];
2330 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2333 for (i = 9; i > 0; --i) {
2334 killnotify_times[i] = killnotify_times[i-1];
2335 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2336 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2337 if(killnotify_attackers[i])
2338 strunzone(killnotify_attackers[i]);
2339 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2340 if(killnotify_victims[i])
2341 strunzone(killnotify_victims[i]);
2342 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2344 killnotify_times[0] = time;
2345 killnotify_deathtype[0] = wpn;
2346 killnotify_actiontype[0] = actiontype;
2347 if(killnotify_attackers[0])
2348 strunzone(killnotify_attackers[0]);
2349 killnotify_attackers[0] = strzone(attacker);
2350 if(killnotify_victims[0])
2351 strunzone(killnotify_victims[0]);
2352 killnotify_victims[0] = strzone(victim);
2355 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2359 alsoprint = (autocvar_hud_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2361 if(msg == MSG_SUICIDE) {
2363 w = DEATH_WEAPONOF(type);
2365 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2367 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2368 } else if (type == DEATH_KILL) {
2369 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2371 print ("^1",s1, "^1 couldn't take it anymore\n");
2372 } else if (type == DEATH_ROT) {
2373 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2375 print ("^1",s1, "^1 died\n");
2376 } else if (type == DEATH_NOAMMO) {
2377 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2379 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2380 } else if (type == DEATH_CAMP) {
2381 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2383 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2384 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2385 HUD_KillNotify_Push(s1, "", 0, type);
2387 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2388 } else if (type == DEATH_CHEAT) {
2389 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2391 print ("^1",s1, "^1 unfairly eliminated themself\n");
2392 } else if (type == DEATH_FIRE) {
2393 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2395 print ("^1",s1, "^1 burned to death\n");
2396 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2397 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2399 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2402 if (stof(s2) > 2) // killcount > 2
2403 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2404 } else if(msg == MSG_KILL) {
2405 w = DEATH_WEAPONOF(type);
2407 HUD_KillNotify_Push(s2, s1, 1, w);
2409 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2411 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2412 HUD_KillNotify_Push(s1, s2, 1, type);
2415 if(cvar("cl_gentle")) {
2416 print ("^1", s1, "^1 took action against a team mate\n");
2418 print ("^1", s1, "^1 mows down a team mate\n");
2421 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2422 if(cvar("cl_gentle"))
2423 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2425 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2427 else if (stof(s2) > 2) {
2428 if(cvar("cl_gentle"))
2429 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2431 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2434 else if(type == KILL_FIRST_BLOOD)
2435 print("^1",s1, "^1 drew first blood", "\n");
2437 else if (type == DEATH_TELEFRAG)
2438 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2439 else if (type == DEATH_DROWN) {
2440 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2442 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2444 else if (type == DEATH_SLIME) {
2445 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2447 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2449 else if (type == DEATH_LAVA) {
2450 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2452 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2454 else if (type == DEATH_FALL) {
2455 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2457 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2459 else if (type == DEATH_SHOOTING_STAR) {
2460 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2462 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2464 else if (type == DEATH_SWAMP) {
2465 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2467 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2469 else if (type == DEATH_HURTTRIGGER)
2471 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2473 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2474 } else if(type == DEATH_SBCRUSH) {
2475 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2477 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2478 } else if(type == DEATH_SBMINIGUN) {
2479 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2481 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2482 } else if(type == DEATH_SBROCKET) {
2483 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2485 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2486 } else if(type == DEATH_SBBLOWUP) {
2487 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2489 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2490 } else if(type == DEATH_WAKIGUN) {
2491 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2493 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2494 } else if(type == DEATH_WAKIROCKET) {
2495 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2497 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2498 } else if(type == DEATH_WAKIBLOWUP) {
2499 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2501 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2502 } else if(type == DEATH_TURRET) {
2503 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2505 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2506 } else if(type == DEATH_TOUCHEXPLODE) {
2507 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2509 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2510 } else if(type == DEATH_CHEAT) {
2511 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2513 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2514 } else if (type == DEATH_FIRE) {
2515 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2517 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2518 } else if (type == DEATH_CUSTOM) {
2519 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2521 print ("^1",s1, "^1 ", s2, "\n");
2523 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2525 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2527 } else if(msg == MSG_SPREE) {
2528 if(type == KILL_END_SPREE) {
2529 if(cvar("cl_gentle"))
2530 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2532 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2533 } else if(type == KILL_SPREE) {
2534 if(cvar("cl_gentle"))
2535 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2537 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2538 } else if(type == KILL_SPREE_3) {
2539 if(cvar("cl_gentle"))
2540 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2542 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2543 } else if(type == KILL_SPREE_5) {
2544 if(cvar("cl_gentle"))
2545 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2547 print (s1,"^7 unleashes ^1RAGE\n");
2548 } else if(type == KILL_SPREE_10) {
2549 if(cvar("cl_gentle"))
2550 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2552 print (s1,"^7 starts the ^1MASSACRE!\n");
2553 } else if(type == KILL_SPREE_15) {
2554 if(cvar("cl_gentle"))
2555 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2557 print (s1,"^7 executes ^1MAYHEM!\n");
2558 } else if(type == KILL_SPREE_20) {
2559 if(cvar("cl_gentle"))
2560 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2562 print (s1,"^7 is a ^1BERSERKER!\n");
2563 } else if(type == KILL_SPREE_25) {
2564 if(cvar("cl_gentle"))
2565 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2567 print (s1,"^7 inflicts ^1CARNAGE!\n");
2568 } else if(type == KILL_SPREE_30) {
2569 if(cvar("cl_gentle"))
2570 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2572 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2574 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2575 if (type == DEATH_DROWN) {
2576 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2579 if(cvar("cl_gentle"))
2580 print ("^1",s1, "^1 was in the water for too long\n");
2582 print ("^1",s1, "^1 drowned\n");
2584 } else if (type == DEATH_SLIME) {
2585 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2587 print ("^1",s1, "^1 was slimed\n");
2588 } else if (type == DEATH_LAVA) {
2589 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2592 if(cvar("cl_gentle"))
2593 print ("^1",s1, "^1 found a hot place\n");
2595 print ("^1",s1, "^1 turned into hot slag\n");
2597 } else if (type == DEATH_FALL) {
2598 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2601 if(cvar("cl_gentle"))
2602 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2604 print ("^1",s1, "^1 hit the ground with a crunch\n");
2606 } else if (type == DEATH_SHOOTING_STAR) {
2607 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2609 print ("^1",s1, "^1 became a shooting star\n");
2610 } else if (type == DEATH_SWAMP) {
2611 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2614 if(cvar("cl_gentle"))
2615 print ("^1",s1, "^1 discovered a swamp\n");
2617 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2619 } else if(type == DEATH_TURRET) {
2620 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2622 print ("^1",s1, "^1 was mowed down by a turret \n");
2623 } else if (type == DEATH_CUSTOM) {
2624 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2626 print ("^1",s1, "^1 ", s2, "\n");
2627 } else if (type == DEATH_HURTTRIGGER) {
2628 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2630 print ("^1",s1, "^1 was in the wrong place\n");
2631 } else if(type == DEATH_TOUCHEXPLODE) {
2632 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2634 print ("^1",s1, "^1 died in an accident\n");
2635 } else if(type == DEATH_CHEAT) {
2636 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2638 print ("^1",s1, "^1 was unfairly eliminated\n");
2639 } else if(type == DEATH_FIRE) {
2640 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2643 if(cvar("cl_gentle"))
2644 print ("^1",s1, "^1 felt a little hot\n");
2646 print ("^1",s1, "^1 burnt to death\n");
2649 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2652 if(cvar("cl_gentle"))
2653 print ("^1",s1, "^1 needs a restart\n");
2655 print ("^1",s1, "^1 died\n");
2658 } else if(msg == MSG_KILL_ACTION_SPREE) {
2659 if(cvar("cl_gentle"))
2660 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2662 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2663 } else if(msg == MSG_INFO) {
2664 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2665 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2666 print(s1, "^7 got the ", s2, "\n");
2667 } else if(type == INFO_LOSTFLAG) {
2668 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2669 print(s1, "^7 lost the ", s2, "\n");
2670 } else if(type == INFO_PICKUPFLAG) {
2671 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2672 print(s1, "^7 picked up the ", s2, "\n");
2673 } else if(type == INFO_RETURNFLAG) {
2674 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2675 print(s1, "^7 returned the ", s2, "\n");
2680 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2682 void HUD_Centerprint(string s1, string s2, float type, float msg)
2684 if(msg == MSG_SUICIDE) {
2685 if (type == DEATH_TEAMCHANGE) {
2686 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2687 } else if (type == DEATH_AUTOTEAMCHANGE) {
2688 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2689 } else if (type == DEATH_CAMP) {
2690 if(cvar("cl_gentle"))
2691 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2693 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2694 } else if (type == DEATH_NOAMMO) {
2695 if(cvar("cl_gentle"))
2696 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2698 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2699 } else if (type == DEATH_ROT) {
2700 if(cvar("cl_gentle"))
2701 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2703 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2704 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2705 if(cvar("cl_gentle"))
2706 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2708 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2709 } else if (type == DEATH_QUIET) {
2711 } else if (type == DEATH_KILL) {
2712 if(cvar("cl_gentle"))
2713 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2715 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2717 } else if(msg == MSG_KILL) {
2718 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2719 if(cvar("cl_gentle")) {
2720 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2722 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2724 } else if (type == KILL_FIRST_BLOOD) {
2725 if(cvar("cl_gentle")) {
2726 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2728 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2730 } else if (type == KILL_FIRST_VICTIM) {
2731 if(cvar("cl_gentle")) {
2732 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2734 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2736 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2737 if(cvar("cl_gentle")) {
2738 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2740 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2742 } else if (type == KILL_TYPEFRAGGED) {
2743 if(cvar("cl_gentle")) {
2744 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2746 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2748 } else if (type == KILL_FRAG) {
2749 if(cvar("cl_gentle")) {
2750 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2752 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2754 } else if (type == KILL_FRAGGED) {
2755 if(cvar("cl_gentle")) {
2756 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2758 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2761 } else if(msg == MSG_KILL_ACTION) {
2762 // TODO: invent more centerprints here?
2763 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2767 void HUD_Notify (void)
2769 if(!autocvar_hud_notify && !autocvar__hud_configure)
2772 float id = HUD_PANEL_NOTIFY;
2773 HUD_Panel_UpdateCvarsForId(id);
2776 mySize = panel_size;
2778 HUD_Panel_DrawBg(1);
2779 if(panel_bg_padding)
2781 pos += '1 1 0' * panel_bg_padding;
2782 mySize -= '2 2 0' * panel_bg_padding;
2785 float entries, height;
2786 entries = bound(1, floor(10 * mySize_y/mySize_x), 10);
2787 height = mySize_y/entries;
2790 fontsize = '0.5 0.5 0' * height;
2794 when = autocvar_hud_notify_time;
2796 fadetime = autocvar_hud_notify_fadetime;
2801 vector pos_attacker, pos_victim;
2803 float width_attacker;
2804 string attacker, victim;
2807 for(j = 0; j < entries; ++j)
2810 if(autocvar_hud_notify_flip)
2812 else // rather nasty hack for ordering items from the bottom up
2813 i = entries - j - 1;
2817 if(killnotify_times[j] + when > time)
2820 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2824 if(killnotify_times[j] + when > time)
2830 // TODO: maybe print in team colors?
2833 if(killnotify_actiontype[j] == 0 && !autocvar__hud_configure)
2835 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2836 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
2837 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2839 if(killnotify_deathtype[j] == DEATH_GENERIC)
2844 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2846 s = "notify_outofammo";
2849 else if(killnotify_deathtype[j] == DEATH_KILL)
2851 s = "notify_selfkill";
2854 else if(killnotify_deathtype[j] == DEATH_CAMP)
2856 s = "notify_camping";
2859 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2861 s = "notify_teamkill";
2864 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2866 s = "notify_teamkill";
2869 else if(killnotify_deathtype[j] == DEATH_DROWN)
2874 else if(killnotify_deathtype[j] == DEATH_SLIME)
2879 else if(killnotify_deathtype[j] == DEATH_LAVA)
2884 else if(killnotify_deathtype[j] == DEATH_FALL)
2889 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2894 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2899 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2901 if(killnotify_victims[j] == "^1RED^7 flag")
2903 s = "flag_red_carrying";
2908 s = "flag_blue_carrying";
2912 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2914 if(killnotify_victims[j] == "^1RED^7 flag")
2916 s = "flag_red_taken";
2921 s = "flag_blue_taken";
2925 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2927 if(killnotify_victims[j] == "^1RED^7 flag")
2929 s = "flag_red_lost";
2934 s = "flag_blue_lost";
2940 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, color, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2941 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2944 // X [did action to] Y
2947 if(autocvar__hud_configure)
2949 attacker = textShortenToWidth("Player1", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2950 victim = textShortenToWidth("Player2", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2951 a = bound(0, (when - j) / 4, 1);
2955 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2956 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2958 width_attacker = stringwidth(attacker, TRUE, fontsize);
2959 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
2960 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
2961 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2963 if(autocvar__hud_configure) // example actions for config mode
2965 s = "weaponelectro";
2968 else if(WEP_VALID(killnotify_deathtype[j]))
2970 self = get_weaponinfo(killnotify_deathtype[j]);
2971 s = strcat("weapon", self.netname);
2974 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2976 s = "notify_teamkill";
2979 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2981 s = "notify_teamkill";
2984 else if(killnotify_deathtype[j] == DEATH_DROWN)
2989 else if(killnotify_deathtype[j] == DEATH_SLIME)
2994 else if(killnotify_deathtype[j] == DEATH_LAVA)
2999 else if(killnotify_deathtype[j] == DEATH_FALL)
3004 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
3006 s = "notify_shootingstar";
3009 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
3016 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, color, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3017 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3018 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3027 string seconds_tostring(float sec)
3030 minutes = floor(sec / 60);
3032 sec -= minutes * 60;
3035 s = ftos(100 + sec);
3037 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3040 void HUD_Timer(void)
3042 if(!autocvar_hud_timer && !autocvar__hud_configure)
3045 float id = HUD_PANEL_TIMER;
3046 HUD_Panel_UpdateCvarsForId(id);
3049 mySize = panel_size;
3051 HUD_Panel_DrawBg(1);
3052 if(panel_bg_padding)
3054 pos += '1 1 0' * panel_bg_padding;
3055 mySize -= '2 2 0' * panel_bg_padding;
3059 float timelimit, elapsedTime, timeleft, minutesLeft;
3061 timelimit = getstatf(STAT_TIMELIMIT);
3063 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3064 timeleft = ceil(timeleft);
3066 minutesLeft = floor(timeleft / 60);
3069 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3070 timer_color = '1 1 1'; //white
3071 else if(minutesLeft >= 1)
3072 timer_color = '1 1 0'; //yellow
3074 timer_color = '1 0 0'; //red
3076 if (autocvar_hud_timer_increment || timelimit == 0 || warmup_stage) {
3077 if (time < getstatf(STAT_GAMESTARTTIME)) {
3078 //while restart is still active, show 00:00
3079 timer = seconds_tostring(0);
3081 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3082 timer = seconds_tostring(elapsedTime);
3085 timer = seconds_tostring(timeleft);
3088 drawfont = hud_bigfont;
3089 drawstring_aspect(pos, timer, mySize, mySize_y, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3090 drawfont = hud_font;
3095 void HUD_Radar(void)
3097 if (!(autocvar_hud_radar != 0 && (autocvar_hud_radar == 2 || teamplay || autocvar__hud_configure)))
3100 float id = HUD_PANEL_RADAR;
3101 HUD_Panel_UpdateCvarsForId(id);
3104 mySize = panel_size;
3106 HUD_Panel_DrawBg(1);
3107 if(panel_bg_padding)
3109 pos += '1 1 0' * panel_bg_padding;
3110 mySize -= '2 2 0' * panel_bg_padding;
3113 local float color1, color2; // color already declared as a global in hud.qc
3116 float scale2d, normalsize, bigsize;
3119 teamradar_origin2d = pos + 0.5 * mySize;
3120 teamradar_size2d = mySize;
3122 if(minimapname == "")
3125 teamradar_loadcvars();
3127 switch(hud_radar_zoommode)
3131 f = current_zoomfraction;
3134 f = 1 - current_zoomfraction;
3144 switch(hud_radar_rotation)
3147 teamradar_angle = view_angles_y - 90;
3150 teamradar_angle = 90 * hud_radar_rotation;
3154 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3155 teamradar_size2d = mySize;
3157 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3159 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3160 if(hud_radar_rotation == 0)
3162 // max-min distance must fit the radar in any rotation
3163 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3167 vector c0, c1, c2, c3, span;
3168 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3169 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3170 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3171 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3173 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3174 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3176 // max-min distance must fit the radar in x=x, y=y
3178 teamradar_size2d_x * scale2d / (1.05 * span_x),
3179 teamradar_size2d_y * scale2d / (1.05 * span_y)
3183 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3184 if(bigsize > normalsize)
3185 normalsize = bigsize;
3189 + (1 - f) * normalsize;
3190 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3191 f * (mi_min + mi_max) * 0.5
3192 + (1 - f) * view_origin);
3194 color1 = GetPlayerColor(player_localentnum-1);
3195 rgb = GetTeamRGB(color1);
3204 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3206 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3207 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3208 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3209 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3210 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3212 color2 = GetPlayerColor(tm.sv_entnum);
3213 //if(color == COLOR_SPECTATOR || color == color2)
3214 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3216 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3218 drawresetcliparea();
3223 void HUD_Score(void)
3225 if(!autocvar_hud_score && !autocvar__hud_configure)
3228 float id = HUD_PANEL_SCORE;
3229 HUD_Panel_UpdateCvarsForId(id);
3232 mySize = panel_size;
3234 HUD_Panel_DrawBg(1);
3235 if(panel_bg_padding)
3237 pos += '1 1 0' * panel_bg_padding;
3238 mySize -= '2 2 0' * panel_bg_padding;
3241 float score, distribution, leader;
3243 vector distribution_color;
3245 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3247 // TODO... this (race part) still uses constant coordinates :/
3248 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3249 /*pl = players.sort_next;
3252 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3253 if(pl.scores[ps_primary] == 0)
3256 score = me.(scores[ps_primary]);
3258 float racemin, racesec, racemsec;
3259 float distsec, distmsec, minusplus;
3261 racemin = floor(score/(60 * TIME_FACTOR));
3262 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
3263 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
3265 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3266 // distribution display
3267 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3269 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
3270 distmsec = fabs(distribution);
3272 distsec = floor(fabs(distribution)/TIME_FACTOR);
3273 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
3274 if (distribution < 0)
3278 if (distribution <= 0) {
3279 distribution_color = eY;
3280 minusplus = 1; // minusplus 1: always prefix with minus sign
3283 distribution_color = eX;
3284 minusplus = 2; // minusplus 1: always prefix with plus sign
3286 //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);
3287 //HUD_DrawXNum(bottomright - '68 48 0' - '16 0 0' * TIME_DECIMALS, distsec, 4, minusplus, 16, distribution_color, 0, 0, panel_fg_alpha, DRAWFLAG_NORMAL);
3288 drawpic_aspect_skin(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "num_dot", '16 16 0', distribution_color, panel_fg_alpha, DRAWFLAG_ADDITIVE);
3290 // race record display
3291 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
3292 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);
3294 //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);
3295 //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);
3296 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);
3298 //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);
3299 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);
3301 } else if (!teamplay) { // non-teamgames
3302 // me vector := [team/connected frags id]
3303 pl = players.sort_next;
3307 if(autocvar__hud_configure)
3310 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3314 score = me.(scores[ps_primary]);
3315 if(autocvar__hud_configure)
3318 if(distribution >= 5) {
3319 distribution_color = eY;
3321 } else if(distribution >= 0) {
3322 distribution_color = '1 1 1';
3324 } else if(distribution >= -5)
3325 distribution_color = '1 1 0';
3327 distribution_color = eX;
3329 score_len = strlen(ftos(score));
3331 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);
3333 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3334 drawfont = hud_bigfont;
3335 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3336 drawfont = hud_font;
3337 } else { // teamgames
3338 float max_fragcount;
3339 max_fragcount = -99;
3342 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3343 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !autocvar__hud_configure)) // no players? don't display
3345 score = tm.(teamscores[ts_primary]);
3346 if(autocvar__hud_configure)
3350 score_len = strlen(ftos(score));
3352 if (score > max_fragcount)
3353 max_fragcount = score;
3355 if(tm.team == myteam) {
3356 if (max_fragcount == score)
3359 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3360 drawfont = hud_bigfont;
3361 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);
3362 drawfont = hud_font;
3364 if (max_fragcount == score)
3367 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);
3368 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);
3377 void HUD_RaceTimer (void) {
3378 if(!autocvar_hud_racetimer && !(gametype == GAME_RACE || gametype == GAME_CTS) && !autocvar__hud_configure)
3381 float id = HUD_PANEL_RACETIMER;
3382 HUD_Panel_UpdateCvarsForId(id);
3385 mySize = panel_size;
3387 HUD_Panel_DrawBg(1);
3388 if(panel_bg_padding)
3390 pos += '1 1 0' * panel_bg_padding;
3391 mySize -= '2 2 0' * panel_bg_padding;
3394 // always force 4:1 aspect
3396 if(mySize_x/mySize_y > 4)
3398 newSize_x = 4 * mySize_y;
3399 newSize_y = mySize_y;
3401 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3405 newSize_y = 1/4 * mySize_x;
3406 newSize_x = mySize_x;
3408 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3412 drawfont = hud_bigfont;
3414 string s, forcetime;
3416 if(autocvar__hud_configure)
3419 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);
3420 s = "^1Intermediate 1 (+15.42)";
3421 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);
3422 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3423 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);
3425 else if(race_checkpointtime)
3427 a = bound(0, 2 - (time - race_checkpointtime), 1);
3430 if(a > 0) // just hit a checkpoint?
3432 if(race_checkpoint != 254)
3434 if(race_time && race_previousbesttime)
3435 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3437 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3439 forcetime = TIME_ENCODED_TOSTRING(race_time);
3444 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3446 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3447 if(a > 0) // next one?
3449 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3454 if(s != "" && a > 0)
3456 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3457 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3458 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);
3461 if(race_penaltytime)
3463 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3466 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3467 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3468 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3469 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);
3475 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3476 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', panel_fg_alpha, 0, a);
3477 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);
3482 if(race_laptime && race_checkpoint != 255)
3484 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3485 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3486 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);
3491 if(race_mycheckpointtime)
3493 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3494 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3495 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3496 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3497 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);
3499 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3501 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3502 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3503 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3504 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3505 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);
3508 if(race_penaltytime && !race_penaltyaccumulator)
3510 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3511 a = bound(0, (1 + t - time), 1);
3515 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3517 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3518 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3519 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3520 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);
3525 drawfont = hud_font;
3530 float vote_yescount;
3533 float vote_highlighted; // currently selected vote
3535 float vote_active; // is there an active vote?
3536 float vote_prev; // previous state of vote_active to check for a change
3538 float vote_change; // "time" when vote_active changed
3540 void HUD_VoteWindow(void)
3542 if(!autocvar_hud_vote && !autocvar__hud_configure)
3545 float id = HUD_PANEL_VOTE;
3546 HUD_Panel_UpdateCvarsForId(id);
3549 mySize = panel_size;
3553 if(vote_active != vote_prev) {
3555 vote_prev = vote_active;
3558 if(vote_active || autocvar__hud_configure)
3559 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3561 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3563 if(autocvar__hud_configure)
3573 a = vote_alpha * bound(autocvar_hud_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3575 HUD_Panel_DrawBg(a);
3576 if(panel_bg_padding)
3578 pos += '1 1 0' * panel_bg_padding;
3579 mySize -= '2 2 0' * panel_bg_padding;
3582 // always force 3:1 aspect
3584 if(mySize_x/mySize_y > 3)
3586 newSize_x = 3 * mySize_y;
3587 newSize_y = mySize_y;
3589 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3593 newSize_y = 1/3 * mySize_x;
3594 newSize_x = mySize_x;
3596 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3600 s = "A vote has been called for:";
3601 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);
3602 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1.75/8), stringwidth_colors);
3603 if(autocvar__hud_configure)
3604 s = "Configure the HUD";
3605 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);
3607 // print the yes/no counts
3608 s = strcat("Yes (", getcommandkey("not bound", "vyes"), "): ", ftos(vote_yescount));
3609 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);
3610 s = strcat("No (", getcommandkey("not bound", "vno"), "): ", ftos(vote_nocount));
3611 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);
3613 // draw the progress bar backgrounds
3614 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);
3616 // draw the highlights
3617 if(vote_highlighted == 1) {
3618 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3619 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);
3621 else if(vote_highlighted == 2) {
3622 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3623 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);
3626 // draw the progress bars
3627 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3628 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);
3630 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3631 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);
3633 drawresetcliparea();
3636 vote_highlighted = 0;
3640 // Mod icons panel (#10)
3643 float mod_active; // is there any active mod icon?
3645 // CTF HUD modicon section
3646 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3647 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3648 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3650 void HUD_Mod_CTF_Reset(void)
3652 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3655 void HUD_Mod_CTF(vector pos, vector mySize)
3657 vector redflag_pos, blueflag_pos;
3659 float f; // every function should have that
3661 float redflag, blueflag; // current status
3662 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3665 stat_items = getstati(STAT_ITEMS);
3666 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3667 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3669 if(redflag || blueflag)
3674 if(autocvar__hud_configure)
3680 // when status CHANGES, set old status into prevstatus and current status into status
3681 if (redflag != redflag_prevframe)
3683 redflag_statuschange_time = time;
3684 redflag_prevstatus = redflag_prevframe;
3685 redflag_prevframe = redflag;
3688 if (blueflag != blueflag_prevframe)
3690 blueflag_statuschange_time = time;
3691 blueflag_prevstatus = blueflag_prevframe;
3692 blueflag_prevframe = blueflag;
3695 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3696 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3698 float BLINK_FACTOR = 0.15;
3699 float BLINK_BASE = 0.85;
3701 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3703 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3705 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3707 string red_icon, red_icon_prevstatus;
3708 float red_alpha, red_alpha_prevstatus;
3709 red_alpha = red_alpha_prevstatus = 1;
3711 case 1: red_icon = "flag_red_taken"; break;
3712 case 2: red_icon = "flag_red_lost"; break;
3713 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3715 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3716 red_icon = "flag_red_shielded";
3718 red_icon = string_null;
3721 switch(redflag_prevstatus) {
3722 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3723 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3724 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3727 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3728 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3729 red_icon_prevstatus = "flag_red_shielded";
3731 red_icon_prevstatus = string_null;
3735 string blue_icon, blue_icon_prevstatus;
3736 float blue_alpha, blue_alpha_prevstatus;
3737 blue_alpha = blue_alpha_prevstatus = 1;
3739 case 1: blue_icon = "flag_blue_taken"; break;
3740 case 2: blue_icon = "flag_blue_lost"; break;
3741 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3743 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3744 blue_icon = "flag_blue_shielded";
3746 blue_icon = string_null;
3749 switch(blueflag_prevstatus) {
3750 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3751 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3752 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3755 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3756 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3757 blue_icon_prevstatus = "flag_blue_shielded";
3759 blue_icon_prevstatus = string_null;
3763 if(mySize_x > mySize_y) {
3764 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3766 blueflag_pos = pos + eX * 0.5 * mySize_x;
3769 redflag_pos = pos + eX * 0.5 * mySize_x;
3771 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3773 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3775 blueflag_pos = pos + eY * 0.5 * mySize_y;
3778 redflag_pos = pos + eY * 0.5 * mySize_y;
3780 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3783 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3784 if(red_icon_prevstatus && f < 1)
3785 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3787 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3789 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3790 if(blue_icon_prevstatus && f < 1)
3791 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3793 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3796 // Keyhunt HUD modicon section
3797 float kh_runheretime;
3799 void HUD_Mod_KH_Reset(void)
3804 void HUD_Mod_KH(vector pos, vector mySize)
3806 mod_active = 1; // keyhunt should never hide the mod icons panel
3810 vector p, pa, kh_size, kh_asize;
3812 kh_keys = getstati(STAT_KH_KEYS);
3815 if(mySize_x > mySize_y)
3817 p_y = pos_y + 0.25 * mySize_y;
3818 pa = p - eY * 0.25 * mySize_y;
3820 kh_size_x = mySize_x * 0.25;
3821 kh_size_y = 0.75 * mySize_y;
3822 kh_asize_x = mySize_x * 0.25;
3823 kh_asize_y = mySize_y * 0.25;
3827 p_y = pos_y + 0.125 * mySize_y;
3828 pa = p - eY * 0.125 * mySize_y;
3830 kh_size_x = mySize_x * 0.5;
3831 kh_size_y = 0.375 * mySize_y;
3832 kh_asize_x = mySize_x * 0.5;
3833 kh_asize_y = mySize_y * 0.125;
3840 for(i = 0; i < 4; ++i)
3842 key = floor(kh_keys / pow(32, i)) & 31;
3844 if(keyteam == 30 && keycount <= 4)
3846 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3850 // this yields 8 exactly if "RUN HERE" shows
3855 kh_runheretime = time;
3856 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3861 for(i = 0; i < 4; ++i)
3863 key = floor(kh_keys / pow(32, i)) & 31;
3876 default: // owned or dropped
3881 a = a * panel_fg_alpha;
3882 aa = aa * panel_fg_alpha;
3888 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3891 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3894 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3897 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3902 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3905 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3908 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3911 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3914 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3918 if(mySize_x > mySize_y)
3920 p_x += 0.25 * mySize_x;
3921 pa_x += 0.25 * mySize_x;
3927 p_y = pos_y + 0.625 * mySize_y;
3928 pa_y = pos_y + 0.5 * mySize_y;
3934 p_x += 0.5 * mySize_x;
3935 pa_x += 0.5 * mySize_x;
3941 // Nexball HUD mod icon
3942 void HUD_Mod_NexBall(vector pos, vector mySize)
3944 float stat_items, nb_pb_starttime, dt, p;
3946 stat_items = getstati(STAT_ITEMS);
3947 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3949 if (stat_items & IT_KEY1)
3954 //Manage the progress bar if any
3955 if (nb_pb_starttime > 0)
3957 dt = mod(time - nb_pb_starttime, nb_pb_period);
3958 // one period of positive triangle
3959 p = 2 * dt / nb_pb_period;
3966 if(mySize_x > mySize_y)
3968 barsize = eX * p * mySize_x + eY * mySize_y;
3973 barsize = eX * mySize_x + eY * p * mySize_y;
3976 HUD_Panel_GetProgressBarColor("nexball")
3977 HUD_Panel_DrawProgressBar(pos, vertical, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3980 if (stat_items & IT_KEY1)
3981 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3984 // Race/CTS HUD mod icons
3985 float crecordtime_prev; // last remembered crecordtime
3986 float crecordtime_change_time; // time when crecordtime last changed
3987 float srecordtime_prev; // last remembered srecordtime
3988 float srecordtime_change_time; // time when srecordtime last changed
3990 float race_status_time;
3991 float race_status_prev;
3992 string race_status_name_prev;
3993 void HUD_Mod_Race(vector pos, vector mySize)
3995 mod_active = 1; // race should never hide the mod icons panel
3997 me = playerslots[player_localentnum - 1];
3999 float f; // yet another function has this
4000 score = me.(scores[ps_primary]);
4002 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
4003 return; // no records in the actual race
4005 drawfont = hud_bigfont;
4007 // clientside personal record
4009 if(gametype == GAME_CTS)
4013 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4015 if(score && (score < t || !t)) {
4016 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4017 if(cvar("cl_autodemo_delete_keeprecords"))
4019 f = cvar("cl_autodemo_delete");
4021 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4025 if(t != crecordtime_prev) {
4026 crecordtime_prev = t;
4027 crecordtime_change_time = time;
4029 f = time - crecordtime_change_time;
4032 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);
4033 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);
4035 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);
4036 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);
4037 //drawstring_expanding(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4038 //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);
4042 t = race_server_record;
4043 if(t != srecordtime_prev) {
4044 srecordtime_prev = t;
4045 srecordtime_change_time = time;
4047 f = time - srecordtime_change_time;
4050 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);
4051 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);
4053 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);
4054 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);
4055 //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);
4056 //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);
4059 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4060 race_status_time = time + 5;
4061 race_status_prev = race_status;
4062 if (race_status_name_prev)
4063 strunzone(race_status_name_prev);
4064 race_status_name_prev = strzone(race_status_name);
4067 pos_x += mySize_x/2;
4070 a = bound(0, race_status_time - time, 1);
4073 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4077 rank = race_CheckName(race_status_name);
4079 rankname = race_PlaceName(rank);
4082 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4084 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4086 if(race_status == 0)
4087 drawpic_aspect_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4088 else if(race_status == 1) {
4089 drawpic_aspect_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4090 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4091 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4092 } else if(race_status == 2) {
4093 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4094 drawpic_aspect_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4096 drawpic_aspect_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4097 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4098 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4099 } else if(race_status == 3) {
4100 drawpic_aspect_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4101 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4102 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4105 if (race_status_time - time <= 0) {
4106 race_status_prev = -1;
4108 if(race_status_name)
4109 strunzone(race_status_name);
4110 race_status_name = string_null;
4111 if(race_status_name_prev)
4112 strunzone(race_status_name_prev);
4113 race_status_name_prev = string_null;
4115 drawfont = hud_font;
4118 float mod_prev; // previous state of mod_active to check for a change
4120 float mod_change; // "time" when mod_active changed
4122 void HUD_ModIcons(void)
4124 if(!autocvar_hud_modicons && !autocvar__hud_configure)
4127 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !autocvar__hud_configure)
4130 float id = HUD_PANEL_MODICONS;
4131 HUD_Panel_UpdateCvarsForId(id);
4134 mySize = panel_size;
4136 if(mod_active != mod_prev) {
4138 mod_prev = mod_active;
4141 if(mod_active || autocvar__hud_configure)
4142 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4144 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4147 HUD_Panel_DrawBg(mod_alpha);
4149 if(panel_bg_padding)
4151 pos += '1 1 0' * panel_bg_padding;
4152 mySize -= '2 2 0' * panel_bg_padding;
4155 // these MUST be ran in order to update mod_active
4156 if(gametype == GAME_KEYHUNT)
4157 HUD_Mod_KH(pos, mySize);
4158 else if(gametype == GAME_CTF || autocvar__hud_configure)
4159 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4160 else if(gametype == GAME_NEXBALL)
4161 HUD_Mod_NexBall(pos, mySize);
4162 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4163 HUD_Mod_Race(pos, mySize);
4166 // Draw pressed keys (#11)
4168 void HUD_DrawPressedKeys(void)
4170 if(!autocvar_hud_pressedkeys && !autocvar__hud_configure)
4173 if(!(spectatee_status > 0 || autocvar_hud_pressedkeys >= 2 || autocvar__hud_configure))
4176 float id = HUD_PANEL_PRESSEDKEYS;
4177 HUD_Panel_UpdateCvarsForId(id);
4180 mySize = panel_size;
4182 HUD_Panel_DrawBg(1);
4183 if(panel_bg_padding)
4185 pos += '1 1 0' * panel_bg_padding;
4186 mySize -= '2 2 0' * panel_bg_padding;
4189 // always force 2:1 aspect
4191 if(mySize_x/mySize_y > 2)
4193 newSize_x = 2 * mySize_y;
4194 newSize_y = mySize_y;
4196 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4200 newSize_y = 1/2 * mySize_x;
4201 newSize_x = mySize_x;
4203 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4208 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4211 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4212 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4213 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);
4214 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);
4215 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);
4216 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);
4217 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);
4220 // Handle chat as a panel (#12)
4224 if(!autocvar_hud_chat && !autocvar__hud_configure)
4226 cvar_set("con_chatrect", "0");
4230 float id = HUD_PANEL_CHAT;
4231 HUD_Panel_UpdateCvarsForId(id);
4234 mySize = panel_size;
4236 HUD_Panel_DrawBg(1);
4237 if(panel_bg_padding)
4239 pos += '1 1 0' * panel_bg_padding;
4240 mySize -= '2 2 0' * panel_bg_padding;
4243 cvar_set("con_chatrect", "1");
4245 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4246 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4248 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4249 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4251 if(autocvar__hud_configure)
4254 chatsize = cvar("con_chatsize");
4255 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4257 for(i = 0; i < cvar("con_chat"); ++i)
4259 if(i == cvar("con_chat") - 1)
4262 a = panel_fg_alpha * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4263 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);
4268 // Engine info panel (#13)
4275 float frametimeavg1; // 1 frame ago
4276 float frametimeavg2; // 2 frames ago
4277 void HUD_EngineInfo(void)
4279 if(!autocvar_hud_engineinfo && !autocvar__hud_configure)
4282 float id = HUD_PANEL_ENGINEINFO;
4283 HUD_Panel_UpdateCvarsForId(id);
4286 mySize = panel_size;
4288 HUD_Panel_DrawBg(1);
4289 if(panel_bg_padding)
4291 pos += '1 1 0' * panel_bg_padding;
4292 mySize -= '2 2 0' * panel_bg_padding;
4295 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4297 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4298 frametimeavg2 = frametimeavg1;
4299 frametimeavg1 = frametimeavg;
4302 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4303 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.
4305 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
4306 prevfps = (1/frametime);
4307 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"
4313 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4315 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4317 prevfps_time = time;
4322 color = HUD_Get_Num_Color (prevfps, 100);
4323 drawfont = hud_bigfont;
4324 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), mySize, mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4325 drawfont = hud_font;
4328 // Info messages panel (#14)
4330 void HUD_InfoMessages(void)
4332 if(!autocvar_hud_infomessages && !autocvar__hud_configure)
4335 float id = HUD_PANEL_INFOMESSAGES;
4336 HUD_Panel_UpdateCvarsForId(id);
4339 mySize = panel_size;
4341 HUD_Panel_DrawBg(1);
4342 if(panel_bg_padding)
4344 pos += '1 1 0' * panel_bg_padding;
4345 mySize -= '2 2 0' * panel_bg_padding;
4348 // always force 6:1 aspect
4350 if(mySize_x/mySize_y > 6)
4352 newSize_x = 6 * mySize_y;
4353 newSize_y = mySize_y;
4355 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4359 newSize_y = 1/6 * mySize_x;
4360 newSize_x = mySize_x;
4362 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4371 fontsize = '0.25 0.25 0' * mySize_y;
4374 if(!autocvar__hud_configure)
4376 if(spectatee_status && !intermission)
4378 //drawfont = hud_bigfont;
4379 if(spectatee_status == -1)
4382 s = GetPlayerName(spectatee_status - 1);
4384 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
4385 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, panel_fg_alpha, DRAWFLAG_NORMAL);
4386 //drawfont = hud_font;
4388 // spectator text in the upper right corner
4389 if(spectatee_status == -1)
4390 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
4392 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
4393 if(autocvar_hud_infomessages_flip)
4394 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4395 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4396 o += eY * fontsize_y;
4398 if(spectatee_status == -1)
4399 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
4401 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
4402 if(autocvar_hud_infomessages_flip)
4403 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4404 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4405 o += eY * fontsize_y;
4407 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
4408 if(autocvar_hud_infomessages_flip)
4409 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4410 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4411 o += eY * fontsize_y;
4413 if(gametype == GAME_ARENA)
4414 s = "^1Wait for your turn to join";
4415 else if(gametype == GAME_LMS)
4418 sk = playerslots[player_localentnum - 1];
4419 if(sk.(scores[ps_primary]) >= 666)
4420 s = "^1Match has already begun";
4421 else if(sk.(scores[ps_primary]) > 0)
4422 s = "^1You have no more lives left";
4424 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4427 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
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;
4433 //show restart countdown:
4434 if (time < getstatf(STAT_GAMESTARTTIME)) {
4436 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4437 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4438 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
4439 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4440 o += eY * fontsize_y;
4443 if(warmup_stage && !intermission)
4445 s = "^2Currently in ^1warmup^2 stage!";
4446 if(autocvar_hud_infomessages_flip)
4447 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4448 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4449 o += eY * fontsize_y;
4453 if(mod(time, 1) >= 0.5)
4458 if(ready_waiting && !intermission && !spectatee_status)
4460 if(ready_waiting_for_me)
4463 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
4465 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
4470 s = strcat("^2Waiting for others to ready up to end warmup...");
4472 s = strcat("^2Waiting for others to ready up...");
4474 if(autocvar_hud_infomessages_flip)
4475 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4476 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4477 o += eY * fontsize_y;
4479 else if(warmup_stage && !intermission && !spectatee_status)
4481 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
4482 if(autocvar_hud_infomessages_flip)
4483 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4484 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4485 o += eY * fontsize_y;
4488 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4490 float ts_min, ts_max;
4491 tm = teams.sort_next;
4494 for(; tm.sort_next; tm = tm.sort_next)
4496 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4498 if(!ts_min) ts_min = tm.team_size;
4499 else ts_min = min(ts_min, tm.team_size);
4500 if(!ts_max) ts_max = tm.team_size;
4501 else ts_max = max(ts_max, tm.team_size);
4503 if ((ts_max - ts_min) > 1)
4505 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
4506 tm = GetTeam(myteam, false);
4508 if (tm.team != COLOR_SPECTATOR)
4509 if (tm.team_size == ts_max)
4510 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
4512 if(autocvar_hud_infomessages_flip)
4513 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4514 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4515 o += eY * fontsize_y;
4522 s = "^7Press ^3ESC ^7to show HUD options.";
4523 if(autocvar_hud_infomessages_flip)
4524 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4525 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4526 o += eY * fontsize_y;
4527 s = "^3Doubleclick ^7a panel for panel-specific options.";
4528 if(autocvar_hud_infomessages_flip)
4529 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4530 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4531 o += eY * fontsize_y;
4532 s = "^3CTRL ^7to disable collision testing, ^3SHIFT ^7and";
4533 if(autocvar_hud_infomessages_flip)
4534 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4535 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4536 o += eY * fontsize_y;
4537 s = "^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.";
4538 if(autocvar_hud_infomessages_flip)
4539 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4540 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4541 o += eY * fontsize_y;
4551 void HUD_ShowSpeed(void)
4554 float pos, conversion_factor;
4555 string speed, zspeed, unit;
4557 switch(cvar("cl_showspeed_unit"))
4562 conversion_factor = 1.0;
4566 conversion_factor = 1.0;
4570 conversion_factor = 0.0254;
4574 conversion_factor = 0.0254 * 3.6;
4578 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4582 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4586 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4588 numsize_x = numsize_y = cvar("cl_showspeed_size");
4589 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4591 drawfont = hud_bigfont;
4592 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4594 if (cvar("cl_showspeed_z") == 1) {
4595 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4596 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4599 drawfont = hud_font;
4602 vector acc_prevspeed;
4606 void HUD_ShowAcceleration(void)
4608 float acceleration, sz, scale, alpha, f;
4609 vector pos, top, rgb;
4610 top_x = vid_conwidth/2;
4613 f = time - acc_prevtime;
4614 if(cvar("cl_showacceleration_z"))
4615 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4617 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4618 acc_prevspeed = pmove_vel;
4619 acc_prevtime = time;
4621 f = bound(0, f * 10, 1);
4622 acc_avg = acc_avg * (1 - f) + acceleration * f;
4623 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4625 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4627 sz = cvar("cl_showacceleration_size");
4628 scale = cvar("cl_showacceleration_scale");
4629 alpha = cvar("cl_showacceleration_alpha");
4630 if (cvar("cl_showacceleration_color_custom"))
4631 rgb = stov(cvar_string("cl_showacceleration_color"));
4634 if (acceleration < 0) {
4635 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4636 } else if (acceleration > 0) {
4637 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4641 if (acceleration > 0)
4642 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4643 else if (acceleration < 0)
4644 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4647 void HUD_Reset (void)
4649 // reset gametype specific icons
4650 if(gametype == GAME_KEYHUNT)
4652 else if(gametype == GAME_CTF)
4653 HUD_Mod_CTF_Reset();
4656 #define HUD_DrawPanel(id)\
4658 case (HUD_PANEL_RADAR):\
4659 HUD_Radar(); break;\
4660 case (HUD_PANEL_WEAPONICONS):\
4661 HUD_WeaponIcons(); break;\
4662 case (HUD_PANEL_INVENTORY):\
4663 HUD_Inventory(); break;\
4664 case (HUD_PANEL_POWERUPS):\
4665 HUD_Powerups(); break;\
4666 case (HUD_PANEL_HEALTHARMOR):\
4667 HUD_HealthArmor(); break;\
4668 case (HUD_PANEL_NOTIFY):\
4669 HUD_Notify(); break;\
4670 case (HUD_PANEL_TIMER):\
4671 HUD_Timer(); break;\
4672 case (HUD_PANEL_SCORE):\
4673 HUD_Score(); break;\
4674 case (HUD_PANEL_RACETIMER):\
4675 HUD_RaceTimer(); break;\
4676 case (HUD_PANEL_VOTE):\
4677 HUD_VoteWindow(); break;\
4678 case (HUD_PANEL_MODICONS):\
4679 HUD_ModIcons(); break;\
4680 case (HUD_PANEL_PRESSEDKEYS):\
4681 HUD_DrawPressedKeys(); break;\
4682 case (HUD_PANEL_CHAT):\
4684 case (HUD_PANEL_ENGINEINFO):\
4685 HUD_EngineInfo(); break;\
4686 case (HUD_PANEL_INFOMESSAGES):\
4687 HUD_InfoMessages(); break;\
4690 void HUD_Main (void)
4692 hud_skin_path = strcat("gfx/hud/", autocvar_hud_skin);
4694 if(disable_menu_alphacheck == 1)
4695 menu_fade_alpha = 1;
4697 menu_fade_alpha = (1 - autocvar__menu_alpha);
4698 hud_fg_alpha = cvar("hud_fg_alpha");
4700 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4701 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4702 hud_color_bg_team = cvar("hud_color_bg_team");
4704 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4705 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4709 // HUD configure visible grid
4710 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4714 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2); ++i)
4716 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);
4719 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2); ++i)
4721 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);
4727 if(teamplay && autocvar_hud_dock_color_team) {
4728 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4729 color = colormapPaletteColor(mod(f, 16), 1) * autocvar_hud_dock_color_team;
4731 else if(autocvar_hud_dock_color == "shirt") {
4732 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4733 color = colormapPaletteColor(floor(f / 16), 0);
4735 else if(autocvar_hud_dock_color == "pants") {
4736 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4737 color = colormapPaletteColor(mod(f, 16), 1);
4740 color = stov(autocvar_hud_dock_color);
4743 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4746 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4747 if(precache_pic(pic) == "") {
4748 pic = "gfx/hud/default/dock";
4750 drawpic('0 0 0', pic, eX * vid_conwidth + eY * vid_conheight, color, autocvar_hud_dock_alpha * menu_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
4753 // cache the panel order into the panel_order array
4754 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4755 if(hud_panelorder_prev)
4756 strunzone(hud_panelorder_prev);
4757 hud_panelorder_prev = strzone(autocvar__hud_panelorder);
4758 tokenize_console(autocvar__hud_panelorder);
4759 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4760 panel_order[i] = stof(argv(i));
4763 // draw panels in order specified by panel_order array
4764 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
4765 HUD_DrawPanel(panel_order[i]);
4768 // TODO hud_'ify these
4769 if (cvar("cl_showspeed"))
4771 if (cvar("cl_showacceleration"))
4772 HUD_ShowAcceleration();
4774 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)
4775 localcmd("cmd selectteam auto; cmd join\n");
4777 hud_configure_prev = autocvar__hud_configure;
4779 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again
4780 disable_menu_alphacheck = 0;