7 // a border picture is a texture containing nine parts:
8 // 1/4 width: left part
9 // 1/2 width: middle part (stretched)
10 // 1/4 width: right part
12 // 1/4 height: top part
13 // 1/2 height: middle part (stretched)
14 // 1/4 height: bottom part
15 void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize)
17 if (theBorderSize_x <= 0 && theBorderSize_y <= 0) // no border
19 // draw only the central part
20 drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
27 //pic = draw_UseSkinFor(pic);
28 width = eX * theSize_x;
29 height = eY * theSize_y;
30 if(theSize_x <= theBorderSize_x * 2)
32 // not wide enough... draw just left and right then
33 bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
34 if(theSize_y <= theBorderSize_y * 2)
36 // not high enough... draw just corners
37 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
38 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
39 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
40 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
41 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
45 dY = theBorderSize_x * eY;
46 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
47 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
48 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
49 drawsubpic(theOrigin + width * 0.5 + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0' + eX - bW, '0 0.5 0' + bW, theColor, theAlpha, 0);
50 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
51 drawsubpic(theOrigin + width * 0.5 + height - dY, width * 0.5 + dY, pic, '0 0.75 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
56 if(theSize_y <= theBorderSize_y * 2)
58 // not high enough... draw just top and bottom then
59 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
60 dX = theBorderSize_x * eX;
61 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
62 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
63 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
64 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
65 drawsubpic(theOrigin + dX + height * 0.5, width - 2 * dX + height * 0.5, pic, '0.25 0 0' + eY - bH, '0.5 0 0' + bH, theColor, theAlpha, 0);
66 drawsubpic(theOrigin + width - dX + height * 0.5, dX + height * 0.5, pic, '0.75 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
70 dX = theBorderSize_x * eX;
71 dY = theBorderSize_x * eY;
72 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
73 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
74 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
75 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
76 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
77 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
78 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
79 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
80 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
85 // drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
88 #define drawpic_aspect(pos,pic,mySize,color,alpha,drawflag)\
91 imgsize = drawgetimagesize(pic);\
92 imgaspect = imgsize_x/imgsize_y;\
96 if(aspect > imgaspect) {\
97 sz_x = sz_y * imgaspect;\
98 drawpic(pos + eX * (oldsz_x - sz_x) * 0.5, pic, sz, color, alpha, drawflag);\
100 sz_y = sz_x / imgaspect;\
101 drawpic(pos + eY * (oldsz_y - sz_y) * 0.5, pic, sz, color, alpha, drawflag);\
106 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
107 #define drawpic_aspect_skin(pos,pic,sz,color,alpha,drawflag)\
109 pic_path = strcat(hud_skin_path, "/", pic);\
110 if(precache_pic(pic_path) == "") {\
111 drawpic_aspect(pos, strcat("gfx/hud/default/", pic), sz, color, alpha, drawflag);\
113 drawpic_aspect(pos, pic_path, sz, color, alpha, drawflag);\
118 void drawpic_aspect_skin_expanding(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
120 //drawpic_aspect_expanding(pos, strcat("gfx/hud/", autocvar_hud_skin, "/", pic), sz, rgb, alpha, flag, fadelerp);
123 void drawpic_aspect_skin_expanding_two(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
125 //drawpic_aspect_expanding_two(pos, strcat("gfx/hud/", autocvar_hud_skin, "/", pic), sz, rgb, alpha, flag, fadelerp);
128 vector HUD_Get_Num_Color (float x, float maxvalue)
136 else if(x > maxvalue * 0.75) {
137 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
138 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
141 else if(x > maxvalue * 0.5) {
142 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
143 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
144 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
146 else if(x > maxvalue * 0.25) {
149 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
151 else if(x > maxvalue * 0.1) {
153 color_y = (x-20)*90/27/100; // green value between 0 -> 1
154 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
164 float stringwidth_colors(string s, vector theSize)
166 return stringwidth(s, TRUE, theSize);
169 float stringwidth_nocolors(string s, vector theSize)
171 return stringwidth(s, FALSE, theSize);
174 #define CENTERPRINT_MAX_LINES 30
175 string centerprint_messages[CENTERPRINT_MAX_LINES];
176 float centerprint_width[CENTERPRINT_MAX_LINES];
177 vector centerprint_start;
178 float centerprint_expire;
179 float centerprint_num;
180 float centerprint_offset_hint;
181 vector centerprint_fontsize;
183 void centerprint(string strMessage)
185 float i, j, n, hcount;
188 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
190 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
192 if(cvar("scr_centertime") <= 0)
198 // strip trailing newlines
199 j = strlen(strMessage) - 1;
200 while(substring(strMessage, j, 1) == "\n" && j >= 0)
202 strMessage = substring(strMessage, 0, j + 1);
207 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
209 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
211 strMessage = substring(strMessage, j, strlen(strMessage) - j);
212 centerprint_offset_hint = j;
217 // if we get here, we have a message. Initialize its height.
220 n = tokenizebyseparator(strMessage, "\n");
222 for(j = 0; j < n; ++j)
224 getWrappedLine_remaining = argv(j);
225 while(getWrappedLine_remaining)
227 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
228 if(centerprint_messages[i])
229 strunzone(centerprint_messages[i]);
230 centerprint_messages[i] = strzone(s);
231 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
234 // half height for empty lines looks better
240 if(i >= CENTERPRINT_MAX_LINES)
246 h = centerprint_fontsize_y*hcount;
248 havail = vid_conheight;
249 if(cvar("con_chatpos") < 0)
250 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
251 if(havail > vid_conheight - 70)
252 havail = vid_conheight - 70; // avoid overlapping HUD
254 centerprint_start_x = 0;
257 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
259 // here, the centerprint would cover the crosshair. REALLY BAD.
260 forbiddenmin = vid_conheight * 0.5 - h - 16;
261 forbiddenmax = vid_conheight * 0.5 + 16;
263 allowedmin = scoreboard_bottom;
264 allowedmax = havail - h;
265 preferred = (havail - h)/2;
268 // possible orderings (total: 4! / 4 = 6)
269 // allowedmin allowedmax forbiddenmin forbiddenmax
270 // forbiddenmin forbiddenmax allowedmin allowedmax
271 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
273 // forbidden doesn't matter in this case
274 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
276 // allowedmin forbiddenmin allowedmax forbiddenmax
277 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
279 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
281 // allowedmin forbiddenmin forbiddenmax allowedmax
282 else if(allowedmin < forbiddenmin)
284 // make sure the forbidden zone is not covered
285 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
286 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
288 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
290 // forbiddenmin allowedmin allowedmax forbiddenmax
291 else if(allowedmax < forbiddenmax)
293 // it's better to leave the allowed zone (overlap with scoreboard) than
294 // to cover the forbidden zone (crosshair)
295 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
296 centerprint_start_y = forbiddenmax;
298 centerprint_start_y = forbiddenmin;
300 // forbiddenmin allowedmin forbiddenmax allowedmax
303 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
306 centerprint_start_y =
309 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
317 centerprint_expire = time + cvar("scr_centertime");
320 void HUD_DrawCenterPrint (void)
327 //if(time > centerprint_expire)
330 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
331 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
332 //sz = 1.2 / (a + 0.2);
337 pos = centerprint_start;
338 for (i=0; i<centerprint_num; i = i + 1)
340 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
341 ts = centerprint_messages[i];
344 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
345 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
346 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
347 pos_y = pos_y + centerprint_fontsize_y;
350 // half height for empty lines looks better
351 pos_y = pos_y + centerprint_fontsize_y * 0.5;
355 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
357 position_x -= 2 / 3 * strlen(text) * scale_x;
358 drawstring(position, text, scale, rgb, alpha, flag);
361 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
363 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
364 drawstring(position, text, scale, rgb, alpha, flag);
367 // return the string of the given race place
368 string race_PlaceName(float pos) {
376 return strcat(ftos(pos), "th");
379 // return the string of the onscreen race timer
380 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
388 if(histime == 0) // goal hit
392 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
402 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
408 lapstr = strcat(" (-", ftos(lapdelta), "L)");
411 else if(lapdelta < 0)
413 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
417 else if(histime > 0) // anticipation
419 if(mytime >= histime)
420 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
422 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
429 cpname = "Start line";
431 cpname = "Finish line";
433 cpname = strcat("Intermediate ", ftos(cp));
435 cpname = "Finish line";
438 return strcat(col, cpname);
439 else if(hisname == "")
440 return strcat(col, cpname, " (", timestr, ")");
442 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
445 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
446 float race_CheckName(string net_name) {
448 for (i=RANKINGS_CNT-1;i>=0;--i)
449 if(grecordholder[i] == net_name)
461 void HUD_Panel_ExportCfg(string cfgname)
464 fh = fopen(strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg"), FILE_WRITE);
467 fputs(fh, strcat("seta hud_skin \"", autocvar_hud_skin, "\"", "\n"));
468 fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
469 fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
470 fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
471 fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
472 fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
473 fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
474 fputs(fh, strcat("seta hud_fg_alpha \"", cvar_string("hud_fg_alpha"), "\"", "\n"));
477 fputs(fh, strcat("seta hud_dock \"", autocvar_hud_dock, "\"", "\n"));
478 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
479 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
480 fputs(fh, strcat("seta hud_dock_alpha \"", ftos(autocvar_hud_dock_alpha), "\"", "\n"));
483 fputs(fh, strcat("seta hud_progressbar_alpha ", ftos(autocvar_hud_progressbar_alpha), "\n"));
484 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
485 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
486 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
487 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
488 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
489 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
492 // common cvars for all panels
494 for (i = 0; i < HUD_PANEL_NUM; ++i)
497 HUD_Panel_UpdateCvarsForId(i)
499 fputs(fh, strcat("seta hud_", panel_name, " ", ftos(cvar(strcat("hud_", panel_name))), "\n"));
500 fputs(fh, strcat("seta hud_", panel_name, "_pos \"", cvar_string(strcat("hud_", panel_name, "_pos")), "\"", "\n"));
501 fputs(fh, strcat("seta hud_", panel_name, "_size \"", cvar_string(strcat("hud_", panel_name, "_size")), "\"", "\n"));
502 fputs(fh, strcat("seta hud_", panel_name, "_bg \"", cvar_string(strcat("hud_", panel_name, "_bg")), "\"", "\n"));
503 fputs(fh, strcat("seta hud_", panel_name, "_bg_color \"", cvar_string(strcat("hud_", panel_name, "_bg_color")), "\"", "\n"));
504 fputs(fh, strcat("seta hud_", panel_name, "_bg_color_team \"", cvar_string(strcat("hud_", panel_name, "_bg_color_team")), "\"", "\n"));
505 fputs(fh, strcat("seta hud_", panel_name, "_bg_alpha \"", cvar_string(strcat("hud_", panel_name, "_bg_alpha")), "\"", "\n"));
506 fputs(fh, strcat("seta hud_", panel_name, "_bg_border \"", cvar_string(strcat("hud_", panel_name, "_bg_border")), "\"", "\n"));
507 fputs(fh, strcat("seta hud_", panel_name, "_bg_padding \"", cvar_string(strcat("hud_", panel_name, "_bg_padding")), "\"", "\n"));
509 case HUD_PANEL_WEAPONICONS:
510 fputs(fh, strcat("seta hud_", panel_name, "_accuracy_yellow ", ftos(cvar(strcat("hud_", panel_name, "_accuracy_yellow"))), "\n"));
512 case HUD_PANEL_INVENTORY:
513 fputs(fh, strcat("seta hud_", panel_name, "_onlycurrent ", ftos(cvar(strcat("hud_", panel_name, "_onlycurrent"))), "\n"));
514 fputs(fh, strcat("seta hud_", panel_name, "_iconalign ", ftos(cvar(strcat("hud_", panel_name, "_iconalign"))), "\n"));
516 case HUD_PANEL_POWERUPS:
517 fputs(fh, strcat("seta hud_", panel_name, "_flip ", ftos(cvar(strcat("hud_", panel_name, "_flip"))), "\n"));
518 fputs(fh, strcat("seta hud_", panel_name, "_iconalign ", ftos(cvar(strcat("hud_", panel_name, "_iconalign"))), "\n"));
519 fputs(fh, strcat("seta hud_", panel_name, "_baralign ", ftos(cvar(strcat("hud_", panel_name, "_baralign"))), "\n"));
521 case HUD_PANEL_HEALTHARMOR:
522 fputs(fh, strcat("seta hud_", panel_name, "_flip ", ftos(cvar(strcat("hud_", panel_name, "_flip"))), "\n"));
523 fputs(fh, strcat("seta hud_", panel_name, "_iconalign ", ftos(cvar(strcat("hud_", panel_name, "_iconalign"))), "\n"));
524 fputs(fh, strcat("seta hud_", panel_name, "_baralign ", ftos(cvar(strcat("hud_", panel_name, "_baralign"))), "\n"));
526 case HUD_PANEL_NOTIFY:
527 fputs(fh, strcat("seta hud_", panel_name, "_flip ", ftos(cvar(strcat("hud_", panel_name, "_flip"))), "\n"));
528 fputs(fh, strcat("seta hud_", panel_name, "_info_top ", ftos(cvar(strcat("hud_", panel_name, "_info_top"))), "\n"));
530 case HUD_PANEL_RADAR:
531 fputs(fh, strcat("seta hud_", panel_name, "_foreground_alpha ", ftos(cvar(strcat("hud_", panel_name, "_foreground_alpha"))), "\n"));
534 fputs(fh, strcat("seta hud_", panel_name, "_alreadyvoted_alpha ", ftos(cvar(strcat("hud_", panel_name, "_alreadyvoted_alpha"))), "\n"));
540 print("^2Successfully exported to hud_", autocvar_hud_skin, "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
545 // return smoothly faded size of given panel when a dialog is active
546 vector HUD_Panel_GetMenuSize(float id)
551 mySize = eX * mySize_x * vid_conwidth + eY * mySize_y * vid_conheight;
553 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
555 vector menu_enable_maxsize, menu_enable_size;
556 menu_enable_maxsize = '0 0 0'; // shut up FTEQCC
557 menu_enable_maxsize_x = 0.3 * vid_conwidth;
558 menu_enable_maxsize_y = 0.18 * vid_conheight;
559 if(mySize_x > mySize_y)
561 if(mySize_y > menu_enable_maxsize_y)
563 menu_enable_size_y = menu_enable_maxsize_y;
564 menu_enable_size_x = mySize_x * (menu_enable_maxsize_y/mySize_y);
565 mySize = (1 - autocvar__menu_alpha) * mySize + (autocvar__menu_alpha) * menu_enable_size;
570 if(mySize_x > menu_enable_maxsize_x)
572 menu_enable_size_x = menu_enable_maxsize_x;
573 menu_enable_size_y = mySize_y * (menu_enable_maxsize_x/mySize_x);
574 mySize = (1 - autocvar__menu_alpha) * mySize + (autocvar__menu_alpha) * menu_enable_size;
581 // return smoothly faded pos of given panel when a dialog is active
582 vector HUD_Panel_GetMenuPos(float id)
587 pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
589 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
591 vector mySize, menu_enable_panelpos;
592 mySize = HUD_Panel_GetMenuSize(id);
593 if(mySize_x > mySize_y)
594 menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * mySize_x + eY * 0.82 * vid_conheight;
596 menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * mySize_y + eX * 0.7 * vid_conwidth;
597 pos = (1 - autocvar__menu_alpha) * pos + (autocvar__menu_alpha) * menu_enable_panelpos;
602 const float hlBorderSize = 4;
603 const string hlBorder = "gfx/hud/default/border_highlighted";
604 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
605 void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
607 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
608 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);
609 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);
610 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);
611 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);
614 // draw the background/borders
615 #define HUD_Panel_DrawBg(alpha)\
617 draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, strcat(hud_skin_path, "/", panel_bg), panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));\
618 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
619 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);
621 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
627 pic = strcat(hud_skin_path, "/");
629 drawsubpic(pos, eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, strcat(pic, "statusbar_vertical"), '0 0 0', '1 0.25 0', color, alpha, drawflag);
630 if(mySize_y/mySize_x > 2)
631 drawsubpic(pos + eY * mySize_x, eY * (mySize_y - 2 * mySize_x) + eX * mySize_x, strcat(pic, "statusbar_vertical"), '0 0.25 0', '1 0.5 0', color, alpha, drawflag);
632 drawsubpic(pos + eY * mySize_y - eY * min(mySize_y * 0.5, mySize_x), eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, strcat(pic, "statusbar_vertical"), '0 0.75 0', '1 0.25 0', color, alpha, drawflag);
634 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, strcat(pic, "statusbar"), '0 0 0', '0.25 1 0', color, alpha, drawflag);
635 if(mySize_x/mySize_y > 2)
636 drawsubpic(pos + eX * mySize_y, eX * (mySize_x - 2 * mySize_y) + eY * mySize_y, strcat(pic, "statusbar"), '0.25 0 0', '0.5 1 0', color, alpha, drawflag);
637 drawsubpic(pos + eX * mySize_x - eX * min(mySize_x * 0.5, mySize_y), eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, strcat(pic, "statusbar"), '0.75 0 0', '0.25 1 0', color, alpha, drawflag);
641 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
642 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
653 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
654 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
656 for (i = 0; i < HUD_PANEL_NUM; ++i) {
657 if(i == highlightedPanel || !panel_enabled)
660 HUD_Panel_UpdatePosSizeForId(i)
662 panel_pos -= '1 1 0' * panel_bg_border;
663 panel_size += '2 2 0' * panel_bg_border;
665 if(myPos_y + mySize_y < panel_pos_y)
667 if(myPos_y > panel_pos_y + panel_size_y)
670 if(myPos_x + mySize_x < panel_pos_x)
672 if(myPos_x > panel_pos_x + panel_size_x)
675 // OK, there IS a collision.
677 myCenter_x = myPos_x + 0.5 * mySize_x;
678 myCenter_y = myPos_y + 0.5 * mySize_y;
680 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
681 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
683 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
685 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
686 myTarget_x = panel_pos_x - mySize_x;
687 else // push it upwards
688 myTarget_y = panel_pos_y - mySize_y;
690 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
692 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
693 myTarget_x = panel_pos_x + panel_size_x;
694 else // push it upwards
695 myTarget_y = panel_pos_y - mySize_y;
697 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
699 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
700 myTarget_x = panel_pos_x - mySize_x;
701 else // push it downwards
702 myTarget_y = panel_pos_y + panel_size_y;
704 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
706 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
707 myTarget_x = panel_pos_x + panel_size_x;
708 else // push it downwards
709 myTarget_y = panel_pos_y + panel_size_y;
711 if(cvar("hud_configure_checkcollisions_debug"))
712 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
718 void HUD_Panel_SetPos(vector pos)
720 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
724 if(cvar("hud_configure_checkcollisions_debug"))
725 drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
727 if(autocvar_hud_configure_grid)
729 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;
730 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;
733 if(hud_configure_checkcollisions)
734 pos = HUD_Panel_CheckMove(pos, mySize);
736 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
737 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
740 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
742 HUD_Panel_GetName(highlightedPanel);
743 cvar_set(strcat("hud_", panel_name, "_pos"), s);
746 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
747 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
757 ratio = mySize_x/mySize_y;
759 for (i = 0; i < HUD_PANEL_NUM; ++i) {
760 if(i == highlightedPanel || !panel_enabled)
763 HUD_Panel_UpdatePosSizeForId(i)
765 panel_pos -= '1 1 0' * panel_bg_border;
766 panel_size += '2 2 0' * panel_bg_border;
768 targEndPos = panel_pos + panel_size;
770 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
771 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
774 if (resizeCorner == 1)
776 // check if this panel is on our way
777 if (resizeorigin_x <= panel_pos_x)
779 if (resizeorigin_y <= panel_pos_y)
781 if (targEndPos_x <= resizeorigin_x - mySize_x)
783 if (targEndPos_y <= resizeorigin_y - mySize_y)
786 // there is a collision:
787 // detect which side of the panel we are facing is actually limiting the resizing
788 // (which side the resize direction finds for first) and reduce the size up to there
790 // dist is the distance between resizeorigin and the "analogous" point of the panel
791 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
792 dist_x = resizeorigin_x - targEndPos_x;
793 dist_y = resizeorigin_y - targEndPos_y;
794 if (dist_y <= 0 || dist_x / dist_y > ratio)
795 mySize_x = min(mySize_x, dist_x);
797 mySize_y = min(mySize_y, dist_y);
799 else if (resizeCorner == 2)
801 if (resizeorigin_x >= targEndPos_x)
803 if (resizeorigin_y <= panel_pos_y)
805 if (panel_pos_x >= resizeorigin_x + mySize_x)
807 if (targEndPos_y <= resizeorigin_y - mySize_y)
810 dist_x = panel_pos_x - resizeorigin_x;
811 dist_y = resizeorigin_y - targEndPos_y;
812 if (dist_y <= 0 || dist_x / dist_y > ratio)
813 mySize_x = min(mySize_x, dist_x);
815 mySize_y = min(mySize_y, dist_y);
817 else if (resizeCorner == 3)
819 if (resizeorigin_x <= panel_pos_x)
821 if (resizeorigin_y >= targEndPos_y)
823 if (targEndPos_x <= resizeorigin_x - mySize_x)
825 if (panel_pos_y >= resizeorigin_y + mySize_y)
828 dist_x = resizeorigin_x - targEndPos_x;
829 dist_y = panel_pos_y - resizeorigin_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 == 4)
837 if (resizeorigin_x >= targEndPos_x)
839 if (resizeorigin_y >= targEndPos_y)
841 if (panel_pos_x >= resizeorigin_x + mySize_x)
843 if (panel_pos_y >= resizeorigin_y + mySize_y)
846 dist_x = panel_pos_x - resizeorigin_x;
847 dist_y = panel_pos_y - resizeorigin_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 if(cvar("hud_configure_checkcollisions_debug"))
854 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
860 void HUD_Panel_SetPosSize(vector mySize)
862 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
864 resizeorigin = panel_click_resizeorigin;
867 // minimum panel size cap
868 mySize_x = max(0.025 * vid_conwidth, mySize_x);
869 mySize_y = max(0.025 * vid_conheight, mySize_y);
871 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.
873 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
874 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
877 // collision testing|
878 // -----------------+
880 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
881 if(resizeCorner == 1) {
882 myPos_x = resizeorigin_x - mySize_x;
883 myPos_y = resizeorigin_y - mySize_y;
884 } else if(resizeCorner == 2) {
885 myPos_x = resizeorigin_x;
886 myPos_y = resizeorigin_y - mySize_y;
887 } else if(resizeCorner == 3) {
888 myPos_x = resizeorigin_x - mySize_x;
889 myPos_y = resizeorigin_y;
890 } else { // resizeCorner == 4
891 myPos_x = resizeorigin_x;
892 myPos_y = resizeorigin_y;
895 // left/top screen edges
897 mySize_x = mySize_x + myPos_x;
899 mySize_y = mySize_y + myPos_y;
901 // bottom/right screen edges
902 if(myPos_x + mySize_x > vid_conwidth)
903 mySize_x = vid_conwidth - myPos_x;
904 if(myPos_y + mySize_y > vid_conheight)
905 mySize_y = vid_conheight - myPos_y;
907 if(cvar("hud_configure_checkcollisions_debug"))
908 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
910 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
911 if(autocvar_hud_configure_grid)
913 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;
914 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;
917 if(hud_configure_checkcollisions)
918 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
920 // 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)
921 mySize_x = max(0.025 * vid_conwidth, mySize_x);
922 mySize_y = max(0.025 * vid_conheight, mySize_y);
924 // do another pos check, as size might have changed by now
925 if(resizeCorner == 1) {
926 myPos_x = resizeorigin_x - mySize_x;
927 myPos_y = resizeorigin_y - mySize_y;
928 } else if(resizeCorner == 2) {
929 myPos_x = resizeorigin_x;
930 myPos_y = resizeorigin_y - mySize_y;
931 } else if(resizeCorner == 3) {
932 myPos_x = resizeorigin_x - mySize_x;
933 myPos_y = resizeorigin_y;
934 } else { // resizeCorner == 4
935 myPos_x = resizeorigin_x;
936 myPos_y = resizeorigin_y;
939 if(cvar("hud_configure_checkcollisions_debug"))
940 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
942 HUD_Panel_GetName(highlightedPanel);
944 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
945 cvar_set(strcat("hud_", panel_name, "_size"), s);
947 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
948 cvar_set(strcat("hud_", panel_name, "_pos"), s);
952 float prevMouseClicked; // previous state
953 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
954 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
957 float menu_enabled_time;
958 float pressed_key_time;
959 void HUD_Panel_Arrow_Action(float nPrimary)
961 if (highlightedPanel_prev == -1 || mouseClicked)
964 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
967 if(autocvar_hud_configure_grid)
969 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
971 if (hudShiftState & S_SHIFT)
972 step = bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
974 step = 2 * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
978 if (hudShiftState & S_SHIFT)
979 step = bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
981 step = 2 * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
986 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
987 step = vid_conheight;
990 if (hudShiftState & S_SHIFT)
991 step = (step / 256); // more precision
993 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
996 highlightedPanel = highlightedPanel_prev;
998 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
1000 if (hudShiftState & S_ALT) // resize
1002 highlightedAction = 1;
1003 if(nPrimary == K_UPARROW)
1005 else if(nPrimary == K_RIGHTARROW)
1007 else if(nPrimary == K_LEFTARROW)
1009 else // if(nPrimary == K_DOWNARROW)
1012 // ctrl+arrow reduces the size, instead of increasing it
1013 // Note that ctrl disables collisions check too, but it's fine
1014 // since we don't collide with anything reducing the size
1015 if (hudShiftState & S_CTRL) {
1017 resizeCorner = 5 - resizeCorner;
1021 mySize = panel_size;
1022 panel_click_resizeorigin = panel_pos;
1023 if(resizeCorner == 1) {
1024 panel_click_resizeorigin += mySize;
1026 } else if(resizeCorner == 2) {
1027 panel_click_resizeorigin_y += mySize_y;
1029 } else if(resizeCorner == 3) {
1030 panel_click_resizeorigin_x += mySize_x;
1032 } else { // resizeCorner == 4
1035 HUD_Panel_SetPosSize(mySize);
1039 highlightedAction = 2;
1042 if(nPrimary == K_UPARROW)
1044 else if(nPrimary == K_DOWNARROW)
1046 else if(nPrimary == K_LEFTARROW)
1048 else // if(nPrimary == K_RIGHTARROW)
1051 HUD_Panel_SetPos(pos);
1055 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1057 if(!autocvar__hud_configure)
1060 // allow console bind to work
1063 con_keys = findkeysforcommand("toggleconsole");
1064 keys = tokenize(con_keys);
1066 float hit_con_bind, i;
1067 for (i = 0; i < keys; ++i)
1069 if(nPrimary == stof(argv(i)))
1073 if(bInputType == 0) {
1074 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1075 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1076 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1078 else if(bInputType == 1) {
1079 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1080 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1081 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1084 if(nPrimary == K_MOUSE1)
1086 if(bInputType == 0) { // key pressed
1090 else if(bInputType == 1) {// key released
1095 else if(nPrimary == K_ESCAPE)
1097 if (bInputType == 1)
1099 disable_menu_alphacheck = 1;
1101 menu_enabled_time = time;
1102 localcmd("menu_showhudexit\n");
1104 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1106 if (bInputType == 1)
1108 pressed_key_time = 0;
1111 else if (pressed_key_time == 0)
1112 pressed_key_time = time;
1114 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1116 else if(hit_con_bind)
1119 return true; // Suppress ALL other input
1122 float HUD_Panel_HighlightCheck()
1128 for(i = 0; i < HUD_PANEL_NUM; ++i)
1130 HUD_Panel_UpdatePosSizeForId(i)
1132 panelPos = panel_pos;
1133 panelSize = panel_size;
1134 border = 10; // FORCED border so a small border size doesn't mean you can't resize
1137 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1141 // resize from topleft border
1142 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)
1146 // resize from topright border
1147 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)
1151 // resize from bottomleft border
1152 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)
1156 // resize from bottomright border
1157 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)
1165 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1166 void HUD_Panel_FirstInDrawQ(float id)
1170 // find out where in the array our current id is, save into place
1171 for(i = 0; i < HUD_PANEL_NUM; ++i)
1173 if(panel_order[i] == id)
1180 // move all ids up by one step in the array until "place"
1181 for(i = place; i > 0; --i)
1183 panel_order[i] = panel_order[i-1];
1185 // now save the new top id
1186 panel_order[0] = id;
1188 // let's save them into the cvar by some strcat trickery
1190 for(i = 0; i < HUD_PANEL_NUM; ++i)
1192 s = strcat(s, ftos(panel_order[i]), " ");
1194 cvar_set("_hud_panelorder", s);
1195 if(hud_panelorder_prev)
1196 strunzone(hud_panelorder_prev);
1197 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1200 void HUD_Panel_Highlight()
1206 while(j <= HUD_PANEL_NUM)
1211 HUD_Panel_UpdatePosSizeForId(i)
1213 panelPos = panel_pos;
1214 panelSize = panel_size;
1215 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1218 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1220 highlightedPanel = i;
1221 HUD_Panel_FirstInDrawQ(i);
1222 highlightedAction = 1;
1223 panel_click_distance = mousepos - panelPos;
1226 // resize from topleft border
1227 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)
1229 highlightedPanel = i;
1230 HUD_Panel_FirstInDrawQ(i);
1231 highlightedAction = 2;
1233 panel_click_distance = mousepos - panelPos;
1234 panel_click_resizeorigin = panelPos + panelSize;
1237 // resize from topright border
1238 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)
1240 highlightedPanel = i;
1241 HUD_Panel_FirstInDrawQ(i);
1242 highlightedAction = 2;
1244 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1245 panel_click_distance_y = mousepos_y - panelPos_y;
1246 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1249 // resize from bottomleft border
1250 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)
1252 highlightedPanel = i;
1253 HUD_Panel_FirstInDrawQ(i);
1254 highlightedAction = 2;
1256 panel_click_distance_x = mousepos_x - panelPos_x;
1257 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1258 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1261 // resize from bottomright border
1262 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)
1264 highlightedPanel = i;
1265 HUD_Panel_FirstInDrawQ(i);
1266 highlightedAction = 2;
1268 panel_click_distance = panelSize - mousepos + panelPos;
1269 panel_click_resizeorigin = panelPos;
1274 highlightedPanel_prev = -1;
1279 float highlightcheck;
1280 void HUD_Panel_Mouse()
1282 // 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
1283 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1284 disable_menu_alphacheck = 0;
1285 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1289 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1290 print("Highlighted: ", ftos(highlightedPanel), "\n");
1291 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1294 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1295 highlightedPanel = -1;
1296 highlightedAction = 0;
1298 if(highlightedPanel != -1)
1299 highlightedPanel_prev = highlightedPanel;
1301 mousepos = mousepos + getmousepos();
1303 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1304 mousepos_y = bound(0, mousepos_y, vid_conheight);
1308 if(prevMouseClicked == 0)
1309 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1311 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1313 if(highlightedAction == 1)
1314 HUD_Panel_SetPos(mousepos - panel_click_distance);
1315 else if(highlightedAction == 2)
1318 if(resizeCorner == 1) {
1319 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1320 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1321 } else if(resizeCorner == 2) {
1322 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1323 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1324 } else if(resizeCorner == 3) {
1325 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1326 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1327 } else { // resizeCorner == 4
1328 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1329 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1331 HUD_Panel_SetPosSize(mySize);
1334 // doubleclick check
1335 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1337 mouseClicked = 0; // to prevent spam, I guess.
1338 disable_menu_alphacheck = 2;
1340 menu_enabled_time = time;
1341 HUD_Panel_GetName(highlightedPanel)
1342 localcmd("menu_showhudoptions ", panel_name, "\n");
1345 if(prevMouseClicked == 0)
1347 prevMouseClickedTime = time;
1348 prevMouseClickedPos = mousepos;
1353 highlightcheck = HUD_Panel_HighlightCheck();
1355 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1358 cursorsize = '32 32 0';
1360 if(highlightcheck == 0)
1361 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1362 else if(highlightcheck == 1)
1363 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1364 else if(highlightcheck == 2)
1365 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1367 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1369 prevMouseClicked = mouseClicked;
1372 // Weapon icons (#0)
1374 float weaponspace[10];
1375 #define HUD_WeaponIcons_Clear()\
1377 for(idx = 0; idx < 10; ++idx)\
1378 weaponspace[idx] = 0;
1380 entity weaponorder[WEP_MAXCOUNT];
1381 void weaponorder_swap(float i, float j, entity pass)
1385 weaponorder[i] = weaponorder[j];
1389 string weaponorder_cmp_str_save;
1390 string weaponorder_cmp_str;
1391 float weaponorder_cmp(float i, float j, entity pass)
1394 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1395 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1396 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)
1399 void HUD_WeaponIcons(void)
1401 if(!autocvar_hud_weaponicons && !autocvar__hud_configure)
1404 float id = HUD_PANEL_WEAPONICONS;
1405 HUD_Panel_UpdateCvarsForId(id);
1406 float alpha, stat_weapons; // "constants"
1408 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1411 mySize = panel_size;
1413 stat_weapons = getstati(STAT_WEAPONS);
1415 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1417 self = get_weaponinfo(i);
1418 if(self.impulse >= 0)
1422 // TODO make this configurable
1423 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1425 if(weaponorder_cmp_str != weaponorder_cmp_str_save)
1427 if(weaponorder_cmp_str_save)
1428 strunzone(weaponorder_cmp_str_save);
1429 weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
1431 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1433 self = get_weaponinfo(i);
1434 if(self.impulse >= 0)
1436 weaponorder[weapon_cnt] = self;
1440 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1443 HUD_Panel_DrawBg(1);
1444 if(panel_bg_padding)
1446 pos += '1 1 0' * panel_bg_padding;
1447 mySize -= '2 2 0' * panel_bg_padding;
1451 weapon_stats = getstati(STAT_DAMAGE_HITS);
1452 weapon_number = weapon_stats & 63;
1453 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1455 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1456 weapon_number = weapon_stats & 63;
1457 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1459 if(cvar_or("hud_weaponicons_fade", 1))
1461 fade = 3.2 - 2 * (time - weapontime);
1462 fade = bound(0.7, fade, 1);
1467 HUD_WeaponIcons_Clear();
1469 float rows, columns;
1470 rows = mySize_y/mySize_x;
1471 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1472 // ^^^ weapon icon aspect goes here
1474 columns = ceil(WEP_COUNT/rows);
1479 when = autocvar_hud_weaponicons_complainbubble_time;
1481 fadetime = autocvar_hud_weaponicons_complainbubble_fadetime;
1484 for(i = 0; i < weapon_cnt; ++i)
1486 self = weaponorder[i];
1487 weapid = self.impulse;
1489 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1491 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1492 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1494 // draw background behind currently selected weapon
1495 if(self.weapon == activeweapon)
1496 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);
1498 // draw the weapon accuracy on the HUD
1499 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1502 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1504 // yellow_accuracy = value at which accuracy becomes yellow
1505 if(weapon_stats >= 100) {
1509 else if(weapon_stats > autocvar_hud_weaponicons_accuracy_yellow) {
1510 color_x = 1 - (weapon_stats-autocvar_hud_weaponicons_accuracy_yellow)/(100-autocvar_hud_weaponicons_accuracy_yellow); // red value between 1 -> 0
1514 color_y = weapon_stats/autocvar_hud_weaponicons_accuracy_yellow; // green value between 0 -> 1
1518 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);
1521 // draw the weapon icon
1522 if((self.impulse >= 0) && (stat_weapons & self.weapons))
1524 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);
1526 if(autocvar_hud_weaponicons_number == 1) // weapon number
1527 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);
1528 else if(autocvar_hud_weaponicons_number == 2) // bind
1529 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);
1532 // draw a "ghost weapon icon" if you don't have the weapon
1535 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);
1538 // draw the complain message
1539 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_weaponicons_complainbubble)
1543 if(complain_weapon_time + when > time)
1546 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1550 if(complain_weapon_time + when > time)
1556 vector complain_bubble_size = '100 50 0' * bound(0.25, autocvar_hud_weaponicons_complainbubble_size, 2);
1557 drawpic_aspect_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows) - complain_bubble_size + 0.5 * (eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows)), "weapon_complainbubble", complain_bubble_size, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
1560 if(complain_weapon_type == 0) {
1561 s = "Out of ammo for the";
1564 else if(complain_weapon_type == 1) {
1565 s = "You don't have the";
1569 s = "Map doesn't have the";
1572 drawstring_aspect(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows) - complain_bubble_size + eX * 0.05 * complain_bubble_size_x + eY * (1/6) * complain_bubble_size_y + 0.5 * (eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows)), s, eX * 0.9 * complain_bubble_size_x + eY * 0.2 * complain_bubble_size_y, 0.2 * complain_bubble_size_y, color, panel_fg_alpha * a, DRAWFLAG_NORMAL);
1573 drawstring_aspect(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows) - complain_bubble_size + eX * 0.05 * complain_bubble_size_x + eY * (11/30) * complain_bubble_size_y + 0.5 * (eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows)), complain_weapon_name, eX * 0.9 * complain_bubble_size_x + eY * 0.25 * complain_bubble_size_y, 0.25 * complain_bubble_size_y, '1 0 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
1589 float GetAmmoStat(float i)
1593 case 0: return STAT_SHELLS;
1594 case 1: return STAT_NAILS;
1595 case 2: return STAT_ROCKETS;
1596 case 3: return STAT_CELLS;
1597 case 4: return STAT_FUEL;
1602 float GetAmmoItemCode(float i)
1606 case 0: return IT_SHELLS;
1607 case 1: return IT_NAILS;
1608 case 2: return IT_ROCKETS;
1609 case 3: return IT_CELLS;
1610 case 4: return IT_FUEL;
1615 string GetAmmoPicture(float i)
1619 case 0: return "ammo_shells";
1620 case 1: return "ammo_bullets";
1621 case 2: return "ammo_rockets";
1622 case 3: return "ammo_cells";
1623 case 4: return "ammo_fuel";
1628 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1631 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1632 if(autocvar__hud_configure)
1642 if(currently_selected)
1647 vector newSize, newPos;
1648 if(mySize_x/mySize_y > 3)
1650 newSize_x = 3 * mySize_y;
1651 newSize_y = mySize_y;
1653 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1658 newSize_y = 1/3 * mySize_x;
1659 newSize_x = mySize_x;
1661 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1665 vector picpos, numpos;
1666 if(autocvar_hud_inventory_iconalign)
1669 picpos = newPos + eX * 2 * newSize_y;
1673 numpos = newPos + eX * newSize_y;
1677 if (currently_selected)
1678 drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1680 drawfont = hud_bigfont;
1681 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1682 drawfont = hud_font;
1683 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1686 void HUD_Inventory(void)
1688 if(!autocvar_hud_inventory && !autocvar__hud_configure)
1691 float id = HUD_PANEL_INVENTORY;
1692 HUD_Panel_UpdateCvarsForId(id);
1693 float i, currently_selected;
1697 mySize = panel_size;
1699 HUD_Panel_DrawBg(1);
1700 if(panel_bg_padding)
1702 pos += '1 1 0' * panel_bg_padding;
1703 mySize -= '2 2 0' * panel_bg_padding;
1706 float rows, columns;
1707 rows = mySize_y/mySize_x;
1708 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1709 // ^^^ ammo item aspect goes here
1711 columns = ceil(AMMO_COUNT/rows);
1715 for (i = 0; i < AMMO_COUNT; ++i) {
1716 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1717 if(autocvar_hud_inventory_onlycurrent) {
1718 if(autocvar__hud_configure)
1720 if (currently_selected || autocvar__hud_configure)
1721 DrawAmmoItem(pos, mySize, i, currently_selected);
1724 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);
1729 column = column + 1;
1735 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color)
1737 vector newSize, newPos;
1738 if(mySize_x/mySize_y > 3)
1740 newSize_x = 3 * mySize_y;
1741 newSize_y = mySize_y;
1743 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1748 newSize_y = 1/3 * mySize_x;
1749 newSize_x = mySize_x;
1751 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1755 vector picpos, numpos;
1758 if(iconalign == 1 || iconalign == 3) // right align
1761 picpos = newPos + eX * 2 * newSize_y;
1765 numpos = newPos + eX * newSize_y;
1771 if(iconalign == 0 || iconalign == 3) // left align
1773 numpos = newPos + eX * newSize_y;
1779 picpos = newPos + eX * 2 * newSize_y;
1783 drawfont = hud_bigfont;
1784 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, newSize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1785 drawfont = hud_font;
1786 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1791 void HUD_Powerups(void) {
1792 if(!autocvar_hud_powerups && !autocvar__hud_configure)
1795 float id = HUD_PANEL_POWERUPS;
1796 HUD_Panel_UpdateCvarsForId(id);
1798 stat_items = getstati(STAT_ITEMS);
1800 if(!autocvar__hud_configure)
1802 if not(stat_items & IT_STRENGTH)
1803 if not(stat_items & IT_INVINCIBLE)
1806 if (getstati(STAT_HEALTH) <= 0)
1812 mySize = panel_size;
1814 HUD_Panel_DrawBg(1);
1815 if(panel_bg_padding)
1817 pos += '1 1 0' * panel_bg_padding;
1818 mySize -= '2 2 0' * panel_bg_padding;
1821 float strength_time, shield_time;
1823 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1824 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1826 if(autocvar__hud_configure)
1832 vector barpos, barsize;
1836 string leftname, rightname;
1837 float leftcnt, rightcnt;
1838 float leftexact, rightexact;
1839 float leftalpha, rightalpha;
1840 if (autocvar_hud_powerups_flip) {
1841 leftname = "strength";
1842 leftcnt = ceil(strength_time);
1843 leftexact = strength_time;
1845 rightname = "shield";
1846 rightcnt = ceil(shield_time);
1847 rightexact = shield_time;
1849 leftname = "shield";
1850 leftcnt = ceil(shield_time);
1851 leftexact = shield_time;
1853 rightname = "strength";
1854 rightcnt = ceil(strength_time);
1855 rightexact = strength_time;
1857 leftalpha = bound(0, leftexact, 1);
1858 rightalpha = bound(0, rightexact, 1);
1860 drawfont = hud_bigfont;
1861 if (mySize_x/mySize_y > 4)
1865 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1866 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1867 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1868 } else { // left align
1870 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1873 HUD_Panel_GetProgressBarColor(leftname)
1874 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1875 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1');
1878 // 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));
1880 // drawpic_aspect_skin(picpos, leftname, eX * (1/6) * mySize_x + eY * mySize_y, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1885 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1886 barpos = pos + eX * 0.5 * mySize_x;
1887 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1888 } else { // right align
1889 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1890 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1893 HUD_Panel_GetProgressBarColor(rightname)
1894 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1895 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');
1898 else if (mySize_x/mySize_y > 1.5)
1902 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1903 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1904 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1905 } else { // left align
1907 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1910 HUD_Panel_GetProgressBarColor(leftname)
1911 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1912 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1');
1917 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1918 barpos = pos + eY * 0.5 * mySize_y;
1919 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1920 } else { // right align
1921 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1922 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1925 HUD_Panel_GetProgressBarColor(rightname)
1926 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1927 DrawNumIcon(autocvar_hud_powerups_iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1');
1934 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // down align
1935 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1936 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1937 } else { // up align
1939 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1942 if(autocvar_hud_powerups_iconalign == 1 || autocvar_hud_powerups_iconalign == 3) { // down align
1943 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
1944 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
1945 } else { // up align
1946 picpos = pos + eX * 0.05 * mySize_x;
1947 numpos = pos + eY * 0.4 * mySize_x;
1950 HUD_Panel_GetProgressBarColor(leftname)
1951 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1953 //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));
1955 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1956 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);
1961 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // up align
1962 barpos = pos + eX * 0.5 * mySize_x;
1963 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1964 } else { // down align
1965 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1966 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1969 if(autocvar_hud_powerups_iconalign == 0 || autocvar_hud_powerups_iconalign == 3) { // up align
1970 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1971 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1972 } else { // down align
1973 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
1974 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
1977 HUD_Panel_GetProgressBarColor(rightname)
1978 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1980 // 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));
1982 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1983 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);
1986 drawfont = hud_font;
1989 // Health/armor (#3)
1991 void HUD_HealthArmor(void)
1993 if(!autocvar_hud_healtharmor && !autocvar__hud_configure)
1996 float id = HUD_PANEL_HEALTHARMOR;
1997 HUD_Panel_UpdateCvarsForId(id);
2000 mySize = panel_size;
2002 HUD_Panel_DrawBg(1);
2003 if(panel_bg_padding)
2005 pos += '1 1 0' * panel_bg_padding;
2006 mySize -= '2 2 0' * panel_bg_padding;
2009 float armor, health;
2010 armor = getstati(STAT_ARMOR);
2011 health = getstati(STAT_HEALTH);
2014 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
2016 if(autocvar__hud_configure)
2026 vector barpos, barsize;
2030 drawfont = hud_bigfont;
2031 if(autocvar_hud_healtharmor == 2) // combined health and armor display
2034 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2039 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2040 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2041 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2042 } else { // left align
2044 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2048 if(v_z) // NOT fully armored
2050 biggercount = "health";
2051 HUD_Panel_GetProgressBarColor("health")
2052 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2054 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);
2058 biggercount = "armor";
2059 HUD_Panel_GetProgressBarColor("armor")
2060 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2062 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);
2064 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200));
2069 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2070 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2071 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2074 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2076 HUD_Panel_GetProgressBarColor("fuel")
2077 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2082 string leftname, rightname;
2083 float leftcnt, rightcnt;
2084 float leftactive, rightactive;
2085 float leftalpha, rightalpha;
2086 if (autocvar_hud_healtharmor_flip) { // old style layout with armor left/top of health
2091 leftalpha = min((armor+10)/55, 1);
2093 rightname = "health";
2098 leftname = "health";
2103 rightname = "armor";
2107 rightalpha = min((armor+10)/55, 1);
2110 if (mySize_x/mySize_y > 4)
2114 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2115 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2116 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2117 } else { // left align
2119 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2122 HUD_Panel_GetProgressBarColor(leftname)
2123 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2124 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2129 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2130 barpos = pos + eX * 0.5 * mySize_x;
2131 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2132 } else { // right align
2133 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2134 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2137 HUD_Panel_GetProgressBarColor(rightname)
2138 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2139 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));
2144 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2145 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2146 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2149 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2151 HUD_Panel_GetProgressBarColor("fuel")
2152 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2155 else if (mySize_x/mySize_y > 1.5)
2159 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2160 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2161 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2162 } else { // left align
2164 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2167 HUD_Panel_GetProgressBarColor(leftname)
2168 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2169 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2174 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2175 barpos = pos + eY * 0.5 * mySize_y;
2176 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2177 } else { // right align
2178 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2179 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2182 HUD_Panel_GetProgressBarColor(rightname)
2183 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2184 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));
2189 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2190 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2191 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2194 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2196 HUD_Panel_GetProgressBarColor("fuel")
2197 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2204 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // down align
2205 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2206 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2207 } else { // up align
2209 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2212 if(autocvar_hud_healtharmor_iconalign == 1 || autocvar_hud_healtharmor_iconalign == 3) { // down align
2213 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2214 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2215 } else { // up align
2216 picpos = pos + eX * 0.05 * mySize_x;
2217 numpos = pos + eY * 0.4 * mySize_x;
2220 HUD_Panel_GetProgressBarColor(leftname)
2221 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2222 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2223 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);
2228 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // up align
2229 barpos = pos + eX * 0.5 * mySize_x;
2230 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2231 } else { // down align
2232 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2233 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2236 if(autocvar_hud_healtharmor_iconalign == 0 || autocvar_hud_healtharmor_iconalign == 3) { // up align
2237 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2238 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2239 } else { // down align
2240 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2241 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2244 HUD_Panel_GetProgressBarColor(rightname)
2245 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2246 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2247 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);
2252 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2254 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2256 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2257 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2259 HUD_Panel_GetProgressBarColor("fuel")
2260 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2264 drawfont = hud_font;
2268 // Notification area (#4)
2271 string Weapon_SuicideMessage(float deathtype)
2273 w_deathtype = deathtype;
2274 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2275 return w_deathtypestring;
2278 string Weapon_KillMessage(float deathtype)
2280 w_deathtype = deathtype;
2281 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2282 return w_deathtypestring;
2285 float killnotify_times[10];
2286 float killnotify_deathtype[10];
2287 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2288 string killnotify_attackers[10];
2289 string killnotify_victims[10];
2290 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2293 for (i = 9; i > 0; --i) {
2294 killnotify_times[i] = killnotify_times[i-1];
2295 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2296 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2297 if(killnotify_attackers[i])
2298 strunzone(killnotify_attackers[i]);
2299 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2300 if(killnotify_victims[i])
2301 strunzone(killnotify_victims[i]);
2302 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2304 killnotify_times[0] = time;
2305 killnotify_deathtype[0] = wpn;
2306 killnotify_actiontype[0] = actiontype;
2307 if(killnotify_attackers[0])
2308 strunzone(killnotify_attackers[0]);
2309 killnotify_attackers[0] = strzone(attacker);
2310 if(killnotify_victims[0])
2311 strunzone(killnotify_victims[0]);
2312 killnotify_victims[0] = strzone(victim);
2315 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2319 alsoprint = (autocvar_hud_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2321 if(msg == MSG_SUICIDE) {
2323 w = DEATH_WEAPONOF(type);
2325 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2327 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2328 } else if (type == DEATH_KILL) {
2329 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2331 print ("^1",s1, "^1 couldn't take it anymore\n");
2332 } else if (type == DEATH_ROT) {
2333 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2335 print ("^1",s1, "^1 died\n");
2336 } else if (type == DEATH_NOAMMO) {
2337 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2339 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2340 } else if (type == DEATH_CAMP) {
2341 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2343 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2344 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2345 HUD_KillNotify_Push(s1, "", 0, type);
2347 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2348 } else if (type == DEATH_CHEAT) {
2349 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2351 print ("^1",s1, "^1 unfairly eliminated themself\n");
2352 } else if (type == DEATH_FIRE) {
2353 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2355 print ("^1",s1, "^1 burned to death\n");
2356 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2357 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2359 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2362 if (stof(s2) > 2) // killcount > 2
2363 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2364 } else if(msg == MSG_KILL) {
2365 w = DEATH_WEAPONOF(type);
2367 HUD_KillNotify_Push(s2, s1, 1, w);
2369 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2371 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2372 HUD_KillNotify_Push(s1, s2, 1, type);
2375 if(cvar("cl_gentle")) {
2376 print ("^1", s1, "^1 took action against a team mate\n");
2378 print ("^1", s1, "^1 mows down a team mate\n");
2381 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2382 if(cvar("cl_gentle"))
2383 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2385 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2387 else if (stof(s2) > 2) {
2388 if(cvar("cl_gentle"))
2389 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2391 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2394 else if(type == KILL_FIRST_BLOOD)
2395 print("^1",s1, "^1 drew first blood", "\n");
2397 else if (type == DEATH_TELEFRAG)
2398 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2399 else if (type == DEATH_DROWN) {
2400 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2402 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2404 else if (type == DEATH_SLIME) {
2405 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2407 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2409 else if (type == DEATH_LAVA) {
2410 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2412 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2414 else if (type == DEATH_FALL) {
2415 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2417 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2419 else if (type == DEATH_SHOOTING_STAR) {
2420 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2422 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2424 else if (type == DEATH_SWAMP) {
2425 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2427 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2429 else if (type == DEATH_HURTTRIGGER)
2431 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2433 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2434 } else if(type == DEATH_SBCRUSH) {
2435 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2437 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2438 } else if(type == DEATH_SBMINIGUN) {
2439 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2441 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2442 } else if(type == DEATH_SBROCKET) {
2443 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2445 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2446 } else if(type == DEATH_SBBLOWUP) {
2447 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2449 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2450 } else if(type == DEATH_WAKIGUN) {
2451 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2453 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2454 } else if(type == DEATH_WAKIROCKET) {
2455 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2457 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2458 } else if(type == DEATH_WAKIBLOWUP) {
2459 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2461 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2462 } else if(type == DEATH_TURRET) {
2463 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2465 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2466 } else if(type == DEATH_TOUCHEXPLODE) {
2467 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2469 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2470 } else if(type == DEATH_CHEAT) {
2471 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2473 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2474 } else if (type == DEATH_FIRE) {
2475 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2477 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2478 } else if (type == DEATH_CUSTOM) {
2479 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2481 print ("^1",s1, "^1 ", s2, "\n");
2483 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2485 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2487 } else if(msg == MSG_SPREE) {
2488 if(type == KILL_END_SPREE) {
2489 if(cvar("cl_gentle"))
2490 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2492 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2493 } else if(type == KILL_SPREE) {
2494 if(cvar("cl_gentle"))
2495 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2497 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2498 } else if(type == KILL_SPREE_3) {
2499 if(cvar("cl_gentle"))
2500 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2502 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2503 } else if(type == KILL_SPREE_5) {
2504 if(cvar("cl_gentle"))
2505 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2507 print (s1,"^7 unleashes ^1RAGE\n");
2508 } else if(type == KILL_SPREE_10) {
2509 if(cvar("cl_gentle"))
2510 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2512 print (s1,"^7 starts the ^1MASSACRE!\n");
2513 } else if(type == KILL_SPREE_15) {
2514 if(cvar("cl_gentle"))
2515 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2517 print (s1,"^7 executes ^1MAYHEM!\n");
2518 } else if(type == KILL_SPREE_20) {
2519 if(cvar("cl_gentle"))
2520 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2522 print (s1,"^7 is a ^1BERSERKER!\n");
2523 } else if(type == KILL_SPREE_25) {
2524 if(cvar("cl_gentle"))
2525 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2527 print (s1,"^7 inflicts ^1CARNAGE!\n");
2528 } else if(type == KILL_SPREE_30) {
2529 if(cvar("cl_gentle"))
2530 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2532 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2534 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2535 if (type == DEATH_DROWN) {
2536 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2539 if(cvar("cl_gentle"))
2540 print ("^1",s1, "^1 was in the water for too long\n");
2542 print ("^1",s1, "^1 drowned\n");
2544 } else if (type == DEATH_SLIME) {
2545 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2547 print ("^1",s1, "^1 was slimed\n");
2548 } else if (type == DEATH_LAVA) {
2549 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2552 if(cvar("cl_gentle"))
2553 print ("^1",s1, "^1 found a hot place\n");
2555 print ("^1",s1, "^1 turned into hot slag\n");
2557 } else if (type == DEATH_FALL) {
2558 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2561 if(cvar("cl_gentle"))
2562 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2564 print ("^1",s1, "^1 hit the ground with a crunch\n");
2566 } else if (type == DEATH_SHOOTING_STAR) {
2567 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2569 print ("^1",s1, "^1 became a shooting star\n");
2570 } else if (type == DEATH_SWAMP) {
2571 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2574 if(cvar("cl_gentle"))
2575 print ("^1",s1, "^1 discovered a swamp\n");
2577 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2579 } else if(type == DEATH_TURRET) {
2580 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2582 print ("^1",s1, "^1 was mowed down by a turret \n");
2583 } else if (type == DEATH_CUSTOM) {
2584 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2586 print ("^1",s1, "^1 ", s2, "\n");
2587 } else if (type == DEATH_HURTTRIGGER) {
2588 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2590 print ("^1",s1, "^1 was in the wrong place\n");
2591 } else if(type == DEATH_TOUCHEXPLODE) {
2592 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2594 print ("^1",s1, "^1 died in an accident\n");
2595 } else if(type == DEATH_CHEAT) {
2596 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2598 print ("^1",s1, "^1 was unfairly eliminated\n");
2599 } else if(type == DEATH_FIRE) {
2600 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2603 if(cvar("cl_gentle"))
2604 print ("^1",s1, "^1 felt a little hot\n");
2606 print ("^1",s1, "^1 burnt to death\n");
2609 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2612 if(cvar("cl_gentle"))
2613 print ("^1",s1, "^1 needs a restart\n");
2615 print ("^1",s1, "^1 died\n");
2618 } else if(msg == MSG_KILL_ACTION_SPREE) {
2619 if(cvar("cl_gentle"))
2620 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2622 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2623 } else if(msg == MSG_INFO) {
2624 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2625 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2626 print(s1, "^7 got the ", s2, "\n");
2627 } else if(type == INFO_LOSTFLAG) {
2628 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2629 print(s1, "^7 lost the ", s2, "\n");
2630 } else if(type == INFO_PICKUPFLAG) {
2631 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2632 print(s1, "^7 picked up the ", s2, "\n");
2633 } else if(type == INFO_RETURNFLAG) {
2634 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2635 print(s1, "^7 returned the ", s2, "\n");
2640 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2642 void HUD_Centerprint(string s1, string s2, float type, float msg)
2644 if(msg == MSG_SUICIDE) {
2645 if (type == DEATH_TEAMCHANGE) {
2646 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2647 } else if (type == DEATH_AUTOTEAMCHANGE) {
2648 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2649 } else if (type == DEATH_CAMP) {
2650 if(cvar("cl_gentle"))
2651 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2653 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2654 } else if (type == DEATH_NOAMMO) {
2655 if(cvar("cl_gentle"))
2656 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2658 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2659 } else if (type == DEATH_ROT) {
2660 if(cvar("cl_gentle"))
2661 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2663 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2664 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2665 if(cvar("cl_gentle"))
2666 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2668 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2669 } else if (type == DEATH_QUIET) {
2671 } else if (type == DEATH_KILL) {
2672 if(cvar("cl_gentle"))
2673 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2675 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2677 } else if(msg == MSG_KILL) {
2678 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2679 if(cvar("cl_gentle")) {
2680 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2682 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2684 } else if (type == KILL_FIRST_BLOOD) {
2685 if(cvar("cl_gentle")) {
2686 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2688 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2690 } else if (type == KILL_FIRST_VICTIM) {
2691 if(cvar("cl_gentle")) {
2692 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2694 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2696 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2697 if(cvar("cl_gentle")) {
2698 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2700 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2702 } else if (type == KILL_TYPEFRAGGED) {
2703 if(cvar("cl_gentle")) {
2704 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2706 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2708 } else if (type == KILL_FRAG) {
2709 if(cvar("cl_gentle")) {
2710 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2712 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2714 } else if (type == KILL_FRAGGED) {
2715 if(cvar("cl_gentle")) {
2716 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2718 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2721 } else if(msg == MSG_KILL_ACTION) {
2722 // TODO: invent more centerprints here?
2723 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2727 void HUD_Notify (void)
2729 if(!autocvar_hud_notify && !autocvar__hud_configure)
2732 float id = HUD_PANEL_NOTIFY;
2733 HUD_Panel_UpdateCvarsForId(id);
2736 mySize = panel_size;
2738 HUD_Panel_DrawBg(1);
2739 if(panel_bg_padding)
2741 pos += '1 1 0' * panel_bg_padding;
2742 mySize -= '2 2 0' * panel_bg_padding;
2745 float entries, height;
2746 entries = bound(1, floor(14 * mySize_y/mySize_x), 12);
2747 height = mySize_y/entries;
2748 entries -= 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2751 fontsize = '0.5 0.5 0' * height;
2755 when = autocvar_hud_notify_time;
2757 fadetime = autocvar_hud_notify_fadetime;
2761 vector pos_attacker, pos_victim;
2763 float width_attacker, width_victim;
2764 string attacker, victim;
2767 for(j = 0; j < entries; ++j)
2769 if(autocvar_hud_notify_flip)
2771 else // rather nasty hack for ordering items from the bottom up
2772 i = entries - j - 1;
2773 if(autocvar_hud_notify_info_top)
2774 i += 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2778 if(killnotify_times[j] + when > time)
2781 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2785 if(killnotify_times[j] + when > time)
2791 // TODO: maybe print in team colors?
2792 // TODO: maybe this could be cleaned up somehow...
2793 // TODO: less copypaste code below
2796 if(killnotify_actiontype[j] == 0 && !autocvar__hud_configure)
2798 attacker = textShortenToWidth(killnotify_attackers[j], mySize_x - 2 * height, fontsize, stringwidth_colors);
2800 width_attacker = stringwidth(attacker, TRUE, fontsize);
2801 pos_attacker = pos + eX * 0.5 * (mySize_x - width_attacker + 2 * height) + eY * 0.5 * fontsize_y + eY * i * height;
2803 weap_pos = pos + eX * 0.5 * (mySize_x - width_attacker) - eX * height + eY * i * height;
2804 if(killnotify_deathtype[j] == DEATH_GENERIC)
2806 drawpic_aspect_skin(weap_pos, "notify_death", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2807 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2809 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2811 drawpic_aspect_skin(weap_pos, "notify_outofammo", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2812 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2814 else if(killnotify_deathtype[j] == DEATH_KILL)
2816 drawpic_aspect_skin(weap_pos, "notify_selfkill", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2817 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2819 else if(killnotify_deathtype[j] == DEATH_CAMP)
2821 drawpic_aspect_skin(weap_pos, "notify_camping", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2822 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2824 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2826 drawpic_aspect_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2827 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2829 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2831 drawpic_aspect_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2832 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2834 else if(killnotify_deathtype[j] == DEATH_DROWN)
2836 drawpic_aspect_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2837 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2839 else if(killnotify_deathtype[j] == DEATH_SLIME)
2841 drawpic_aspect_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2842 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2844 else if(killnotify_deathtype[j] == DEATH_LAVA)
2846 drawpic_aspect_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2847 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2849 else if(killnotify_deathtype[j] == DEATH_FALL)
2851 drawpic_aspect_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2852 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2854 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2856 drawpic_aspect_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2857 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2859 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2861 drawpic_aspect_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2862 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2864 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2866 if(killnotify_victims[j] == "^1RED^7 flag")
2870 drawpic_aspect_skin(weap_pos, strcat("flag_", s, "_carrying"), '1 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2871 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2873 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2875 if(killnotify_victims[j] == "^1RED^7 flag")
2879 drawpic_aspect_skin(weap_pos, strcat("flag_", s, "_taken"), '1 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2880 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2882 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2884 if(killnotify_victims[j] == "^1RED^7 flag")
2888 drawpic_aspect_skin(weap_pos, strcat("flag_", s, "_lost"), '1 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2889 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2892 // X [did action to] Y
2895 if(autocvar__hud_configure)
2897 attacker = textShortenToWidth("Player1", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2898 victim = textShortenToWidth("Player2", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2899 a = bound(0, (when - j) / 4, 1);
2903 attacker = textShortenToWidth(killnotify_attackers[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2904 victim = textShortenToWidth(killnotify_victims[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2906 width_attacker = stringwidth(attacker, TRUE, fontsize);
2907 width_victim = stringwidth(victim, TRUE, fontsize);
2908 pos_attacker = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_attacker) + eY * 0.5 * fontsize_y + eY * i * height;
2909 pos_victim = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_victim) + eY * 0.5 * fontsize_y + eX * 0.5 * mySize_x + eX * height + eY * i * height;
2910 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2912 if(autocvar__hud_configure) // example actions for config mode
2914 drawpic_aspect_skin(weap_pos, strcat("weapon", "electro"), '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2915 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2916 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2918 else if(WEP_VALID(killnotify_deathtype[j]))
2920 self = get_weaponinfo(killnotify_deathtype[j]);
2921 drawpic_aspect_skin(weap_pos, strcat("weapon", self.netname), '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2922 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2923 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2925 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2927 drawpic_aspect_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2928 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2929 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2931 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2933 drawpic_aspect_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2934 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2935 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2937 else if(killnotify_deathtype[j] == DEATH_DROWN)
2939 drawpic_aspect_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2940 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2941 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2943 else if(killnotify_deathtype[j] == DEATH_SLIME)
2945 drawpic_aspect_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2946 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2947 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2949 else if(killnotify_deathtype[j] == DEATH_LAVA)
2951 drawpic_aspect_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2952 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2953 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2955 else if(killnotify_deathtype[j] == DEATH_FALL)
2957 drawpic_aspect_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2958 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2959 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2961 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2963 drawpic_aspect_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2964 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2965 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2967 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2969 drawpic_aspect_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2970 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2971 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2977 // TODO: separate panel for these?
2983 if(autocvar_hud_notify_info_top)
2986 o = pos + eY * mySize_y - eY * 2 * height;
2988 if(spectatee_status && !intermission)
2990 //drawfont = hud_bigfont;
2991 if(spectatee_status == -1)
2994 s = GetPlayerName(spectatee_status - 1);
2996 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
2997 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, panel_fg_alpha, DRAWFLAG_NORMAL);
2998 //drawfont = hud_font;
3000 // spectator text in the upper right corner
3001 if(spectatee_status == -1)
3002 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
3004 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
3005 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3006 o += eY * fontsize_y;
3008 if(spectatee_status == -1)
3009 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
3011 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
3012 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3013 o += eY * fontsize_y;
3015 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
3016 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3017 o += eY * fontsize_y;
3019 if(gametype == GAME_ARENA)
3020 s = "^1Wait for your turn to join";
3021 else if(gametype == GAME_LMS)
3024 sk = playerslots[player_localentnum - 1];
3025 if(sk.(scores[ps_primary]) >= 666)
3026 s = "^1Match has already begun";
3027 else if(sk.(scores[ps_primary]) > 0)
3028 s = "^1You have no more lives left";
3030 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
3033 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
3034 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3035 o += eY * fontsize_y;
3037 //show restart countdown:
3038 if (time < getstatf(STAT_GAMESTARTTIME)) {
3040 //we need to ceil, otherwise the countdown would be off by .5 when using round()
3041 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
3042 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
3043 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3044 o += eY * fontsize_y;
3047 if(warmup_stage && !intermission)
3049 s = "^2Currently in ^1warmup^2 stage!";
3050 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3051 o += eY * fontsize_y;
3055 if(mod(time, 1) >= 0.5)
3060 if(ready_waiting && !intermission && !spectatee_status)
3062 if(ready_waiting_for_me)
3065 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
3067 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
3072 s = strcat("^2Waiting for others to ready up to end warmup...");
3074 s = strcat("^2Waiting for others to ready up...");
3076 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3077 o += eY * fontsize_y;
3079 else if(warmup_stage && !intermission && !spectatee_status)
3081 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
3082 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3083 o += eY * fontsize_y;
3086 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
3088 float ts_min, ts_max;
3089 tm = teams.sort_next;
3092 for(; tm.sort_next; tm = tm.sort_next)
3094 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
3096 if(!ts_min) ts_min = tm.team_size;
3097 else ts_min = min(ts_min, tm.team_size);
3098 if(!ts_max) ts_max = tm.team_size;
3099 else ts_max = max(ts_max, tm.team_size);
3101 if ((ts_max - ts_min) > 1)
3103 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
3104 tm = GetTeam(myteam, false);
3106 if (tm.team != COLOR_SPECTATOR)
3107 if (tm.team_size == ts_max)
3108 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
3110 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3111 o += eY * fontsize_y;
3115 if(autocvar__hud_configure)
3117 s = "^7Press ^3ESC ^7to show HUD options.";
3118 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3119 o += eY * fontsize_y;
3120 s = "^3Doubleclick a panel for panel-specific options.";
3121 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3122 o += eY * fontsize_y;
3129 string seconds_tostring(float sec)
3132 minutes = floor(sec / 60);
3134 sec -= minutes * 60;
3137 s = ftos(100 + sec);
3139 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3142 void HUD_Timer(void)
3144 if(!autocvar_hud_timer && !autocvar__hud_configure)
3147 float id = HUD_PANEL_TIMER;
3148 HUD_Panel_UpdateCvarsForId(id);
3151 mySize = panel_size;
3153 HUD_Panel_DrawBg(1);
3154 if(panel_bg_padding)
3156 pos += '1 1 0' * panel_bg_padding;
3157 mySize -= '2 2 0' * panel_bg_padding;
3161 float timelimit, elapsedTime, timeleft, minutesLeft;
3163 timelimit = getstatf(STAT_TIMELIMIT);
3165 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3166 timeleft = ceil(timeleft);
3168 minutesLeft = floor(timeleft / 60);
3171 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3172 timer_color = '1 1 1'; //white
3173 else if(minutesLeft >= 1)
3174 timer_color = '1 1 0'; //yellow
3176 timer_color = '1 0 0'; //red
3178 if (autocvar_hud_timer_increment || timelimit == 0 || warmup_stage) {
3179 if (time < getstatf(STAT_GAMESTARTTIME)) {
3180 //while restart is still active, show 00:00
3181 timer = seconds_tostring(0);
3183 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3184 timer = seconds_tostring(elapsedTime);
3187 timer = seconds_tostring(timeleft);
3190 drawfont = hud_bigfont;
3191 drawstring_aspect(pos, timer, mySize, mySize_y, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3192 drawfont = hud_font;
3197 void HUD_Radar(void)
3199 if (!(autocvar_hud_radar != 0 && (autocvar_hud_radar == 2 || teamplay || autocvar__hud_configure)))
3202 float id = HUD_PANEL_RADAR;
3203 HUD_Panel_UpdateCvarsForId(id);
3206 mySize = panel_size;
3208 HUD_Panel_DrawBg(1);
3209 if(panel_bg_padding)
3211 pos += '1 1 0' * panel_bg_padding;
3212 mySize -= '2 2 0' * panel_bg_padding;
3215 local float color1, color2; // color already declared as a global in hud.qc
3218 float scale2d, normalsize, bigsize;
3221 teamradar_origin2d = pos + 0.5 * mySize;
3222 teamradar_size2d = mySize;
3224 if(minimapname == "")
3227 teamradar_loadcvars();
3229 switch(hud_radar_zoommode)
3233 f = current_zoomfraction;
3236 f = 1 - current_zoomfraction;
3246 switch(hud_radar_rotation)
3249 teamradar_angle = view_angles_y - 90;
3252 teamradar_angle = 90 * hud_radar_rotation;
3256 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3257 teamradar_size2d = mySize;
3259 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3261 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3262 if(hud_radar_rotation == 0)
3264 // max-min distance must fit the radar in any rotation
3265 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3269 vector c0, c1, c2, c3, span;
3270 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3271 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3272 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3273 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3275 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3276 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3278 // max-min distance must fit the radar in x=x, y=y
3280 teamradar_size2d_x * scale2d / (1.05 * span_x),
3281 teamradar_size2d_y * scale2d / (1.05 * span_y)
3285 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3286 if(bigsize > normalsize)
3287 normalsize = bigsize;
3291 + (1 - f) * normalsize;
3292 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3293 f * (mi_min + mi_max) * 0.5
3294 + (1 - f) * view_origin);
3296 color1 = GetPlayerColor(player_localentnum-1);
3297 rgb = GetTeamRGB(color1);
3306 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3308 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3309 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3310 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3311 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3312 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3314 color2 = GetPlayerColor(tm.sv_entnum);
3315 //if(color == COLOR_SPECTATOR || color == color2)
3316 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3318 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3320 drawresetcliparea();
3325 void HUD_Score(void)
3327 if(!autocvar_hud_score && !autocvar__hud_configure)
3330 float id = HUD_PANEL_SCORE;
3331 HUD_Panel_UpdateCvarsForId(id);
3334 mySize = panel_size;
3336 HUD_Panel_DrawBg(1);
3337 if(panel_bg_padding)
3339 pos += '1 1 0' * panel_bg_padding;
3340 mySize -= '2 2 0' * panel_bg_padding;
3343 float score, distribution, leader;
3345 vector distribution_color;
3347 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3349 // TODO... this (race part) still uses constant coordinates :/
3350 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3351 /*pl = players.sort_next;
3354 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3355 if(pl.scores[ps_primary] == 0)
3358 score = me.(scores[ps_primary]);
3360 float racemin, racesec, racemsec;
3361 float distsec, distmsec, minusplus;
3363 racemin = floor(score/(60 * TIME_FACTOR));
3364 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
3365 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
3367 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3368 // distribution display
3369 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3371 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
3372 distmsec = fabs(distribution);
3374 distsec = floor(fabs(distribution)/TIME_FACTOR);
3375 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
3376 if (distribution < 0)
3380 if (distribution <= 0) {
3381 distribution_color = eY;
3382 minusplus = 1; // minusplus 1: always prefix with minus sign
3385 distribution_color = eX;
3386 minusplus = 2; // minusplus 1: always prefix with plus sign
3388 //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);
3389 //HUD_DrawXNum(bottomright - '68 48 0' - '16 0 0' * TIME_DECIMALS, distsec, 4, minusplus, 16, distribution_color, 0, 0, panel_fg_alpha, DRAWFLAG_NORMAL);
3390 drawpic_aspect_skin(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "num_dot", '16 16 0', distribution_color, panel_fg_alpha, DRAWFLAG_ADDITIVE);
3392 // race record display
3393 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
3394 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);
3396 //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);
3397 //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);
3398 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);
3400 //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);
3401 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);
3403 } else if (!teamplay) { // non-teamgames
3404 // me vector := [team/connected frags id]
3405 pl = players.sort_next;
3409 if(autocvar__hud_configure)
3412 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3416 score = me.(scores[ps_primary]);
3417 if(autocvar__hud_configure)
3420 if(distribution >= 5) {
3421 distribution_color = eY;
3423 } else if(distribution >= 0) {
3424 distribution_color = '1 1 1';
3426 } else if(distribution >= -5)
3427 distribution_color = '1 1 0';
3429 distribution_color = eX;
3431 score_len = strlen(ftos(score));
3433 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);
3435 drawpic_aspect_skin(pos, strcat("num_leading_", ftos(score_len)), eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3436 drawfont = hud_bigfont;
3437 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3438 drawfont = hud_font;
3439 } else { // teamgames
3440 float max_fragcount;
3441 max_fragcount = -99;
3444 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3445 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !autocvar__hud_configure)) // no players? don't display
3447 score = tm.(teamscores[ts_primary]);
3448 if(autocvar__hud_configure)
3452 score_len = strlen(ftos(score));
3454 if (score > max_fragcount)
3455 max_fragcount = score;
3457 if(tm.team == myteam) {
3458 if (max_fragcount == score)
3461 drawpic_aspect_skin(pos, strcat("num_leading_", ftos(score_len)), eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3462 drawfont = hud_bigfont;
3463 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);
3464 drawfont = hud_font;
3466 if (max_fragcount == score)
3469 drawpic_aspect_skin(pos + eX * 0.75 * mySize_x + eY * (1/3) * teamnum * mySize_y, strcat("num_leading_", ftos(score_len)), eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3470 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);
3479 void HUD_RaceTimer (void) {
3480 if(!autocvar_hud_racetimer && !(gametype == GAME_RACE || gametype == GAME_CTS) && !autocvar__hud_configure)
3483 float id = HUD_PANEL_RACETIMER;
3484 HUD_Panel_UpdateCvarsForId(id);
3487 mySize = panel_size;
3489 HUD_Panel_DrawBg(1);
3490 if(panel_bg_padding)
3492 pos += '1 1 0' * panel_bg_padding;
3493 mySize -= '2 2 0' * panel_bg_padding;
3496 // always force 2:1 aspect
3498 if(mySize_x/mySize_y > 2)
3500 newSize_x = 2 * mySize_y;
3501 newSize_y = mySize_y;
3503 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3507 newSize_y = 1/2 * mySize_x;
3508 newSize_x = mySize_x;
3510 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3514 drawfont = hud_bigfont;
3516 string s, forcetime;
3518 if(autocvar__hud_configure)
3521 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);
3522 s = "^1Intermediate 1 (+15.42)";
3523 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);
3524 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3525 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);
3527 else if(race_checkpointtime)
3529 a = bound(0, 2 - (time - race_checkpointtime), 1);
3532 if(a > 0) // just hit a checkpoint?
3534 if(race_checkpoint != 254)
3536 if(race_time && race_previousbesttime)
3537 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3539 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3541 forcetime = TIME_ENCODED_TOSTRING(race_time);
3546 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3548 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3549 if(a > 0) // next one?
3551 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3556 if(s != "" && a > 0)
3558 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3559 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3560 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);
3563 if(race_penaltytime)
3565 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3568 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3569 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3570 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3571 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);
3577 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3578 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', panel_fg_alpha, 0, a);
3579 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);
3584 if(race_laptime && race_checkpoint != 255)
3586 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3587 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3588 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);
3593 if(race_mycheckpointtime)
3595 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3596 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3597 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3598 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3599 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);
3601 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3603 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3604 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3605 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3606 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3607 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);
3610 if(race_penaltytime && !race_penaltyaccumulator)
3612 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3613 a = bound(0, (1 + t - time), 1);
3617 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3619 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3620 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3621 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3622 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);
3627 drawfont = hud_font;
3632 float vote_yescount;
3635 float vote_highlighted; // currently selected vote
3637 float vote_active; // is there an active vote?
3638 float vote_prev; // previous state of vote_active to check for a change
3640 float vote_change; // "time" when vote_active changed
3642 void HUD_VoteWindow(void)
3644 if(!autocvar_hud_vote && !autocvar__hud_configure)
3647 float id = HUD_PANEL_VOTE;
3648 HUD_Panel_UpdateCvarsForId(id);
3651 mySize = panel_size;
3655 if(vote_active != vote_prev) {
3657 vote_prev = vote_active;
3660 if(vote_active || autocvar__hud_configure)
3661 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3663 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3665 if(autocvar__hud_configure)
3675 a = vote_alpha * bound(autocvar_hud_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3677 HUD_Panel_DrawBg(1);
3678 if(panel_bg_padding)
3680 pos += '1 1 0' * panel_bg_padding;
3681 mySize -= '2 2 0' * panel_bg_padding;
3684 // always force 2:1 aspect
3686 if(mySize_x/mySize_y > 2)
3688 newSize_x = 2 * mySize_y;
3689 newSize_y = mySize_y;
3691 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3695 newSize_y = 1/2 * mySize_x;
3696 newSize_x = mySize_x;
3698 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3702 drawpic_aspect_skin(pos, "voteprogress_back", mySize, '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3704 s = "A vote has been called for: ";
3705 drawstring_aspect(pos + eY * (1/12) * mySize_y, s, eX * mySize_x + eY * (3/12) * mySize_y, mySize_y*(3/12), '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3706 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (3/12), stringwidth_colors); // TODO: broken?
3707 if(autocvar__hud_configure)
3708 s = "Configure the HUD";
3709 drawstring_aspect(pos + eY * (4/12) * mySize_y, s, eX * mySize_x + eY * (2/12) * mySize_y, mySize_y*(2/12), '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3711 // print the yes/no counts
3712 s = strcat("Yes: ", ftos(vote_yescount));
3713 drawstring(pos + '0 0.6 0' * mySize_y + '0.02 0 0' * mySize_x, s, '1 1 0' * mySize_y*(1/6) , eY, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3714 s = strcat("No: ", ftos(vote_nocount));
3715 drawstring(pos + '0 0.6 0' * mySize_y + '0.98 0 0' * mySize_x - eX * stringwidth(s, FALSE, '1 1 0' * mySize_y*(1/6)), s, '1 1 0' * mySize_y*(1/6), eX, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3717 // draw the progress bars
3718 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3719 drawpic_aspect_skin(pos, "voteprogress_prog", mySize, eY, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3721 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3722 drawpic_aspect_skin(pos, "voteprogress_prog", mySize, eX, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3724 // draw the highlights
3725 if(vote_highlighted == 1) {
3726 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3727 drawpic_aspect_skin(pos, "voteprogress_voted", mySize, eY, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3729 else if(vote_highlighted == 2) {
3730 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3731 drawpic_aspect_skin(pos, "voteprogress_voted", mySize, eX, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3734 drawresetcliparea();
3737 vote_highlighted = 0;
3741 // Mod icons panel (#10)
3744 float mod_active; // is there any active mod icon?
3746 // CTF HUD modicon section
3747 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3748 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3749 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3751 void HUD_Mod_CTF_Reset(void)
3753 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3756 void HUD_Mod_CTF(vector pos, vector mySize)
3758 vector redflag_pos, blueflag_pos;
3760 float f; // every function should have that
3762 float redflag, blueflag; // current status
3763 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3766 stat_items = getstati(STAT_ITEMS);
3767 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3768 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3770 if(redflag || blueflag)
3775 if(autocvar__hud_configure)
3781 // when status CHANGES, set old status into prevstatus and current status into status
3782 if (redflag != redflag_prevframe)
3784 redflag_statuschange_time = time;
3785 redflag_prevstatus = redflag_prevframe;
3786 redflag_prevframe = redflag;
3789 if (blueflag != blueflag_prevframe)
3791 blueflag_statuschange_time = time;
3792 blueflag_prevstatus = blueflag_prevframe;
3793 blueflag_prevframe = blueflag;
3796 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3797 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3799 float BLINK_FACTOR = 0.15;
3800 float BLINK_BASE = 0.85;
3802 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3804 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3806 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3808 string red_icon, red_icon_prevstatus;
3809 float red_alpha, red_alpha_prevstatus;
3810 red_alpha = red_alpha_prevstatus = 1;
3812 case 1: red_icon = "flag_red_taken"; break;
3813 case 2: red_icon = "flag_red_lost"; break;
3814 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3816 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3817 red_icon = "flag_red_shielded";
3819 red_icon = string_null;
3822 switch(redflag_prevstatus) {
3823 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3824 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3825 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3828 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3829 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3830 red_icon_prevstatus = "flag_red_shielded";
3832 red_icon_prevstatus = string_null;
3836 string blue_icon, blue_icon_prevstatus;
3837 float blue_alpha, blue_alpha_prevstatus;
3838 blue_alpha = blue_alpha_prevstatus = 1;
3840 case 1: blue_icon = "flag_blue_taken"; break;
3841 case 2: blue_icon = "flag_blue_lost"; break;
3842 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3844 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3845 blue_icon = "flag_blue_shielded";
3847 blue_icon = string_null;
3850 switch(blueflag_prevstatus) {
3851 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3852 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3853 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3856 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3857 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3858 blue_icon_prevstatus = "flag_blue_shielded";
3860 blue_icon_prevstatus = string_null;
3864 if(mySize_x > mySize_y) {
3865 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3867 blueflag_pos = pos + eX * 0.5 * mySize_x;
3870 redflag_pos = pos + eX * 0.5 * mySize_x;
3872 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3874 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3876 blueflag_pos = pos + eY * 0.5 * mySize_y;
3879 redflag_pos = pos + eY * 0.5 * mySize_y;
3881 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3884 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3885 if(red_icon_prevstatus && f < 1)
3886 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3888 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3890 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3891 if(blue_icon_prevstatus && f < 1)
3892 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3894 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3897 // Keyhunt HUD modicon section
3898 float kh_runheretime;
3900 void HUD_Mod_KH_Reset(void)
3905 void HUD_Mod_KH(vector pos, vector mySize)
3907 mod_active = 1; // keyhunt should never hide the mod icons panel
3911 vector p, pa, kh_size, kh_asize;
3913 kh_keys = getstati(STAT_KH_KEYS);
3916 if(mySize_x > mySize_y)
3918 p_y = pos_y + 0.25 * mySize_y;
3919 pa = p - eY * 0.25 * mySize_y;
3921 kh_size_x = mySize_x * 0.25;
3922 kh_size_y = 0.75 * mySize_y;
3923 kh_asize_x = mySize_x * 0.25;
3924 kh_asize_y = mySize_y * 0.25;
3928 p_y = pos_y + 0.125 * mySize_y;
3929 pa = p - eY * 0.125 * mySize_y;
3931 kh_size_x = mySize_x * 0.5;
3932 kh_size_y = 0.375 * mySize_y;
3933 kh_asize_x = mySize_x * 0.5;
3934 kh_asize_y = mySize_y * 0.125;
3941 for(i = 0; i < 4; ++i)
3943 key = floor(kh_keys / pow(32, i)) & 31;
3945 if(keyteam == 30 && keycount <= 4)
3947 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3951 // this yields 8 exactly if "RUN HERE" shows
3956 kh_runheretime = time;
3957 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3962 for(i = 0; i < 4; ++i)
3964 key = floor(kh_keys / pow(32, i)) & 31;
3977 default: // owned or dropped
3982 a = a * panel_fg_alpha;
3983 aa = aa * panel_fg_alpha;
3989 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3992 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3995 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3998 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4003 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
4006 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4009 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4012 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4015 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4019 if(mySize_x > mySize_y)
4021 p_x += 0.25 * mySize_x;
4022 pa_x += 0.25 * mySize_x;
4028 p_y = pos_y + 0.625 * mySize_y;
4029 pa_y = pos_y + 0.5 * mySize_y;
4035 p_x += 0.5 * mySize_x;
4036 pa_x += 0.5 * mySize_x;
4042 // Nexball HUD mod icon
4043 void HUD_Mod_NexBall(vector pos, vector mySize)
4045 float stat_items, nb_pb_starttime, dt, p;
4047 stat_items = getstati(STAT_ITEMS);
4048 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
4050 if (stat_items & IT_KEY1)
4055 //Manage the progress bar if any
4056 if (nb_pb_starttime > 0)
4058 dt = mod(time - nb_pb_starttime, nb_pb_period);
4059 // one period of positive triangle
4060 p = 2 * dt / nb_pb_period;
4067 if(mySize_x > mySize_y)
4069 barsize = eX * p * mySize_x + eY * mySize_y;
4074 barsize = eX * mySize_x + eY * p * mySize_y;
4077 HUD_Panel_GetProgressBarColor("nexball")
4078 HUD_Panel_DrawProgressBar(pos, vertical, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4081 if (stat_items & IT_KEY1)
4082 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4085 // Race/CTS HUD mod icons
4086 float crecordtime_prev; // last remembered crecordtime
4087 float crecordtime_change_time; // time when crecordtime last changed
4088 float srecordtime_prev; // last remembered srecordtime
4089 float srecordtime_change_time; // time when srecordtime last changed
4091 float race_status_time;
4092 float race_status_prev;
4093 string race_status_name_prev;
4094 void HUD_Mod_Race(vector pos, vector mySize)
4096 mod_active = 1; // race should never hide the mod icons panel
4098 me = playerslots[player_localentnum - 1];
4100 float f; // yet another function has this
4101 score = me.(scores[ps_primary]);
4103 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
4104 return; // no records in the actual race
4106 drawfont = hud_bigfont;
4108 // clientside personal record
4110 if(gametype == GAME_CTS)
4114 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4116 if(score && (score < t || !t)) {
4117 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4118 if(cvar("cl_autodemo_delete_keeprecords"))
4120 f = cvar("cl_autodemo_delete");
4122 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4126 if(t != crecordtime_prev) {
4127 crecordtime_prev = t;
4128 crecordtime_change_time = time;
4130 f = time - crecordtime_change_time;
4133 drawstring_aspect(pos, "Personal best ", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4134 drawstring(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);
4136 drawstring(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4137 drawstring(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);
4138 drawstring_expanding(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4139 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);
4143 t = race_server_record;
4144 if(t != srecordtime_prev) {
4145 srecordtime_prev = t;
4146 srecordtime_change_time = time;
4148 f = time - srecordtime_change_time;
4151 drawstring(pos + eY * 0.5 * mySize_y, "Server best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4152 drawstring(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);
4154 drawstring(pos + eY * 0.5 * mySize_y, "Server best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4155 drawstring(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);
4156 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);
4157 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);
4160 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4161 race_status_time = time + 5;
4162 race_status_prev = race_status;
4163 if (race_status_name_prev)
4164 strunzone(race_status_name_prev);
4165 race_status_name_prev = strzone(race_status_name);
4168 pos_x += mySize_x/2;
4171 a = bound(0, race_status_time - time, 1);
4174 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4178 rank = race_CheckName(race_status_name);
4180 rankname = race_PlaceName(rank);
4183 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4185 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4187 if(race_status == 0)
4188 drawpic_aspect_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4189 else if(race_status == 1) {
4190 drawpic_aspect_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4191 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4192 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4193 } else if(race_status == 2) {
4194 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4195 drawpic_aspect_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4197 drawpic_aspect_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4198 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4199 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4200 } else if(race_status == 3) {
4201 drawpic_aspect_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4202 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4203 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4206 if (race_status_time - time <= 0) {
4207 race_status_prev = -1;
4209 if(race_status_name)
4210 strunzone(race_status_name);
4211 race_status_name = string_null;
4212 if(race_status_name_prev)
4213 strunzone(race_status_name_prev);
4214 race_status_name_prev = string_null;
4216 drawfont = hud_font;
4219 float mod_prev; // previous state of mod_active to check for a change
4221 float mod_change; // "time" when mod_active changed
4223 void HUD_ModIcons(void)
4225 if(!autocvar_hud_modicons && !autocvar__hud_configure)
4228 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !autocvar__hud_configure)
4231 float id = HUD_PANEL_MODICONS;
4232 HUD_Panel_UpdateCvarsForId(id);
4235 mySize = panel_size;
4237 if(mod_active != mod_prev) {
4239 mod_prev = mod_active;
4242 if(mod_active || autocvar__hud_configure)
4243 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4245 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4248 HUD_Panel_DrawBg(mod_alpha);
4250 if(panel_bg_padding)
4252 pos += '1 1 0' * panel_bg_padding;
4253 mySize -= '2 2 0' * panel_bg_padding;
4256 // these MUST be ran in order to update mod_active
4257 if(gametype == GAME_KEYHUNT)
4258 HUD_Mod_KH(pos, mySize);
4259 else if(gametype == GAME_CTF || autocvar__hud_configure)
4260 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4261 else if(gametype == GAME_NEXBALL)
4262 HUD_Mod_NexBall(pos, mySize);
4263 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4264 HUD_Mod_Race(pos, mySize);
4267 // Draw pressed keys (#11)
4269 void HUD_DrawPressedKeys(void)
4271 if(!autocvar_hud_pressedkeys && !autocvar__hud_configure)
4274 if(!(spectatee_status > 0 || autocvar_hud_pressedkeys >= 2 || autocvar__hud_configure))
4277 float id = HUD_PANEL_PRESSEDKEYS;
4278 HUD_Panel_UpdateCvarsForId(id);
4281 mySize = panel_size;
4283 HUD_Panel_DrawBg(1);
4284 if(panel_bg_padding)
4286 pos += '1 1 0' * panel_bg_padding;
4287 mySize -= '2 2 0' * panel_bg_padding;
4291 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4294 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4295 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4296 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);
4297 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);
4298 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);
4299 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);
4300 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);
4303 // Handle chat as a panel (#12)
4307 if(!autocvar_hud_chat && !autocvar__hud_configure)
4309 cvar_set("con_chatrect", "0");
4313 float id = HUD_PANEL_CHAT;
4314 HUD_Panel_UpdateCvarsForId(id);
4317 mySize = panel_size;
4319 HUD_Panel_DrawBg(1);
4320 if(panel_bg_padding)
4322 pos += '1 1 0' * panel_bg_padding;
4323 mySize -= '2 2 0' * panel_bg_padding;
4326 cvar_set("con_chatrect", "1");
4328 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4329 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4331 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4332 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4334 if(autocvar__hud_configure)
4337 chatsize = cvar("con_chatsize");
4338 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4340 for(i = 0; i < cvar("con_chat"); ++i)
4342 if(i == cvar("con_chat") - 1)
4345 a = panel_fg_alpha * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4346 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);
4351 // Engine info panel (#13)
4358 float frametimeavg1; // 1 frame ago
4359 float frametimeavg2; // 2 frames ago
4360 void HUD_EngineInfo(void)
4362 if(!autocvar_hud_engineinfo && !autocvar__hud_configure)
4365 float id = HUD_PANEL_ENGINEINFO;
4366 HUD_Panel_UpdateCvarsForId(id);
4369 mySize = panel_size;
4371 HUD_Panel_DrawBg(1);
4372 if(panel_bg_padding)
4374 pos += '1 1 0' * panel_bg_padding;
4375 mySize -= '2 2 0' * panel_bg_padding;
4378 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4380 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4381 frametimeavg2 = frametimeavg1;
4382 frametimeavg1 = frametimeavg;
4385 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4386 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.
4388 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
4389 prevfps = (1/frametime);
4390 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"
4396 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4398 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4400 prevfps_time = time;
4405 color = HUD_Get_Num_Color (prevfps, 100);
4406 drawfont = hud_bigfont;
4407 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), mySize, mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4408 drawfont = hud_font;
4416 void HUD_ShowSpeed(void)
4419 float pos, conversion_factor;
4420 string speed, zspeed, unit;
4422 switch(cvar("cl_showspeed_unit"))
4427 conversion_factor = 1.0;
4431 conversion_factor = 1.0;
4435 conversion_factor = 0.0254;
4439 conversion_factor = 0.0254 * 3.6;
4443 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4447 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4451 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4453 numsize_x = numsize_y = cvar("cl_showspeed_size");
4454 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4456 drawfont = hud_bigfont;
4457 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4459 if (cvar("cl_showspeed_z") == 1) {
4460 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4461 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4464 drawfont = hud_font;
4467 vector acc_prevspeed;
4471 void HUD_ShowAcceleration(void)
4473 float acceleration, sz, scale, alpha, f;
4474 vector pos, top, rgb;
4475 top_x = vid_conwidth/2;
4478 f = time - acc_prevtime;
4479 if(cvar("cl_showacceleration_z"))
4480 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4482 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4483 acc_prevspeed = pmove_vel;
4484 acc_prevtime = time;
4486 f = bound(0, f * 10, 1);
4487 acc_avg = acc_avg * (1 - f) + acceleration * f;
4488 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4490 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4492 sz = cvar("cl_showacceleration_size");
4493 scale = cvar("cl_showacceleration_scale");
4494 alpha = cvar("cl_showacceleration_alpha");
4495 if (cvar("cl_showacceleration_color_custom"))
4496 rgb = stov(cvar_string("cl_showacceleration_color"));
4499 if (acceleration < 0) {
4500 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4501 } else if (acceleration > 0) {
4502 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4506 if (acceleration > 0)
4507 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4508 else if (acceleration < 0)
4509 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4512 void HUD_Reset (void)
4514 // reset gametype specific icons
4515 if(gametype == GAME_KEYHUNT)
4517 else if(gametype == GAME_CTF)
4518 HUD_Mod_CTF_Reset();
4521 #define HUD_DrawPanel(id)\
4523 case (HUD_PANEL_RADAR):\
4524 HUD_Radar(); break;\
4525 case (HUD_PANEL_WEAPONICONS):\
4526 HUD_WeaponIcons(); break;\
4527 case (HUD_PANEL_INVENTORY):\
4528 HUD_Inventory(); break;\
4529 case (HUD_PANEL_POWERUPS):\
4530 HUD_Powerups(); break;\
4531 case (HUD_PANEL_HEALTHARMOR):\
4532 HUD_HealthArmor(); break;\
4533 case (HUD_PANEL_NOTIFY):\
4534 HUD_Notify(); break;\
4535 case (HUD_PANEL_TIMER):\
4536 HUD_Timer(); break;\
4537 case (HUD_PANEL_SCORE):\
4538 HUD_Score(); break;\
4539 case (HUD_PANEL_RACETIMER):\
4540 HUD_RaceTimer(); break;\
4541 case (HUD_PANEL_VOTE):\
4542 HUD_VoteWindow(); break;\
4543 case (HUD_PANEL_MODICONS):\
4544 HUD_ModIcons(); break;\
4545 case (HUD_PANEL_PRESSEDKEYS):\
4546 HUD_DrawPressedKeys(); break;\
4547 case (HUD_PANEL_CHAT):\
4549 case (HUD_PANEL_ENGINEINFO):\
4550 HUD_EngineInfo(); break;\
4553 void HUD_Main (void)
4555 // TODO: render order?
4556 hud_skin_path = strcat("gfx/hud/", autocvar_hud_skin);
4558 if(disable_menu_alphacheck == 1)
4559 menu_fade_alpha = 1;
4561 menu_fade_alpha = (1 - autocvar__menu_alpha);
4562 hud_fg_alpha = cvar("hud_fg_alpha");
4564 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4565 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4566 hud_color_bg_team = cvar("hud_color_bg_team");
4568 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4569 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4573 // HUD configure visible grid
4574 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4578 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2); ++i)
4580 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);
4583 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2); ++i)
4585 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);
4591 if(teamplay && autocvar_hud_dock_color_team) {
4592 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4593 color = colormapPaletteColor(mod(f, 16), 1) * autocvar_hud_dock_color_team;
4595 else if(autocvar_hud_dock_color == "shirt") {
4596 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4597 color = colormapPaletteColor(floor(f / 16), 0);
4599 else if(autocvar_hud_dock_color == "pants") {
4600 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4601 color = colormapPaletteColor(mod(f, 16), 1);
4604 color = stov(autocvar_hud_dock_color);
4606 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4607 drawpic('0 0 0', strcat("gfx/hud/", autocvar_hud_skin, "/", autocvar_hud_dock), eX * vid_conwidth + eY * vid_conheight, color, autocvar_hud_dock_alpha * menu_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
4609 // cache the panel order into the panel_order array
4610 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4611 if(hud_panelorder_prev)
4612 strunzone(hud_panelorder_prev);
4613 hud_panelorder_prev = strzone(autocvar__hud_panelorder);
4614 tokenize_console(autocvar__hud_panelorder);
4615 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4616 panel_order[i] = stof(argv(i));
4619 // draw panels in order specified by panel_order array
4620 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
4621 HUD_DrawPanel(panel_order[i]);
4624 // TODO hud_'ify these
4625 if (cvar("cl_showspeed"))
4627 if (cvar("cl_showacceleration"))
4628 HUD_ShowAcceleration();
4630 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)
4631 localcmd("cmd selectteam auto; cmd join\n");
4633 hud_configure_prev = autocvar__hud_configure;
4635 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again
4636 disable_menu_alphacheck = 0;