7 // a border picture is a texture containing nine parts:
8 // 1/4 width: left part
9 // 1/2 width: middle part (stretched)
10 // 1/4 width: right part
12 // 1/4 height: top part
13 // 1/2 height: middle part (stretched)
14 // 1/4 height: bottom part
15 void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize)
17 if (theBorderSize_x <= 0 && theBorderSize_y <= 0) // no border
19 // draw only the central part
20 drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
27 //pic = draw_UseSkinFor(pic);
28 width = eX * theSize_x;
29 height = eY * theSize_y;
30 if(theSize_x <= theBorderSize_x * 2)
32 // not wide enough... draw just left and right then
33 bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
34 if(theSize_y <= theBorderSize_y * 2)
36 // not high enough... draw just corners
37 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
38 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
39 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
40 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
41 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
45 dY = theBorderSize_x * eY;
46 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
47 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
48 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
49 drawsubpic(theOrigin + width * 0.5 + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0' + eX - bW, '0 0.5 0' + bW, theColor, theAlpha, 0);
50 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
51 drawsubpic(theOrigin + width * 0.5 + height - dY, width * 0.5 + dY, pic, '0 0.75 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
56 if(theSize_y <= theBorderSize_y * 2)
58 // not high enough... draw just top and bottom then
59 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
60 dX = theBorderSize_x * eX;
61 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
62 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
63 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
64 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
65 drawsubpic(theOrigin + dX + height * 0.5, width - 2 * dX + height * 0.5, pic, '0.25 0 0' + eY - bH, '0.5 0 0' + bH, theColor, theAlpha, 0);
66 drawsubpic(theOrigin + width - dX + height * 0.5, dX + height * 0.5, pic, '0.75 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
70 dX = theBorderSize_x * eX;
71 dY = theBorderSize_x * eY;
72 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
73 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
74 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
75 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
76 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
77 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
78 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
79 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
80 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
85 // drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
86 void drawpic_aspect(vector pos, string pic, vector sz, vector color, float alpha, float drawflag) {
88 imgsize = drawgetimagesize(pic);
90 imgaspect = imgsize_x/imgsize_y;
97 if(aspect > imgaspect) {
98 sz_x = sz_y * imgaspect;
99 drawpic(pos + eX * (oldsz_x - sz_x) * 0.5, pic, sz, color, alpha, drawflag);
101 sz_y = sz_x / imgaspect;
102 drawpic(pos + eY * (oldsz_y - sz_y) * 0.5, pic, sz, color, alpha, drawflag);
106 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
107 void drawpic_skin(vector pos, string pic, vector sz, vector color, float alpha, float drawflag) {
108 drawpic_aspect(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, color, alpha, drawflag);
112 void drawpic_skin_expanding(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
113 drawpic_expanding(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
116 void drawpic_skin_expanding_two(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
117 drawpic_expanding_two(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
120 // return HUD background color
121 vector HUD_GetBgColor()
125 GetTeamRGB(myteam) * hud_color_bg_team;
127 // allow custom HUD colors in non-teamgames
128 color_x = cvar("hud_color_bg_r");
129 color_y = cvar("hud_color_bg_g");
130 color_z = cvar("hud_color_bg_b");
135 // return accuracy text color
136 vector HUD_AccuracyColor(float accuracy)
139 float yellow_accuracy = cvar("hud_weaponicons_accuracy_yellow"); // value at which this function returns yellow
140 if(accuracy >= 100) {
144 else if(accuracy > yellow_accuracy) {
145 rgb_x = 1 - (accuracy-yellow_accuracy)/(100-yellow_accuracy); // red value between 1 -> 0
150 rgb_y = accuracy/yellow_accuracy; // green value between 0 -> 1
156 // draw number in the XSCALE font
157 void HUD_DrawXNum (vector pos, float num, float digits, float showsign, float lettersize, vector rgb, float highlighted, float stroke, float alpha, float dflags)
160 string str, tmp, l_length;
162 vector vsize, num_color;
164 vsize_x = vsize_y = lettersize;
167 // showsign 1: always prefix with minus sign (useful in race distribution display)
168 // showsign 2: always prefix with plus sign (useful in race distribution display)
169 // showsign 3: prefix with minus sign if negative, plus sign if positive (useful in score distribution display)
171 if((showsign == 2 && num >= 0) || (num > 0 && showsign == 3))
178 if(num < 0 || (num < 0 && showsign == 3) || (showsign == 1 && num <= 0))
190 str = strcat(substring("0000000000", 0, digits - strlen(tmp)), tmp);
199 str = substring(str, l-digits, 999);
201 } else if(l < digits)
202 pos_x += (digits-l) * lettersize;
204 if (highlighted == 1) {
206 hl_size_x = vsize_x * l + vsize_x * 0.2;
207 hl_size_y = vsize_y * 1.1;
210 hl_size_x = hl_size_x + vsize_x;
213 hl_pos_x = pos_x - lettersize/10;
214 hl_pos_y = pos_y - lettersize/20;
217 drawpic_skin(hl_pos, strcat("num_leading_", l_length), hl_size, '1 1 1', alpha, dflags);
228 drawpic_skin(pos, "num_minus_stroke", vsize, rgb, alpha, dflags);
229 drawpic_skin(pos, "num_minus", vsize, num_color, alpha, dflags);
234 drawpic_skin(pos, "num_plus_stroke", vsize, rgb, alpha, dflags);
235 drawpic_skin(pos, "num_plus", vsize, num_color, alpha, dflags);
239 for(i = 0; i < l; ++i)
241 tmp = substring(str, i, 1);
243 drawpic_skin(pos, strcat("num_", tmp, "_stroke"), vsize, rgb, alpha, dflags);
244 drawpic_skin(pos, strcat("num_", tmp), vsize, num_color, alpha, dflags);
249 vector HUD_Get_Num_Color (float x, float maxvalue)
257 else if(x > maxvalue * 0.75) {
258 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
259 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
262 else if(x > maxvalue * 0.5) {
263 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
264 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
265 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
267 else if(x > maxvalue * 0.25) {
270 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
272 else if(x > maxvalue * 0.1) {
274 color_y = (x-20)*90/27/100; // green value between 0 -> 1
275 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
284 // color the number differently based on how big it is (used in the health/armor panel)
285 void HUD_DrawXNum_Colored (vector pos, float x, float digits, float lettersize, float alpha)
288 color = HUD_Get_Num_Color (x, 200);
289 HUD_DrawXNum(pos, x, digits, 0, lettersize, color, 0, 0, alpha, DRAWFLAG_NORMAL);
292 float stringwidth_colors(string s, vector theSize)
294 return stringwidth(s, TRUE, theSize);
297 float stringwidth_nocolors(string s, vector theSize)
299 return stringwidth(s, FALSE, theSize);
302 #define CENTERPRINT_MAX_LINES 30
303 string centerprint_messages[CENTERPRINT_MAX_LINES];
304 float centerprint_width[CENTERPRINT_MAX_LINES];
305 vector centerprint_start;
306 float centerprint_expire;
307 float centerprint_num;
308 float centerprint_offset_hint;
309 vector centerprint_fontsize;
311 void centerprint(string strMessage)
313 float i, j, n, hcount;
316 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
318 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
320 if(cvar("scr_centertime") <= 0)
326 // strip trailing newlines
327 j = strlen(strMessage) - 1;
328 while(substring(strMessage, j, 1) == "\n" && j >= 0)
330 strMessage = substring(strMessage, 0, j + 1);
335 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
337 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
339 strMessage = substring(strMessage, j, strlen(strMessage) - j);
340 centerprint_offset_hint = j;
345 // if we get here, we have a message. Initialize its height.
348 n = tokenizebyseparator(strMessage, "\n");
350 for(j = 0; j < n; ++j)
352 getWrappedLine_remaining = argv(j);
353 while(getWrappedLine_remaining)
355 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
356 if(centerprint_messages[i])
357 strunzone(centerprint_messages[i]);
358 centerprint_messages[i] = strzone(s);
359 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
362 // half height for empty lines looks better
368 if(i >= CENTERPRINT_MAX_LINES)
374 h = centerprint_fontsize_y*hcount;
376 havail = vid_conheight;
377 if(cvar("con_chatpos") < 0)
378 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
379 if(havail > vid_conheight - 70)
380 havail = vid_conheight - 70; // avoid overlapping HUD
382 centerprint_start_x = 0;
385 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
387 // here, the centerprint would cover the crosshair. REALLY BAD.
388 forbiddenmin = vid_conheight * 0.5 - h - 16;
389 forbiddenmax = vid_conheight * 0.5 + 16;
391 allowedmin = scoreboard_bottom;
392 allowedmax = havail - h;
393 preferred = (havail - h)/2;
396 // possible orderings (total: 4! / 4 = 6)
397 // allowedmin allowedmax forbiddenmin forbiddenmax
398 // forbiddenmin forbiddenmax allowedmin allowedmax
399 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
401 // forbidden doesn't matter in this case
402 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
404 // allowedmin forbiddenmin allowedmax forbiddenmax
405 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
407 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
409 // allowedmin forbiddenmin forbiddenmax allowedmax
410 else if(allowedmin < forbiddenmin)
412 // make sure the forbidden zone is not covered
413 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
414 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
416 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
418 // forbiddenmin allowedmin allowedmax forbiddenmax
419 else if(allowedmax < forbiddenmax)
421 // it's better to leave the allowed zone (overlap with scoreboard) than
422 // to cover the forbidden zone (crosshair)
423 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
424 centerprint_start_y = forbiddenmax;
426 centerprint_start_y = forbiddenmin;
428 // forbiddenmin allowedmin forbiddenmax allowedmax
431 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
434 centerprint_start_y =
437 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
445 centerprint_expire = time + cvar("scr_centertime");
448 void HUD_DrawCenterPrint (void)
455 //if(time > centerprint_expire)
458 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
459 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
460 //sz = 1.2 / (a + 0.2);
465 pos = centerprint_start;
466 for (i=0; i<centerprint_num; i = i + 1)
468 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
469 ts = centerprint_messages[i];
472 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
473 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
474 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
475 pos_y = pos_y + centerprint_fontsize_y;
478 // half height for empty lines looks better
479 pos_y = pos_y + centerprint_fontsize_y * 0.5;
483 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
485 position_x -= 2 / 3 * strlen(text) * scale_x;
486 drawstring(position, text, scale, rgb, alpha, flag);
489 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
491 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
492 drawstring(position, text, scale, rgb, alpha, flag);
495 // return the string of the given race place
496 string race_PlaceName(float pos) {
504 return strcat(ftos(pos), "th");
507 // return the string of the onscreen race timer
508 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
516 if(histime == 0) // goal hit
520 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
530 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
536 lapstr = strcat(" (-", ftos(lapdelta), "L)");
539 else if(lapdelta < 0)
541 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
545 else if(histime > 0) // anticipation
547 if(mytime >= histime)
548 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
550 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
557 cpname = "Start line";
559 cpname = "Finish line";
561 cpname = strcat("Intermediate ", ftos(cp));
563 cpname = "Finish line";
566 return strcat(col, cpname);
567 else if(hisname == "")
568 return strcat(col, cpname, " (", timestr, ")");
570 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
573 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
574 float race_CheckName(string net_name) {
576 for (i=RANKINGS_CNT-1;i>=0;--i)
577 if(grecordholder[i] == net_name)
589 void HUD_Panel_ExportCfg(string cfgname)
592 fh = fopen(strcat("hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg"), FILE_WRITE);
595 fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
596 fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
597 fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
598 fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
599 fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
600 fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
601 fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
602 fputs(fh, strcat("seta hud_fg_alpha \"", cvar_string("hud_fg_alpha"), "\"", "\n"));
605 fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
606 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
607 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
608 fputs(fh, strcat("seta hud_dock_alpha \"", ftos(cvar("hud_dock_alpha")), "\"", "\n"));
611 fputs(fh, strcat("seta hud_progressbar_alpha ", ftos(cvar("hud_progressbar_alpha")), "\n"));
612 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
613 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
614 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
615 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
616 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
617 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
620 // common cvars for all panels
622 for (i = 0; i < HUD_PANEL_NUM; ++i)
624 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), " ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i)))), "\n"));
625 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_pos \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_pos")), "\"", "\n"));
626 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_size \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_size")), "\"", "\n"));
627 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg")), "\"", "\n"));
628 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color")), "\"", "\n"));
629 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color_team \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color_team")), "\"", "\n"));
630 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_alpha \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_alpha")), "\"", "\n"));
631 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_border \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_border")), "\"", "\n"));
632 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_padding \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_padding")), "\"", "\n"));
635 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_accuracy_yellow ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_accuracy_yellow"))), "\n"));
638 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_onlycurrent ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_onlycurrent"))), "\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), "_mirror ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
645 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
646 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_mirror ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
649 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
650 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_info_top ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_info_top"))), "\n"));
653 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_foreground_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_foreground_alpha"))), "\n"));
655 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha"))), "\n"));
661 print("^2Successfully exported to hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
666 // return active status of panel
667 float HUD_Panel_CheckActive(float id)
669 if (cvar_or(strcat("hud_", HUD_Panel_GetName(id)), 1))
674 // return size of given panel
675 vector HUD_Panel_GetSize(float id)
678 mySize = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_size")));
680 mySize = eX * mySize_x * vid_conwidth + eY * mySize_y * vid_conheight;
682 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
684 vector menu_enable_maxsize, menu_enable_size;
685 menu_enable_maxsize = '0 0 0'; // shut up FTEQCC
686 menu_enable_maxsize_x = 0.3 * vid_conwidth;
687 menu_enable_maxsize_y = 0.18 * vid_conheight;
688 if(mySize_x > mySize_y)
690 if(mySize_y > menu_enable_maxsize_y)
692 menu_enable_size_y = menu_enable_maxsize_y;
693 menu_enable_size_x = mySize_x * (menu_enable_maxsize_y/mySize_y);
694 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
699 if(mySize_x > menu_enable_maxsize_x)
701 menu_enable_size_x = menu_enable_maxsize_x;
702 menu_enable_size_y = mySize_y * (menu_enable_maxsize_x/mySize_x);
703 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
710 // return pos of given panel
711 vector HUD_Panel_GetPos(float id)
714 pos = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_pos")));
716 pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
718 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
720 vector mySize, menu_enable_panelpos;
721 mySize = HUD_Panel_GetSize(id);
722 if(mySize_x > mySize_y)
723 menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * mySize_x + eY * 0.82 * vid_conheight;
725 menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * mySize_y + eX * 0.7 * vid_conwidth;
726 pos = (1 - cvar("_menu_alpha")) * pos + (cvar("_menu_alpha")) * menu_enable_panelpos;
731 float HUD_Panel_GetBorder(float id)
734 border = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_border"));
736 border = cvar_string("hud_bg_border");
740 vector HUD_Panel_GetColor(float id)
746 // fetch per-panel color
747 if(teamplay && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")) != "") {
748 f = stof(getplayerkey(self.sv_entnum, "colors"));
749 color = vtos(colormapPaletteColor(mod(f, 16), 1) * cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")));
752 color = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color"));
753 color_vec = stov(color);
755 if(color == "") { // fetch default color
756 color = cvar_string("hud_bg_color");
757 color_vec = stov(color);
758 if(teamplay && cvar(strcat("hud_bg_color_team"))) {
759 f = stof(getplayerkey(self.sv_entnum, "colors"));
760 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_bg_color_team");
762 else if(color == "shirt") {
763 f = stof(getplayerkey(self.sv_entnum, "colors"));
764 color_vec = colormapPaletteColor(floor(f / 16), 0);
766 else if(color == "pants") {
767 f = stof(getplayerkey(self.sv_entnum, "colors"));
768 color_vec = colormapPaletteColor(mod(f, 16), 1);
771 else if(color == "shirt") {
772 f = stof(getplayerkey(self.sv_entnum, "colors"));
773 color_vec = colormapPaletteColor(floor(f / 16), 0);
775 else if(color == "pants") {
776 f = stof(getplayerkey(self.sv_entnum, "colors"));
777 color_vec = colormapPaletteColor(mod(f, 16), 1);
782 vector HUD_Panel_Dock_GetColor(void)
787 color = cvar_string("hud_dock_color");
788 color_vec = stov(color);
789 if(teamplay && cvar(strcat("hud_dock_color_team"))) {
790 f = stof(getplayerkey(self.sv_entnum, "colors"));
791 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_dock_color_team");
793 else if(color == "shirt") {
794 f = stof(getplayerkey(self.sv_entnum, "colors"));
795 color_vec = colormapPaletteColor(floor(f / 16), 0);
797 else if(color == "pants") {
798 f = stof(getplayerkey(self.sv_entnum, "colors"));
799 color_vec = colormapPaletteColor(mod(f, 16), 1);
804 float HUD_Panel_GetBgAlpha(float id)
807 alpha = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_alpha"));
809 alpha = cvar_string("hud_bg_alpha");
811 if(hud_configure && disable_menu_alphacheck == 2 && highlightedPanel == id) // do not set a minalpha cap when showing the config dialog for this panel
812 alpha = ftos((1 - cvar("_menu_alpha")) * max(cvar("hud_configure_bg_minalpha"), stof(alpha)) + (cvar("_menu_alpha")) * stof(alpha));
813 else if(hud_configure)
814 alpha = ftos(max(cvar("hud_configure_bg_minalpha"), stof(alpha)));
816 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
819 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
822 return stof(alpha) * menu_fade_alpha;
825 float HUD_Panel_GetFgAlpha(float id)
828 alpha = hud_fg_alpha;
830 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
833 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
836 return alpha * menu_fade_alpha;
839 float HUD_Panel_GetPadding(float id)
842 padding = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
844 padding = cvar_string("hud_bg_padding");
847 mySize = HUD_Panel_GetSize(id);
849 smallestsize = min(mySize_x, mySize_y);
850 return min(smallestsize/2 - 5, stof(padding));
853 // draw the background/borders
854 void HUD_Panel_DrawBg(float id, vector pos, vector mySize, float alpha)
856 if(!hud_configure && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg")) == "0")
860 bg = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg"));
862 bg = cvar_string("hud_bg");
864 if(bg == "0" && hud_configure) {
865 bg = "border"; // we probably want to see a background in config mode at all times...
871 border = HUD_Panel_GetBorder(id);
874 color = HUD_Panel_GetColor(id);
877 alpha = HUD_Panel_GetBgAlpha(id) * alpha; // allow panels to fade in/out by passing an alpha value
879 alpha = HUD_Panel_GetBgAlpha(id);
881 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));
885 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
887 //float drawsubpic(vector position, vector size, string pic, vector srcPosition, vector srcSize, vector rgb, float alpha, float flag) = #328;
889 pic = strcat("gfx/hud/", cvar_string("hud_skin"), "/");
891 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);
892 if(mySize_y/mySize_x > 2)
893 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);
894 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);
896 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);
897 if(mySize_x/mySize_y > 2)
898 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);
899 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);
903 vector HUD_Panel_GetProgressBarColor(string item)
905 return stov(cvar_string(strcat("hud_progressbar_", item, "_color")));
908 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
909 vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
920 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
921 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
923 for (i = 0; i < HUD_PANEL_NUM; ++i) {
924 if(i == id || !HUD_Panel_CheckActive(i))
927 targPos = HUD_Panel_GetPos(i) - '1 1 0' * HUD_Panel_GetBorder(id);
928 targSize = HUD_Panel_GetSize(i) + '2 2 0' * HUD_Panel_GetBorder(id);
930 if(myPos_y + mySize_y < targPos_y)
932 if(myPos_y > targPos_y + targSize_y)
935 if(myPos_x + mySize_x < targPos_x)
937 if(myPos_x > targPos_x + targSize_x)
940 // OK, there IS a collision.
942 myCenter_x = myPos_x + 0.5 * mySize_x;
943 myCenter_y = myPos_y + 0.5 * mySize_y;
945 targCenter_x = targPos_x + 0.5 * targSize_x;
946 targCenter_y = targPos_y + 0.5 * targSize_y;
948 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
950 if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
951 myTarget_x = targPos_x - mySize_x;
952 else // push it upwards
953 myTarget_y = targPos_y - mySize_y;
955 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
957 if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
958 myTarget_x = targPos_x + targSize_x;
959 else // push it upwards
960 myTarget_y = targPos_y - mySize_y;
962 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
964 if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
965 myTarget_x = targPos_x - mySize_x;
966 else // push it downwards
967 myTarget_y = targPos_y + targSize_y;
969 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
971 if(targPos_x + targSize_x - myPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
972 myTarget_x = targPos_x + targSize_x;
973 else // push it downwards
974 myTarget_y = targPos_y + targSize_y;
981 void HUD_Panel_SetPos(float id, vector pos)
984 oldPos = HUD_Panel_GetPos(id);
987 mySize = HUD_Panel_GetSize(id);
989 if(hud_configure_checkcollisions)
990 pos = HUD_Panel_CheckMove(id, pos, mySize);
992 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
993 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
995 if(cvar("hud_configure_grid"))
997 pos_x = floor((pos_x/vid_conwidth)/bound(0.005, cvar("hud_configure_grid_x"), 0.2) + 0.5) * bound(0.005, cvar("hud_configure_grid_x"), 0.2) * vid_conwidth;
998 pos_y = floor((pos_y/vid_conheight)/bound(0.005, cvar("hud_configure_grid_y"), 0.2) + 0.5) * bound(0.005, cvar("hud_configure_grid_y"), 0.2) * vid_conheight;
1002 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
1004 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
1007 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
1008 vector HUD_Panel_CheckResize(float id, vector mySize, vector resizeorigin) {
1018 ratio = mySize_x/mySize_y;
1020 for (i = 0; i < HUD_PANEL_NUM; ++i) {
1021 if(i == id || !HUD_Panel_CheckActive(i))
1024 targBorder = HUD_Panel_GetBorder(i);
1025 targPos = HUD_Panel_GetPos(i) - '1 1 0' * targBorder;
1026 targSize = HUD_Panel_GetSize(i) + '2 2 0' * targBorder;
1027 targEndPos = targPos + targSize;
1029 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
1030 if(resizeorigin_x > targPos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > targPos_y && resizeorigin_y < targEndPos_y)
1033 if (resizeCorner == 1)
1035 // check if this panel is on our way
1036 if (resizeorigin_x <= targPos_x)
1038 if (resizeorigin_y <= targPos_y)
1040 if (targEndPos_x <= resizeorigin_x - mySize_x)
1042 if (targEndPos_y <= resizeorigin_y - mySize_y)
1045 // there is a collision:
1046 // detect which side of the panel we are facing is actually limiting the resizing
1047 // (which side the resize direction finds for first) and reduce the size up to there
1049 // dist is the distance between resizeorigin and the "analogous" point of the panel
1050 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
1051 dist_x = resizeorigin_x - targEndPos_x;
1052 dist_y = resizeorigin_y - targEndPos_y;
1053 if (dist_y < 0 || dist_x / dist_y > ratio)
1054 mySize_x = min(mySize_x, dist_x);
1056 mySize_y = min(mySize_y, dist_y);
1058 else if (resizeCorner == 2)
1060 if (resizeorigin_x >= targEndPos_x)
1062 if (resizeorigin_y <= targPos_y)
1064 if (targPos_x >= resizeorigin_x + mySize_x)
1066 if (targEndPos_y <= resizeorigin_y - mySize_y)
1069 dist_x = targPos_x - resizeorigin_x;
1070 dist_y = resizeorigin_y - targEndPos_y;
1071 if (dist_y < 0 || dist_x / dist_y > ratio)
1072 mySize_x = min(mySize_x, dist_x);
1074 mySize_y = min(mySize_y, dist_y);
1076 else if (resizeCorner == 3)
1078 if (resizeorigin_x <= targPos_x)
1080 if (resizeorigin_y >= targEndPos_y)
1082 if (targEndPos_x <= resizeorigin_x - mySize_x)
1084 if (targPos_y >= resizeorigin_y + mySize_y)
1087 dist_x = resizeorigin_x - targEndPos_x;
1088 dist_y = targPos_y - resizeorigin_y;
1089 if (dist_y < 0 || dist_x / dist_y > ratio)
1090 mySize_x = min(mySize_x, dist_x);
1092 mySize_y = min(mySize_y, dist_y);
1094 else if (resizeCorner == 4)
1096 if (resizeorigin_x >= targEndPos_x)
1098 if (resizeorigin_y >= targEndPos_y)
1100 if (targPos_x >= resizeorigin_x + mySize_x)
1102 if (targPos_y >= resizeorigin_y + mySize_y)
1105 dist_x = targPos_x - resizeorigin_x;
1106 dist_y = targPos_y - resizeorigin_y;
1107 if (dist_y < 0 || dist_x / dist_y > ratio)
1108 mySize_x = min(mySize_x, dist_x);
1110 mySize_y = min(mySize_y, dist_y);
1112 if(cvar("hud_configure_checkcollisions_debug"))
1113 drawfill(targPos + '1 1 0' * targBorder, targSize - '2 2 0' * targBorder, '1 1 0', .3, DRAWFLAG_NORMAL);
1119 void HUD_Panel_SetPosSize(float id, vector mySize)
1121 vector resizeorigin;
1122 resizeorigin = panel_click_resizeorigin;
1125 // minimum panel size cap
1126 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1127 mySize_y = max(0.025 * vid_conheight, mySize_y);
1129 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.
1131 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
1132 mySize_y = max(2 * cvar("con_chatsize") + 2 * HUD_Panel_GetPadding(id), mySize_y);
1135 // collision testing|
1136 // -----------------+
1138 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
1139 if(resizeCorner == 1) {
1140 myPos_x = resizeorigin_x - mySize_x;
1141 myPos_y = resizeorigin_y - mySize_y;
1142 } else if(resizeCorner == 2) {
1143 myPos_x = resizeorigin_x;
1144 myPos_y = resizeorigin_y - mySize_y;
1145 } else if(resizeCorner == 3) {
1146 myPos_x = resizeorigin_x - mySize_x;
1147 myPos_y = resizeorigin_y;
1148 } else { // resizeCorner == 4
1149 myPos_x = resizeorigin_x;
1150 myPos_y = resizeorigin_y;
1153 // left/top screen edges
1155 mySize_x = mySize_x + myPos_x;
1157 mySize_y = mySize_y + myPos_y;
1159 // bottom/right screen edges
1160 if(myPos_x + mySize_x > vid_conwidth)
1161 mySize_x = vid_conwidth - myPos_x;
1162 if(myPos_y + mySize_y > vid_conheight)
1163 mySize_y = vid_conheight - myPos_y;
1165 if(cvar("hud_configure_checkcollisions_debug"))
1166 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
1168 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
1169 if(cvar("hud_configure_grid"))
1171 mySize_x = floor((mySize_x/vid_conwidth)/bound(0.005, cvar("hud_configure_grid_x"), 0.2) + 0.5) * bound(0.005, cvar("hud_configure_grid_x"), 0.2) * vid_conwidth;
1172 mySize_y = floor((mySize_y/vid_conheight)/bound(0.005, cvar("hud_configure_grid_y"), 0.2) + 0.5) * bound(0.005, cvar("hud_configure_grid_y"), 0.2) * vid_conheight;
1175 if(hud_configure_checkcollisions)
1176 mySize = HUD_Panel_CheckResize(id, mySize, resizeorigin);
1178 // 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)
1179 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1180 mySize_y = max(0.025 * vid_conheight, mySize_y);
1182 // do another pos check, as size might have changed by now
1183 if(resizeCorner == 1) {
1184 myPos_x = resizeorigin_x - mySize_x;
1185 myPos_y = resizeorigin_y - mySize_y;
1186 } else if(resizeCorner == 2) {
1187 myPos_x = resizeorigin_x;
1188 myPos_y = resizeorigin_y - mySize_y;
1189 } else if(resizeCorner == 3) {
1190 myPos_x = resizeorigin_x - mySize_x;
1191 myPos_y = resizeorigin_y;
1192 } else { // resizeCorner == 4
1193 myPos_x = resizeorigin_x;
1194 myPos_y = resizeorigin_y;
1197 if(cvar("hud_configure_checkcollisions_debug"))
1198 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
1201 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
1202 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_size"), s);
1204 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
1205 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
1208 float pressed_key_time;
1209 void HUD_Panel_Arrow_Action(float nPrimary)
1211 if (highlightedPanel_prev == -1)
1214 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
1217 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
1218 step = vid_conheight;
1220 step = vid_conwidth;
1221 if (hudShiftState & S_SHIFT)
1222 step = (step / 256); // more precision
1224 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
1226 highlightedPanel = highlightedPanel_prev;
1228 if (hudShiftState & S_ALT) // resize
1230 highlightedAction = 1;
1231 if(nPrimary == K_UPARROW)
1233 else if(nPrimary == K_RIGHTARROW)
1235 else if(nPrimary == K_LEFTARROW)
1237 else // if(nPrimary == K_DOWNARROW)
1240 // ctrl+arrow reduces the size, instead of increasing it
1241 // Note that ctrl disables collisions check too, but it's fine
1242 // since we don't collide with anything reducing the size
1243 if (hudShiftState & S_CTRL) {
1245 resizeCorner = 5 - resizeCorner;
1249 mySize = HUD_Panel_GetSize(highlightedPanel);
1250 panel_click_resizeorigin = HUD_Panel_GetPos(highlightedPanel);
1251 if(resizeCorner == 1) {
1252 panel_click_resizeorigin += mySize;
1254 } else if(resizeCorner == 2) {
1255 panel_click_resizeorigin_y += mySize_y;
1257 } else if(resizeCorner == 3) {
1258 panel_click_resizeorigin_x += mySize_x;
1260 } else { // resizeCorner == 4
1263 HUD_Panel_SetPosSize(highlightedPanel, mySize);
1267 highlightedAction = 2;
1269 pos = HUD_Panel_GetPos(highlightedPanel);
1270 if(nPrimary == K_UPARROW)
1272 else if(nPrimary == K_DOWNARROW)
1274 else if(nPrimary == K_LEFTARROW)
1276 else // if(nPrimary == K_RIGHTARROW)
1279 HUD_Panel_SetPos(highlightedPanel, pos);
1284 float prevMouseClicked; // previous state
1285 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
1286 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
1289 float menu_enabled_time;
1290 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1295 // allow console bind to work
1298 con_keys = findkeysforcommand("toggleconsole");
1299 keys = tokenize(con_keys);
1301 float hit_con_bind, i;
1302 for (i = 0; i < keys; ++i)
1304 if(nPrimary == stof(argv(i)))
1308 if(bInputType == 0) {
1309 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1310 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1311 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1313 else if(bInputType == 1) {
1314 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1315 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1316 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1319 if(nPrimary == K_MOUSE1)
1321 if(bInputType == 0) { // key pressed
1325 else if(bInputType == 1) {// key released
1330 else if(nPrimary == K_ESCAPE)
1332 if (bInputType == 1)
1334 disable_menu_alphacheck = 1;
1336 menu_enabled_time = time;
1337 localcmd("menu_showhudexit\n");
1339 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1341 if (bInputType == 1)
1343 pressed_key_time = 0;
1346 else if (pressed_key_time == 0)
1347 pressed_key_time = time;
1349 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1351 else if(hit_con_bind)
1354 return true; // Suppress ALL other input
1357 void HUD_Panel_Highlight()
1363 for(i = 0; i < HUD_PANEL_NUM; ++i)
1365 panelPos = HUD_Panel_GetPos(i);
1366 panelSize = HUD_Panel_GetSize(i);
1367 border = HUD_Panel_GetBorder(i);
1370 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1372 highlightedPanel = i;
1373 highlightedAction = 1;
1374 panel_click_distance = mousepos - panelPos;
1377 // resize from topleft border
1378 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)
1380 highlightedPanel = i;
1381 highlightedAction = 2;
1383 panel_click_distance = mousepos - panelPos;
1384 panel_click_resizeorigin = panelPos + panelSize;
1387 // resize from topright border
1388 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)
1390 highlightedPanel = i;
1391 highlightedAction = 2;
1393 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1394 panel_click_distance_y = mousepos_y - panelPos_y;
1395 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1398 // resize from bottomleft border
1399 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)
1401 highlightedPanel = i;
1402 highlightedAction = 2;
1404 panel_click_distance_x = mousepos_x - panelPos_x;
1405 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1406 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1409 // resize from bottomright border
1410 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)
1412 highlightedPanel = i;
1413 highlightedAction = 2;
1415 panel_click_distance = panelSize - mousepos + panelPos;
1416 panel_click_resizeorigin = panelPos;
1422 void HUD_Panel_Mouse()
1424 // 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
1425 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1426 disable_menu_alphacheck = 0;
1427 if (cvar("_menu_alpha") == 0 && time - menu_enabled_time > 0.5)
1431 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1432 print("Highlighted: ", ftos(highlightedPanel), "\n");
1433 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1436 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1437 highlightedPanel_prev = highlightedPanel;
1438 highlightedPanel = -1;
1439 highlightedAction = 0;
1442 mousepos = mousepos + getmousepos();
1444 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1445 mousepos_y = bound(0, mousepos_y, vid_conheight);
1447 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1451 if(prevMouseClicked == 0)
1452 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1454 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
1456 if(highlightedAction == 1)
1457 HUD_Panel_SetPos(highlightedPanel, mousepos - panel_click_distance);
1458 else if(highlightedAction == 2)
1461 if(resizeCorner == 1) {
1462 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1463 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1464 } else if(resizeCorner == 2) {
1465 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1466 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1467 } else if(resizeCorner == 3) {
1468 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1469 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1470 } else { // resizeCorner == 4
1471 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1472 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1474 HUD_Panel_SetPosSize(highlightedPanel, mySize);
1477 // doubleclick check
1478 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1480 mouseClicked = 0; // to prevent spam, I guess.
1481 disable_menu_alphacheck = 2;
1483 menu_enabled_time = time;
1484 localcmd("menu_showhudoptions ", ftos(highlightedPanel), "\n");
1487 if(prevMouseClicked == 0)
1489 prevMouseClickedTime = time;
1490 prevMouseClickedPos = mousepos;
1493 prevMouseClicked = mouseClicked;
1496 // Weapon icons (#0)
1498 float weaponspace[10];
1499 void HUD_WeaponIcons_Clear()
1502 for(idx = 0; idx < 10; ++idx)
1503 weaponspace[idx] = 0;
1506 entity weaponorder[WEP_MAXCOUNT];
1508 void weaponorder_swap(float i, float j, entity pass)
1512 weaponorder[i] = weaponorder[j];
1516 string weaponorder_cmp_str;
1517 float weaponorder_cmp(float i, float j, entity pass)
1520 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1521 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1522 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)
1525 void HUD_WeaponIcons(void)
1527 float id = HUD_PANEL_WEAPONICONS;
1528 float alpha, stat_weapons; // "constants"
1529 vector pos, mySize, accuracy_color;
1530 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1532 pos = HUD_Panel_GetPos(id);
1533 mySize = HUD_Panel_GetSize(id);
1535 stat_weapons = getstati(STAT_WEAPONS);
1536 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1538 self = get_weaponinfo(i);
1539 if(self.impulse >= 0)
1541 weaponorder[weapon_cnt] = self;
1546 // TODO make this configurable
1547 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1548 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1550 HUD_Panel_DrawBg(id, pos, mySize, 0);
1552 padding = HUD_Panel_GetPadding(id);
1555 pos += '1 1 0' * padding;
1556 mySize -= '2 2 0' * padding;
1560 weapon_stats = getstati(STAT_DAMAGE_HITS);
1561 weapon_number = weapon_stats & 63;
1562 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1564 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1565 weapon_number = weapon_stats & 63;
1566 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1568 if(cvar_or("hud_weaponicons_fade", 1))
1570 fade = 3.2 - 2 * (time - weapontime);
1571 fade = bound(0.7, fade, 1);
1576 HUD_WeaponIcons_Clear();
1578 float rows, columns;
1579 rows = mySize_y/mySize_x;
1580 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1581 // ^^^ weapon icon aspect goes here
1583 columns = ceil(WEP_COUNT/rows);
1585 for(i = 0; i < weapon_cnt; ++i)
1587 self = weaponorder[i];
1588 weapid = self.impulse;
1590 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1592 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1593 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1595 // draw background behind currently selected weapon
1596 if(self.weapon == activeweapon)
1597 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);
1599 // draw the weapon accuracy on the HUD
1600 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1603 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1605 accuracy_color = HUD_AccuracyColor(weapon_stats);
1607 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);
1610 // draw the weapon icon
1611 if((self.impulse >= 0) && (stat_weapons & self.weapons))
1613 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);
1615 if(cvar_or("hud_weaponicons_number", 1))
1616 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);
1620 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);
1635 float GetAmmoStat(float i)
1639 case 0: return STAT_SHELLS;
1640 case 1: return STAT_NAILS;
1641 case 2: return STAT_ROCKETS;
1642 case 3: return STAT_CELLS;
1643 case 4: return STAT_FUEL;
1648 float GetAmmoItemCode(float i)
1652 case 0: return IT_SHELLS;
1653 case 1: return IT_NAILS;
1654 case 2: return IT_ROCKETS;
1655 case 3: return IT_CELLS;
1656 case 4: return IT_FUEL;
1661 string GetAmmoPicture(float i)
1665 case 0: return "ammo_shells";
1666 case 1: return "ammo_bullets";
1667 case 2: return "ammo_rockets";
1668 case 3: return "ammo_cells";
1669 case 4: return "ammo_fuel";
1674 void HUD_Inventory(void)
1676 float id = HUD_PANEL_INVENTORY;
1680 vector pos, mySize, mysize, mypos;
1681 pos = HUD_Panel_GetPos(id);
1682 mySize = HUD_Panel_GetSize(id);
1684 HUD_Panel_DrawBg(id, pos, mySize, 0);
1686 padding = HUD_Panel_GetPadding(id);
1689 pos += '1 1 0' * padding;
1690 mySize -= '2 2 0' * padding;
1694 stat_items = getstati(STAT_ITEMS);
1695 for (i = 0; i < 4; ++i) {
1697 a = getstati(GetAmmoStat(i)); // how much ammo do we have of type i?
1701 if(cvar("hud_inventory_onlycurrent")) {
1704 if (stat_items & GetAmmoItemCode(i) || hud_configure) {
1705 drawpic_skin(pos, GetAmmoPicture(i), '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1707 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);
1709 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);
1715 if(mySize_x/mySize_y >= 10) { // arrange horizontally
1717 case 0: mypos_x = pos_x; mypos_y = pos_y; break; // shells
1718 case 1: mypos_x = pos_x + 0.25 * mySize_x; mypos_y = pos_y; break; // bullets
1719 case 2: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y; break; // rockets
1720 case 3: mypos_x = pos_x + 0.75 * mySize_x; mypos_y = pos_y; break; // cells
1722 mysize_x = 0.25 * mySize_x;
1723 mysize_y = mySize_y;
1724 } else if(mySize_x/mySize_y >= 2.5) { // arrange in a 2x2 grid
1726 case 0: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y + 0.5 * mySize_y; break; // shells
1727 case 1: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y; break; // bullets
1728 case 2: mypos_x = pos_x; mypos_y = pos_y + 0.5 * mySize_y; break; // rockets
1729 case 3: mypos_x = pos_x; mypos_y = pos_y; break; // cells
1731 mysize_x = 0.5 * mySize_x;
1732 mysize_y = 0.5 * mySize_y;
1733 } else { // arrange vertically
1735 case 0: mypos_x = pos_x; mypos_y = pos_y; break; // shells
1736 case 1: mypos_x = pos_x; mypos_y = pos_y + 0.25 * mySize_y; break; // bullets
1737 case 2: mypos_x = pos_x; mypos_y = pos_y + 0.5 * mySize_y; break; // rockets
1738 case 3: mypos_x = pos_x; mypos_y = pos_y + 0.75 * mySize_y; break; // cells
1740 mysize_x = mySize_x;
1741 mysize_y = 0.25 * mySize_y;
1744 if (stat_items & GetAmmoItemCode(i))
1745 drawpic_skin(mypos, "ammo_current_bg", mysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1746 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);
1748 if(stat_items & GetAmmoItemCode(i))
1749 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);
1751 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);
1753 if(stat_items & GetAmmoItemCode(i))
1754 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);
1756 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);
1766 void HUD_Powerups(void) {
1767 float id = HUD_PANEL_POWERUPS;
1769 stat_items = getstati(STAT_ITEMS);
1773 if not(stat_items & IT_STRENGTH)
1774 if not(stat_items & IT_INVINCIBLE)
1777 if (getstati(STAT_HEALTH) <= 0)
1782 pos = HUD_Panel_GetPos(id);
1783 mySize = HUD_Panel_GetSize(id);
1785 HUD_Panel_DrawBg(id, pos, mySize, 0);
1787 padding = HUD_Panel_GetPadding(id);
1790 pos += '1 1 0' * padding;
1791 mySize -= '2 2 0' * padding;
1794 float strength_time, shield_time;
1796 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1797 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1807 vector barpos, barsize;
1811 string leftname, rightname;
1812 float leftcnt, rightcnt;
1813 float leftexact, rightexact;
1814 float leftalpha, rightalpha;
1815 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) {
1816 leftname = "strength";
1817 leftcnt = ceil(strength_time);
1818 leftexact = strength_time;
1820 rightname = "shield";
1821 rightcnt = ceil(shield_time);
1822 rightexact = shield_time;
1824 leftname = "shield";
1825 leftcnt = ceil(shield_time);
1826 leftexact = shield_time;
1828 rightname = "strength";
1829 rightcnt = ceil(strength_time);
1830 rightexact = strength_time;
1832 leftalpha = bound(0, leftexact, 1);
1833 rightalpha = bound(0, rightexact, 1);
1835 if (mySize_x/mySize_y > 4)
1839 len = strlen(ftos(leftcnt));
1841 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1842 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1843 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1844 picpos = pos + eX * 0.5 * mySize_x - eX * mySize_y;
1845 numpos = picpos - eX * 2 * 0.5 * mySize_y + eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1848 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1850 numpos = picpos + eX * mySize_y - eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1853 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1855 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));
1857 drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1858 HUD_DrawXNum(numpos, leftcnt, 2, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1863 len = strlen(ftos(rightcnt));
1865 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1866 barpos = pos + eX * 0.5 * mySize_x;
1867 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1868 picpos = pos + eX * 0.5 * mySize_x;
1869 numpos = picpos + eX * mySize_y - eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1871 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1872 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1873 picpos = pos + eX * mySize_x - eX * mySize_y;
1874 numpos = picpos - eX * mySize_y + eY * 0.25 * mySize_y;
1877 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1879 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));
1881 drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1882 HUD_DrawXNum(numpos, rightcnt, 2, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1885 else if (mySize_x/mySize_y > 1.5)
1889 len = strlen(ftos(leftcnt));
1891 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1892 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1893 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1894 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y;
1895 numpos = picpos - eX * len * 0.5 * mySize_y;
1898 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1900 numpos = picpos + eX * 0.5 * mySize_y;
1903 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1905 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));
1907 drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1908 HUD_DrawXNum(numpos, leftcnt, len, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1913 len = strlen(ftos(rightcnt));
1915 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1916 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1917 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1918 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y + eY * 0.5 * mySize_y;
1919 numpos = picpos - eX * len * 0.5 * mySize_y;
1921 barpos = pos + eY * 0.5 * mySize_y;
1922 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1923 picpos = pos + eY * 0.5 * mySize_y;
1924 numpos = picpos + eX * 0.5 * mySize_y;
1927 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1929 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));
1931 drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1932 HUD_DrawXNum(numpos, rightcnt, len, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1939 len = strlen(ftos(leftcnt));
1941 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1943 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1944 picpos = pos + eX * 0.05 * mySize_x;
1945 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x;
1947 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1948 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1949 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.65 * mySize_x;
1950 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.25 * mySize_x;
1953 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1955 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));
1957 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1958 HUD_DrawXNum(numpos, leftcnt, len, 0, 0.25 * mySize_x, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1963 len = strlen(ftos(rightcnt));
1965 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1966 barpos = pos + eX * 0.5 * mySize_x;
1967 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1968 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1969 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1971 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1972 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1973 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.65 * mySize_x + eX * 0.5 * mySize_x;
1974 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
1977 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1979 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));
1981 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1982 HUD_DrawXNum(numpos, rightcnt, len, 0, 0.25 * mySize_x, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1987 // Health/armor (#3)
1989 void HUD_HealthArmor(void)
1991 float id = HUD_PANEL_HEALTHARMOR;
1993 pos = HUD_Panel_GetPos(id);
1994 mySize = HUD_Panel_GetSize(id);
1996 HUD_Panel_DrawBg(id, pos, mySize, 0);
1998 padding = HUD_Panel_GetPadding(id);
2001 pos += '1 1 0' * padding;
2002 mySize -= '2 2 0' * padding;
2005 float armor, health;
2006 armor = getstati(STAT_ARMOR);
2007 health = getstati(STAT_HEALTH);
2010 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
2023 vector barpos, barsize;
2027 if(cvar("hud_healtharmor") == 2) // combined health and armor display
2030 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2035 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2036 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2037 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2039 numpos = picpos + eX * 1.5 * mySize_y;
2042 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2043 picpos = pos + eX * 3 * mySize_y;
2047 if(v_z) // NOT fully armored
2049 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("health"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2050 drawpic_skin(picpos, "health", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2052 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);
2056 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("armor"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2057 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);
2059 drawpic_skin(picpos, "armor", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2061 HUD_DrawXNum_Colored(numpos, x, 3, mySize_y, HUD_Panel_GetFgAlpha(id)); // draw the combined health and armor
2064 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2065 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2066 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2069 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2072 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2077 string leftname, rightname;
2078 float leftcnt, rightcnt;
2079 float leftactive, rightactive;
2080 float leftalpha, rightalpha;
2081 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) { // old style layout with armor left/top of health
2086 leftalpha = min((armor+10)/55, 1);
2088 rightname = "health";
2093 leftname = "health";
2098 rightname = "armor";
2102 rightalpha = min((armor+10)/55, 1);
2105 if (mySize_x/mySize_y > 5)
2109 len = strlen(ftos(leftcnt));
2111 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2112 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2113 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2114 picpos = pos + eX * 0.5 * mySize_x - eX * mySize_y;
2115 numpos = picpos - eX * 3 * 0.5 * mySize_y + eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
2118 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2120 numpos = picpos + eX * mySize_y + eY * 0.25 * mySize_y;
2123 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2124 drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2125 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2130 len = strlen(ftos(rightcnt));
2132 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2133 barpos = pos + eX * 0.5 * mySize_x;
2134 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2135 picpos = pos + eX * 0.5 * mySize_x;
2136 numpos = picpos + eX * mySize_y - eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
2138 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2139 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2140 picpos = pos + eX * mySize_x - eX * mySize_y;
2141 numpos = picpos - eX * 1.5 * mySize_y + eY * 0.25 * mySize_y;
2144 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2145 drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2146 HUD_DrawXNum_Colored(numpos, rightcnt, 3, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2149 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2150 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2151 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2154 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2157 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2159 else if (mySize_x/mySize_y > 2)
2163 len = strlen(ftos(leftcnt));
2165 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2166 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2167 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2168 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y;
2169 numpos = picpos - eX * len * 0.5 * mySize_y;
2172 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2174 numpos = picpos + eX * 0.5 * mySize_y;
2177 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2178 drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2179 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2184 len = strlen(ftos(rightcnt));
2186 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2187 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2188 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2189 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y + eY * 0.5 * mySize_y;
2190 numpos = picpos - eX * len * 0.5 * mySize_y;
2192 barpos = pos + eY * 0.5 * mySize_y;
2193 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2194 picpos = pos + eY * 0.5 * mySize_y;
2195 numpos = picpos + eX * 0.5 * mySize_y;
2198 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2199 drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2200 HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2203 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2204 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2205 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2208 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2211 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2217 len = strlen(ftos(leftcnt));
2219 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2221 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2222 picpos = pos + eX * 0.05 * mySize_x;
2223 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x;
2225 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2226 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2227 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x;
2228 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x;
2231 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2232 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2233 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.166 * mySize_x, HUD_Panel_GetFgAlpha(id));
2238 len = strlen(ftos(rightcnt));
2240 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2241 barpos = pos + eX * 0.5 * mySize_x;
2242 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2243 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2244 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2246 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2247 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2248 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x + eX * 0.5 * mySize_x;
2249 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x + eX * 0.5 * mySize_x;
2252 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2253 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2254 HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.166 * mySize_x, HUD_Panel_GetFgAlpha(id));
2257 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2259 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2261 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2262 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2265 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2271 // Notification area (#4)
2274 string Weapon_SuicideMessage(float deathtype)
2276 w_deathtype = deathtype;
2277 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2278 return w_deathtypestring;
2281 string Weapon_KillMessage(float deathtype)
2283 w_deathtype = deathtype;
2284 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2285 return w_deathtypestring;
2288 float killnotify_times[10];
2289 float killnotify_deathtype[10];
2290 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2291 string killnotify_attackers[10];
2292 string killnotify_victims[10];
2293 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2296 for (i = 9; i > 0; --i) {
2297 killnotify_times[i] = killnotify_times[i-1];
2298 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2299 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2300 if(killnotify_attackers[i])
2301 strunzone(killnotify_attackers[i]);
2302 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2303 if(killnotify_victims[i])
2304 strunzone(killnotify_victims[i]);
2305 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2307 killnotify_times[0] = time;
2308 killnotify_deathtype[0] = wpn;
2309 killnotify_actiontype[0] = actiontype;
2310 if(killnotify_attackers[0])
2311 strunzone(killnotify_attackers[0]);
2312 killnotify_attackers[0] = strzone(attacker);
2313 if(killnotify_victims[0])
2314 strunzone(killnotify_victims[0]);
2315 killnotify_victims[0] = strzone(victim);
2318 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2322 alsoprint = (cvar("hud_notify_print") || !HUD_Panel_CheckActive(4)); // print message to console if: notify panel disabled, or cvar to do so enabled
2324 if(msg == MSG_SUICIDE) {
2326 w = DEATH_WEAPONOF(type);
2328 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2330 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2331 } else if (type == DEATH_KILL) {
2332 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2334 print ("^1",s1, "^1 couldn't take it anymore\n");
2335 } else if (type == DEATH_ROT) {
2336 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2338 print ("^1",s1, "^1 died\n");
2339 } else if (type == DEATH_NOAMMO) {
2340 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2342 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2343 } else if (type == DEATH_CAMP) {
2344 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2346 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2347 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2348 HUD_KillNotify_Push(s1, "", 0, type);
2350 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2351 } else if (type == DEATH_CHEAT) {
2352 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2354 print ("^1",s1, "^1 unfairly eliminated themself\n");
2355 } else if (type == DEATH_FIRE) {
2356 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2358 print ("^1",s1, "^1 burned to death\n");
2359 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2360 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2362 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2365 if (stof(s2) > 2) // killcount > 2
2366 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2367 } else if(msg == MSG_KILL) {
2368 w = DEATH_WEAPONOF(type);
2370 HUD_KillNotify_Push(s2, s1, 1, w);
2372 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2374 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2375 HUD_KillNotify_Push(s1, s2, 1, type);
2378 if(cvar("cl_gentle")) {
2379 print ("^1", s1, "^1 took action against a team mate\n");
2381 print ("^1", s1, "^1 mows down a team mate\n");
2384 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2385 if(cvar("cl_gentle"))
2386 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2388 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2390 else if (stof(s2) > 2) {
2391 if(cvar("cl_gentle"))
2392 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2394 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2397 else if(type == KILL_FIRST_BLOOD)
2398 print("^1",s1, "^1 drew first blood", "\n");
2400 else if (type == DEATH_TELEFRAG)
2401 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2402 else if (type == DEATH_DROWN) {
2403 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2405 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2407 else if (type == DEATH_SLIME) {
2408 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2410 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2412 else if (type == DEATH_LAVA) {
2413 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2415 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2417 else if (type == DEATH_FALL) {
2418 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2420 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2422 else if (type == DEATH_SHOOTING_STAR) {
2423 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2425 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2427 else if (type == DEATH_SWAMP) {
2428 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2430 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2432 else if (type == DEATH_HURTTRIGGER)
2434 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2436 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2437 } else if(type == DEATH_SBCRUSH) {
2438 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2440 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2441 } else if(type == DEATH_SBMINIGUN) {
2442 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2444 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2445 } else if(type == DEATH_SBROCKET) {
2446 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2448 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2449 } else if(type == DEATH_SBBLOWUP) {
2450 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2452 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2453 } else if(type == DEATH_WAKIGUN) {
2454 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2456 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2457 } else if(type == DEATH_WAKIROCKET) {
2458 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2460 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2461 } else if(type == DEATH_WAKIBLOWUP) {
2462 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2464 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2465 } else if(type == DEATH_TURRET) {
2466 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2468 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2469 } else if(type == DEATH_TOUCHEXPLODE) {
2470 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2472 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2473 } else if(type == DEATH_CHEAT) {
2474 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2476 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2477 } else if (type == DEATH_FIRE) {
2478 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2480 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2481 } else if (type == DEATH_CUSTOM) {
2482 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2484 print ("^1",s1, "^1 ", s2, "\n");
2486 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2488 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2490 } else if(msg == MSG_SPREE) {
2491 if(type == KILL_END_SPREE) {
2492 if(cvar("cl_gentle"))
2493 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2495 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2496 } else if(type == KILL_SPREE) {
2497 if(cvar("cl_gentle"))
2498 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2500 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2501 } else if(type == KILL_SPREE_3) {
2502 if(cvar("cl_gentle"))
2503 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2505 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2506 } else if(type == KILL_SPREE_5) {
2507 if(cvar("cl_gentle"))
2508 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2510 print (s1,"^7 unleashes ^1RAGE\n");
2511 } else if(type == KILL_SPREE_10) {
2512 if(cvar("cl_gentle"))
2513 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2515 print (s1,"^7 starts the ^1MASSACRE!\n");
2516 } else if(type == KILL_SPREE_15) {
2517 if(cvar("cl_gentle"))
2518 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2520 print (s1,"^7 executes ^1MAYHEM!\n");
2521 } else if(type == KILL_SPREE_20) {
2522 if(cvar("cl_gentle"))
2523 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2525 print (s1,"^7 is a ^1BERSERKER!\n");
2526 } else if(type == KILL_SPREE_25) {
2527 if(cvar("cl_gentle"))
2528 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2530 print (s1,"^7 inflicts ^1CARNAGE!\n");
2531 } else if(type == KILL_SPREE_30) {
2532 if(cvar("cl_gentle"))
2533 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2535 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2537 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2538 if (type == DEATH_DROWN) {
2539 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2542 if(cvar("cl_gentle"))
2543 print ("^1",s1, "^1 was in the water for too long\n");
2545 print ("^1",s1, "^1 drowned\n");
2547 } else if (type == DEATH_SLIME) {
2548 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2550 print ("^1",s1, "^1 was slimed\n");
2551 } else if (type == DEATH_LAVA) {
2552 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2555 if(cvar("cl_gentle"))
2556 print ("^1",s1, "^1 found a hot place\n");
2558 print ("^1",s1, "^1 turned into hot slag\n");
2560 } else if (type == DEATH_FALL) {
2561 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2564 if(cvar("cl_gentle"))
2565 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2567 print ("^1",s1, "^1 hit the ground with a crunch\n");
2569 } else if (type == DEATH_SHOOTING_STAR) {
2570 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2572 print ("^1",s1, "^1 became a shooting star\n");
2573 } else if (type == DEATH_SWAMP) {
2574 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2577 if(cvar("cl_gentle"))
2578 print ("^1",s1, "^1 discovered a swamp\n");
2580 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2582 } else if(type == DEATH_TURRET) {
2583 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2585 print ("^1",s1, "^1 was mowed down by a turret \n");
2586 } else if (type == DEATH_CUSTOM) {
2587 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2589 print ("^1",s1, "^1 ", s2, "\n");
2590 } else if (type == DEATH_HURTTRIGGER) {
2591 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2593 print ("^1",s1, "^1 was in the wrong place\n");
2594 } else if(type == DEATH_TOUCHEXPLODE) {
2595 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2597 print ("^1",s1, "^1 died in an accident\n");
2598 } else if(type == DEATH_CHEAT) {
2599 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2601 print ("^1",s1, "^1 was unfairly eliminated\n");
2602 } else if(type == DEATH_FIRE) {
2603 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2606 if(cvar("cl_gentle"))
2607 print ("^1",s1, "^1 felt a little hot\n");
2609 print ("^1",s1, "^1 burnt to death\n");
2612 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2615 if(cvar("cl_gentle"))
2616 print ("^1",s1, "^1 needs a restart\n");
2618 print ("^1",s1, "^1 died\n");
2621 } else if(msg == MSG_KILL_ACTION_SPREE) {
2622 if(cvar("cl_gentle"))
2623 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2625 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2626 } else if(msg == MSG_INFO) {
2627 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2628 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2629 print(s1, "^7 got the ", s2, "\n");
2630 } else if(type == INFO_LOSTFLAG) {
2631 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2632 print(s1, "^7 lost the ", s2, "\n");
2633 } else if(type == INFO_PICKUPFLAG) {
2634 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2635 print(s1, "^7 picked up the ", s2, "\n");
2636 } else if(type == INFO_RETURNFLAG) {
2637 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2638 print(s1, "^7 returned the ", s2, "\n");
2643 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2645 void HUD_Centerprint(string s1, string s2, float type, float msg)
2647 if(msg == MSG_SUICIDE) {
2648 if (type == DEATH_TEAMCHANGE) {
2649 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2650 } else if (type == DEATH_AUTOTEAMCHANGE) {
2651 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2652 } else if (type == DEATH_CAMP) {
2653 if(cvar("cl_gentle"))
2654 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2656 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2657 } else if (type == DEATH_NOAMMO) {
2658 if(cvar("cl_gentle"))
2659 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2661 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2662 } else if (type == DEATH_ROT) {
2663 if(cvar("cl_gentle"))
2664 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2666 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2667 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2668 if(cvar("cl_gentle"))
2669 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2671 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2672 } else if (type == DEATH_QUIET) {
2674 } else if (type == DEATH_KILL) {
2675 if(cvar("cl_gentle"))
2676 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2678 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2680 } else if(msg == MSG_KILL) {
2681 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2682 if(cvar("cl_gentle")) {
2683 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2685 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2687 } else if (type == KILL_FIRST_BLOOD) {
2688 if(cvar("cl_gentle")) {
2689 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2691 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2693 } else if (type == KILL_FIRST_VICTIM) {
2694 if(cvar("cl_gentle")) {
2695 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2697 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2699 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2700 if(cvar("cl_gentle")) {
2701 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2703 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2705 } else if (type == KILL_TYPEFRAGGED) {
2706 if(cvar("cl_gentle")) {
2707 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2709 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2711 } else if (type == KILL_FRAG) {
2712 if(cvar("cl_gentle")) {
2713 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2715 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2717 } else if (type == KILL_FRAGGED) {
2718 if(cvar("cl_gentle")) {
2719 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2721 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2724 } else if(msg == MSG_KILL_ACTION) {
2725 // TODO: invent more centerprints here?
2726 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2730 void HUD_Notify (void)
2732 float id = HUD_PANEL_NOTIFY;
2734 pos = HUD_Panel_GetPos(id);
2735 mySize = HUD_Panel_GetSize(id);
2737 HUD_Panel_DrawBg(id, pos, mySize, 0);
2739 padding = HUD_Panel_GetPadding(id);
2742 pos += '1 1 0' * padding;
2743 mySize -= '2 2 0' * padding;
2746 float entries, height;
2747 entries = bound(1, floor(14 * mySize_y/mySize_x), 12);
2748 height = mySize_y/entries;
2749 entries -= 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2752 fontsize = '0.5 0.5 0' * height;
2756 when = cvar("hud_notify_time");
2758 fadetime = cvar("hud_notify_fadetime");
2762 vector pos_attacker, pos_victim;
2764 float width_attacker, width_victim;
2765 string attacker, victim;
2768 for(j = 0; j < entries; ++j)
2770 if(cvar("hud_notify_flip"))
2772 else // rather nasty hack for ordering items from the bottom up
2773 i = entries - j - 1;
2774 if(cvar("hud_notify_info_top"))
2775 i += 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2779 if(killnotify_times[j] + when > time)
2782 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2786 if(killnotify_times[j] + when > time)
2792 // TODO: maybe print in team colors?
2793 // TODO: maybe this could be cleaned up somehow...
2794 // TODO: less copypaste code below
2797 if(killnotify_actiontype[j] == 0 && !hud_configure)
2799 attacker = textShortenToWidth(killnotify_attackers[j], mySize_x - 2 * height, fontsize, stringwidth_colors);
2801 width_attacker = stringwidth(attacker, TRUE, fontsize);
2802 pos_attacker = pos + eX * 0.5 * (mySize_x - width_attacker + 2 * height) + eY * 0.5 * fontsize_y + eY * i * height;
2804 weap_pos = pos + eX * 0.5 * (mySize_x - width_attacker) - eX * height + eY * i * height;
2805 if(killnotify_deathtype[j] == DEATH_GENERIC)
2807 drawpic_skin(weap_pos, "notify_death", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2808 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2810 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2812 drawpic_skin(weap_pos, "notify_outofammo", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2813 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2815 else if(killnotify_deathtype[j] == DEATH_KILL)
2817 drawpic_skin(weap_pos, "notify_selfkill", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2818 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2820 else if(killnotify_deathtype[j] == DEATH_CAMP)
2822 drawpic_skin(weap_pos, "notify_camping", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2823 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2825 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2827 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2828 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2830 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2832 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2833 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2835 else if(killnotify_deathtype[j] == DEATH_DROWN)
2837 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2838 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2840 else if(killnotify_deathtype[j] == DEATH_SLIME)
2842 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2843 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2845 else if(killnotify_deathtype[j] == DEATH_LAVA)
2847 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2848 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2850 else if(killnotify_deathtype[j] == DEATH_FALL)
2852 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2853 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2855 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2857 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2858 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2860 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2862 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2863 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2865 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2867 if(killnotify_victims[j] == "^1RED^7 flag")
2871 drawpic_skin(weap_pos, strcat("flag_", s, "_carrying"), '1 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] == INFO_RETURNFLAG)
2876 if(killnotify_victims[j] == "^1RED^7 flag")
2880 drawpic_skin(weap_pos, strcat("flag_", s, "_taken"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2881 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2883 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2885 if(killnotify_victims[j] == "^1RED^7 flag")
2889 drawpic_skin(weap_pos, strcat("flag_", s, "_lost"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2890 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2893 // X [did action to] Y
2898 attacker = textShortenToWidth("Player1", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2899 victim = textShortenToWidth("Player2", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2900 a = bound(0, (when - j) / 4, 1);
2904 attacker = textShortenToWidth(killnotify_attackers[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2905 victim = textShortenToWidth(killnotify_victims[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2907 width_attacker = stringwidth(attacker, TRUE, fontsize);
2908 width_victim = stringwidth(victim, TRUE, fontsize);
2909 pos_attacker = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_attacker) + eY * 0.5 * fontsize_y + eY * i * height;
2910 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;
2911 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2913 if(hud_configure) // example actions for config mode
2915 drawpic_skin(weap_pos, strcat("weapon", "electro"), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2916 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2917 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2919 else if(WEP_VALID(killnotify_deathtype[j]))
2921 self = get_weaponinfo(killnotify_deathtype[j]);
2922 drawpic_skin(weap_pos, strcat("weapon", self.netname), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2923 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2924 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2926 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2928 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2929 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2930 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2932 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2934 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2935 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2936 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2938 else if(killnotify_deathtype[j] == DEATH_DROWN)
2940 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2941 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2942 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2944 else if(killnotify_deathtype[j] == DEATH_SLIME)
2946 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2947 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2948 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2950 else if(killnotify_deathtype[j] == DEATH_LAVA)
2952 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2953 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2954 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2956 else if(killnotify_deathtype[j] == DEATH_FALL)
2958 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2959 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2960 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2962 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2964 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2965 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2966 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2968 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2970 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2971 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2972 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2983 if(cvar("hud_notify_info_top"))
2986 o = pos + eY * mySize_y - eY * 2 * height;
2988 if(spectatee_status && !intermission)
2990 //drawfont = hud_bigfont;
2991 if(spectatee_status == -1)
2994 s = GetPlayerName(spectatee_status - 1);
2996 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
2997 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2998 //drawfont = hud_font;
3000 // spectator text in the upper right corner
3001 if(spectatee_status == -1)
3002 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
3004 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
3005 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3006 o += eY * fontsize_y;
3008 if(spectatee_status == -1)
3009 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
3011 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
3012 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3013 o += eY * fontsize_y;
3015 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
3016 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3017 o += eY * fontsize_y;
3019 if(gametype == GAME_ARENA)
3020 s = "^1Wait for your turn to join";
3021 else if(gametype == GAME_LMS)
3024 sk = playerslots[player_localentnum - 1];
3025 if(sk.(scores[ps_primary]) >= 666)
3026 s = "^1Match has already begun";
3027 else if(sk.(scores[ps_primary]) > 0)
3028 s = "^1You have no more lives left";
3030 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
3033 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
3034 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3035 o += eY * fontsize_y;
3037 //show restart countdown:
3038 if (time < getstatf(STAT_GAMESTARTTIME)) {
3040 //we need to ceil, otherwise the countdown would be off by .5 when using round()
3041 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
3042 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
3043 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3044 o += eY * fontsize_y;
3047 if(warmup_stage && !intermission)
3049 s = "^2Currently in ^1warmup^2 stage!";
3050 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3051 o += eY * fontsize_y;
3055 if(mod(time, 1) >= 0.5)
3060 if(ready_waiting && !intermission && !spectatee_status)
3062 if(ready_waiting_for_me)
3065 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
3067 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
3072 s = strcat("^2Waiting for others to ready up to end warmup...");
3074 s = strcat("^2Waiting for others to ready up...");
3076 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3077 o += eY * fontsize_y;
3079 else if(warmup_stage && !intermission && !spectatee_status)
3081 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
3082 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3083 o += eY * fontsize_y;
3086 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
3088 float ts_min, ts_max;
3089 tm = teams.sort_next;
3092 for(; tm.sort_next; tm = tm.sort_next)
3094 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
3096 if(!ts_min) ts_min = tm.team_size;
3097 else ts_min = min(ts_min, tm.team_size);
3098 if(!ts_max) ts_max = tm.team_size;
3099 else ts_max = max(ts_max, tm.team_size);
3101 if ((ts_max - ts_min) > 1)
3103 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
3104 tm = GetTeam(myteam, false);
3106 if (tm.team != COLOR_SPECTATOR)
3107 if (tm.team_size == ts_max)
3108 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
3110 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3111 o += eY * fontsize_y;
3117 s = "^7Press ^3ESC ^7to show HUD options.";
3118 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3119 o += eY * fontsize_y;
3120 s = "^3Doubleclick a panel for panel-specific options.";
3121 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3122 o += eY * fontsize_y;
3128 string seconds_tostring(float sec)
3131 minutes = floor(sec / 60);
3133 sec -= minutes * 60;
3136 s = ftos(100 + sec);
3138 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3141 void HUD_Timer(void)
3143 float id = HUD_PANEL_TIMER;
3145 pos = HUD_Panel_GetPos(id);
3146 mySize = HUD_Panel_GetSize(id);
3148 HUD_Panel_DrawBg(id, pos, mySize, 0);
3150 padding = HUD_Panel_GetPadding(id);
3153 pos += '1 1 0' * padding;
3154 mySize -= '2 2 0' * padding;
3158 float timelimit, elapsedTime, timeleft, minutesLeft;
3160 timelimit = getstatf(STAT_TIMELIMIT);
3162 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3163 timeleft = ceil(timeleft);
3165 minutesLeft = floor(timeleft / 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 timer = seconds_tostring(0);
3180 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3181 timer = seconds_tostring(elapsedTime);
3184 timer = seconds_tostring(timeleft);
3187 drawstring_aspect(pos, timer, mySize, mySize_y, timer_color, HUD_Panel_GetFgAlpha(HUD_PANEL_TIMER), DRAWFLAG_NORMAL);
3192 void HUD_Radar(void)
3194 float id = HUD_PANEL_RADAR;
3196 pos = HUD_Panel_GetPos(id);
3197 mySize = HUD_Panel_GetSize(id);
3199 HUD_Panel_DrawBg(id, pos, mySize, 0);
3201 padding = HUD_Panel_GetPadding(id);
3204 pos += '1 1 0' * padding;
3205 mySize -= '2 2 0' * padding;
3208 local float color1, color2; // color already declared as a global in hud.qc
3211 float scale2d, normalsize, bigsize;
3214 teamradar_origin2d = pos + 0.5 * mySize;
3215 teamradar_size2d = mySize;
3217 if(minimapname == "")
3220 teamradar_loadcvars();
3222 switch(hud_radar_zoommode)
3226 f = current_zoomfraction;
3229 f = 1 - current_zoomfraction;
3239 switch(hud_radar_rotation)
3242 teamradar_angle = view_angles_y - 90;
3245 teamradar_angle = 90 * hud_radar_rotation;
3249 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3250 teamradar_size2d = mySize;
3252 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3254 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3255 if(hud_radar_rotation == 0)
3257 // max-min distance must fit the radar in any rotation
3258 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3262 vector c0, c1, c2, c3, span;
3263 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3264 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3265 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3266 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3268 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3269 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3271 // max-min distance must fit the radar in x=x, y=y
3273 teamradar_size2d_x * scale2d / (1.05 * span_x),
3274 teamradar_size2d_y * scale2d / (1.05 * span_y)
3278 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3279 if(bigsize > normalsize)
3280 normalsize = bigsize;
3284 + (1 - f) * normalsize;
3285 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3286 f * (mi_min + mi_max) * 0.5
3287 + (1 - f) * view_origin);
3289 color1 = GetPlayerColor(player_localentnum-1);
3290 rgb = GetTeamRGB(color1);
3299 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3301 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3302 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3303 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3304 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, HUD_Panel_GetFgAlpha(id));
3305 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3307 color2 = GetPlayerColor(tm.sv_entnum);
3308 //if(color == COLOR_SPECTATOR || color == color2)
3309 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3311 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3313 drawresetcliparea();
3318 void HUD_Score(void)
3320 float id = HUD_PANEL_SCORE;
3322 pos = HUD_Panel_GetPos(id);
3323 mySize = HUD_Panel_GetSize(id);
3325 HUD_Panel_DrawBg(id, pos, mySize, 0);
3327 padding = HUD_Panel_GetPadding(id);
3330 pos += '1 1 0' * padding;
3331 mySize -= '2 2 0' * padding;
3334 float score, distribution, leader;
3335 float score_len, distr_len;
3336 vector distribution_color;
3338 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3340 // TODO... this (race part) still uses constant coordinates :/
3341 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3342 /*pl = players.sort_next;
3345 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3346 if(pl.scores[ps_primary] == 0)
3349 score = me.(scores[ps_primary]);
3351 float racemin, racesec, racemsec;
3352 float distsec, distmsec, minusplus;
3354 racemin = floor(score/(60 * TIME_FACTOR));
3355 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
3356 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
3358 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3359 // distribution display
3360 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3362 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
3363 distmsec = fabs(distribution);
3365 distsec = floor(fabs(distribution)/TIME_FACTOR);
3366 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
3367 if (distribution < 0)
3371 if (distribution <= 0) {
3372 distribution_color = eY;
3373 minusplus = 1; // minusplus 1: always prefix with minus sign
3376 distribution_color = eX;
3377 minusplus = 2; // minusplus 1: always prefix with plus sign
3379 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);
3380 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);
3381 drawpic_skin(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "num_dot", '16 16 0', distribution_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE);
3383 // race record display
3384 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
3385 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);
3387 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);
3388 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);
3389 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);
3391 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);
3392 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);
3394 } else if (!teamplay) { // non-teamgames
3395 // me vector := [team/connected frags id]
3396 pl = players.sort_next;
3403 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3407 score = me.(scores[ps_primary]);
3411 if(distribution >= 5) {
3412 distribution_color = eY;
3414 } else if(distribution >= 0) {
3415 distribution_color = '1 1 1';
3417 } else if(distribution >= -5)
3418 distribution_color = '1 1 0';
3420 distribution_color = eX;
3422 score_len = strlen(ftos(score));
3423 distr_len = strlen(ftos(distribution));
3425 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);
3427 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);
3428 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);
3429 } else { // teamgames
3430 float max_fragcount;
3431 max_fragcount = -99;
3434 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3435 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !hud_configure)) // no players? don't display
3437 score = tm.(teamscores[ts_primary]);
3442 score_len = strlen(ftos(score));
3444 if (score > max_fragcount)
3445 max_fragcount = score;
3447 if(tm.team == myteam) {
3448 if (max_fragcount == score)
3451 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);
3452 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);
3454 if (max_fragcount == score)
3457 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);
3458 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);
3467 void HUD_RaceTimer (void) {
3468 float id = HUD_PANEL_RACETIMER;
3470 pos = HUD_Panel_GetPos(id);
3471 mySize = HUD_Panel_GetSize(id);
3473 HUD_Panel_DrawBg(id, pos, mySize, 0);
3475 padding = HUD_Panel_GetPadding(id);
3478 pos += '1 1 0' * padding;
3479 mySize -= '2 2 0' * padding;
3482 drawfont = hud_bigfont;
3484 string s, forcetime;
3489 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);
3490 s = "^1Intermediate 1 (+15.42)";
3491 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);
3492 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3493 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);
3495 else if(race_checkpointtime)
3497 a = bound(0, 2 - (time - race_checkpointtime), 1);
3500 if(a > 0) // just hit a checkpoint?
3502 if(race_checkpoint != 254)
3504 if(race_time && race_previousbesttime)
3505 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3507 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3509 forcetime = TIME_ENCODED_TOSTRING(race_time);
3514 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3516 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3517 if(a > 0) // next one?
3519 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3524 if(s != "" && a > 0)
3526 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3527 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3528 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);
3531 if(race_penaltytime)
3533 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3536 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3537 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3538 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3539 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);
3545 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3546 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id), 0, a);
3547 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);
3552 if(race_laptime && race_checkpoint != 255)
3554 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3555 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3556 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);
3561 if(race_mycheckpointtime)
3563 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3564 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3565 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3566 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3567 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);
3569 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3571 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3572 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3573 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3574 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3575 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_penaltytime && !race_penaltyaccumulator)
3580 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3581 a = bound(0, (1 + t - time), 1);
3585 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3587 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3588 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3589 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3590 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);
3595 drawfont = hud_font;
3600 float vote_yescount;
3603 float vote_highlighted; // currently selected vote
3605 float vote_active; // is there an active vote?
3606 float vote_prev; // previous state of vote_active to check for a change
3608 float vote_change; // "time" when vote_active changed
3610 void HUD_VoteWindow(void)
3612 float id = HUD_PANEL_VOTE;
3614 pos = HUD_Panel_GetPos(id);
3615 mySize = HUD_Panel_GetSize(id);
3619 if(vote_active != vote_prev) {
3621 vote_prev = vote_active;
3624 if(vote_active || hud_configure)
3625 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3627 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3639 a = vote_alpha * bound(cvar_or("hud_vote_alreadyvoted_alpha", 0.75), 1 - vote_highlighted, 1);
3641 HUD_Panel_DrawBg(id, pos, mySize, a);
3643 padding = HUD_Panel_GetPadding(id);
3646 pos += '1 1 0' * padding;
3647 mySize -= '2 2 0' * padding;
3650 drawpic_skin(pos, "voteprogress_back", mySize, '1 1 1', a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3652 s = "A vote has been called for: ";
3653 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);
3654 s = textShortenToWidth(vote_called_vote, mySize_x * 0.96, '1 1 0' * mySize_y*(1/5), stringwidth_colors); // TODO: broken?
3656 s = "Configure the HUD";
3657 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);
3659 // print the yes/no counts
3660 s = strcat("Yes: ", ftos(vote_yescount));
3661 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);
3662 s = strcat("No: ", ftos(vote_nocount));
3663 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);
3665 // draw the progress bars
3666 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3667 drawpic_skin(pos, "voteprogress_prog", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3669 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3670 drawpic_skin(pos, "voteprogress_prog", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3672 // draw the highlights
3673 if(vote_highlighted == 1) {
3674 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3675 drawpic_skin(pos, "voteprogress_voted", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3677 else if(vote_highlighted == 2) {
3678 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3679 drawpic_skin(pos, "voteprogress_voted", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3682 drawresetcliparea();
3685 vote_highlighted = 0;
3689 // Mod icons panel (#10)
3692 float mod_active; // is there any active mod icon?
3694 // CTF HUD modicon section
3695 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3696 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3697 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3699 void HUD_Mod_CTF_Reset(void)
3701 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3704 void HUD_Mod_CTF(vector pos, vector mySize)
3706 vector redflag_pos, blueflag_pos;
3708 float f; // every function should have that
3710 float redflag, blueflag; // current status
3711 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3714 stat_items = getstati(STAT_ITEMS);
3715 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3716 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3718 if(redflag || blueflag)
3729 // when status CHANGES, set old status into prevstatus and current status into status
3730 if (redflag != redflag_prevframe)
3732 redflag_statuschange_time = time;
3733 redflag_prevstatus = redflag_prevframe;
3734 redflag_prevframe = redflag;
3737 if (blueflag != blueflag_prevframe)
3739 blueflag_statuschange_time = time;
3740 blueflag_prevstatus = blueflag_prevframe;
3741 blueflag_prevframe = blueflag;
3744 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3745 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3747 float BLINK_FACTOR = 0.15;
3748 float BLINK_BASE = 0.85;
3750 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3752 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3754 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3756 string red_icon, red_icon_prevstatus;
3757 float red_alpha, red_alpha_prevstatus;
3758 red_alpha = red_alpha_prevstatus = 1;
3760 case 1: red_icon = "flag_red_taken"; break;
3761 case 2: red_icon = "flag_red_lost"; break;
3762 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3764 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3765 red_icon = "flag_red_shielded";
3767 red_icon = string_null;
3770 switch(redflag_prevstatus) {
3771 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3772 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3773 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3776 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3777 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3778 red_icon_prevstatus = "flag_red_shielded";
3780 red_icon_prevstatus = string_null;
3784 string blue_icon, blue_icon_prevstatus;
3785 float blue_alpha, blue_alpha_prevstatus;
3786 blue_alpha = blue_alpha_prevstatus = 1;
3788 case 1: blue_icon = "flag_blue_taken"; break;
3789 case 2: blue_icon = "flag_blue_lost"; break;
3790 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3792 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3793 blue_icon = "flag_blue_shielded";
3795 blue_icon = string_null;
3798 switch(blueflag_prevstatus) {
3799 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3800 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3801 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3804 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3805 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3806 blue_icon_prevstatus = "flag_blue_shielded";
3808 blue_icon_prevstatus = string_null;
3812 if(mySize_x > mySize_y) {
3813 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3815 blueflag_pos = pos + eX * 0.5 * mySize_x;
3818 redflag_pos = pos + eX * 0.5 * mySize_x;
3820 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3822 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3824 blueflag_pos = pos + eY * 0.5 * mySize_y;
3827 redflag_pos = pos + eY * 0.5 * mySize_y;
3829 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3832 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3833 if(red_icon_prevstatus && f < 1)
3834 drawpic_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3836 drawpic_skin(redflag_pos, red_icon, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * red_alpha * f, DRAWFLAG_NORMAL);
3838 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3839 if(blue_icon_prevstatus && f < 1)
3840 drawpic_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3842 drawpic_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * blue_alpha * f, DRAWFLAG_NORMAL);
3845 // Keyhunt HUD modicon section
3846 float kh_runheretime;
3848 void HUD_Mod_KH_Reset(void)
3853 void HUD_Mod_KH(vector pos, vector mySize)
3855 mod_active = 1; // keyhunt should never hide the mod icons panel
3859 vector p, pa, kh_size, kh_asize;
3861 kh_keys = getstati(STAT_KH_KEYS);
3864 if(mySize_x > mySize_y)
3866 p_y = pos_y + 0.25 * mySize_y;
3867 pa = p - eY * 0.25 * mySize_y;
3869 kh_size_x = mySize_x * 0.25;
3870 kh_size_y = 0.75 * mySize_y;
3871 kh_asize_x = mySize_x * 0.25;
3872 kh_asize_y = mySize_y * 0.25;
3876 p_y = pos_y + 0.125 * mySize_y;
3877 pa = p - eY * 0.125 * mySize_y;
3879 kh_size_x = mySize_x * 0.5;
3880 kh_size_y = 0.375 * mySize_y;
3881 kh_asize_x = mySize_x * 0.5;
3882 kh_asize_y = mySize_y * 0.125;
3889 for(i = 0; i < 4; ++i)
3891 key = floor(kh_keys / pow(32, i)) & 31;
3893 if(keyteam == 30 && keycount <= 4)
3895 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3899 // this yields 8 exactly if "RUN HERE" shows
3904 kh_runheretime = time;
3905 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3910 for(i = 0; i < 4; ++i)
3912 key = floor(kh_keys / pow(32, i)) & 31;
3925 default: // owned or dropped
3930 a = a * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3931 aa = aa * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3937 drawpic_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3940 drawpic_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3943 drawpic_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3946 drawpic_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3951 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3954 drawpic_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3957 drawpic_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3960 drawpic_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3963 drawpic_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3967 if(mySize_x > mySize_y)
3969 p_x += 0.25 * mySize_x;
3970 pa_x += 0.25 * mySize_x;
3976 p_y = pos_y + 0.625 * mySize_y;
3977 pa_y = pos_y + 0.5 * mySize_y;
3983 p_x += 0.5 * mySize_x;
3984 pa_x += 0.5 * mySize_x;
3990 // Nexball HUD mod icon
3991 void HUD_Mod_NexBall(vector pos, vector mySize)
3993 float stat_items, nb_pb_starttime, dt, p;
3995 stat_items = getstati(STAT_ITEMS);
3996 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3998 if (stat_items & IT_KEY1)
4003 //Manage the progress bar if any
4004 if (nb_pb_starttime > 0)
4006 dt = mod(time - nb_pb_starttime, nb_pb_period);
4007 // one period of positive triangle
4008 p = 2 * dt / nb_pb_period;
4015 if(mySize_x > mySize_y)
4017 barsize = eX * p * mySize_x + eY * mySize_y;
4022 barsize = eX * mySize_x + eY * p * mySize_y;
4025 HUD_Panel_DrawProgressBar(pos, vertical, barsize, HUD_Panel_GetProgressBarColor("nexball"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4028 if (stat_items & IT_KEY1)
4029 drawpic_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4032 // Race/CTS HUD mod icons
4033 float crecordtime_prev; // last remembered crecordtime
4034 float crecordtime_change_time; // time when crecordtime last changed
4035 float srecordtime_prev; // last remembered srecordtime
4036 float srecordtime_change_time; // time when srecordtime last changed
4038 float race_status_time;
4039 float race_status_prev;
4040 string race_status_name_prev;
4041 void HUD_Mod_Race(vector pos, vector mySize)
4043 mod_active = 1; // race should never hide the mod icons panel
4045 me = playerslots[player_localentnum - 1];
4047 float f; // yet another function has this
4048 score = me.(scores[ps_primary]);
4050 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
4051 return; // no records in the actual race
4053 drawfont = hud_bigfont;
4055 // clientside personal record
4057 if(gametype == GAME_CTS)
4061 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4063 if(score && (score < t || !t)) {
4064 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4065 if(cvar("cl_autodemo_delete_keeprecords"))
4067 f = cvar("cl_autodemo_delete");
4069 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4073 if(t != crecordtime_prev) {
4074 crecordtime_prev = t;
4075 crecordtime_change_time = time;
4077 f = time - crecordtime_change_time;
4080 drawstring_aspect(pos, "Personal best ", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4081 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);
4083 drawstring(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4084 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);
4085 drawstring_expanding(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL, f);
4086 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);
4090 t = race_server_record;
4091 if(t != srecordtime_prev) {
4092 srecordtime_prev = t;
4093 srecordtime_change_time = time;
4095 f = time - srecordtime_change_time;
4098 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);
4099 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);
4101 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);
4102 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);
4103 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);
4104 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);
4107 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4108 race_status_time = time + 5;
4109 race_status_prev = race_status;
4110 if (race_status_name_prev)
4111 strunzone(race_status_name_prev);
4112 race_status_name_prev = strzone(race_status_name);
4115 pos_x += mySize_x/2;
4118 a = bound(0, race_status_time - time, 1);
4121 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4125 rank = race_CheckName(race_status_name);
4127 rankname = race_PlaceName(rank);
4130 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4132 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4134 if(race_status == 0)
4135 drawpic_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4136 else if(race_status == 1) {
4137 drawpic_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4138 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4139 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4140 } else if(race_status == 2) {
4141 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4142 drawpic_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4144 drawpic_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4145 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4146 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4147 } else if(race_status == 3) {
4148 drawpic_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4149 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4150 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4153 if (race_status_time - time <= 0) {
4154 race_status_prev = -1;
4156 if(race_status_name)
4157 strunzone(race_status_name);
4158 race_status_name = string_null;
4159 if(race_status_name_prev)
4160 strunzone(race_status_name_prev);
4161 race_status_name_prev = string_null;
4163 drawfont = hud_font;
4166 float mod_prev; // previous state of mod_active to check for a change
4168 float mod_change; // "time" when mod_active changed
4170 void HUD_ModIcons(void)
4172 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !hud_configure)
4175 float id = HUD_PANEL_MODICONS;
4177 pos = HUD_Panel_GetPos(id);
4178 mySize = HUD_Panel_GetSize(id);
4180 if(mod_active != mod_prev) {
4182 mod_prev = mod_active;
4185 if(mod_active || hud_configure)
4186 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4188 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4191 HUD_Panel_DrawBg(id, pos, mySize, mod_alpha);
4194 padding = HUD_Panel_GetPadding(id);
4197 pos += '1 1 0' * padding;
4198 mySize -= '2 2 0' * padding;
4201 // these MUST be ran in order to update mod_active
4202 if(gametype == GAME_KEYHUNT)
4203 HUD_Mod_KH(pos, mySize);
4204 else if(gametype == GAME_CTF || hud_configure)
4205 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4206 else if(gametype == GAME_NEXBALL)
4207 HUD_Mod_NexBall(pos, mySize);
4208 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4209 HUD_Mod_Race(pos, mySize);
4212 // Draw pressed keys (#11)
4214 void HUD_DrawPressedKeys(void)
4216 float id = HUD_PANEL_PRESSEDKEYS;
4218 pos = HUD_Panel_GetPos(id);
4219 mySize = HUD_Panel_GetSize(id);
4221 HUD_Panel_DrawBg(id, pos, mySize, 0);
4223 padding = HUD_Panel_GetPadding(id);
4226 pos += '1 1 0' * padding;
4227 mySize -= '2 2 0' * padding;
4231 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4234 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4235 drawpic_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4236 drawpic_skin(pos + eX * mySize_x * (1/3), ((pressedkeys & KEY_FORWARD) ? "key_forward_inv.tga" : "key_forward.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4237 drawpic_skin(pos + eX * mySize_x * (2/3), ((pressedkeys & KEY_JUMP) ? "key_jump_inv.tga" : "key_jump.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4238 drawpic_skin(pos + eY * 0.5 * mySize_y, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4239 drawpic_skin(pos + eY * 0.5 * mySize_y + eX * mySize_x * (1/3), ((pressedkeys & KEY_BACKWARD) ? "key_backward_inv.tga" : "key_backward.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4240 drawpic_skin(pos + eY * 0.5 * mySize_y + eX * mySize_x * (2/3), ((pressedkeys & KEY_RIGHT) ? "key_right_inv.tga" : "key_right.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4243 // Handle chat as a panel (#12)
4247 float id = HUD_PANEL_CHAT;
4249 pos = HUD_Panel_GetPos(id);
4250 mySize = HUD_Panel_GetSize(id);
4252 HUD_Panel_DrawBg(id, pos, mySize, 0);
4254 padding = HUD_Panel_GetPadding(id);
4257 pos += '1 1 0' * padding;
4258 mySize -= '2 2 0' * padding;
4261 cvar_set("con_chatrect", "1");
4263 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4264 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4266 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4267 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4272 chatsize = cvar("con_chatsize");
4273 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4275 for(i = 0; i < cvar("con_chat"); ++i)
4277 if(i == cvar("con_chat") - 1)
4278 a = HUD_Panel_GetFgAlpha(id);
4280 a = HUD_Panel_GetFgAlpha(id) * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4281 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);
4286 // Engine info panel (#13)
4293 float frametimeavg1; // 1 frame ago
4294 float frametimeavg2; // 2 frames ago
4295 void HUD_EngineInfo(void)
4297 float id = HUD_PANEL_ENGINEINFO;
4299 pos = HUD_Panel_GetPos(id);
4300 mySize = HUD_Panel_GetSize(id);
4302 HUD_Panel_DrawBg(id, pos, mySize, 0);
4304 padding = HUD_Panel_GetPadding(id);
4307 pos += '1 1 0' * padding;
4308 mySize -= '2 2 0' * padding;
4311 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4313 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4314 frametimeavg2 = frametimeavg1;
4315 frametimeavg1 = frametimeavg;
4318 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4319 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.
4321 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
4322 prevfps = (1/frametime);
4323 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"
4329 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4331 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4333 prevfps_time = time;
4338 color = HUD_Get_Num_Color (prevfps, 100);
4339 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), mySize, mySize_y, color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4347 void HUD_ShowSpeed(void)
4350 float pos, conversion_factor;
4351 string speed, zspeed, unit;
4353 switch(cvar("cl_showspeed_unit"))
4358 conversion_factor = 1.0;
4362 conversion_factor = 1.0;
4366 conversion_factor = 0.0254;
4370 conversion_factor = 0.0254 * 3.6;
4374 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4378 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4382 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4384 numsize_x = numsize_y = cvar("cl_showspeed_size");
4385 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4387 drawfont = hud_bigfont;
4388 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4390 if (cvar("cl_showspeed_z") == 1) {
4391 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4392 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4395 drawfont = hud_font;
4398 vector acc_prevspeed;
4402 void HUD_ShowAcceleration(void)
4404 float acceleration, sz, scale, alpha, f;
4405 vector pos, top, rgb;
4406 top_x = vid_conwidth/2;
4409 f = time - acc_prevtime;
4410 if(cvar("cl_showacceleration_z"))
4411 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4413 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4414 acc_prevspeed = pmove_vel;
4415 acc_prevtime = time;
4417 f = bound(0, f * 10, 1);
4418 acc_avg = acc_avg * (1 - f) + acceleration * f;
4419 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4421 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4423 sz = cvar("cl_showacceleration_size");
4424 scale = cvar("cl_showacceleration_scale");
4425 alpha = cvar("cl_showacceleration_alpha");
4426 if (cvar("cl_showacceleration_color_custom"))
4427 rgb = stov(cvar_string("cl_showacceleration_color"));
4430 if (acceleration < 0) {
4431 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4432 } else if (acceleration > 0) {
4433 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4437 if (acceleration > 0)
4438 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4439 else if (acceleration < 0)
4440 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4443 void HUD_Reset (void)
4445 // reset gametype specific icons
4446 if(gametype == GAME_KEYHUNT)
4448 else if(gametype == GAME_CTF)
4449 HUD_Mod_CTF_Reset();
4452 void HUD_Main (void)
4454 if(disable_menu_alphacheck == 1)
4455 menu_fade_alpha = 1;
4457 menu_fade_alpha = (1 - cvar("_menu_alpha"));
4458 hud_fg_alpha = cvar("hud_fg_alpha");
4460 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4461 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4462 hud_color_bg_team = cvar("hud_color_bg_team");
4464 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4465 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4467 hud_configure = cvar("_hud_configure");
4471 // HUD configure visible grid
4472 if(hud_configure && cvar("hud_configure_grid") && cvar("hud_configure_grid_alpha"))
4476 for(i = 0; i < 1/bound(0.005, cvar("hud_configure_grid_x"), 0.2); ++i)
4478 drawfill(eX * i * vid_conwidth * bound(0.005, cvar("hud_configure_grid_x"), 0.2), eX + eY * vid_conheight, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
4481 for(i = 0; i < 1/bound(0.005, cvar("hud_configure_grid_y"), 0.2); ++i)
4483 drawfill(eY * i * vid_conheight * bound(0.005, cvar("hud_configure_grid_y"), 0.2), eY + eX * vid_conwidth, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
4487 if(cvar_string("hud_dock") != "")
4488 drawpic('0 0 0', strcat("gfx/hud/", cvar_string("hud_skin"), "/", cvar_string("hud_dock")), eX * vid_conwidth + eY * vid_conheight, HUD_Panel_Dock_GetColor(), cvar("hud_dock_alpha") * menu_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
4490 if(HUD_Panel_CheckActive(HUD_PANEL_RADAR) || hud_configure)
4491 if(cvar_string("hud_radar") != "0" && (cvar("hud_radar") == 2 || teamplay))
4493 if(HUD_Panel_CheckActive(HUD_PANEL_WEAPONICONS) || hud_configure)
4495 if(HUD_Panel_CheckActive(HUD_PANEL_INVENTORY) || hud_configure)
4497 if(HUD_Panel_CheckActive(HUD_PANEL_POWERUPS) || hud_configure)
4499 if(HUD_Panel_CheckActive(HUD_PANEL_HEALTHARMOR) || hud_configure)
4501 if(HUD_Panel_CheckActive(HUD_PANEL_NOTIFY) || hud_configure)
4503 if(HUD_Panel_CheckActive(HUD_PANEL_TIMER) || hud_configure)
4505 if(HUD_Panel_CheckActive(HUD_PANEL_SCORE) || hud_configure)
4507 if(HUD_Panel_CheckActive(HUD_PANEL_RACETIMER) || hud_configure)
4508 if(gametype == GAME_RACE || gametype == GAME_CTS || hud_configure)
4510 if(HUD_Panel_CheckActive(HUD_PANEL_VOTE) || hud_configure)
4512 if(HUD_Panel_CheckActive(HUD_PANEL_MODICONS) || hud_configure)
4515 if(HUD_Panel_CheckActive(HUD_PANEL_PRESSEDKEYS) || hud_configure)
4516 if(spectatee_status > 0 || cvar("hud_pressedkeys") >= 2 || hud_configure)
4517 HUD_DrawPressedKeys();
4518 if(HUD_Panel_CheckActive(HUD_PANEL_CHAT) || hud_configure)
4521 cvar_set("con_chatrect", "0");
4522 if(HUD_Panel_CheckActive(HUD_PANEL_ENGINEINFO) || hud_configure)
4525 // TODO hud_'ify these
4526 if (cvar("cl_showspeed"))
4528 if (cvar("cl_showacceleration"))
4529 HUD_ShowAcceleration();
4531 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)
4532 localcmd("cmd selectteam auto; cmd join\n");
4534 if (!hud_configure) // hud config mode disabled, enable normal alpha stuff again
4535 disable_menu_alphacheck = 0;