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 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
86 // TODO: make a default skin, and fallback to these!
88 // drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
89 void drawpic_aspect_skin(vector pos, string pic, vector sz, vector color, float alpha, float drawflag) {
90 pic = strcat(hud_skin_path, "/", pic);
93 imgsize = drawgetimagesize(pic);
95 imgaspect = imgsize_x/imgsize_y;
102 if(aspect > imgaspect) {
103 sz_x = sz_y * imgaspect;
104 drawpic(pos + eX * (oldsz_x - sz_x) * 0.5, pic, sz, color, alpha, drawflag);
106 sz_y = sz_x / imgaspect;
107 drawpic(pos + eY * (oldsz_y - sz_y) * 0.5, pic, sz, color, alpha, drawflag);
111 // drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
112 void drawpic_aspect(vector pos, string pic, vector sz, vector color, float alpha, float drawflag) {
114 imgsize = drawgetimagesize(pic);
116 imgaspect = imgsize_x/imgsize_y;
123 if(aspect > imgaspect) {
124 sz_x = sz_y * imgaspect;
125 drawpic(pos + eX * (oldsz_x - sz_x) * 0.5, pic, sz, color, alpha, drawflag);
127 sz_y = sz_x / imgaspect;
128 drawpic(pos + eY * (oldsz_y - sz_y) * 0.5, pic, sz, color, alpha, drawflag);
133 void drawpic_aspect_skin_expanding(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
135 //drawpic_aspect_expanding(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
138 void drawpic_aspect_skin_expanding_two(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
140 //drawpic_aspect_expanding_two(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
143 // return HUD background color
144 vector HUD_GetBgColor()
148 GetTeamRGB(myteam) * hud_color_bg_team;
150 // allow custom HUD colors in non-teamgames
151 color_x = cvar("hud_color_bg_r");
152 color_y = cvar("hud_color_bg_g");
153 color_z = cvar("hud_color_bg_b");
158 // return accuracy text color
159 vector HUD_AccuracyColor(float accuracy)
162 float yellow_accuracy = cvar("hud_weaponicons_accuracy_yellow"); // value at which this function returns yellow
163 if(accuracy >= 100) {
167 else if(accuracy > yellow_accuracy) {
168 rgb_x = 1 - (accuracy-yellow_accuracy)/(100-yellow_accuracy); // red value between 1 -> 0
173 rgb_y = accuracy/yellow_accuracy; // green value between 0 -> 1
179 vector HUD_Get_Num_Color (float x, float maxvalue)
187 else if(x > maxvalue * 0.75) {
188 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
189 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
192 else if(x > maxvalue * 0.5) {
193 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
194 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
195 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
197 else if(x > maxvalue * 0.25) {
200 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
202 else if(x > maxvalue * 0.1) {
204 color_y = (x-20)*90/27/100; // green value between 0 -> 1
205 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
215 float stringwidth_colors(string s, vector theSize)
217 return stringwidth(s, TRUE, theSize);
220 float stringwidth_nocolors(string s, vector theSize)
222 return stringwidth(s, FALSE, theSize);
225 #define CENTERPRINT_MAX_LINES 30
226 string centerprint_messages[CENTERPRINT_MAX_LINES];
227 float centerprint_width[CENTERPRINT_MAX_LINES];
228 vector centerprint_start;
229 float centerprint_expire;
230 float centerprint_num;
231 float centerprint_offset_hint;
232 vector centerprint_fontsize;
234 void centerprint(string strMessage)
236 float i, j, n, hcount;
239 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
241 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
243 if(cvar("scr_centertime") <= 0)
249 // strip trailing newlines
250 j = strlen(strMessage) - 1;
251 while(substring(strMessage, j, 1) == "\n" && j >= 0)
253 strMessage = substring(strMessage, 0, j + 1);
258 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
260 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
262 strMessage = substring(strMessage, j, strlen(strMessage) - j);
263 centerprint_offset_hint = j;
268 // if we get here, we have a message. Initialize its height.
271 n = tokenizebyseparator(strMessage, "\n");
273 for(j = 0; j < n; ++j)
275 getWrappedLine_remaining = argv(j);
276 while(getWrappedLine_remaining)
278 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
279 if(centerprint_messages[i])
280 strunzone(centerprint_messages[i]);
281 centerprint_messages[i] = strzone(s);
282 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
285 // half height for empty lines looks better
291 if(i >= CENTERPRINT_MAX_LINES)
297 h = centerprint_fontsize_y*hcount;
299 havail = vid_conheight;
300 if(cvar("con_chatpos") < 0)
301 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
302 if(havail > vid_conheight - 70)
303 havail = vid_conheight - 70; // avoid overlapping HUD
305 centerprint_start_x = 0;
308 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
310 // here, the centerprint would cover the crosshair. REALLY BAD.
311 forbiddenmin = vid_conheight * 0.5 - h - 16;
312 forbiddenmax = vid_conheight * 0.5 + 16;
314 allowedmin = scoreboard_bottom;
315 allowedmax = havail - h;
316 preferred = (havail - h)/2;
319 // possible orderings (total: 4! / 4 = 6)
320 // allowedmin allowedmax forbiddenmin forbiddenmax
321 // forbiddenmin forbiddenmax allowedmin allowedmax
322 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
324 // forbidden doesn't matter in this case
325 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
327 // allowedmin forbiddenmin allowedmax forbiddenmax
328 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
330 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
332 // allowedmin forbiddenmin forbiddenmax allowedmax
333 else if(allowedmin < forbiddenmin)
335 // make sure the forbidden zone is not covered
336 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
337 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
339 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
341 // forbiddenmin allowedmin allowedmax forbiddenmax
342 else if(allowedmax < forbiddenmax)
344 // it's better to leave the allowed zone (overlap with scoreboard) than
345 // to cover the forbidden zone (crosshair)
346 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
347 centerprint_start_y = forbiddenmax;
349 centerprint_start_y = forbiddenmin;
351 // forbiddenmin allowedmin forbiddenmax allowedmax
354 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
357 centerprint_start_y =
360 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
368 centerprint_expire = time + cvar("scr_centertime");
371 void HUD_DrawCenterPrint (void)
378 //if(time > centerprint_expire)
381 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
382 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
383 //sz = 1.2 / (a + 0.2);
388 pos = centerprint_start;
389 for (i=0; i<centerprint_num; i = i + 1)
391 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
392 ts = centerprint_messages[i];
395 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
396 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
397 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
398 pos_y = pos_y + centerprint_fontsize_y;
401 // half height for empty lines looks better
402 pos_y = pos_y + centerprint_fontsize_y * 0.5;
406 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
408 position_x -= 2 / 3 * strlen(text) * scale_x;
409 drawstring(position, text, scale, rgb, alpha, flag);
412 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
414 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
415 drawstring(position, text, scale, rgb, alpha, flag);
418 // return the string of the given race place
419 string race_PlaceName(float pos) {
427 return strcat(ftos(pos), "th");
430 // return the string of the onscreen race timer
431 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
439 if(histime == 0) // goal hit
443 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
453 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
459 lapstr = strcat(" (-", ftos(lapdelta), "L)");
462 else if(lapdelta < 0)
464 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
468 else if(histime > 0) // anticipation
470 if(mytime >= histime)
471 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
473 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
480 cpname = "Start line";
482 cpname = "Finish line";
484 cpname = strcat("Intermediate ", ftos(cp));
486 cpname = "Finish line";
489 return strcat(col, cpname);
490 else if(hisname == "")
491 return strcat(col, cpname, " (", timestr, ")");
493 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
496 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
497 float race_CheckName(string net_name) {
499 for (i=RANKINGS_CNT-1;i>=0;--i)
500 if(grecordholder[i] == net_name)
512 void HUD_Panel_ExportCfg(string cfgname)
515 fh = fopen(strcat("hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg"), FILE_WRITE);
518 fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
519 fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
520 fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
521 fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
522 fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
523 fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
524 fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
525 fputs(fh, strcat("seta hud_fg_alpha \"", cvar_string("hud_fg_alpha"), "\"", "\n"));
528 fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
529 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
530 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
531 fputs(fh, strcat("seta hud_dock_alpha \"", ftos(cvar("hud_dock_alpha")), "\"", "\n"));
534 fputs(fh, strcat("seta hud_progressbar_alpha ", ftos(cvar("hud_progressbar_alpha")), "\n"));
535 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
536 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
537 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
538 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
539 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
540 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
543 // common cvars for all panels
545 for (i = 0; i < HUD_PANEL_NUM; ++i)
547 // HUD_Panel_GetName(i)
548 // HUD_Panel_UpdateCvarsForId(i)
550 fputs(fh, strcat("seta hud_", panel_name, " ", ftos(cvar(strcat("hud_", panel_name))), "\n"));
551 fputs(fh, strcat("seta hud_", panel_name, "_pos \"", cvar_string(strcat("hud_", panel_name, "_pos")), "\"", "\n"));
552 fputs(fh, strcat("seta hud_", panel_name, "_size \"", cvar_string(strcat("hud_", panel_name, "_size")), "\"", "\n"));
553 fputs(fh, strcat("seta hud_", panel_name, "_bg \"", cvar_string(strcat("hud_", panel_name, "_bg")), "\"", "\n"));
554 fputs(fh, strcat("seta hud_", panel_name, "_bg_color \"", cvar_string(strcat("hud_", panel_name, "_bg_color")), "\"", "\n"));
555 fputs(fh, strcat("seta hud_", panel_name, "_bg_color_team \"", cvar_string(strcat("hud_", panel_name, "_bg_color_team")), "\"", "\n"));
556 fputs(fh, strcat("seta hud_", panel_name, "_bg_alpha \"", cvar_string(strcat("hud_", panel_name, "_bg_alpha")), "\"", "\n"));
557 fputs(fh, strcat("seta hud_", panel_name, "_bg_border \"", cvar_string(strcat("hud_", panel_name, "_bg_border")), "\"", "\n"));
558 fputs(fh, strcat("seta hud_", panel_name, "_bg_padding \"", cvar_string(strcat("hud_", panel_name, "_bg_padding")), "\"", "\n"));
560 case HUD_PANEL_WEAPONICONS:
561 fputs(fh, strcat("seta hud_", panel_name, "_accuracy_yellow ", ftos(cvar(strcat("hud_", panel_name, "_accuracy_yellow"))), "\n"));
563 case HUD_PANEL_INVENTORY:
564 fputs(fh, strcat("seta hud_", panel_name, "_onlycurrent ", ftos(cvar(strcat("hud_", panel_name, "_onlycurrent"))), "\n"));
565 fputs(fh, strcat("seta hud_", panel_name, "_iconalign ", ftos(cvar(strcat("hud_", panel_name, "_iconalign"))), "\n"));
567 case HUD_PANEL_POWERUPS:
568 fputs(fh, strcat("seta hud_", panel_name, "_flip ", ftos(cvar(strcat("hud_", panel_name, "_flip"))), "\n"));
569 fputs(fh, strcat("seta hud_", panel_name, "_iconalign ", ftos(cvar(strcat("hud_", panel_name, "_iconalign"))), "\n"));
570 fputs(fh, strcat("seta hud_", panel_name, "_baralign ", ftos(cvar(strcat("hud_", panel_name, "_baralign"))), "\n"));
572 case HUD_PANEL_HEALTHARMOR:
573 fputs(fh, strcat("seta hud_", panel_name, "_flip ", ftos(cvar(strcat("hud_", panel_name, "_flip"))), "\n"));
574 fputs(fh, strcat("seta hud_", panel_name, "_iconalign ", ftos(cvar(strcat("hud_", panel_name, "_iconalign"))), "\n"));
575 fputs(fh, strcat("seta hud_", panel_name, "_baralign ", ftos(cvar(strcat("hud_", panel_name, "_baralign"))), "\n"));
577 case HUD_PANEL_NOTIFY:
578 fputs(fh, strcat("seta hud_", panel_name, "_flip ", ftos(cvar(strcat("hud_", panel_name, "_flip"))), "\n"));
579 fputs(fh, strcat("seta hud_", panel_name, "_info_top ", ftos(cvar(strcat("hud_", panel_name, "_info_top"))), "\n"));
581 case HUD_PANEL_RADAR:
582 fputs(fh, strcat("seta hud_", panel_name, "_foreground_alpha ", ftos(cvar(strcat("hud_", panel_name, "_foreground_alpha"))), "\n"));
585 fputs(fh, strcat("seta hud_", panel_name, "_alreadyvoted_alpha ", ftos(cvar(strcat("hud_", panel_name, "_alreadyvoted_alpha"))), "\n"));
591 print("^2Successfully exported to hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
596 // return smoothly faded size of given panel when a dialog is active
597 vector HUD_Panel_GetMenuSize(float id)
600 mySize = stov(cvar_string(strcat("hud_", panel_name, "_size")));
602 mySize = eX * mySize_x * vid_conwidth + eY * mySize_y * vid_conheight;
604 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
606 vector menu_enable_maxsize, menu_enable_size;
607 menu_enable_maxsize = '0 0 0'; // shut up FTEQCC
608 menu_enable_maxsize_x = 0.3 * vid_conwidth;
609 menu_enable_maxsize_y = 0.18 * vid_conheight;
610 if(mySize_x > mySize_y)
612 if(mySize_y > menu_enable_maxsize_y)
614 menu_enable_size_y = menu_enable_maxsize_y;
615 menu_enable_size_x = mySize_x * (menu_enable_maxsize_y/mySize_y);
616 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
621 if(mySize_x > menu_enable_maxsize_x)
623 menu_enable_size_x = menu_enable_maxsize_x;
624 menu_enable_size_y = mySize_y * (menu_enable_maxsize_x/mySize_x);
625 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
632 // return smoothly faded pos of given panel when a dialog is active
633 vector HUD_Panel_GetMenuPos(float id)
636 pos = stov(cvar_string(strcat("hud_", panel_name, "_pos")));
638 pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
640 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
642 vector mySize, menu_enable_panelpos;
643 mySize = HUD_Panel_GetMenuSize(id);
644 if(mySize_x > mySize_y)
645 menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * mySize_x + eY * 0.82 * vid_conheight;
647 menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * mySize_y + eX * 0.7 * vid_conwidth;
648 pos = (1 - cvar("_menu_alpha")) * pos + (cvar("_menu_alpha")) * menu_enable_panelpos;
653 vector HUD_Panel_GetColor(float id)
659 // fetch per-panel color
660 if(teamplay && cvar_string(strcat("hud_", panel_name, "_bg_color_team")) != "") {
661 f = stof(getplayerkey(player_localentnum - 1, "colors"));
662 color = vtos(colormapPaletteColor(mod(f, 16), 1) * cvar(strcat("hud_", panel_name, "_bg_color_team")));
665 color = cvar_string(strcat("hud_", panel_name, "_bg_color"));
666 color_vec = stov(color);
668 if(color == "") { // fetch default color
669 color = cvar_string("hud_bg_color");
670 color_vec = stov(color);
671 if(teamplay && cvar(strcat("hud_bg_color_team"))) {
672 f = stof(getplayerkey(player_localentnum - 1, "colors"));
673 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_bg_color_team");
675 else if(color == "shirt") {
676 f = stof(getplayerkey(player_localentnum - 1, "colors"));
677 color_vec = colormapPaletteColor(floor(f / 16), 0);
679 else if(color == "pants") {
680 f = stof(getplayerkey(player_localentnum - 1, "colors"));
681 color_vec = colormapPaletteColor(mod(f, 16), 1);
684 else if(color == "shirt") {
685 f = stof(getplayerkey(player_localentnum - 1, "colors"));
686 color_vec = colormapPaletteColor(floor(f / 16), 0);
688 else if(color == "pants") {
689 f = stof(getplayerkey(player_localentnum - 1, "colors"));
690 color_vec = colormapPaletteColor(mod(f, 16), 1);
695 // draw the background/borders
696 void HUD_Panel_DrawBg(float id, vector pos, vector mySize, float alpha)
698 if(!autocvar__hud_configure && panel_bg == "0")
702 panel_bg = cvar_string("hud_bg");
704 if(panel_bg == "0" && autocvar__hud_configure) {
705 panel_bg = "border"; // we probably want to see a background in config mode at all times...
712 border = cvar_string(strcat("hud_", panel_name, "_bg_border"));
714 border = cvar_string("hud_bg_border");
717 borderf = stof(border);
720 color = stov(panel_bg_color);
723 // alpha = HUD_Panel_GetBgAlpha(id) * alpha; // allow panels to fade in/out by passing an alpha value
725 // alpha = HUD_Panel_GetBgAlpha(id);
727 draw_BorderPicture(pos - '1 1 0' * borderf, strcat("gfx/hud/", cvar_string("hud_skin"), "/", panel_bg), mySize + '1 1 0' * 2 * borderf, color, alpha, '1 1 0' * (borderf/BORDER_MULTIPLIER));
730 if(highlightedPanel_prev == id && autocvar__hud_configure)
731 drawfill(pos - '1 1 0' * borderf, mySize + '1 1 0' * 2 * borderf, '1 1 1', .1 * (1 - cvar("_menu_alpha")), DRAWFLAG_ADDITIVE);
734 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
740 pic = strcat("gfx/hud/", cvar_string("hud_skin"), "/");
742 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);
743 if(mySize_y/mySize_x > 2)
744 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);
745 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);
747 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);
748 if(mySize_x/mySize_y > 2)
749 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);
750 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);
755 #define HUD_Panel_GetProgressBarColor(item) \
756 stov(cvar_string(strcat("hud_progressbar_", item, "_color")))
758 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
759 vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
770 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
771 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
773 for (i = 0; i < HUD_PANEL_NUM; ++i) {
774 HUD_Panel_UpdateCvarsForId(i)
776 if(i == id || !panel_enabled)
780 targSize = panel_size;
782 if(myPos_y + mySize_y < targPos_y)
784 if(myPos_y > targPos_y + targSize_y)
787 if(myPos_x + mySize_x < targPos_x)
789 if(myPos_x > targPos_x + targSize_x)
792 // OK, there IS a collision.
794 myCenter_x = myPos_x + 0.5 * mySize_x;
795 myCenter_y = myPos_y + 0.5 * mySize_y;
797 targCenter_x = targPos_x + 0.5 * targSize_x;
798 targCenter_y = targPos_y + 0.5 * targSize_y;
800 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
802 if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
803 myTarget_x = targPos_x - mySize_x;
804 else // push it upwards
805 myTarget_y = targPos_y - mySize_y;
807 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
809 if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
810 myTarget_x = targPos_x + targSize_x;
811 else // push it upwards
812 myTarget_y = targPos_y - mySize_y;
814 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
816 if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
817 myTarget_x = targPos_x - mySize_x;
818 else // push it downwards
819 myTarget_y = targPos_y + targSize_y;
821 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
823 if(targPos_x + targSize_x - myPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
824 myTarget_x = targPos_x + targSize_x;
825 else // push it downwards
826 myTarget_y = targPos_y + targSize_y;
833 void HUD_Panel_SetPos(float id, vector pos)
841 if(autocvar_hud_configure_checkcollisions)
842 pos = HUD_Panel_CheckMove(id, pos, mySize);
844 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
845 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
847 if(autocvar_hud_configure_grid)
849 pos_x = floor((pos_x/vid_conwidth)/bound(0.005, autocvar_hud_configure_grid_x, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_x, 0.2) * vid_conwidth;
850 pos_y = floor((pos_y/vid_conheight)/bound(0.005, autocvar_hud_configure_grid_y, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_y, 0.2) * vid_conheight;
854 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
856 cvar_set(strcat("hud_", panel_name, "_pos"), s);
859 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
860 vector HUD_Panel_CheckResize(float id, vector mySize, vector resizeorigin) {
870 ratio = mySize_x/mySize_y;
872 for (i = 0; i < HUD_PANEL_NUM; ++i) {
873 if(i == id || !panel_enabled)
877 targSize = panel_size;
878 targEndPos = targPos + targSize;
880 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
881 if(resizeorigin_x > targPos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > targPos_y && resizeorigin_y < targEndPos_y)
884 if (resizeCorner == 1)
886 // check if this panel is on our way
887 if (resizeorigin_x <= targPos_x)
889 if (resizeorigin_y <= targPos_y)
891 if (targEndPos_x <= resizeorigin_x - mySize_x)
893 if (targEndPos_y <= resizeorigin_y - mySize_y)
896 // there is a collision:
897 // detect which side of the panel we are facing is actually limiting the resizing
898 // (which side the resize direction finds for first) and reduce the size up to there
900 // dist is the distance between resizeorigin and the "analogous" point of the panel
901 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
902 dist_x = resizeorigin_x - targEndPos_x;
903 dist_y = resizeorigin_y - targEndPos_y;
904 if (dist_y < 0 || dist_x / dist_y > ratio)
905 mySize_x = min(mySize_x, dist_x);
907 mySize_y = min(mySize_y, dist_y);
909 else if (resizeCorner == 2)
911 if (resizeorigin_x >= targEndPos_x)
913 if (resizeorigin_y <= targPos_y)
915 if (targPos_x >= resizeorigin_x + mySize_x)
917 if (targEndPos_y <= resizeorigin_y - mySize_y)
920 dist_x = targPos_x - resizeorigin_x;
921 dist_y = resizeorigin_y - targEndPos_y;
922 if (dist_y < 0 || dist_x / dist_y > ratio)
923 mySize_x = min(mySize_x, dist_x);
925 mySize_y = min(mySize_y, dist_y);
927 else if (resizeCorner == 3)
929 if (resizeorigin_x <= targPos_x)
931 if (resizeorigin_y >= targEndPos_y)
933 if (targEndPos_x <= resizeorigin_x - mySize_x)
935 if (targPos_y >= resizeorigin_y + mySize_y)
938 dist_x = resizeorigin_x - targEndPos_x;
939 dist_y = targPos_y - resizeorigin_y;
940 if (dist_y < 0 || dist_x / dist_y > ratio)
941 mySize_x = min(mySize_x, dist_x);
943 mySize_y = min(mySize_y, dist_y);
945 else if (resizeCorner == 4)
947 if (resizeorigin_x >= targEndPos_x)
949 if (resizeorigin_y >= targEndPos_y)
951 if (targPos_x >= resizeorigin_x + mySize_x)
953 if (targPos_y >= resizeorigin_y + mySize_y)
956 dist_x = targPos_x - resizeorigin_x;
957 dist_y = targPos_y - resizeorigin_y;
958 if (dist_y < 0 || dist_x / dist_y > ratio)
959 mySize_x = min(mySize_x, dist_x);
961 mySize_y = min(mySize_y, dist_y);
963 if(cvar("hud_configure_checkcollisions_debug"))
964 drawfill(targPos, targSize, '1 1 0', .3, DRAWFLAG_NORMAL);
970 void HUD_Panel_SetPosSize(float id, vector mySize)
973 resizeorigin = panel_click_resizeorigin;
976 // minimum panel size cap
977 mySize_x = max(0.025 * vid_conwidth, mySize_x);
978 mySize_y = max(0.025 * vid_conheight, mySize_y);
980 if(id == 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.
982 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
983 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
986 // collision testing|
987 // -----------------+
989 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
990 if(resizeCorner == 1) {
991 myPos_x = resizeorigin_x - mySize_x;
992 myPos_y = resizeorigin_y - mySize_y;
993 } else if(resizeCorner == 2) {
994 myPos_x = resizeorigin_x;
995 myPos_y = resizeorigin_y - mySize_y;
996 } else if(resizeCorner == 3) {
997 myPos_x = resizeorigin_x - mySize_x;
998 myPos_y = resizeorigin_y;
999 } else { // resizeCorner == 4
1000 myPos_x = resizeorigin_x;
1001 myPos_y = resizeorigin_y;
1004 // left/top screen edges
1006 mySize_x = mySize_x + myPos_x;
1008 mySize_y = mySize_y + myPos_y;
1010 // bottom/right screen edges
1011 if(myPos_x + mySize_x > vid_conwidth)
1012 mySize_x = vid_conwidth - myPos_x;
1013 if(myPos_y + mySize_y > vid_conheight)
1014 mySize_y = vid_conheight - myPos_y;
1016 if(cvar("hud_configure_checkcollisions_debug"))
1017 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
1019 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
1020 if(autocvar_hud_configure_grid)
1022 mySize_x = floor((mySize_x/vid_conwidth)/bound(0.005, autocvar_hud_configure_grid_x, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_x, 0.2) * vid_conwidth;
1023 mySize_y = floor((mySize_y/vid_conheight)/bound(0.005, autocvar_hud_configure_grid_y, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_y, 0.2) * vid_conheight;
1026 if(autocvar_hud_configure_checkcollisions)
1027 mySize = HUD_Panel_CheckResize(id, mySize, resizeorigin);
1029 // 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)
1030 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1031 mySize_y = max(0.025 * vid_conheight, mySize_y);
1033 // do another pos check, as size might have changed by now
1034 if(resizeCorner == 1) {
1035 myPos_x = resizeorigin_x - mySize_x;
1036 myPos_y = resizeorigin_y - mySize_y;
1037 } else if(resizeCorner == 2) {
1038 myPos_x = resizeorigin_x;
1039 myPos_y = resizeorigin_y - mySize_y;
1040 } else if(resizeCorner == 3) {
1041 myPos_x = resizeorigin_x - mySize_x;
1042 myPos_y = resizeorigin_y;
1043 } else { // resizeCorner == 4
1044 myPos_x = resizeorigin_x;
1045 myPos_y = resizeorigin_y;
1048 if(cvar("hud_configure_checkcollisions_debug"))
1049 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
1052 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
1053 cvar_set(strcat("hud_", panel_name, "_size"), s);
1055 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
1056 cvar_set(strcat("hud_", panel_name, "_pos"), s);
1060 float prevMouseClicked; // previous state
1061 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
1062 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
1065 float menu_enabled_time;
1066 float pressed_key_time;
1067 void HUD_Panel_Arrow_Action(float nPrimary)
1069 if (highlightedPanel_prev == -1 || mouseClicked)
1072 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
1075 if(autocvar_hud_configure_grid)
1077 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
1079 if (hudShiftState & S_SHIFT)
1080 step = bound(0.005, autocvar_hud_configure_grid_y, 0.2) * vid_conheight;
1082 step = 2 * bound(0.005, autocvar_hud_configure_grid_y, 0.2) * vid_conheight;
1086 if (hudShiftState & S_SHIFT)
1087 step = bound(0.005, autocvar_hud_configure_grid_x, 0.2) * vid_conwidth;
1089 step = 2 * bound(0.005, autocvar_hud_configure_grid_x, 0.2) * vid_conwidth;
1094 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
1095 step = vid_conheight;
1097 step = vid_conwidth;
1098 if (hudShiftState & S_SHIFT)
1099 step = (step / 256); // more precision
1101 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
1104 highlightedPanel = highlightedPanel_prev;
1106 HUD_Panel_UpdateCvarsForId(highlightedPanel)
1108 if (hudShiftState & S_ALT) // resize
1110 highlightedAction = 1;
1111 if(nPrimary == K_UPARROW)
1113 else if(nPrimary == K_RIGHTARROW)
1115 else if(nPrimary == K_LEFTARROW)
1117 else // if(nPrimary == K_DOWNARROW)
1120 // ctrl+arrow reduces the size, instead of increasing it
1121 // Note that ctrl disables collisions check too, but it's fine
1122 // since we don't collide with anything reducing the size
1123 if (hudShiftState & S_CTRL) {
1125 resizeCorner = 5 - resizeCorner;
1129 mySize = panel_size;
1130 panel_click_resizeorigin = panel_pos;
1131 if(resizeCorner == 1) {
1132 panel_click_resizeorigin += mySize;
1134 } else if(resizeCorner == 2) {
1135 panel_click_resizeorigin_y += mySize_y;
1137 } else if(resizeCorner == 3) {
1138 panel_click_resizeorigin_x += mySize_x;
1140 } else { // resizeCorner == 4
1143 HUD_Panel_SetPosSize(highlightedPanel, mySize);
1147 highlightedAction = 2;
1150 if(nPrimary == K_UPARROW)
1152 else if(nPrimary == K_DOWNARROW)
1154 else if(nPrimary == K_LEFTARROW)
1156 else // if(nPrimary == K_RIGHTARROW)
1159 HUD_Panel_SetPos(highlightedPanel, pos);
1163 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1165 if(!autocvar__hud_configure)
1168 // allow console bind to work
1171 con_keys = findkeysforcommand("toggleconsole");
1172 keys = tokenize(con_keys);
1174 float hit_con_bind, i;
1175 for (i = 0; i < keys; ++i)
1177 if(nPrimary == stof(argv(i)))
1181 if(bInputType == 0) {
1182 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1183 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1184 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1186 else if(bInputType == 1) {
1187 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1188 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1189 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1192 if(nPrimary == K_MOUSE1)
1194 if(bInputType == 0) { // key pressed
1198 else if(bInputType == 1) {// key released
1203 else if(nPrimary == K_ESCAPE)
1205 if (bInputType == 1)
1207 disable_menu_alphacheck = 1;
1209 menu_enabled_time = time;
1210 localcmd("menu_showhudexit\n");
1212 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1214 if (bInputType == 1)
1216 pressed_key_time = 0;
1219 else if (pressed_key_time == 0)
1220 pressed_key_time = time;
1222 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1224 else if(hit_con_bind)
1227 return true; // Suppress ALL other input
1230 float HUD_Panel_HighlightCheck()
1236 for(i = 0; i < HUD_PANEL_NUM; ++i)
1238 panelPos = panel_pos;
1239 panelSize = panel_size;
1240 border = 10; // FORCED border so a small border size doesn't mean you can't resize
1243 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1247 // resize from topleft border
1248 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)
1252 // resize from topright border
1253 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)
1257 // resize from bottomleft border
1258 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)
1262 // resize from bottomright border
1263 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)
1271 void HUD_Panel_Highlight()
1277 for(i = 0; i < HUD_PANEL_NUM; ++i)
1279 panelPos = panel_pos;
1280 panelSize = panel_size;
1281 border = 10; // FORCED border so a small border size doesn't mean you can't resize
1284 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1286 highlightedPanel = i;
1287 highlightedAction = 1;
1288 panel_click_distance = mousepos - panelPos;
1291 // resize from topleft border
1292 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)
1294 highlightedPanel = i;
1295 highlightedAction = 2;
1297 panel_click_distance = mousepos - panelPos;
1298 panel_click_resizeorigin = panelPos + panelSize;
1301 // resize from topright border
1302 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)
1304 highlightedPanel = i;
1305 highlightedAction = 2;
1307 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1308 panel_click_distance_y = mousepos_y - panelPos_y;
1309 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1312 // resize from bottomleft border
1313 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)
1315 highlightedPanel = i;
1316 highlightedAction = 2;
1318 panel_click_distance_x = mousepos_x - panelPos_x;
1319 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1320 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1323 // resize from bottomright border
1324 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)
1326 highlightedPanel = i;
1327 highlightedAction = 2;
1329 panel_click_distance = panelSize - mousepos + panelPos;
1330 panel_click_resizeorigin = panelPos;
1336 float highlightcheck;
1337 void HUD_Panel_Mouse()
1339 // 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
1340 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1341 disable_menu_alphacheck = 0;
1342 if (cvar("_menu_alpha") == 0 && time - menu_enabled_time > 0.5)
1346 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1347 print("Highlighted: ", ftos(highlightedPanel), "\n");
1348 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1351 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1352 highlightedPanel_prev = highlightedPanel;
1353 highlightedPanel = -1;
1354 highlightedAction = 0;
1357 mousepos = mousepos + getmousepos();
1359 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1360 mousepos_y = bound(0, mousepos_y, vid_conheight);
1364 if(prevMouseClicked == 0)
1365 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1367 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
1369 if(highlightedAction == 1)
1370 HUD_Panel_SetPos(highlightedPanel, mousepos - panel_click_distance);
1371 else if(highlightedAction == 2)
1374 if(resizeCorner == 1) {
1375 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1376 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1377 } else if(resizeCorner == 2) {
1378 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1379 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1380 } else if(resizeCorner == 3) {
1381 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1382 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1383 } else { // resizeCorner == 4
1384 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1385 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1387 HUD_Panel_SetPosSize(highlightedPanel, mySize);
1390 // doubleclick check
1391 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1393 mouseClicked = 0; // to prevent spam, I guess.
1394 disable_menu_alphacheck = 2;
1396 menu_enabled_time = time;
1397 localcmd("menu_showhudoptions ", ftos(highlightedPanel), "\n");
1400 if(prevMouseClicked == 0)
1402 prevMouseClickedTime = time;
1403 prevMouseClickedPos = mousepos;
1408 highlightcheck = HUD_Panel_HighlightCheck();
1410 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1413 cursorsize = '32 32 0';
1415 if(highlightcheck == 0)
1416 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1417 else if(highlightcheck == 1)
1418 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1419 else if(highlightcheck == 2)
1420 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1422 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1424 prevMouseClicked = mouseClicked;
1427 // Weapon icons (#0)
1429 float weaponspace[10];
1430 void HUD_WeaponIcons_Clear()
1433 for(idx = 0; idx < 10; ++idx)
1434 weaponspace[idx] = 0;
1437 entity weaponorder[WEP_MAXCOUNT];
1438 void weaponorder_swap(float i, float j, entity pass)
1442 weaponorder[i] = weaponorder[j];
1446 string weaponorder_cmp_str_save;
1447 string weaponorder_cmp_str;
1448 float weaponorder_cmp(float i, float j, entity pass)
1451 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1452 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1453 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)
1456 void HUD_WeaponIcons(void)
1458 float id = HUD_PANEL_WEAPONICONS;
1459 HUD_Panel_UpdateCvarsForId(id);
1460 float alpha, stat_weapons; // "constants"
1461 vector pos, mySize, accuracy_color;
1462 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1464 pos = stov(cvar_string("hud_weaponicons_pos"));
1465 pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
1467 mySize = panel_size;
1469 stat_weapons = getstati(STAT_WEAPONS);
1471 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1473 self = get_weaponinfo(i);
1474 if(self.impulse >= 0)
1478 // TODO make this configurable
1479 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1481 if(weaponorder_cmp_str != weaponorder_cmp_str_save)
1483 if(weaponorder_cmp_str_save)
1484 strunzone(weaponorder_cmp_str_save);
1485 weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
1487 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1489 self = get_weaponinfo(i);
1490 if(self.impulse >= 0)
1492 weaponorder[weapon_cnt] = self;
1496 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1499 HUD_Panel_DrawBg(id, pos, mySize, 0);
1500 if(panel_bg_padding)
1502 pos += '1 1 0' * panel_bg_padding;
1503 mySize -= '2 2 0' * panel_bg_padding;
1507 weapon_stats = getstati(STAT_DAMAGE_HITS);
1508 weapon_number = weapon_stats & 63;
1509 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1511 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1512 weapon_number = weapon_stats & 63;
1513 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1515 if(cvar_or("hud_weaponicons_fade", 1))
1517 fade = 3.2 - 2 * (time - weapontime);
1518 fade = bound(0.7, fade, 1);
1523 HUD_WeaponIcons_Clear();
1525 float rows, columns;
1526 rows = mySize_y/mySize_x;
1527 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1528 // ^^^ weapon icon aspect goes here
1530 columns = ceil(WEP_COUNT/rows);
1535 when = cvar("hud_weaponicons_complainbubble_time");
1537 fadetime = cvar("hud_weaponicons_complainbubble_fadetime");
1539 for(i = 0; i < weapon_cnt; ++i)
1541 self = weaponorder[i];
1542 weapid = self.impulse;
1544 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1546 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1547 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1549 // draw background behind currently selected weapon
1550 if(self.weapon == activeweapon)
1551 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);
1553 // draw the weapon accuracy on the HUD
1554 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1557 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1559 accuracy_color = HUD_AccuracyColor(weapon_stats);
1561 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), accuracy_color, panel_fg_alpha, DRAWFLAG_NORMAL);
1564 // draw the weapon icon
1565 if((self.impulse >= 0) && (stat_weapons & self.weapons))
1567 drawpic_aspect_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), strcat("weapon", self.netname), eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1569 if(cvar_or("hud_weaponicons_number", 1))
1570 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);
1572 // draw a "ghost weapon icon" if you don't have the weapon
1575 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);
1578 // draw the complain message
1579 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && cvar("hud_weaponicons_complainbubble"))
1583 if(complain_weapon_time + when > time)
1586 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1590 if(complain_weapon_time + when > time)
1596 vector complain_bubble_size = '100 50 0' * bound(0.25, cvar("hud_weaponicons_complainbubble_size"), 2);
1597 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);
1601 if(complain_weapon_type == 0) {
1602 s = "Out of ammo for the";
1605 else if(complain_weapon_type == 1) {
1606 s = "You don't have the";
1610 s = "Map doesn't have the";
1613 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);
1614 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);
1629 float GetAmmoStat(float i)
1633 case 0: return STAT_SHELLS;
1634 case 1: return STAT_NAILS;
1635 case 2: return STAT_ROCKETS;
1636 case 3: return STAT_CELLS;
1637 case 4: return STAT_FUEL;
1642 float GetAmmoItemCode(float i)
1646 case 0: return IT_SHELLS;
1647 case 1: return IT_NAILS;
1648 case 2: return IT_ROCKETS;
1649 case 3: return IT_CELLS;
1650 case 4: return IT_FUEL;
1655 string GetAmmoPicture(float i)
1659 case 0: return "ammo_shells";
1660 case 1: return "ammo_bullets";
1661 case 2: return "ammo_rockets";
1662 case 3: return "ammo_cells";
1663 case 4: return "ammo_fuel";
1668 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1671 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1672 if(autocvar__hud_configure)
1682 if(currently_selected)
1687 vector newSize, newPos;
1688 if(mySize_x/mySize_y > 3)
1690 newSize_x = 3 * mySize_y;
1691 newSize_y = mySize_y;
1693 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1698 newSize_y = 1/3 * mySize_x;
1699 newSize_x = mySize_x;
1701 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1705 vector picpos, numpos;
1706 if(cvar("hud_inventory_iconalign"))
1709 picpos = newPos + eX * 2 * newSize_y;
1713 numpos = newPos + eX * newSize_y;
1717 if (currently_selected)
1718 drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1720 drawfont = hud_bigfont;
1721 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1722 drawfont = hud_font;
1723 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1726 void HUD_Inventory(void)
1728 float id = HUD_PANEL_INVENTORY;
1729 HUD_Panel_UpdateCvarsForId(id);
1730 float i, currently_selected;
1734 mySize = panel_size;
1736 HUD_Panel_DrawBg(id, pos, mySize, 0);
1737 if(panel_bg_padding)
1739 pos += '1 1 0' * panel_bg_padding;
1740 mySize -= '2 2 0' * panel_bg_padding;
1743 float rows, columns;
1744 rows = mySize_y/mySize_x;
1745 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1746 // ^^^ ammo item aspect goes here
1748 columns = ceil(AMMO_COUNT/rows);
1752 for (i = 0; i < AMMO_COUNT; ++i) {
1753 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1754 if(cvar("hud_inventory_onlycurrent")) {
1755 if(autocvar__hud_configure)
1757 if (currently_selected || autocvar__hud_configure)
1758 DrawAmmoItem(pos, mySize, i, currently_selected);
1761 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);
1766 column = column + 1;
1772 void DrawNumIcon(float id, vector myPos, vector mySize, float x, string icon, float left, vector color)
1774 vector newSize, newPos;
1775 if(mySize_x/mySize_y > 3)
1777 newSize_x = 3 * mySize_y;
1778 newSize_y = mySize_y;
1780 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1785 newSize_y = 1/3 * mySize_x;
1786 newSize_x = mySize_x;
1788 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1792 vector picpos, numpos;
1794 iconalign = cvar(strcat("hud_", panel_name, "_iconalign"));
1797 if(iconalign == 1 || iconalign == 3) // right align
1800 picpos = newPos + eX * 2 * newSize_y;
1804 numpos = newPos + eX * newSize_y;
1810 if(iconalign == 0 || iconalign == 3) // left align
1812 numpos = newPos + eX * newSize_y;
1818 picpos = newPos + eX * 2 * newSize_y;
1822 drawfont = hud_bigfont;
1823 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, newSize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1824 drawfont = hud_font;
1825 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1830 void HUD_Powerups(void) {
1831 float id = HUD_PANEL_POWERUPS;
1832 HUD_Panel_UpdateCvarsForId(id);
1834 stat_items = getstati(STAT_ITEMS);
1836 if(!autocvar__hud_configure)
1838 if not(stat_items & IT_STRENGTH)
1839 if not(stat_items & IT_INVINCIBLE)
1842 if (getstati(STAT_HEALTH) <= 0)
1848 mySize = panel_size;
1850 HUD_Panel_DrawBg(id, pos, mySize, 0);
1851 if(panel_bg_padding)
1853 pos += '1 1 0' * panel_bg_padding;
1854 mySize -= '2 2 0' * panel_bg_padding;
1857 float strength_time, shield_time;
1859 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1860 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1862 if(autocvar__hud_configure)
1868 vector barpos, barsize;
1872 string leftname, rightname;
1873 float leftcnt, rightcnt;
1874 float leftexact, rightexact;
1875 float leftalpha, rightalpha;
1876 if (cvar(strcat("hud_", panel_name, "_flip"))) {
1877 leftname = "strength";
1878 leftcnt = ceil(strength_time);
1879 leftexact = strength_time;
1881 rightname = "shield";
1882 rightcnt = ceil(shield_time);
1883 rightexact = shield_time;
1885 leftname = "shield";
1886 leftcnt = ceil(shield_time);
1887 leftexact = shield_time;
1889 rightname = "strength";
1890 rightcnt = ceil(strength_time);
1891 rightexact = strength_time;
1893 leftalpha = bound(0, leftexact, 1);
1894 rightalpha = bound(0, rightexact, 1);
1896 float baralign, iconalign;
1897 baralign = cvar(strcat("hud_", panel_name, "_baralign"));
1898 iconalign = cvar(strcat("hud_", panel_name, "_iconalign"));
1900 if (mySize_x/mySize_y > 4)
1904 if(baralign == 1 || baralign == 3) { // right align
1905 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1906 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1907 } else { // left align
1909 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1912 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * panel_fg_alpha, DRAWFLAG_NORMAL);
1913 DrawNumIcon(id, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1');
1916 // 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));
1918 // drawpic_aspect_skin(picpos, leftname, eX * (1/6) * mySize_x + eY * mySize_y, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1923 if(baralign == 0 || baralign == 3) { // left align
1924 barpos = pos + eX * 0.5 * mySize_x;
1925 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1926 } else { // right align
1927 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1928 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1931 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * panel_fg_alpha, DRAWFLAG_NORMAL);
1932 DrawNumIcon(id, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1');
1935 else if (mySize_x/mySize_y > 1.5)
1939 if(baralign == 1 || baralign == 3) { // right align
1940 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1941 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1942 } else { // left align
1944 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1947 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * panel_fg_alpha, DRAWFLAG_NORMAL);
1948 DrawNumIcon(id, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1');
1953 if(baralign == 0 || baralign == 3) { // left align
1954 barpos = pos + eY * 0.5 * mySize_y;
1955 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1956 } else { // right align
1957 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1958 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1961 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * panel_fg_alpha, DRAWFLAG_NORMAL);
1962 DrawNumIcon(id, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1');
1969 if(baralign == 1 || baralign == 3) { // down align
1970 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1971 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1972 } else { // up align
1974 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1977 if(iconalign == 1 || iconalign == 3) { // down align
1978 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
1979 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
1980 } else { // up align
1981 picpos = pos + eX * 0.05 * mySize_x;
1982 numpos = pos + eY * 0.4 * mySize_x;
1985 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * panel_fg_alpha, DRAWFLAG_NORMAL);
1987 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));
1989 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1990 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);
1995 if(baralign == 0 || baralign == 3) { // up align
1996 barpos = pos + eX * 0.5 * mySize_x;
1997 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1998 } else { // down align
1999 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
2000 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2003 if(iconalign == 0 || iconalign == 3) { // up align
2004 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2005 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2006 } else { // down align
2007 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2008 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2011 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * panel_fg_alpha, DRAWFLAG_NORMAL);
2013 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));
2015 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2016 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);
2021 // Health/armor (#3)
2023 void HUD_HealthArmor(void)
2025 float id = HUD_PANEL_HEALTHARMOR;
2026 HUD_Panel_UpdateCvarsForId(id);
2029 mySize = panel_size;
2031 HUD_Panel_DrawBg(id, pos, mySize, 0);
2032 if(panel_bg_padding)
2034 pos += '1 1 0' * panel_bg_padding;
2035 mySize -= '2 2 0' * panel_bg_padding;
2038 float armor, health;
2039 armor = getstati(STAT_ARMOR);
2040 health = getstati(STAT_HEALTH);
2043 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
2045 if(autocvar__hud_configure)
2055 vector barpos, barsize;
2059 float baralign, iconalign;
2060 baralign = cvar(strcat("hud_", panel_name, "_baralign"));
2061 iconalign = cvar(strcat("hud_", panel_name, "_iconalign"));
2063 if(cvar("hud_healtharmor") == 2) // combined health and armor display
2066 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2071 if(baralign == 1 || baralign == 3) { // right align
2072 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2073 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2074 } else { // left align
2076 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2080 if(v_z) // NOT fully armored
2082 biggercount = "health";
2083 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("health"), cvar("hud_progressbar_alpha") * panel_fg_alpha, DRAWFLAG_NORMAL);
2085 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);
2089 biggercount = "armor";
2090 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("armor"), cvar("hud_progressbar_alpha") * panel_fg_alpha, DRAWFLAG_NORMAL);
2092 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);
2094 DrawNumIcon(id, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200));
2099 if(baralign == 0 || baralign == 3) { // left align
2100 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2101 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2104 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2106 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2111 string leftname, rightname;
2112 float leftcnt, rightcnt;
2113 float leftactive, rightactive;
2114 float leftalpha, rightalpha;
2115 if (cvar(strcat("hud_", panel_name, "_flip"))) { // old style layout with armor left/top of health
2120 leftalpha = min((armor+10)/55, 1);
2122 rightname = "health";
2127 leftname = "health";
2132 rightname = "armor";
2136 rightalpha = min((armor+10)/55, 1);
2139 if (mySize_x/mySize_y > 4)
2143 if(baralign == 1 || baralign == 3) { // right align
2144 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2145 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2146 } else { // left align
2148 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2151 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * panel_fg_alpha, DRAWFLAG_NORMAL);
2152 DrawNumIcon(id, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2157 if(baralign == 0 || baralign == 3) { // left align
2158 barpos = pos + eX * 0.5 * mySize_x;
2159 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2160 } else { // right align
2161 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2162 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2165 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * panel_fg_alpha, DRAWFLAG_NORMAL);
2166 DrawNumIcon(id, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(leftcnt, 200));
2171 if(baralign == 0 || baralign == 3) { // left align
2172 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2173 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2176 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2178 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2181 else if (mySize_x/mySize_y > 1.5)
2185 if(baralign == 1 || baralign == 3) { // right align
2186 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2187 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2188 } else { // left align
2190 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2193 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * panel_fg_alpha, DRAWFLAG_NORMAL);
2194 DrawNumIcon(id, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2199 if(baralign == 0 || baralign == 3) { // left align
2200 barpos = pos + eY * 0.5 * mySize_y;
2201 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2202 } else { // right align
2203 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2204 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2207 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * panel_fg_alpha, DRAWFLAG_NORMAL);
2208 DrawNumIcon(id, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(leftcnt, 200));
2213 if(baralign == 0 || baralign == 3) { // left align
2214 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2215 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2218 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2220 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2227 if(baralign == 1 || baralign == 3) { // down align
2228 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2229 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2230 } else { // up align
2232 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2235 if(iconalign == 1 || iconalign == 3) { // down align
2236 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2237 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2238 } else { // up align
2239 picpos = pos + eX * 0.05 * mySize_x;
2240 numpos = pos + eY * 0.4 * mySize_x;
2243 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * panel_fg_alpha, DRAWFLAG_NORMAL);
2244 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2245 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);
2250 if(baralign == 0 || baralign == 3) { // up align
2251 barpos = pos + eX * 0.5 * mySize_x;
2252 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2253 } else { // down align
2254 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2255 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2258 if(iconalign == 0 || iconalign == 3) { // up align
2259 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2260 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2261 } else { // down align
2262 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2263 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2266 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * panel_fg_alpha, DRAWFLAG_NORMAL);
2267 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2268 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);
2273 if(baralign == 0 || baralign == 3) { // left align
2275 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2277 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2278 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2280 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor("fuel"), panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2287 // Notification area (#4)
2290 string Weapon_SuicideMessage(float deathtype)
2292 w_deathtype = deathtype;
2293 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2294 return w_deathtypestring;
2297 string Weapon_KillMessage(float deathtype)
2299 w_deathtype = deathtype;
2300 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2301 return w_deathtypestring;
2304 float killnotify_times[10];
2305 float killnotify_deathtype[10];
2306 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2307 string killnotify_attackers[10];
2308 string killnotify_victims[10];
2309 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2312 for (i = 9; i > 0; --i) {
2313 killnotify_times[i] = killnotify_times[i-1];
2314 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2315 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2316 if(killnotify_attackers[i])
2317 strunzone(killnotify_attackers[i]);
2318 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2319 if(killnotify_victims[i])
2320 strunzone(killnotify_victims[i]);
2321 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2323 killnotify_times[0] = time;
2324 killnotify_deathtype[0] = wpn;
2325 killnotify_actiontype[0] = actiontype;
2326 if(killnotify_attackers[0])
2327 strunzone(killnotify_attackers[0]);
2328 killnotify_attackers[0] = strzone(attacker);
2329 if(killnotify_victims[0])
2330 strunzone(killnotify_victims[0]);
2331 killnotify_victims[0] = strzone(victim);
2334 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2338 alsoprint = (cvar("hud_notify_print") || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2340 if(msg == MSG_SUICIDE) {
2342 w = DEATH_WEAPONOF(type);
2344 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2346 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2347 } else if (type == DEATH_KILL) {
2348 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2350 print ("^1",s1, "^1 couldn't take it anymore\n");
2351 } else if (type == DEATH_ROT) {
2352 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2354 print ("^1",s1, "^1 died\n");
2355 } else if (type == DEATH_NOAMMO) {
2356 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2358 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2359 } else if (type == DEATH_CAMP) {
2360 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2362 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2363 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2364 HUD_KillNotify_Push(s1, "", 0, type);
2366 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2367 } else if (type == DEATH_CHEAT) {
2368 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2370 print ("^1",s1, "^1 unfairly eliminated themself\n");
2371 } else if (type == DEATH_FIRE) {
2372 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2374 print ("^1",s1, "^1 burned to death\n");
2375 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2376 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2378 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2381 if (stof(s2) > 2) // killcount > 2
2382 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2383 } else if(msg == MSG_KILL) {
2384 w = DEATH_WEAPONOF(type);
2386 HUD_KillNotify_Push(s2, s1, 1, w);
2388 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2390 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2391 HUD_KillNotify_Push(s1, s2, 1, type);
2394 if(cvar("cl_gentle")) {
2395 print ("^1", s1, "^1 took action against a team mate\n");
2397 print ("^1", s1, "^1 mows down a team mate\n");
2400 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2401 if(cvar("cl_gentle"))
2402 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2404 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2406 else if (stof(s2) > 2) {
2407 if(cvar("cl_gentle"))
2408 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2410 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2413 else if(type == KILL_FIRST_BLOOD)
2414 print("^1",s1, "^1 drew first blood", "\n");
2416 else if (type == DEATH_TELEFRAG)
2417 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2418 else if (type == DEATH_DROWN) {
2419 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2421 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2423 else if (type == DEATH_SLIME) {
2424 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2426 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2428 else if (type == DEATH_LAVA) {
2429 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2431 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2433 else if (type == DEATH_FALL) {
2434 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2436 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2438 else if (type == DEATH_SHOOTING_STAR) {
2439 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2441 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2443 else if (type == DEATH_SWAMP) {
2444 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2446 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2448 else if (type == DEATH_HURTTRIGGER)
2450 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2452 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2453 } else if(type == DEATH_SBCRUSH) {
2454 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2456 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2457 } else if(type == DEATH_SBMINIGUN) {
2458 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2460 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2461 } else if(type == DEATH_SBROCKET) {
2462 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2464 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2465 } else if(type == DEATH_SBBLOWUP) {
2466 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2468 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2469 } else if(type == DEATH_WAKIGUN) {
2470 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2472 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2473 } else if(type == DEATH_WAKIROCKET) {
2474 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2476 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2477 } else if(type == DEATH_WAKIBLOWUP) {
2478 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2480 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2481 } else if(type == DEATH_TURRET) {
2482 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2484 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2485 } else if(type == DEATH_TOUCHEXPLODE) {
2486 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2488 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2489 } else if(type == DEATH_CHEAT) {
2490 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2492 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2493 } else if (type == DEATH_FIRE) {
2494 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2496 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2497 } else if (type == DEATH_CUSTOM) {
2498 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2500 print ("^1",s1, "^1 ", s2, "\n");
2502 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2504 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2506 } else if(msg == MSG_SPREE) {
2507 if(type == KILL_END_SPREE) {
2508 if(cvar("cl_gentle"))
2509 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2511 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2512 } else if(type == KILL_SPREE) {
2513 if(cvar("cl_gentle"))
2514 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2516 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2517 } else if(type == KILL_SPREE_3) {
2518 if(cvar("cl_gentle"))
2519 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2521 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2522 } else if(type == KILL_SPREE_5) {
2523 if(cvar("cl_gentle"))
2524 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2526 print (s1,"^7 unleashes ^1RAGE\n");
2527 } else if(type == KILL_SPREE_10) {
2528 if(cvar("cl_gentle"))
2529 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2531 print (s1,"^7 starts the ^1MASSACRE!\n");
2532 } else if(type == KILL_SPREE_15) {
2533 if(cvar("cl_gentle"))
2534 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2536 print (s1,"^7 executes ^1MAYHEM!\n");
2537 } else if(type == KILL_SPREE_20) {
2538 if(cvar("cl_gentle"))
2539 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2541 print (s1,"^7 is a ^1BERSERKER!\n");
2542 } else if(type == KILL_SPREE_25) {
2543 if(cvar("cl_gentle"))
2544 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2546 print (s1,"^7 inflicts ^1CARNAGE!\n");
2547 } else if(type == KILL_SPREE_30) {
2548 if(cvar("cl_gentle"))
2549 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2551 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2553 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2554 if (type == DEATH_DROWN) {
2555 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2558 if(cvar("cl_gentle"))
2559 print ("^1",s1, "^1 was in the water for too long\n");
2561 print ("^1",s1, "^1 drowned\n");
2563 } else if (type == DEATH_SLIME) {
2564 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2566 print ("^1",s1, "^1 was slimed\n");
2567 } else if (type == DEATH_LAVA) {
2568 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2571 if(cvar("cl_gentle"))
2572 print ("^1",s1, "^1 found a hot place\n");
2574 print ("^1",s1, "^1 turned into hot slag\n");
2576 } else if (type == DEATH_FALL) {
2577 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2580 if(cvar("cl_gentle"))
2581 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2583 print ("^1",s1, "^1 hit the ground with a crunch\n");
2585 } else if (type == DEATH_SHOOTING_STAR) {
2586 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2588 print ("^1",s1, "^1 became a shooting star\n");
2589 } else if (type == DEATH_SWAMP) {
2590 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2593 if(cvar("cl_gentle"))
2594 print ("^1",s1, "^1 discovered a swamp\n");
2596 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2598 } else if(type == DEATH_TURRET) {
2599 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2601 print ("^1",s1, "^1 was mowed down by a turret \n");
2602 } else if (type == DEATH_CUSTOM) {
2603 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2605 print ("^1",s1, "^1 ", s2, "\n");
2606 } else if (type == DEATH_HURTTRIGGER) {
2607 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2609 print ("^1",s1, "^1 was in the wrong place\n");
2610 } else if(type == DEATH_TOUCHEXPLODE) {
2611 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2613 print ("^1",s1, "^1 died in an accident\n");
2614 } else if(type == DEATH_CHEAT) {
2615 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2617 print ("^1",s1, "^1 was unfairly eliminated\n");
2618 } else if(type == DEATH_FIRE) {
2619 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2622 if(cvar("cl_gentle"))
2623 print ("^1",s1, "^1 felt a little hot\n");
2625 print ("^1",s1, "^1 burnt to death\n");
2628 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2631 if(cvar("cl_gentle"))
2632 print ("^1",s1, "^1 needs a restart\n");
2634 print ("^1",s1, "^1 died\n");
2637 } else if(msg == MSG_KILL_ACTION_SPREE) {
2638 if(cvar("cl_gentle"))
2639 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2641 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2642 } else if(msg == MSG_INFO) {
2643 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2644 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2645 print(s1, "^7 got the ", s2, "\n");
2646 } else if(type == INFO_LOSTFLAG) {
2647 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2648 print(s1, "^7 lost the ", s2, "\n");
2649 } else if(type == INFO_PICKUPFLAG) {
2650 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2651 print(s1, "^7 picked up the ", s2, "\n");
2652 } else if(type == INFO_RETURNFLAG) {
2653 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2654 print(s1, "^7 returned the ", s2, "\n");
2659 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2661 void HUD_Centerprint(string s1, string s2, float type, float msg)
2663 if(msg == MSG_SUICIDE) {
2664 if (type == DEATH_TEAMCHANGE) {
2665 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2666 } else if (type == DEATH_AUTOTEAMCHANGE) {
2667 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2668 } else if (type == DEATH_CAMP) {
2669 if(cvar("cl_gentle"))
2670 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2672 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2673 } else if (type == DEATH_NOAMMO) {
2674 if(cvar("cl_gentle"))
2675 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2677 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2678 } else if (type == DEATH_ROT) {
2679 if(cvar("cl_gentle"))
2680 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2682 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2683 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2684 if(cvar("cl_gentle"))
2685 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2687 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2688 } else if (type == DEATH_QUIET) {
2690 } else if (type == DEATH_KILL) {
2691 if(cvar("cl_gentle"))
2692 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2694 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2696 } else if(msg == MSG_KILL) {
2697 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2698 if(cvar("cl_gentle")) {
2699 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2701 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2703 } else if (type == KILL_FIRST_BLOOD) {
2704 if(cvar("cl_gentle")) {
2705 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2707 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2709 } else if (type == KILL_FIRST_VICTIM) {
2710 if(cvar("cl_gentle")) {
2711 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2713 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2715 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2716 if(cvar("cl_gentle")) {
2717 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2719 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2721 } else if (type == KILL_TYPEFRAGGED) {
2722 if(cvar("cl_gentle")) {
2723 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2725 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2727 } else if (type == KILL_FRAG) {
2728 if(cvar("cl_gentle")) {
2729 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2731 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2733 } else if (type == KILL_FRAGGED) {
2734 if(cvar("cl_gentle")) {
2735 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2737 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2740 } else if(msg == MSG_KILL_ACTION) {
2741 // TODO: invent more centerprints here?
2742 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2746 void HUD_Notify (void)
2748 float id = HUD_PANEL_NOTIFY;
2749 HUD_Panel_UpdateCvarsForId(id);
2752 mySize = panel_size;
2754 HUD_Panel_DrawBg(id, pos, mySize, 0);
2755 if(panel_bg_padding)
2757 pos += '1 1 0' * panel_bg_padding;
2758 mySize -= '2 2 0' * panel_bg_padding;
2761 float entries, height;
2762 entries = bound(1, floor(14 * mySize_y/mySize_x), 12);
2763 height = mySize_y/entries;
2764 entries -= 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2767 fontsize = '0.5 0.5 0' * height;
2771 when = cvar("hud_notify_time");
2773 fadetime = cvar("hud_notify_fadetime");
2777 vector pos_attacker, pos_victim;
2779 float width_attacker, width_victim;
2780 string attacker, victim;
2783 for(j = 0; j < entries; ++j)
2785 if(cvar("hud_notify_flip"))
2787 else // rather nasty hack for ordering items from the bottom up
2788 i = entries - j - 1;
2789 if(cvar("hud_notify_info_top"))
2790 i += 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2794 if(killnotify_times[j] + when > time)
2797 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2801 if(killnotify_times[j] + when > time)
2807 // TODO: maybe print in team colors?
2808 // TODO: maybe this could be cleaned up somehow...
2809 // TODO: less copypaste code below
2812 if(killnotify_actiontype[j] == 0 && !autocvar__hud_configure)
2814 attacker = textShortenToWidth(killnotify_attackers[j], mySize_x - 2 * height, fontsize, stringwidth_colors);
2816 width_attacker = stringwidth(attacker, TRUE, fontsize);
2817 pos_attacker = pos + eX * 0.5 * (mySize_x - width_attacker + 2 * height) + eY * 0.5 * fontsize_y + eY * i * height;
2819 weap_pos = pos + eX * 0.5 * (mySize_x - width_attacker) - eX * height + eY * i * height;
2820 if(killnotify_deathtype[j] == DEATH_GENERIC)
2822 drawpic_aspect_skin(weap_pos, "notify_death", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2823 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2825 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2827 drawpic_aspect_skin(weap_pos, "notify_outofammo", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2828 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2830 else if(killnotify_deathtype[j] == DEATH_KILL)
2832 drawpic_aspect_skin(weap_pos, "notify_selfkill", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2833 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2835 else if(killnotify_deathtype[j] == DEATH_CAMP)
2837 drawpic_aspect_skin(weap_pos, "notify_camping", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2838 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2840 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2842 drawpic_aspect_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2843 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2845 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2847 drawpic_aspect_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2848 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2850 else if(killnotify_deathtype[j] == DEATH_DROWN)
2852 drawpic_aspect_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2853 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2855 else if(killnotify_deathtype[j] == DEATH_SLIME)
2857 drawpic_aspect_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2858 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2860 else if(killnotify_deathtype[j] == DEATH_LAVA)
2862 drawpic_aspect_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2863 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2865 else if(killnotify_deathtype[j] == DEATH_FALL)
2867 drawpic_aspect_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2868 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2870 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2872 drawpic_aspect_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2873 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2875 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2877 drawpic_aspect_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2878 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2880 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2882 if(killnotify_victims[j] == "^1RED^7 flag")
2886 drawpic_aspect_skin(weap_pos, strcat("flag_", s, "_carrying"), '1 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2887 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2889 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2891 if(killnotify_victims[j] == "^1RED^7 flag")
2895 drawpic_aspect_skin(weap_pos, strcat("flag_", s, "_taken"), '1 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2896 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2898 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2900 if(killnotify_victims[j] == "^1RED^7 flag")
2904 drawpic_aspect_skin(weap_pos, strcat("flag_", s, "_lost"), '1 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2905 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2908 // X [did action to] Y
2911 if(autocvar__hud_configure)
2913 attacker = textShortenToWidth("Player1", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2914 victim = textShortenToWidth("Player2", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2915 a = bound(0, (when - j) / 4, 1);
2919 attacker = textShortenToWidth(killnotify_attackers[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2920 victim = textShortenToWidth(killnotify_victims[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2922 width_attacker = stringwidth(attacker, TRUE, fontsize);
2923 width_victim = stringwidth(victim, TRUE, fontsize);
2924 pos_attacker = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_attacker) + eY * 0.5 * fontsize_y + eY * i * height;
2925 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;
2926 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2928 if(autocvar__hud_configure) // example actions for config mode
2930 drawpic_aspect_skin(weap_pos, strcat("weapon", "electro"), '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2931 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2932 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2934 else if(WEP_VALID(killnotify_deathtype[j]))
2936 self = get_weaponinfo(killnotify_deathtype[j]);
2937 drawpic_aspect_skin(weap_pos, strcat("weapon", self.netname), '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2938 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2939 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2941 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2943 drawpic_aspect_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2944 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2945 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2947 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2949 drawpic_aspect_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2950 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2951 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2953 else if(killnotify_deathtype[j] == DEATH_DROWN)
2955 drawpic_aspect_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2956 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2957 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2959 else if(killnotify_deathtype[j] == DEATH_SLIME)
2961 drawpic_aspect_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2962 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2963 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2965 else if(killnotify_deathtype[j] == DEATH_LAVA)
2967 drawpic_aspect_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2968 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2969 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2971 else if(killnotify_deathtype[j] == DEATH_FALL)
2973 drawpic_aspect_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2974 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2975 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2977 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2979 drawpic_aspect_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2980 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2981 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2983 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2985 drawpic_aspect_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2986 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2987 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2993 // TODO: separate panel for these?
2999 if(cvar("hud_notify_info_top"))
3002 o = pos + eY * mySize_y - eY * 2 * height;
3004 if(spectatee_status && !intermission)
3006 //drawfont = hud_bigfont;
3007 if(spectatee_status == -1)
3010 s = GetPlayerName(spectatee_status - 1);
3012 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
3013 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, panel_fg_alpha, DRAWFLAG_NORMAL);
3014 //drawfont = hud_font;
3016 // spectator text in the upper right corner
3017 if(spectatee_status == -1)
3018 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
3020 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
3021 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3022 o += eY * fontsize_y;
3024 if(spectatee_status == -1)
3025 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
3027 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
3028 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3029 o += eY * fontsize_y;
3031 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
3032 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3033 o += eY * fontsize_y;
3035 if(gametype == GAME_ARENA)
3036 s = "^1Wait for your turn to join";
3037 else if(gametype == GAME_LMS)
3040 sk = playerslots[player_localentnum - 1];
3041 if(sk.(scores[ps_primary]) >= 666)
3042 s = "^1Match has already begun";
3043 else if(sk.(scores[ps_primary]) > 0)
3044 s = "^1You have no more lives left";
3046 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
3049 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
3050 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3051 o += eY * fontsize_y;
3053 //show restart countdown:
3054 if (time < getstatf(STAT_GAMESTARTTIME)) {
3056 //we need to ceil, otherwise the countdown would be off by .5 when using round()
3057 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
3058 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
3059 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3060 o += eY * fontsize_y;
3063 if(warmup_stage && !intermission)
3065 s = "^2Currently in ^1warmup^2 stage!";
3066 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3067 o += eY * fontsize_y;
3071 if(mod(time, 1) >= 0.5)
3076 if(ready_waiting && !intermission && !spectatee_status)
3078 if(ready_waiting_for_me)
3081 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
3083 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
3088 s = strcat("^2Waiting for others to ready up to end warmup...");
3090 s = strcat("^2Waiting for others to ready up...");
3092 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3093 o += eY * fontsize_y;
3095 else if(warmup_stage && !intermission && !spectatee_status)
3097 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
3098 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3099 o += eY * fontsize_y;
3102 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
3104 float ts_min, ts_max;
3105 tm = teams.sort_next;
3108 for(; tm.sort_next; tm = tm.sort_next)
3110 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
3112 if(!ts_min) ts_min = tm.team_size;
3113 else ts_min = min(ts_min, tm.team_size);
3114 if(!ts_max) ts_max = tm.team_size;
3115 else ts_max = max(ts_max, tm.team_size);
3117 if ((ts_max - ts_min) > 1)
3119 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
3120 tm = GetTeam(myteam, false);
3122 if (tm.team != COLOR_SPECTATOR)
3123 if (tm.team_size == ts_max)
3124 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
3126 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3127 o += eY * fontsize_y;
3131 if(autocvar__hud_configure)
3133 s = "^7Press ^3ESC ^7to show HUD options.";
3134 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3135 o += eY * fontsize_y;
3136 s = "^3Doubleclick a panel for panel-specific options.";
3137 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3138 o += eY * fontsize_y;
3144 string seconds_tostring(float sec)
3147 minutes = floor(sec / 60);
3149 sec -= minutes * 60;
3152 s = ftos(100 + sec);
3154 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3157 void HUD_Timer(void)
3159 float id = HUD_PANEL_TIMER;
3160 HUD_Panel_UpdateCvarsForId(id);
3163 mySize = panel_size;
3165 HUD_Panel_DrawBg(id, pos, mySize, 0);
3166 if(panel_bg_padding)
3168 pos += '1 1 0' * panel_bg_padding;
3169 mySize -= '2 2 0' * panel_bg_padding;
3173 float timelimit, elapsedTime, timeleft, minutesLeft;
3175 timelimit = getstatf(STAT_TIMELIMIT);
3177 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3178 timeleft = ceil(timeleft);
3180 minutesLeft = floor(timeleft / 60);
3183 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3184 timer_color = '1 1 1'; //white
3185 else if(minutesLeft >= 1)
3186 timer_color = '1 1 0'; //yellow
3188 timer_color = '1 0 0'; //red
3190 if (cvar("hud_timer_increment") || timelimit == 0 || warmup_stage) {
3191 if (time < getstatf(STAT_GAMESTARTTIME)) {
3192 //while restart is still active, show 00:00
3193 timer = seconds_tostring(0);
3195 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3196 timer = seconds_tostring(elapsedTime);
3199 timer = seconds_tostring(timeleft);
3202 drawfont = hud_bigfont;
3203 drawstring_aspect(pos, timer, mySize, mySize_y, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3204 drawfont = hud_font;
3209 void HUD_Radar(void)
3211 float id = HUD_PANEL_RADAR;
3212 HUD_Panel_UpdateCvarsForId(id);
3215 mySize = panel_size;
3217 HUD_Panel_DrawBg(id, pos, mySize, 0);
3218 if(panel_bg_padding)
3220 pos += '1 1 0' * panel_bg_padding;
3221 mySize -= '2 2 0' * panel_bg_padding;
3224 local float color1, color2; // color already declared as a global in hud.qc
3227 float scale2d, normalsize, bigsize;
3230 teamradar_origin2d = pos + 0.5 * mySize;
3231 teamradar_size2d = mySize;
3233 if(minimapname == "")
3236 teamradar_loadcvars();
3238 switch(hud_radar_zoommode)
3242 f = current_zoomfraction;
3245 f = 1 - current_zoomfraction;
3255 switch(hud_radar_rotation)
3258 teamradar_angle = view_angles_y - 90;
3261 teamradar_angle = 90 * hud_radar_rotation;
3265 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3266 teamradar_size2d = mySize;
3268 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3270 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3271 if(hud_radar_rotation == 0)
3273 // max-min distance must fit the radar in any rotation
3274 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3278 vector c0, c1, c2, c3, span;
3279 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3280 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3281 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3282 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3284 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3285 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3287 // max-min distance must fit the radar in x=x, y=y
3289 teamradar_size2d_x * scale2d / (1.05 * span_x),
3290 teamradar_size2d_y * scale2d / (1.05 * span_y)
3294 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3295 if(bigsize > normalsize)
3296 normalsize = bigsize;
3300 + (1 - f) * normalsize;
3301 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3302 f * (mi_min + mi_max) * 0.5
3303 + (1 - f) * view_origin);
3305 color1 = GetPlayerColor(player_localentnum-1);
3306 rgb = GetTeamRGB(color1);
3315 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3317 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3318 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3319 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3320 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3321 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3323 color2 = GetPlayerColor(tm.sv_entnum);
3324 //if(color == COLOR_SPECTATOR || color == color2)
3325 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3327 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3329 drawresetcliparea();
3334 void HUD_Score(void)
3336 float id = HUD_PANEL_SCORE;
3337 HUD_Panel_UpdateCvarsForId(id);
3340 mySize = panel_size;
3342 HUD_Panel_DrawBg(id, pos, mySize, 0);
3343 if(panel_bg_padding)
3345 pos += '1 1 0' * panel_bg_padding;
3346 mySize -= '2 2 0' * panel_bg_padding;
3349 float score, distribution, leader;
3351 vector distribution_color;
3353 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3355 // TODO... this (race part) still uses constant coordinates :/
3356 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3357 /*pl = players.sort_next;
3360 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3361 if(pl.scores[ps_primary] == 0)
3364 score = me.(scores[ps_primary]);
3366 float racemin, racesec, racemsec;
3367 float distsec, distmsec, minusplus;
3369 racemin = floor(score/(60 * TIME_FACTOR));
3370 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
3371 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
3373 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3374 // distribution display
3375 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3377 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
3378 distmsec = fabs(distribution);
3380 distsec = floor(fabs(distribution)/TIME_FACTOR);
3381 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
3382 if (distribution < 0)
3386 if (distribution <= 0) {
3387 distribution_color = eY;
3388 minusplus = 1; // minusplus 1: always prefix with minus sign
3391 distribution_color = eX;
3392 minusplus = 2; // minusplus 1: always prefix with plus sign
3394 //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);
3395 //HUD_DrawXNum(bottomright - '68 48 0' - '16 0 0' * TIME_DECIMALS, distsec, 4, minusplus, 16, distribution_color, 0, 0, panel_fg_alpha, DRAWFLAG_NORMAL);
3396 drawpic_aspect_skin(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "num_dot", '16 16 0', distribution_color, panel_fg_alpha, DRAWFLAG_ADDITIVE);
3398 // race record display
3399 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
3400 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);
3402 //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);
3403 //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);
3404 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);
3406 //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);
3407 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);
3409 } else if (!teamplay) { // non-teamgames
3410 // me vector := [team/connected frags id]
3411 pl = players.sort_next;
3415 if(autocvar__hud_configure)
3418 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3422 score = me.(scores[ps_primary]);
3423 if(autocvar__hud_configure)
3426 if(distribution >= 5) {
3427 distribution_color = eY;
3429 } else if(distribution >= 0) {
3430 distribution_color = '1 1 1';
3432 } else if(distribution >= -5)
3433 distribution_color = '1 1 0';
3435 distribution_color = eX;
3437 score_len = strlen(ftos(score));
3439 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);
3441 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);
3442 drawfont = hud_bigfont;
3443 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3444 drawfont = hud_font;
3445 } else { // teamgames
3446 float max_fragcount;
3447 max_fragcount = -99;
3450 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3451 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !autocvar__hud_configure)) // no players? don't display
3453 score = tm.(teamscores[ts_primary]);
3454 if(autocvar__hud_configure)
3458 score_len = strlen(ftos(score));
3460 if (score > max_fragcount)
3461 max_fragcount = score;
3463 if(tm.team == myteam) {
3464 if (max_fragcount == score)
3467 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);
3468 drawfont = hud_bigfont;
3469 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);
3470 drawfont = hud_font;
3472 if (max_fragcount == score)
3475 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);
3476 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);
3485 void HUD_RaceTimer (void) {
3486 float id = HUD_PANEL_RACETIMER;
3487 HUD_Panel_UpdateCvarsForId(id);
3490 mySize = panel_size;
3492 HUD_Panel_DrawBg(id, pos, mySize, 0);
3493 if(panel_bg_padding)
3495 pos += '1 1 0' * panel_bg_padding;
3496 mySize -= '2 2 0' * panel_bg_padding;
3499 // always force 2:1 aspect
3501 if(mySize_x/mySize_y > 2)
3503 newSize_x = 2 * mySize_y;
3504 newSize_y = mySize_y;
3506 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3510 newSize_y = 1/2 * mySize_x;
3511 newSize_x = mySize_x;
3513 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3517 drawfont = hud_bigfont;
3519 string s, forcetime;
3521 if(autocvar__hud_configure)
3524 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);
3525 s = "^1Intermediate 1 (+15.42)";
3526 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);
3527 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3528 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);
3530 else if(race_checkpointtime)
3532 a = bound(0, 2 - (time - race_checkpointtime), 1);
3535 if(a > 0) // just hit a checkpoint?
3537 if(race_checkpoint != 254)
3539 if(race_time && race_previousbesttime)
3540 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3542 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3544 forcetime = TIME_ENCODED_TOSTRING(race_time);
3549 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3551 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3552 if(a > 0) // next one?
3554 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3559 if(s != "" && a > 0)
3561 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3562 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3563 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);
3566 if(race_penaltytime)
3568 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3571 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3572 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3573 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3574 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);
3580 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3581 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', panel_fg_alpha, 0, a);
3582 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);
3587 if(race_laptime && race_checkpoint != 255)
3589 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3590 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3591 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);
3596 if(race_mycheckpointtime)
3598 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3599 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3600 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3601 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3602 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);
3604 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3606 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3607 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3608 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3609 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3610 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);
3613 if(race_penaltytime && !race_penaltyaccumulator)
3615 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3616 a = bound(0, (1 + t - time), 1);
3620 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3622 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3623 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3624 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3625 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);
3630 drawfont = hud_font;
3635 float vote_yescount;
3638 float vote_highlighted; // currently selected vote
3640 float vote_active; // is there an active vote?
3641 float vote_prev; // previous state of vote_active to check for a change
3643 float vote_change; // "time" when vote_active changed
3645 void HUD_VoteWindow(void)
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(cvar_or("hud_vote_alreadyvoted_alpha", 0.75), 1 - vote_highlighted, 1);
3677 HUD_Panel_DrawBg(id, pos, mySize, a);
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_DrawProgressBar(pos, vertical, barsize, HUD_Panel_GetProgressBarColor("nexball"), cvar("hud_progressbar_alpha") * panel_fg_alpha, DRAWFLAG_NORMAL);
4080 if (stat_items & IT_KEY1)
4081 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4084 // Race/CTS HUD mod icons
4085 float crecordtime_prev; // last remembered crecordtime
4086 float crecordtime_change_time; // time when crecordtime last changed
4087 float srecordtime_prev; // last remembered srecordtime
4088 float srecordtime_change_time; // time when srecordtime last changed
4090 float race_status_time;
4091 float race_status_prev;
4092 string race_status_name_prev;
4093 void HUD_Mod_Race(vector pos, vector mySize)
4095 mod_active = 1; // race should never hide the mod icons panel
4097 me = playerslots[player_localentnum - 1];
4099 float f; // yet another function has this
4100 score = me.(scores[ps_primary]);
4102 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
4103 return; // no records in the actual race
4105 drawfont = hud_bigfont;
4107 // clientside personal record
4109 if(gametype == GAME_CTS)
4113 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4115 if(score && (score < t || !t)) {
4116 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4117 if(cvar("cl_autodemo_delete_keeprecords"))
4119 f = cvar("cl_autodemo_delete");
4121 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4125 if(t != crecordtime_prev) {
4126 crecordtime_prev = t;
4127 crecordtime_change_time = time;
4129 f = time - crecordtime_change_time;
4132 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);
4133 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);
4135 drawstring(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4136 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);
4137 drawstring_expanding(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4138 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);
4142 t = race_server_record;
4143 if(t != srecordtime_prev) {
4144 srecordtime_prev = t;
4145 srecordtime_change_time = time;
4147 f = time - srecordtime_change_time;
4150 drawstring(pos + eY * 0.5 * mySize_y, "Server best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4151 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);
4153 drawstring(pos + eY * 0.5 * mySize_y, "Server best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4154 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);
4155 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);
4156 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);
4159 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4160 race_status_time = time + 5;
4161 race_status_prev = race_status;
4162 if (race_status_name_prev)
4163 strunzone(race_status_name_prev);
4164 race_status_name_prev = strzone(race_status_name);
4167 pos_x += mySize_x/2;
4170 a = bound(0, race_status_time - time, 1);
4173 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4177 rank = race_CheckName(race_status_name);
4179 rankname = race_PlaceName(rank);
4182 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4184 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4186 if(race_status == 0)
4187 drawpic_aspect_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4188 else if(race_status == 1) {
4189 drawpic_aspect_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4190 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4191 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4192 } else if(race_status == 2) {
4193 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4194 drawpic_aspect_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4196 drawpic_aspect_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4197 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4198 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4199 } else if(race_status == 3) {
4200 drawpic_aspect_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4201 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4202 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4205 if (race_status_time - time <= 0) {
4206 race_status_prev = -1;
4208 if(race_status_name)
4209 strunzone(race_status_name);
4210 race_status_name = string_null;
4211 if(race_status_name_prev)
4212 strunzone(race_status_name_prev);
4213 race_status_name_prev = string_null;
4215 drawfont = hud_font;
4218 float mod_prev; // previous state of mod_active to check for a change
4220 float mod_change; // "time" when mod_active changed
4222 void HUD_ModIcons(void)
4224 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !autocvar__hud_configure)
4227 float id = HUD_PANEL_MODICONS;
4228 HUD_Panel_UpdateCvarsForId(id);
4231 mySize = panel_size;
4233 if(mod_active != mod_prev) {
4235 mod_prev = mod_active;
4238 if(mod_active || autocvar__hud_configure)
4239 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4241 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4244 HUD_Panel_DrawBg(id, pos, mySize, mod_alpha);
4246 if(panel_bg_padding)
4248 pos += '1 1 0' * panel_bg_padding;
4249 mySize -= '2 2 0' * panel_bg_padding;
4252 // these MUST be ran in order to update mod_active
4253 if(gametype == GAME_KEYHUNT)
4254 HUD_Mod_KH(pos, mySize);
4255 else if(gametype == GAME_CTF || autocvar__hud_configure)
4256 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4257 else if(gametype == GAME_NEXBALL)
4258 HUD_Mod_NexBall(pos, mySize);
4259 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4260 HUD_Mod_Race(pos, mySize);
4263 // Draw pressed keys (#11)
4265 void HUD_DrawPressedKeys(void)
4267 float id = HUD_PANEL_PRESSEDKEYS;
4268 HUD_Panel_UpdateCvarsForId(id);
4271 mySize = panel_size;
4273 HUD_Panel_DrawBg(id, pos, mySize, 0);
4274 if(panel_bg_padding)
4276 pos += '1 1 0' * panel_bg_padding;
4277 mySize -= '2 2 0' * panel_bg_padding;
4281 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4284 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4285 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4286 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);
4287 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);
4288 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);
4289 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);
4290 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);
4293 // Handle chat as a panel (#12)
4297 float id = HUD_PANEL_CHAT;
4298 HUD_Panel_UpdateCvarsForId(id);
4301 mySize = panel_size;
4303 HUD_Panel_DrawBg(id, pos, mySize, 0);
4304 if(panel_bg_padding)
4306 pos += '1 1 0' * panel_bg_padding;
4307 mySize -= '2 2 0' * panel_bg_padding;
4310 cvar_set("con_chatrect", "1");
4312 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4313 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4315 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4316 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4318 if(autocvar__hud_configure)
4321 chatsize = cvar("con_chatsize");
4322 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4324 for(i = 0; i < cvar("con_chat"); ++i)
4326 if(i == cvar("con_chat") - 1)
4329 a = panel_fg_alpha * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4330 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);
4335 // Engine info panel (#13)
4342 float frametimeavg1; // 1 frame ago
4343 float frametimeavg2; // 2 frames ago
4344 void HUD_EngineInfo(void)
4346 float id = HUD_PANEL_ENGINEINFO;
4347 HUD_Panel_UpdateCvarsForId(id);
4350 mySize = panel_size;
4352 HUD_Panel_DrawBg(id, pos, mySize, 0);
4353 if(panel_bg_padding)
4355 pos += '1 1 0' * panel_bg_padding;
4356 mySize -= '2 2 0' * panel_bg_padding;
4359 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4361 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4362 frametimeavg2 = frametimeavg1;
4363 frametimeavg1 = frametimeavg;
4366 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4367 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.
4369 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
4370 prevfps = (1/frametime);
4371 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"
4377 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4379 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4381 prevfps_time = time;
4386 color = HUD_Get_Num_Color (prevfps, 100);
4387 drawfont = hud_bigfont;
4388 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), mySize, mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4389 drawfont = hud_font;
4397 void HUD_ShowSpeed(void)
4400 float pos, conversion_factor;
4401 string speed, zspeed, unit;
4403 switch(cvar("cl_showspeed_unit"))
4408 conversion_factor = 1.0;
4412 conversion_factor = 1.0;
4416 conversion_factor = 0.0254;
4420 conversion_factor = 0.0254 * 3.6;
4424 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4428 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4432 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4434 numsize_x = numsize_y = cvar("cl_showspeed_size");
4435 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4437 drawfont = hud_bigfont;
4438 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4440 if (cvar("cl_showspeed_z") == 1) {
4441 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4442 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4445 drawfont = hud_font;
4448 vector acc_prevspeed;
4452 void HUD_ShowAcceleration(void)
4454 float acceleration, sz, scale, alpha, f;
4455 vector pos, top, rgb;
4456 top_x = vid_conwidth/2;
4459 f = time - acc_prevtime;
4460 if(cvar("cl_showacceleration_z"))
4461 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4463 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4464 acc_prevspeed = pmove_vel;
4465 acc_prevtime = time;
4467 f = bound(0, f * 10, 1);
4468 acc_avg = acc_avg * (1 - f) + acceleration * f;
4469 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4471 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4473 sz = cvar("cl_showacceleration_size");
4474 scale = cvar("cl_showacceleration_scale");
4475 alpha = cvar("cl_showacceleration_alpha");
4476 if (cvar("cl_showacceleration_color_custom"))
4477 rgb = stov(cvar_string("cl_showacceleration_color"));
4480 if (acceleration < 0) {
4481 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4482 } else if (acceleration > 0) {
4483 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4487 if (acceleration > 0)
4488 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4489 else if (acceleration < 0)
4490 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4493 void HUD_Reset (void)
4495 // reset gametype specific icons
4496 if(gametype == GAME_KEYHUNT)
4498 else if(gametype == GAME_CTF)
4499 HUD_Mod_CTF_Reset();
4502 void HUD_Main (void)
4504 hud_skin_path = strcat("gfx/hud/", cvar_string("hud_skin"));
4506 if(disable_menu_alphacheck == 1)
4507 menu_fade_alpha = 1;
4509 menu_fade_alpha = (1 - cvar("_menu_alpha"));
4510 hud_fg_alpha = cvar("hud_fg_alpha");
4512 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4513 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4514 hud_color_bg_team = cvar("hud_color_bg_team");
4516 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4517 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4521 // HUD configure visible grid
4522 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4526 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_x, 0.2); ++i)
4528 drawfill(eX * i * vid_conwidth * bound(0.005, autocvar_hud_configure_grid_x, 0.2), eX + eY * vid_conheight, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4531 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_y, 0.2); ++i)
4533 drawfill(eY * i * vid_conheight * bound(0.005, autocvar_hud_configure_grid_y, 0.2), eY + eX * vid_conwidth, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4540 color = cvar_string("hud_dock_color");
4541 color_vec = stov(color);
4542 if(teamplay && cvar(strcat("hud_dock_color_team"))) {
4543 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4544 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_dock_color_team");
4546 else if(color == "shirt") {
4547 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4548 color_vec = colormapPaletteColor(floor(f / 16), 0);
4550 else if(color == "pants") {
4551 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4552 color_vec = colormapPaletteColor(mod(f, 16), 1);
4555 if(cvar_string("hud_dock") != "" && cvar_string("hud_dock") != "0")
4556 drawpic('0 0 0', strcat("gfx/hud/", cvar_string("hud_skin"), "/", cvar_string("hud_dock")), eX * vid_conwidth + eY * vid_conheight, color_vec, cvar("hud_dock_alpha") * menu_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
4558 if(autocvar_hud_radar || autocvar__hud_configure)
4559 if(cvar_string("hud_radar") != "0" && (cvar("hud_radar") == 2 || teamplay))
4561 if(autocvar_hud_weaponicons || autocvar__hud_configure)
4563 if(autocvar_hud_inventory || autocvar__hud_configure)
4565 if(autocvar_hud_powerups || autocvar__hud_configure)
4567 if(autocvar_hud_healtharmor || autocvar__hud_configure)
4569 if(autocvar_hud_notify || autocvar__hud_configure)
4571 if(autocvar_hud_timer || autocvar__hud_configure)
4573 if(autocvar_hud_score || autocvar__hud_configure)
4575 if(autocvar_hud_racetimer || autocvar__hud_configure)
4576 if(gametype == GAME_RACE || gametype == GAME_CTS || autocvar__hud_configure)
4578 if(autocvar_hud_vote || autocvar__hud_configure)
4580 if(autocvar_hud_modicons || autocvar__hud_configure)
4582 if(autocvar_hud_pressedkeys || autocvar__hud_configure)
4583 if(spectatee_status > 0 || cvar("hud_pressedkeys") >= 2 || autocvar__hud_configure)
4584 HUD_DrawPressedKeys();
4585 if(autocvar_hud_chat || autocvar__hud_configure)
4588 cvar_set("con_chatrect", "0");
4589 if(autocvar_hud_engineinfo || autocvar__hud_configure)
4592 // TODO hud_'ify these
4593 if (cvar("cl_showspeed"))
4595 if (cvar("cl_showacceleration"))
4596 HUD_ShowAcceleration();
4598 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)
4599 localcmd("cmd selectteam auto; cmd join\n");
4601 hud_configure_prev = autocvar__hud_configure;
4603 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again
4604 disable_menu_alphacheck = 0;