7 // a border picture is a texture containing nine parts:
8 // 1/4 width: left part
9 // 1/2 width: middle part (stretched)
10 // 1/4 width: right part
12 // 1/4 height: top part
13 // 1/2 height: middle part (stretched)
14 // 1/4 height: bottom part
15 void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize)
20 //pic = draw_UseSkinFor(pic);
21 width = eX * theSize_x;
22 height = eY * theSize_y;
23 if(theSize_x <= theBorderSize_x * 2)
25 // not wide enough... draw just left and right then
26 bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
27 if(theSize_y <= theBorderSize_y * 2)
29 // not high enough... draw just corners
30 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
31 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
32 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
33 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
34 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
38 dY = theBorderSize_x * eY;
39 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
40 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
41 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
42 drawsubpic(theOrigin + width * 0.5 + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0' + eX - bW, '0 0.5 0' + bW, theColor, theAlpha, 0);
43 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
44 drawsubpic(theOrigin + width * 0.5 + height - dY, width * 0.5 + dY, pic, '0 0.75 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
49 if(theSize_y <= theBorderSize_y * 2)
51 // not high enough... draw just top and bottom then
52 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
53 dX = theBorderSize_x * eX;
54 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
55 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
56 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
57 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
58 drawsubpic(theOrigin + dX + height * 0.5, width - 2 * dX + height * 0.5, pic, '0.25 0 0' + eY - bH, '0.5 0 0' + bH, theColor, theAlpha, 0);
59 drawsubpic(theOrigin + width - dX + height * 0.5, dX + height * 0.5, pic, '0.75 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
63 dX = theBorderSize_x * eX;
64 dY = theBorderSize_x * eY;
65 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
66 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
67 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
68 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
69 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
70 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
71 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
72 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
73 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
78 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
79 void drawpic_skin(vector pos, string pic, vector sz, vector color, float alpha, float drawflag) {
80 drawpic(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, color, alpha, drawflag);
83 // return HUD background color
84 vector HUD_GetBgColor()
88 GetTeamRGB(myteam) * hud_color_bg_team;
90 // allow custom HUD colors in non-teamgames
91 color_x = cvar("hud_color_bg_r");
92 color_y = cvar("hud_color_bg_g");
93 color_z = cvar("hud_color_bg_b");
98 // return accuracy text color
99 vector HUD_AccuracyColor(float accuracy)
102 float yellow_accuracy = cvar("hud_weaponicons_accuracy_yellow"); // value at which this function returns yellow
103 if(accuracy >= 100) {
107 else if(accuracy > yellow_accuracy) {
108 rgb_x = 1 - (accuracy-yellow_accuracy)/(100-yellow_accuracy); // red value between 1 -> 0
113 rgb_y = accuracy/yellow_accuracy; // green value between 0 -> 1
119 // draw number in the XSCALE font
120 void HUD_DrawXNum (vector pos, float num, float digits, float showsign, float lettersize, vector rgb, float highlighted, float stroke, float alpha, float dflags)
123 string str, tmp, l_length;
125 vector vsize, num_color;
127 vsize_x = vsize_y = lettersize;
130 // showsign 1: always prefix with minus sign (useful in race distribution display)
131 // showsign 2: always prefix with plus sign (useful in race distribution display)
132 // showsign 3: prefix with minus sign if negative, plus sign if positive (useful in score distribution display)
134 if((showsign == 2 && num >= 0) || (num > 0 && showsign == 3))
141 if(num < 0 || (num < 0 && showsign == 3) || (showsign == 1 && num <= 0))
153 str = strcat(substring("0000000000", 0, digits - strlen(tmp)), tmp);
162 str = substring(str, l-digits, 999);
164 } else if(l < digits)
165 pos_x += (digits-l) * lettersize;
167 if (highlighted == 1) {
169 hl_size_x = vsize_x * l + vsize_x * 0.2;
170 hl_size_y = vsize_y * 1.1;
173 hl_size_x = hl_size_x + vsize_x;
176 hl_pos_x = pos_x - lettersize/10;
177 hl_pos_y = pos_y - lettersize/20;
180 drawpic_skin(hl_pos, strcat("highlight_", l_length), hl_size, '1 1 1', alpha, dflags);
191 drawpic_skin(pos, "num_minus_stroke", vsize, rgb, alpha, dflags);
192 drawpic_skin(pos, "num_minus", vsize, num_color, alpha, dflags);
197 drawpic_skin(pos, "num_plus_stroke", vsize, rgb, alpha, dflags);
198 drawpic_skin(pos, "num_plus", vsize, num_color, alpha, dflags);
202 for(i = 0; i < l; ++i)
204 tmp = substring(str, i, 1);
206 drawpic_skin(pos, strcat("num_", tmp, "_stroke"), vsize, rgb, alpha, dflags);
207 drawpic_skin(pos, strcat("num_", tmp), vsize, num_color, alpha, dflags);
212 // color the number differently based on how big it is (used in the health/armor panel)
213 void HUD_DrawXNum_Colored (vector pos, float x, float digits, float lettersize, float alpha)
222 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
223 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
227 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
228 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
229 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
234 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
238 color_y = (x-20)*90/27/100; // green value between 0 -> 1
239 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
246 HUD_DrawXNum(pos, x, digits, 0, lettersize, color, 0, 0, alpha, DRAWFLAG_NORMAL);
249 float stringwidth_colors(string s, vector theSize)
251 return stringwidth(s, TRUE, theSize);
254 float stringwidth_nocolors(string s, vector theSize)
256 return stringwidth(s, FALSE, theSize);
259 #define CENTERPRINT_MAX_LINES 30
260 string centerprint_messages[CENTERPRINT_MAX_LINES];
261 float centerprint_width[CENTERPRINT_MAX_LINES];
262 vector centerprint_start;
263 float centerprint_expire;
264 float centerprint_num;
265 float centerprint_offset_hint;
266 vector centerprint_fontsize;
268 void centerprint(string strMessage)
270 float i, j, n, hcount;
273 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
275 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
277 if(cvar("scr_centertime") <= 0)
283 // strip trailing newlines
284 j = strlen(strMessage) - 1;
285 while(substring(strMessage, j, 1) == "\n" && j >= 0)
287 strMessage = substring(strMessage, 0, j + 1);
292 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
294 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
296 strMessage = substring(strMessage, j, strlen(strMessage) - j);
297 centerprint_offset_hint = j;
302 // if we get here, we have a message. Initialize its height.
305 n = tokenizebyseparator(strMessage, "\n");
307 for(j = 0; j < n; ++j)
309 getWrappedLine_remaining = argv(j);
310 while(getWrappedLine_remaining)
312 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
313 if(centerprint_messages[i])
314 strunzone(centerprint_messages[i]);
315 centerprint_messages[i] = strzone(s);
316 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
319 // half height for empty lines looks better
325 if(i >= CENTERPRINT_MAX_LINES)
331 h = centerprint_fontsize_y*hcount;
333 havail = vid_conheight;
334 if(cvar("con_chatpos") < 0)
335 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
336 if(havail > vid_conheight - 70)
337 havail = vid_conheight - 70; // avoid overlapping HUD
339 centerprint_start_x = 0;
342 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
344 // here, the centerprint would cover the crosshair. REALLY BAD.
345 forbiddenmin = vid_conheight * 0.5 - h - 16;
346 forbiddenmax = vid_conheight * 0.5 + 16;
348 allowedmin = scoreboard_bottom;
349 allowedmax = havail - h;
350 preferred = (havail - h)/2;
353 // possible orderings (total: 4! / 4 = 6)
354 // allowedmin allowedmax forbiddenmin forbiddenmax
355 // forbiddenmin forbiddenmax allowedmin allowedmax
356 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
358 // forbidden doesn't matter in this case
359 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
361 // allowedmin forbiddenmin allowedmax forbiddenmax
362 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
364 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
366 // allowedmin forbiddenmin forbiddenmax allowedmax
367 else if(allowedmin < forbiddenmin)
369 // make sure the forbidden zone is not covered
370 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
371 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
373 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
375 // forbiddenmin allowedmin allowedmax forbiddenmax
376 else if(allowedmax < forbiddenmax)
378 // it's better to leave the allowed zone (overlap with scoreboard) than
379 // to cover the forbidden zone (crosshair)
380 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
381 centerprint_start_y = forbiddenmax;
383 centerprint_start_y = forbiddenmin;
385 // forbiddenmin allowedmin forbiddenmax allowedmax
388 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
391 centerprint_start_y =
394 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
402 centerprint_expire = time + cvar("scr_centertime");
405 void HUD_DrawCenterPrint (void)
412 //if(time > centerprint_expire)
415 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
416 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
417 //sz = 1.2 / (a + 0.2);
422 pos = centerprint_start;
423 for (i=0; i<centerprint_num; i = i + 1)
425 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
426 ts = centerprint_messages[i];
429 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
430 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
431 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
432 pos_y = pos_y + centerprint_fontsize_y;
435 // half height for empty lines looks better
436 pos_y = pos_y + centerprint_fontsize_y * 0.5;
440 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
442 position_x -= 2 / 3 * strlen(text) * scale_x;
443 drawstring(position, text, scale, rgb, alpha, flag);
446 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
448 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
449 drawstring(position, text, scale, rgb, alpha, flag);
452 // return the string of the given race place
453 string race_PlaceName(float pos) {
461 return strcat(ftos(pos), "th");
464 // return the string of the onscreen race timer
465 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
473 if(histime == 0) // goal hit
477 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
487 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
493 lapstr = strcat(" (-", ftos(lapdelta), "L)");
496 else if(lapdelta < 0)
498 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
502 else if(histime > 0) // anticipation
504 if(mytime >= histime)
505 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
507 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
514 cpname = "Start line";
516 cpname = "Finish line";
518 cpname = strcat("Intermediate ", ftos(cp));
520 cpname = "Finish line";
523 return strcat(col, cpname);
524 else if(hisname == "")
525 return strcat(col, cpname, " (", timestr, ")");
527 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
530 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
531 float race_CheckName(string net_name) {
533 for (i=RANKINGS_CNT-1;i>=0;--i)
534 if(grecordholder[i] == net_name)
545 string HUD_Panel_GetName(float id)
548 case 0: return "weaponicons"; break;
549 case 1: return "inventory"; break;
550 case 2: return "powerups"; break;
551 case 3: return "healtharmor"; break;
552 case 4: return "notify"; break;
553 case 5: return "timer"; break;
554 case 6: return "radar"; break;
555 case 7: return "score"; break;
556 case 8: return "racetimer"; break;
557 case 9: return "vote"; break;
558 case 10: return "pressedkeys"; break;
564 void HUD_Panel_ExportCfg(string cfgname)
567 fh = fopen(strcat("hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg"), FILE_WRITE);
570 fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
571 fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
572 fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
573 fputs(fh, strcat("seta hud_bg_alpha ", ftos(cvar("hud_bg_alpha")), "\n"));
574 fputs(fh, strcat("seta hud_bg_border ", ftos(cvar("hud_bg_border")), "\n"));
575 fputs(fh, strcat("seta hud_fg_alpha ", ftos(cvar("hud_fg_alpha")), "\n"));
578 fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
579 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
580 fputs(fh, strcat("seta hud_dock_alpha ", ftos(cvar("hud_dock_alpha")), "\n"));
583 fputs(fh, strcat("seta hud_progressbar_alpha ", ftos(cvar("hud_progressbar_alpha")), "\n"));
584 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
585 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
586 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
587 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
588 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
591 // common cvars for all panels
593 for (i = 0; i < panel_cnt; ++i)
595 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), " ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i)))), "\n"));
596 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_pos \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_pos")), "\"", "\n"));
597 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_size \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_size")), "\"", "\n"));
598 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg")), "\"", "\n"));
599 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color")), "\"", "\n"));
600 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_bg_alpha"))), "\n"));
601 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_border ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_bg_border"))), "\n"));
604 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_accuracy_height ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_accuracy_height"))), "\n"));
605 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_accuracy_yellow ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_accuracy_yellow"))), "\n"));
608 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_onlycurrent ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_onlycurrent"))), "\n"));
611 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
612 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_mirror ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
615 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
616 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_mirror ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
619 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha"))), "\n"));
625 print("^2Successfully exported to hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
630 vector HUD_Panel_CheckLimitSize(float id, vector mySize)
634 mySize_x = max(mySize_y * (1/10), mySize_x); // at least 1/10 * height
635 mySize_y = max(mySize_x * (1/26), mySize_y); // at least 1/26 * width
638 mySize_x = max(mySize_y * 0.7, mySize_x); // at least 0.7 * height
641 // mySize_x = max(mySize_y * 1.5, mySize_x); // at least 1.5 * height
644 // mySize_x = max(mySize_y * 2, mySize_x); // at least 2 * height
647 mySize_y = (1/4.1) * mySize_x; // 1/4.1 * width, trial and error...
650 mySize_y = (1/4) * mySize_x; // 1/4 * width
653 mySize_y = (1/4) * mySize_x; // 1/4 * width
656 mySize_y = (1/4) * mySize_x; // 1/4 * width
659 mySize_y = 0.5898 * mySize_x; // 0.5898 * width, reason: bg has weird dimensions...
665 // return active status of panel
666 float HUD_Panel_CheckActive(float id)
668 if (cvar_or(strcat("hud_", HUD_Panel_GetName(id)), 1))
673 // return size of given panel
674 vector HUD_Panel_GetSize(float id)
677 mySize = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_size")));
679 mySize = eX * mySize_x * vid_conwidth + eY * mySize_y * vid_conheight;
684 // return pos of given panel
685 vector HUD_Panel_GetPos(float id)
688 pos = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_pos")));
690 pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
693 pos_x = vid_conwidth + pos_x;
695 pos_y = vid_conheight + pos_y;
699 float HUD_Panel_GetBorder(float id)
702 border = cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_border"));
704 border = cvar("hud_bg_border");
708 // draw the background/borders
709 void HUD_Panel_DrawBg(float id, vector pos, vector mySize)
711 if(!hud_configure && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg")) == "0")
715 bg = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg"));
717 bg = cvar_string("hud_bg");
722 border = HUD_Panel_GetBorder(id);
725 if(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color")) != "")
726 color = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color")));
728 color = stov(cvar_string("hud_bg_color"));
731 alpha = cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_alpha"));
733 alpha = cvar("hud_bg_alpha");
735 alpha = max(cvar("hud_configure_bg_minalpha"), alpha);
737 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));
741 vector HUD_Panel_GetProgressBarColor(string item)
743 return stov(cvar_string(strcat("hud_progressbar_", item, "_color")));
746 float resizeCorner; // 1 = topleft, 2 = topright, 3 = bottomleft, 4 = bottomright
747 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
748 vector HUD_Panel_CheckResize(float id, vector myPos, vector mySize)
760 for (i = 0; i < panel_cnt; ++i) {
761 if(i == id || !HUD_Panel_CheckActive(i))
764 targPos = HUD_Panel_GetPos(i);
765 targSize = HUD_Panel_GetSize(i);
767 targPos = HUD_Panel_GetPos(i) - '1 1 0' * HUD_Panel_GetBorder(id);
768 targSize = HUD_Panel_GetSize(i) + '2 2 0' * HUD_Panel_GetBorder(id);
770 if(myPos_y + mySize_y < targPos_y)
772 if(myPos_y > targPos_y + targSize_y)
775 if(myPos_x + mySize_x < targPos_x)
777 if(myPos_x > targPos_x + targSize_x)
780 // OK, there IS a collision.
782 myCenter_x = myPos_x + 0.5 * mySize_x;
783 myCenter_y = myPos_y + 0.5 * mySize_y;
785 targCenter_x = targPos_x + 0.5 * targSize_x;
786 targCenter_y = targPos_y + 0.5 * targSize_y;
789 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y && resizeCorner != 1) // top left (of target panel)
791 if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
792 myTarget_x = targPos_x - myPos_x;
793 else // push it upwards
794 myTarget_y = targPos_y - myPos_y;
796 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y && resizeCorner != 2) // top right
798 if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
799 myTarget_x = targPos_x + targSize_x;
800 else // push it upwards
801 myTarget_y = targPos_y - myPos_y;
803 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
805 if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
806 myTarget_x = targPos_x - myPos_x;
807 else // push it downwards
808 myTarget_y = targPos_y + targSize_y;
810 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
812 if(targPos_x + targSize_x - myPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
813 myTarget_x = targPos_x + targSize_x;
814 else // push it downwards
815 myTarget_y = targPos_y + targSize_y;
823 float HUD_Panel_SetSize(float id, vector mySize)
828 oldSize = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_size")));
831 myPos = HUD_Panel_GetPos(id);
833 // check for collisions
834 if(cvar("hud_configure_checkcollisions"))
835 mySize = HUD_Panel_CheckResize(id, HUD_Panel_GetPos(id), mySize);
837 mySize_x = bound(0.025 * vid_conwidth, mySize_x, vid_conwidth - myPos_x);
838 mySize_y = bound(0.025 * vid_conheight, mySize_y, vid_conheight - myPos_y);
840 // cap against panel's own limits
841 mySize = HUD_Panel_CheckLimitSize(id, mySize);
843 //mySize_x = bound(0.025 * vid_conwidth, mySize_x, vid_conwidth);
844 //mySize_y = bound(0.025 * vid_conheight, mySize_y, vid_conheight);
846 // TODO: is this needed?
847 // this is to check if (and how) SetPos should be called
848 if(mySize_x == oldSize_x && mySize_y == oldSize_y)
849 didntresize = 3; // didnt resize either
850 else if(mySize_x == oldSize_x && mySize_y != oldSize_y)
851 didntresize = 2; // resized Y
852 else if(mySize_y == oldSize_y && mySize_x != oldSize_x)
853 didntresize = 1; // resized X
856 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
857 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_size"), s);
861 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
862 vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
874 for (i = 0; i < panel_cnt; ++i) {
875 if(i == id || !HUD_Panel_CheckActive(i))
878 targPos = HUD_Panel_GetPos(i) - '1 1 0' * HUD_Panel_GetBorder(id);
879 targSize = HUD_Panel_GetSize(i) + '2 2 0' * HUD_Panel_GetBorder(id);
881 if(myPos_y + mySize_y < targPos_y)
883 if(myPos_y > targPos_y + targSize_y)
886 if(myPos_x + mySize_x < targPos_x)
888 if(myPos_x > targPos_x + targSize_x)
891 // OK, there IS a collision.
893 myCenter_x = myPos_x + 0.5 * mySize_x;
894 myCenter_y = myPos_y + 0.5 * mySize_y;
896 targCenter_x = targPos_x + 0.5 * targSize_x;
897 targCenter_y = targPos_y + 0.5 * targSize_y;
900 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
902 if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
903 myTarget_x = targPos_x - mySize_x;
904 else // push it upwards
905 myTarget_y = targPos_y - mySize_y;
907 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
909 if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
910 myTarget_x = targPos_x + targSize_x;
911 else // push it upwards
912 myTarget_y = targPos_y - mySize_y;
914 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
916 if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
917 myTarget_x = targPos_x - mySize_x;
918 else // push it downwards
919 myTarget_y = targPos_y + targSize_y;
921 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
923 if(targPos_x + targSize_x - myPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
924 myTarget_x = targPos_x + targSize_x;
925 else // push it downwards
926 myTarget_y = targPos_y + targSize_y;
933 void HUD_Panel_SetPos(float id, vector pos, float didntresize)
936 oldPos = HUD_Panel_GetPos(id);
939 else if(didntresize == 1)
941 else if(didntresize == 3)
945 mySize = HUD_Panel_GetSize(id);
947 if(cvar("hud_configure_checkcollisions"))
948 pos = HUD_Panel_CheckMove(id, pos, mySize);
950 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
951 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
953 if (pos_x + 0.5 * mySize_x > 0.5 * vid_conwidth)
954 pos_x = pos_x - vid_conwidth;
955 if (pos_y + 0.5 * mySize_y > 0.5 * vid_conheight)
956 pos_y = pos_y - vid_conheight;
959 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
961 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
965 float prevMouseClicked; // previous state
966 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
968 prevMouseClicked = mouseClicked;
969 if(nPrimary == K_MOUSE1)
971 if(bInputType == 0) { // key pressed
975 if(bInputType == 1) {// key released
983 vector mousepos, mouseprevpos;
984 vector panel_click_distance; // mouse cursor distance from the top left corner of the panel (saved only upon a click)
985 vector panel_click_pos; // panel pos (saved only upon a click)
986 vector panel_click_size; // panel size (saved only upon a click)
987 float highlightedPanel;
988 float highlightedAction; // 0 = nothing, 1 = move, 2 = resize
989 void HUD_Panel_Mouse()
991 if(mouseClicked == 0) {
992 highlightedPanel = -1;
993 highlightedAction = 0;
996 mousepos = mousepos + getmousepos();
998 mousepos_x = bound(0, mousepos_x, vid_conwidth);
999 mousepos_y = bound(0, mousepos_y, vid_conheight);
1001 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1009 for(i = 0; i <= panel_cnt; ++i)
1011 panelPos = HUD_Panel_GetPos(i);
1012 panelSize = HUD_Panel_GetSize(i);
1013 border = HUD_Panel_GetBorder(i);
1014 if(prevMouseClicked == 0) {
1016 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1018 highlightedPanel = i;
1019 highlightedAction = 1;
1021 // resize from topleft border
1022 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)
1024 highlightedPanel = i;
1025 highlightedAction = 2;
1028 // resize from topright border
1029 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)
1031 highlightedPanel = i;
1032 highlightedAction = 2;
1035 // resize from bottomleft border
1036 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)
1038 highlightedPanel = i;
1039 highlightedAction = 2;
1042 // resize from bottomright border
1043 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)
1045 highlightedPanel = i;
1046 highlightedAction = 2;
1051 if(highlightedPanel == i)
1053 if(prevMouseClicked == 0)
1055 panel_click_distance = mousepos - panelPos;
1056 panel_click_pos = panelPos;
1057 panel_click_size = panelSize;
1060 if(highlightedAction == 1)
1061 HUD_Panel_SetPos(i, mousepos - panel_click_distance, 0);
1062 else if(highlightedAction == 2)
1064 float didntresize; // panel too big/too small, dont resize (also has to affect moving)
1065 if(resizeCorner == 1) {
1066 didntresize = HUD_Panel_SetSize(i, panelSize + mouseprevpos - mousepos);
1067 HUD_Panel_SetPos(i, mousepos - panel_click_distance, didntresize);
1069 if(resizeCorner == 2) {
1070 didntresize = HUD_Panel_SetSize(i, eY * panel_click_size_y + eX * (mousepos_x - panelPos_x - (panel_click_distance_x - panel_click_size_x))
1071 + eY * (panel_click_distance_y + (panel_click_pos_y - mousepos_y)));
1072 HUD_Panel_SetPos(i, eX * panelPos_x + eY * (mousepos_y - panel_click_distance_y), didntresize);
1074 if(resizeCorner == 3) {
1075 didntresize = HUD_Panel_SetSize(i, panelSize + eX * (mouseprevpos_x - mousepos_x) + eY * (mousepos_y - mouseprevpos_y));
1076 HUD_Panel_SetPos(i, eX * (mousepos_x - panel_click_distance_x) + eY * panelPos_y, didntresize);
1078 if(resizeCorner == 4) {
1079 HUD_Panel_SetSize(i, mousepos - panelPos - (panel_click_distance - panel_click_size));
1085 mouseprevpos = mousepos;
1086 prevMouseClicked = mouseClicked;
1089 /*void HUD_DrawDockEdge(float id, vector p1, vector p2, float target)
1095 */ // maybe one day, since this will be quite complicated
1097 // Weapon icons (#0)
1100 float weaponspace[10];
1101 void HUD_WeaponIcons_Clear()
1104 for(idx = 0; idx < 10; ++idx)
1105 weaponspace[idx] = 0;
1108 entity weaponorder[WEP_MAXCOUNT];
1110 void weaponorder_swap(float i, float j, entity pass)
1114 weaponorder[i] = weaponorder[j];
1118 float weaponorder_cmp(float i, float j, entity pass)
1121 d = mod(weaponorder[i].impulse + 9, 10) - mod(weaponorder[j].impulse + 9, 10);
1124 d = weaponorder[i].weapon - weaponorder[j].weapon;
1128 void HUD_WeaponIcons()
1131 float alpha, height, accuracybar_height, stat_weapons; // "constants"
1132 vector pos, mySize, mysize, mypos, accuracy_color;
1133 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1135 pos = HUD_Panel_GetPos(id);
1136 mySize = HUD_Panel_GetSize(id);
1137 accuracybar_height = cvar_or("hud_weaponicons_accuracy_height", 3);
1139 stat_weapons = getstati(STAT_WEAPONS);
1140 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1142 self = get_weaponinfo(i);
1143 if(self.weapons && (self.impulse >= 0) && (stat_weapons & self.weapons) || hud_configure)
1145 weaponorder[weapon_cnt] = self;
1149 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1151 HUD_Panel_DrawBg(id, pos, mySize);
1154 weapon_stats = getstati(STAT_DAMAGE_HITS);
1155 weapon_number = weapon_stats & 63;
1156 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1158 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1159 weapon_number = weapon_stats & 63;
1160 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1162 if(cvar_or("hud_weaponicons_fade", 1))
1164 fade = 3.2 - 2 * (time - weapontime);
1165 fade = bound(0.7, fade, 1);
1170 HUD_WeaponIcons_Clear();
1172 float rows, columns;
1173 rows = mySize_y/mySize_x;
1174 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1175 // ^^^ weapon icon aspect goes here
1177 columns = ceil(WEP_COUNT/rows);
1179 for(i = 0; i < weapon_cnt; ++i)
1181 self = weaponorder[i];
1182 if((self.weapons && (self.impulse >= 0) && (stat_weapons & self.weapons)) || hud_configure)
1184 weapid = self.impulse;
1186 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1188 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1189 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1191 if(self.weapon == activeweapon)
1192 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_alpha_fg, DRAWFLAG_NORMAL);
1193 drawpic(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), strcat("gfx/weapons/weapon", self.netname), eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), '1 1 1', fade * hud_alpha_fg, DRAWFLAG_NORMAL);
1195 if(cvar_or("hud_weaponicons_number", 1))
1196 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_alpha_fg, DRAWFLAG_NORMAL);
1198 // draw the weapon accuracy on the HUD
1199 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1202 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1204 accuracy_color = HUD_AccuracyColor(weapon_stats);
1206 drawpic_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows) - '2 0 0' + eY * (mySize_y/rows - accuracybar_height), "accuracy_bar.tga", eX * mySize_x*(1/columns) + eY * accuracybar_height, accuracy_color, hud_alpha_fg, DRAWFLAG_NORMAL);
1223 float GetAmmoStat(float i)
1227 case 0: return STAT_SHELLS;
1228 case 1: return STAT_NAILS;
1229 case 2: return STAT_ROCKETS;
1230 case 3: return STAT_CELLS;
1231 case 4: return STAT_FUEL;
1236 float GetAmmoItemCode(float i)
1240 case 0: return IT_SHELLS;
1241 case 1: return IT_NAILS;
1242 case 2: return IT_ROCKETS;
1243 case 3: return IT_CELLS;
1244 case 4: return IT_FUEL;
1249 string GetAmmoPicture(float i)
1253 case 0: return "ammo_shells";
1254 case 1: return "ammo_bullets";
1255 case 2: return "ammo_rocket";
1256 case 3: return "ammo_cells";
1257 case 4: return "ammo_fuel";
1262 void HUD_Inventory()
1268 vector pos, mySize, mysize, mypos;
1269 pos = HUD_Panel_GetPos(id);
1270 mySize = HUD_Panel_GetSize(id);
1272 HUD_Panel_DrawBg(id, pos, mySize);
1275 stat_items = getstati(STAT_ITEMS);
1276 for (i = 0; i < 4; ++i) {
1278 a = getstati(GetAmmoStat(i)); // how much ammo do we have of type i?
1282 if(cvar("hud_inventory_onlycurrent")) {
1283 if (stat_items & GetAmmoItemCode(i)) {
1284 drawpic_skin(pos, "ammo_current_bg", mySize, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
1285 drawpic_skin(pos + eY * 0.05 * mySize_y, GetAmmoPicture(i), '1 1 0' * 0.8 * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
1287 HUD_DrawXNum(pos + 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_alpha_fg, DRAWFLAG_NORMAL);
1289 HUD_DrawXNum(pos + 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_alpha_fg, DRAWFLAG_NORMAL);
1293 if(mySize_x/mySize_y >= 10) { // arrange horizontally
1295 case 0: mypos_x = pos_x; mypos_y = pos_y; break; // shells
1296 case 1: mypos_x = pos_x + 0.25 * mySize_x; mypos_y = pos_y; break; // bullets
1297 case 2: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y; break; // rockets
1298 case 3: mypos_x = pos_x + 0.75 * mySize_x; mypos_y = pos_y; break; // cells
1300 mysize_x = 0.25 * mySize_x;
1301 mysize_y = mySize_y;
1302 } else if(mySize_x/mySize_y >= 2.5) { // arrange in a 2x2 grid
1304 case 0: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y + 0.5 * mySize_y; break; // shells
1305 case 1: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y; break; // bullets
1306 case 2: mypos_x = pos_x; mypos_y = pos_y + 0.5 * mySize_y; break; // rockets
1307 case 3: mypos_x = pos_x; mypos_y = pos_y; break; // cells
1309 mysize_x = 0.5 * mySize_x;
1310 mysize_y = 0.5 * mySize_y;
1311 } else { // arrange vertically
1313 case 0: mypos_x = pos_x; mypos_y = pos_y; break; // shells
1314 case 1: mypos_x = pos_x; mypos_y = pos_y + 0.25 * mySize_y; break; // bullets
1315 case 2: mypos_x = pos_x; mypos_y = pos_y + 0.5 * mySize_y; break; // rockets
1316 case 3: mypos_x = pos_x; mypos_y = pos_y + 0.75 * mySize_y; break; // cells
1318 mysize_x = mySize_x;
1319 mysize_y = 0.25 * mySize_y;
1322 if (stat_items & GetAmmoItemCode(i))
1323 drawpic_skin(mypos, "ammo_current_bg", mysize, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
1324 drawpic_skin(mypos + eY * 0.05 * mysize_y, GetAmmoPicture(i), '1 1 0' * 0.8 * mysize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
1326 if(stat_items & GetAmmoItemCode(i))
1327 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_alpha_fg, DRAWFLAG_NORMAL);
1329 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_alpha_fg * 0.7, DRAWFLAG_NORMAL);
1331 if(stat_items & GetAmmoItemCode(i))
1332 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_alpha_fg, DRAWFLAG_NORMAL);
1334 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_alpha_fg * 0.7, DRAWFLAG_NORMAL);
1343 float shield_maxtime;
1344 float strength_maxtime;
1345 void HUD_Powerups() {
1348 stat_items = getstati(STAT_ITEMS);
1352 if not(stat_items & IT_STRENGTH)
1353 if not(stat_items & IT_INVINCIBLE)
1356 if (getstati(STAT_HEALTH) <= 0)
1361 pos = HUD_Panel_GetPos(id);
1362 mySize = HUD_Panel_GetSize(id);
1364 HUD_Panel_DrawBg(id, pos, mySize);
1366 float strength_time, shield_time;
1368 strength_time = bound(0, ceil(getstatf(STAT_STRENGTH_FINISHED) - time), 99);
1369 shield_time = bound(0, ceil(getstatf(STAT_INVINCIBLE_FINISHED) - time), 99);
1379 vector barpos, barsize;
1383 string leftname, rightname;
1384 float leftcnt, rightcnt;
1385 float leftalpha, rightalpha;
1386 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) {
1387 leftname = "strength";
1388 leftcnt = strength_time;
1390 rightname = "shield";
1391 rightcnt = shield_time;
1393 leftname = "shield";
1394 leftcnt = shield_time;
1396 rightname = "strength";
1397 rightcnt = strength_time;
1399 leftalpha = bound(0, leftcnt, 1);
1400 rightalpha = bound(0, rightcnt, 1);
1402 // TODO: tile statusbars?
1403 if (mySize_x/mySize_y > 4)
1407 len = strlen(ftos(leftcnt));
1409 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1410 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1411 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1412 picpos = pos + eX * 0.5 * mySize_x - eX * mySize_y;
1413 numpos = picpos - eX * 2 * 0.5 * mySize_y + eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1416 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1418 numpos = picpos + eX * mySize_y - eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1421 drawpic_skin(barpos, "statusbar", barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
1422 drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
1423 HUD_DrawXNum(numpos, leftcnt, 2, 0, 0.5 * mySize_y, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
1428 len = strlen(ftos(rightcnt));
1430 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1431 barpos = pos + eX * 0.5 * mySize_x;
1432 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1433 picpos = pos + eX * 0.5 * mySize_x;
1434 numpos = picpos + eX * mySize_y - eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1436 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1437 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1438 picpos = pos + eX * mySize_x - eX * mySize_y;
1439 numpos = picpos - eX * mySize_y + eY * 0.25 * mySize_y;
1442 drawpic_skin(barpos, "statusbar", barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
1443 drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
1444 HUD_DrawXNum(numpos, rightcnt, 2, 0, 0.5 * mySize_y, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
1447 else if (mySize_x/mySize_y > 1.5)
1451 len = strlen(ftos(leftcnt));
1453 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1454 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1455 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1456 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y;
1457 numpos = picpos - eX * len * 0.5 * mySize_y;
1460 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1462 numpos = picpos + eX * 0.5 * mySize_y;
1465 drawpic_skin(barpos, "statusbar", barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
1466 drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
1467 HUD_DrawXNum(numpos, leftcnt, len, 0, 0.5 * mySize_y, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
1472 len = strlen(ftos(rightcnt));
1474 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1475 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1476 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1477 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y + eY * 0.5 * mySize_y;
1478 numpos = picpos - eX * len * 0.5 * mySize_y;
1480 barpos = pos + eY * 0.5 * mySize_y;
1481 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1482 picpos = pos + eY * 0.5 * mySize_y;
1483 numpos = picpos + eX * 0.5 * mySize_y;
1486 drawpic_skin(barpos, "statusbar", barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
1487 drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
1488 HUD_DrawXNum(numpos, rightcnt, len, 0, 0.5 * mySize_y, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
1495 len = strlen(ftos(leftcnt));
1497 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1499 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1500 picpos = pos + eX * 0.05 * mySize_x;
1501 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x;
1503 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1504 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1505 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.65 * mySize_x;
1506 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.25 * mySize_x;
1509 drawpic_skin(barpos, "statusbar_vertical", barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
1510 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
1511 HUD_DrawXNum(numpos, leftcnt, len, 0, 0.25 * mySize_x, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
1516 len = strlen(ftos(rightcnt));
1518 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1519 barpos = pos + eX * 0.5 * mySize_x;
1520 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1521 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1522 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1524 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1525 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1526 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.65 * mySize_x + eX * 0.5 * mySize_x;
1527 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
1530 drawpic_skin(barpos, "statusbar_vertical", barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
1531 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
1532 HUD_DrawXNum(numpos, rightcnt, len, 0, 0.25 * mySize_x, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
1536 /* TODO: add expand from old code!
1538 if (strength_time) {
1539 dt = strength_time - time;
1544 drawpic_expanding_two(pos, "str", '1 1 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_ADDITIVE,
1545 bound(0, (ceil(dt) - dt) / 0.5, 1));
1549 drawpic_skin(pos, "str", '1 1 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_ADDITIVE);
1551 HUD_DrawXNum(pos - '40 -2 0', ceil(dt), 2, 0, countdown_fontsize, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
1555 drawpic_expanding(pos, "str", '1 1 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_ADDITIVE,
1556 bound(0, -dt / 0.5, 1));
1561 if (invincibility_time) {
1562 dt = invincibility_time - time;
1567 drawpic_expanding_two(pos - '0 -22 0', "invinc", '1 1 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_ADDITIVE,
1568 bound(0, (ceil(dt) - dt) / 0.5, 1));
1572 drawpic_skin(pos - '0 -22 0', "invinc", '1 1 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_ADDITIVE);
1574 HUD_DrawXNum(pos - '40 -24 0', ceil(dt), 2, 0, countdown_fontsize, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
1578 drawpic_expanding(pos - '0 -22 0', "invinc", '1 1 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_ADDITIVE,
1579 bound(0, -dt / 0.5, 1));
1585 // Health/armor (#3)
1587 void HUD_HealthArmor(void)
1591 pos = HUD_Panel_GetPos(id);
1592 mySize = HUD_Panel_GetSize(id);
1594 HUD_Panel_DrawBg(id, pos, mySize);
1596 float armor, health, x;
1597 armor = getstati(STAT_ARMOR);
1598 health = getstati(STAT_HEALTH);
1601 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
1617 if(hud_hudselector == 2) // combined health and armor display
1620 v = healtharmor_maxdamage(health, armor, armorblockpercent);
1623 num_pos = - '96 28 0';
1627 if(v_z) // fully armored
1629 // here, armorideal > armor
1630 drawpic_skin(num_pos + '78 -4.5 0', "health", '32 32 0', '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
1631 drawpic_skin(num_pos + '108 -4.5 0', "armor", '20 20 0', '1 1 1', hud_alpha_fg * armor / v_y, DRAWFLAG_NORMAL);
1635 drawpic_skin(num_pos + '108 -4.5 0', "health", '20 20 0', '1 1 1', hud_alpha_fg * v_y / armor, DRAWFLAG_NORMAL);
1636 drawpic_skin(num_pos + '78 -4.5 0', "armor", '32 32 0', '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
1638 HUD_DrawXNum_Colored(num_pos, x, 3, 24, hud_alpha_fg); // draw the combined health and armor
1644 vector barpos, barsize;
1648 string leftname, rightname;
1649 float leftcnt, rightcnt;
1650 float leftactive, rightactive;
1651 float leftalpha, rightalpha;
1653 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) { // old style layout with armor left/top of health
1658 leftalpha = min((armor+10)/55, 1);
1660 rightname = "health";
1665 leftname = "health";
1670 rightname = "armor";
1674 rightalpha = min((armor+10)/55, 1);
1677 // TODO: tile statusbars?
1678 if (mySize_x/mySize_y > 5)
1682 len = strlen(ftos(leftcnt));
1684 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1685 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
1686 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
1687 picpos = pos + eX * 0.5 * mySize_x - eX * mySize_y;
1688 numpos = picpos - eX * 3 * 0.5 * mySize_y + eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1691 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
1693 numpos = picpos + eX * mySize_y + eY * 0.25 * mySize_y;
1696 drawpic_skin(barpos, "statusbar", barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
1697 drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
1698 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, hud_alpha_fg);
1703 len = strlen(ftos(rightcnt));
1705 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1706 barpos = pos + eX * 0.5 * mySize_x;
1707 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
1708 picpos = pos + eX * 0.5 * mySize_x;
1709 numpos = picpos + eX * mySize_y - eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1711 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
1712 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
1713 picpos = pos + eX * mySize_x - eX * mySize_y;
1714 numpos = picpos - eX * 1.5 * mySize_y + eY * 0.25 * mySize_y;
1717 drawpic_skin(barpos, "statusbar", barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
1718 drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
1719 HUD_DrawXNum_Colored(numpos, rightcnt, 3, 0.5 * mySize_y, hud_alpha_fg);
1723 drawpic_skin(pos, "statusbar", eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y, HUD_Panel_GetProgressBarColor("fuel"), hud_alpha_fg * 0.8, DRAWFLAG_NORMAL);
1725 else if (mySize_x/mySize_y > 2)
1729 len = strlen(ftos(leftcnt));
1731 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1732 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
1733 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
1734 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y;
1735 numpos = picpos - eX * len * 0.5 * mySize_y;
1738 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
1740 numpos = picpos + eX * 0.5 * mySize_y;
1743 drawpic_skin(barpos, "statusbar", barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
1744 drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
1745 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, hud_alpha_fg);
1750 len = strlen(ftos(rightcnt));
1752 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1753 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
1754 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
1755 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y + eY * 0.5 * mySize_y;
1756 numpos = picpos - eX * len * 0.5 * mySize_y;
1758 barpos = pos + eY * 0.5 * mySize_y;
1759 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
1760 picpos = pos + eY * 0.5 * mySize_y;
1761 numpos = picpos + eX * 0.5 * mySize_y;
1764 drawpic_skin(barpos, "statusbar", barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
1765 drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
1766 HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.5 * mySize_y, hud_alpha_fg);
1769 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1770 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
1771 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
1774 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
1777 drawpic_skin(barpos, "statusbar", barsize, HUD_Panel_GetProgressBarColor("fuel"), hud_alpha_fg * 0.8, DRAWFLAG_NORMAL);
1783 len = strlen(ftos(leftcnt));
1785 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1787 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
1788 picpos = pos + eX * 0.05 * mySize_x;
1789 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x;
1791 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
1792 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
1793 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x;
1794 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x;
1797 drawpic_skin(barpos, "statusbar_vertical", barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
1798 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
1799 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.166 * mySize_x, hud_alpha_fg);
1804 len = strlen(ftos(rightcnt));
1806 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1807 barpos = pos + eX * 0.5 * mySize_x;
1808 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
1809 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1810 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1812 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
1813 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
1814 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x + eX * 0.5 * mySize_x;
1815 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x + eX * 0.5 * mySize_x;
1818 drawpic_skin(barpos, "statusbar_vertical", barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
1819 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
1820 HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.166 * mySize_x, hud_alpha_fg);
1823 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1825 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
1827 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
1828 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
1831 drawpic_skin(barpos, "statusbar_vertical", barsize, HUD_Panel_GetProgressBarColor("fuel"), hud_alpha_fg * 0.8, DRAWFLAG_NORMAL);
1836 // Notification area (#4)
1837 void HUD_Notify (void)
1841 pos = HUD_Panel_GetPos(id);
1842 mySize = HUD_Panel_GetSize(id);
1844 HUD_Panel_DrawBg(id, pos, mySize);
1848 if(spectatee_status && !intermission)
1850 drawfont = hud_bigfont;
1851 if(spectatee_status == -1)
1854 s = GetPlayerName(spectatee_status - 1);
1855 // spectated player name between HUD and chat area, aligned to the left
1857 pos_y = - 50 - hud_fontsize_spec_y;
1858 s = textShortenToWidth(s, vid_conwidth/2.5, hud_fontsize_spec, stringwidth_colors);
1859 drawcolorcodedstring(pos, s, hud_fontsize_spec, hud_alpha_fg, DRAWFLAG_NORMAL);
1860 drawfont = hud_font;
1862 // spectator text in the upper right corner
1863 if(spectatee_status == -1)
1864 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
1866 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
1868 if(spectatee_status == -1)
1869 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
1871 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
1873 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
1875 if(gametype == GAME_ARENA)
1876 s = "^1Wait for your turn to join";
1877 else if(gametype == GAME_LMS)
1880 sk = playerslots[player_localentnum - 1];
1881 if(sk.(scores[ps_primary]) >= 666)
1882 s = "^1Match has already begun";
1883 else if(sk.(scores[ps_primary]) > 0)
1884 s = "^1You have no more lives left";
1886 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
1889 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
1891 //show restart countdown:
1892 if (time < getstatf(STAT_GAMESTARTTIME)) {
1894 //we need to ceil, otherwise the countdown would be off by .5 when using round()
1895 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
1896 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
1899 if(warmup_stage && !intermission)
1901 s = "^2Currently in ^1warmup^2 stage!";
1904 // move more important stuff more to the middle so its more visible
1907 if(mod(time, 1) >= 0.5)
1912 if(ready_waiting && !intermission && !spectatee_status)
1914 if(ready_waiting_for_me)
1917 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
1919 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
1924 s = strcat("^2Waiting for others to ready up to end warmup...");
1926 s = strcat("^2Waiting for others to ready up...");
1929 else if(warmup_stage && !intermission && !spectatee_status)
1931 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
1934 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
1936 float ts_min, ts_max;
1937 tm = teams.sort_next;
1940 for(; tm.sort_next; tm = tm.sort_next)
1942 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
1944 if(!ts_min) ts_min = tm.team_size;
1945 else ts_min = min(ts_min, tm.team_size);
1946 if(!ts_max) ts_max = tm.team_size;
1947 else ts_max = max(ts_max, tm.team_size);
1949 if ((ts_max - ts_min) > 1)
1951 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
1952 tm = GetTeam(myteam, false);
1954 if (tm.team != COLOR_SPECTATOR)
1955 if (tm.team_size == ts_max)
1956 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
1969 pos = HUD_Panel_GetPos(id);
1970 mySize = HUD_Panel_GetSize(id);
1972 HUD_Panel_DrawBg(id, pos, mySize);
1974 float timelimit, elapsedTime, minutes, seconds, timeleft, minutesLeft, secondsLeft;
1976 timelimit = getstatf(STAT_TIMELIMIT);
1978 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
1979 timeleft = ceil(timeleft);
1980 minutesLeft = floor(timeleft / 60);
1981 secondsLeft = timeleft - minutesLeft*60;
1984 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
1985 timer_color = '1 1 1'; //white
1986 else if(minutesLeft >= 1)
1987 timer_color = '1 1 0'; //yellow
1989 timer_color = '1 0 0'; //red
1991 if (cvar("hud_timer_increment") || timelimit == 0 || warmup_stage) {
1992 if (time < getstatf(STAT_GAMESTARTTIME)) {
1993 //while restart is still active, show 00:00
1994 minutes = seconds = 0;
1996 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
1997 minutes = floor(elapsedTime / 60);
1998 seconds = elapsedTime - minutes*60;
2001 minutes = minutesLeft;
2002 seconds = secondsLeft;
2007 minutes = min(minutes, 999);
2008 if(minutesLeft >= 1 || cvar("hud_timer_increment") || timelimit == 0 || warmup_stage) {
2009 HUD_DrawXNum(pos + eX * mySize_x - eX * 5.1 * mySize_y, minutes, 3, 0, mySize_y, timer_color, 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
2010 drawpic_skin(pos + eX * mySize_x - eX * 2.57 * mySize_y, "num_colon", '1 1 0' * mySize_y, timer_color, hud_alpha_fg, DRAWFLAG_NORMAL);
2012 HUD_DrawXNum(pos + eX * mySize_x - eX * 2 * mySize_y, seconds, -2, 0, mySize_y, timer_color, 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
2017 void HUD_Radar(void)
2021 pos = HUD_Panel_GetPos(id);
2022 mySize = HUD_Panel_GetSize(id);
2024 HUD_Panel_DrawBg(id, pos, mySize);
2026 local float color1, color2; // color already declared as a global in hud.qc
2029 float scale2d, normalsize, bigsize;
2032 teamradar_origin2d = pos + 0.5 * mySize; // TODO: stupid compat, should be removed
2033 teamradar_size2d = mySize;
2035 if(minimapname == "" && !ons_showmap)
2038 teamradar_loadcvars();
2040 switch(cl_teamradar_zoommode)
2044 f = current_zoomfraction;
2047 f = 1 - current_zoomfraction;
2057 switch(cl_teamradar_rotation)
2060 teamradar_angle = view_angles_y - 90;
2063 teamradar_angle = 90 * cl_teamradar_rotation;
2067 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
2068 teamradar_size2d = mySize;
2070 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
2072 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
2073 if(cl_teamradar_rotation == 0)
2075 // max-min distance must fit the radar in any rotation
2076 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
2080 vector c0, c1, c2, c3, span;
2081 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
2082 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
2083 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
2084 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
2086 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
2087 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
2089 // max-min distance must fit the radar in x=x, y=y
2091 teamradar_size2d_x * scale2d / (1.05 * span_x),
2092 teamradar_size2d_y * scale2d / (1.05 * span_y)
2096 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / cl_teamradar_scale;
2097 if(bigsize > normalsize)
2098 normalsize = bigsize;
2102 + (1 - f) * normalsize;
2103 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
2104 f * (mi_min + mi_max) * 0.5
2105 + (1 - f) * view_origin);
2107 color1 = GetPlayerColor(player_localentnum-1);
2108 rgb = GetTeamRGB(color1);
2117 draw_teamradar_background(cl_teamradar_background_alpha, cl_teamradar_foreground_alpha);
2121 drawresetcliparea();
2123 vector frame_origin, frame_size;
2124 frame_origin = frame_size = '0 0 0';
2126 frame_origin_x = pos_x - teamradar_size2d_x * 0.55859375; // matches the picture
2127 frame_origin_y = pos_y - teamradar_size2d_y * 0.55859375; // matches the picture
2128 frame_size_x = pos_x * 1.1171875; // matches the picture
2129 frame_size_y = pos_y * 1.1171875; // matches the picture
2130 drawpic_skin(frame_origin, "gfx/ons-frame.tga", frame_size, '1 1 1', hud_alpha_fg, 0);
2131 drawpic_skin(frame_origin, "gfx/ons-frame-team.tga", frame_size, rgb, hud_alpha_fg, 0);
2134 pos_x - teamradar_size2d_x * 0.5,
2135 pos_y - teamradar_size2d_y * 0.5,
2141 for(tm = world; (tm = find(tm, classname, "radarlink")); )
2142 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
2143 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
2144 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, hud_alpha_fg);
2145 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
2147 color2 = GetPlayerColor(tm.sv_entnum);
2148 //if(color == COLOR_SPECTATOR || color == color2)
2149 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
2151 draw_teamradar_player(view_origin, view_angles, '1 1 1');
2153 drawresetcliparea();
2162 pos = HUD_Panel_GetPos(id);
2163 mySize = HUD_Panel_GetSize(id);
2165 HUD_Panel_DrawBg(id, pos, mySize);
2167 float score, distribution, leader;
2168 float score_len, distr_len;
2169 vector score_pos, secondary_score_pos, distribution_color;
2171 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
2173 if (!teamplay) { // non-teamgames
2174 // me vector := [team/connected frags id]
2175 pl = players.sort_next;
2182 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2186 score = me.(scores[ps_primary]);
2190 if(distribution >= 5) {
2191 distribution_color = eY;
2193 } else if(distribution >= 0) {
2194 distribution_color = '1 1 1';
2196 } else if(distribution >= -5)
2197 distribution_color = '1 1 0';
2199 distribution_color = eX;
2201 score_len = strlen(ftos(score));
2202 distr_len = strlen(ftos(distribution));
2204 HUD_DrawXNum(pos + eX * mySize_x - eX * 3 * 0.33 * mySize_y, distribution, 3, 3, 0.33 * mySize_y, distribution_color, 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
2206 drawpic_skin(pos + eX * mySize_x - eX * score_len * mySize_y - eX * 3 * 0.33 * mySize_y, strcat("highlight_", ftos(score_len)), eX * score_len * mySize_y + eY * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
2207 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_alpha_fg, DRAWFLAG_NORMAL);
2208 } else { // teamgames
2209 float max_fragcount;
2210 max_fragcount = -99;
2213 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2214 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !hud_configure)) // no players? don't display
2216 score = tm.(teamscores[ts_primary]);
2221 score_len = strlen(ftos(score));
2223 if (score > max_fragcount)
2224 max_fragcount = score;
2226 if(tm.team == myteam) {
2227 if (max_fragcount == score)
2230 drawpic_skin(pos + eX * mySize_x - eX * score_len * mySize_y - eX * 3 * 0.33 * mySize_y, strcat("highlight_", ftos(score_len)), eX * score_len * mySize_y + eY * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
2231 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_alpha_fg, DRAWFLAG_NORMAL);
2233 if (max_fragcount == score)
2236 drawpic_skin(pos + eX * mySize_x - eX * 0.33 * score_len * mySize_y + eY * 0.33 * mySize_y * teamnum, strcat("highlight_", ftos(score_len)), eX * 0.33 * score_len * mySize_y + eY * 0.33 * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
2237 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_alpha_fg, DRAWFLAG_NORMAL);
2246 void HUD_RaceTimer (void) {
2249 pos = HUD_Panel_GetPos(id);
2250 mySize = HUD_Panel_GetSize(id);
2252 HUD_Panel_DrawBg(id, pos, mySize);
2254 drawfont = hud_bigfont;
2256 string s, forcetime;
2261 drawstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, FALSE, '0.75 0.75 0' * mySize_y), s, '0.75 0.75 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
2262 s = "^1Intermediate 1 (+15.42)";
2263 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.25 * mySize_y) + eY * 0.75 * mySize_y, s, '1 1 0' * 0.25 * mySize_y, hud_alpha_fg, DRAWFLAG_NORMAL);
2265 else if(race_checkpointtime)
2267 a = bound(0, 2 - (time - race_checkpointtime), 1);
2270 if(a > 0) // just hit a checkpoint?
2272 if(race_checkpoint != 254)
2274 if(race_time && race_previousbesttime)
2275 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
2277 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
2279 forcetime = TIME_ENCODED_TOSTRING(race_time);
2284 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
2286 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
2287 if(a > 0) // next one?
2289 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
2294 if(s != "" && a > 0)
2296 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
2297 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2298 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.25 * mySize_y) + eY * 0.75 * mySize_y, s, '1 1 0' * 0.25 * mySize_y, hud_alpha_fg * a, DRAWFLAG_NORMAL);
2302 if(race_penaltytime)
2304 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
2307 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
2308 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
2309 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2310 drawcolorcodedstring(pos - '0 32 0' - '0.5 0 0' * stringwidth(s, TRUE, '16 16 0'), s, '16 16 0', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2316 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
2317 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', hud_alpha_fg, 0, a);
2318 drawstring_expanding(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(forcetime, FALSE, '1 1 0' * 0.75 * mySize_y), forcetime, '1 1 0' * 0.75 * mySize_y, '1 1 1', hud_alpha_fg, 0, a);
2323 if(race_laptime && race_checkpoint != 255)
2325 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
2326 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2327 drawstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, FALSE, '0.75 0.75 0' * mySize_y), s, '0.75 0.75 0' * mySize_y, '1 1 1', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2332 if(race_mycheckpointtime)
2334 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
2335 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
2336 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
2337 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2338 drawcolorcodedstring(pos - '0 16 0' - '0.5 0 0' * stringwidth(s, TRUE, '16 16 0'), s, '16 16 0', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2340 if(race_othercheckpointtime && race_othercheckpointenemy != "")
2342 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
2343 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
2344 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
2345 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2346 drawcolorcodedstring(pos - '0 0 0' - '0.5 0 0' * stringwidth(s, TRUE, '16 16 0'), s, '16 16 0', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2349 if(race_penaltytime && !race_penaltyaccumulator)
2351 t = race_penaltytime * 0.1 + race_penaltyeventtime;
2352 a = bound(0, (1 + t - time), 1);
2356 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
2358 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
2359 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
2360 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2361 drawcolorcodedstring(pos - '0 32 0' - '0.5 0 0' * stringwidth(s, TRUE, '16 16 0'), s, '16 16 0', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2366 drawfont = hud_font;
2370 float vote_yescount;
2373 float vote_highlighted; // currently selected vote
2375 float vote_active; // is there an active vote?
2376 float vote_prev; // previous state of vote_active to check for a change
2378 float vote_change; // "time" when vote_active changed
2380 void HUD_VoteWindow(void)
2384 pos = HUD_Panel_GetPos(id);
2385 mySize = HUD_Panel_GetSize(id);
2389 if(vote_active != vote_prev) {
2391 vote_prev = bound(0, vote_active, 1);
2395 vote_alpha = bound(0, (time - vote_change) * 2, 1);
2397 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
2407 HUD_Panel_DrawBg(id, pos, mySize);
2410 a = vote_alpha * bound(cvar_or("hud_vote_alreadyvoted_alpha", 0.75), 1 - vote_highlighted, 1);
2412 drawpic_skin(pos, "voteprogress_back", mySize, HUD_GetBgColor(), a * hud_alpha_bg, DRAWFLAG_NORMAL);
2414 s = "A vote has been called for: ";
2415 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_alpha_fg, DRAWFLAG_NORMAL);
2416 s = textShortenToWidth(vote_called_vote, mySize_x * 0.96, '10 0 0', stringwidth_colors);
2418 s = "Configure the HUD";
2419 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_alpha_fg, DRAWFLAG_NORMAL);
2421 // print the yes/no counts
2422 s = strcat("Yes: ", ftos(vote_yescount));
2423 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_alpha_fg, DRAWFLAG_NORMAL);
2424 s = strcat("No: ", ftos(vote_nocount));
2425 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_alpha_fg, DRAWFLAG_NORMAL);
2427 // draw the progress bars
2428 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
2429 drawpic_skin(pos, "voteprogress_prog", mySize, eY, a * hud_alpha_fg, DRAWFLAG_NORMAL);
2431 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
2432 drawpic_skin(pos, "voteprogress_prog", mySize, eX, a * hud_alpha_fg, DRAWFLAG_NORMAL);
2434 // draw the highlights
2435 if(vote_highlighted == 1) {
2436 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
2437 drawpic_skin(pos, "voteprogress_voted", mySize, eY, a * hud_alpha_fg, DRAWFLAG_NORMAL);
2439 else if(vote_highlighted == 2) {
2440 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
2441 drawpic_skin(pos, "voteprogress_voted", mySize, eX, a * hud_alpha_fg, DRAWFLAG_NORMAL);
2444 drawresetcliparea();
2446 else if(!vote_active) {
2447 vote_highlighted = 0;
2452 float race_status_time;
2453 float race_status_prev;
2454 string race_status_name_prev;
2455 void HUD_DrawRaceStatus(vector pos)
2457 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
2458 race_status_time = time + 5;
2459 race_status_prev = race_status;
2460 if (race_status_name_prev)
2461 strunzone(race_status_name_prev);
2462 race_status_name_prev = strzone(race_status_name);
2466 a = bound(0, race_status_time - time, 1);
2469 s = textShortenToWidth(race_status_name, 120, '10 10 0', stringwidth_colors);
2473 rank = race_CheckName(race_status_name);
2475 rankname = race_PlaceName(rank);
2477 if(race_status == 0)
2478 drawpic_skin(pos, "race_newfail", '80 80 0', '1 1 1', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2479 else if(race_status == 1) {
2480 drawpic_skin(pos, "race_newtime", '80 80 0', '1 1 1', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2481 drawcolorcodedstring(pos + '40 80 0' - eX * stringwidth(s, TRUE, '5 0 0'), s, '10 10 0', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2482 drawstring(pos + '40 20 0' - eX * stringwidth(rankname, TRUE, '7 0 0'), rankname, '14 14 0', '1 1 1', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2483 } else if(race_status == 2) {
2484 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
2485 drawpic_skin(pos, "race_newrankgreen", '80 80 0', '1 1 1', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2487 drawpic_skin(pos, "race_newrankyellow", '80 80 0', '1 1 1', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2488 drawcolorcodedstring(pos + '40 80 0' - eX * stringwidth(s, TRUE, '5 0 0'), s, '10 10 0', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2489 drawstring(pos + '40 20 0' - eX * stringwidth(rankname, TRUE, '7 0 0'), rankname, '14 14 0', '1 1 1', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2490 } else if(race_status == 3) {
2491 drawpic_skin(pos, "race_newrecordserver", '80 80 0', '1 1 1', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2492 drawcolorcodedstring(pos + '40 80 0' - eX * stringwidth(s, TRUE, '5 0 0'), s, '10 10 0', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2493 drawstring(pos + '40 20 0' - eX * stringwidth(rankname, TRUE, '7 0 0'), rankname, '14 14 0', '1 1 1', hud_alpha_fg * a, DRAWFLAG_NORMAL);
2496 if (race_status_time - time <= 0) {
2497 race_status_prev = -1;
2499 if(race_status_name)
2500 strunzone(race_status_name);
2501 race_status_name = string_null;
2502 if(race_status_name_prev)
2503 strunzone(race_status_name_prev);
2504 race_status_name_prev = string_null;
2508 // CTF HUD modicon section
2509 float redflag_prevframe, blueflag_prevframe; // status during previous frame
2510 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
2511 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
2513 void CSQC_ctf_hudreset(void)
2515 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
2518 void CSQC_ctf_hud(void)
2520 vector bottomleft, redflag_pos, blueflag_pos, sz;
2521 float f; // every function should have that
2522 bottomleft_y = vid_conheight;
2525 float redflag, blueflag; // current status
2526 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
2529 stat_items = getstati(STAT_ITEMS);
2530 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
2531 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
2533 // when status CHANGES, set old status into prevstatus and current status into status
2534 if (redflag != redflag_prevframe)
2536 redflag_statuschange_time = time;
2537 redflag_prevstatus = redflag_prevframe;
2538 redflag_prevframe = redflag;
2541 if (blueflag != blueflag_prevframe)
2543 blueflag_statuschange_time = time;
2544 blueflag_prevstatus = blueflag_prevframe;
2545 blueflag_prevframe = blueflag;
2548 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
2549 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
2551 float BLINK_FACTOR = 0.15;
2552 float BLINK_BASE = 0.85;
2554 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
2556 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
2558 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
2560 string red_icon, red_icon_prevstatus;
2561 float red_alpha, red_alpha_prevstatus;
2562 red_alpha = red_alpha_prevstatus = 1;
2564 case 1: red_icon = "flag_red_taken"; break;
2565 case 2: red_icon = "flag_red_lost"; break;
2566 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
2568 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
2569 red_icon = "flag_red_shielded";
2571 red_icon = string_null;
2574 switch(redflag_prevstatus) {
2575 case 1: red_icon_prevstatus = "flag_red_taken"; break;
2576 case 2: red_icon_prevstatus = "flag_red_lost"; break;
2577 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
2580 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
2581 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
2582 red_icon_prevstatus = "flag_red_shielded";
2584 red_icon_prevstatus = string_null;
2588 string blue_icon, blue_icon_prevstatus;
2589 float blue_alpha, blue_alpha_prevstatus;
2590 blue_alpha = blue_alpha_prevstatus = 1;
2592 case 1: blue_icon = "flag_blue_taken"; break;
2593 case 2: blue_icon = "flag_blue_lost"; break;
2594 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
2596 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
2597 blue_icon = "flag_blue_shielded";
2599 blue_icon = string_null;
2602 switch(blueflag_prevstatus) {
2603 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
2604 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
2605 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
2608 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
2609 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
2610 blue_icon_prevstatus = "flag_blue_shielded";
2612 blue_icon_prevstatus = string_null;
2616 if (myteam == COLOR_TEAM1) { // always draw own flag on left
2617 redflag_pos = bottomleft - '-4 50 0';
2618 blueflag_pos = bottomleft - '-62 50 0';
2620 blueflag_pos = bottomleft - '-4 50 0';
2621 redflag_pos = bottomleft - '-62 50 0';
2626 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
2627 if(red_icon_prevstatus && f < 1)
2628 drawpic_expanding(redflag_pos, red_icon_prevstatus, sz, '1 1 1', hud_alpha_fg * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
2630 drawpic_skin(redflag_pos, red_icon, sz, '1 1 1', hud_alpha_fg * red_alpha * f, DRAWFLAG_NORMAL);
2632 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
2633 if(blue_icon_prevstatus && f < 1)
2634 drawpic_expanding(blueflag_pos, blue_icon_prevstatus, sz, '1 1 1', hud_alpha_fg * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
2636 drawpic_skin(blueflag_pos, blue_icon, sz, '1 1 1', hud_alpha_fg * blue_alpha * f, DRAWFLAG_NORMAL);
2639 /*void HUD_Mod_Race (void) {
2640 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
2641 pl = players.sort_next;
2644 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
2645 if(pl.scores[ps_primary] == 0)
2648 score = me.(scores[ps_primary]);
2650 float racemin, racesec, racemsec;
2651 float distsec, distmsec, minusplus;
2653 racemin = floor(score/(60 * TIME_FACTOR));
2654 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
2655 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
2657 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
2658 // distribution display
2659 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2661 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
2662 distmsec = fabs(distribution);
2664 distsec = floor(fabs(distribution)/TIME_FACTOR);
2665 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
2666 if (distribution < 0)
2670 if (distribution <= 0) {
2671 distribution_color = eY;
2672 minusplus = 1; // minusplus 1: always prefix with minus sign
2675 distribution_color = eX;
2676 minusplus = 2; // minusplus 1: always prefix with plus sign
2678 HUD_DrawXNum(bottomright - '0 48 0' - '16 0 0' * TIME_DECIMALS, distmsec, -TIME_DECIMALS, 0, 16, distribution_color, 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
2679 HUD_DrawXNum(bottomright - '68 48 0' - '16 0 0' * TIME_DECIMALS, distsec, 4, minusplus, 16, distribution_color, 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
2680 drawpic_skin(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "num_dot", '16 16 0', distribution_color, hud_alpha_fg, DRAWFLAG_ADDITIVE);
2682 // race record display
2683 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
2684 drawpic_skin(bottomright - '0 32 0' - '32 0 0' * (4 + TIME_DECIMALS), "highlight_4", '0 28 0' + '32 0 0' * (4 + TIME_DECIMALS), '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
2686 HUD_DrawXNum(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0', racemsec, -TIME_DECIMALS, 0, 30, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
2687 HUD_DrawXNum(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '66 0 0', racesec, -2, 0, 30, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
2688 drawpic_skin(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '18 0 0', "num_dot", '30 30 0', '1 1 1', hud_alpha_fg, DRAWFLAG_ADDITIVE);
2690 HUD_DrawXNum(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '132 0 0', racemin, -2, 0, 30, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
2691 drawpic_skin(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '84 0 0', "num_colon", '30 30 0', '1 1 1', hud_alpha_fg, DRAWFLAG_ADDITIVE);
2695 // Keyhunt HUD modicon section
2696 float kh_runheretime;
2698 void CSQC_kh_hudreset(void)
2703 void CSQC_kh_hud(void)
2708 vector p, pa, kh_size, kh_asize;
2711 p_y = vid_conheight - 34 - 3;
2714 kh_keys = getstati(STAT_KH_KEYS);
2716 kh_size = '19 34 0';
2717 kh_asize = '19 10 0';
2724 for(i = 0; i < 4; ++i)
2726 key = floor(kh_keys / pow(32, i)) & 31;
2728 if(keyteam == 30 && keycount <= 4)
2730 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
2733 // this yields 8 exactly if "RUN HERE" shows
2738 kh_runheretime = time;
2739 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
2744 for(i = 0; i < 4; ++i)
2746 key = floor(kh_keys / pow(32, i)) & 31;
2759 default: // owned or dropped
2764 a = a * hud_alpha_fg;
2765 aa = aa * hud_alpha_fg;
2771 drawpic (pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
2774 drawpic (pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
2777 drawpic (pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
2780 drawpic (pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
2785 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
2788 drawpic (p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
2791 drawpic (p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
2794 drawpic (p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
2797 drawpic (p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
2806 // Nexball HUD modicon section
2807 #define NBPB_SIZE '96 38 0'
2808 #define NBPB_BT 2 //thickness
2809 #define NBPB_BRGB '1 1 1'
2810 #define NBPB_BALPH 1 //alpha
2811 #define NBPB_BFLAG DRAWFLAG_NORMAL
2812 #define NBPB_IALPH 0.4
2813 #define NBPB_IFLAG DRAWFLAG_NORMAL
2814 #define NBPB_IRGB '0.7 0.1 0'
2816 void CSQC_nb_hud(void)
2818 float stat_items, nb_pb_starttime, dt, p;
2821 stat_items = getstati(STAT_ITEMS);
2822 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
2825 pos_y = vid_conheight - 42;
2828 //Manage the progress bar if any
2829 if (nb_pb_starttime > 0)
2832 dt = mod(time - nb_pb_starttime, nb_pb_period);
2833 // one period of positive triangle
2834 p = 2 * dt / nb_pb_period;
2840 drawfill(pos, p * s_x * eX + s_y * eY, NBPB_IRGB, NBPB_IALPH, NBPB_IFLAG);
2844 drawline(NBPB_BT, pos , pos + eX * s_x, NBPB_BRGB, NBPB_BALPH, NBPB_BFLAG);
2845 drawline(NBPB_BT, pos , pos + eY * s_y, NBPB_BRGB, NBPB_BALPH, NBPB_BFLAG);
2846 drawline(NBPB_BT, pos + s, pos + eX * s_x, NBPB_BRGB, NBPB_BALPH, NBPB_BFLAG);
2847 drawline(NBPB_BT, pos + s, pos + eY * s_y, NBPB_BRGB, NBPB_BALPH, NBPB_BFLAG);
2850 pos_x += 12; //horizontal margin to the picture
2851 pos_y += 2; //vertical margin to the picture
2853 if (stat_items & IT_KEY1)
2854 drawpic_skin(pos, "nexball_carrying", '80 34 0', '1 1 1', 1, DRAWFLAG_NORMAL);
2857 // Race/CTS HUD modicon section
2858 float crecordtime_prev; // last remembered crecordtime
2859 float crecordtime_change_time; // time when crecordtime last changed
2860 float srecordtime_prev; // last remembered srecordtime
2861 float srecordtime_change_time; // time when srecordtime last changed
2862 void CSQC_race_hud(void)
2865 me = playerslots[player_localentnum - 1];
2867 float f; // yet another function has this
2868 score = me.(scores[ps_primary]);
2870 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
2871 return; // no records in the actual race
2873 drawfont = hud_bigfont;
2876 pos_y = vid_conheight - 48;
2878 // clientside personal record
2880 if(gametype == GAME_CTS)
2884 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
2886 if(score && (score < t || !t)) {
2887 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
2888 if(cvar("cl_autodemo_delete_keeprecords"))
2890 f = cvar("cl_autodemo_delete");
2892 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
2896 if(t != crecordtime_prev) {
2897 crecordtime_prev = t;
2898 crecordtime_change_time = time;
2900 f = time - crecordtime_change_time;
2903 drawstring(pos, "Personal best ", '10 10 0', '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
2904 drawstring(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
2906 drawstring(pos, "Personal best ", '10 10 0', '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
2907 drawstring(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
2908 drawstring_expanding(pos, "Personal best ", '10 10 0', '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL, f);
2909 drawstring_expanding(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL, f);
2914 t = race_server_record;
2915 if(t != srecordtime_prev) {
2916 srecordtime_prev = t;
2917 srecordtime_change_time = time;
2919 f = time - srecordtime_change_time;
2922 drawstring(pos, "Server best ", '10 10 0', '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
2923 drawstring(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
2925 drawstring(pos, "Server best ", '10 10 0', '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
2926 drawstring(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
2927 drawstring_expanding(pos, "Server best ", '10 10 0', '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL, f);
2928 drawstring_expanding(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL, f);
2930 drawfont = hud_font;
2939 void HUD_DrawPressedKeys(void)
2943 pos = HUD_Panel_GetPos(id);
2944 mySize = HUD_Panel_GetSize(id);
2946 HUD_Panel_DrawBg(id, pos, mySize);
2950 pressedkeys = getstatf(STAT_PRESSED_KEYS);
2951 drawpic_skin(pos, "key_bg.tga", mySize, '1 1 1', 0.1 * hud_alpha_fg, DRAWFLAG_NORMAL);
2952 drawpic_skin(pos + eX * mySize_x - eX * 0.22 * mySize_x + eY * 0.195 * mySize_y, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), '1 1 0' * (1/3) * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
2953 drawpic_skin(pos + eX * 0.5 * mySize_x - eX * 0.23 * mySize_y + eY * 0.040 * mySize_y, ((pressedkeys & KEY_FORWARD) ? "key_forward_inv.tga" : "key_forward.tga"), '1 1 0' * 0.46 * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
2954 drawpic_skin(pos + eX * 0.023 * mySize_x + eY * 0.195 * mySize_y, ((pressedkeys & KEY_JUMP) ? "key_jump_inv.tga" : "key_jump.tga"), '1 1 0' * (1/3) * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
2955 drawpic_skin(pos + eX * 0.1 * mySize_x + eY * 0.486 * mySize_y, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), '1 1 0' * 0.46 * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
2956 drawpic_skin(pos + eX * 0.5 * mySize_x - eX * 0.23 * mySize_y + eY * 0.486 * mySize_y, ((pressedkeys & KEY_BACKWARD) ? "key_backward_inv.tga" : "key_backward.tga"), '1 1 0' * 0.46 * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
2957 drawpic_skin(pos + eX * mySize_x - eX * 0.372 * mySize_x + eY * 0.486 * mySize_y, ((pressedkeys & KEY_RIGHT) ? "key_right_inv.tga" : "key_right.tga"), '1 1 0' * 0.46 * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
2960 void HUD_ShowSpeed(void)
2963 float pos, conversion_factor;
2964 string speed, zspeed, unit;
2966 switch(cvar("cl_showspeed_unit"))
2971 conversion_factor = 1.0;
2975 conversion_factor = 1.0;
2979 conversion_factor = 0.0254;
2983 conversion_factor = 0.0254 * 3.6;
2987 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
2991 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
2995 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
2997 numsize_x = numsize_y = cvar("cl_showspeed_size");
2998 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
3000 drawfont = hud_bigfont;
3001 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
3003 if (cvar("cl_showspeed_z") == 1) {
3004 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
3005 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
3008 drawfont = hud_font;
3011 vector acc_prevspeed;
3015 void HUD_ShowAcceleration(void)
3017 float acceleration, sz, scale, alpha, f;
3018 vector pos, top, rgb;
3019 top_x = vid_conwidth/2;
3022 f = time - acc_prevtime;
3023 if(cvar("cl_showacceleration_z"))
3024 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
3026 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
3027 acc_prevspeed = pmove_vel;
3028 acc_prevtime = time;
3030 f = bound(0, f * 10, 1);
3031 acc_avg = acc_avg * (1 - f) + acceleration * f;
3032 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
3034 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
3036 sz = cvar("cl_showacceleration_size");
3037 scale = cvar("cl_showacceleration_scale");
3038 alpha = cvar("cl_showacceleration_alpha");
3039 if (cvar("cl_showacceleration_color_custom"))
3040 rgb = stov(cvar_string("cl_showacceleration_color"));
3043 if (acceleration < 0) {
3044 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
3045 } else if (acceleration > 0) {
3046 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
3050 if (acceleration > 0)
3051 drawpic_skin(pos, "statusbar", acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_alpha_fg, DRAWFLAG_NORMAL);
3052 else if (acceleration < 0)
3053 drawpic_skin(pos + acceleration * scale * '40 0 0', "statusbar", -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_alpha_fg, DRAWFLAG_NORMAL);
3056 void HUD_Reset (void)
3058 // reset gametype specific icons
3059 if(gametype == GAME_KEYHUNT)
3061 else if(gametype == GAME_CTF)
3062 CSQC_ctf_hudreset();
3065 void HUD_Main (void)
3067 hud_alpha_bg = cvar_or("hud_bg_alpha", 0.8) * (1 - cvar("_menu_alpha"));
3068 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
3069 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
3070 hud_color_bg_team = cvar("hud_color_bg_team");
3072 hud_fontsize = HUD_GetFontsize("hud_fontsize");
3073 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
3075 hud_configure = cvar("_hud_configure");
3078 if(cvar("hud_dock"))
3079 drawpic_skin('0 0 0', "dock", eX * vid_conwidth + eY * vid_conheight, stov(cvar_string("hud_dock_color")), cvar("hud_dock_alpha"), DRAWFLAG_NORMAL);
3081 if(HUD_Panel_CheckActive(0))
3083 if(HUD_Panel_CheckActive(1))
3085 if(HUD_Panel_CheckActive(2))
3087 if(HUD_Panel_CheckActive(3))
3089 if(HUD_Panel_CheckActive(4))
3091 if(HUD_Panel_CheckActive(5))
3094 if(HUD_Panel_CheckActive(6))
3095 if(ons_showmap || cvar_string("cl_teamradar") != "0" && (cvar("cl_teamradar") == 2 || teamplay))
3097 if(HUD_Panel_CheckActive(7))
3099 if(HUD_Panel_CheckActive(8))
3100 if(gametype == GAME_RACE || gametype == GAME_CTS || hud_configure)
3102 if(HUD_Panel_CheckActive(9))
3105 if(HUD_Panel_CheckActive(10))
3106 if(spectatee_status > 0 || cvar("cl_showpressedkeys") >= 2 || hud_configure)
3107 HUD_DrawPressedKeys();
3109 // TODO hud_'ify these
3110 if (cvar("cl_showspeed"))
3112 if (cvar("cl_showacceleration"))
3113 HUD_ShowAcceleration();
3115 // TODO... well make them work in a panel etc
3116 if(gametype == GAME_KEYHUNT)
3118 else if(gametype == GAME_CTF)
3120 else if(gametype == GAME_NEXBALL)
3122 else if(gametype == GAME_CTS || gametype == GAME_RACE)