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)
20 //pic = draw_UseSkinFor(pic);
21 width = eX * theSize_x;
22 height = eY * theSize_y;
23 if(theSize_x <= theBorderSize_x * 2)
25 // not wide enough... draw just left and right then
26 bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
27 if(theSize_y <= theBorderSize_y * 2)
29 // not high enough... draw just corners
30 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
31 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
32 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
33 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
34 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
38 dY = theBorderSize_x * eY;
39 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
40 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
41 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
42 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);
43 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
44 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);
49 if(theSize_y <= theBorderSize_y * 2)
51 // not high enough... draw just top and bottom then
52 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
53 dX = theBorderSize_x * eX;
54 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
55 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
56 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
57 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
58 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);
59 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);
63 dX = theBorderSize_x * eX;
64 dY = theBorderSize_x * eY;
65 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
66 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
67 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
68 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
69 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
70 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
71 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
72 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
73 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
78 // drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
79 void drawpic_aspect(vector pos, string pic, vector sz, vector color, float alpha, float drawflag) {
81 imgsize = drawgetimagesize(pic);
83 imgaspect = imgsize_x/imgsize_y;
90 if(aspect > imgaspect) {
91 sz_x = sz_y * imgaspect;
92 drawpic(pos + eX * (oldsz_x - sz_x) * 0.5, pic, sz, color, alpha, drawflag);
94 sz_y = sz_x / imgaspect;
95 drawpic(pos + eY * (oldsz_y - sz_y) * 0.5, pic, sz, color, alpha, drawflag);
99 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
100 void drawpic_skin(vector pos, string pic, vector sz, vector color, float alpha, float drawflag) {
101 drawpic_aspect(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, color, alpha, drawflag);
104 void drawpic_skin_expanding(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
105 drawpic_expanding(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
108 void drawpic_skin_expanding_two(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
109 drawpic_expanding_two(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
112 // return HUD background color
113 vector HUD_GetBgColor()
117 GetTeamRGB(myteam) * hud_color_bg_team;
119 // allow custom HUD colors in non-teamgames
120 color_x = cvar("hud_color_bg_r");
121 color_y = cvar("hud_color_bg_g");
122 color_z = cvar("hud_color_bg_b");
127 // return accuracy text color
128 vector HUD_AccuracyColor(float accuracy)
131 float yellow_accuracy = cvar("hud_weaponicons_accuracy_yellow"); // value at which this function returns yellow
132 if(accuracy >= 100) {
136 else if(accuracy > yellow_accuracy) {
137 rgb_x = 1 - (accuracy-yellow_accuracy)/(100-yellow_accuracy); // red value between 1 -> 0
142 rgb_y = accuracy/yellow_accuracy; // green value between 0 -> 1
148 // draw number in the XSCALE font
149 void HUD_DrawXNum (vector pos, float num, float digits, float showsign, float lettersize, vector rgb, float highlighted, float stroke, float alpha, float dflags)
152 string str, tmp, l_length;
154 vector vsize, num_color;
156 vsize_x = vsize_y = lettersize;
159 // showsign 1: always prefix with minus sign (useful in race distribution display)
160 // showsign 2: always prefix with plus sign (useful in race distribution display)
161 // showsign 3: prefix with minus sign if negative, plus sign if positive (useful in score distribution display)
163 if((showsign == 2 && num >= 0) || (num > 0 && showsign == 3))
170 if(num < 0 || (num < 0 && showsign == 3) || (showsign == 1 && num <= 0))
182 str = strcat(substring("0000000000", 0, digits - strlen(tmp)), tmp);
191 str = substring(str, l-digits, 999);
193 } else if(l < digits)
194 pos_x += (digits-l) * lettersize;
196 if (highlighted == 1) {
198 hl_size_x = vsize_x * l + vsize_x * 0.2;
199 hl_size_y = vsize_y * 1.1;
202 hl_size_x = hl_size_x + vsize_x;
205 hl_pos_x = pos_x - lettersize/10;
206 hl_pos_y = pos_y - lettersize/20;
209 drawpic_skin(hl_pos, strcat("num_leading_", l_length), hl_size, '1 1 1', alpha, dflags);
220 drawpic_skin(pos, "num_minus_stroke", vsize, rgb, alpha, dflags);
221 drawpic_skin(pos, "num_minus", vsize, num_color, alpha, dflags);
226 drawpic_skin(pos, "num_plus_stroke", vsize, rgb, alpha, dflags);
227 drawpic_skin(pos, "num_plus", vsize, num_color, alpha, dflags);
231 for(i = 0; i < l; ++i)
233 tmp = substring(str, i, 1);
235 drawpic_skin(pos, strcat("num_", tmp, "_stroke"), vsize, rgb, alpha, dflags);
236 drawpic_skin(pos, strcat("num_", tmp), vsize, num_color, alpha, dflags);
241 vector HUD_Get_Num_Color (float x, float maxvalue)
249 else if(x > maxvalue * 0.75) {
250 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
251 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
254 else if(x > maxvalue * 0.5) {
255 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
256 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
257 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
259 else if(x > maxvalue * 0.25) {
262 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
264 else if(x > maxvalue * 0.1) {
266 color_y = (x-20)*90/27/100; // green value between 0 -> 1
267 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
276 // color the number differently based on how big it is (used in the health/armor panel)
277 void HUD_DrawXNum_Colored (vector pos, float x, float digits, float lettersize, float alpha)
280 color = HUD_Get_Num_Color (x, 200);
281 HUD_DrawXNum(pos, x, digits, 0, lettersize, color, 0, 0, alpha, DRAWFLAG_NORMAL);
284 float stringwidth_colors(string s, vector theSize)
286 return stringwidth(s, TRUE, theSize);
289 float stringwidth_nocolors(string s, vector theSize)
291 return stringwidth(s, FALSE, theSize);
294 #define CENTERPRINT_MAX_LINES 30
295 string centerprint_messages[CENTERPRINT_MAX_LINES];
296 float centerprint_width[CENTERPRINT_MAX_LINES];
297 vector centerprint_start;
298 float centerprint_expire;
299 float centerprint_num;
300 float centerprint_offset_hint;
301 vector centerprint_fontsize;
303 void centerprint(string strMessage)
305 float i, j, n, hcount;
308 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
310 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
312 if(cvar("scr_centertime") <= 0)
318 // strip trailing newlines
319 j = strlen(strMessage) - 1;
320 while(substring(strMessage, j, 1) == "\n" && j >= 0)
322 strMessage = substring(strMessage, 0, j + 1);
327 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
329 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
331 strMessage = substring(strMessage, j, strlen(strMessage) - j);
332 centerprint_offset_hint = j;
337 // if we get here, we have a message. Initialize its height.
340 n = tokenizebyseparator(strMessage, "\n");
342 for(j = 0; j < n; ++j)
344 getWrappedLine_remaining = argv(j);
345 while(getWrappedLine_remaining)
347 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
348 if(centerprint_messages[i])
349 strunzone(centerprint_messages[i]);
350 centerprint_messages[i] = strzone(s);
351 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
354 // half height for empty lines looks better
360 if(i >= CENTERPRINT_MAX_LINES)
366 h = centerprint_fontsize_y*hcount;
368 havail = vid_conheight;
369 if(cvar("con_chatpos") < 0)
370 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
371 if(havail > vid_conheight - 70)
372 havail = vid_conheight - 70; // avoid overlapping HUD
374 centerprint_start_x = 0;
377 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
379 // here, the centerprint would cover the crosshair. REALLY BAD.
380 forbiddenmin = vid_conheight * 0.5 - h - 16;
381 forbiddenmax = vid_conheight * 0.5 + 16;
383 allowedmin = scoreboard_bottom;
384 allowedmax = havail - h;
385 preferred = (havail - h)/2;
388 // possible orderings (total: 4! / 4 = 6)
389 // allowedmin allowedmax forbiddenmin forbiddenmax
390 // forbiddenmin forbiddenmax allowedmin allowedmax
391 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
393 // forbidden doesn't matter in this case
394 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
396 // allowedmin forbiddenmin allowedmax forbiddenmax
397 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
399 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
401 // allowedmin forbiddenmin forbiddenmax allowedmax
402 else if(allowedmin < forbiddenmin)
404 // make sure the forbidden zone is not covered
405 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
406 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
408 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
410 // forbiddenmin allowedmin allowedmax forbiddenmax
411 else if(allowedmax < forbiddenmax)
413 // it's better to leave the allowed zone (overlap with scoreboard) than
414 // to cover the forbidden zone (crosshair)
415 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
416 centerprint_start_y = forbiddenmax;
418 centerprint_start_y = forbiddenmin;
420 // forbiddenmin allowedmin forbiddenmax allowedmax
423 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
426 centerprint_start_y =
429 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
437 centerprint_expire = time + cvar("scr_centertime");
440 void HUD_DrawCenterPrint (void)
447 //if(time > centerprint_expire)
450 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
451 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
452 //sz = 1.2 / (a + 0.2);
457 pos = centerprint_start;
458 for (i=0; i<centerprint_num; i = i + 1)
460 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
461 ts = centerprint_messages[i];
464 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
465 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
466 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
467 pos_y = pos_y + centerprint_fontsize_y;
470 // half height for empty lines looks better
471 pos_y = pos_y + centerprint_fontsize_y * 0.5;
475 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
477 position_x -= 2 / 3 * strlen(text) * scale_x;
478 drawstring(position, text, scale, rgb, alpha, flag);
481 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
483 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
484 drawstring(position, text, scale, rgb, alpha, flag);
487 // return the string of the given race place
488 string race_PlaceName(float pos) {
496 return strcat(ftos(pos), "th");
499 // return the string of the onscreen race timer
500 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
508 if(histime == 0) // goal hit
512 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
522 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
528 lapstr = strcat(" (-", ftos(lapdelta), "L)");
531 else if(lapdelta < 0)
533 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
537 else if(histime > 0) // anticipation
539 if(mytime >= histime)
540 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
542 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
549 cpname = "Start line";
551 cpname = "Finish line";
553 cpname = strcat("Intermediate ", ftos(cp));
555 cpname = "Finish line";
558 return strcat(col, cpname);
559 else if(hisname == "")
560 return strcat(col, cpname, " (", timestr, ")");
562 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
565 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
566 float race_CheckName(string net_name) {
568 for (i=RANKINGS_CNT-1;i>=0;--i)
569 if(grecordholder[i] == net_name)
581 void HUD_Panel_ExportCfg(string cfgname)
584 fh = fopen(strcat("hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg"), FILE_WRITE);
587 fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
588 fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
589 fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
590 fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
591 fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
592 fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
593 fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
594 fputs(fh, strcat("seta hud_fg_alpha \"", cvar_string("hud_fg_alpha"), "\"", "\n"));
597 fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
598 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
599 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
600 fputs(fh, strcat("seta hud_dock_alpha \"", ftos(cvar("hud_dock_alpha")), "\"", "\n"));
603 fputs(fh, strcat("seta hud_progressbar_alpha ", ftos(cvar("hud_progressbar_alpha")), "\n"));
604 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
605 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
606 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
607 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
608 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
609 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
612 // common cvars for all panels
614 for (i = 0; i < HUD_PANEL_NUM; ++i)
616 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), " ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i)))), "\n"));
617 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_pos \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_pos")), "\"", "\n"));
618 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_size \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_size")), "\"", "\n"));
619 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg")), "\"", "\n"));
620 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color")), "\"", "\n"));
621 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color_team \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color_team")), "\"", "\n"));
622 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_alpha \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_alpha")), "\"", "\n"));
623 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_border \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_border")), "\"", "\n"));
624 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_padding \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_padding")), "\"", "\n"));
627 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_accuracy_yellow ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_accuracy_yellow"))), "\n"));
630 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_onlycurrent ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_onlycurrent"))), "\n"));
633 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
634 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_mirror ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
637 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
638 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_mirror ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
641 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
642 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_info_top ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_info_top"))), "\n"));
645 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_foreground_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_foreground_alpha"))), "\n"));
647 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha"))), "\n"));
653 print("^2Successfully exported to hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
658 vector HUD_Panel_GetMinSize(float id)
661 // note: please only set mySize_y on aspect ratio forced panels
664 mySize_x = 1/10; // at least 1/10 * height
665 mySize_y = 1/26; // at least 1/26 * width
668 if(cvar("hud_inventory_onlycurrent"))
669 mySize_y = 2/5; // 2/5 width
671 mySize_x = 0.7; // at least 0.7 * height
674 if(cvar("hud_healtharmor") == 2)
676 mySize_x = 4.35; // 4.35 * height, trial and error...
677 mySize_y = 0.01; // "unlimited" ;)
681 mySize_x = 1.1; // 4/5 * height, trial and error...
682 mySize_y = 1/3; // 1/3 * width, trial and error...
685 mySize_y = 1/4.1; // 1/4.1 * width, trial and error...
688 mySize_y = 1/4; // 1/4 * width
691 mySize_y = 1/4; // 1/4 * width
694 mySize_y = 1/4; // 1/4 * width
697 mySize_y = 1/2; // 1/2 * width
700 mySize_y = 0.5898; // 0.5898 * width, reason: bg has weird dimensions...
703 mySize_y = 0.2; // 0.25 * width, trial and error...
709 // return active status of panel
710 float HUD_Panel_CheckActive(float id)
712 if (cvar_or(strcat("hud_", HUD_Panel_GetName(id)), 1))
717 // return size of given panel
718 vector HUD_Panel_GetSize(float id)
721 mySize = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_size")));
723 mySize = eX * mySize_x * vid_conwidth + eY * mySize_y * vid_conheight;
725 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
727 vector menu_enable_maxsize, menu_enable_size;
728 menu_enable_maxsize = '0 0 0'; // shut up FTEQCC
729 menu_enable_maxsize_x = 0.3 * vid_conwidth;
730 menu_enable_maxsize_y = 0.18 * vid_conheight;
731 if(mySize_x > mySize_y)
733 if(mySize_y > menu_enable_maxsize_y)
735 menu_enable_size_y = menu_enable_maxsize_y;
736 menu_enable_size_x = mySize_x * (menu_enable_maxsize_y/mySize_y);
737 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
742 if(mySize_x > menu_enable_maxsize_x)
744 menu_enable_size_x = menu_enable_maxsize_x;
745 menu_enable_size_y = mySize_y * (menu_enable_maxsize_x/mySize_x);
746 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
753 // return pos of given panel
754 vector HUD_Panel_GetPos(float id)
757 pos = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_pos")));
759 pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
761 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
763 vector mySize, menu_enable_panelpos;
764 mySize = HUD_Panel_GetSize(id);
765 if(mySize_x > mySize_y)
766 menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * mySize_x + eY * 0.82 * vid_conheight;
768 menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * mySize_y + eX * 0.7 * vid_conwidth;
769 pos = (1 - cvar("_menu_alpha")) * pos + (cvar("_menu_alpha")) * menu_enable_panelpos;
774 float HUD_Panel_GetBorder(float id)
777 border = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_border"));
779 border = cvar_string("hud_bg_border");
783 vector HUD_Panel_GetColor(float id)
789 // fetch per-panel color
790 if(teamplay && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")) != "") {
791 f = stof(getplayerkey(self.sv_entnum, "colors"));
792 color = vtos(colormapPaletteColor(mod(f, 16), 1) * cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")));
795 color = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color"));
796 color_vec = stov(color);
798 if(color == "") { // fetch default color
799 color = cvar_string("hud_bg_color");
800 color_vec = stov(color);
801 if(teamplay && cvar(strcat("hud_bg_color_team"))) {
802 f = stof(getplayerkey(self.sv_entnum, "colors"));
803 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_bg_color_team");
805 else if(color == "shirt") {
806 f = stof(getplayerkey(self.sv_entnum, "colors"));
807 color_vec = colormapPaletteColor(floor(f / 16), 0);
809 else if(color == "pants") {
810 f = stof(getplayerkey(self.sv_entnum, "colors"));
811 color_vec = colormapPaletteColor(mod(f, 16), 1);
814 else if(color == "shirt") {
815 f = stof(getplayerkey(self.sv_entnum, "colors"));
816 color_vec = colormapPaletteColor(floor(f / 16), 0);
818 else if(color == "pants") {
819 f = stof(getplayerkey(self.sv_entnum, "colors"));
820 color_vec = colormapPaletteColor(mod(f, 16), 1);
825 vector HUD_Panel_Dock_GetColor(void)
830 color = cvar_string("hud_dock_color");
831 color_vec = stov(color);
832 if(teamplay && cvar(strcat("hud_dock_color_team"))) {
833 f = stof(getplayerkey(self.sv_entnum, "colors"));
834 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_dock_color_team");
836 else if(color == "shirt") {
837 f = stof(getplayerkey(self.sv_entnum, "colors"));
838 color_vec = colormapPaletteColor(floor(f / 16), 0);
840 else if(color == "pants") {
841 f = stof(getplayerkey(self.sv_entnum, "colors"));
842 color_vec = colormapPaletteColor(mod(f, 16), 1);
847 float HUD_Panel_GetBgAlpha(float id)
850 alpha = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_alpha"));
852 alpha = cvar_string("hud_bg_alpha");
854 if(hud_configure && disable_menu_alphacheck == 2 && highlightedPanel == id) // do not set a minalpha cap when showing the config dialog for this panel
855 alpha = ftos((1 - cvar("_menu_alpha")) * max(cvar("hud_configure_bg_minalpha"), stof(alpha)) + (cvar("_menu_alpha")) * stof(alpha));
856 else if(hud_configure)
857 alpha = ftos(max(cvar("hud_configure_bg_minalpha"), stof(alpha)));
859 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
862 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
865 return stof(alpha) * menu_fade_alpha;
868 float HUD_Panel_GetFgAlpha(float id)
871 alpha = hud_fg_alpha;
873 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
876 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
879 return alpha * menu_fade_alpha;
882 float HUD_Panel_GetPadding(float id)
885 padding = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
887 padding = cvar_string("hud_bg_padding");
890 mySize = HUD_Panel_GetSize(id);
892 smallestsize = min(mySize_x, mySize_y);
893 return min(smallestsize/2 - 5, stof(padding));
896 // draw the background/borders
897 void HUD_Panel_DrawBg(float id, vector pos, vector mySize, float alpha)
899 if(!hud_configure && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg")) == "0")
903 bg = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg"));
905 bg = cvar_string("hud_bg");
907 if(bg == "0" && hud_configure) {
908 bg = "border"; // we probably want to see a background in config mode at all times...
914 border = max(0.0000001, HUD_Panel_GetBorder(id)); // draw_BorderPicture does not like border = 0
917 color = HUD_Panel_GetColor(id);
920 alpha = HUD_Panel_GetBgAlpha(id) * alpha; // allow panels to fade in/out by passing an alpha value
922 alpha = HUD_Panel_GetBgAlpha(id);
924 draw_BorderPicture(pos - '1 1 0' * border, strcat("gfx/hud/", cvar_string("hud_skin"), "/", bg), mySize + '1 1 0' * 2 * border, color, alpha, '1 1 0' * (border/BORDER_MULTIPLIER));
928 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
930 //float drawsubpic(vector position, vector size, string pic, vector srcPosition, vector srcSize, vector rgb, float alpha, float flag) = #328;
932 pic = strcat("gfx/hud/", cvar_string("hud_skin"), "/");
934 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);
935 if(mySize_y/mySize_x > 2)
936 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);
937 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);
939 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);
940 if(mySize_x/mySize_y > 2)
941 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);
942 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);
946 vector HUD_Panel_GetProgressBarColor(string item)
948 return stov(cvar_string(strcat("hud_progressbar_", item, "_color")));
951 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
952 vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
963 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
964 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
966 for (i = 0; i < HUD_PANEL_NUM; ++i) {
967 if(i == id || !HUD_Panel_CheckActive(i))
970 targPos = HUD_Panel_GetPos(i) - '1 1 0' * HUD_Panel_GetBorder(id);
971 targSize = HUD_Panel_GetSize(i) + '2 2 0' * HUD_Panel_GetBorder(id);
973 if(myPos_y + mySize_y < targPos_y)
975 if(myPos_y > targPos_y + targSize_y)
978 if(myPos_x + mySize_x < targPos_x)
980 if(myPos_x > targPos_x + targSize_x)
983 // OK, there IS a collision.
985 myCenter_x = myPos_x + 0.5 * mySize_x;
986 myCenter_y = myPos_y + 0.5 * mySize_y;
988 targCenter_x = targPos_x + 0.5 * targSize_x;
989 targCenter_y = targPos_y + 0.5 * targSize_y;
991 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
993 if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
994 myTarget_x = targPos_x - mySize_x;
995 else // push it upwards
996 myTarget_y = targPos_y - mySize_y;
998 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
1000 if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
1001 myTarget_x = targPos_x + targSize_x;
1002 else // push it upwards
1003 myTarget_y = targPos_y - mySize_y;
1005 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
1007 if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
1008 myTarget_x = targPos_x - mySize_x;
1009 else // push it downwards
1010 myTarget_y = targPos_y + targSize_y;
1012 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
1014 if(targPos_x + targSize_x - myPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
1015 myTarget_x = targPos_x + targSize_x;
1016 else // push it downwards
1017 myTarget_y = targPos_y + targSize_y;
1024 void HUD_Panel_SetPos(float id, vector pos)
1027 oldPos = HUD_Panel_GetPos(id);
1030 mySize = HUD_Panel_GetSize(id);
1032 if(cvar("hud_configure_checkcollisions"))
1033 pos = HUD_Panel_CheckMove(id, pos, mySize);
1035 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
1036 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
1038 if(cvar("hud_configure_grid"))
1040 pos_x = floor((pos_x/vid_conwidth)/bound(0.005, cvar("hud_configure_grid_x"), 0.2) + 0.5) * cvar("hud_configure_grid_x") * vid_conwidth;
1041 pos_y = floor((pos_y/vid_conheight)/bound(0.005, cvar("hud_configure_grid_y"), 0.2) + 0.5) * cvar("hud_configure_grid_y") * vid_conheight;
1045 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
1047 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
1050 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
1051 vector HUD_Panel_CheckResize(float id, vector mySize, vector resizeorigin, float ratio) {
1060 for (i = 0; i < HUD_PANEL_NUM; ++i) {
1061 if(i == id || !HUD_Panel_CheckActive(i))
1064 targBorder = HUD_Panel_GetBorder(i);
1065 targPos = HUD_Panel_GetPos(i) - '1 1 0' * targBorder;
1066 targSize = HUD_Panel_GetSize(i) + '2 2 0' * targBorder;
1067 targEndPos = targPos + targSize;
1069 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
1070 if(resizeorigin_x > targPos_x && resizeorigin_x < targPos_x + targSize_x && resizeorigin_y > targPos_y && resizeorigin_y < targPos_y + targSize_y)
1073 if (resizeCorner == 1)
1075 // check if this panel is on our way
1076 if (resizeorigin_x <= targPos_x)
1078 if (resizeorigin_y <= targPos_y)
1080 if (targEndPos_x <= resizeorigin_x - mySize_x)
1082 if (targEndPos_y <= resizeorigin_y - mySize_y)
1085 // there is a collision:
1086 // detect which side of the panel we are facing is actually limiting the resizing
1087 // (which side the resize direction finds for first) and reduce the size up to there
1089 // dist is the distance between resizeorigin and the "analogous" point of the panel
1090 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
1091 dist_x = resizeorigin_x - targEndPos_x;
1092 dist_y = resizeorigin_y - targEndPos_y;
1093 if (dist_y < 0 || dist_x / dist_y > ratio)
1094 mySize_x = min(mySize_x, dist_x);
1096 mySize_y = min(mySize_y, dist_y);
1098 else if (resizeCorner == 2)
1100 if (resizeorigin_x >= targEndPos_x)
1102 if (resizeorigin_y <= targPos_y)
1104 if (targPos_x >= resizeorigin_x + mySize_x)
1106 if (targEndPos_y <= resizeorigin_y - mySize_y)
1109 dist_x = targPos_x - resizeorigin_x;
1110 dist_y = resizeorigin_y - targEndPos_y;
1111 if (dist_y < 0 || dist_x / dist_y > ratio)
1112 mySize_x = min(mySize_x, dist_x);
1114 mySize_y = min(mySize_y, dist_y);
1116 else if (resizeCorner == 3)
1118 if (resizeorigin_x <= targPos_x)
1120 if (resizeorigin_y >= targEndPos_y)
1122 if (targEndPos_x <= resizeorigin_x - mySize_x)
1124 if (targPos_y >= resizeorigin_y + mySize_y)
1127 dist_x = resizeorigin_x - targEndPos_x;
1128 dist_y = targPos_y - resizeorigin_y;
1129 if (dist_y < 0 || dist_x / dist_y > ratio)
1130 mySize_x = min(mySize_x, dist_x);
1132 mySize_y = min(mySize_y, dist_y);
1134 else if (resizeCorner == 4)
1136 if (resizeorigin_x >= targEndPos_x)
1138 if (resizeorigin_y >= targEndPos_y)
1140 if (targPos_x >= resizeorigin_x + mySize_x)
1142 if (targPos_y >= resizeorigin_y + mySize_y)
1145 dist_x = targPos_x - resizeorigin_x;
1146 dist_y = targPos_y - resizeorigin_y;
1147 if (dist_y < 0 || dist_x / dist_y > ratio)
1148 mySize_x = min(mySize_x, dist_x);
1150 mySize_y = min(mySize_y, dist_y);
1152 if(cvar("hud_configure_checkcollisions_debug"))
1153 drawfill(targPos + '1 1 0' * targBorder, targSize - '2 2 0' * targBorder, '1 1 0', .3, DRAWFLAG_NORMAL);
1159 void HUD_Panel_SetPosSize(float id)
1161 vector resizeorigin;
1162 resizeorigin = panel_click_resizeorigin;
1163 vector mySize, myPos;
1165 if(resizeCorner == 1) {
1166 mySize_x = resizeorigin_x - (mousepos_x - panel_click_distance_x);
1167 mySize_y = resizeorigin_y - (mousepos_y - panel_click_distance_y);
1168 } else if(resizeCorner == 2) {
1169 mySize_x = mousepos_x + panel_click_distance_x - resizeorigin_x;
1170 mySize_y = panel_click_distance_y + resizeorigin_y - mousepos_y;
1171 } else if(resizeCorner == 3) {
1172 mySize_x = resizeorigin_x + panel_click_distance_x - mousepos_x;
1173 mySize_y = mousepos_y + panel_click_distance_y - resizeorigin_y;
1174 } else { // resizeCorner == 4
1175 mySize_x = mousepos_x - (resizeorigin_x - panel_click_distance_x);
1176 mySize_y = mousepos_y - (resizeorigin_y - panel_click_distance_y);
1179 // minimum panel size cap
1180 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1181 mySize_y = max(0.025 * vid_conheight, mySize_y);
1183 if(id == 12) // 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.
1185 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
1186 mySize_y = max(2 * cvar("con_chatsize") + 2 * HUD_Panel_GetPadding(id), mySize_y);
1189 // cap against panel's own limits
1191 minSize = HUD_Panel_GetMinSize(id); // mySize_x at least minSize_x * mySize_y, and vice versa
1193 if(!minSize_x && minSize_y) // forced aspect ratio
1195 minSize_x = 1/minSize_y;
1196 fixedRatio = minSize_x;
1197 mySize_x = max(minSize_x * mySize_y, mySize_x);
1198 mySize_y = max(minSize_y * mySize_x, mySize_y);
1200 else if(minSize_x && !minSize_y) // hybrid aspect ratio, currently supported only in one dimension
1202 if (mySize_x/mySize_y < minSize_x) // resizing in x direction allows free aspect ratio
1204 fixedRatio = minSize_x;
1205 minSize_y = 1/minSize_x;
1206 mySize_y = max(minSize_y * mySize_x, mySize_y);
1207 mySize_x = max(minSize_x * mySize_y, mySize_x);
1210 fixedRatio = -minSize_x; //negative so that it will be used ONLY after checkResize
1213 // collision testing|
1214 // -----------------+
1216 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
1217 if(resizeCorner == 1) {
1218 myPos_x = resizeorigin_x - mySize_x;
1219 myPos_y = resizeorigin_y - mySize_y;
1220 } else if(resizeCorner == 2) {
1221 myPos_x = resizeorigin_x;
1222 myPos_y = resizeorigin_y - mySize_y;
1223 } else if(resizeCorner == 3) {
1224 myPos_x = resizeorigin_x - mySize_x;
1225 myPos_y = resizeorigin_y;
1226 } else { // resizeCorner == 4
1227 myPos_x = resizeorigin_x;
1228 myPos_y = resizeorigin_y;
1231 // left/top screen edges
1233 mySize_x = mySize_x + myPos_x;
1235 mySize_y = mySize_y + myPos_y;
1237 // bottom/right screen edges
1238 if(myPos_x + mySize_x > vid_conwidth)
1239 mySize_x = vid_conwidth - myPos_x;
1240 if(myPos_y + mySize_y > vid_conheight)
1241 mySize_y = vid_conheight - myPos_y;
1243 if(cvar("hud_configure_checkcollisions_debug"))
1244 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
1246 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
1247 if(cvar("hud_configure_grid"))
1249 mySize_x = floor((mySize_x/vid_conwidth)/bound(0.005, cvar("hud_configure_grid_x"), 0.2) + 0.5) * cvar("hud_configure_grid_x") * vid_conwidth;
1250 mySize_y = floor((mySize_y/vid_conheight)/bound(0.005, cvar("hud_configure_grid_y"), 0.2) + 0.5) * cvar("hud_configure_grid_y") * vid_conheight;
1255 // keep aspect ratio _MAXIMIZING_ the size
1256 if (mySize_x / mySize_y > fixedRatio)
1257 mySize_y = mySize_x / fixedRatio;
1259 mySize_x = mySize_y * fixedRatio;
1262 if(cvar("hud_configure_checkcollisions"))
1266 mySize = HUD_Panel_CheckResize(id, mySize, resizeorigin, fixedRatio);
1268 // Make sure once more that we DON'T cross the screen edges
1269 // left/top screen edges
1271 mySize_x = mySize_x + myPos_x;
1273 mySize_y = mySize_y + myPos_y;
1275 // bottom/right screen edges
1276 if(myPos_x + mySize_x > vid_conwidth)
1277 mySize_x = vid_conwidth - myPos_x;
1278 if(myPos_y + mySize_y > vid_conheight)
1279 mySize_y = vid_conheight - myPos_y;
1281 // restore again aspect ratio, _minimizing_ the size
1282 if (mySize_x / mySize_y < fixedRatio)
1283 mySize_y = mySize_x / fixedRatio;
1285 mySize_x = mySize_y * fixedRatio;
1289 mySize = HUD_Panel_CheckResize(id, mySize, resizeorigin, mySize_x / mySize_y);
1292 fixedRatio = -fixedRatio;
1293 // restore again aspect ratio, _minimizing_ the size
1294 if (mySize_x / mySize_y < fixedRatio)
1295 mySize_y = mySize_x / fixedRatio;
1300 // 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)
1301 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1302 mySize_y = max(0.025 * vid_conheight, mySize_y);
1304 // do another pos check, as size might have changed by now
1305 if(resizeCorner == 1) {
1306 myPos_x = resizeorigin_x - mySize_x;
1307 myPos_y = resizeorigin_y - mySize_y;
1308 } else if(resizeCorner == 2) {
1309 myPos_x = resizeorigin_x;
1310 myPos_y = resizeorigin_y - mySize_y;
1311 } else if(resizeCorner == 3) {
1312 myPos_x = resizeorigin_x - mySize_x;
1313 myPos_y = resizeorigin_y;
1314 } else { // resizeCorner == 4
1315 myPos_x = resizeorigin_x;
1316 myPos_y = resizeorigin_y;
1319 if(cvar("hud_configure_checkcollisions_debug"))
1320 if(cvar("hud_configure_checkcollisions"))
1321 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
1324 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
1325 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_size"), s);
1327 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
1328 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
1332 float prevMouseClicked; // previous state
1333 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
1334 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
1337 float menu_enabled_time;
1338 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1343 // allow console bind to work
1346 con_keys = findkeysforcommand("toggleconsole");
1347 keys = tokenize(con_keys);
1349 float hit_con_bind, i;
1350 for (i = 0; i < keys; ++i)
1352 if(nPrimary == stof(argv(i)))
1356 if(nPrimary == K_MOUSE1)
1358 if(bInputType == 0) { // key pressed
1362 else if(bInputType == 1) {// key released
1367 else if(nPrimary == K_ESCAPE)
1369 disable_menu_alphacheck = 1;
1371 menu_enabled_time = time;
1372 localcmd("menu_showhudexit\n");
1375 else if(hit_con_bind)
1378 return true; // Suppress ALL other input
1381 void HUD_Panel_Mouse()
1383 // 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
1384 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1385 disable_menu_alphacheck = 0;
1386 if (cvar("_menu_alpha") == 0 && time - menu_enabled_time > 0.5)
1390 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1391 print("Highlighted: ", ftos(highlightedPanel), "\n");
1392 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1395 if(mouseClicked == 0 && disable_menu_alphacheck != 2) { // don't reset these variables in disable_menu_alphacheck mode 2!
1396 highlightedPanel = -1;
1397 highlightedAction = 0;
1400 mousepos = mousepos + getmousepos();
1402 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1403 mousepos_y = bound(0, mousepos_y, vid_conheight);
1405 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1413 for(i = 0; i < HUD_PANEL_NUM; ++i)
1415 panelPos = HUD_Panel_GetPos(i);
1416 panelSize = HUD_Panel_GetSize(i);
1417 border = HUD_Panel_GetBorder(i);
1418 if(prevMouseClicked == 0) {
1420 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1422 highlightedPanel = i;
1423 highlightedAction = 1;
1425 // resize from topleft border
1426 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)
1428 highlightedPanel = i;
1429 highlightedAction = 2;
1432 // resize from topright border
1433 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)
1435 highlightedPanel = i;
1436 highlightedAction = 2;
1439 // resize from bottomleft border
1440 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)
1442 highlightedPanel = i;
1443 highlightedAction = 2;
1446 // resize from bottomright border
1447 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)
1449 highlightedPanel = i;
1450 highlightedAction = 2;
1455 if(highlightedPanel == i)
1457 if(prevMouseClicked == 0)
1459 if(highlightedAction == 1)
1460 panel_click_distance = mousepos - panelPos;
1461 else if(highlightedAction == 2)
1463 if(resizeCorner == 1) {
1464 panel_click_distance = mousepos - panelPos;
1465 panel_click_resizeorigin = panelPos + panelSize;
1466 } else if(resizeCorner == 2) {
1467 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1468 panel_click_distance_y = mousepos_y - panelPos_y;
1469 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1470 } else if(resizeCorner == 3) {
1471 panel_click_distance_x = mousepos_x - panelPos_x;
1472 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1473 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1474 } else if(resizeCorner == 4) {
1475 panel_click_distance = panelSize - mousepos + panelPos;
1476 panel_click_resizeorigin = panelPos;
1481 if(cvar("hud_configure_checkcollisions_debug"))
1482 drawfill(panelPos, panelSize, '1 0 0', .3, DRAWFLAG_NORMAL);
1484 if(highlightedAction == 1)
1485 HUD_Panel_SetPos(i, mousepos - panel_click_distance);
1486 else if(highlightedAction == 2)
1487 HUD_Panel_SetPosSize(i);
1491 // doubleclick check
1492 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1494 mouseClicked = 0; // to prevent spam, I guess.
1495 disable_menu_alphacheck = 2;
1497 menu_enabled_time = time;
1498 localcmd("menu_showhudoptions ", ftos(highlightedPanel), "\n");
1501 if(prevMouseClicked == 0)
1503 prevMouseClickedTime = time;
1504 prevMouseClickedPos = mousepos;
1507 prevMouseClicked = mouseClicked;
1510 // Weapon icons (#0)
1512 float weaponspace[10];
1513 void HUD_WeaponIcons_Clear()
1516 for(idx = 0; idx < 10; ++idx)
1517 weaponspace[idx] = 0;
1520 entity weaponorder[WEP_MAXCOUNT];
1522 void weaponorder_swap(float i, float j, entity pass)
1526 weaponorder[i] = weaponorder[j];
1530 string weaponorder_cmp_str;
1531 float weaponorder_cmp(float i, float j, entity pass)
1534 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1535 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1536 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)
1539 void HUD_WeaponIcons(void)
1541 float id = HUD_PANEL_WEAPONICONS;
1542 float alpha, stat_weapons; // "constants"
1543 vector pos, mySize, accuracy_color;
1544 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1546 pos = HUD_Panel_GetPos(id);
1547 mySize = HUD_Panel_GetSize(id);
1549 stat_weapons = getstati(STAT_WEAPONS);
1550 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1552 self = get_weaponinfo(i);
1553 if(self.impulse >= 0)
1555 weaponorder[weapon_cnt] = self;
1560 // TODO make this configurable
1561 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1562 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1564 HUD_Panel_DrawBg(id, pos, mySize, 0);
1566 padding = HUD_Panel_GetPadding(id);
1569 pos += '1 1 0' * padding;
1570 mySize -= '2 2 0' * padding;
1574 weapon_stats = getstati(STAT_DAMAGE_HITS);
1575 weapon_number = weapon_stats & 63;
1576 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1578 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1579 weapon_number = weapon_stats & 63;
1580 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1582 if(cvar_or("hud_weaponicons_fade", 1))
1584 fade = 3.2 - 2 * (time - weapontime);
1585 fade = bound(0.7, fade, 1);
1590 HUD_WeaponIcons_Clear();
1592 float rows, columns;
1593 rows = mySize_y/mySize_x;
1594 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1595 // ^^^ weapon icon aspect goes here
1597 columns = ceil(WEP_COUNT/rows);
1599 for(i = 0; i < weapon_cnt; ++i)
1601 self = weaponorder[i];
1602 weapid = self.impulse;
1604 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1606 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1607 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1609 // draw background behind currently selected weapon
1610 if(self.weapon == activeweapon)
1611 drawpic_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 * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1613 // draw the weapon accuracy on the HUD
1614 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1617 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1619 accuracy_color = HUD_AccuracyColor(weapon_stats);
1621 drawpic_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, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1624 // draw the weapon icon
1625 if((self.impulse >= 0) && (stat_weapons & self.weapons))
1627 drawpic_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 * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1629 if(cvar_or("hud_weaponicons_number", 1))
1630 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', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1634 drawpic_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', HUD_Panel_GetFgAlpha(id) * 0.5, DRAWFLAG_NORMAL);
1649 float GetAmmoStat(float i)
1653 case 0: return STAT_SHELLS;
1654 case 1: return STAT_NAILS;
1655 case 2: return STAT_ROCKETS;
1656 case 3: return STAT_CELLS;
1657 case 4: return STAT_FUEL;
1662 float GetAmmoItemCode(float i)
1666 case 0: return IT_SHELLS;
1667 case 1: return IT_NAILS;
1668 case 2: return IT_ROCKETS;
1669 case 3: return IT_CELLS;
1670 case 4: return IT_FUEL;
1675 string GetAmmoPicture(float i)
1679 case 0: return "ammo_shells";
1680 case 1: return "ammo_bullets";
1681 case 2: return "ammo_rockets";
1682 case 3: return "ammo_cells";
1683 case 4: return "ammo_fuel";
1688 void HUD_Inventory(void)
1690 float id = HUD_PANEL_INVENTORY;
1694 vector pos, mySize, mysize, mypos;
1695 pos = HUD_Panel_GetPos(id);
1696 mySize = HUD_Panel_GetSize(id);
1698 HUD_Panel_DrawBg(id, pos, mySize, 0);
1700 padding = HUD_Panel_GetPadding(id);
1703 pos += '1 1 0' * padding;
1704 mySize -= '2 2 0' * padding;
1708 stat_items = getstati(STAT_ITEMS);
1709 for (i = 0; i < 4; ++i) {
1711 a = getstati(GetAmmoStat(i)); // how much ammo do we have of type i?
1715 if(cvar("hud_inventory_onlycurrent")) {
1718 if (stat_items & GetAmmoItemCode(i) || hud_configure) {
1719 drawpic_skin(pos, GetAmmoPicture(i), '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1721 HUD_DrawXNum(pos + eX * mySize_y + eY * 0.25 * mySize_y, a, strlen(ftos(a)), 0, 0.5 * mySize_y, '0.7 0 0', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1723 HUD_DrawXNum(pos + eX * mySize_y + eY * 0.25 * mySize_y, a, strlen(ftos(a)), 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1729 if(mySize_x/mySize_y >= 10) { // arrange horizontally
1731 case 0: mypos_x = pos_x; mypos_y = pos_y; break; // shells
1732 case 1: mypos_x = pos_x + 0.25 * mySize_x; mypos_y = pos_y; break; // bullets
1733 case 2: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y; break; // rockets
1734 case 3: mypos_x = pos_x + 0.75 * mySize_x; mypos_y = pos_y; break; // cells
1736 mysize_x = 0.25 * mySize_x;
1737 mysize_y = mySize_y;
1738 } else if(mySize_x/mySize_y >= 2.5) { // arrange in a 2x2 grid
1740 case 0: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y + 0.5 * mySize_y; break; // shells
1741 case 1: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y; break; // bullets
1742 case 2: mypos_x = pos_x; mypos_y = pos_y + 0.5 * mySize_y; break; // rockets
1743 case 3: mypos_x = pos_x; mypos_y = pos_y; break; // cells
1745 mysize_x = 0.5 * mySize_x;
1746 mysize_y = 0.5 * mySize_y;
1747 } else { // arrange vertically
1749 case 0: mypos_x = pos_x; mypos_y = pos_y; break; // shells
1750 case 1: mypos_x = pos_x; mypos_y = pos_y + 0.25 * mySize_y; break; // bullets
1751 case 2: mypos_x = pos_x; mypos_y = pos_y + 0.5 * mySize_y; break; // rockets
1752 case 3: mypos_x = pos_x; mypos_y = pos_y + 0.75 * mySize_y; break; // cells
1754 mysize_x = mySize_x;
1755 mysize_y = 0.25 * mySize_y;
1758 if (stat_items & GetAmmoItemCode(i))
1759 drawpic_skin(mypos, "ammo_current_bg", mysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1760 drawpic_skin(mypos + eY * 0.05 * mysize_y, GetAmmoPicture(i), '1 1 0' * 0.8 * mysize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1762 if(stat_items & GetAmmoItemCode(i))
1763 HUD_DrawXNum(mypos + eX * 0.8 * mysize_y + eY * 0.25 * mysize_y, a, strlen(ftos(a)), 0, 0.5 * mysize_y, '0.7 0 0', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1765 HUD_DrawXNum(mypos + eX * 0.8 * mysize_y + eY * 0.25 * mysize_y, a, strlen(ftos(a)), 0, 0.5 * mysize_y, '0.7 0 0', 0, 0, HUD_Panel_GetFgAlpha(id) * 0.7, DRAWFLAG_NORMAL);
1767 if(stat_items & GetAmmoItemCode(i))
1768 HUD_DrawXNum(mypos + eX * 0.8 * mysize_y + eY * 0.25 * mysize_y, a, strlen(ftos(a)), 0, 0.5 * mysize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1770 HUD_DrawXNum(mypos + eX * 0.8 * mysize_y + eY * 0.25 * mysize_y, a, strlen(ftos(a)), 0, 0.5 * mysize_y, '0.7 0.7 0.7', 0, 0, HUD_Panel_GetFgAlpha(id) * 0.7, DRAWFLAG_NORMAL);
1780 void HUD_Powerups(void) {
1781 float id = HUD_PANEL_POWERUPS;
1783 stat_items = getstati(STAT_ITEMS);
1787 if not(stat_items & IT_STRENGTH)
1788 if not(stat_items & IT_INVINCIBLE)
1791 if (getstati(STAT_HEALTH) <= 0)
1796 pos = HUD_Panel_GetPos(id);
1797 mySize = HUD_Panel_GetSize(id);
1799 HUD_Panel_DrawBg(id, pos, mySize, 0);
1801 padding = HUD_Panel_GetPadding(id);
1804 pos += '1 1 0' * padding;
1805 mySize -= '2 2 0' * padding;
1808 float strength_time, shield_time;
1810 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1811 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1821 vector barpos, barsize;
1825 string leftname, rightname;
1826 float leftcnt, rightcnt;
1827 float leftexact, rightexact;
1828 float leftalpha, rightalpha;
1829 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) {
1830 leftname = "strength";
1831 leftcnt = ceil(strength_time);
1832 leftexact = strength_time;
1834 rightname = "shield";
1835 rightcnt = ceil(shield_time);
1836 rightexact = shield_time;
1838 leftname = "shield";
1839 leftcnt = ceil(shield_time);
1840 leftexact = shield_time;
1842 rightname = "strength";
1843 rightcnt = ceil(strength_time);
1844 rightexact = strength_time;
1846 leftalpha = bound(0, leftexact, 1);
1847 rightalpha = bound(0, rightexact, 1);
1849 if (mySize_x/mySize_y > 4)
1853 len = strlen(ftos(leftcnt));
1855 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1856 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1857 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1858 picpos = pos + eX * 0.5 * mySize_x - eX * mySize_y;
1859 numpos = picpos - eX * 2 * 0.5 * mySize_y + eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1862 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1864 numpos = picpos + eX * mySize_y - eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1867 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1869 drawpic_skin_expanding_two(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE, bound(0, (leftcnt - leftexact) / 0.5, 1));
1871 drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1872 HUD_DrawXNum(numpos, leftcnt, 2, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1877 len = strlen(ftos(rightcnt));
1879 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1880 barpos = pos + eX * 0.5 * mySize_x;
1881 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1882 picpos = pos + eX * 0.5 * mySize_x;
1883 numpos = picpos + eX * mySize_y - eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1885 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1886 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1887 picpos = pos + eX * mySize_x - eX * mySize_y;
1888 numpos = picpos - eX * mySize_y + eY * 0.25 * mySize_y;
1891 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1893 drawpic_skin_expanding_two(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE, bound(0, (rightcnt - rightexact) / 0.5, 1));
1895 drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1896 HUD_DrawXNum(numpos, rightcnt, 2, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1899 else if (mySize_x/mySize_y > 1.5)
1903 len = strlen(ftos(leftcnt));
1905 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1906 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1907 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1908 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y;
1909 numpos = picpos - eX * len * 0.5 * mySize_y;
1912 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1914 numpos = picpos + eX * 0.5 * mySize_y;
1917 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1919 drawpic_skin_expanding_two(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE, bound(0, (leftcnt - leftexact) / 0.5, 1));
1921 drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1922 HUD_DrawXNum(numpos, leftcnt, len, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1927 len = strlen(ftos(rightcnt));
1929 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1930 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1931 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1932 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y + eY * 0.5 * mySize_y;
1933 numpos = picpos - eX * len * 0.5 * mySize_y;
1935 barpos = pos + eY * 0.5 * mySize_y;
1936 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1937 picpos = pos + eY * 0.5 * mySize_y;
1938 numpos = picpos + eX * 0.5 * mySize_y;
1941 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1943 drawpic_skin_expanding_two(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE, bound(0, (rightcnt - rightexact) / 0.5, 1));
1945 drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1946 HUD_DrawXNum(numpos, rightcnt, len, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1953 len = strlen(ftos(leftcnt));
1955 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1957 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1958 picpos = pos + eX * 0.05 * mySize_x;
1959 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x;
1961 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1962 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1963 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.65 * mySize_x;
1964 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.25 * mySize_x;
1967 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1969 drawpic_skin_expanding_two(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE, bound(0, (leftcnt - leftexact) / 0.5, 1));
1971 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1972 HUD_DrawXNum(numpos, leftcnt, len, 0, 0.25 * mySize_x, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1977 len = strlen(ftos(rightcnt));
1979 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1980 barpos = pos + eX * 0.5 * mySize_x;
1981 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1982 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1983 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1985 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1986 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1987 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.65 * mySize_x + eX * 0.5 * mySize_x;
1988 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
1991 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1993 drawpic_skin_expanding_two(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE, bound(0, (rightcnt - rightexact) / 0.5, 1));
1995 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1996 HUD_DrawXNum(numpos, rightcnt, len, 0, 0.25 * mySize_x, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2001 // Health/armor (#3)
2003 void HUD_HealthArmor(void)
2005 float id = HUD_PANEL_HEALTHARMOR;
2007 pos = HUD_Panel_GetPos(id);
2008 mySize = HUD_Panel_GetSize(id);
2010 HUD_Panel_DrawBg(id, pos, mySize, 0);
2012 padding = HUD_Panel_GetPadding(id);
2015 pos += '1 1 0' * padding;
2016 mySize -= '2 2 0' * padding;
2019 float armor, health;
2020 armor = getstati(STAT_ARMOR);
2021 health = getstati(STAT_HEALTH);
2024 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
2037 vector barpos, barsize;
2041 if(cvar("hud_healtharmor") == 2) // combined health and armor display
2044 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2049 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2050 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2051 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2053 numpos = picpos + eX * 1.5 * mySize_y;
2056 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2057 picpos = pos + eX * 3 * mySize_y;
2061 if(v_z) // NOT fully armored
2063 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("health"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2064 drawpic_skin(picpos, "health", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2066 drawpic_skin(picpos + eX * mySize_y, "armor", '0.5 0.5 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id) * armor / health, DRAWFLAG_NORMAL);
2070 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("armor"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2071 drawpic_skin(picpos + eX * mySize_y, "health", '0.5 0.5 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id) * health / armor, DRAWFLAG_NORMAL);
2073 drawpic_skin(picpos, "armor", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2075 HUD_DrawXNum_Colored(numpos, x, 3, mySize_y, HUD_Panel_GetFgAlpha(id)); // draw the combined health and armor
2078 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2079 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2080 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2083 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2086 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2091 string leftname, rightname;
2092 float leftcnt, rightcnt;
2093 float leftactive, rightactive;
2094 float leftalpha, rightalpha;
2095 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) { // old style layout with armor left/top of health
2100 leftalpha = min((armor+10)/55, 1);
2102 rightname = "health";
2107 leftname = "health";
2112 rightname = "armor";
2116 rightalpha = min((armor+10)/55, 1);
2119 if (mySize_x/mySize_y > 5)
2123 len = strlen(ftos(leftcnt));
2125 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2126 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2127 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2128 picpos = pos + eX * 0.5 * mySize_x - eX * mySize_y;
2129 numpos = picpos - eX * 3 * 0.5 * mySize_y + eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
2132 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2134 numpos = picpos + eX * mySize_y + eY * 0.25 * mySize_y;
2137 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2138 drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2139 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2144 len = strlen(ftos(rightcnt));
2146 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2147 barpos = pos + eX * 0.5 * mySize_x;
2148 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2149 picpos = pos + eX * 0.5 * mySize_x;
2150 numpos = picpos + eX * mySize_y - eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
2152 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2153 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2154 picpos = pos + eX * mySize_x - eX * mySize_y;
2155 numpos = picpos - eX * 1.5 * mySize_y + eY * 0.25 * mySize_y;
2158 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2159 drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2160 HUD_DrawXNum_Colored(numpos, rightcnt, 3, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2163 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2164 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2165 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2168 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2171 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2173 else if (mySize_x/mySize_y > 2)
2177 len = strlen(ftos(leftcnt));
2179 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2180 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2181 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2182 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y;
2183 numpos = picpos - eX * len * 0.5 * mySize_y;
2186 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2188 numpos = picpos + eX * 0.5 * mySize_y;
2191 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2192 drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2193 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2198 len = strlen(ftos(rightcnt));
2200 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2201 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2202 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2203 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y + eY * 0.5 * mySize_y;
2204 numpos = picpos - eX * len * 0.5 * mySize_y;
2206 barpos = pos + eY * 0.5 * mySize_y;
2207 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2208 picpos = pos + eY * 0.5 * mySize_y;
2209 numpos = picpos + eX * 0.5 * mySize_y;
2212 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2213 drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2214 HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2217 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2218 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2219 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2222 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2225 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2231 len = strlen(ftos(leftcnt));
2233 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2235 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2236 picpos = pos + eX * 0.05 * mySize_x;
2237 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x;
2239 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2240 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2241 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x;
2242 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x;
2245 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2246 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2247 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.166 * mySize_x, HUD_Panel_GetFgAlpha(id));
2252 len = strlen(ftos(rightcnt));
2254 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2255 barpos = pos + eX * 0.5 * mySize_x;
2256 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2257 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2258 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2260 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2261 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2262 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x + eX * 0.5 * mySize_x;
2263 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x + eX * 0.5 * mySize_x;
2266 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2267 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2268 HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.166 * mySize_x, HUD_Panel_GetFgAlpha(id));
2271 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2273 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2275 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2276 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2279 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2285 // Notification area (#4)
2288 string Weapon_SuicideMessage(float deathtype)
2290 w_deathtype = deathtype;
2291 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2292 return w_deathtypestring;
2295 string Weapon_KillMessage(float deathtype)
2297 w_deathtype = deathtype;
2298 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2299 return w_deathtypestring;
2302 float killnotify_times[10];
2303 float killnotify_deathtype[10];
2304 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2305 string killnotify_attackers[10];
2306 string killnotify_victims[10];
2307 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2310 for (i = 9; i > 0; --i) {
2311 killnotify_times[i] = killnotify_times[i-1];
2312 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2313 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2314 if(killnotify_attackers[i])
2315 strunzone(killnotify_attackers[i]);
2316 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2317 if(killnotify_victims[i])
2318 strunzone(killnotify_victims[i]);
2319 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2321 killnotify_times[0] = time;
2322 killnotify_deathtype[0] = wpn;
2323 killnotify_actiontype[0] = actiontype;
2324 if(killnotify_attackers[0])
2325 strunzone(killnotify_attackers[0]);
2326 killnotify_attackers[0] = strzone(attacker);
2327 if(killnotify_victims[0])
2328 strunzone(killnotify_victims[0]);
2329 killnotify_victims[0] = strzone(victim);
2332 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2336 alsoprint = (cvar("hud_notify_print") || !HUD_Panel_CheckActive(4)); // print message to console if: notify panel disabled, or cvar to do so enabled
2338 if(msg == MSG_SUICIDE) {
2340 w = DEATH_WEAPONOF(type);
2342 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2344 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2345 } else if (type == DEATH_KILL) {
2346 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2348 print ("^1",s1, "^1 couldn't take it anymore\n");
2349 } else if (type == DEATH_ROT) {
2350 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2352 print ("^1",s1, "^1 died\n");
2353 } else if (type == DEATH_NOAMMO) {
2354 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2356 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2357 } else if (type == DEATH_CAMP) {
2358 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2360 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2361 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2362 HUD_KillNotify_Push(s1, "", 0, type);
2364 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2365 } else if (type == DEATH_CHEAT) {
2366 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2368 print ("^1",s1, "^1 unfairly eliminated themself\n");
2369 } else if (type == DEATH_FIRE) {
2370 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2372 print ("^1",s1, "^1 burned to death\n");
2373 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2374 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2376 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2379 if (stof(s2) > 2) // killcount > 2
2380 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2381 } else if(msg == MSG_KILL) {
2382 w = DEATH_WEAPONOF(type);
2384 HUD_KillNotify_Push(s2, s1, 1, w);
2386 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2388 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2389 HUD_KillNotify_Push(s1, s2, 1, type);
2392 if(cvar("cl_gentle")) {
2393 print ("^1", s1, "^1 took action against a team mate\n");
2395 print ("^1", s1, "^1 mows down a team mate\n");
2398 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2399 if(cvar("cl_gentle"))
2400 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2402 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2404 else if (stof(s2) > 2) {
2405 if(cvar("cl_gentle"))
2406 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2408 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2411 else if(type == KILL_FIRST_BLOOD)
2412 print("^1",s1, "^1 drew first blood", "\n");
2414 else if (type == DEATH_TELEFRAG)
2415 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2416 else if (type == DEATH_DROWN) {
2417 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2419 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2421 else if (type == DEATH_SLIME) {
2422 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2424 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2426 else if (type == DEATH_LAVA) {
2427 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2429 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2431 else if (type == DEATH_FALL) {
2432 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2434 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2436 else if (type == DEATH_SHOOTING_STAR) {
2437 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2439 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2441 else if (type == DEATH_SWAMP) {
2442 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2444 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2446 else if (type == DEATH_HURTTRIGGER)
2448 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2450 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2451 } else if(type == DEATH_SBCRUSH) {
2452 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2454 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2455 } else if(type == DEATH_SBMINIGUN) {
2456 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2458 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2459 } else if(type == DEATH_SBROCKET) {
2460 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2462 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2463 } else if(type == DEATH_SBBLOWUP) {
2464 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2466 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2467 } else if(type == DEATH_WAKIGUN) {
2468 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2470 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2471 } else if(type == DEATH_WAKIROCKET) {
2472 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2474 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2475 } else if(type == DEATH_WAKIBLOWUP) {
2476 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2478 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2479 } else if(type == DEATH_TURRET) {
2480 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2482 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2483 } else if(type == DEATH_TOUCHEXPLODE) {
2484 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2486 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2487 } else if(type == DEATH_CHEAT) {
2488 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2490 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2491 } else if (type == DEATH_FIRE) {
2492 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2494 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2495 } else if (type == DEATH_CUSTOM) {
2496 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2498 print ("^1",s1, "^1 ", s2, "\n");
2500 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2502 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2504 } else if(msg == MSG_SPREE) {
2505 if(type == KILL_END_SPREE) {
2506 if(cvar("cl_gentle"))
2507 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2509 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2510 } else if(type == KILL_SPREE) {
2511 if(cvar("cl_gentle"))
2512 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2514 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2515 } else if(type == KILL_SPREE_3) {
2516 if(cvar("cl_gentle"))
2517 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2519 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2520 } else if(type == KILL_SPREE_5) {
2521 if(cvar("cl_gentle"))
2522 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2524 print (s1,"^7 unleashes ^1RAGE\n");
2525 } else if(type == KILL_SPREE_10) {
2526 if(cvar("cl_gentle"))
2527 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2529 print (s1,"^7 starts the ^1MASSACRE!\n");
2530 } else if(type == KILL_SPREE_15) {
2531 if(cvar("cl_gentle"))
2532 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2534 print (s1,"^7 executes ^1MAYHEM!\n");
2535 } else if(type == KILL_SPREE_20) {
2536 if(cvar("cl_gentle"))
2537 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2539 print (s1,"^7 is a ^1BERSERKER!\n");
2540 } else if(type == KILL_SPREE_25) {
2541 if(cvar("cl_gentle"))
2542 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2544 print (s1,"^7 inflicts ^1CARNAGE!\n");
2545 } else if(type == KILL_SPREE_30) {
2546 if(cvar("cl_gentle"))
2547 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2549 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2551 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2552 if (type == DEATH_DROWN) {
2553 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2556 if(cvar("cl_gentle"))
2557 print ("^1",s1, "^1 was in the water for too long\n");
2559 print ("^1",s1, "^1 drowned\n");
2561 } else if (type == DEATH_SLIME) {
2562 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2564 print ("^1",s1, "^1 was slimed\n");
2565 } else if (type == DEATH_LAVA) {
2566 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2569 if(cvar("cl_gentle"))
2570 print ("^1",s1, "^1 found a hot place\n");
2572 print ("^1",s1, "^1 turned into hot slag\n");
2574 } else if (type == DEATH_FALL) {
2575 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2578 if(cvar("cl_gentle"))
2579 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2581 print ("^1",s1, "^1 hit the ground with a crunch\n");
2583 } else if (type == DEATH_SHOOTING_STAR) {
2584 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2586 print ("^1",s1, "^1 became a shooting star\n");
2587 } else if (type == DEATH_SWAMP) {
2588 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2591 if(cvar("cl_gentle"))
2592 print ("^1",s1, "^1 discovered a swamp\n");
2594 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2596 } else if(type == DEATH_TURRET) {
2597 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2599 print ("^1",s1, "^1 was mowed down by a turret \n");
2600 } else if (type == DEATH_CUSTOM) {
2601 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2603 print ("^1",s1, "^1 ", s2, "\n");
2604 } else if (type == DEATH_HURTTRIGGER) {
2605 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2607 print ("^1",s1, "^1 was in the wrong place\n");
2608 } else if(type == DEATH_TOUCHEXPLODE) {
2609 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2611 print ("^1",s1, "^1 died in an accident\n");
2612 } else if(type == DEATH_CHEAT) {
2613 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2615 print ("^1",s1, "^1 was unfairly eliminated\n");
2616 } else if(type == DEATH_FIRE) {
2617 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2620 if(cvar("cl_gentle"))
2621 print ("^1",s1, "^1 felt a little hot\n");
2623 print ("^1",s1, "^1 burnt to death\n");
2626 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2629 if(cvar("cl_gentle"))
2630 print ("^1",s1, "^1 needs a restart\n");
2632 print ("^1",s1, "^1 died\n");
2635 } else if(msg == MSG_KILL_ACTION_SPREE) {
2636 if(cvar("cl_gentle"))
2637 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2639 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2640 } else if(msg == MSG_INFO) {
2641 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2642 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2643 print(s1, "^7 got the ", s2, "\n");
2644 } else if(type == INFO_LOSTFLAG) {
2645 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2646 print(s1, "^7 lost the ", s2, "\n");
2647 } else if(type == INFO_PICKUPFLAG) {
2648 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2649 print(s1, "^7 picked up the ", s2, "\n");
2650 } else if(type == INFO_RETURNFLAG) {
2651 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2652 print(s1, "^7 returned the ", s2, "\n");
2657 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2659 void HUD_Centerprint(string s1, string s2, float type, float msg)
2661 if(msg == MSG_SUICIDE) {
2662 if (type == DEATH_TEAMCHANGE) {
2663 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2664 } else if (type == DEATH_AUTOTEAMCHANGE) {
2665 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2666 } else if (type == DEATH_CAMP) {
2667 if(cvar("cl_gentle"))
2668 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2670 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2671 } else if (type == DEATH_NOAMMO) {
2672 if(cvar("cl_gentle"))
2673 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2675 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2676 } else if (type == DEATH_ROT) {
2677 if(cvar("cl_gentle"))
2678 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2680 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2681 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2682 if(cvar("cl_gentle"))
2683 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2685 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2686 } else if (type == DEATH_QUIET) {
2688 } else if (type == DEATH_KILL) {
2689 if(cvar("cl_gentle"))
2690 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2692 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2694 } else if(msg == MSG_KILL) {
2695 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2696 if(cvar("cl_gentle")) {
2697 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2699 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2701 } else if (type == KILL_FIRST_BLOOD) {
2702 if(cvar("cl_gentle")) {
2703 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2705 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2707 } else if (type == KILL_FIRST_VICTIM) {
2708 if(cvar("cl_gentle")) {
2709 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2711 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2713 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2714 if(cvar("cl_gentle")) {
2715 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2717 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2719 } else if (type == KILL_TYPEFRAGGED) {
2720 if(cvar("cl_gentle")) {
2721 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2723 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2725 } else if (type == KILL_FRAG) {
2726 if(cvar("cl_gentle")) {
2727 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2729 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2731 } else if (type == KILL_FRAGGED) {
2732 if(cvar("cl_gentle")) {
2733 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2735 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2738 } else if(msg == MSG_KILL_ACTION) {
2739 // TODO: invent more centerprints here?
2740 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2744 void HUD_Notify (void)
2746 float id = HUD_PANEL_NOTIFY;
2748 pos = HUD_Panel_GetPos(id);
2749 mySize = HUD_Panel_GetSize(id);
2751 HUD_Panel_DrawBg(id, pos, mySize, 0);
2753 padding = HUD_Panel_GetPadding(id);
2756 pos += '1 1 0' * padding;
2757 mySize -= '2 2 0' * padding;
2760 float entries, height;
2761 entries = bound(1, floor(14 * mySize_y/mySize_x), 12);
2762 height = mySize_y/entries;
2763 entries -= 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2766 fontsize = '0.5 0.5 0' * height;
2770 when = cvar("hud_notify_time");
2772 fadetime = cvar("hud_notify_fadetime");
2776 vector pos_attacker, pos_victim;
2778 float width_attacker, width_victim;
2779 string attacker, victim;
2782 for(j = 0; j < entries; ++j)
2784 if(cvar("hud_notify_flip"))
2786 else // rather nasty hack for ordering items from the bottom up
2787 i = entries - j - 1;
2788 if(cvar("hud_notify_info_top"))
2789 i += 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2793 if(killnotify_times[j] + when > time)
2796 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2800 if(killnotify_times[j] + when > time)
2806 // TODO: maybe print in team colors?
2807 // TODO: maybe this could be cleaned up somehow...
2808 // TODO: less copypaste code below
2811 if(killnotify_actiontype[j] == 0 && !hud_configure)
2813 attacker = textShortenToWidth(killnotify_attackers[j], mySize_x - 2 * height, fontsize, stringwidth_colors);
2815 width_attacker = stringwidth(attacker, TRUE, fontsize);
2816 pos_attacker = pos + eX * 0.5 * (mySize_x - width_attacker + 2 * height) + eY * 0.5 * fontsize_y + eY * i * height;
2818 weap_pos = pos + eX * 0.5 * (mySize_x - width_attacker) - eX * height + eY * i * height;
2819 if(killnotify_deathtype[j] == DEATH_GENERIC)
2821 drawpic_skin(weap_pos, "notify_death", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2822 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2824 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2826 drawpic_skin(weap_pos, "notify_outofammo", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2827 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2829 else if(killnotify_deathtype[j] == DEATH_KILL)
2831 drawpic_skin(weap_pos, "notify_selfkill", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2832 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2834 else if(killnotify_deathtype[j] == DEATH_CAMP)
2836 drawpic_skin(weap_pos, "notify_camping", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2837 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2839 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2841 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2842 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2844 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2846 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2847 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2849 else if(killnotify_deathtype[j] == DEATH_DROWN)
2851 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2852 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2854 else if(killnotify_deathtype[j] == DEATH_SLIME)
2856 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2857 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2859 else if(killnotify_deathtype[j] == DEATH_LAVA)
2861 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2862 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2864 else if(killnotify_deathtype[j] == DEATH_FALL)
2866 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2867 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2869 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2871 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2872 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2874 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2876 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2877 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2879 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2881 if(killnotify_victims[j] == "^1RED^7 flag")
2885 drawpic_skin(weap_pos, strcat("flag_", s, "_carrying"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2886 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2888 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2890 if(killnotify_victims[j] == "^1RED^7 flag")
2894 drawpic_skin(weap_pos, strcat("flag_", s, "_taken"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2895 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2897 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2899 if(killnotify_victims[j] == "^1RED^7 flag")
2903 drawpic_skin(weap_pos, strcat("flag_", s, "_lost"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2904 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2907 // X [did action to] Y
2912 attacker = textShortenToWidth("Player1", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2913 victim = textShortenToWidth("Player2", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2914 a = bound(0, (when - j) / 4, 1);
2918 attacker = textShortenToWidth(killnotify_attackers[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2919 victim = textShortenToWidth(killnotify_victims[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2921 width_attacker = stringwidth(attacker, TRUE, fontsize);
2922 width_victim = stringwidth(victim, TRUE, fontsize);
2923 pos_attacker = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_attacker) + eY * 0.5 * fontsize_y + eY * i * height;
2924 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;
2925 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2927 if(hud_configure) // example actions for config mode
2929 drawpic_skin(weap_pos, strcat("weapon", "electro"), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2930 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2931 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2933 else if(WEP_VALID(killnotify_deathtype[j]))
2935 self = get_weaponinfo(killnotify_deathtype[j]);
2936 drawpic_skin(weap_pos, strcat("weapon", self.netname), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2937 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2938 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2940 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2942 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2943 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2944 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2946 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2948 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2949 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2950 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2952 else if(killnotify_deathtype[j] == DEATH_DROWN)
2954 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2955 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2956 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2958 else if(killnotify_deathtype[j] == DEATH_SLIME)
2960 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2961 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2962 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2964 else if(killnotify_deathtype[j] == DEATH_LAVA)
2966 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2967 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2968 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2970 else if(killnotify_deathtype[j] == DEATH_FALL)
2972 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2973 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2974 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2976 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2978 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2979 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2980 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2982 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2984 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2985 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2986 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2997 if(cvar("hud_notify_info_top"))
3000 o = pos + eY * mySize_y - eY * 2 * height;
3002 if(spectatee_status && !intermission)
3004 //drawfont = hud_bigfont;
3005 if(spectatee_status == -1)
3008 s = GetPlayerName(spectatee_status - 1);
3010 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
3011 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3012 //drawfont = hud_font;
3014 // spectator text in the upper right corner
3015 if(spectatee_status == -1)
3016 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
3018 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
3019 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3020 o += eY * fontsize_y;
3022 if(spectatee_status == -1)
3023 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
3025 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
3026 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3027 o += eY * fontsize_y;
3029 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
3030 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3031 o += eY * fontsize_y;
3033 if(gametype == GAME_ARENA)
3034 s = "^1Wait for your turn to join";
3035 else if(gametype == GAME_LMS)
3038 sk = playerslots[player_localentnum - 1];
3039 if(sk.(scores[ps_primary]) >= 666)
3040 s = "^1Match has already begun";
3041 else if(sk.(scores[ps_primary]) > 0)
3042 s = "^1You have no more lives left";
3044 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
3047 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
3048 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3049 o += eY * fontsize_y;
3051 //show restart countdown:
3052 if (time < getstatf(STAT_GAMESTARTTIME)) {
3054 //we need to ceil, otherwise the countdown would be off by .5 when using round()
3055 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
3056 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
3057 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3058 o += eY * fontsize_y;
3061 if(warmup_stage && !intermission)
3063 s = "^2Currently in ^1warmup^2 stage!";
3064 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3065 o += eY * fontsize_y;
3069 if(mod(time, 1) >= 0.5)
3074 if(ready_waiting && !intermission && !spectatee_status)
3076 if(ready_waiting_for_me)
3079 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
3081 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
3086 s = strcat("^2Waiting for others to ready up to end warmup...");
3088 s = strcat("^2Waiting for others to ready up...");
3090 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3091 o += eY * fontsize_y;
3093 else if(warmup_stage && !intermission && !spectatee_status)
3095 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
3096 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3097 o += eY * fontsize_y;
3100 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
3102 float ts_min, ts_max;
3103 tm = teams.sort_next;
3106 for(; tm.sort_next; tm = tm.sort_next)
3108 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
3110 if(!ts_min) ts_min = tm.team_size;
3111 else ts_min = min(ts_min, tm.team_size);
3112 if(!ts_max) ts_max = tm.team_size;
3113 else ts_max = max(ts_max, tm.team_size);
3115 if ((ts_max - ts_min) > 1)
3117 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
3118 tm = GetTeam(myteam, false);
3120 if (tm.team != COLOR_SPECTATOR)
3121 if (tm.team_size == ts_max)
3122 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
3124 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3125 o += eY * fontsize_y;
3131 s = "^7Press ^3ESC ^7to show HUD options.";
3132 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3133 o += eY * fontsize_y;
3134 s = "^3Doubleclick a panel for panel-specific options.";
3135 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3136 o += eY * fontsize_y;
3142 void HUD_Timer(void)
3144 float id = HUD_PANEL_TIMER;
3146 pos = HUD_Panel_GetPos(id);
3147 mySize = HUD_Panel_GetSize(id);
3149 HUD_Panel_DrawBg(id, pos, mySize, 0);
3151 padding = HUD_Panel_GetPadding(id);
3154 pos += '1 1 0' * padding;
3155 mySize -= '2 2 0' * padding;
3158 float timelimit, elapsedTime, minutes, seconds, timeleft, minutesLeft, secondsLeft;
3160 timelimit = getstatf(STAT_TIMELIMIT);
3162 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3163 timeleft = ceil(timeleft);
3164 minutesLeft = floor(timeleft / 60);
3165 secondsLeft = timeleft - minutesLeft*60;
3168 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3169 timer_color = '1 1 1'; //white
3170 else if(minutesLeft >= 1)
3171 timer_color = '1 1 0'; //yellow
3173 timer_color = '1 0 0'; //red
3175 if (cvar("hud_timer_increment") || timelimit == 0 || warmup_stage) {
3176 if (time < getstatf(STAT_GAMESTARTTIME)) {
3177 //while restart is still active, show 00:00
3178 minutes = seconds = 0;
3180 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3181 minutes = floor(elapsedTime / 60);
3182 seconds = elapsedTime - minutes*60;
3185 minutes = minutesLeft;
3186 seconds = secondsLeft;
3191 minutes = min(minutes, 999);
3192 if(minutesLeft >= 1 || cvar("hud_timer_increment") || timelimit == 0 || warmup_stage) {
3193 HUD_DrawXNum(pos + eX * mySize_x - eX * 5.1 * mySize_y, minutes, 3, 0, mySize_y, timer_color, 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3194 drawpic_skin(pos + eX * mySize_x - eX * 2.57 * mySize_y, "num_colon", '1 1 0' * mySize_y, timer_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3196 HUD_DrawXNum(pos + eX * mySize_x - eX * 2 * mySize_y, seconds, -2, 0, mySize_y, timer_color, 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3201 void HUD_Radar(void)
3203 float id = HUD_PANEL_RADAR;
3205 pos = HUD_Panel_GetPos(id);
3206 mySize = HUD_Panel_GetSize(id);
3208 HUD_Panel_DrawBg(id, pos, mySize, 0);
3210 padding = HUD_Panel_GetPadding(id);
3213 pos += '1 1 0' * padding;
3214 mySize -= '2 2 0' * padding;
3217 local float color1, color2; // color already declared as a global in hud.qc
3220 float scale2d, normalsize, bigsize;
3223 teamradar_origin2d = pos + 0.5 * mySize;
3224 teamradar_size2d = mySize;
3226 if(minimapname == "")
3229 teamradar_loadcvars();
3231 switch(hud_radar_zoommode)
3235 f = current_zoomfraction;
3238 f = 1 - current_zoomfraction;
3248 switch(hud_radar_rotation)
3251 teamradar_angle = view_angles_y - 90;
3254 teamradar_angle = 90 * hud_radar_rotation;
3258 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3259 teamradar_size2d = mySize;
3261 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3263 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3264 if(hud_radar_rotation == 0)
3266 // max-min distance must fit the radar in any rotation
3267 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3271 vector c0, c1, c2, c3, span;
3272 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3273 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3274 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3275 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3277 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3278 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3280 // max-min distance must fit the radar in x=x, y=y
3282 teamradar_size2d_x * scale2d / (1.05 * span_x),
3283 teamradar_size2d_y * scale2d / (1.05 * span_y)
3287 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3288 if(bigsize > normalsize)
3289 normalsize = bigsize;
3293 + (1 - f) * normalsize;
3294 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3295 f * (mi_min + mi_max) * 0.5
3296 + (1 - f) * view_origin);
3298 color1 = GetPlayerColor(player_localentnum-1);
3299 rgb = GetTeamRGB(color1);
3308 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3310 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3311 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3312 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3313 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, HUD_Panel_GetFgAlpha(id));
3314 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3316 color2 = GetPlayerColor(tm.sv_entnum);
3317 //if(color == COLOR_SPECTATOR || color == color2)
3318 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3320 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3322 drawresetcliparea();
3327 void HUD_Score(void)
3329 float id = HUD_PANEL_SCORE;
3331 pos = HUD_Panel_GetPos(id);
3332 mySize = HUD_Panel_GetSize(id);
3334 HUD_Panel_DrawBg(id, pos, mySize, 0);
3336 padding = HUD_Panel_GetPadding(id);
3339 pos += '1 1 0' * padding;
3340 mySize -= '2 2 0' * padding;
3343 float score, distribution, leader;
3344 float score_len, distr_len;
3345 vector distribution_color;
3347 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3349 // TODO... this (race part) still uses constant coordinates :/
3350 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3351 /*pl = players.sort_next;
3354 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3355 if(pl.scores[ps_primary] == 0)
3358 score = me.(scores[ps_primary]);
3360 float racemin, racesec, racemsec;
3361 float distsec, distmsec, minusplus;
3363 racemin = floor(score/(60 * TIME_FACTOR));
3364 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
3365 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
3367 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3368 // distribution display
3369 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3371 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
3372 distmsec = fabs(distribution);
3374 distsec = floor(fabs(distribution)/TIME_FACTOR);
3375 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
3376 if (distribution < 0)
3380 if (distribution <= 0) {
3381 distribution_color = eY;
3382 minusplus = 1; // minusplus 1: always prefix with minus sign
3385 distribution_color = eX;
3386 minusplus = 2; // minusplus 1: always prefix with plus sign
3388 HUD_DrawXNum(bottomright - '0 48 0' - '16 0 0' * TIME_DECIMALS, distmsec, -TIME_DECIMALS, 0, 16, distribution_color, 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3389 HUD_DrawXNum(bottomright - '68 48 0' - '16 0 0' * TIME_DECIMALS, distsec, 4, minusplus, 16, distribution_color, 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3390 drawpic_skin(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "num_dot", '16 16 0', distribution_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE);
3392 // race record display
3393 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
3394 drawpic_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', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3396 HUD_DrawXNum(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0', racemsec, -TIME_DECIMALS, 0, 30, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3397 HUD_DrawXNum(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '66 0 0', racesec, -2, 0, 30, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3398 drawpic_skin(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '18 0 0', "num_dot", '30 30 0', '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE);
3400 HUD_DrawXNum(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '132 0 0', racemin, -2, 0, 30, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3401 drawpic_skin(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '84 0 0', "num_colon", '30 30 0', '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE);
3403 } else if (!teamplay) { // non-teamgames
3404 // me vector := [team/connected frags id]
3405 pl = players.sort_next;
3412 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3416 score = me.(scores[ps_primary]);
3420 if(distribution >= 5) {
3421 distribution_color = eY;
3423 } else if(distribution >= 0) {
3424 distribution_color = '1 1 1';
3426 } else if(distribution >= -5)
3427 distribution_color = '1 1 0';
3429 distribution_color = eX;
3431 score_len = strlen(ftos(score));
3432 distr_len = strlen(ftos(distribution));
3434 HUD_DrawXNum(pos + eX * mySize_x - eX * 3 * 0.33 * mySize_y, distribution, 3, 3, 0.33 * mySize_y, distribution_color, 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3436 drawpic_skin(pos + eX * mySize_x - eX * score_len * mySize_y - eX * 3 * 0.33 * mySize_y, strcat("num_leading_", ftos(score_len)), eX * score_len * mySize_y + eY * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3437 HUD_DrawXNum(pos + eX * mySize_x - eX * 3 * mySize_y - eX * 3 * 0.33 * mySize_y, score, 3, 0, mySize_y, distribution_color, 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3438 } else { // teamgames
3439 float max_fragcount;
3440 max_fragcount = -99;
3443 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3444 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !hud_configure)) // no players? don't display
3446 score = tm.(teamscores[ts_primary]);
3451 score_len = strlen(ftos(score));
3453 if (score > max_fragcount)
3454 max_fragcount = score;
3456 if(tm.team == myteam) {
3457 if (max_fragcount == score)
3460 drawpic_skin(pos + eX * mySize_x - eX * score_len * mySize_y - eX * 3 * 0.33 * mySize_y, strcat("num_leading_", ftos(score_len)), eX * score_len * mySize_y + eY * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3461 HUD_DrawXNum(pos + eX * mySize_x - eX * 3 * mySize_y - eX * 3 * 0.33 * mySize_y, score, 3, 0, mySize_y, GetTeamRGB(tm.team) * 0.8, 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3463 if (max_fragcount == score)
3466 drawpic_skin(pos + eX * mySize_x - eX * 0.33 * score_len * mySize_y + eY * 0.33 * mySize_y * teamnum, strcat("num_leading_", ftos(score_len)), eX * 0.33 * score_len * mySize_y + eY * 0.33 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3467 HUD_DrawXNum(pos + eX * mySize_x - eX * 3 * 0.33 * mySize_y + eY * 0.33 * mySize_y * teamnum, score, 3, 0, 0.33 * mySize_y, GetTeamRGB(tm.team) * 0.8, 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3476 void HUD_RaceTimer (void) {
3477 float id = HUD_PANEL_RACETIMER;
3479 pos = HUD_Panel_GetPos(id);
3480 mySize = HUD_Panel_GetSize(id);
3482 HUD_Panel_DrawBg(id, pos, mySize, 0);
3484 padding = HUD_Panel_GetPadding(id);
3487 pos += '1 1 0' * padding;
3488 mySize -= '2 2 0' * padding;
3491 drawfont = hud_bigfont;
3493 string s, forcetime;
3498 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', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3499 s = "^1Intermediate 1 (+15.42)";
3500 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, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3501 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3502 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, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3504 else if(race_checkpointtime)
3506 a = bound(0, 2 - (time - race_checkpointtime), 1);
3509 if(a > 0) // just hit a checkpoint?
3511 if(race_checkpoint != 254)
3513 if(race_time && race_previousbesttime)
3514 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3516 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3518 forcetime = TIME_ENCODED_TOSTRING(race_time);
3523 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3525 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3526 if(a > 0) // next one?
3528 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3533 if(s != "" && a > 0)
3535 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3536 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3537 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, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3540 if(race_penaltytime)
3542 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3545 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3546 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3547 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3548 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, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3554 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3555 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id), 0, a);
3556 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', HUD_Panel_GetFgAlpha(id), 0, a);
3561 if(race_laptime && race_checkpoint != 255)
3563 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3564 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3565 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', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3570 if(race_mycheckpointtime)
3572 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3573 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3574 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3575 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3576 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, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3578 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3580 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3581 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3582 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3583 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3584 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, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3587 if(race_penaltytime && !race_penaltyaccumulator)
3589 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3590 a = bound(0, (1 + t - time), 1);
3594 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3596 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3597 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3598 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3599 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3604 drawfont = hud_font;
3609 float vote_yescount;
3612 float vote_highlighted; // currently selected vote
3614 float vote_active; // is there an active vote?
3615 float vote_prev; // previous state of vote_active to check for a change
3617 float vote_change; // "time" when vote_active changed
3619 void HUD_VoteWindow(void)
3621 float id = HUD_PANEL_VOTE;
3623 pos = HUD_Panel_GetPos(id);
3624 mySize = HUD_Panel_GetSize(id);
3628 if(vote_active != vote_prev) {
3630 vote_prev = vote_active;
3633 if(vote_active || hud_configure)
3634 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3636 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3648 a = vote_alpha * bound(cvar_or("hud_vote_alreadyvoted_alpha", 0.75), 1 - vote_highlighted, 1);
3650 HUD_Panel_DrawBg(id, pos, mySize, a);
3652 padding = HUD_Panel_GetPadding(id);
3655 pos += '1 1 0' * padding;
3656 mySize -= '2 2 0' * padding;
3659 drawpic_skin(pos, "voteprogress_back", mySize, '1 1 1', a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3661 s = "A vote has been called for: ";
3662 drawstring(pos + '0.5 0 0' * mySize_x + '0 0.1 0' * mySize_y - eX * stringwidth(s, FALSE, '1 1 0' * 0.5 * mySize_y*(1/5)), s, '1 1 0' * mySize_y*(1/5), '1 1 1', a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3663 s = textShortenToWidth(vote_called_vote, mySize_x * 0.96, '1 1 0' * mySize_y*(1/5), stringwidth_colors); // TODO: broken?
3665 s = "Configure the HUD";
3666 drawcolorcodedstring(pos + '0.52 0 0' * mySize_x + '0 0.3 0' * mySize_y - eX * stringwidth(s, FALSE, '1 1 0' * 0.5 * mySize_y*(1/6)), s, '1 1 0' * mySize_y*(1/6), a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3668 // print the yes/no counts
3669 s = strcat("Yes: ", ftos(vote_yescount));
3670 drawstring(pos + '0 0.6 0' * mySize_y + '0.02 0 0' * mySize_x, s, '1 1 0' * mySize_y*(1/6) , eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3671 s = strcat("No: ", ftos(vote_nocount));
3672 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 * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3674 // draw the progress bars
3675 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3676 drawpic_skin(pos, "voteprogress_prog", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3678 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3679 drawpic_skin(pos, "voteprogress_prog", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3681 // draw the highlights
3682 if(vote_highlighted == 1) {
3683 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3684 drawpic_skin(pos, "voteprogress_voted", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3686 else if(vote_highlighted == 2) {
3687 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3688 drawpic_skin(pos, "voteprogress_voted", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3691 drawresetcliparea();
3694 vote_highlighted = 0;
3698 // Mod icons panel (#10)
3701 float mod_active; // is there any active mod icon?
3703 // CTF HUD modicon section
3704 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3705 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3706 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3708 void HUD_Mod_CTF_Reset(void)
3710 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3713 void HUD_Mod_CTF(vector pos, vector mySize)
3715 vector redflag_pos, blueflag_pos;
3716 float f; // every function should have that
3718 float redflag, blueflag; // current status
3719 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3722 stat_items = getstati(STAT_ITEMS);
3723 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3724 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3726 if(redflag || blueflag)
3737 // when status CHANGES, set old status into prevstatus and current status into status
3738 if (redflag != redflag_prevframe)
3740 redflag_statuschange_time = time;
3741 redflag_prevstatus = redflag_prevframe;
3742 redflag_prevframe = redflag;
3745 if (blueflag != blueflag_prevframe)
3747 blueflag_statuschange_time = time;
3748 blueflag_prevstatus = blueflag_prevframe;
3749 blueflag_prevframe = blueflag;
3752 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3753 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3755 float BLINK_FACTOR = 0.15;
3756 float BLINK_BASE = 0.85;
3758 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3760 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3762 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3764 string red_icon, red_icon_prevstatus;
3765 float red_alpha, red_alpha_prevstatus;
3766 red_alpha = red_alpha_prevstatus = 1;
3768 case 1: red_icon = "flag_red_taken"; break;
3769 case 2: red_icon = "flag_red_lost"; break;
3770 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3772 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3773 red_icon = "flag_red_shielded";
3775 red_icon = string_null;
3778 switch(redflag_prevstatus) {
3779 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3780 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3781 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3784 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3785 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3786 red_icon_prevstatus = "flag_red_shielded";
3788 red_icon_prevstatus = string_null;
3792 string blue_icon, blue_icon_prevstatus;
3793 float blue_alpha, blue_alpha_prevstatus;
3794 blue_alpha = blue_alpha_prevstatus = 1;
3796 case 1: blue_icon = "flag_blue_taken"; break;
3797 case 2: blue_icon = "flag_blue_lost"; break;
3798 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3800 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3801 blue_icon = "flag_blue_shielded";
3803 blue_icon = string_null;
3806 switch(blueflag_prevstatus) {
3807 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3808 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3809 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3812 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3813 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3814 blue_icon_prevstatus = "flag_blue_shielded";
3816 blue_icon_prevstatus = string_null;
3820 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3822 blueflag_pos = pos + eX * mySize_y;
3825 redflag_pos = pos + eX * mySize_y;
3828 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3829 if(red_icon_prevstatus && f < 1)
3830 drawpic_skin_expanding(redflag_pos, red_icon_prevstatus, '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3832 drawpic_skin(redflag_pos, red_icon, '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * red_alpha * f, DRAWFLAG_NORMAL);
3834 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3835 if(blue_icon_prevstatus && f < 1)
3836 drawpic_skin_expanding(blueflag_pos, blue_icon_prevstatus, '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3838 drawpic_skin(blueflag_pos, blue_icon, '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * blue_alpha * f, DRAWFLAG_NORMAL);
3841 // Keyhunt HUD modicon section
3842 float kh_runheretime;
3844 void HUD_Mod_KH_Reset(void)
3849 void HUD_Mod_KH(vector pos, vector mySize)
3851 mod_active = 1; // keyhunt should never hide the mod icons panel
3855 vector p, pa, kh_size, kh_asize;
3858 p_y = pos_y + 0.25 * mySize_y;
3860 kh_keys = getstati(STAT_KH_KEYS);
3862 kh_size_x = mySize_x * 0.25;
3863 kh_size_y = 0.75 * mySize_y;
3865 pa = p - eY * 0.25 * mySize_y;
3867 kh_asize_x = mySize_x * 0.25;
3868 kh_asize_y = mySize_y * 0.25;
3874 for(i = 0; i < 4; ++i)
3876 key = floor(kh_keys / pow(32, i)) & 31;
3878 if(keyteam == 30 && keycount <= 4)
3880 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3884 // this yields 8 exactly if "RUN HERE" shows
3889 kh_runheretime = time;
3890 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3895 for(i = 0; i < 4; ++i)
3897 key = floor(kh_keys / pow(32, i)) & 31;
3910 default: // owned or dropped
3915 a = a * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3916 aa = aa * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3922 drawpic_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3925 drawpic_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3928 drawpic_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3931 drawpic_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3936 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3939 drawpic_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3942 drawpic_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3945 drawpic_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3948 drawpic_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3952 p_x += 0.25 * mySize_x;
3953 pa_x += 0.25 * mySize_x;
3957 // Nexball HUD mod icon
3958 void HUD_Mod_NexBall(vector pos, vector mySize)
3960 float stat_items, nb_pb_starttime, dt, p;
3962 stat_items = getstati(STAT_ITEMS);
3963 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3965 if (stat_items & IT_KEY1)
3970 //Manage the progress bar if any
3971 if (nb_pb_starttime > 0)
3973 dt = mod(time - nb_pb_starttime, nb_pb_period);
3974 // one period of positive triangle
3975 p = 2 * dt / nb_pb_period;
3980 HUD_Panel_DrawProgressBar(pos, 0, eX * p * mySize_x + eY * mySize_y, HUD_Panel_GetProgressBarColor("nexball"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3983 pos_x += 0.5 * mySize_x - 0.5 * mySize_y; //horizontal margin to the picture
3985 if (stat_items & IT_KEY1)
3986 drawpic_skin(pos, "nexball_carrying", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3989 // Race/CTS HUD mod icons
3990 float crecordtime_prev; // last remembered crecordtime
3991 float crecordtime_change_time; // time when crecordtime last changed
3992 float srecordtime_prev; // last remembered srecordtime
3993 float srecordtime_change_time; // time when srecordtime last changed
3995 float race_status_time;
3996 float race_status_prev;
3997 string race_status_name_prev;
3998 void HUD_Mod_Race(vector pos, vector mySize)
4000 mod_active = 1; // race should never hide the mod icons panel
4002 me = playerslots[player_localentnum - 1];
4004 float f; // yet another function has this
4005 score = me.(scores[ps_primary]);
4007 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
4008 return; // no records in the actual race
4010 drawfont = hud_bigfont;
4012 // clientside personal record
4014 if(gametype == GAME_CTS)
4018 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4020 if(score && (score < t || !t)) {
4021 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4022 if(cvar("cl_autodemo_delete_keeprecords"))
4024 f = cvar("cl_autodemo_delete");
4026 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4030 if(t != crecordtime_prev) {
4031 crecordtime_prev = t;
4032 crecordtime_change_time = time;
4034 f = time - crecordtime_change_time;
4037 drawstring(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4038 drawstring(pos + eY * 0.2 * mySize_y, TIME_ENCODED_TOSTRING(t), '1 1 0' * 0.2 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4040 drawstring(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4041 drawstring(pos + eY * 0.2 * mySize_y, TIME_ENCODED_TOSTRING(t), '1 1 0' * 0.2 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4042 drawstring_expanding(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL, f);
4043 drawstring_expanding(pos + eY * 0.2 * mySize_y, TIME_ENCODED_TOSTRING(t), '1 1 0' * 0.2 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL, f);
4047 t = race_server_record;
4048 if(t != srecordtime_prev) {
4049 srecordtime_prev = t;
4050 srecordtime_change_time = time;
4052 f = time - srecordtime_change_time;
4055 drawstring(pos + eY * 0.5 * mySize_y, "Server best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4056 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', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4058 drawstring(pos + eY * 0.5 * mySize_y, "Server best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4059 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', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4060 drawstring_expanding(pos + eY * 0.5 * mySize_y, "Server best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL, f);
4061 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', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL, f);
4064 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4065 race_status_time = time + 5;
4066 race_status_prev = race_status;
4067 if (race_status_name_prev)
4068 strunzone(race_status_name_prev);
4069 race_status_name_prev = strzone(race_status_name);
4072 pos_x += mySize_x/2;
4075 a = bound(0, race_status_time - time, 1);
4078 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4082 rank = race_CheckName(race_status_name);
4084 rankname = race_PlaceName(rank);
4087 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4089 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4091 if(race_status == 0)
4092 drawpic_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4093 else if(race_status == 1) {
4094 drawpic_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4095 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4096 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4097 } else if(race_status == 2) {
4098 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4099 drawpic_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4101 drawpic_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4102 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4103 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4104 } else if(race_status == 3) {
4105 drawpic_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4106 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4107 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4110 if (race_status_time - time <= 0) {
4111 race_status_prev = -1;
4113 if(race_status_name)
4114 strunzone(race_status_name);
4115 race_status_name = string_null;
4116 if(race_status_name_prev)
4117 strunzone(race_status_name_prev);
4118 race_status_name_prev = string_null;
4120 drawfont = hud_font;
4123 float mod_prev; // previous state of mod_active to check for a change
4125 float mod_change; // "time" when mod_active changed
4127 void HUD_ModIcons(void)
4129 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !hud_configure)
4132 float id = HUD_PANEL_MODICONS;
4134 pos = HUD_Panel_GetPos(id);
4135 mySize = HUD_Panel_GetSize(id);
4137 if(mod_active != mod_prev) {
4139 mod_prev = mod_active;
4142 if(mod_active || hud_configure)
4143 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4145 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4148 HUD_Panel_DrawBg(id, pos, mySize, mod_alpha);
4151 padding = HUD_Panel_GetPadding(id);
4154 pos += '1 1 0' * padding;
4155 mySize -= '2 2 0' * padding;
4158 // these MUST be ran in order to update mod_active
4159 if(gametype == GAME_KEYHUNT)
4160 HUD_Mod_KH(pos, mySize);
4161 else if(gametype == GAME_CTF || hud_configure)
4162 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4163 else if(gametype == GAME_NEXBALL)
4164 HUD_Mod_NexBall(pos, mySize);
4165 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4166 HUD_Mod_Race(pos, mySize);
4169 // Draw pressed keys (#11)
4171 void HUD_DrawPressedKeys(void)
4173 float id = HUD_PANEL_PRESSEDKEYS;
4175 pos = HUD_Panel_GetPos(id);
4176 mySize = HUD_Panel_GetSize(id);
4178 HUD_Panel_DrawBg(id, pos, mySize, 0);
4180 padding = HUD_Panel_GetPadding(id);
4183 pos += '1 1 0' * padding;
4184 mySize -= '2 2 0' * padding;
4189 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4190 drawpic_skin(pos, "key_bg.tga", mySize, '1 1 1', 0.1 * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4191 drawpic_skin(pos + eX * mySize_x - eX * 0.22 * mySize_x + eY * 0.195 * mySize_y, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), '1 1 0' * (1/3) * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4192 drawpic_skin(pos + eX * 0.5 * mySize_x - eX * 0.23 * mySize_y + eY * 0.040 * mySize_y, ((pressedkeys & KEY_FORWARD) ? "key_forward_inv.tga" : "key_forward.tga"), '1 1 0' * 0.46 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4193 drawpic_skin(pos + eX * 0.023 * mySize_x + eY * 0.195 * mySize_y, ((pressedkeys & KEY_JUMP) ? "key_jump_inv.tga" : "key_jump.tga"), '1 1 0' * (1/3) * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4194 drawpic_skin(pos + eX * 0.1 * mySize_x + eY * 0.486 * mySize_y, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), '1 1 0' * 0.46 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4195 drawpic_skin(pos + eX * 0.5 * mySize_x - eX * 0.23 * mySize_y + eY * 0.486 * mySize_y, ((pressedkeys & KEY_BACKWARD) ? "key_backward_inv.tga" : "key_backward.tga"), '1 1 0' * 0.46 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4196 drawpic_skin(pos + eX * mySize_x - eX * 0.372 * mySize_x + eY * 0.486 * mySize_y, ((pressedkeys & KEY_RIGHT) ? "key_right_inv.tga" : "key_right.tga"), '1 1 0' * 0.46 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4199 // Handle chat as a panel (#12)
4203 float id = HUD_PANEL_CHAT;
4205 pos = HUD_Panel_GetPos(id);
4206 mySize = HUD_Panel_GetSize(id);
4208 HUD_Panel_DrawBg(id, pos, mySize, 0);
4210 padding = HUD_Panel_GetPadding(id);
4213 pos += '1 1 0' * padding;
4214 mySize -= '2 2 0' * padding;
4217 cvar_set("con_chatrect", "1");
4219 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4220 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4222 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4223 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4228 chatsize = cvar("con_chatsize");
4229 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4231 for(i = 0; i < cvar("con_chat"); ++i)
4233 if(i == cvar("con_chat") - 1)
4234 a = HUD_Panel_GetFgAlpha(id);
4236 a = HUD_Panel_GetFgAlpha(id) * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4237 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);
4242 // Engine info panel (#13)
4249 float frametimeavg1; // 1 frame ago
4250 float frametimeavg2; // 2 frames ago
4251 void HUD_EngineInfo(void)
4253 float id = HUD_PANEL_ENGINEINFO;
4255 pos = HUD_Panel_GetPos(id);
4256 mySize = HUD_Panel_GetSize(id);
4258 HUD_Panel_DrawBg(id, pos, mySize, 0);
4260 padding = HUD_Panel_GetPadding(id);
4263 pos += '1 1 0' * padding;
4264 mySize -= '2 2 0' * padding;
4267 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4269 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4270 frametimeavg2 = frametimeavg1;
4271 frametimeavg1 = frametimeavg;
4274 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4275 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.
4277 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
4278 prevfps = (1/frametime);
4279 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"
4285 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4287 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4289 prevfps_time = time;
4294 color = HUD_Get_Num_Color (prevfps, 100);
4295 drawstring(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), '1 1 0' * mySize_y, color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4303 void HUD_ShowSpeed(void)
4306 float pos, conversion_factor;
4307 string speed, zspeed, unit;
4309 switch(cvar("cl_showspeed_unit"))
4314 conversion_factor = 1.0;
4318 conversion_factor = 1.0;
4322 conversion_factor = 0.0254;
4326 conversion_factor = 0.0254 * 3.6;
4330 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4334 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4338 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4340 numsize_x = numsize_y = cvar("cl_showspeed_size");
4341 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4343 drawfont = hud_bigfont;
4344 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4346 if (cvar("cl_showspeed_z") == 1) {
4347 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4348 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4351 drawfont = hud_font;
4354 vector acc_prevspeed;
4358 void HUD_ShowAcceleration(void)
4360 float acceleration, sz, scale, alpha, f;
4361 vector pos, top, rgb;
4362 top_x = vid_conwidth/2;
4365 f = time - acc_prevtime;
4366 if(cvar("cl_showacceleration_z"))
4367 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4369 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4370 acc_prevspeed = pmove_vel;
4371 acc_prevtime = time;
4373 f = bound(0, f * 10, 1);
4374 acc_avg = acc_avg * (1 - f) + acceleration * f;
4375 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4377 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4379 sz = cvar("cl_showacceleration_size");
4380 scale = cvar("cl_showacceleration_scale");
4381 alpha = cvar("cl_showacceleration_alpha");
4382 if (cvar("cl_showacceleration_color_custom"))
4383 rgb = stov(cvar_string("cl_showacceleration_color"));
4386 if (acceleration < 0) {
4387 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4388 } else if (acceleration > 0) {
4389 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4393 if (acceleration > 0)
4394 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4395 else if (acceleration < 0)
4396 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4399 void HUD_Reset (void)
4401 // reset gametype specific icons
4402 if(gametype == GAME_KEYHUNT)
4404 else if(gametype == GAME_CTF)
4405 HUD_Mod_CTF_Reset();
4408 void HUD_Main (void)
4410 if(disable_menu_alphacheck == 1)
4411 menu_fade_alpha = 1;
4413 menu_fade_alpha = (1 - cvar("_menu_alpha"));
4414 hud_fg_alpha = cvar("hud_fg_alpha");
4416 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4417 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4418 hud_color_bg_team = cvar("hud_color_bg_team");
4420 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4421 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4423 hud_configure = cvar("_hud_configure");
4427 // HUD configure visible grid
4428 if(hud_configure && cvar("hud_configure_grid") && cvar("hud_configure_grid_alpha"))
4432 for(i = 0; i < 1/bound(0.005, bound(0.005, cvar("hud_configure_grid_x"), 0.2), 0.2); ++i)
4434 drawfill(eX * i * vid_conwidth * bound(0.005, bound(0.005, cvar("hud_configure_grid_x"), 0.2), 0.2), eX + eY * vid_conheight, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
4437 for(i = 0; i < 1/bound(0.005, bound(0.005, cvar("hud_configure_grid_y"), 0.2), 0.2); ++i)
4439 drawfill(eY * i * vid_conheight * bound(0.005, bound(0.005, cvar("hud_configure_grid_y"), 0.2), 0.2), eY + eX * vid_conwidth, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
4443 if(cvar_string("hud_dock") != "")
4444 drawpic_skin('0 0 0', cvar_string("hud_dock"), eX * vid_conwidth + eY * vid_conheight, HUD_Panel_Dock_GetColor(), cvar("hud_dock_alpha") * menu_fade_alpha, DRAWFLAG_NORMAL);
4446 if(HUD_Panel_CheckActive(HUD_PANEL_RADAR) || hud_configure)
4447 if(cvar_string("hud_radar") != "0" && (cvar("hud_radar") == 2 || teamplay))
4449 if(HUD_Panel_CheckActive(HUD_PANEL_WEAPONICONS) || hud_configure)
4451 if(HUD_Panel_CheckActive(HUD_PANEL_INVENTORY) || hud_configure)
4453 if(HUD_Panel_CheckActive(HUD_PANEL_POWERUPS) || hud_configure)
4455 if(HUD_Panel_CheckActive(HUD_PANEL_HEALTHARMOR) || hud_configure)
4457 if(HUD_Panel_CheckActive(HUD_PANEL_NOTIFY) || hud_configure)
4459 if(HUD_Panel_CheckActive(HUD_PANEL_TIMER) || hud_configure)
4461 if(HUD_Panel_CheckActive(HUD_PANEL_SCORE) || hud_configure)
4463 if(HUD_Panel_CheckActive(HUD_PANEL_RACETIMER) || hud_configure)
4464 if(gametype == GAME_RACE || gametype == GAME_CTS || hud_configure)
4466 if(HUD_Panel_CheckActive(HUD_PANEL_VOTE) || hud_configure)
4468 if(HUD_Panel_CheckActive(HUD_PANEL_MODICONS) || hud_configure)
4471 if(HUD_Panel_CheckActive(HUD_PANEL_PRESSEDKEYS) || hud_configure)
4472 if(spectatee_status > 0 || cvar("hud_pressedkeys") >= 2 || hud_configure)
4473 HUD_DrawPressedKeys();
4474 if(HUD_Panel_CheckActive(HUD_PANEL_CHAT) || hud_configure)
4477 cvar_set("con_chatrect", "0");
4478 if(HUD_Panel_CheckActive(HUD_PANEL_ENGINEINFO) || hud_configure)
4481 // TODO hud_'ify these
4482 if (cvar("cl_showspeed"))
4484 if (cvar("cl_showacceleration"))
4485 HUD_ShowAcceleration();
4487 if (hud_configure && spectatee_status) // try to join if we are in hud_configure mode, but still spectating (in order to get rid of motd and such)
4488 localcmd("cmd selectteam auto; cmd join\n");
4490 if (!hud_configure) // hud config mode disabled, enable normal alpha stuff again
4491 disable_menu_alphacheck = 0;