7 // a border picture is a texture containing nine parts:
8 // 1/4 width: left part
9 // 1/2 width: middle part (stretched)
10 // 1/4 width: right part
12 // 1/4 height: top part
13 // 1/2 height: middle part (stretched)
14 // 1/4 height: bottom part
15 void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize)
20 //pic = draw_UseSkinFor(pic);
21 width = eX * theSize_x;
22 height = eY * theSize_y;
23 if(theSize_x <= theBorderSize_x * 2)
25 // not wide enough... draw just left and right then
26 bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
27 if(theSize_y <= theBorderSize_y * 2)
29 // not high enough... draw just corners
30 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
31 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
32 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
33 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
34 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
38 dY = theBorderSize_x * eY;
39 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
40 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
41 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
42 drawsubpic(theOrigin + width * 0.5 + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0' + eX - bW, '0 0.5 0' + bW, theColor, theAlpha, 0);
43 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
44 drawsubpic(theOrigin + width * 0.5 + height - dY, width * 0.5 + dY, pic, '0 0.75 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
49 if(theSize_y <= theBorderSize_y * 2)
51 // not high enough... draw just top and bottom then
52 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
53 dX = theBorderSize_x * eX;
54 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
55 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
56 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
57 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
58 drawsubpic(theOrigin + dX + height * 0.5, width - 2 * dX + height * 0.5, pic, '0.25 0 0' + eY - bH, '0.5 0 0' + bH, theColor, theAlpha, 0);
59 drawsubpic(theOrigin + width - dX + height * 0.5, dX + height * 0.5, pic, '0.75 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
63 dX = theBorderSize_x * eX;
64 dY = theBorderSize_x * eY;
65 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
66 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
67 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
68 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
69 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
70 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
71 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
72 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
73 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
78 // drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
79 void drawpic_aspect(vector pos, string pic, vector sz, vector color, float alpha, float drawflag) {
81 imgsize = drawgetimagesize(pic);
83 imgaspect = imgsize_x/imgsize_y;
90 if(aspect > imgaspect) {
91 sz_x = sz_y * imgaspect;
92 drawpic(pos + eX * (oldsz_x - sz_x) * 0.5, pic, sz, color, alpha, drawflag);
94 sz_y = sz_x / imgaspect;
95 drawpic(pos + eY * (oldsz_y - sz_y) * 0.5, pic, sz, color, alpha, drawflag);
99 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
100 void drawpic_skin(vector pos, string pic, vector sz, vector color, float alpha, float drawflag) {
101 drawpic_aspect(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, color, alpha, drawflag);
105 void drawpic_skin_expanding(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
106 drawpic_expanding(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
109 void drawpic_skin_expanding_two(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
110 drawpic_expanding_two(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
113 // return HUD background color
114 vector HUD_GetBgColor()
118 GetTeamRGB(myteam) * hud_color_bg_team;
120 // allow custom HUD colors in non-teamgames
121 color_x = cvar("hud_color_bg_r");
122 color_y = cvar("hud_color_bg_g");
123 color_z = cvar("hud_color_bg_b");
128 // return accuracy text color
129 vector HUD_AccuracyColor(float accuracy)
132 float yellow_accuracy = cvar("hud_weaponicons_accuracy_yellow"); // value at which this function returns yellow
133 if(accuracy >= 100) {
137 else if(accuracy > yellow_accuracy) {
138 rgb_x = 1 - (accuracy-yellow_accuracy)/(100-yellow_accuracy); // red value between 1 -> 0
143 rgb_y = accuracy/yellow_accuracy; // green value between 0 -> 1
149 // draw number in the XSCALE font
150 void HUD_DrawXNum (vector pos, float num, float digits, float showsign, float lettersize, vector rgb, float highlighted, float stroke, float alpha, float dflags)
153 string str, tmp, l_length;
155 vector vsize, num_color;
157 vsize_x = vsize_y = lettersize;
160 // showsign 1: always prefix with minus sign (useful in race distribution display)
161 // showsign 2: always prefix with plus sign (useful in race distribution display)
162 // showsign 3: prefix with minus sign if negative, plus sign if positive (useful in score distribution display)
164 if((showsign == 2 && num >= 0) || (num > 0 && showsign == 3))
171 if(num < 0 || (num < 0 && showsign == 3) || (showsign == 1 && num <= 0))
183 str = strcat(substring("0000000000", 0, digits - strlen(tmp)), tmp);
192 str = substring(str, l-digits, 999);
194 } else if(l < digits)
195 pos_x += (digits-l) * lettersize;
197 if (highlighted == 1) {
199 hl_size_x = vsize_x * l + vsize_x * 0.2;
200 hl_size_y = vsize_y * 1.1;
203 hl_size_x = hl_size_x + vsize_x;
206 hl_pos_x = pos_x - lettersize/10;
207 hl_pos_y = pos_y - lettersize/20;
210 drawpic_skin(hl_pos, strcat("num_leading_", l_length), hl_size, '1 1 1', alpha, dflags);
221 drawpic_skin(pos, "num_minus_stroke", vsize, rgb, alpha, dflags);
222 drawpic_skin(pos, "num_minus", vsize, num_color, alpha, dflags);
227 drawpic_skin(pos, "num_plus_stroke", vsize, rgb, alpha, dflags);
228 drawpic_skin(pos, "num_plus", vsize, num_color, alpha, dflags);
232 for(i = 0; i < l; ++i)
234 tmp = substring(str, i, 1);
236 drawpic_skin(pos, strcat("num_", tmp, "_stroke"), vsize, rgb, alpha, dflags);
237 drawpic_skin(pos, strcat("num_", tmp), vsize, num_color, alpha, dflags);
242 vector HUD_Get_Num_Color (float x, float maxvalue)
250 else if(x > maxvalue * 0.75) {
251 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
252 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
255 else if(x > maxvalue * 0.5) {
256 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
257 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
258 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
260 else if(x > maxvalue * 0.25) {
263 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
265 else if(x > maxvalue * 0.1) {
267 color_y = (x-20)*90/27/100; // green value between 0 -> 1
268 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
277 // color the number differently based on how big it is (used in the health/armor panel)
278 void HUD_DrawXNum_Colored (vector pos, float x, float digits, float lettersize, float alpha)
281 color = HUD_Get_Num_Color (x, 200);
282 HUD_DrawXNum(pos, x, digits, 0, lettersize, color, 0, 0, alpha, DRAWFLAG_NORMAL);
285 float stringwidth_colors(string s, vector theSize)
287 return stringwidth(s, TRUE, theSize);
290 float stringwidth_nocolors(string s, vector theSize)
292 return stringwidth(s, FALSE, theSize);
295 #define CENTERPRINT_MAX_LINES 30
296 string centerprint_messages[CENTERPRINT_MAX_LINES];
297 float centerprint_width[CENTERPRINT_MAX_LINES];
298 vector centerprint_start;
299 float centerprint_expire;
300 float centerprint_num;
301 float centerprint_offset_hint;
302 vector centerprint_fontsize;
304 void centerprint(string strMessage)
306 float i, j, n, hcount;
309 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
311 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
313 if(cvar("scr_centertime") <= 0)
319 // strip trailing newlines
320 j = strlen(strMessage) - 1;
321 while(substring(strMessage, j, 1) == "\n" && j >= 0)
323 strMessage = substring(strMessage, 0, j + 1);
328 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
330 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
332 strMessage = substring(strMessage, j, strlen(strMessage) - j);
333 centerprint_offset_hint = j;
338 // if we get here, we have a message. Initialize its height.
341 n = tokenizebyseparator(strMessage, "\n");
343 for(j = 0; j < n; ++j)
345 getWrappedLine_remaining = argv(j);
346 while(getWrappedLine_remaining)
348 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
349 if(centerprint_messages[i])
350 strunzone(centerprint_messages[i]);
351 centerprint_messages[i] = strzone(s);
352 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
355 // half height for empty lines looks better
361 if(i >= CENTERPRINT_MAX_LINES)
367 h = centerprint_fontsize_y*hcount;
369 havail = vid_conheight;
370 if(cvar("con_chatpos") < 0)
371 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
372 if(havail > vid_conheight - 70)
373 havail = vid_conheight - 70; // avoid overlapping HUD
375 centerprint_start_x = 0;
378 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
380 // here, the centerprint would cover the crosshair. REALLY BAD.
381 forbiddenmin = vid_conheight * 0.5 - h - 16;
382 forbiddenmax = vid_conheight * 0.5 + 16;
384 allowedmin = scoreboard_bottom;
385 allowedmax = havail - h;
386 preferred = (havail - h)/2;
389 // possible orderings (total: 4! / 4 = 6)
390 // allowedmin allowedmax forbiddenmin forbiddenmax
391 // forbiddenmin forbiddenmax allowedmin allowedmax
392 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
394 // forbidden doesn't matter in this case
395 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
397 // allowedmin forbiddenmin allowedmax forbiddenmax
398 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
400 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
402 // allowedmin forbiddenmin forbiddenmax allowedmax
403 else if(allowedmin < forbiddenmin)
405 // make sure the forbidden zone is not covered
406 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
407 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
409 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
411 // forbiddenmin allowedmin allowedmax forbiddenmax
412 else if(allowedmax < forbiddenmax)
414 // it's better to leave the allowed zone (overlap with scoreboard) than
415 // to cover the forbidden zone (crosshair)
416 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
417 centerprint_start_y = forbiddenmax;
419 centerprint_start_y = forbiddenmin;
421 // forbiddenmin allowedmin forbiddenmax allowedmax
424 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
427 centerprint_start_y =
430 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
438 centerprint_expire = time + cvar("scr_centertime");
441 void HUD_DrawCenterPrint (void)
448 //if(time > centerprint_expire)
451 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
452 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
453 //sz = 1.2 / (a + 0.2);
458 pos = centerprint_start;
459 for (i=0; i<centerprint_num; i = i + 1)
461 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
462 ts = centerprint_messages[i];
465 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
466 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
467 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
468 pos_y = pos_y + centerprint_fontsize_y;
471 // half height for empty lines looks better
472 pos_y = pos_y + centerprint_fontsize_y * 0.5;
476 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
478 position_x -= 2 / 3 * strlen(text) * scale_x;
479 drawstring(position, text, scale, rgb, alpha, flag);
482 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
484 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
485 drawstring(position, text, scale, rgb, alpha, flag);
488 // return the string of the given race place
489 string race_PlaceName(float pos) {
497 return strcat(ftos(pos), "th");
500 // return the string of the onscreen race timer
501 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
509 if(histime == 0) // goal hit
513 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
523 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
529 lapstr = strcat(" (-", ftos(lapdelta), "L)");
532 else if(lapdelta < 0)
534 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
538 else if(histime > 0) // anticipation
540 if(mytime >= histime)
541 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
543 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
550 cpname = "Start line";
552 cpname = "Finish line";
554 cpname = strcat("Intermediate ", ftos(cp));
556 cpname = "Finish line";
559 return strcat(col, cpname);
560 else if(hisname == "")
561 return strcat(col, cpname, " (", timestr, ")");
563 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
566 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
567 float race_CheckName(string net_name) {
569 for (i=RANKINGS_CNT-1;i>=0;--i)
570 if(grecordholder[i] == net_name)
582 void HUD_Panel_ExportCfg(string cfgname)
585 fh = fopen(strcat("hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg"), FILE_WRITE);
588 fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
589 fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
590 fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
591 fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
592 fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
593 fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
594 fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
595 fputs(fh, strcat("seta hud_fg_alpha \"", cvar_string("hud_fg_alpha"), "\"", "\n"));
598 fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
599 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
600 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
601 fputs(fh, strcat("seta hud_dock_alpha \"", ftos(cvar("hud_dock_alpha")), "\"", "\n"));
604 fputs(fh, strcat("seta hud_progressbar_alpha ", ftos(cvar("hud_progressbar_alpha")), "\n"));
605 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
606 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
607 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
608 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
609 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
610 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
613 // common cvars for all panels
615 for (i = 0; i < HUD_PANEL_NUM; ++i)
617 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), " ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i)))), "\n"));
618 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_pos \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_pos")), "\"", "\n"));
619 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_size \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_size")), "\"", "\n"));
620 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg")), "\"", "\n"));
621 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color")), "\"", "\n"));
622 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color_team \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color_team")), "\"", "\n"));
623 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_alpha \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_alpha")), "\"", "\n"));
624 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_border \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_border")), "\"", "\n"));
625 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_padding \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_padding")), "\"", "\n"));
628 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_accuracy_yellow ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_accuracy_yellow"))), "\n"));
631 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_onlycurrent ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_onlycurrent"))), "\n"));
634 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
635 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_mirror ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
638 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
639 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_mirror ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
642 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
643 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_info_top ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_info_top"))), "\n"));
646 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_foreground_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_foreground_alpha"))), "\n"));
648 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha"))), "\n"));
654 print("^2Successfully exported to hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
659 // return active status of panel
660 float HUD_Panel_CheckActive(float id)
662 if (cvar_or(strcat("hud_", HUD_Panel_GetName(id)), 1))
667 // return size of given panel
668 vector HUD_Panel_GetSize(float id)
671 mySize = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_size")));
673 mySize = eX * mySize_x * vid_conwidth + eY * mySize_y * vid_conheight;
675 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
677 vector menu_enable_maxsize, menu_enable_size;
678 menu_enable_maxsize = '0 0 0'; // shut up FTEQCC
679 menu_enable_maxsize_x = 0.3 * vid_conwidth;
680 menu_enable_maxsize_y = 0.18 * vid_conheight;
681 if(mySize_x > mySize_y)
683 if(mySize_y > menu_enable_maxsize_y)
685 menu_enable_size_y = menu_enable_maxsize_y;
686 menu_enable_size_x = mySize_x * (menu_enable_maxsize_y/mySize_y);
687 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
692 if(mySize_x > menu_enable_maxsize_x)
694 menu_enable_size_x = menu_enable_maxsize_x;
695 menu_enable_size_y = mySize_y * (menu_enable_maxsize_x/mySize_x);
696 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
703 // return pos of given panel
704 vector HUD_Panel_GetPos(float id)
707 pos = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_pos")));
709 pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
711 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
713 vector mySize, menu_enable_panelpos;
714 mySize = HUD_Panel_GetSize(id);
715 if(mySize_x > mySize_y)
716 menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * mySize_x + eY * 0.82 * vid_conheight;
718 menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * mySize_y + eX * 0.7 * vid_conwidth;
719 pos = (1 - cvar("_menu_alpha")) * pos + (cvar("_menu_alpha")) * menu_enable_panelpos;
724 float HUD_Panel_GetBorder(float id)
727 border = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_border"));
729 border = cvar_string("hud_bg_border");
733 vector HUD_Panel_GetColor(float id)
739 // fetch per-panel color
740 if(teamplay && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")) != "") {
741 f = stof(getplayerkey(self.sv_entnum, "colors"));
742 color = vtos(colormapPaletteColor(mod(f, 16), 1) * cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")));
745 color = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color"));
746 color_vec = stov(color);
748 if(color == "") { // fetch default color
749 color = cvar_string("hud_bg_color");
750 color_vec = stov(color);
751 if(teamplay && cvar(strcat("hud_bg_color_team"))) {
752 f = stof(getplayerkey(self.sv_entnum, "colors"));
753 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_bg_color_team");
755 else if(color == "shirt") {
756 f = stof(getplayerkey(self.sv_entnum, "colors"));
757 color_vec = colormapPaletteColor(floor(f / 16), 0);
759 else if(color == "pants") {
760 f = stof(getplayerkey(self.sv_entnum, "colors"));
761 color_vec = colormapPaletteColor(mod(f, 16), 1);
764 else if(color == "shirt") {
765 f = stof(getplayerkey(self.sv_entnum, "colors"));
766 color_vec = colormapPaletteColor(floor(f / 16), 0);
768 else if(color == "pants") {
769 f = stof(getplayerkey(self.sv_entnum, "colors"));
770 color_vec = colormapPaletteColor(mod(f, 16), 1);
775 vector HUD_Panel_Dock_GetColor(void)
780 color = cvar_string("hud_dock_color");
781 color_vec = stov(color);
782 if(teamplay && cvar(strcat("hud_dock_color_team"))) {
783 f = stof(getplayerkey(self.sv_entnum, "colors"));
784 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_dock_color_team");
786 else if(color == "shirt") {
787 f = stof(getplayerkey(self.sv_entnum, "colors"));
788 color_vec = colormapPaletteColor(floor(f / 16), 0);
790 else if(color == "pants") {
791 f = stof(getplayerkey(self.sv_entnum, "colors"));
792 color_vec = colormapPaletteColor(mod(f, 16), 1);
797 float HUD_Panel_GetBgAlpha(float id)
800 alpha = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_alpha"));
802 alpha = cvar_string("hud_bg_alpha");
804 if(hud_configure && disable_menu_alphacheck == 2 && highlightedPanel == id) // do not set a minalpha cap when showing the config dialog for this panel
805 alpha = ftos((1 - cvar("_menu_alpha")) * max(cvar("hud_configure_bg_minalpha"), stof(alpha)) + (cvar("_menu_alpha")) * stof(alpha));
806 else if(hud_configure)
807 alpha = ftos(max(cvar("hud_configure_bg_minalpha"), stof(alpha)));
809 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
812 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
815 return stof(alpha) * menu_fade_alpha;
818 float HUD_Panel_GetFgAlpha(float id)
821 alpha = hud_fg_alpha;
823 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
826 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
829 return alpha * menu_fade_alpha;
832 float HUD_Panel_GetPadding(float id)
835 padding = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
837 padding = cvar_string("hud_bg_padding");
840 mySize = HUD_Panel_GetSize(id);
842 smallestsize = min(mySize_x, mySize_y);
843 return min(smallestsize/2 - 5, stof(padding));
846 // draw the background/borders
847 void HUD_Panel_DrawBg(float id, vector pos, vector mySize, float alpha)
849 if(!hud_configure && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg")) == "0")
853 bg = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg"));
855 bg = cvar_string("hud_bg");
857 if(bg == "0" && hud_configure) {
858 bg = "border"; // we probably want to see a background in config mode at all times...
864 border = max(0.0000001, HUD_Panel_GetBorder(id)); // draw_BorderPicture does not like border = 0
867 color = HUD_Panel_GetColor(id);
870 alpha = HUD_Panel_GetBgAlpha(id) * alpha; // allow panels to fade in/out by passing an alpha value
872 alpha = HUD_Panel_GetBgAlpha(id);
874 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));
878 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
880 //float drawsubpic(vector position, vector size, string pic, vector srcPosition, vector srcSize, vector rgb, float alpha, float flag) = #328;
882 pic = strcat("gfx/hud/", cvar_string("hud_skin"), "/");
884 drawsubpic(pos, eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, strcat(pic, "statusbar_vertical"), '0 0 0', '1 0.25 0', color, alpha, drawflag);
885 if(mySize_y/mySize_x > 2)
886 drawsubpic(pos + eY * mySize_x, eY * (mySize_y - 2 * mySize_x) + eX * mySize_x, strcat(pic, "statusbar_vertical"), '0 0.25 0', '1 0.5 0', color, alpha, drawflag);
887 drawsubpic(pos + eY * mySize_y - eY * min(mySize_y * 0.5, mySize_x), eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, strcat(pic, "statusbar_vertical"), '0 0.75 0', '1 0.25 0', color, alpha, drawflag);
889 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, strcat(pic, "statusbar"), '0 0 0', '0.25 1 0', color, alpha, drawflag);
890 if(mySize_x/mySize_y > 2)
891 drawsubpic(pos + eX * mySize_y, eX * (mySize_x - 2 * mySize_y) + eY * mySize_y, strcat(pic, "statusbar"), '0.25 0 0', '0.5 1 0', color, alpha, drawflag);
892 drawsubpic(pos + eX * mySize_x - eX * min(mySize_x * 0.5, mySize_y), eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, strcat(pic, "statusbar"), '0.75 0 0', '0.25 1 0', color, alpha, drawflag);
896 vector HUD_Panel_GetProgressBarColor(string item)
898 return stov(cvar_string(strcat("hud_progressbar_", item, "_color")));
901 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
902 vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
913 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
914 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
916 for (i = 0; i < HUD_PANEL_NUM; ++i) {
917 if(i == id || !HUD_Panel_CheckActive(i))
920 targPos = HUD_Panel_GetPos(i) - '1 1 0' * HUD_Panel_GetBorder(id);
921 targSize = HUD_Panel_GetSize(i) + '2 2 0' * HUD_Panel_GetBorder(id);
923 if(myPos_y + mySize_y < targPos_y)
925 if(myPos_y > targPos_y + targSize_y)
928 if(myPos_x + mySize_x < targPos_x)
930 if(myPos_x > targPos_x + targSize_x)
933 // OK, there IS a collision.
935 myCenter_x = myPos_x + 0.5 * mySize_x;
936 myCenter_y = myPos_y + 0.5 * mySize_y;
938 targCenter_x = targPos_x + 0.5 * targSize_x;
939 targCenter_y = targPos_y + 0.5 * targSize_y;
941 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
943 if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
944 myTarget_x = targPos_x - mySize_x;
945 else // push it upwards
946 myTarget_y = targPos_y - mySize_y;
948 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
950 if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
951 myTarget_x = targPos_x + targSize_x;
952 else // push it upwards
953 myTarget_y = targPos_y - mySize_y;
955 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
957 if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
958 myTarget_x = targPos_x - mySize_x;
959 else // push it downwards
960 myTarget_y = targPos_y + targSize_y;
962 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
964 if(targPos_x + targSize_x - myPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
965 myTarget_x = targPos_x + targSize_x;
966 else // push it downwards
967 myTarget_y = targPos_y + targSize_y;
974 void HUD_Panel_SetPos(float id, vector pos)
977 oldPos = HUD_Panel_GetPos(id);
980 mySize = HUD_Panel_GetSize(id);
982 if(hud_configure_checkcollisions)
983 pos = HUD_Panel_CheckMove(id, pos, mySize);
985 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
986 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
988 if(cvar("hud_configure_grid"))
990 pos_x = floor((pos_x/vid_conwidth)/bound(0.005, cvar("hud_configure_grid_x"), 0.2) + 0.5) * bound(0.005, cvar("hud_configure_grid_x"), 0.2) * vid_conwidth;
991 pos_y = floor((pos_y/vid_conheight)/bound(0.005, cvar("hud_configure_grid_y"), 0.2) + 0.5) * bound(0.005, cvar("hud_configure_grid_y"), 0.2) * vid_conheight;
995 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
997 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
1000 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
1001 vector HUD_Panel_CheckResize(float id, vector mySize, vector resizeorigin) {
1011 ratio = mySize_x/mySize_y;
1013 for (i = 0; i < HUD_PANEL_NUM; ++i) {
1014 if(i == id || !HUD_Panel_CheckActive(i))
1017 targBorder = HUD_Panel_GetBorder(i);
1018 targPos = HUD_Panel_GetPos(i) - '1 1 0' * targBorder;
1019 targSize = HUD_Panel_GetSize(i) + '2 2 0' * targBorder;
1020 targEndPos = targPos + targSize;
1022 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
1023 if(resizeorigin_x > targPos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > targPos_y && resizeorigin_y < targEndPos_y)
1026 if (resizeCorner == 1)
1028 // check if this panel is on our way
1029 if (resizeorigin_x <= targPos_x)
1031 if (resizeorigin_y <= targPos_y)
1033 if (targEndPos_x <= resizeorigin_x - mySize_x)
1035 if (targEndPos_y <= resizeorigin_y - mySize_y)
1038 // there is a collision:
1039 // detect which side of the panel we are facing is actually limiting the resizing
1040 // (which side the resize direction finds for first) and reduce the size up to there
1042 // dist is the distance between resizeorigin and the "analogous" point of the panel
1043 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
1044 dist_x = resizeorigin_x - targEndPos_x;
1045 dist_y = resizeorigin_y - targEndPos_y;
1046 if (dist_y < 0 || dist_x / dist_y > ratio)
1047 mySize_x = min(mySize_x, dist_x);
1049 mySize_y = min(mySize_y, dist_y);
1051 else if (resizeCorner == 2)
1053 if (resizeorigin_x >= targEndPos_x)
1055 if (resizeorigin_y <= targPos_y)
1057 if (targPos_x >= resizeorigin_x + mySize_x)
1059 if (targEndPos_y <= resizeorigin_y - mySize_y)
1062 dist_x = targPos_x - resizeorigin_x;
1063 dist_y = resizeorigin_y - targEndPos_y;
1064 if (dist_y < 0 || dist_x / dist_y > ratio)
1065 mySize_x = min(mySize_x, dist_x);
1067 mySize_y = min(mySize_y, dist_y);
1069 else if (resizeCorner == 3)
1071 if (resizeorigin_x <= targPos_x)
1073 if (resizeorigin_y >= targEndPos_y)
1075 if (targEndPos_x <= resizeorigin_x - mySize_x)
1077 if (targPos_y >= resizeorigin_y + mySize_y)
1080 dist_x = resizeorigin_x - targEndPos_x;
1081 dist_y = targPos_y - resizeorigin_y;
1082 if (dist_y < 0 || dist_x / dist_y > ratio)
1083 mySize_x = min(mySize_x, dist_x);
1085 mySize_y = min(mySize_y, dist_y);
1087 else if (resizeCorner == 4)
1089 if (resizeorigin_x >= targEndPos_x)
1091 if (resizeorigin_y >= targEndPos_y)
1093 if (targPos_x >= resizeorigin_x + mySize_x)
1095 if (targPos_y >= resizeorigin_y + mySize_y)
1098 dist_x = targPos_x - resizeorigin_x;
1099 dist_y = targPos_y - resizeorigin_y;
1100 if (dist_y < 0 || dist_x / dist_y > ratio)
1101 mySize_x = min(mySize_x, dist_x);
1103 mySize_y = min(mySize_y, dist_y);
1105 if(cvar("hud_configure_checkcollisions_debug"))
1106 drawfill(targPos + '1 1 0' * targBorder, targSize - '2 2 0' * targBorder, '1 1 0', .3, DRAWFLAG_NORMAL);
1112 void HUD_Panel_SetPosSize(float id, vector mySize)
1114 vector resizeorigin;
1115 resizeorigin = panel_click_resizeorigin;
1118 // minimum panel size cap
1119 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1120 mySize_y = max(0.025 * vid_conheight, mySize_y);
1122 if(id == 12) // some panels have their own restrictions, like the chat panel (which actually only moves the engine chat print around). Looks bad if it's too small.
1124 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
1125 mySize_y = max(2 * cvar("con_chatsize") + 2 * HUD_Panel_GetPadding(id), mySize_y);
1128 // collision testing|
1129 // -----------------+
1131 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
1132 if(resizeCorner == 1) {
1133 myPos_x = resizeorigin_x - mySize_x;
1134 myPos_y = resizeorigin_y - mySize_y;
1135 } else if(resizeCorner == 2) {
1136 myPos_x = resizeorigin_x;
1137 myPos_y = resizeorigin_y - mySize_y;
1138 } else if(resizeCorner == 3) {
1139 myPos_x = resizeorigin_x - mySize_x;
1140 myPos_y = resizeorigin_y;
1141 } else { // resizeCorner == 4
1142 myPos_x = resizeorigin_x;
1143 myPos_y = resizeorigin_y;
1146 // left/top screen edges
1148 mySize_x = mySize_x + myPos_x;
1150 mySize_y = mySize_y + myPos_y;
1152 // bottom/right screen edges
1153 if(myPos_x + mySize_x > vid_conwidth)
1154 mySize_x = vid_conwidth - myPos_x;
1155 if(myPos_y + mySize_y > vid_conheight)
1156 mySize_y = vid_conheight - myPos_y;
1158 if(cvar("hud_configure_checkcollisions_debug"))
1159 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
1161 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
1162 if(cvar("hud_configure_grid"))
1164 mySize_x = floor((mySize_x/vid_conwidth)/bound(0.005, cvar("hud_configure_grid_x"), 0.2) + 0.5) * bound(0.005, cvar("hud_configure_grid_x"), 0.2) * vid_conwidth;
1165 mySize_y = floor((mySize_y/vid_conheight)/bound(0.005, cvar("hud_configure_grid_y"), 0.2) + 0.5) * bound(0.005, cvar("hud_configure_grid_y"), 0.2) * vid_conheight;
1168 if(hud_configure_checkcollisions)
1169 mySize = HUD_Panel_CheckResize(id, mySize, resizeorigin);
1171 // minimum panel size cap, do this once more so we NEVER EVER EVER have a panel smaller than this, JUST IN CASE above code still makes the panel eg negative (impossible to resize back without changing cvars manually then)
1172 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1173 mySize_y = max(0.025 * vid_conheight, mySize_y);
1175 // do another pos check, as size might have changed by now
1176 if(resizeCorner == 1) {
1177 myPos_x = resizeorigin_x - mySize_x;
1178 myPos_y = resizeorigin_y - mySize_y;
1179 } else if(resizeCorner == 2) {
1180 myPos_x = resizeorigin_x;
1181 myPos_y = resizeorigin_y - mySize_y;
1182 } else if(resizeCorner == 3) {
1183 myPos_x = resizeorigin_x - mySize_x;
1184 myPos_y = resizeorigin_y;
1185 } else { // resizeCorner == 4
1186 myPos_x = resizeorigin_x;
1187 myPos_y = resizeorigin_y;
1190 if(cvar("hud_configure_checkcollisions_debug"))
1191 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
1194 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
1195 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_size"), s);
1197 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
1198 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
1201 float pressed_key_time;
1202 void HUD_Panel_Arrow_Action(float nPrimary)
1204 if (highlightedPanel_prev == -1)
1207 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
1210 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
1211 step = vid_conheight;
1213 step = vid_conwidth;
1214 if (hudShiftState & S_SHIFT)
1215 step = (step / 256); // more precision
1217 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
1219 highlightedPanel = highlightedPanel_prev;
1221 if (hudShiftState & S_ALT) // resize
1223 highlightedAction = 1;
1224 if(nPrimary == K_UPARROW)
1226 else if(nPrimary == K_RIGHTARROW)
1228 else if(nPrimary == K_LEFTARROW)
1230 else // if(nPrimary == K_DOWNARROW)
1233 // ctrl+arrow reduces the size, instead of increasing it
1234 // Note that ctrl disables collisions check too, but it's fine
1235 // since we don't collide with anything reducing the size
1236 if (hudShiftState & S_CTRL) {
1238 resizeCorner = 5 - resizeCorner;
1242 mySize = HUD_Panel_GetSize(highlightedPanel);
1243 panel_click_resizeorigin = HUD_Panel_GetPos(highlightedPanel);
1244 if(resizeCorner == 1) {
1245 panel_click_resizeorigin += mySize;
1247 } else if(resizeCorner == 2) {
1248 panel_click_resizeorigin_y += mySize_y;
1250 } else if(resizeCorner == 3) {
1251 panel_click_resizeorigin_x += mySize_x;
1253 } else { // resizeCorner == 4
1256 HUD_Panel_SetPosSize(highlightedPanel, mySize);
1260 highlightedAction = 2;
1262 pos = HUD_Panel_GetPos(highlightedPanel);
1263 if(nPrimary == K_UPARROW)
1265 else if(nPrimary == K_DOWNARROW)
1267 else if(nPrimary == K_LEFTARROW)
1269 else // if(nPrimary == K_RIGHTARROW)
1272 HUD_Panel_SetPos(highlightedPanel, pos);
1277 float prevMouseClicked; // previous state
1278 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
1279 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
1282 float menu_enabled_time;
1283 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1288 // allow console bind to work
1291 con_keys = findkeysforcommand("toggleconsole");
1292 keys = tokenize(con_keys);
1294 float hit_con_bind, i;
1295 for (i = 0; i < keys; ++i)
1297 if(nPrimary == stof(argv(i)))
1301 if(bInputType == 0) {
1302 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1303 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1304 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1306 else if(bInputType == 1) {
1307 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1308 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1309 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1312 if(nPrimary == K_MOUSE1)
1314 if(bInputType == 0) { // key pressed
1318 else if(bInputType == 1) {// key released
1323 else if(nPrimary == K_ESCAPE)
1325 if (bInputType == 1)
1327 disable_menu_alphacheck = 1;
1329 menu_enabled_time = time;
1330 localcmd("menu_showhudexit\n");
1332 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1334 if (bInputType == 1)
1336 pressed_key_time = 0;
1339 else if (pressed_key_time == 0)
1340 pressed_key_time = time;
1342 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1344 else if(hit_con_bind)
1347 return true; // Suppress ALL other input
1350 void HUD_Panel_Highlight()
1356 for(i = 0; i < HUD_PANEL_NUM; ++i)
1358 panelPos = HUD_Panel_GetPos(i);
1359 panelSize = HUD_Panel_GetSize(i);
1360 border = HUD_Panel_GetBorder(i);
1363 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1365 highlightedPanel = i;
1366 highlightedAction = 1;
1367 panel_click_distance = mousepos - panelPos;
1370 // resize from topleft border
1371 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)
1373 highlightedPanel = i;
1374 highlightedAction = 2;
1376 panel_click_distance = mousepos - panelPos;
1377 panel_click_resizeorigin = panelPos + panelSize;
1380 // resize from topright border
1381 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)
1383 highlightedPanel = i;
1384 highlightedAction = 2;
1386 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1387 panel_click_distance_y = mousepos_y - panelPos_y;
1388 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1391 // resize from bottomleft border
1392 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)
1394 highlightedPanel = i;
1395 highlightedAction = 2;
1397 panel_click_distance_x = mousepos_x - panelPos_x;
1398 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1399 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1402 // resize from bottomright border
1403 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)
1405 highlightedPanel = i;
1406 highlightedAction = 2;
1408 panel_click_distance = panelSize - mousepos + panelPos;
1409 panel_click_resizeorigin = panelPos;
1415 void HUD_Panel_Mouse()
1417 // TODO: needs better check... is there any float that contains the current state of the menu? _menu_alpha isn't apparently updated the frame the menu gets enabled
1418 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1419 disable_menu_alphacheck = 0;
1420 if (cvar("_menu_alpha") == 0 && time - menu_enabled_time > 0.5)
1424 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1425 print("Highlighted: ", ftos(highlightedPanel), "\n");
1426 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1429 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1430 highlightedPanel_prev = highlightedPanel;
1431 highlightedPanel = -1;
1432 highlightedAction = 0;
1435 mousepos = mousepos + getmousepos();
1437 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1438 mousepos_y = bound(0, mousepos_y, vid_conheight);
1440 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1444 if(prevMouseClicked == 0)
1445 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1447 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
1449 if(highlightedAction == 1)
1450 HUD_Panel_SetPos(highlightedPanel, mousepos - panel_click_distance);
1451 else if(highlightedAction == 2)
1454 if(resizeCorner == 1) {
1455 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1456 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1457 } else if(resizeCorner == 2) {
1458 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1459 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1460 } else if(resizeCorner == 3) {
1461 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1462 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1463 } else { // resizeCorner == 4
1464 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1465 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1467 HUD_Panel_SetPosSize(highlightedPanel, mySize);
1470 // doubleclick check
1471 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1473 mouseClicked = 0; // to prevent spam, I guess.
1474 disable_menu_alphacheck = 2;
1476 menu_enabled_time = time;
1477 localcmd("menu_showhudoptions ", ftos(highlightedPanel), "\n");
1480 if(prevMouseClicked == 0)
1482 prevMouseClickedTime = time;
1483 prevMouseClickedPos = mousepos;
1486 prevMouseClicked = mouseClicked;
1489 // Weapon icons (#0)
1491 float weaponspace[10];
1492 void HUD_WeaponIcons_Clear()
1495 for(idx = 0; idx < 10; ++idx)
1496 weaponspace[idx] = 0;
1499 entity weaponorder[WEP_MAXCOUNT];
1501 void weaponorder_swap(float i, float j, entity pass)
1505 weaponorder[i] = weaponorder[j];
1509 string weaponorder_cmp_str;
1510 float weaponorder_cmp(float i, float j, entity pass)
1513 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1514 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1515 return aj - ai; // the string is in REVERSE order (higher prio at the right is what we want, but higher prio first is the string)
1518 void HUD_WeaponIcons(void)
1520 float id = HUD_PANEL_WEAPONICONS;
1521 float alpha, stat_weapons; // "constants"
1522 vector pos, mySize, accuracy_color;
1523 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1525 pos = HUD_Panel_GetPos(id);
1526 mySize = HUD_Panel_GetSize(id);
1528 stat_weapons = getstati(STAT_WEAPONS);
1529 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1531 self = get_weaponinfo(i);
1532 if(self.impulse >= 0)
1534 weaponorder[weapon_cnt] = self;
1539 // TODO make this configurable
1540 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1541 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1543 HUD_Panel_DrawBg(id, pos, mySize, 0);
1545 padding = HUD_Panel_GetPadding(id);
1548 pos += '1 1 0' * padding;
1549 mySize -= '2 2 0' * padding;
1553 weapon_stats = getstati(STAT_DAMAGE_HITS);
1554 weapon_number = weapon_stats & 63;
1555 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1557 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1558 weapon_number = weapon_stats & 63;
1559 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1561 if(cvar_or("hud_weaponicons_fade", 1))
1563 fade = 3.2 - 2 * (time - weapontime);
1564 fade = bound(0.7, fade, 1);
1569 HUD_WeaponIcons_Clear();
1571 float rows, columns;
1572 rows = mySize_y/mySize_x;
1573 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1574 // ^^^ weapon icon aspect goes here
1576 columns = ceil(WEP_COUNT/rows);
1578 for(i = 0; i < weapon_cnt; ++i)
1580 self = weaponorder[i];
1581 weapid = self.impulse;
1583 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1585 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1586 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1588 // draw background behind currently selected weapon
1589 if(self.weapon == activeweapon)
1590 drawpic_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), "weapon_current_bg", eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), '1 1 1', fade * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1592 // draw the weapon accuracy on the HUD
1593 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1596 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1598 accuracy_color = HUD_AccuracyColor(weapon_stats);
1600 drawpic_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), "weapon_accuracy", eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), accuracy_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1603 // draw the weapon icon
1604 if((self.impulse >= 0) && (stat_weapons & self.weapons))
1606 drawpic_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), strcat("weapon", self.netname), eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), '1 1 1', fade * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1608 if(cvar_or("hud_weaponicons_number", 1))
1609 drawstring(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), ftos(weapid), '1 1 0' * 0.5 * mySize_y*(1/rows), '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1613 drawpic_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), strcat("weapon", self.netname), eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), '0 0 0', HUD_Panel_GetFgAlpha(id) * 0.5, DRAWFLAG_NORMAL);
1628 float GetAmmoStat(float i)
1632 case 0: return STAT_SHELLS;
1633 case 1: return STAT_NAILS;
1634 case 2: return STAT_ROCKETS;
1635 case 3: return STAT_CELLS;
1636 case 4: return STAT_FUEL;
1641 float GetAmmoItemCode(float i)
1645 case 0: return IT_SHELLS;
1646 case 1: return IT_NAILS;
1647 case 2: return IT_ROCKETS;
1648 case 3: return IT_CELLS;
1649 case 4: return IT_FUEL;
1654 string GetAmmoPicture(float i)
1658 case 0: return "ammo_shells";
1659 case 1: return "ammo_bullets";
1660 case 2: return "ammo_rockets";
1661 case 3: return "ammo_cells";
1662 case 4: return "ammo_fuel";
1667 void HUD_Inventory(void)
1669 float id = HUD_PANEL_INVENTORY;
1673 vector pos, mySize, mysize, mypos;
1674 pos = HUD_Panel_GetPos(id);
1675 mySize = HUD_Panel_GetSize(id);
1677 HUD_Panel_DrawBg(id, pos, mySize, 0);
1679 padding = HUD_Panel_GetPadding(id);
1682 pos += '1 1 0' * padding;
1683 mySize -= '2 2 0' * padding;
1687 stat_items = getstati(STAT_ITEMS);
1688 for (i = 0; i < 4; ++i) {
1690 a = getstati(GetAmmoStat(i)); // how much ammo do we have of type i?
1694 if(cvar("hud_inventory_onlycurrent")) {
1697 if (stat_items & GetAmmoItemCode(i) || hud_configure) {
1698 drawpic_skin(pos, GetAmmoPicture(i), '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1700 HUD_DrawXNum(pos + eX * mySize_y + eY * 0.25 * mySize_y, a, strlen(ftos(a)), 0, 0.5 * mySize_y, '0.7 0 0', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1702 HUD_DrawXNum(pos + eX * mySize_y + eY * 0.25 * mySize_y, a, strlen(ftos(a)), 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1708 if(mySize_x/mySize_y >= 10) { // arrange horizontally
1710 case 0: mypos_x = pos_x; mypos_y = pos_y; break; // shells
1711 case 1: mypos_x = pos_x + 0.25 * mySize_x; mypos_y = pos_y; break; // bullets
1712 case 2: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y; break; // rockets
1713 case 3: mypos_x = pos_x + 0.75 * mySize_x; mypos_y = pos_y; break; // cells
1715 mysize_x = 0.25 * mySize_x;
1716 mysize_y = mySize_y;
1717 } else if(mySize_x/mySize_y >= 2.5) { // arrange in a 2x2 grid
1719 case 0: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y + 0.5 * mySize_y; break; // shells
1720 case 1: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y; break; // bullets
1721 case 2: mypos_x = pos_x; mypos_y = pos_y + 0.5 * mySize_y; break; // rockets
1722 case 3: mypos_x = pos_x; mypos_y = pos_y; break; // cells
1724 mysize_x = 0.5 * mySize_x;
1725 mysize_y = 0.5 * mySize_y;
1726 } else { // arrange vertically
1728 case 0: mypos_x = pos_x; mypos_y = pos_y; break; // shells
1729 case 1: mypos_x = pos_x; mypos_y = pos_y + 0.25 * mySize_y; break; // bullets
1730 case 2: mypos_x = pos_x; mypos_y = pos_y + 0.5 * mySize_y; break; // rockets
1731 case 3: mypos_x = pos_x; mypos_y = pos_y + 0.75 * mySize_y; break; // cells
1733 mysize_x = mySize_x;
1734 mysize_y = 0.25 * mySize_y;
1737 if (stat_items & GetAmmoItemCode(i))
1738 drawpic_skin(mypos, "ammo_current_bg", mysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1739 drawpic_skin(mypos + eY * 0.05 * mysize_y, GetAmmoPicture(i), '1 1 0' * 0.8 * mysize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1741 if(stat_items & GetAmmoItemCode(i))
1742 HUD_DrawXNum(mypos + eX * 0.8 * mysize_y + eY * 0.25 * mysize_y, a, strlen(ftos(a)), 0, 0.5 * mysize_y, '0.7 0 0', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1744 HUD_DrawXNum(mypos + eX * 0.8 * mysize_y + eY * 0.25 * mysize_y, a, strlen(ftos(a)), 0, 0.5 * mysize_y, '0.7 0 0', 0, 0, HUD_Panel_GetFgAlpha(id) * 0.7, DRAWFLAG_NORMAL);
1746 if(stat_items & GetAmmoItemCode(i))
1747 HUD_DrawXNum(mypos + eX * 0.8 * mysize_y + eY * 0.25 * mysize_y, a, strlen(ftos(a)), 0, 0.5 * mysize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1749 HUD_DrawXNum(mypos + eX * 0.8 * mysize_y + eY * 0.25 * mysize_y, a, strlen(ftos(a)), 0, 0.5 * mysize_y, '0.7 0.7 0.7', 0, 0, HUD_Panel_GetFgAlpha(id) * 0.7, DRAWFLAG_NORMAL);
1759 void HUD_Powerups(void) {
1760 float id = HUD_PANEL_POWERUPS;
1762 stat_items = getstati(STAT_ITEMS);
1766 if not(stat_items & IT_STRENGTH)
1767 if not(stat_items & IT_INVINCIBLE)
1770 if (getstati(STAT_HEALTH) <= 0)
1775 pos = HUD_Panel_GetPos(id);
1776 mySize = HUD_Panel_GetSize(id);
1778 HUD_Panel_DrawBg(id, pos, mySize, 0);
1780 padding = HUD_Panel_GetPadding(id);
1783 pos += '1 1 0' * padding;
1784 mySize -= '2 2 0' * padding;
1787 float strength_time, shield_time;
1789 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1790 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1800 vector barpos, barsize;
1804 string leftname, rightname;
1805 float leftcnt, rightcnt;
1806 float leftexact, rightexact;
1807 float leftalpha, rightalpha;
1808 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) {
1809 leftname = "strength";
1810 leftcnt = ceil(strength_time);
1811 leftexact = strength_time;
1813 rightname = "shield";
1814 rightcnt = ceil(shield_time);
1815 rightexact = shield_time;
1817 leftname = "shield";
1818 leftcnt = ceil(shield_time);
1819 leftexact = shield_time;
1821 rightname = "strength";
1822 rightcnt = ceil(strength_time);
1823 rightexact = strength_time;
1825 leftalpha = bound(0, leftexact, 1);
1826 rightalpha = bound(0, rightexact, 1);
1828 if (mySize_x/mySize_y > 4)
1832 len = strlen(ftos(leftcnt));
1834 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1835 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1836 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1837 picpos = pos + eX * 0.5 * mySize_x - eX * mySize_y;
1838 numpos = picpos - eX * 2 * 0.5 * mySize_y + eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1841 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1843 numpos = picpos + eX * mySize_y - eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1846 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1848 drawpic_skin_expanding_two(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE, bound(0, (leftcnt - leftexact) / 0.5, 1));
1850 drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1851 HUD_DrawXNum(numpos, leftcnt, 2, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1856 len = strlen(ftos(rightcnt));
1858 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1859 barpos = pos + eX * 0.5 * mySize_x;
1860 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1861 picpos = pos + eX * 0.5 * mySize_x;
1862 numpos = picpos + eX * mySize_y - eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1864 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1865 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1866 picpos = pos + eX * mySize_x - eX * mySize_y;
1867 numpos = picpos - eX * mySize_y + eY * 0.25 * mySize_y;
1870 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1872 drawpic_skin_expanding_two(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE, bound(0, (rightcnt - rightexact) / 0.5, 1));
1874 drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1875 HUD_DrawXNum(numpos, rightcnt, 2, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1878 else if (mySize_x/mySize_y > 1.5)
1882 len = strlen(ftos(leftcnt));
1884 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1885 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1886 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1887 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y;
1888 numpos = picpos - eX * len * 0.5 * mySize_y;
1891 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1893 numpos = picpos + eX * 0.5 * mySize_y;
1896 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1898 drawpic_skin_expanding_two(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE, bound(0, (leftcnt - leftexact) / 0.5, 1));
1900 drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1901 HUD_DrawXNum(numpos, leftcnt, len, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1906 len = strlen(ftos(rightcnt));
1908 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1909 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1910 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1911 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y + eY * 0.5 * mySize_y;
1912 numpos = picpos - eX * len * 0.5 * mySize_y;
1914 barpos = pos + eY * 0.5 * mySize_y;
1915 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1916 picpos = pos + eY * 0.5 * mySize_y;
1917 numpos = picpos + eX * 0.5 * mySize_y;
1920 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1922 drawpic_skin_expanding_two(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE, bound(0, (rightcnt - rightexact) / 0.5, 1));
1924 drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1925 HUD_DrawXNum(numpos, rightcnt, len, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1932 len = strlen(ftos(leftcnt));
1934 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1936 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1937 picpos = pos + eX * 0.05 * mySize_x;
1938 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x;
1940 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1941 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1942 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.65 * mySize_x;
1943 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.25 * mySize_x;
1946 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1948 drawpic_skin_expanding_two(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE, bound(0, (leftcnt - leftexact) / 0.5, 1));
1950 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1951 HUD_DrawXNum(numpos, leftcnt, len, 0, 0.25 * mySize_x, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1956 len = strlen(ftos(rightcnt));
1958 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1959 barpos = pos + eX * 0.5 * mySize_x;
1960 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1961 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1962 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1964 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1965 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1966 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.65 * mySize_x + eX * 0.5 * mySize_x;
1967 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
1970 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1972 drawpic_skin_expanding_two(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE, bound(0, (rightcnt - rightexact) / 0.5, 1));
1974 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1975 HUD_DrawXNum(numpos, rightcnt, len, 0, 0.25 * mySize_x, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1980 // Health/armor (#3)
1982 void HUD_HealthArmor(void)
1984 float id = HUD_PANEL_HEALTHARMOR;
1986 pos = HUD_Panel_GetPos(id);
1987 mySize = HUD_Panel_GetSize(id);
1989 HUD_Panel_DrawBg(id, pos, mySize, 0);
1991 padding = HUD_Panel_GetPadding(id);
1994 pos += '1 1 0' * padding;
1995 mySize -= '2 2 0' * padding;
1998 float armor, health;
1999 armor = getstati(STAT_ARMOR);
2000 health = getstati(STAT_HEALTH);
2003 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
2016 vector barpos, barsize;
2020 if(cvar("hud_healtharmor") == 2) // combined health and armor display
2023 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2028 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2029 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2030 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2032 numpos = picpos + eX * 1.5 * mySize_y;
2035 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2036 picpos = pos + eX * 3 * mySize_y;
2040 if(v_z) // NOT fully armored
2042 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("health"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2043 drawpic_skin(picpos, "health", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2045 drawpic_skin(picpos + eX * mySize_y, "armor", '0.5 0.5 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id) * armor / health, DRAWFLAG_NORMAL);
2049 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("armor"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2050 drawpic_skin(picpos + eX * mySize_y, "health", '0.5 0.5 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id) * health / armor, DRAWFLAG_NORMAL);
2052 drawpic_skin(picpos, "armor", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2054 HUD_DrawXNum_Colored(numpos, x, 3, mySize_y, HUD_Panel_GetFgAlpha(id)); // draw the combined health and armor
2057 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2058 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2059 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2062 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2065 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2070 string leftname, rightname;
2071 float leftcnt, rightcnt;
2072 float leftactive, rightactive;
2073 float leftalpha, rightalpha;
2074 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) { // old style layout with armor left/top of health
2079 leftalpha = min((armor+10)/55, 1);
2081 rightname = "health";
2086 leftname = "health";
2091 rightname = "armor";
2095 rightalpha = min((armor+10)/55, 1);
2098 if (mySize_x/mySize_y > 5)
2102 len = strlen(ftos(leftcnt));
2104 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2105 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2106 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2107 picpos = pos + eX * 0.5 * mySize_x - eX * mySize_y;
2108 numpos = picpos - eX * 3 * 0.5 * mySize_y + eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
2111 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2113 numpos = picpos + eX * mySize_y + eY * 0.25 * mySize_y;
2116 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2117 drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2118 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2123 len = strlen(ftos(rightcnt));
2125 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2126 barpos = pos + eX * 0.5 * mySize_x;
2127 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2128 picpos = pos + eX * 0.5 * mySize_x;
2129 numpos = picpos + eX * mySize_y - eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
2131 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2132 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2133 picpos = pos + eX * mySize_x - eX * mySize_y;
2134 numpos = picpos - eX * 1.5 * mySize_y + eY * 0.25 * mySize_y;
2137 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2138 drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2139 HUD_DrawXNum_Colored(numpos, rightcnt, 3, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2142 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2143 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2144 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2147 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2150 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2152 else if (mySize_x/mySize_y > 2)
2156 len = strlen(ftos(leftcnt));
2158 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2159 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2160 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2161 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y;
2162 numpos = picpos - eX * len * 0.5 * mySize_y;
2165 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2167 numpos = picpos + eX * 0.5 * mySize_y;
2170 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2171 drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2172 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2177 len = strlen(ftos(rightcnt));
2179 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2180 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2181 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2182 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y + eY * 0.5 * mySize_y;
2183 numpos = picpos - eX * len * 0.5 * mySize_y;
2185 barpos = pos + eY * 0.5 * mySize_y;
2186 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2187 picpos = pos + eY * 0.5 * mySize_y;
2188 numpos = picpos + eX * 0.5 * mySize_y;
2191 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2192 drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2193 HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2196 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2197 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2198 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2201 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2204 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2210 len = strlen(ftos(leftcnt));
2212 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2214 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2215 picpos = pos + eX * 0.05 * mySize_x;
2216 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x;
2218 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2219 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2220 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x;
2221 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x;
2224 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2225 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2226 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.166 * mySize_x, HUD_Panel_GetFgAlpha(id));
2231 len = strlen(ftos(rightcnt));
2233 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2234 barpos = pos + eX * 0.5 * mySize_x;
2235 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2236 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2237 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2239 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2240 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2241 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x + eX * 0.5 * mySize_x;
2242 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x + eX * 0.5 * mySize_x;
2245 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2246 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2247 HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.166 * mySize_x, HUD_Panel_GetFgAlpha(id));
2250 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2252 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2254 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2255 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2258 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2264 // Notification area (#4)
2267 string Weapon_SuicideMessage(float deathtype)
2269 w_deathtype = deathtype;
2270 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2271 return w_deathtypestring;
2274 string Weapon_KillMessage(float deathtype)
2276 w_deathtype = deathtype;
2277 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2278 return w_deathtypestring;
2281 float killnotify_times[10];
2282 float killnotify_deathtype[10];
2283 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2284 string killnotify_attackers[10];
2285 string killnotify_victims[10];
2286 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2289 for (i = 9; i > 0; --i) {
2290 killnotify_times[i] = killnotify_times[i-1];
2291 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2292 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2293 if(killnotify_attackers[i])
2294 strunzone(killnotify_attackers[i]);
2295 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2296 if(killnotify_victims[i])
2297 strunzone(killnotify_victims[i]);
2298 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2300 killnotify_times[0] = time;
2301 killnotify_deathtype[0] = wpn;
2302 killnotify_actiontype[0] = actiontype;
2303 if(killnotify_attackers[0])
2304 strunzone(killnotify_attackers[0]);
2305 killnotify_attackers[0] = strzone(attacker);
2306 if(killnotify_victims[0])
2307 strunzone(killnotify_victims[0]);
2308 killnotify_victims[0] = strzone(victim);
2311 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2315 alsoprint = (cvar("hud_notify_print") || !HUD_Panel_CheckActive(4)); // print message to console if: notify panel disabled, or cvar to do so enabled
2317 if(msg == MSG_SUICIDE) {
2319 w = DEATH_WEAPONOF(type);
2321 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2323 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2324 } else if (type == DEATH_KILL) {
2325 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2327 print ("^1",s1, "^1 couldn't take it anymore\n");
2328 } else if (type == DEATH_ROT) {
2329 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2331 print ("^1",s1, "^1 died\n");
2332 } else if (type == DEATH_NOAMMO) {
2333 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2335 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2336 } else if (type == DEATH_CAMP) {
2337 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2339 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2340 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2341 HUD_KillNotify_Push(s1, "", 0, type);
2343 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2344 } else if (type == DEATH_CHEAT) {
2345 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2347 print ("^1",s1, "^1 unfairly eliminated themself\n");
2348 } else if (type == DEATH_FIRE) {
2349 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2351 print ("^1",s1, "^1 burned to death\n");
2352 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2353 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2355 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2358 if (stof(s2) > 2) // killcount > 2
2359 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2360 } else if(msg == MSG_KILL) {
2361 w = DEATH_WEAPONOF(type);
2363 HUD_KillNotify_Push(s2, s1, 1, w);
2365 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2367 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2368 HUD_KillNotify_Push(s1, s2, 1, type);
2371 if(cvar("cl_gentle")) {
2372 print ("^1", s1, "^1 took action against a team mate\n");
2374 print ("^1", s1, "^1 mows down a team mate\n");
2377 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2378 if(cvar("cl_gentle"))
2379 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2381 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2383 else if (stof(s2) > 2) {
2384 if(cvar("cl_gentle"))
2385 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2387 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2390 else if(type == KILL_FIRST_BLOOD)
2391 print("^1",s1, "^1 drew first blood", "\n");
2393 else if (type == DEATH_TELEFRAG)
2394 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2395 else if (type == DEATH_DROWN) {
2396 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2398 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2400 else if (type == DEATH_SLIME) {
2401 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2403 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2405 else if (type == DEATH_LAVA) {
2406 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2408 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2410 else if (type == DEATH_FALL) {
2411 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2413 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2415 else if (type == DEATH_SHOOTING_STAR) {
2416 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2418 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2420 else if (type == DEATH_SWAMP) {
2421 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2423 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2425 else if (type == DEATH_HURTTRIGGER)
2427 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2429 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2430 } else if(type == DEATH_SBCRUSH) {
2431 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2433 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2434 } else if(type == DEATH_SBMINIGUN) {
2435 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2437 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2438 } else if(type == DEATH_SBROCKET) {
2439 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2441 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2442 } else if(type == DEATH_SBBLOWUP) {
2443 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2445 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2446 } else if(type == DEATH_WAKIGUN) {
2447 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2449 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2450 } else if(type == DEATH_WAKIROCKET) {
2451 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2453 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2454 } else if(type == DEATH_WAKIBLOWUP) {
2455 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2457 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2458 } else if(type == DEATH_TURRET) {
2459 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2461 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2462 } else if(type == DEATH_TOUCHEXPLODE) {
2463 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2465 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2466 } else if(type == DEATH_CHEAT) {
2467 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2469 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2470 } else if (type == DEATH_FIRE) {
2471 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2473 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2474 } else if (type == DEATH_CUSTOM) {
2475 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2477 print ("^1",s1, "^1 ", s2, "\n");
2479 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2481 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2483 } else if(msg == MSG_SPREE) {
2484 if(type == KILL_END_SPREE) {
2485 if(cvar("cl_gentle"))
2486 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2488 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2489 } else if(type == KILL_SPREE) {
2490 if(cvar("cl_gentle"))
2491 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2493 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2494 } else if(type == KILL_SPREE_3) {
2495 if(cvar("cl_gentle"))
2496 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2498 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2499 } else if(type == KILL_SPREE_5) {
2500 if(cvar("cl_gentle"))
2501 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2503 print (s1,"^7 unleashes ^1RAGE\n");
2504 } else if(type == KILL_SPREE_10) {
2505 if(cvar("cl_gentle"))
2506 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2508 print (s1,"^7 starts the ^1MASSACRE!\n");
2509 } else if(type == KILL_SPREE_15) {
2510 if(cvar("cl_gentle"))
2511 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2513 print (s1,"^7 executes ^1MAYHEM!\n");
2514 } else if(type == KILL_SPREE_20) {
2515 if(cvar("cl_gentle"))
2516 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2518 print (s1,"^7 is a ^1BERSERKER!\n");
2519 } else if(type == KILL_SPREE_25) {
2520 if(cvar("cl_gentle"))
2521 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2523 print (s1,"^7 inflicts ^1CARNAGE!\n");
2524 } else if(type == KILL_SPREE_30) {
2525 if(cvar("cl_gentle"))
2526 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2528 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2530 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2531 if (type == DEATH_DROWN) {
2532 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2535 if(cvar("cl_gentle"))
2536 print ("^1",s1, "^1 was in the water for too long\n");
2538 print ("^1",s1, "^1 drowned\n");
2540 } else if (type == DEATH_SLIME) {
2541 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2543 print ("^1",s1, "^1 was slimed\n");
2544 } else if (type == DEATH_LAVA) {
2545 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2548 if(cvar("cl_gentle"))
2549 print ("^1",s1, "^1 found a hot place\n");
2551 print ("^1",s1, "^1 turned into hot slag\n");
2553 } else if (type == DEATH_FALL) {
2554 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2557 if(cvar("cl_gentle"))
2558 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2560 print ("^1",s1, "^1 hit the ground with a crunch\n");
2562 } else if (type == DEATH_SHOOTING_STAR) {
2563 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2565 print ("^1",s1, "^1 became a shooting star\n");
2566 } else if (type == DEATH_SWAMP) {
2567 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2570 if(cvar("cl_gentle"))
2571 print ("^1",s1, "^1 discovered a swamp\n");
2573 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2575 } else if(type == DEATH_TURRET) {
2576 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2578 print ("^1",s1, "^1 was mowed down by a turret \n");
2579 } else if (type == DEATH_CUSTOM) {
2580 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2582 print ("^1",s1, "^1 ", s2, "\n");
2583 } else if (type == DEATH_HURTTRIGGER) {
2584 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2586 print ("^1",s1, "^1 was in the wrong place\n");
2587 } else if(type == DEATH_TOUCHEXPLODE) {
2588 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2590 print ("^1",s1, "^1 died in an accident\n");
2591 } else if(type == DEATH_CHEAT) {
2592 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2594 print ("^1",s1, "^1 was unfairly eliminated\n");
2595 } else if(type == DEATH_FIRE) {
2596 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2599 if(cvar("cl_gentle"))
2600 print ("^1",s1, "^1 felt a little hot\n");
2602 print ("^1",s1, "^1 burnt to death\n");
2605 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2608 if(cvar("cl_gentle"))
2609 print ("^1",s1, "^1 needs a restart\n");
2611 print ("^1",s1, "^1 died\n");
2614 } else if(msg == MSG_KILL_ACTION_SPREE) {
2615 if(cvar("cl_gentle"))
2616 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2618 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2619 } else if(msg == MSG_INFO) {
2620 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2621 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2622 print(s1, "^7 got the ", s2, "\n");
2623 } else if(type == INFO_LOSTFLAG) {
2624 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2625 print(s1, "^7 lost the ", s2, "\n");
2626 } else if(type == INFO_PICKUPFLAG) {
2627 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2628 print(s1, "^7 picked up the ", s2, "\n");
2629 } else if(type == INFO_RETURNFLAG) {
2630 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2631 print(s1, "^7 returned the ", s2, "\n");
2636 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2638 void HUD_Centerprint(string s1, string s2, float type, float msg)
2640 if(msg == MSG_SUICIDE) {
2641 if (type == DEATH_TEAMCHANGE) {
2642 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2643 } else if (type == DEATH_AUTOTEAMCHANGE) {
2644 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2645 } else if (type == DEATH_CAMP) {
2646 if(cvar("cl_gentle"))
2647 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2649 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2650 } else if (type == DEATH_NOAMMO) {
2651 if(cvar("cl_gentle"))
2652 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2654 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2655 } else if (type == DEATH_ROT) {
2656 if(cvar("cl_gentle"))
2657 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2659 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2660 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2661 if(cvar("cl_gentle"))
2662 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2664 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2665 } else if (type == DEATH_QUIET) {
2667 } else if (type == DEATH_KILL) {
2668 if(cvar("cl_gentle"))
2669 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2671 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2673 } else if(msg == MSG_KILL) {
2674 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2675 if(cvar("cl_gentle")) {
2676 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2678 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2680 } else if (type == KILL_FIRST_BLOOD) {
2681 if(cvar("cl_gentle")) {
2682 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2684 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2686 } else if (type == KILL_FIRST_VICTIM) {
2687 if(cvar("cl_gentle")) {
2688 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2690 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2692 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2693 if(cvar("cl_gentle")) {
2694 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2696 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2698 } else if (type == KILL_TYPEFRAGGED) {
2699 if(cvar("cl_gentle")) {
2700 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2702 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2704 } else if (type == KILL_FRAG) {
2705 if(cvar("cl_gentle")) {
2706 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2708 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2710 } else if (type == KILL_FRAGGED) {
2711 if(cvar("cl_gentle")) {
2712 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2714 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2717 } else if(msg == MSG_KILL_ACTION) {
2718 // TODO: invent more centerprints here?
2719 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2723 void HUD_Notify (void)
2725 float id = HUD_PANEL_NOTIFY;
2727 pos = HUD_Panel_GetPos(id);
2728 mySize = HUD_Panel_GetSize(id);
2730 HUD_Panel_DrawBg(id, pos, mySize, 0);
2732 padding = HUD_Panel_GetPadding(id);
2735 pos += '1 1 0' * padding;
2736 mySize -= '2 2 0' * padding;
2739 float entries, height;
2740 entries = bound(1, floor(14 * mySize_y/mySize_x), 12);
2741 height = mySize_y/entries;
2742 entries -= 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2745 fontsize = '0.5 0.5 0' * height;
2749 when = cvar("hud_notify_time");
2751 fadetime = cvar("hud_notify_fadetime");
2755 vector pos_attacker, pos_victim;
2757 float width_attacker, width_victim;
2758 string attacker, victim;
2761 for(j = 0; j < entries; ++j)
2763 if(cvar("hud_notify_flip"))
2765 else // rather nasty hack for ordering items from the bottom up
2766 i = entries - j - 1;
2767 if(cvar("hud_notify_info_top"))
2768 i += 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2772 if(killnotify_times[j] + when > time)
2775 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2779 if(killnotify_times[j] + when > time)
2785 // TODO: maybe print in team colors?
2786 // TODO: maybe this could be cleaned up somehow...
2787 // TODO: less copypaste code below
2790 if(killnotify_actiontype[j] == 0 && !hud_configure)
2792 attacker = textShortenToWidth(killnotify_attackers[j], mySize_x - 2 * height, fontsize, stringwidth_colors);
2794 width_attacker = stringwidth(attacker, TRUE, fontsize);
2795 pos_attacker = pos + eX * 0.5 * (mySize_x - width_attacker + 2 * height) + eY * 0.5 * fontsize_y + eY * i * height;
2797 weap_pos = pos + eX * 0.5 * (mySize_x - width_attacker) - eX * height + eY * i * height;
2798 if(killnotify_deathtype[j] == DEATH_GENERIC)
2800 drawpic_skin(weap_pos, "notify_death", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2801 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2803 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2805 drawpic_skin(weap_pos, "notify_outofammo", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2806 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2808 else if(killnotify_deathtype[j] == DEATH_KILL)
2810 drawpic_skin(weap_pos, "notify_selfkill", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2811 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2813 else if(killnotify_deathtype[j] == DEATH_CAMP)
2815 drawpic_skin(weap_pos, "notify_camping", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2816 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2818 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2820 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2821 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2823 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2825 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2826 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2828 else if(killnotify_deathtype[j] == DEATH_DROWN)
2830 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2831 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2833 else if(killnotify_deathtype[j] == DEATH_SLIME)
2835 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2836 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2838 else if(killnotify_deathtype[j] == DEATH_LAVA)
2840 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2841 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2843 else if(killnotify_deathtype[j] == DEATH_FALL)
2845 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2846 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2848 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2850 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2851 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2853 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2855 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2856 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2858 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2860 if(killnotify_victims[j] == "^1RED^7 flag")
2864 drawpic_skin(weap_pos, strcat("flag_", s, "_carrying"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2865 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2867 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2869 if(killnotify_victims[j] == "^1RED^7 flag")
2873 drawpic_skin(weap_pos, strcat("flag_", s, "_taken"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2874 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2876 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2878 if(killnotify_victims[j] == "^1RED^7 flag")
2882 drawpic_skin(weap_pos, strcat("flag_", s, "_lost"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2883 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2886 // X [did action to] Y
2891 attacker = textShortenToWidth("Player1", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2892 victim = textShortenToWidth("Player2", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2893 a = bound(0, (when - j) / 4, 1);
2897 attacker = textShortenToWidth(killnotify_attackers[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2898 victim = textShortenToWidth(killnotify_victims[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2900 width_attacker = stringwidth(attacker, TRUE, fontsize);
2901 width_victim = stringwidth(victim, TRUE, fontsize);
2902 pos_attacker = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_attacker) + eY * 0.5 * fontsize_y + eY * i * height;
2903 pos_victim = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_victim) + eY * 0.5 * fontsize_y + eX * 0.5 * mySize_x + eX * height + eY * i * height;
2904 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2906 if(hud_configure) // example actions for config mode
2908 drawpic_skin(weap_pos, strcat("weapon", "electro"), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2909 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2910 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2912 else if(WEP_VALID(killnotify_deathtype[j]))
2914 self = get_weaponinfo(killnotify_deathtype[j]);
2915 drawpic_skin(weap_pos, strcat("weapon", self.netname), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2916 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2917 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2919 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2921 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2922 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2923 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2925 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2927 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2928 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2929 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2931 else if(killnotify_deathtype[j] == DEATH_DROWN)
2933 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2934 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2935 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2937 else if(killnotify_deathtype[j] == DEATH_SLIME)
2939 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2940 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2941 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2943 else if(killnotify_deathtype[j] == DEATH_LAVA)
2945 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2946 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2947 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2949 else if(killnotify_deathtype[j] == DEATH_FALL)
2951 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2952 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2953 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2955 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2957 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2958 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2959 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2961 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2963 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2964 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2965 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2976 if(cvar("hud_notify_info_top"))
2979 o = pos + eY * mySize_y - eY * 2 * height;
2981 if(spectatee_status && !intermission)
2983 //drawfont = hud_bigfont;
2984 if(spectatee_status == -1)
2987 s = GetPlayerName(spectatee_status - 1);
2989 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
2990 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2991 //drawfont = hud_font;
2993 // spectator text in the upper right corner
2994 if(spectatee_status == -1)
2995 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
2997 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
2998 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2999 o += eY * fontsize_y;
3001 if(spectatee_status == -1)
3002 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
3004 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
3005 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3006 o += eY * fontsize_y;
3008 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
3009 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3010 o += eY * fontsize_y;
3012 if(gametype == GAME_ARENA)
3013 s = "^1Wait for your turn to join";
3014 else if(gametype == GAME_LMS)
3017 sk = playerslots[player_localentnum - 1];
3018 if(sk.(scores[ps_primary]) >= 666)
3019 s = "^1Match has already begun";
3020 else if(sk.(scores[ps_primary]) > 0)
3021 s = "^1You have no more lives left";
3023 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
3026 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
3027 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3028 o += eY * fontsize_y;
3030 //show restart countdown:
3031 if (time < getstatf(STAT_GAMESTARTTIME)) {
3033 //we need to ceil, otherwise the countdown would be off by .5 when using round()
3034 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
3035 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
3036 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3037 o += eY * fontsize_y;
3040 if(warmup_stage && !intermission)
3042 s = "^2Currently in ^1warmup^2 stage!";
3043 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3044 o += eY * fontsize_y;
3048 if(mod(time, 1) >= 0.5)
3053 if(ready_waiting && !intermission && !spectatee_status)
3055 if(ready_waiting_for_me)
3058 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
3060 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
3065 s = strcat("^2Waiting for others to ready up to end warmup...");
3067 s = strcat("^2Waiting for others to ready up...");
3069 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3070 o += eY * fontsize_y;
3072 else if(warmup_stage && !intermission && !spectatee_status)
3074 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
3075 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3076 o += eY * fontsize_y;
3079 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
3081 float ts_min, ts_max;
3082 tm = teams.sort_next;
3085 for(; tm.sort_next; tm = tm.sort_next)
3087 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
3089 if(!ts_min) ts_min = tm.team_size;
3090 else ts_min = min(ts_min, tm.team_size);
3091 if(!ts_max) ts_max = tm.team_size;
3092 else ts_max = max(ts_max, tm.team_size);
3094 if ((ts_max - ts_min) > 1)
3096 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
3097 tm = GetTeam(myteam, false);
3099 if (tm.team != COLOR_SPECTATOR)
3100 if (tm.team_size == ts_max)
3101 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
3103 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3104 o += eY * fontsize_y;
3110 s = "^7Press ^3ESC ^7to show HUD options.";
3111 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3112 o += eY * fontsize_y;
3113 s = "^3Doubleclick a panel for panel-specific options.";
3114 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3115 o += eY * fontsize_y;
3121 string seconds_tostring(float sec)
3124 minutes = floor(sec / 60);
3126 sec -= minutes * 60;
3129 s = ftos(100 + sec);
3131 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3134 void HUD_Timer(void)
3136 float id = HUD_PANEL_TIMER;
3138 pos = HUD_Panel_GetPos(id);
3139 mySize = HUD_Panel_GetSize(id);
3141 HUD_Panel_DrawBg(id, pos, mySize, 0);
3143 padding = HUD_Panel_GetPadding(id);
3146 pos += '1 1 0' * padding;
3147 mySize -= '2 2 0' * padding;
3151 float timelimit, elapsedTime, timeleft, minutesLeft;
3153 timelimit = getstatf(STAT_TIMELIMIT);
3155 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3156 timeleft = ceil(timeleft);
3158 minutesLeft = floor(timeleft / 60);
3161 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3162 timer_color = '1 1 1'; //white
3163 else if(minutesLeft >= 1)
3164 timer_color = '1 1 0'; //yellow
3166 timer_color = '1 0 0'; //red
3168 if (cvar("hud_timer_increment") || timelimit == 0 || warmup_stage) {
3169 if (time < getstatf(STAT_GAMESTARTTIME)) {
3170 //while restart is still active, show 00:00
3171 timer = seconds_tostring(0);
3173 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3174 timer = seconds_tostring(elapsedTime);
3177 timer = seconds_tostring(timeleft);
3180 drawstring_aspect(pos, timer, mySize, mySize_y, timer_color, HUD_Panel_GetFgAlpha(HUD_PANEL_TIMER), DRAWFLAG_NORMAL);
3185 void HUD_Radar(void)
3187 float id = HUD_PANEL_RADAR;
3189 pos = HUD_Panel_GetPos(id);
3190 mySize = HUD_Panel_GetSize(id);
3192 HUD_Panel_DrawBg(id, pos, mySize, 0);
3194 padding = HUD_Panel_GetPadding(id);
3197 pos += '1 1 0' * padding;
3198 mySize -= '2 2 0' * padding;
3201 local float color1, color2; // color already declared as a global in hud.qc
3204 float scale2d, normalsize, bigsize;
3207 teamradar_origin2d = pos + 0.5 * mySize;
3208 teamradar_size2d = mySize;
3210 if(minimapname == "")
3213 teamradar_loadcvars();
3215 switch(hud_radar_zoommode)
3219 f = current_zoomfraction;
3222 f = 1 - current_zoomfraction;
3232 switch(hud_radar_rotation)
3235 teamradar_angle = view_angles_y - 90;
3238 teamradar_angle = 90 * hud_radar_rotation;
3242 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3243 teamradar_size2d = mySize;
3245 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3247 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3248 if(hud_radar_rotation == 0)
3250 // max-min distance must fit the radar in any rotation
3251 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3255 vector c0, c1, c2, c3, span;
3256 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3257 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3258 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3259 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3261 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3262 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3264 // max-min distance must fit the radar in x=x, y=y
3266 teamradar_size2d_x * scale2d / (1.05 * span_x),
3267 teamradar_size2d_y * scale2d / (1.05 * span_y)
3271 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3272 if(bigsize > normalsize)
3273 normalsize = bigsize;
3277 + (1 - f) * normalsize;
3278 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3279 f * (mi_min + mi_max) * 0.5
3280 + (1 - f) * view_origin);
3282 color1 = GetPlayerColor(player_localentnum-1);
3283 rgb = GetTeamRGB(color1);
3292 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3294 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3295 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3296 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3297 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, HUD_Panel_GetFgAlpha(id));
3298 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3300 color2 = GetPlayerColor(tm.sv_entnum);
3301 //if(color == COLOR_SPECTATOR || color == color2)
3302 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3304 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3306 drawresetcliparea();
3311 void HUD_Score(void)
3313 float id = HUD_PANEL_SCORE;
3315 pos = HUD_Panel_GetPos(id);
3316 mySize = HUD_Panel_GetSize(id);
3318 HUD_Panel_DrawBg(id, pos, mySize, 0);
3320 padding = HUD_Panel_GetPadding(id);
3323 pos += '1 1 0' * padding;
3324 mySize -= '2 2 0' * padding;
3327 float score, distribution, leader;
3328 float score_len, distr_len;
3329 vector distribution_color;
3331 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3333 // TODO... this (race part) still uses constant coordinates :/
3334 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3335 /*pl = players.sort_next;
3338 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3339 if(pl.scores[ps_primary] == 0)
3342 score = me.(scores[ps_primary]);
3344 float racemin, racesec, racemsec;
3345 float distsec, distmsec, minusplus;
3347 racemin = floor(score/(60 * TIME_FACTOR));
3348 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
3349 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
3351 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3352 // distribution display
3353 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3355 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
3356 distmsec = fabs(distribution);
3358 distsec = floor(fabs(distribution)/TIME_FACTOR);
3359 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
3360 if (distribution < 0)
3364 if (distribution <= 0) {
3365 distribution_color = eY;
3366 minusplus = 1; // minusplus 1: always prefix with minus sign
3369 distribution_color = eX;
3370 minusplus = 2; // minusplus 1: always prefix with plus sign
3372 HUD_DrawXNum(bottomright - '0 48 0' - '16 0 0' * TIME_DECIMALS, distmsec, -TIME_DECIMALS, 0, 16, distribution_color, 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3373 HUD_DrawXNum(bottomright - '68 48 0' - '16 0 0' * TIME_DECIMALS, distsec, 4, minusplus, 16, distribution_color, 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3374 drawpic_skin(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "num_dot", '16 16 0', distribution_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE);
3376 // race record display
3377 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
3378 drawpic_skin(bottomright - '0 32 0' - '32 0 0' * (4 + TIME_DECIMALS), "num_leading_4", '0 28 0' + '32 0 0' * (4 + TIME_DECIMALS), '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3380 HUD_DrawXNum(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0', racemsec, -TIME_DECIMALS, 0, 30, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3381 HUD_DrawXNum(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '66 0 0', racesec, -2, 0, 30, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3382 drawpic_skin(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '18 0 0', "num_dot", '30 30 0', '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE);
3384 HUD_DrawXNum(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '132 0 0', racemin, -2, 0, 30, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3385 drawpic_skin(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '84 0 0', "num_colon", '30 30 0', '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE);
3387 } else if (!teamplay) { // non-teamgames
3388 // me vector := [team/connected frags id]
3389 pl = players.sort_next;
3396 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3400 score = me.(scores[ps_primary]);
3404 if(distribution >= 5) {
3405 distribution_color = eY;
3407 } else if(distribution >= 0) {
3408 distribution_color = '1 1 1';
3410 } else if(distribution >= -5)
3411 distribution_color = '1 1 0';
3413 distribution_color = eX;
3415 score_len = strlen(ftos(score));
3416 distr_len = strlen(ftos(distribution));
3418 HUD_DrawXNum(pos + eX * mySize_x - eX * 3 * 0.33 * mySize_y, distribution, 3, 3, 0.33 * mySize_y, distribution_color, 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3420 drawpic_skin(pos + eX * mySize_x - eX * score_len * mySize_y - eX * 3 * 0.33 * mySize_y, strcat("num_leading_", ftos(score_len)), eX * score_len * mySize_y + eY * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3421 HUD_DrawXNum(pos + eX * mySize_x - eX * 3 * mySize_y - eX * 3 * 0.33 * mySize_y, score, 3, 0, mySize_y, distribution_color, 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3422 } else { // teamgames
3423 float max_fragcount;
3424 max_fragcount = -99;
3427 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3428 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !hud_configure)) // no players? don't display
3430 score = tm.(teamscores[ts_primary]);
3435 score_len = strlen(ftos(score));
3437 if (score > max_fragcount)
3438 max_fragcount = score;
3440 if(tm.team == myteam) {
3441 if (max_fragcount == score)
3444 drawpic_skin(pos + eX * mySize_x - eX * score_len * mySize_y - eX * 3 * 0.33 * mySize_y, strcat("num_leading_", ftos(score_len)), eX * score_len * mySize_y + eY * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3445 HUD_DrawXNum(pos + eX * mySize_x - eX * 3 * mySize_y - eX * 3 * 0.33 * mySize_y, score, 3, 0, mySize_y, GetTeamRGB(tm.team) * 0.8, 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3447 if (max_fragcount == score)
3450 drawpic_skin(pos + eX * mySize_x - eX * 0.33 * score_len * mySize_y + eY * 0.33 * mySize_y * teamnum, strcat("num_leading_", ftos(score_len)), eX * 0.33 * score_len * mySize_y + eY * 0.33 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3451 HUD_DrawXNum(pos + eX * mySize_x - eX * 3 * 0.33 * mySize_y + eY * 0.33 * mySize_y * teamnum, score, 3, 0, 0.33 * mySize_y, GetTeamRGB(tm.team) * 0.8, 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3460 void HUD_RaceTimer (void) {
3461 float id = HUD_PANEL_RACETIMER;
3463 pos = HUD_Panel_GetPos(id);
3464 mySize = HUD_Panel_GetSize(id);
3466 HUD_Panel_DrawBg(id, pos, mySize, 0);
3468 padding = HUD_Panel_GetPadding(id);
3471 pos += '1 1 0' * padding;
3472 mySize -= '2 2 0' * padding;
3475 drawfont = hud_bigfont;
3477 string s, forcetime;
3482 drawstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, FALSE, '0.60 0.60 0' * mySize_y), s, '0.60 0.60 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3483 s = "^1Intermediate 1 (+15.42)";
3484 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.20 * mySize_y) + eY * 0.60 * mySize_y, s, '1 1 0' * 0.20 * mySize_y, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3485 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3486 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.20 * mySize_y) + eY * 0.80 * mySize_y, s, '1 1 0' * 0.20 * mySize_y, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3488 else if(race_checkpointtime)
3490 a = bound(0, 2 - (time - race_checkpointtime), 1);
3493 if(a > 0) // just hit a checkpoint?
3495 if(race_checkpoint != 254)
3497 if(race_time && race_previousbesttime)
3498 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3500 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3502 forcetime = TIME_ENCODED_TOSTRING(race_time);
3507 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3509 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3510 if(a > 0) // next one?
3512 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3517 if(s != "" && a > 0)
3519 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3520 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3521 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3524 if(race_penaltytime)
3526 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3529 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3530 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3531 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3532 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.8 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3538 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3539 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id), 0, a);
3540 drawstring_expanding(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(forcetime, FALSE, '1 1 0' * 0.6 * mySize_y), forcetime, '1 1 0' * 0.6 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), 0, a);
3545 if(race_laptime && race_checkpoint != 255)
3547 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3548 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3549 drawstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, FALSE, '0.6 0.6 0' * mySize_y), s, '0.6 0.6 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3554 if(race_mycheckpointtime)
3556 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3557 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3558 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3559 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3560 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3562 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3564 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3565 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3566 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3567 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3568 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3571 if(race_penaltytime && !race_penaltyaccumulator)
3573 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3574 a = bound(0, (1 + t - time), 1);
3578 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3580 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3581 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3582 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3583 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3588 drawfont = hud_font;
3593 float vote_yescount;
3596 float vote_highlighted; // currently selected vote
3598 float vote_active; // is there an active vote?
3599 float vote_prev; // previous state of vote_active to check for a change
3601 float vote_change; // "time" when vote_active changed
3603 void HUD_VoteWindow(void)
3605 float id = HUD_PANEL_VOTE;
3607 pos = HUD_Panel_GetPos(id);
3608 mySize = HUD_Panel_GetSize(id);
3612 if(vote_active != vote_prev) {
3614 vote_prev = vote_active;
3617 if(vote_active || hud_configure)
3618 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3620 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3632 a = vote_alpha * bound(cvar_or("hud_vote_alreadyvoted_alpha", 0.75), 1 - vote_highlighted, 1);
3634 HUD_Panel_DrawBg(id, pos, mySize, a);
3636 padding = HUD_Panel_GetPadding(id);
3639 pos += '1 1 0' * padding;
3640 mySize -= '2 2 0' * padding;
3643 drawpic_skin(pos, "voteprogress_back", mySize, '1 1 1', a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3645 s = "A vote has been called for: ";
3646 drawstring(pos + '0.5 0 0' * mySize_x + '0 0.1 0' * mySize_y - eX * stringwidth(s, FALSE, '1 1 0' * 0.5 * mySize_y*(1/5)), s, '1 1 0' * mySize_y*(1/5), '1 1 1', a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3647 s = textShortenToWidth(vote_called_vote, mySize_x * 0.96, '1 1 0' * mySize_y*(1/5), stringwidth_colors); // TODO: broken?
3649 s = "Configure the HUD";
3650 drawcolorcodedstring(pos + '0.52 0 0' * mySize_x + '0 0.3 0' * mySize_y - eX * stringwidth(s, FALSE, '1 1 0' * 0.5 * mySize_y*(1/6)), s, '1 1 0' * mySize_y*(1/6), a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3652 // print the yes/no counts
3653 s = strcat("Yes: ", ftos(vote_yescount));
3654 drawstring(pos + '0 0.6 0' * mySize_y + '0.02 0 0' * mySize_x, s, '1 1 0' * mySize_y*(1/6) , eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3655 s = strcat("No: ", ftos(vote_nocount));
3656 drawstring(pos + '0 0.6 0' * mySize_y + '0.98 0 0' * mySize_x - eX * stringwidth(s, FALSE, '1 1 0' * mySize_y*(1/6)), s, '1 1 0' * mySize_y*(1/6), eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3658 // draw the progress bars
3659 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3660 drawpic_skin(pos, "voteprogress_prog", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3662 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3663 drawpic_skin(pos, "voteprogress_prog", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3665 // draw the highlights
3666 if(vote_highlighted == 1) {
3667 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3668 drawpic_skin(pos, "voteprogress_voted", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3670 else if(vote_highlighted == 2) {
3671 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3672 drawpic_skin(pos, "voteprogress_voted", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3675 drawresetcliparea();
3678 vote_highlighted = 0;
3682 // Mod icons panel (#10)
3685 float mod_active; // is there any active mod icon?
3687 // CTF HUD modicon section
3688 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3689 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3690 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3692 void HUD_Mod_CTF_Reset(void)
3694 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3697 void HUD_Mod_CTF(vector pos, vector mySize)
3699 vector redflag_pos, blueflag_pos;
3701 float f; // every function should have that
3703 float redflag, blueflag; // current status
3704 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3707 stat_items = getstati(STAT_ITEMS);
3708 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3709 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3711 if(redflag || blueflag)
3722 // when status CHANGES, set old status into prevstatus and current status into status
3723 if (redflag != redflag_prevframe)
3725 redflag_statuschange_time = time;
3726 redflag_prevstatus = redflag_prevframe;
3727 redflag_prevframe = redflag;
3730 if (blueflag != blueflag_prevframe)
3732 blueflag_statuschange_time = time;
3733 blueflag_prevstatus = blueflag_prevframe;
3734 blueflag_prevframe = blueflag;
3737 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3738 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3740 float BLINK_FACTOR = 0.15;
3741 float BLINK_BASE = 0.85;
3743 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3745 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3747 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3749 string red_icon, red_icon_prevstatus;
3750 float red_alpha, red_alpha_prevstatus;
3751 red_alpha = red_alpha_prevstatus = 1;
3753 case 1: red_icon = "flag_red_taken"; break;
3754 case 2: red_icon = "flag_red_lost"; break;
3755 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3757 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3758 red_icon = "flag_red_shielded";
3760 red_icon = string_null;
3763 switch(redflag_prevstatus) {
3764 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3765 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3766 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3769 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3770 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3771 red_icon_prevstatus = "flag_red_shielded";
3773 red_icon_prevstatus = string_null;
3777 string blue_icon, blue_icon_prevstatus;
3778 float blue_alpha, blue_alpha_prevstatus;
3779 blue_alpha = blue_alpha_prevstatus = 1;
3781 case 1: blue_icon = "flag_blue_taken"; break;
3782 case 2: blue_icon = "flag_blue_lost"; break;
3783 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3785 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3786 blue_icon = "flag_blue_shielded";
3788 blue_icon = string_null;
3791 switch(blueflag_prevstatus) {
3792 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3793 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3794 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3797 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3798 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3799 blue_icon_prevstatus = "flag_blue_shielded";
3801 blue_icon_prevstatus = string_null;
3805 if(mySize_x > mySize_y) {
3806 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3808 blueflag_pos = pos + eX * 0.5 * mySize_x;
3811 redflag_pos = pos + eX * 0.5 * mySize_x;
3813 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3815 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3817 blueflag_pos = pos + eY * 0.5 * mySize_y;
3820 redflag_pos = pos + eY * 0.5 * mySize_y;
3822 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3825 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3826 if(red_icon_prevstatus && f < 1)
3827 drawpic_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3829 drawpic_skin(redflag_pos, red_icon, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * red_alpha * f, DRAWFLAG_NORMAL);
3831 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3832 if(blue_icon_prevstatus && f < 1)
3833 drawpic_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3835 drawpic_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * blue_alpha * f, DRAWFLAG_NORMAL);
3838 // Keyhunt HUD modicon section
3839 float kh_runheretime;
3841 void HUD_Mod_KH_Reset(void)
3846 void HUD_Mod_KH(vector pos, vector mySize)
3848 mod_active = 1; // keyhunt should never hide the mod icons panel
3852 vector p, pa, kh_size, kh_asize;
3854 kh_keys = getstati(STAT_KH_KEYS);
3857 if(mySize_x > mySize_y)
3859 p_y = pos_y + 0.25 * mySize_y;
3860 pa = p - eY * 0.25 * mySize_y;
3862 kh_size_x = mySize_x * 0.25;
3863 kh_size_y = 0.75 * mySize_y;
3864 kh_asize_x = mySize_x * 0.25;
3865 kh_asize_y = mySize_y * 0.25;
3869 p_y = pos_y + 0.125 * mySize_y;
3870 pa = p - eY * 0.125 * mySize_y;
3872 kh_size_x = mySize_x * 0.5;
3873 kh_size_y = 0.375 * mySize_y;
3874 kh_asize_x = mySize_x * 0.5;
3875 kh_asize_y = mySize_y * 0.125;
3882 for(i = 0; i < 4; ++i)
3884 key = floor(kh_keys / pow(32, i)) & 31;
3886 if(keyteam == 30 && keycount <= 4)
3888 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3892 // this yields 8 exactly if "RUN HERE" shows
3897 kh_runheretime = time;
3898 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3903 for(i = 0; i < 4; ++i)
3905 key = floor(kh_keys / pow(32, i)) & 31;
3918 default: // owned or dropped
3923 a = a * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3924 aa = aa * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3930 drawpic_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3933 drawpic_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3936 drawpic_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3939 drawpic_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3944 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3947 drawpic_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3950 drawpic_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3953 drawpic_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3956 drawpic_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3960 if(mySize_x > mySize_y)
3962 p_x += 0.25 * mySize_x;
3963 pa_x += 0.25 * mySize_x;
3969 p_y = pos_y + 0.625 * mySize_y;
3970 pa_y = pos_y + 0.5 * mySize_y;
3976 p_x += 0.5 * mySize_x;
3977 pa_x += 0.5 * mySize_x;
3983 // Nexball HUD mod icon
3984 void HUD_Mod_NexBall(vector pos, vector mySize)
3986 float stat_items, nb_pb_starttime, dt, p;
3988 stat_items = getstati(STAT_ITEMS);
3989 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3991 if (stat_items & IT_KEY1)
3996 //Manage the progress bar if any
3997 if (nb_pb_starttime > 0)
3999 dt = mod(time - nb_pb_starttime, nb_pb_period);
4000 // one period of positive triangle
4001 p = 2 * dt / nb_pb_period;
4008 if(mySize_x > mySize_y)
4010 barsize = eX * p * mySize_x + eY * mySize_y;
4015 barsize = eX * mySize_x + eY * p * mySize_y;
4018 HUD_Panel_DrawProgressBar(pos, vertical, barsize, HUD_Panel_GetProgressBarColor("nexball"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4021 if (stat_items & IT_KEY1)
4022 drawpic_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4025 // Race/CTS HUD mod icons
4026 float crecordtime_prev; // last remembered crecordtime
4027 float crecordtime_change_time; // time when crecordtime last changed
4028 float srecordtime_prev; // last remembered srecordtime
4029 float srecordtime_change_time; // time when srecordtime last changed
4031 float race_status_time;
4032 float race_status_prev;
4033 string race_status_name_prev;
4034 void HUD_Mod_Race(vector pos, vector mySize)
4036 mod_active = 1; // race should never hide the mod icons panel
4038 me = playerslots[player_localentnum - 1];
4040 float f; // yet another function has this
4041 score = me.(scores[ps_primary]);
4043 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
4044 return; // no records in the actual race
4046 drawfont = hud_bigfont;
4048 // clientside personal record
4050 if(gametype == GAME_CTS)
4054 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4056 if(score && (score < t || !t)) {
4057 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4058 if(cvar("cl_autodemo_delete_keeprecords"))
4060 f = cvar("cl_autodemo_delete");
4062 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4066 if(t != crecordtime_prev) {
4067 crecordtime_prev = t;
4068 crecordtime_change_time = time;
4070 f = time - crecordtime_change_time;
4073 drawstring_aspect(pos, "Personal best ", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4074 drawstring(pos + eY * 0.2 * mySize_y, TIME_ENCODED_TOSTRING(t), '1 1 0' * 0.2 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4076 drawstring(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4077 drawstring(pos + eY * 0.2 * mySize_y, TIME_ENCODED_TOSTRING(t), '1 1 0' * 0.2 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4078 drawstring_expanding(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL, f);
4079 drawstring_expanding(pos + eY * 0.2 * mySize_y, TIME_ENCODED_TOSTRING(t), '1 1 0' * 0.2 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL, f);
4083 t = race_server_record;
4084 if(t != srecordtime_prev) {
4085 srecordtime_prev = t;
4086 srecordtime_change_time = time;
4088 f = time - srecordtime_change_time;
4091 drawstring(pos + eY * 0.5 * mySize_y, "Server best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4092 drawstring(pos + eY * 0.5 * mySize_y + eY * 0.2 * mySize_y, TIME_ENCODED_TOSTRING(t),'1 1 0' * 0.2 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4094 drawstring(pos + eY * 0.5 * mySize_y, "Server best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4095 drawstring(pos + eY * 0.5 * mySize_y + eY * 0.2 * mySize_y, TIME_ENCODED_TOSTRING(t),'1 1 0' * 0.2 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4096 drawstring_expanding(pos + eY * 0.5 * mySize_y, "Server best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL, f);
4097 drawstring_expanding(pos + eY * 0.5 * mySize_y + eY * 0.2 * mySize_y, TIME_ENCODED_TOSTRING(t),'1 1 0' * 0.2 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL, f);
4100 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4101 race_status_time = time + 5;
4102 race_status_prev = race_status;
4103 if (race_status_name_prev)
4104 strunzone(race_status_name_prev);
4105 race_status_name_prev = strzone(race_status_name);
4108 pos_x += mySize_x/2;
4111 a = bound(0, race_status_time - time, 1);
4114 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4118 rank = race_CheckName(race_status_name);
4120 rankname = race_PlaceName(rank);
4123 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4125 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4127 if(race_status == 0)
4128 drawpic_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4129 else if(race_status == 1) {
4130 drawpic_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4131 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4132 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4133 } else if(race_status == 2) {
4134 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4135 drawpic_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4137 drawpic_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4138 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4139 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4140 } else if(race_status == 3) {
4141 drawpic_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4142 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4143 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4146 if (race_status_time - time <= 0) {
4147 race_status_prev = -1;
4149 if(race_status_name)
4150 strunzone(race_status_name);
4151 race_status_name = string_null;
4152 if(race_status_name_prev)
4153 strunzone(race_status_name_prev);
4154 race_status_name_prev = string_null;
4156 drawfont = hud_font;
4159 float mod_prev; // previous state of mod_active to check for a change
4161 float mod_change; // "time" when mod_active changed
4163 void HUD_ModIcons(void)
4165 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !hud_configure)
4168 float id = HUD_PANEL_MODICONS;
4170 pos = HUD_Panel_GetPos(id);
4171 mySize = HUD_Panel_GetSize(id);
4173 if(mod_active != mod_prev) {
4175 mod_prev = mod_active;
4178 if(mod_active || hud_configure)
4179 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4181 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4184 HUD_Panel_DrawBg(id, pos, mySize, mod_alpha);
4187 padding = HUD_Panel_GetPadding(id);
4190 pos += '1 1 0' * padding;
4191 mySize -= '2 2 0' * padding;
4194 // these MUST be ran in order to update mod_active
4195 if(gametype == GAME_KEYHUNT)
4196 HUD_Mod_KH(pos, mySize);
4197 else if(gametype == GAME_CTF || hud_configure)
4198 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4199 else if(gametype == GAME_NEXBALL)
4200 HUD_Mod_NexBall(pos, mySize);
4201 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4202 HUD_Mod_Race(pos, mySize);
4205 // Draw pressed keys (#11)
4207 void HUD_DrawPressedKeys(void)
4209 float id = HUD_PANEL_PRESSEDKEYS;
4211 pos = HUD_Panel_GetPos(id);
4212 mySize = HUD_Panel_GetSize(id);
4214 HUD_Panel_DrawBg(id, pos, mySize, 0);
4216 padding = HUD_Panel_GetPadding(id);
4219 pos += '1 1 0' * padding;
4220 mySize -= '2 2 0' * padding;
4224 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4227 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4228 drawpic_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4229 drawpic_skin(pos + eX * mySize_x * (1/3), ((pressedkeys & KEY_FORWARD) ? "key_forward_inv.tga" : "key_forward.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4230 drawpic_skin(pos + eX * mySize_x * (2/3), ((pressedkeys & KEY_JUMP) ? "key_jump_inv.tga" : "key_jump.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4231 drawpic_skin(pos + eY * 0.5 * mySize_y, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4232 drawpic_skin(pos + eY * 0.5 * mySize_y + eX * mySize_x * (1/3), ((pressedkeys & KEY_BACKWARD) ? "key_backward_inv.tga" : "key_backward.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4233 drawpic_skin(pos + eY * 0.5 * mySize_y + eX * mySize_x * (2/3), ((pressedkeys & KEY_RIGHT) ? "key_right_inv.tga" : "key_right.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4236 // Handle chat as a panel (#12)
4240 float id = HUD_PANEL_CHAT;
4242 pos = HUD_Panel_GetPos(id);
4243 mySize = HUD_Panel_GetSize(id);
4245 HUD_Panel_DrawBg(id, pos, mySize, 0);
4247 padding = HUD_Panel_GetPadding(id);
4250 pos += '1 1 0' * padding;
4251 mySize -= '2 2 0' * padding;
4254 cvar_set("con_chatrect", "1");
4256 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4257 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4259 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4260 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4265 chatsize = cvar("con_chatsize");
4266 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4268 for(i = 0; i < cvar("con_chat"); ++i)
4270 if(i == cvar("con_chat") - 1)
4271 a = HUD_Panel_GetFgAlpha(id);
4273 a = HUD_Panel_GetFgAlpha(id) * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4274 drawcolorcodedstring(pos + eY * i * chatsize, textShortenToWidth("^3Player^7: This is the chat area.", mySize_x, '1 1 0' * chatsize, stringwidth_colors), '1 1 0' * chatsize, a, DRAWFLAG_NORMAL);
4279 // Engine info panel (#13)
4286 float frametimeavg1; // 1 frame ago
4287 float frametimeavg2; // 2 frames ago
4288 void HUD_EngineInfo(void)
4290 float id = HUD_PANEL_ENGINEINFO;
4292 pos = HUD_Panel_GetPos(id);
4293 mySize = HUD_Panel_GetSize(id);
4295 HUD_Panel_DrawBg(id, pos, mySize, 0);
4297 padding = HUD_Panel_GetPadding(id);
4300 pos += '1 1 0' * padding;
4301 mySize -= '2 2 0' * padding;
4304 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4306 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4307 frametimeavg2 = frametimeavg1;
4308 frametimeavg1 = frametimeavg;
4311 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4312 if(frametime > 0.0001) // filter out insane values which sometimes seem to occur and throw off the average? If you are getting 10,000 fps or more, then you don't need a framerate counter.
4314 if(fabs(prevfps - (1/frametimeavg)) > prevfps * cvar("hud_engineinfo_framecounter_exponentialmovingaverage_instantupdate_change_threshold")) // if there was a big jump in fps, just force prevfps at current (1/frametime) to make big updates instant
4315 prevfps = (1/frametime);
4316 prevfps = (1 - weight) * prevfps + weight * (1/frametimeavg); // framecounter just used so there's no need for a new variable, think of it as "frametime average"
4322 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4324 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4326 prevfps_time = time;
4331 color = HUD_Get_Num_Color (prevfps, 100);
4332 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), mySize, mySize_y, color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4340 void HUD_ShowSpeed(void)
4343 float pos, conversion_factor;
4344 string speed, zspeed, unit;
4346 switch(cvar("cl_showspeed_unit"))
4351 conversion_factor = 1.0;
4355 conversion_factor = 1.0;
4359 conversion_factor = 0.0254;
4363 conversion_factor = 0.0254 * 3.6;
4367 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4371 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4375 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4377 numsize_x = numsize_y = cvar("cl_showspeed_size");
4378 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4380 drawfont = hud_bigfont;
4381 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4383 if (cvar("cl_showspeed_z") == 1) {
4384 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4385 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4388 drawfont = hud_font;
4391 vector acc_prevspeed;
4395 void HUD_ShowAcceleration(void)
4397 float acceleration, sz, scale, alpha, f;
4398 vector pos, top, rgb;
4399 top_x = vid_conwidth/2;
4402 f = time - acc_prevtime;
4403 if(cvar("cl_showacceleration_z"))
4404 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4406 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4407 acc_prevspeed = pmove_vel;
4408 acc_prevtime = time;
4410 f = bound(0, f * 10, 1);
4411 acc_avg = acc_avg * (1 - f) + acceleration * f;
4412 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4414 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4416 sz = cvar("cl_showacceleration_size");
4417 scale = cvar("cl_showacceleration_scale");
4418 alpha = cvar("cl_showacceleration_alpha");
4419 if (cvar("cl_showacceleration_color_custom"))
4420 rgb = stov(cvar_string("cl_showacceleration_color"));
4423 if (acceleration < 0) {
4424 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4425 } else if (acceleration > 0) {
4426 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4430 if (acceleration > 0)
4431 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4432 else if (acceleration < 0)
4433 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4436 void HUD_Reset (void)
4438 // reset gametype specific icons
4439 if(gametype == GAME_KEYHUNT)
4441 else if(gametype == GAME_CTF)
4442 HUD_Mod_CTF_Reset();
4445 void HUD_Main (void)
4447 if(disable_menu_alphacheck == 1)
4448 menu_fade_alpha = 1;
4450 menu_fade_alpha = (1 - cvar("_menu_alpha"));
4451 hud_fg_alpha = cvar("hud_fg_alpha");
4453 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4454 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4455 hud_color_bg_team = cvar("hud_color_bg_team");
4457 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4458 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4460 hud_configure = cvar("_hud_configure");
4464 // HUD configure visible grid
4465 if(hud_configure && cvar("hud_configure_grid") && cvar("hud_configure_grid_alpha"))
4469 for(i = 0; i < 1/bound(0.005, cvar("hud_configure_grid_x"), 0.2); ++i)
4471 drawfill(eX * i * vid_conwidth * bound(0.005, cvar("hud_configure_grid_x"), 0.2), eX + eY * vid_conheight, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
4474 for(i = 0; i < 1/bound(0.005, cvar("hud_configure_grid_y"), 0.2); ++i)
4476 drawfill(eY * i * vid_conheight * bound(0.005, cvar("hud_configure_grid_y"), 0.2), eY + eX * vid_conwidth, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
4480 if(cvar_string("hud_dock") != "")
4481 drawpic('0 0 0', strcat("gfx/hud/", cvar_string("hud_skin"), "/", cvar_string("hud_dock")), eX * vid_conwidth + eY * vid_conheight, HUD_Panel_Dock_GetColor(), cvar("hud_dock_alpha") * menu_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
4483 if(HUD_Panel_CheckActive(HUD_PANEL_RADAR) || hud_configure)
4484 if(cvar_string("hud_radar") != "0" && (cvar("hud_radar") == 2 || teamplay))
4486 if(HUD_Panel_CheckActive(HUD_PANEL_WEAPONICONS) || hud_configure)
4488 if(HUD_Panel_CheckActive(HUD_PANEL_INVENTORY) || hud_configure)
4490 if(HUD_Panel_CheckActive(HUD_PANEL_POWERUPS) || hud_configure)
4492 if(HUD_Panel_CheckActive(HUD_PANEL_HEALTHARMOR) || hud_configure)
4494 if(HUD_Panel_CheckActive(HUD_PANEL_NOTIFY) || hud_configure)
4496 if(HUD_Panel_CheckActive(HUD_PANEL_TIMER) || hud_configure)
4498 if(HUD_Panel_CheckActive(HUD_PANEL_SCORE) || hud_configure)
4500 if(HUD_Panel_CheckActive(HUD_PANEL_RACETIMER) || hud_configure)
4501 if(gametype == GAME_RACE || gametype == GAME_CTS || hud_configure)
4503 if(HUD_Panel_CheckActive(HUD_PANEL_VOTE) || hud_configure)
4505 if(HUD_Panel_CheckActive(HUD_PANEL_MODICONS) || hud_configure)
4508 if(HUD_Panel_CheckActive(HUD_PANEL_PRESSEDKEYS) || hud_configure)
4509 if(spectatee_status > 0 || cvar("hud_pressedkeys") >= 2 || hud_configure)
4510 HUD_DrawPressedKeys();
4511 if(HUD_Panel_CheckActive(HUD_PANEL_CHAT) || hud_configure)
4514 cvar_set("con_chatrect", "0");
4515 if(HUD_Panel_CheckActive(HUD_PANEL_ENGINEINFO) || hud_configure)
4518 // TODO hud_'ify these
4519 if (cvar("cl_showspeed"))
4521 if (cvar("cl_showacceleration"))
4522 HUD_ShowAcceleration();
4524 if (hud_configure && spectatee_status) // try to join if we are in hud_configure mode, but still spectating (in order to get rid of motd and such)
4525 localcmd("cmd selectteam auto; cmd join\n");
4527 if (!hud_configure) // hud config mode disabled, enable normal alpha stuff again
4528 disable_menu_alphacheck = 0;