7 // a border picture is a texture containing nine parts:
8 // 1/4 width: left part
9 // 1/2 width: middle part (stretched)
10 // 1/4 width: right part
12 // 1/4 height: top part
13 // 1/2 height: middle part (stretched)
14 // 1/4 height: bottom part
15 void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize)
20 //pic = draw_UseSkinFor(pic);
21 width = eX * theSize_x;
22 height = eY * theSize_y;
23 if(theSize_x <= theBorderSize_x * 2)
25 // not wide enough... draw just left and right then
26 bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
27 if(theSize_y <= theBorderSize_y * 2)
29 // not high enough... draw just corners
30 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
31 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
32 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
33 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
34 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
38 dY = theBorderSize_x * eY;
39 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
40 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
41 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
42 drawsubpic(theOrigin + width * 0.5 + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0' + eX - bW, '0 0.5 0' + bW, theColor, theAlpha, 0);
43 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
44 drawsubpic(theOrigin + width * 0.5 + height - dY, width * 0.5 + dY, pic, '0 0.75 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
49 if(theSize_y <= theBorderSize_y * 2)
51 // not high enough... draw just top and bottom then
52 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
53 dX = theBorderSize_x * eX;
54 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
55 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
56 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
57 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
58 drawsubpic(theOrigin + dX + height * 0.5, width - 2 * dX + height * 0.5, pic, '0.25 0 0' + eY - bH, '0.5 0 0' + bH, theColor, theAlpha, 0);
59 drawsubpic(theOrigin + width - dX + height * 0.5, dX + height * 0.5, pic, '0.75 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
63 dX = theBorderSize_x * eX;
64 dY = theBorderSize_x * eY;
65 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
66 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
67 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
68 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
69 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
70 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
71 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
72 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
73 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
78 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
79 void drawpic_skin(vector pos, string pic, vector sz, vector color, float alpha, float drawflag) {
80 drawpic(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, color, alpha, drawflag);
83 void drawpic_skin_expanding(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
84 drawpic_expanding(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
87 void drawpic_skin_expanding_two(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
88 drawpic_expanding_two(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
91 // return HUD background color
92 vector HUD_GetBgColor()
96 GetTeamRGB(myteam) * hud_color_bg_team;
98 // allow custom HUD colors in non-teamgames
99 color_x = cvar("hud_color_bg_r");
100 color_y = cvar("hud_color_bg_g");
101 color_z = cvar("hud_color_bg_b");
106 // return accuracy text color
107 vector HUD_AccuracyColor(float accuracy)
110 float yellow_accuracy = cvar("hud_weaponicons_accuracy_yellow"); // value at which this function returns yellow
111 if(accuracy >= 100) {
115 else if(accuracy > yellow_accuracy) {
116 rgb_x = 1 - (accuracy-yellow_accuracy)/(100-yellow_accuracy); // red value between 1 -> 0
121 rgb_y = accuracy/yellow_accuracy; // green value between 0 -> 1
127 // draw number in the XSCALE font
128 void HUD_DrawXNum (vector pos, float num, float digits, float showsign, float lettersize, vector rgb, float highlighted, float stroke, float alpha, float dflags)
131 string str, tmp, l_length;
133 vector vsize, num_color;
135 vsize_x = vsize_y = lettersize;
138 // showsign 1: always prefix with minus sign (useful in race distribution display)
139 // showsign 2: always prefix with plus sign (useful in race distribution display)
140 // showsign 3: prefix with minus sign if negative, plus sign if positive (useful in score distribution display)
142 if((showsign == 2 && num >= 0) || (num > 0 && showsign == 3))
149 if(num < 0 || (num < 0 && showsign == 3) || (showsign == 1 && num <= 0))
161 str = strcat(substring("0000000000", 0, digits - strlen(tmp)), tmp);
170 str = substring(str, l-digits, 999);
172 } else if(l < digits)
173 pos_x += (digits-l) * lettersize;
175 if (highlighted == 1) {
177 hl_size_x = vsize_x * l + vsize_x * 0.2;
178 hl_size_y = vsize_y * 1.1;
181 hl_size_x = hl_size_x + vsize_x;
184 hl_pos_x = pos_x - lettersize/10;
185 hl_pos_y = pos_y - lettersize/20;
188 drawpic_skin(hl_pos, strcat("num_leading_", l_length), hl_size, '1 1 1', alpha, dflags);
199 drawpic_skin(pos, "num_minus_stroke", vsize, rgb, alpha, dflags);
200 drawpic_skin(pos, "num_minus", vsize, num_color, alpha, dflags);
205 drawpic_skin(pos, "num_plus_stroke", vsize, rgb, alpha, dflags);
206 drawpic_skin(pos, "num_plus", vsize, num_color, alpha, dflags);
210 for(i = 0; i < l; ++i)
212 tmp = substring(str, i, 1);
214 drawpic_skin(pos, strcat("num_", tmp, "_stroke"), vsize, rgb, alpha, dflags);
215 drawpic_skin(pos, strcat("num_", tmp), vsize, num_color, alpha, dflags);
220 vector HUD_Get_Num_Color (float x, float maxvalue)
228 else if(x > maxvalue * 0.75) {
229 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
230 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
233 else if(x > maxvalue * 0.5) {
234 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
235 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
236 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
238 else if(x > maxvalue * 0.25) {
241 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
243 else if(x > maxvalue * 0.1) {
245 color_y = (x-20)*90/27/100; // green value between 0 -> 1
246 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
255 // color the number differently based on how big it is (used in the health/armor panel)
256 void HUD_DrawXNum_Colored (vector pos, float x, float digits, float lettersize, float alpha)
259 color = HUD_Get_Num_Color (x, 200);
260 HUD_DrawXNum(pos, x, digits, 0, lettersize, color, 0, 0, alpha, DRAWFLAG_NORMAL);
263 float stringwidth_colors(string s, vector theSize)
265 return stringwidth(s, TRUE, theSize);
268 float stringwidth_nocolors(string s, vector theSize)
270 return stringwidth(s, FALSE, theSize);
273 #define CENTERPRINT_MAX_LINES 30
274 string centerprint_messages[CENTERPRINT_MAX_LINES];
275 float centerprint_width[CENTERPRINT_MAX_LINES];
276 vector centerprint_start;
277 float centerprint_expire;
278 float centerprint_num;
279 float centerprint_offset_hint;
280 vector centerprint_fontsize;
282 void centerprint(string strMessage)
284 float i, j, n, hcount;
287 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
289 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
291 if(cvar("scr_centertime") <= 0)
297 // strip trailing newlines
298 j = strlen(strMessage) - 1;
299 while(substring(strMessage, j, 1) == "\n" && j >= 0)
301 strMessage = substring(strMessage, 0, j + 1);
306 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
308 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
310 strMessage = substring(strMessage, j, strlen(strMessage) - j);
311 centerprint_offset_hint = j;
316 // if we get here, we have a message. Initialize its height.
319 n = tokenizebyseparator(strMessage, "\n");
321 for(j = 0; j < n; ++j)
323 getWrappedLine_remaining = argv(j);
324 while(getWrappedLine_remaining)
326 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
327 if(centerprint_messages[i])
328 strunzone(centerprint_messages[i]);
329 centerprint_messages[i] = strzone(s);
330 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
333 // half height for empty lines looks better
339 if(i >= CENTERPRINT_MAX_LINES)
345 h = centerprint_fontsize_y*hcount;
347 havail = vid_conheight;
348 if(cvar("con_chatpos") < 0)
349 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
350 if(havail > vid_conheight - 70)
351 havail = vid_conheight - 70; // avoid overlapping HUD
353 centerprint_start_x = 0;
356 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
358 // here, the centerprint would cover the crosshair. REALLY BAD.
359 forbiddenmin = vid_conheight * 0.5 - h - 16;
360 forbiddenmax = vid_conheight * 0.5 + 16;
362 allowedmin = scoreboard_bottom;
363 allowedmax = havail - h;
364 preferred = (havail - h)/2;
367 // possible orderings (total: 4! / 4 = 6)
368 // allowedmin allowedmax forbiddenmin forbiddenmax
369 // forbiddenmin forbiddenmax allowedmin allowedmax
370 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
372 // forbidden doesn't matter in this case
373 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
375 // allowedmin forbiddenmin allowedmax forbiddenmax
376 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
378 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
380 // allowedmin forbiddenmin forbiddenmax allowedmax
381 else if(allowedmin < forbiddenmin)
383 // make sure the forbidden zone is not covered
384 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
385 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
387 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
389 // forbiddenmin allowedmin allowedmax forbiddenmax
390 else if(allowedmax < forbiddenmax)
392 // it's better to leave the allowed zone (overlap with scoreboard) than
393 // to cover the forbidden zone (crosshair)
394 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
395 centerprint_start_y = forbiddenmax;
397 centerprint_start_y = forbiddenmin;
399 // forbiddenmin allowedmin forbiddenmax allowedmax
402 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
405 centerprint_start_y =
408 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
416 centerprint_expire = time + cvar("scr_centertime");
419 void HUD_DrawCenterPrint (void)
426 //if(time > centerprint_expire)
429 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
430 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
431 //sz = 1.2 / (a + 0.2);
436 pos = centerprint_start;
437 for (i=0; i<centerprint_num; i = i + 1)
439 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
440 ts = centerprint_messages[i];
443 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
444 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
445 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
446 pos_y = pos_y + centerprint_fontsize_y;
449 // half height for empty lines looks better
450 pos_y = pos_y + centerprint_fontsize_y * 0.5;
454 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
456 position_x -= 2 / 3 * strlen(text) * scale_x;
457 drawstring(position, text, scale, rgb, alpha, flag);
460 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
462 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
463 drawstring(position, text, scale, rgb, alpha, flag);
466 // return the string of the given race place
467 string race_PlaceName(float pos) {
475 return strcat(ftos(pos), "th");
478 // return the string of the onscreen race timer
479 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
487 if(histime == 0) // goal hit
491 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
501 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
507 lapstr = strcat(" (-", ftos(lapdelta), "L)");
510 else if(lapdelta < 0)
512 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
516 else if(histime > 0) // anticipation
518 if(mytime >= histime)
519 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
521 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
528 cpname = "Start line";
530 cpname = "Finish line";
532 cpname = strcat("Intermediate ", ftos(cp));
534 cpname = "Finish line";
537 return strcat(col, cpname);
538 else if(hisname == "")
539 return strcat(col, cpname, " (", timestr, ")");
541 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
544 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
545 float race_CheckName(string net_name) {
547 for (i=RANKINGS_CNT-1;i>=0;--i)
548 if(grecordholder[i] == net_name)
560 void HUD_Panel_ExportCfg(string cfgname)
563 fh = fopen(strcat("hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg"), FILE_WRITE);
566 fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
567 fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
568 fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
569 fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
570 fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
571 fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
572 fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
573 fputs(fh, strcat("seta hud_fg_alpha \"", cvar_string("hud_fg_alpha"), "\"", "\n"));
576 fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
577 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
578 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
579 fputs(fh, strcat("seta hud_dock_alpha \"", ftos(cvar("hud_dock_alpha")), "\"", "\n"));
582 fputs(fh, strcat("seta hud_progressbar_alpha ", ftos(cvar("hud_progressbar_alpha")), "\n"));
583 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
584 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
585 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
586 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
587 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
588 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
591 // common cvars for all panels
593 for (i = 0; i < HUD_PANEL_NUM; ++i)
595 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), " ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i)))), "\n"));
596 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_pos \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_pos")), "\"", "\n"));
597 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_size \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_size")), "\"", "\n"));
598 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg")), "\"", "\n"));
599 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color")), "\"", "\n"));
600 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color_team \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color_team")), "\"", "\n"));
601 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_alpha \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_alpha")), "\"", "\n"));
602 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_border \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_border")), "\"", "\n"));
603 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_padding \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_padding")), "\"", "\n"));
606 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_accuracy_yellow ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_accuracy_yellow"))), "\n"));
609 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_onlycurrent ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_onlycurrent"))), "\n"));
612 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
613 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_mirror ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
616 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
617 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_mirror ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
620 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
621 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_info_top ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_info_top"))), "\n"));
624 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_foreground_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_foreground_alpha"))), "\n"));
626 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha"))), "\n"));
632 print("^2Successfully exported to hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
637 vector HUD_Panel_GetMinSize(float id)
640 // note: please only set mySize_y on aspect ratio forced panels
643 mySize_x = 1/10; // at least 1/10 * height
644 mySize_y = 1/26; // at least 1/26 * width
647 if(cvar("hud_inventory_onlycurrent"))
648 mySize_y = 2/5; // 2/5 width
650 mySize_x = 0.7; // at least 0.7 * height
653 if(cvar("hud_healtharmor") == 2)
655 mySize_x = 4.35; // 4.35 * height, trial and error...
656 mySize_y = 0.01; // "unlimited" ;)
660 mySize_x = 1.1; // 4/5 * height, trial and error...
661 mySize_y = 1/3; // 1/3 * width, trial and error...
664 mySize_y = 1/4.1; // 1/4.1 * width, trial and error...
667 mySize_y = 1/4; // 1/4 * width
670 mySize_y = 1/4; // 1/4 * width
673 mySize_y = 1/4; // 1/4 * width
676 mySize_y = 1/2; // 1/2 * width
679 mySize_y = 0.5898; // 0.5898 * width, reason: bg has weird dimensions...
682 mySize_y = 0.25; // 0.25 * width, trial and error...
688 // return active status of panel
689 float HUD_Panel_CheckActive(float id)
691 if (cvar_or(strcat("hud_", HUD_Panel_GetName(id)), 1))
696 // return size of given panel
697 vector HUD_Panel_GetSize(float id)
700 mySize = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_size")));
702 mySize = eX * mySize_x * vid_conwidth + eY * mySize_y * vid_conheight;
704 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
706 vector menu_enable_maxsize, menu_enable_size;
707 menu_enable_maxsize = '0 0 0'; // shut up FTEQCC
708 menu_enable_maxsize_x = 0.3 * vid_conwidth;
709 menu_enable_maxsize_y = 0.18 * vid_conheight;
710 if(mySize_x > mySize_y)
712 if(mySize_y > menu_enable_maxsize_y)
714 menu_enable_size_y = menu_enable_maxsize_y;
715 menu_enable_size_x = mySize_x * (menu_enable_maxsize_y/mySize_y);
716 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
721 if(mySize_x > menu_enable_maxsize_x)
723 menu_enable_size_x = menu_enable_maxsize_x;
724 menu_enable_size_y = mySize_y * (menu_enable_maxsize_x/mySize_x);
725 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
732 // return pos of given panel
733 vector HUD_Panel_GetPos(float id)
736 pos = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_pos")));
738 pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
740 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
742 vector mySize, menu_enable_panelpos;
743 mySize = HUD_Panel_GetSize(id);
744 if(mySize_x > mySize_y)
745 menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * mySize_x + eY * 0.82 * vid_conheight;
747 menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * mySize_y + eX * 0.7 * vid_conwidth;
748 pos = (1 - cvar("_menu_alpha")) * pos + (cvar("_menu_alpha")) * menu_enable_panelpos;
753 float HUD_Panel_GetBorder(float id)
756 border = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_border"));
758 border = cvar_string("hud_bg_border");
762 vector HUD_Panel_GetColor(float id)
768 // fetch per-panel color
769 if(teamplay && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")) != "") {
770 f = stof(getplayerkey(self.sv_entnum, "colors"));
771 color = vtos(colormapPaletteColor(mod(f, 16), 1) * cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")));
774 color = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color"));
775 color_vec = stov(color);
777 if(color == "") { // fetch default color
778 color = cvar_string("hud_bg_color");
779 color_vec = stov(color);
780 if(teamplay && cvar(strcat("hud_bg_color_team"))) {
781 f = stof(getplayerkey(self.sv_entnum, "colors"));
782 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_bg_color_team");
784 else if(color == "shirt") {
785 f = stof(getplayerkey(self.sv_entnum, "colors"));
786 color_vec = colormapPaletteColor(floor(f / 16), 0);
788 else if(color == "pants") {
789 f = stof(getplayerkey(self.sv_entnum, "colors"));
790 color_vec = colormapPaletteColor(mod(f, 16), 1);
793 else if(color == "shirt") {
794 f = stof(getplayerkey(self.sv_entnum, "colors"));
795 color_vec = colormapPaletteColor(floor(f / 16), 0);
797 else if(color == "pants") {
798 f = stof(getplayerkey(self.sv_entnum, "colors"));
799 color_vec = colormapPaletteColor(mod(f, 16), 1);
804 vector HUD_Panel_Dock_GetColor(void)
809 color = cvar_string("hud_dock_color");
810 color_vec = stov(color);
811 if(teamplay && cvar(strcat("hud_dock_color_team"))) {
812 f = stof(getplayerkey(self.sv_entnum, "colors"));
813 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_dock_color_team");
815 else if(color == "shirt") {
816 f = stof(getplayerkey(self.sv_entnum, "colors"));
817 color_vec = colormapPaletteColor(floor(f / 16), 0);
819 else if(color == "pants") {
820 f = stof(getplayerkey(self.sv_entnum, "colors"));
821 color_vec = colormapPaletteColor(mod(f, 16), 1);
826 float HUD_Panel_GetBgAlpha(float id)
829 alpha = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_alpha"));
831 alpha = cvar_string("hud_bg_alpha");
833 if(hud_configure && disable_menu_alphacheck == 2 && highlightedPanel == id) // do not set a minalpha cap when showing the config dialog for this panel
834 alpha = ftos((1 - cvar("_menu_alpha")) * max(cvar("hud_configure_bg_minalpha"), stof(alpha)) + (cvar("_menu_alpha")) * stof(alpha));
835 else if(hud_configure)
836 alpha = ftos(max(cvar("hud_configure_bg_minalpha"), stof(alpha)));
838 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
841 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
844 return stof(alpha) * menu_fade_alpha;
847 float HUD_Panel_GetFgAlpha(float id)
850 alpha = hud_fg_alpha;
852 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
855 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
858 return alpha * menu_fade_alpha;
861 float HUD_Panel_GetPadding(float id)
864 padding = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
866 padding = cvar_string("hud_bg_padding");
869 mySize = HUD_Panel_GetSize(id);
871 smallestsize = min(mySize_x, mySize_y);
872 return min(smallestsize/2 - 5, stof(padding));
875 // draw the background/borders
876 void HUD_Panel_DrawBg(float id, vector pos, vector mySize, float alpha)
878 if(!hud_configure && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg")) == "0")
882 bg = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg"));
884 bg = cvar_string("hud_bg");
886 if(bg == "0" && hud_configure) {
887 bg = "border"; // we probably want to see a background in config mode at all times...
893 border = max(0.0000001, HUD_Panel_GetBorder(id)); // draw_BorderPicture does not like border = 0
896 color = HUD_Panel_GetColor(id);
899 alpha = HUD_Panel_GetBgAlpha(id) * alpha; // allow panels to fade in/out by passing an alpha value
901 alpha = HUD_Panel_GetBgAlpha(id);
903 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));
907 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
909 //float drawsubpic(vector position, vector size, string pic, vector srcPosition, vector srcSize, vector rgb, float alpha, float flag) = #328;
911 pic = strcat("gfx/hud/", cvar_string("hud_skin"), "/");
913 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);
914 if(mySize_y/mySize_x > 2)
915 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);
916 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);
918 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);
919 if(mySize_x/mySize_y > 2)
920 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);
921 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);
925 vector HUD_Panel_GetProgressBarColor(string item)
927 return stov(cvar_string(strcat("hud_progressbar_", item, "_color")));
930 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
931 vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
942 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
943 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
945 for (i = 0; i < HUD_PANEL_NUM; ++i) {
946 if(i == id || !HUD_Panel_CheckActive(i))
949 targPos = HUD_Panel_GetPos(i) - '1 1 0' * HUD_Panel_GetBorder(id);
950 targSize = HUD_Panel_GetSize(i) + '2 2 0' * HUD_Panel_GetBorder(id);
952 if(myPos_y + mySize_y < targPos_y)
954 if(myPos_y > targPos_y + targSize_y)
957 if(myPos_x + mySize_x < targPos_x)
959 if(myPos_x > targPos_x + targSize_x)
962 // OK, there IS a collision.
964 myCenter_x = myPos_x + 0.5 * mySize_x;
965 myCenter_y = myPos_y + 0.5 * mySize_y;
967 targCenter_x = targPos_x + 0.5 * targSize_x;
968 targCenter_y = targPos_y + 0.5 * targSize_y;
970 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
972 if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
973 myTarget_x = targPos_x - mySize_x;
974 else // push it upwards
975 myTarget_y = targPos_y - mySize_y;
977 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
979 if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
980 myTarget_x = targPos_x + targSize_x;
981 else // push it upwards
982 myTarget_y = targPos_y - mySize_y;
984 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
986 if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
987 myTarget_x = targPos_x - mySize_x;
988 else // push it downwards
989 myTarget_y = targPos_y + targSize_y;
991 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
993 if(targPos_x + targSize_x - myPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
994 myTarget_x = targPos_x + targSize_x;
995 else // push it downwards
996 myTarget_y = targPos_y + targSize_y;
1003 void HUD_Panel_SetPos(float id, vector pos)
1006 oldPos = HUD_Panel_GetPos(id);
1009 mySize = HUD_Panel_GetSize(id);
1011 if(cvar("hud_configure_checkcollisions"))
1012 pos = HUD_Panel_CheckMove(id, pos, mySize);
1014 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
1015 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
1017 if(cvar("hud_configure_grid"))
1019 pos_x = floor((pos_x/vid_conwidth)/bound(0.005, cvar("hud_configure_grid_x"), 0.2) + 0.5) * cvar("hud_configure_grid_x") * vid_conwidth;
1020 pos_y = floor((pos_y/vid_conheight)/bound(0.005, cvar("hud_configure_grid_y"), 0.2) + 0.5) * cvar("hud_configure_grid_y") * vid_conheight;
1024 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
1026 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
1029 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
1030 vector HUD_Panel_CheckResize(float id, vector mySize, vector resizeorigin, float ratio) {
1039 for (i = 0; i < HUD_PANEL_NUM; ++i) {
1040 if(i == id || !HUD_Panel_CheckActive(i))
1043 targBorder = HUD_Panel_GetBorder(i);
1044 targPos = HUD_Panel_GetPos(i) - '1 1 0' * targBorder;
1045 targSize = HUD_Panel_GetSize(i) + '2 2 0' * targBorder;
1046 targEndPos = targPos + targSize;
1048 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
1049 if(resizeorigin_x > targPos_x && resizeorigin_x < targPos_x + targSize_x && resizeorigin_y > targPos_y && resizeorigin_y < targPos_y + targSize_y)
1052 if (resizeCorner == 1)
1054 // check if this panel is on our way
1055 if (resizeorigin_x <= targPos_x)
1057 if (resizeorigin_y <= targPos_y)
1059 if (targEndPos_x <= resizeorigin_x - mySize_x)
1061 if (targEndPos_y <= resizeorigin_y - mySize_y)
1064 // there is a collision:
1065 // detect which side of the panel we are facing is actually limiting the resizing
1066 // (which side the resize direction finds for first) and reduce the size up to there
1068 // dist is the distance between resizeorigin and the "analogous" point of the panel
1069 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
1070 dist_x = resizeorigin_x - targEndPos_x;
1071 dist_y = resizeorigin_y - targEndPos_y;
1072 if (dist_y < 0 || dist_x / dist_y > ratio)
1073 mySize_x = min(mySize_x, dist_x);
1075 mySize_y = min(mySize_y, dist_y);
1077 else if (resizeCorner == 2)
1079 if (resizeorigin_x >= targEndPos_x)
1081 if (resizeorigin_y <= targPos_y)
1083 if (targPos_x >= resizeorigin_x + mySize_x)
1085 if (targEndPos_y <= resizeorigin_y - mySize_y)
1088 dist_x = targPos_x - resizeorigin_x;
1089 dist_y = resizeorigin_y - targEndPos_y;
1090 if (dist_y < 0 || dist_x / dist_y > ratio)
1091 mySize_x = min(mySize_x, dist_x);
1093 mySize_y = min(mySize_y, dist_y);
1095 else if (resizeCorner == 3)
1097 if (resizeorigin_x <= targPos_x)
1099 if (resizeorigin_y >= targEndPos_y)
1101 if (targEndPos_x <= resizeorigin_x - mySize_x)
1103 if (targPos_y >= resizeorigin_y + mySize_y)
1106 dist_x = resizeorigin_x - targEndPos_x;
1107 dist_y = targPos_y - resizeorigin_y;
1108 if (dist_y < 0 || dist_x / dist_y > ratio)
1109 mySize_x = min(mySize_x, dist_x);
1111 mySize_y = min(mySize_y, dist_y);
1113 else if (resizeCorner == 4)
1115 if (resizeorigin_x >= targEndPos_x)
1117 if (resizeorigin_y >= targEndPos_y)
1119 if (targPos_x >= resizeorigin_x + mySize_x)
1121 if (targPos_y >= resizeorigin_y + mySize_y)
1124 dist_x = targPos_x - resizeorigin_x;
1125 dist_y = targPos_y - resizeorigin_y;
1126 if (dist_y < 0 || dist_x / dist_y > ratio)
1127 mySize_x = min(mySize_x, dist_x);
1129 mySize_y = min(mySize_y, dist_y);
1131 if(cvar("hud_configure_checkcollisions_debug"))
1132 drawfill(targPos + '1 1 0' * targBorder, targSize - '2 2 0' * targBorder, '1 1 0', .3, DRAWFLAG_NORMAL);
1138 void HUD_Panel_SetPosSize(float id)
1140 vector resizeorigin;
1141 resizeorigin = panel_click_resizeorigin;
1142 vector mySize, myPos;
1144 if(resizeCorner == 1) {
1145 mySize_x = resizeorigin_x - (mousepos_x - panel_click_distance_x);
1146 mySize_y = resizeorigin_y - (mousepos_y - panel_click_distance_y);
1147 } else if(resizeCorner == 2) {
1148 mySize_x = mousepos_x + panel_click_distance_x - resizeorigin_x;
1149 mySize_y = panel_click_distance_y + resizeorigin_y - mousepos_y;
1150 } else if(resizeCorner == 3) {
1151 mySize_x = resizeorigin_x + panel_click_distance_x - mousepos_x;
1152 mySize_y = mousepos_y + panel_click_distance_y - resizeorigin_y;
1153 } else { // resizeCorner == 4
1154 mySize_x = mousepos_x - (resizeorigin_x - panel_click_distance_x);
1155 mySize_y = mousepos_y - (resizeorigin_y - panel_click_distance_y);
1158 // minimum panel size cap
1159 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1160 mySize_y = max(0.025 * vid_conheight, mySize_y);
1162 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.
1164 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
1165 mySize_y = max(2 * cvar("con_chatsize") + 2 * HUD_Panel_GetPadding(id), mySize_y);
1168 // cap against panel's own limits
1170 minSize = HUD_Panel_GetMinSize(id); // mySize_x at least minSize_x * mySize_y, and vice versa
1172 if(!minSize_x && minSize_y) // forced aspect ratio
1174 minSize_x = 1/minSize_y;
1175 fixedRatio = minSize_x;
1176 mySize_x = max(minSize_x * mySize_y, mySize_x);
1177 mySize_y = max(minSize_y * mySize_x, mySize_y);
1179 else if(minSize_x && !minSize_y) // hybrid aspect ratio, currently supported only in one dimension
1181 if (mySize_x/mySize_y < minSize_x) // resizing in x direction allows free aspect ratio
1183 fixedRatio = minSize_x;
1184 minSize_y = 1/minSize_x;
1185 mySize_y = max(minSize_y * mySize_x, mySize_y);
1186 mySize_x = max(minSize_x * mySize_y, mySize_x);
1189 fixedRatio = -minSize_x; //negative so that it will be used ONLY after checkResize
1192 // collision testing|
1193 // -----------------+
1195 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
1196 if(resizeCorner == 1) {
1197 myPos_x = resizeorigin_x - mySize_x;
1198 myPos_y = resizeorigin_y - mySize_y;
1199 } else if(resizeCorner == 2) {
1200 myPos_x = resizeorigin_x;
1201 myPos_y = resizeorigin_y - mySize_y;
1202 } else if(resizeCorner == 3) {
1203 myPos_x = resizeorigin_x - mySize_x;
1204 myPos_y = resizeorigin_y;
1205 } else { // resizeCorner == 4
1206 myPos_x = resizeorigin_x;
1207 myPos_y = resizeorigin_y;
1210 // left/top screen edges
1212 mySize_x = mySize_x + myPos_x;
1214 mySize_y = mySize_y + myPos_y;
1216 // bottom/right screen edges
1217 if(myPos_x + mySize_x > vid_conwidth)
1218 mySize_x = vid_conwidth - myPos_x;
1219 if(myPos_y + mySize_y > vid_conheight)
1220 mySize_y = vid_conheight - myPos_y;
1222 if(cvar("hud_configure_checkcollisions_debug"))
1223 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
1225 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
1226 if(cvar("hud_configure_grid"))
1228 mySize_x = floor((mySize_x/vid_conwidth)/bound(0.005, cvar("hud_configure_grid_x"), 0.2) + 0.5) * cvar("hud_configure_grid_x") * vid_conwidth;
1229 mySize_y = floor((mySize_y/vid_conheight)/bound(0.005, cvar("hud_configure_grid_y"), 0.2) + 0.5) * cvar("hud_configure_grid_y") * vid_conheight;
1234 // keep aspect ratio _MAXIMIZING_ the size
1235 if (mySize_x / mySize_y > fixedRatio)
1236 mySize_y = mySize_x / fixedRatio;
1238 mySize_x = mySize_y * fixedRatio;
1241 if(cvar("hud_configure_checkcollisions"))
1245 mySize = HUD_Panel_CheckResize(id, mySize, resizeorigin, fixedRatio);
1247 // Make sure once more that we DON'T cross the screen edges
1248 // left/top screen edges
1250 mySize_x = mySize_x + myPos_x;
1252 mySize_y = mySize_y + myPos_y;
1254 // bottom/right screen edges
1255 if(myPos_x + mySize_x > vid_conwidth)
1256 mySize_x = vid_conwidth - myPos_x;
1257 if(myPos_y + mySize_y > vid_conheight)
1258 mySize_y = vid_conheight - myPos_y;
1260 // restore again aspect ratio, _minimizing_ the size
1261 if (mySize_x / mySize_y < fixedRatio)
1262 mySize_y = mySize_x / fixedRatio;
1264 mySize_x = mySize_y * fixedRatio;
1268 mySize = HUD_Panel_CheckResize(id, mySize, resizeorigin, mySize_x / mySize_y);
1271 fixedRatio = -fixedRatio;
1272 // restore again aspect ratio, _minimizing_ the size
1273 if (mySize_x / mySize_y < fixedRatio)
1274 mySize_y = mySize_x / fixedRatio;
1279 // 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)
1280 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1281 mySize_y = max(0.025 * vid_conheight, mySize_y);
1283 // do another pos check, as size might have changed by now
1284 if(resizeCorner == 1) {
1285 myPos_x = resizeorigin_x - mySize_x;
1286 myPos_y = resizeorigin_y - mySize_y;
1287 } else if(resizeCorner == 2) {
1288 myPos_x = resizeorigin_x;
1289 myPos_y = resizeorigin_y - mySize_y;
1290 } else if(resizeCorner == 3) {
1291 myPos_x = resizeorigin_x - mySize_x;
1292 myPos_y = resizeorigin_y;
1293 } else { // resizeCorner == 4
1294 myPos_x = resizeorigin_x;
1295 myPos_y = resizeorigin_y;
1298 if(cvar("hud_configure_checkcollisions_debug"))
1299 if(cvar("hud_configure_checkcollisions"))
1300 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
1303 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
1304 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_size"), s);
1306 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
1307 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
1311 float prevMouseClicked; // previous state
1312 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
1313 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
1316 float menu_enabled_time;
1317 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1322 // allow console bind to work
1325 con_keys = findkeysforcommand("toggleconsole");
1326 keys = tokenize(con_keys);
1328 float hit_con_bind, i;
1329 for (i = 0; i < keys; ++i)
1331 if(nPrimary == stof(argv(i)))
1335 if(nPrimary == K_MOUSE1)
1337 if(bInputType == 0) { // key pressed
1341 else if(bInputType == 1) {// key released
1346 else if(nPrimary == K_ESCAPE)
1348 disable_menu_alphacheck = 1;
1350 menu_enabled_time = time;
1351 localcmd("menu_showhudexit\n");
1354 else if(hit_con_bind)
1357 return true; // Suppress ALL other input
1360 void HUD_Panel_Mouse()
1362 // 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
1363 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1364 disable_menu_alphacheck = 0;
1365 if (cvar("_menu_alpha") == 0 && time - menu_enabled_time > 0.5)
1369 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1370 print("Highlighted: ", ftos(highlightedPanel), "\n");
1371 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1374 if(mouseClicked == 0 && disable_menu_alphacheck != 2) { // don't reset these variables in disable_menu_alphacheck mode 2!
1375 highlightedPanel = -1;
1376 highlightedAction = 0;
1379 mousepos = mousepos + getmousepos();
1381 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1382 mousepos_y = bound(0, mousepos_y, vid_conheight);
1384 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1392 for(i = 0; i < HUD_PANEL_NUM; ++i)
1394 panelPos = HUD_Panel_GetPos(i);
1395 panelSize = HUD_Panel_GetSize(i);
1396 border = HUD_Panel_GetBorder(i);
1397 if(prevMouseClicked == 0) {
1399 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1401 highlightedPanel = i;
1402 highlightedAction = 1;
1404 // resize from topleft border
1405 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)
1407 highlightedPanel = i;
1408 highlightedAction = 2;
1411 // resize from topright border
1412 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)
1414 highlightedPanel = i;
1415 highlightedAction = 2;
1418 // resize from bottomleft border
1419 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)
1421 highlightedPanel = i;
1422 highlightedAction = 2;
1425 // resize from bottomright border
1426 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)
1428 highlightedPanel = i;
1429 highlightedAction = 2;
1434 if(highlightedPanel == i)
1436 if(prevMouseClicked == 0)
1438 if(highlightedAction == 1)
1439 panel_click_distance = mousepos - panelPos;
1440 else if(highlightedAction == 2)
1442 if(resizeCorner == 1) {
1443 panel_click_distance = mousepos - panelPos;
1444 panel_click_resizeorigin = panelPos + panelSize;
1445 } else if(resizeCorner == 2) {
1446 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1447 panel_click_distance_y = mousepos_y - panelPos_y;
1448 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1449 } else if(resizeCorner == 3) {
1450 panel_click_distance_x = mousepos_x - panelPos_x;
1451 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1452 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1453 } else if(resizeCorner == 4) {
1454 panel_click_distance = panelSize - mousepos + panelPos;
1455 panel_click_resizeorigin = panelPos;
1460 if(cvar("hud_configure_checkcollisions_debug"))
1461 drawfill(panelPos, panelSize, '1 0 0', .3, DRAWFLAG_NORMAL);
1463 if(highlightedAction == 1)
1464 HUD_Panel_SetPos(i, mousepos - panel_click_distance);
1465 else if(highlightedAction == 2)
1466 HUD_Panel_SetPosSize(i);
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.weapons && (self.impulse >= 0) && (stat_weapons & self.weapons) || hud_configure)
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 if((self.weapons && (self.impulse >= 0) && (stat_weapons & self.weapons)) || hud_configure)
1583 weapid = self.impulse;
1585 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1587 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1588 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1590 // draw background behind currently selected weapon
1591 if(self.weapon == activeweapon)
1592 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);
1594 // draw the weapon accuracy on the HUD
1595 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1598 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1600 accuracy_color = HUD_AccuracyColor(weapon_stats);
1602 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);
1605 // draw the weapon icon
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);
1624 float GetAmmoStat(float i)
1628 case 0: return STAT_SHELLS;
1629 case 1: return STAT_NAILS;
1630 case 2: return STAT_ROCKETS;
1631 case 3: return STAT_CELLS;
1632 case 4: return STAT_FUEL;
1637 float GetAmmoItemCode(float i)
1641 case 0: return IT_SHELLS;
1642 case 1: return IT_NAILS;
1643 case 2: return IT_ROCKETS;
1644 case 3: return IT_CELLS;
1645 case 4: return IT_FUEL;
1650 string GetAmmoPicture(float i)
1654 case 0: return "ammo_shells";
1655 case 1: return "ammo_bullets";
1656 case 2: return "ammo_rockets";
1657 case 3: return "ammo_cells";
1658 case 4: return "ammo_fuel";
1663 void HUD_Inventory(void)
1665 float id = HUD_PANEL_INVENTORY;
1669 vector pos, mySize, mysize, mypos;
1670 pos = HUD_Panel_GetPos(id);
1671 mySize = HUD_Panel_GetSize(id);
1673 HUD_Panel_DrawBg(id, pos, mySize, 0);
1675 padding = HUD_Panel_GetPadding(id);
1678 pos += '1 1 0' * padding;
1679 mySize -= '2 2 0' * padding;
1683 stat_items = getstati(STAT_ITEMS);
1684 for (i = 0; i < 4; ++i) {
1686 a = getstati(GetAmmoStat(i)); // how much ammo do we have of type i?
1690 if(cvar("hud_inventory_onlycurrent")) {
1693 if (stat_items & GetAmmoItemCode(i) || hud_configure) {
1694 drawpic_skin(pos, GetAmmoPicture(i), '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1696 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);
1698 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);
1704 if(mySize_x/mySize_y >= 10) { // arrange horizontally
1706 case 0: mypos_x = pos_x; mypos_y = pos_y; break; // shells
1707 case 1: mypos_x = pos_x + 0.25 * mySize_x; mypos_y = pos_y; break; // bullets
1708 case 2: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y; break; // rockets
1709 case 3: mypos_x = pos_x + 0.75 * mySize_x; mypos_y = pos_y; break; // cells
1711 mysize_x = 0.25 * mySize_x;
1712 mysize_y = mySize_y;
1713 } else if(mySize_x/mySize_y >= 2.5) { // arrange in a 2x2 grid
1715 case 0: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y + 0.5 * mySize_y; break; // shells
1716 case 1: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y; break; // bullets
1717 case 2: mypos_x = pos_x; mypos_y = pos_y + 0.5 * mySize_y; break; // rockets
1718 case 3: mypos_x = pos_x; mypos_y = pos_y; break; // cells
1720 mysize_x = 0.5 * mySize_x;
1721 mysize_y = 0.5 * mySize_y;
1722 } else { // arrange vertically
1724 case 0: mypos_x = pos_x; mypos_y = pos_y; break; // shells
1725 case 1: mypos_x = pos_x; mypos_y = pos_y + 0.25 * mySize_y; break; // bullets
1726 case 2: mypos_x = pos_x; mypos_y = pos_y + 0.5 * mySize_y; break; // rockets
1727 case 3: mypos_x = pos_x; mypos_y = pos_y + 0.75 * mySize_y; break; // cells
1729 mysize_x = mySize_x;
1730 mysize_y = 0.25 * mySize_y;
1733 if (stat_items & GetAmmoItemCode(i))
1734 drawpic_skin(mypos, "ammo_current_bg", mysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1735 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);
1737 if(stat_items & GetAmmoItemCode(i))
1738 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);
1740 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);
1742 if(stat_items & GetAmmoItemCode(i))
1743 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);
1745 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);
1755 void HUD_Powerups(void) {
1756 float id = HUD_PANEL_POWERUPS;
1758 stat_items = getstati(STAT_ITEMS);
1762 if not(stat_items & IT_STRENGTH)
1763 if not(stat_items & IT_INVINCIBLE)
1766 if (getstati(STAT_HEALTH) <= 0)
1771 pos = HUD_Panel_GetPos(id);
1772 mySize = HUD_Panel_GetSize(id);
1774 HUD_Panel_DrawBg(id, pos, mySize, 0);
1776 padding = HUD_Panel_GetPadding(id);
1779 pos += '1 1 0' * padding;
1780 mySize -= '2 2 0' * padding;
1783 float strength_time, shield_time;
1785 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1786 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1796 vector barpos, barsize;
1800 string leftname, rightname;
1801 float leftcnt, rightcnt;
1802 float leftexact, rightexact;
1803 float leftalpha, rightalpha;
1804 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) {
1805 leftname = "strength";
1806 leftcnt = ceil(strength_time);
1807 leftexact = strength_time;
1809 rightname = "shield";
1810 rightcnt = ceil(shield_time);
1811 rightexact = shield_time;
1813 leftname = "shield";
1814 leftcnt = ceil(shield_time);
1815 leftexact = shield_time;
1817 rightname = "strength";
1818 rightcnt = ceil(strength_time);
1819 rightexact = strength_time;
1821 leftalpha = bound(0, leftexact, 1);
1822 rightalpha = bound(0, rightexact, 1);
1824 if (mySize_x/mySize_y > 4)
1828 len = strlen(ftos(leftcnt));
1830 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1831 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1832 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1833 picpos = pos + eX * 0.5 * mySize_x - eX * mySize_y;
1834 numpos = picpos - eX * 2 * 0.5 * mySize_y + eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1837 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1839 numpos = picpos + eX * mySize_y - eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1842 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1844 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));
1846 drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1847 HUD_DrawXNum(numpos, leftcnt, 2, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1852 len = strlen(ftos(rightcnt));
1854 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1855 barpos = pos + eX * 0.5 * mySize_x;
1856 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1857 picpos = pos + eX * 0.5 * mySize_x;
1858 numpos = picpos + eX * mySize_y - eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1860 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1861 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1862 picpos = pos + eX * mySize_x - eX * mySize_y;
1863 numpos = picpos - eX * mySize_y + eY * 0.25 * mySize_y;
1866 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1868 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));
1870 drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1871 HUD_DrawXNum(numpos, rightcnt, 2, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1874 else if (mySize_x/mySize_y > 1.5)
1878 len = strlen(ftos(leftcnt));
1880 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1881 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1882 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1883 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y;
1884 numpos = picpos - eX * len * 0.5 * mySize_y;
1887 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1889 numpos = picpos + eX * 0.5 * mySize_y;
1892 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1894 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));
1896 drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1897 HUD_DrawXNum(numpos, leftcnt, len, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1902 len = strlen(ftos(rightcnt));
1904 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1905 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1906 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1907 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y + eY * 0.5 * mySize_y;
1908 numpos = picpos - eX * len * 0.5 * mySize_y;
1910 barpos = pos + eY * 0.5 * mySize_y;
1911 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1912 picpos = pos + eY * 0.5 * mySize_y;
1913 numpos = picpos + eX * 0.5 * mySize_y;
1916 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1918 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));
1920 drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1921 HUD_DrawXNum(numpos, rightcnt, len, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1928 len = strlen(ftos(leftcnt));
1930 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1932 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1933 picpos = pos + eX * 0.05 * mySize_x;
1934 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x;
1936 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1937 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1938 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.65 * mySize_x;
1939 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.25 * mySize_x;
1942 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1944 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));
1946 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1947 HUD_DrawXNum(numpos, leftcnt, len, 0, 0.25 * mySize_x, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1952 len = strlen(ftos(rightcnt));
1954 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1955 barpos = pos + eX * 0.5 * mySize_x;
1956 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1957 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1958 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1960 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1961 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1962 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.65 * mySize_x + eX * 0.5 * mySize_x;
1963 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
1966 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1968 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));
1970 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1971 HUD_DrawXNum(numpos, rightcnt, len, 0, 0.25 * mySize_x, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1976 // Health/armor (#3)
1978 void HUD_HealthArmor(void)
1980 float id = HUD_PANEL_HEALTHARMOR;
1982 pos = HUD_Panel_GetPos(id);
1983 mySize = HUD_Panel_GetSize(id);
1985 HUD_Panel_DrawBg(id, pos, mySize, 0);
1987 padding = HUD_Panel_GetPadding(id);
1990 pos += '1 1 0' * padding;
1991 mySize -= '2 2 0' * padding;
1994 float armor, health;
1995 armor = getstati(STAT_ARMOR);
1996 health = getstati(STAT_HEALTH);
1999 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
2012 vector barpos, barsize;
2016 if(cvar("hud_healtharmor") == 2) // combined health and armor display
2019 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2024 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2025 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2026 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2028 numpos = picpos + eX * 1.5 * mySize_y;
2031 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2032 picpos = pos + eX * 3 * mySize_y;
2036 if(v_z) // NOT fully armored
2038 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("health"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2039 drawpic_skin(picpos, "health", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2041 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);
2045 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("armor"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2046 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);
2048 drawpic_skin(picpos, "armor", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2050 HUD_DrawXNum_Colored(numpos, x, 3, mySize_y, HUD_Panel_GetFgAlpha(id)); // draw the combined health and armor
2053 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2054 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2055 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2058 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2061 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2066 string leftname, rightname;
2067 float leftcnt, rightcnt;
2068 float leftactive, rightactive;
2069 float leftalpha, rightalpha;
2070 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) { // old style layout with armor left/top of health
2075 leftalpha = min((armor+10)/55, 1);
2077 rightname = "health";
2082 leftname = "health";
2087 rightname = "armor";
2091 rightalpha = min((armor+10)/55, 1);
2094 if (mySize_x/mySize_y > 5)
2098 len = strlen(ftos(leftcnt));
2100 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2101 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2102 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2103 picpos = pos + eX * 0.5 * mySize_x - eX * mySize_y;
2104 numpos = picpos - eX * 3 * 0.5 * mySize_y + eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
2107 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2109 numpos = picpos + eX * mySize_y + eY * 0.25 * mySize_y;
2112 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2113 drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2114 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2119 len = strlen(ftos(rightcnt));
2121 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2122 barpos = pos + eX * 0.5 * mySize_x;
2123 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2124 picpos = pos + eX * 0.5 * mySize_x;
2125 numpos = picpos + eX * mySize_y - eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
2127 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2128 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2129 picpos = pos + eX * mySize_x - eX * mySize_y;
2130 numpos = picpos - eX * 1.5 * mySize_y + eY * 0.25 * mySize_y;
2133 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2134 drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2135 HUD_DrawXNum_Colored(numpos, rightcnt, 3, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2138 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2139 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2140 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2143 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2146 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2148 else if (mySize_x/mySize_y > 2)
2152 len = strlen(ftos(leftcnt));
2154 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2155 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2156 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2157 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y;
2158 numpos = picpos - eX * len * 0.5 * mySize_y;
2161 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2163 numpos = picpos + eX * 0.5 * mySize_y;
2166 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2167 drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2168 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2173 len = strlen(ftos(rightcnt));
2175 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2176 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2177 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2178 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y + eY * 0.5 * mySize_y;
2179 numpos = picpos - eX * len * 0.5 * mySize_y;
2181 barpos = pos + eY * 0.5 * mySize_y;
2182 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2183 picpos = pos + eY * 0.5 * mySize_y;
2184 numpos = picpos + eX * 0.5 * mySize_y;
2187 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2188 drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2189 HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2192 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2193 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2194 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2197 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2200 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2206 len = strlen(ftos(leftcnt));
2208 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2210 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2211 picpos = pos + eX * 0.05 * mySize_x;
2212 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x;
2214 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2215 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2216 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x;
2217 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x;
2220 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2221 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2222 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.166 * mySize_x, HUD_Panel_GetFgAlpha(id));
2227 len = strlen(ftos(rightcnt));
2229 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2230 barpos = pos + eX * 0.5 * mySize_x;
2231 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2232 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2233 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2235 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2236 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2237 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x + eX * 0.5 * mySize_x;
2238 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x + eX * 0.5 * mySize_x;
2241 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2242 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2243 HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.166 * mySize_x, HUD_Panel_GetFgAlpha(id));
2246 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2248 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2250 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2251 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2254 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2260 // Notification area (#4)
2263 string Weapon_SuicideMessage(float deathtype)
2265 w_deathtype = deathtype;
2266 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2267 return w_deathtypestring;
2270 string Weapon_KillMessage(float deathtype)
2272 w_deathtype = deathtype;
2273 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2274 return w_deathtypestring;
2277 float killnotify_times[10];
2278 float killnotify_deathtype[10];
2279 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2280 string killnotify_attackers[10];
2281 string killnotify_victims[10];
2282 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2285 for (i = 9; i > 0; --i) {
2286 killnotify_times[i] = killnotify_times[i-1];
2287 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2288 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2289 if(killnotify_attackers[i])
2290 strunzone(killnotify_attackers[i]);
2291 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2292 if(killnotify_victims[i])
2293 strunzone(killnotify_victims[i]);
2294 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2296 killnotify_times[0] = time;
2297 killnotify_deathtype[0] = wpn;
2298 killnotify_actiontype[0] = actiontype;
2299 if(killnotify_attackers[0])
2300 strunzone(killnotify_attackers[0]);
2301 killnotify_attackers[0] = strzone(attacker);
2302 if(killnotify_victims[0])
2303 strunzone(killnotify_victims[0]);
2304 killnotify_victims[0] = strzone(victim);
2307 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2311 alsoprint = (cvar("hud_notify_print") || !HUD_Panel_CheckActive(4)); // print message to console if: notify panel disabled, or cvar to do so enabled
2313 if(msg == MSG_SUICIDE) {
2315 w = DEATH_WEAPONOF(type);
2317 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2319 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2320 } else if (type == DEATH_KILL) {
2321 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2323 print ("^1",s1, "^1 couldn't take it anymore\n");
2324 } else if (type == DEATH_ROT) {
2325 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2327 print ("^1",s1, "^1 died\n");
2328 } else if (type == DEATH_NOAMMO) {
2329 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2331 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2332 } else if (type == DEATH_CAMP) {
2333 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2335 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2336 } else if (type == DEATH_MIRRORDAMAGE) {
2337 HUD_KillNotify_Push(s1, "", 0, DEATH_MIRRORDAMAGE);
2339 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2340 } else if (type == DEATH_CHEAT) {
2341 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2343 print ("^1",s1, "^1 unfairly eliminated themself\n");
2344 } else if (type == DEATH_FIRE) {
2345 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2347 print ("^1",s1, "^1 burned to death\n");
2348 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2349 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2351 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2354 if (stof(s2) > 2) // killcount > 2
2355 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2356 } else if(msg == MSG_KILL) {
2357 w = DEATH_WEAPONOF(type);
2359 HUD_KillNotify_Push(s2, s1, 1, w);
2361 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2363 else if(type == KILL_TEAM || type == KILL_TEAM_SPREE) {
2364 HUD_KillNotify_Push(s1, s2, 1, DEATH_MIRRORDAMAGE);
2367 if(cvar("cl_gentle")) {
2368 print ("^1", s1, "^1 took action against a team mate\n");
2370 print ("^1", s1, "^1 mows down a team mate\n");
2373 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2374 if(cvar("cl_gentle"))
2375 print ("^1",s1,"^1 ended a ",s2," scoring spree by going against a team mate\n");
2377 print ("^1",s1,"^1 ended a ",s2," kill spree by killing a team mate\n");
2379 else if (stof(s2) > 2) {
2380 if(cvar("cl_gentle"))
2381 print ("^1",s1,"'s ^1",s2," scoring spree was ended by a team mate!\n");
2383 print ("^1",s1,"'s ^1",s2," kill spree was ended by a team mate!\n");
2386 else if(type == KILL_FIRST_BLOOD)
2387 print("^1",s1, "^1 drew first blood", "\n");
2389 else if (type == DEATH_TELEFRAG)
2390 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2391 else if (type == DEATH_DROWN) {
2392 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2394 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2396 else if (type == DEATH_SLIME) {
2397 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2399 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2401 else if (type == DEATH_LAVA) {
2402 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2404 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2406 else if (type == DEATH_FALL) {
2407 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2409 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2411 else if (type == DEATH_SHOOTING_STAR) {
2412 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2414 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2416 else if (type == DEATH_SWAMP) {
2417 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2419 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2421 else if (type == DEATH_HURTTRIGGER)
2423 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2425 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2426 } else if(type == DEATH_SBCRUSH) {
2427 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2429 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2430 } else if(type == DEATH_SBMINIGUN) {
2431 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2433 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2434 } else if(type == DEATH_SBROCKET) {
2435 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2437 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2438 } else if(type == DEATH_SBBLOWUP) {
2439 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2441 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2442 } else if(type == DEATH_WAKIGUN) {
2443 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2445 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2446 } else if(type == DEATH_WAKIROCKET) {
2447 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2449 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2450 } else if(type == DEATH_WAKIBLOWUP) {
2451 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2453 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2454 } else if(type == DEATH_TURRET) {
2455 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2457 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2458 } else if(type == DEATH_TOUCHEXPLODE) {
2459 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2461 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2462 } else if(type == DEATH_CHEAT) {
2463 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2465 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2466 } else if (type == DEATH_FIRE) {
2467 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2469 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2470 } else if (type == DEATH_CUSTOM) {
2471 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2473 print ("^1",s1, "^1 ", s2, "\n");
2475 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2477 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2479 } else if(msg == MSG_SPREE) {
2480 if(type == KILL_END_SPREE) {
2481 if(cvar("cl_gentle"))
2482 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2484 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2485 } else if(type == KILL_SPREE) {
2486 if(cvar("cl_gentle"))
2487 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2489 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2490 } else if(type == KILL_SPREE_3) {
2491 if(cvar("cl_gentle"))
2492 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2494 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2495 } else if(type == KILL_SPREE_5) {
2496 if(cvar("cl_gentle"))
2497 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2499 print (s1,"^7 unleashes ^1RAGE\n");
2500 } else if(type == KILL_SPREE_10) {
2501 if(cvar("cl_gentle"))
2502 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2504 print (s1,"^7 starts the ^1MASSACRE!\n");
2505 } else if(type == KILL_SPREE_15) {
2506 if(cvar("cl_gentle"))
2507 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2509 print (s1,"^7 executes ^1MAYHEM!\n");
2510 } else if(type == KILL_SPREE_20) {
2511 if(cvar("cl_gentle"))
2512 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2514 print (s1,"^7 is a ^1BERSERKER!\n");
2515 } else if(type == KILL_SPREE_25) {
2516 if(cvar("cl_gentle"))
2517 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2519 print (s1,"^7 inflicts ^1CARNAGE!\n");
2520 } else if(type == KILL_SPREE_30) {
2521 if(cvar("cl_gentle"))
2522 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2524 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2526 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2527 if (type == DEATH_DROWN) {
2528 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2531 if(cvar("cl_gentle"))
2532 print ("^1",s1, "^1 was in the water for too long\n");
2534 print ("^1",s1, "^1 drowned\n");
2536 } else if (type == DEATH_SLIME) {
2537 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2539 print ("^1",s1, "^1 was slimed\n");
2540 } else if (type == DEATH_LAVA) {
2541 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2544 if(cvar("cl_gentle"))
2545 print ("^1",s1, "^1 found a hot place\n");
2547 print ("^1",s1, "^1 turned into hot slag\n");
2549 } else if (type == DEATH_FALL) {
2550 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2553 if(cvar("cl_gentle"))
2554 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2556 print ("^1",s1, "^1 hit the ground with a crunch\n");
2558 } else if (type == DEATH_SHOOTING_STAR) {
2559 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2561 print ("^1",s1, "^1 became a shooting star\n");
2562 } else if (type == DEATH_SWAMP) {
2563 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2566 if(cvar("cl_gentle"))
2567 print ("^1",s1, "^1 discovered a swamp\n");
2569 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2571 } else if(type == DEATH_TURRET) {
2572 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2574 print ("^1",s1, "^1 was mowed down by a turret \n");
2575 } else if (type == DEATH_CUSTOM) {
2576 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2578 print ("^1",s1, "^1 ", s2, "\n");
2579 } else if (type == DEATH_HURTTRIGGER) {
2580 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2582 print ("^1",s1, "^1 was in the wrong place\n");
2583 } else if(type == DEATH_TOUCHEXPLODE) {
2584 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2586 print ("^1",s1, "^1 died in an accident\n");
2587 } else if(type == DEATH_CHEAT) {
2588 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2590 print ("^1",s1, "^1 was unfairly eliminated\n");
2591 } else if(type == DEATH_FIRE) {
2592 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2595 if(cvar("cl_gentle"))
2596 print ("^1",s1, "^1 felt a little hot\n");
2598 print ("^1",s1, "^1 burnt to death\n");
2601 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2604 if(cvar("cl_gentle"))
2605 print ("^1",s1, "^1 needs a restart\n");
2607 print ("^1",s1, "^1 died\n");
2610 } else if(msg == MSG_KILL_ACTION_SPREE) {
2611 if(cvar("cl_gentle"))
2612 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2614 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2615 } else if(msg == MSG_INFO) {
2616 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2617 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2618 print(s1, "^7 got the ", s2, "\n");
2619 } else if(type == INFO_LOSTFLAG) {
2620 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2621 print(s1, "^7 lost the ", s2, "\n");
2622 } else if(type == INFO_PICKUPFLAG) {
2623 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2624 print(s1, "^7 picked up the ", s2, "\n");
2625 } else if(type == INFO_RETURNFLAG) {
2626 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2627 print(s1, "^7 returned the ", s2, "\n");
2632 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2634 void HUD_Centerprint(string s1, string s2, float type, float msg)
2636 if(msg == MSG_SUICIDE) {
2637 if (type == DEATH_TEAMCHANGE) {
2638 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2639 } else if (type == DEATH_AUTOTEAMCHANGE) {
2640 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2641 } else if (type == DEATH_CAMP) {
2642 if(cvar("cl_gentle"))
2643 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2645 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2646 } else if (type == DEATH_NOAMMO) {
2647 if(cvar("cl_gentle"))
2648 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2650 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2651 } else if (type == DEATH_ROT) {
2652 if(cvar("cl_gentle"))
2653 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2655 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2656 } else if (type == DEATH_MIRRORDAMAGE) {
2657 if(cvar("cl_gentle"))
2658 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2660 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2661 } else if (type == DEATH_QUIET) {
2663 } else if (type == DEATH_KILL) {
2664 if(cvar("cl_gentle"))
2665 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2667 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2669 } else if(msg == MSG_KILL) {
2670 if (type == KILL_TEAM) {
2671 if(cvar("cl_gentle")) {
2672 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against a team mate!"));
2674 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2676 } else if (type == KILL_FIRST_BLOOD) {
2677 if(cvar("cl_gentle")) {
2678 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2680 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2682 } else if (type == KILL_FIRST_VICTIM) {
2683 if(cvar("cl_gentle")) {
2684 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2686 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2688 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2689 if(cvar("cl_gentle")) {
2690 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^7 who was typing!", s2));
2692 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2694 } else if (type == KILL_TYPEFRAGGED) {
2695 if(cvar("cl_gentle")) {
2696 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^7 while you were typing!", s2));
2698 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2700 } else if (type == KILL_FRAG) {
2701 if(cvar("cl_gentle")) {
2702 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2704 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2706 } else if (type == KILL_FRAGGED) {
2707 if(cvar("cl_gentle")) {
2708 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You were scored against by ^7", s1, s2));
2710 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You were fragged by ^7", s1, s2));
2713 } else if(msg == MSG_KILL_ACTION) {
2714 // TODO: invent more centerprints here?
2715 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!", s1));
2719 void HUD_Notify (void)
2721 float id = HUD_PANEL_NOTIFY;
2723 pos = HUD_Panel_GetPos(id);
2724 mySize = HUD_Panel_GetSize(id);
2726 HUD_Panel_DrawBg(id, pos, mySize, 0);
2728 padding = HUD_Panel_GetPadding(id);
2731 pos += '1 1 0' * padding;
2732 mySize -= '2 2 0' * padding;
2735 float entries, height;
2736 entries = bound(1, floor(14 * mySize_y/mySize_x), 12);
2737 height = mySize_y/entries;
2738 entries -= 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2741 fontsize = '0.5 0.5 0' * height;
2745 when = cvar("hud_notify_time");
2747 fadetime = cvar("hud_notify_fadetime");
2751 vector pos_attacker, pos_victim;
2753 float width_attacker, width_victim;
2754 string attacker, victim;
2757 for(j = 0; j < entries; ++j)
2759 if(cvar("hud_notify_flip"))
2761 else // rather nasty hack for ordering items from the bottom up
2762 i = entries - j - 1;
2763 if(cvar("hud_notify_info_top"))
2764 i += 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2768 if(killnotify_times[j] + when > time)
2771 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2775 if(killnotify_times[j] + when > time)
2781 // TODO: maybe print in team colors?
2782 // TODO: maybe this could be cleaned up somehow...
2783 // TODO: less copypaste code below
2786 if(killnotify_actiontype[j] == 0 && !hud_configure)
2788 attacker = textShortenToWidth(killnotify_attackers[j], mySize_x - 2 * height, fontsize, stringwidth_colors);
2790 width_attacker = stringwidth(attacker, TRUE, fontsize);
2791 pos_attacker = pos + eX * 0.5 * (mySize_x - width_attacker + 2 * height) + eY * 0.5 * fontsize_y + eY * i * height;
2793 weap_pos = pos + eX * 0.5 * (mySize_x - width_attacker) - eX * height + eY * i * height;
2794 if(killnotify_deathtype[j] == DEATH_GENERIC)
2796 drawpic_skin(weap_pos, "notify_death", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2797 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2799 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2801 drawpic_skin(weap_pos, "notify_outofammo", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2802 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2804 else if(killnotify_deathtype[j] == DEATH_KILL)
2806 drawpic_skin(weap_pos, "notify_selfkill", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2807 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2809 else if(killnotify_deathtype[j] == DEATH_CAMP)
2811 drawpic_skin(weap_pos, "notify_camping", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2812 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2814 else if(killnotify_deathtype[j] == DEATH_MIRRORDAMAGE)
2816 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2817 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2819 else if(killnotify_deathtype[j] == DEATH_DROWN)
2821 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2822 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2824 else if(killnotify_deathtype[j] == DEATH_SLIME)
2826 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2827 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2829 else if(killnotify_deathtype[j] == DEATH_LAVA)
2831 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2832 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2834 else if(killnotify_deathtype[j] == DEATH_FALL)
2836 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2837 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2839 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2841 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2842 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2844 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2846 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2847 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2849 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2851 if(killnotify_victims[j] == "^1RED^7 flag")
2855 drawpic_skin(weap_pos, strcat("flag_", s, "_carrying"), '1 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_RETURNFLAG)
2860 if(killnotify_victims[j] == "^1RED^7 flag")
2864 drawpic_skin(weap_pos, strcat("flag_", s, "_taken"), '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_LOSTFLAG)
2869 if(killnotify_victims[j] == "^1RED^7 flag")
2873 drawpic_skin(weap_pos, strcat("flag_", s, "_lost"), '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);
2877 // X [did action to] Y
2882 attacker = textShortenToWidth("Player1", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2883 victim = textShortenToWidth("Player2", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2884 a = bound(0, (when - j) / 4, 1);
2888 attacker = textShortenToWidth(killnotify_attackers[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2889 victim = textShortenToWidth(killnotify_victims[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2891 width_attacker = stringwidth(attacker, TRUE, fontsize);
2892 width_victim = stringwidth(victim, TRUE, fontsize);
2893 pos_attacker = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_attacker) + eY * 0.5 * fontsize_y + eY * i * height;
2894 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;
2895 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2897 if(hud_configure) // example actions for config mode
2899 drawpic_skin(weap_pos, strcat("weapon", "electro"), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2900 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2901 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2903 else if(WEP_VALID(killnotify_deathtype[j]))
2905 self = get_weaponinfo(killnotify_deathtype[j]);
2906 drawpic_skin(weap_pos, strcat("weapon", self.netname), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2907 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2908 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2910 else if(killnotify_deathtype[j] == DEATH_MIRRORDAMAGE)
2912 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2913 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2914 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2916 else if(killnotify_deathtype[j] == DEATH_DROWN)
2918 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2919 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2920 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2922 else if(killnotify_deathtype[j] == DEATH_SLIME)
2924 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2925 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2926 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2928 else if(killnotify_deathtype[j] == DEATH_LAVA)
2930 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2931 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2932 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2934 else if(killnotify_deathtype[j] == DEATH_FALL)
2936 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2937 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2938 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2940 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2942 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2943 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2944 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2946 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2948 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2949 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2950 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2961 if(cvar("hud_notify_info_top"))
2964 o = pos + eY * mySize_y - eY * 2 * height;
2966 if(spectatee_status && !intermission)
2968 //drawfont = hud_bigfont;
2969 if(spectatee_status == -1)
2972 s = GetPlayerName(spectatee_status - 1);
2974 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
2975 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2976 //drawfont = hud_font;
2978 // spectator text in the upper right corner
2979 if(spectatee_status == -1)
2980 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
2982 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
2983 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2984 o += eY * fontsize_y;
2986 if(spectatee_status == -1)
2987 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
2989 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
2990 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2991 o += eY * fontsize_y;
2993 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
2994 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2995 o += eY * fontsize_y;
2997 if(gametype == GAME_ARENA)
2998 s = "^1Wait for your turn to join";
2999 else if(gametype == GAME_LMS)
3002 sk = playerslots[player_localentnum - 1];
3003 if(sk.(scores[ps_primary]) >= 666)
3004 s = "^1Match has already begun";
3005 else if(sk.(scores[ps_primary]) > 0)
3006 s = "^1You have no more lives left";
3008 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
3011 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
3012 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3013 o += eY * fontsize_y;
3015 //show restart countdown:
3016 if (time < getstatf(STAT_GAMESTARTTIME)) {
3018 //we need to ceil, otherwise the countdown would be off by .5 when using round()
3019 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
3020 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
3021 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3022 o += eY * fontsize_y;
3025 if(warmup_stage && !intermission)
3027 s = "^2Currently in ^1warmup^2 stage!";
3028 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3029 o += eY * fontsize_y;
3033 if(mod(time, 1) >= 0.5)
3038 if(ready_waiting && !intermission && !spectatee_status)
3040 if(ready_waiting_for_me)
3043 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
3045 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
3050 s = strcat("^2Waiting for others to ready up to end warmup...");
3052 s = strcat("^2Waiting for others to ready up...");
3054 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3055 o += eY * fontsize_y;
3057 else if(warmup_stage && !intermission && !spectatee_status)
3059 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
3060 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3061 o += eY * fontsize_y;
3064 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
3066 float ts_min, ts_max;
3067 tm = teams.sort_next;
3070 for(; tm.sort_next; tm = tm.sort_next)
3072 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
3074 if(!ts_min) ts_min = tm.team_size;
3075 else ts_min = min(ts_min, tm.team_size);
3076 if(!ts_max) ts_max = tm.team_size;
3077 else ts_max = max(ts_max, tm.team_size);
3079 if ((ts_max - ts_min) > 1)
3081 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
3082 tm = GetTeam(myteam, false);
3084 if (tm.team != COLOR_SPECTATOR)
3085 if (tm.team_size == ts_max)
3086 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
3088 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3089 o += eY * fontsize_y;
3095 s = "^7Press ^3ESC ^7to show HUD options.";
3096 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3097 o += eY * fontsize_y;
3098 s = "^3Doubleclick a panel for panel-specific options.";
3099 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3100 o += eY * fontsize_y;
3106 void HUD_Timer(void)
3108 float id = HUD_PANEL_TIMER;
3110 pos = HUD_Panel_GetPos(id);
3111 mySize = HUD_Panel_GetSize(id);
3113 HUD_Panel_DrawBg(id, pos, mySize, 0);
3115 padding = HUD_Panel_GetPadding(id);
3118 pos += '1 1 0' * padding;
3119 mySize -= '2 2 0' * padding;
3122 float timelimit, elapsedTime, minutes, seconds, timeleft, minutesLeft, secondsLeft;
3124 timelimit = getstatf(STAT_TIMELIMIT);
3126 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3127 timeleft = ceil(timeleft);
3128 minutesLeft = floor(timeleft / 60);
3129 secondsLeft = timeleft - minutesLeft*60;
3132 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3133 timer_color = '1 1 1'; //white
3134 else if(minutesLeft >= 1)
3135 timer_color = '1 1 0'; //yellow
3137 timer_color = '1 0 0'; //red
3139 if (cvar("hud_timer_increment") || timelimit == 0 || warmup_stage) {
3140 if (time < getstatf(STAT_GAMESTARTTIME)) {
3141 //while restart is still active, show 00:00
3142 minutes = seconds = 0;
3144 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3145 minutes = floor(elapsedTime / 60);
3146 seconds = elapsedTime - minutes*60;
3149 minutes = minutesLeft;
3150 seconds = secondsLeft;
3155 minutes = min(minutes, 999);
3156 if(minutesLeft >= 1 || cvar("hud_timer_increment") || timelimit == 0 || warmup_stage) {
3157 HUD_DrawXNum(pos + eX * mySize_x - eX * 5.1 * mySize_y, minutes, 3, 0, mySize_y, timer_color, 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3158 drawpic_skin(pos + eX * mySize_x - eX * 2.57 * mySize_y, "num_colon", '1 1 0' * mySize_y, timer_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3160 HUD_DrawXNum(pos + eX * mySize_x - eX * 2 * mySize_y, seconds, -2, 0, mySize_y, timer_color, 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3165 void HUD_Radar(void)
3167 float id = HUD_PANEL_RADAR;
3169 pos = HUD_Panel_GetPos(id);
3170 mySize = HUD_Panel_GetSize(id);
3172 HUD_Panel_DrawBg(id, pos, mySize, 0);
3174 padding = HUD_Panel_GetPadding(id);
3177 pos += '1 1 0' * padding;
3178 mySize -= '2 2 0' * padding;
3181 local float color1, color2; // color already declared as a global in hud.qc
3184 float scale2d, normalsize, bigsize;
3187 teamradar_origin2d = pos + 0.5 * mySize;
3188 teamradar_size2d = mySize;
3190 if(minimapname == "")
3193 teamradar_loadcvars();
3195 switch(hud_radar_zoommode)
3199 f = current_zoomfraction;
3202 f = 1 - current_zoomfraction;
3212 switch(hud_radar_rotation)
3215 teamradar_angle = view_angles_y - 90;
3218 teamradar_angle = 90 * hud_radar_rotation;
3222 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3223 teamradar_size2d = mySize;
3225 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3227 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3228 if(hud_radar_rotation == 0)
3230 // max-min distance must fit the radar in any rotation
3231 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3235 vector c0, c1, c2, c3, span;
3236 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3237 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3238 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3239 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3241 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3242 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3244 // max-min distance must fit the radar in x=x, y=y
3246 teamradar_size2d_x * scale2d / (1.05 * span_x),
3247 teamradar_size2d_y * scale2d / (1.05 * span_y)
3251 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3252 if(bigsize > normalsize)
3253 normalsize = bigsize;
3257 + (1 - f) * normalsize;
3258 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3259 f * (mi_min + mi_max) * 0.5
3260 + (1 - f) * view_origin);
3262 color1 = GetPlayerColor(player_localentnum-1);
3263 rgb = GetTeamRGB(color1);
3272 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3274 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3275 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3276 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3277 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, HUD_Panel_GetFgAlpha(id));
3278 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3280 color2 = GetPlayerColor(tm.sv_entnum);
3281 //if(color == COLOR_SPECTATOR || color == color2)
3282 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3284 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3286 drawresetcliparea();
3291 void HUD_Score(void)
3293 float id = HUD_PANEL_SCORE;
3295 pos = HUD_Panel_GetPos(id);
3296 mySize = HUD_Panel_GetSize(id);
3298 HUD_Panel_DrawBg(id, pos, mySize, 0);
3300 padding = HUD_Panel_GetPadding(id);
3303 pos += '1 1 0' * padding;
3304 mySize -= '2 2 0' * padding;
3307 float score, distribution, leader;
3308 float score_len, distr_len;
3309 vector distribution_color;
3311 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3313 // TODO... this (race part) still uses constant coordinates :/
3314 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3315 /*pl = players.sort_next;
3318 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3319 if(pl.scores[ps_primary] == 0)
3322 score = me.(scores[ps_primary]);
3324 float racemin, racesec, racemsec;
3325 float distsec, distmsec, minusplus;
3327 racemin = floor(score/(60 * TIME_FACTOR));
3328 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
3329 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
3331 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3332 // distribution display
3333 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3335 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
3336 distmsec = fabs(distribution);
3338 distsec = floor(fabs(distribution)/TIME_FACTOR);
3339 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
3340 if (distribution < 0)
3344 if (distribution <= 0) {
3345 distribution_color = eY;
3346 minusplus = 1; // minusplus 1: always prefix with minus sign
3349 distribution_color = eX;
3350 minusplus = 2; // minusplus 1: always prefix with plus sign
3352 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);
3353 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);
3354 drawpic_skin(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "num_dot", '16 16 0', distribution_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE);
3356 // race record display
3357 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
3358 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);
3360 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);
3361 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);
3362 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);
3364 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);
3365 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);
3367 } else if (!teamplay) { // non-teamgames
3368 // me vector := [team/connected frags id]
3369 pl = players.sort_next;
3376 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3380 score = me.(scores[ps_primary]);
3384 if(distribution >= 5) {
3385 distribution_color = eY;
3387 } else if(distribution >= 0) {
3388 distribution_color = '1 1 1';
3390 } else if(distribution >= -5)
3391 distribution_color = '1 1 0';
3393 distribution_color = eX;
3395 score_len = strlen(ftos(score));
3396 distr_len = strlen(ftos(distribution));
3398 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);
3400 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);
3401 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);
3402 } else { // teamgames
3403 float max_fragcount;
3404 max_fragcount = -99;
3407 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3408 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !hud_configure)) // no players? don't display
3410 score = tm.(teamscores[ts_primary]);
3415 score_len = strlen(ftos(score));
3417 if (score > max_fragcount)
3418 max_fragcount = score;
3420 if(tm.team == myteam) {
3421 if (max_fragcount == score)
3424 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);
3425 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);
3427 if (max_fragcount == score)
3430 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);
3431 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);
3440 void HUD_RaceTimer (void) {
3441 float id = HUD_PANEL_RACETIMER;
3443 pos = HUD_Panel_GetPos(id);
3444 mySize = HUD_Panel_GetSize(id);
3446 HUD_Panel_DrawBg(id, pos, mySize, 0);
3448 padding = HUD_Panel_GetPadding(id);
3451 pos += '1 1 0' * padding;
3452 mySize -= '2 2 0' * padding;
3455 drawfont = hud_bigfont;
3457 string s, forcetime;
3462 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);
3463 s = "^1Intermediate 1 (+15.42)";
3464 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);
3465 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3466 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);
3468 else if(race_checkpointtime)
3470 a = bound(0, 2 - (time - race_checkpointtime), 1);
3473 if(a > 0) // just hit a checkpoint?
3475 if(race_checkpoint != 254)
3477 if(race_time && race_previousbesttime)
3478 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3480 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3482 forcetime = TIME_ENCODED_TOSTRING(race_time);
3487 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3489 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3490 if(a > 0) // next one?
3492 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3497 if(s != "" && a > 0)
3499 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3500 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3501 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);
3504 if(race_penaltytime)
3506 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3509 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3510 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3511 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3512 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);
3518 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3519 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id), 0, a);
3520 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);
3525 if(race_laptime && race_checkpoint != 255)
3527 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3528 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3529 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);
3534 if(race_mycheckpointtime)
3536 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3537 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3538 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3539 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3540 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);
3542 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3544 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3545 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3546 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3547 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3548 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3551 if(race_penaltytime && !race_penaltyaccumulator)
3553 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3554 a = bound(0, (1 + t - time), 1);
3558 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3560 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3561 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3562 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3563 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3568 drawfont = hud_font;
3573 float vote_yescount;
3576 float vote_highlighted; // currently selected vote
3578 float vote_active; // is there an active vote?
3579 float vote_prev; // previous state of vote_active to check for a change
3581 float vote_change; // "time" when vote_active changed
3583 void HUD_VoteWindow(void)
3585 float id = HUD_PANEL_VOTE;
3587 pos = HUD_Panel_GetPos(id);
3588 mySize = HUD_Panel_GetSize(id);
3592 if(vote_active != vote_prev) {
3594 vote_prev = vote_active;
3597 if(vote_active || hud_configure)
3598 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3600 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3612 a = vote_alpha * bound(cvar_or("hud_vote_alreadyvoted_alpha", 0.75), 1 - vote_highlighted, 1);
3614 HUD_Panel_DrawBg(id, pos, mySize, a);
3616 padding = HUD_Panel_GetPadding(id);
3619 pos += '1 1 0' * padding;
3620 mySize -= '2 2 0' * padding;
3623 drawpic_skin(pos, "voteprogress_back", mySize, '1 1 1', a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3625 s = "A vote has been called for: ";
3626 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);
3627 s = textShortenToWidth(vote_called_vote, mySize_x * 0.96, '1 1 0' * mySize_y*(1/5), stringwidth_colors); // TODO: broken?
3629 s = "Configure the HUD";
3630 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);
3632 // print the yes/no counts
3633 s = strcat("Yes: ", ftos(vote_yescount));
3634 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);
3635 s = strcat("No: ", ftos(vote_nocount));
3636 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);
3638 // draw the progress bars
3639 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3640 drawpic_skin(pos, "voteprogress_prog", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3642 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3643 drawpic_skin(pos, "voteprogress_prog", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3645 // draw the highlights
3646 if(vote_highlighted == 1) {
3647 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3648 drawpic_skin(pos, "voteprogress_voted", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3650 else if(vote_highlighted == 2) {
3651 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3652 drawpic_skin(pos, "voteprogress_voted", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3655 drawresetcliparea();
3658 vote_highlighted = 0;
3662 // Mod icons panel (#10)
3665 float mod_active; // is there any active mod icon?
3667 // CTF HUD modicon section
3668 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3669 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3670 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3672 void HUD_Mod_CTF_Reset(void)
3674 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3677 void HUD_Mod_CTF(vector pos, vector mySize)
3679 vector redflag_pos, blueflag_pos;
3680 float f; // every function should have that
3682 float redflag, blueflag; // current status
3683 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3686 stat_items = getstati(STAT_ITEMS);
3687 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3688 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3690 if(redflag || blueflag)
3701 // when status CHANGES, set old status into prevstatus and current status into status
3702 if (redflag != redflag_prevframe)
3704 redflag_statuschange_time = time;
3705 redflag_prevstatus = redflag_prevframe;
3706 redflag_prevframe = redflag;
3709 if (blueflag != blueflag_prevframe)
3711 blueflag_statuschange_time = time;
3712 blueflag_prevstatus = blueflag_prevframe;
3713 blueflag_prevframe = blueflag;
3716 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3717 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3719 float BLINK_FACTOR = 0.15;
3720 float BLINK_BASE = 0.85;
3722 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3724 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3726 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3728 string red_icon, red_icon_prevstatus;
3729 float red_alpha, red_alpha_prevstatus;
3730 red_alpha = red_alpha_prevstatus = 1;
3732 case 1: red_icon = "flag_red_taken"; break;
3733 case 2: red_icon = "flag_red_lost"; break;
3734 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3736 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3737 red_icon = "flag_red_shielded";
3739 red_icon = string_null;
3742 switch(redflag_prevstatus) {
3743 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3744 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3745 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3748 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3749 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3750 red_icon_prevstatus = "flag_red_shielded";
3752 red_icon_prevstatus = string_null;
3756 string blue_icon, blue_icon_prevstatus;
3757 float blue_alpha, blue_alpha_prevstatus;
3758 blue_alpha = blue_alpha_prevstatus = 1;
3760 case 1: blue_icon = "flag_blue_taken"; break;
3761 case 2: blue_icon = "flag_blue_lost"; break;
3762 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3764 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3765 blue_icon = "flag_blue_shielded";
3767 blue_icon = string_null;
3770 switch(blueflag_prevstatus) {
3771 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3772 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3773 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3776 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3777 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3778 blue_icon_prevstatus = "flag_blue_shielded";
3780 blue_icon_prevstatus = string_null;
3784 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3786 blueflag_pos = pos + eX * mySize_y;
3789 redflag_pos = pos + eX * mySize_y;
3792 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3793 if(red_icon_prevstatus && f < 1)
3794 drawpic_skin_expanding(redflag_pos, red_icon_prevstatus, '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3796 drawpic_skin(redflag_pos, red_icon, '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * red_alpha * f, DRAWFLAG_NORMAL);
3798 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3799 if(blue_icon_prevstatus && f < 1)
3800 drawpic_skin_expanding(blueflag_pos, blue_icon_prevstatus, '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3802 drawpic_skin(blueflag_pos, blue_icon, '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * blue_alpha * f, DRAWFLAG_NORMAL);
3805 // Keyhunt HUD modicon section
3806 float kh_runheretime;
3808 void HUD_Mod_KH_Reset(void)
3813 void HUD_Mod_KH(vector pos, vector mySize)
3815 mod_active = 1; // keyhunt should never hide the mod icons panel
3819 vector p, pa, kh_size, kh_asize;
3822 p_y = pos_y + 0.25 * mySize_y;
3824 kh_keys = getstati(STAT_KH_KEYS);
3826 kh_size_x = mySize_x * 0.25;
3827 kh_size_y = 0.75 * mySize_y;
3829 pa = p - eY * 0.25 * mySize_y;
3831 kh_asize_x = mySize_x * 0.25;
3832 kh_asize_y = mySize_y * 0.25;
3838 for(i = 0; i < 4; ++i)
3840 key = floor(kh_keys / pow(32, i)) & 31;
3842 if(keyteam == 30 && keycount <= 4)
3844 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3848 // this yields 8 exactly if "RUN HERE" shows
3853 kh_runheretime = time;
3854 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3859 for(i = 0; i < 4; ++i)
3861 key = floor(kh_keys / pow(32, i)) & 31;
3874 default: // owned or dropped
3879 a = a * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3880 aa = aa * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3886 drawpic_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3889 drawpic_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3892 drawpic_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3895 drawpic_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3900 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3903 drawpic_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3906 drawpic_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3909 drawpic_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3912 drawpic_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3916 p_x += 0.25 * mySize_x;
3917 pa_x += 0.25 * mySize_x;
3921 // Nexball HUD mod icon
3922 void HUD_Mod_NexBall(vector pos, vector mySize)
3924 float stat_items, nb_pb_starttime, dt, p;
3926 stat_items = getstati(STAT_ITEMS);
3927 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3929 if (stat_items & IT_KEY1)
3934 //Manage the progress bar if any
3935 if (nb_pb_starttime > 0)
3937 dt = mod(time - nb_pb_starttime, nb_pb_period);
3938 // one period of positive triangle
3939 p = 2 * dt / nb_pb_period;
3944 HUD_Panel_DrawProgressBar(pos, 0, eX * p * mySize_x + eY * mySize_y, HUD_Panel_GetProgressBarColor("nexball"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3947 pos_x += 0.5 * mySize_x - 0.5 * mySize_y; //horizontal margin to the picture
3949 if (stat_items & IT_KEY1)
3950 drawpic_skin(pos, "nexball_carrying", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3953 // Race/CTS HUD mod icons
3954 float crecordtime_prev; // last remembered crecordtime
3955 float crecordtime_change_time; // time when crecordtime last changed
3956 float srecordtime_prev; // last remembered srecordtime
3957 float srecordtime_change_time; // time when srecordtime last changed
3959 float race_status_time;
3960 float race_status_prev;
3961 string race_status_name_prev;
3962 void HUD_Mod_Race(vector pos, vector mySize)
3964 mod_active = 1; // race should never hide the mod icons panel
3966 me = playerslots[player_localentnum - 1];
3968 float f; // yet another function has this
3969 score = me.(scores[ps_primary]);
3971 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3972 return; // no records in the actual race
3974 drawfont = hud_bigfont;
3976 // clientside personal record
3978 if(gametype == GAME_CTS)
3982 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3984 if(score && (score < t || !t)) {
3985 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3986 if(cvar("cl_autodemo_delete_keeprecords"))
3988 f = cvar("cl_autodemo_delete");
3990 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3994 if(t != crecordtime_prev) {
3995 crecordtime_prev = t;
3996 crecordtime_change_time = time;
3998 f = time - crecordtime_change_time;
4001 drawstring(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4002 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);
4004 drawstring(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4005 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);
4006 drawstring_expanding(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL, f);
4007 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);
4011 t = race_server_record;
4012 if(t != srecordtime_prev) {
4013 srecordtime_prev = t;
4014 srecordtime_change_time = time;
4016 f = time - srecordtime_change_time;
4019 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);
4020 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);
4022 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);
4023 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);
4024 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);
4025 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);
4028 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4029 race_status_time = time + 5;
4030 race_status_prev = race_status;
4031 if (race_status_name_prev)
4032 strunzone(race_status_name_prev);
4033 race_status_name_prev = strzone(race_status_name);
4036 pos_x += mySize_x/2;
4039 a = bound(0, race_status_time - time, 1);
4042 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4046 rank = race_CheckName(race_status_name);
4048 rankname = race_PlaceName(rank);
4051 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4053 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4055 if(race_status == 0)
4056 drawpic_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4057 else if(race_status == 1) {
4058 drawpic_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4059 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4060 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4061 } else if(race_status == 2) {
4062 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4063 drawpic_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4065 drawpic_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4066 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4067 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4068 } else if(race_status == 3) {
4069 drawpic_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4070 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4071 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4074 if (race_status_time - time <= 0) {
4075 race_status_prev = -1;
4077 if(race_status_name)
4078 strunzone(race_status_name);
4079 race_status_name = string_null;
4080 if(race_status_name_prev)
4081 strunzone(race_status_name_prev);
4082 race_status_name_prev = string_null;
4084 drawfont = hud_font;
4087 float mod_prev; // previous state of mod_active to check for a change
4089 float mod_change; // "time" when mod_active changed
4091 void HUD_ModIcons(void)
4093 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !hud_configure)
4096 float id = HUD_PANEL_MODICONS;
4098 pos = HUD_Panel_GetPos(id);
4099 mySize = HUD_Panel_GetSize(id);
4101 if(mod_active != mod_prev) {
4103 mod_prev = mod_active;
4106 if(mod_active || hud_configure)
4107 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4109 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4112 HUD_Panel_DrawBg(id, pos, mySize, mod_alpha);
4115 padding = HUD_Panel_GetPadding(id);
4118 pos += '1 1 0' * padding;
4119 mySize -= '2 2 0' * padding;
4122 // these MUST be ran in order to update mod_active
4123 if(gametype == GAME_KEYHUNT)
4124 HUD_Mod_KH(pos, mySize);
4125 else if(gametype == GAME_CTF || hud_configure)
4126 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4127 else if(gametype == GAME_NEXBALL)
4128 HUD_Mod_NexBall(pos, mySize);
4129 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4130 HUD_Mod_Race(pos, mySize);
4133 // Draw pressed keys (#11)
4135 void HUD_DrawPressedKeys(void)
4137 float id = HUD_PANEL_PRESSEDKEYS;
4139 pos = HUD_Panel_GetPos(id);
4140 mySize = HUD_Panel_GetSize(id);
4142 HUD_Panel_DrawBg(id, pos, mySize, 0);
4144 padding = HUD_Panel_GetPadding(id);
4147 pos += '1 1 0' * padding;
4148 mySize -= '2 2 0' * padding;
4153 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4154 drawpic_skin(pos, "key_bg.tga", mySize, '1 1 1', 0.1 * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4155 drawpic_skin(pos + eX * mySize_x - eX * 0.22 * mySize_x + eY * 0.195 * mySize_y, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), '1 1 0' * (1/3) * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4156 drawpic_skin(pos + eX * 0.5 * mySize_x - eX * 0.23 * mySize_y + eY * 0.040 * mySize_y, ((pressedkeys & KEY_FORWARD) ? "key_forward_inv.tga" : "key_forward.tga"), '1 1 0' * 0.46 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4157 drawpic_skin(pos + eX * 0.023 * mySize_x + eY * 0.195 * mySize_y, ((pressedkeys & KEY_JUMP) ? "key_jump_inv.tga" : "key_jump.tga"), '1 1 0' * (1/3) * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4158 drawpic_skin(pos + eX * 0.1 * mySize_x + eY * 0.486 * mySize_y, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), '1 1 0' * 0.46 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4159 drawpic_skin(pos + eX * 0.5 * mySize_x - eX * 0.23 * mySize_y + eY * 0.486 * mySize_y, ((pressedkeys & KEY_BACKWARD) ? "key_backward_inv.tga" : "key_backward.tga"), '1 1 0' * 0.46 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4160 drawpic_skin(pos + eX * mySize_x - eX * 0.372 * mySize_x + eY * 0.486 * mySize_y, ((pressedkeys & KEY_RIGHT) ? "key_right_inv.tga" : "key_right.tga"), '1 1 0' * 0.46 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4163 // Handle chat as a panel (#12)
4167 float id = HUD_PANEL_CHAT;
4169 pos = HUD_Panel_GetPos(id);
4170 mySize = HUD_Panel_GetSize(id);
4172 HUD_Panel_DrawBg(id, pos, mySize, 0);
4174 padding = HUD_Panel_GetPadding(id);
4177 pos += '1 1 0' * padding;
4178 mySize -= '2 2 0' * padding;
4181 cvar_set("con_chatrect", "1");
4183 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4184 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4186 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4187 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4192 chatsize = cvar("con_chatsize");
4193 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4195 for(i = 0; i < cvar("con_chat"); ++i)
4197 if(i == cvar("con_chat") - 1)
4198 a = HUD_Panel_GetFgAlpha(id);
4200 a = HUD_Panel_GetFgAlpha(id) * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4201 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);
4206 // Engine info panel (#13)
4213 float frametimeavg1; // 1 frame ago
4214 float frametimeavg2; // 2 frames ago
4215 void HUD_EngineInfo(void)
4217 float id = HUD_PANEL_ENGINEINFO;
4219 pos = HUD_Panel_GetPos(id);
4220 mySize = HUD_Panel_GetSize(id);
4222 HUD_Panel_DrawBg(id, pos, mySize, 0);
4224 padding = HUD_Panel_GetPadding(id);
4227 pos += '1 1 0' * padding;
4228 mySize -= '2 2 0' * padding;
4231 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4233 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4234 frametimeavg2 = frametimeavg1;
4235 frametimeavg1 = frametimeavg;
4238 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4239 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.
4241 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
4242 prevfps = (1/frametime);
4243 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"
4249 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4251 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4253 prevfps_time = time;
4258 color = HUD_Get_Num_Color (prevfps, 100);
4259 drawstring(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), '1 1 0' * 0.5 * mySize_y, color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4267 void HUD_ShowSpeed(void)
4270 float pos, conversion_factor;
4271 string speed, zspeed, unit;
4273 switch(cvar("cl_showspeed_unit"))
4278 conversion_factor = 1.0;
4282 conversion_factor = 1.0;
4286 conversion_factor = 0.0254;
4290 conversion_factor = 0.0254 * 3.6;
4294 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4298 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4302 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4304 numsize_x = numsize_y = cvar("cl_showspeed_size");
4305 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4307 drawfont = hud_bigfont;
4308 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4310 if (cvar("cl_showspeed_z") == 1) {
4311 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4312 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4315 drawfont = hud_font;
4318 vector acc_prevspeed;
4322 void HUD_ShowAcceleration(void)
4324 float acceleration, sz, scale, alpha, f;
4325 vector pos, top, rgb;
4326 top_x = vid_conwidth/2;
4329 f = time - acc_prevtime;
4330 if(cvar("cl_showacceleration_z"))
4331 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4333 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4334 acc_prevspeed = pmove_vel;
4335 acc_prevtime = time;
4337 f = bound(0, f * 10, 1);
4338 acc_avg = acc_avg * (1 - f) + acceleration * f;
4339 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4341 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4343 sz = cvar("cl_showacceleration_size");
4344 scale = cvar("cl_showacceleration_scale");
4345 alpha = cvar("cl_showacceleration_alpha");
4346 if (cvar("cl_showacceleration_color_custom"))
4347 rgb = stov(cvar_string("cl_showacceleration_color"));
4350 if (acceleration < 0) {
4351 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4352 } else if (acceleration > 0) {
4353 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4357 if (acceleration > 0)
4358 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4359 else if (acceleration < 0)
4360 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4363 void HUD_Reset (void)
4365 // reset gametype specific icons
4366 if(gametype == GAME_KEYHUNT)
4368 else if(gametype == GAME_CTF)
4369 HUD_Mod_CTF_Reset();
4372 void HUD_Main (void)
4374 if(disable_menu_alphacheck == 1)
4375 menu_fade_alpha = 1;
4377 menu_fade_alpha = (1 - cvar("_menu_alpha"));
4378 hud_fg_alpha = cvar("hud_fg_alpha");
4380 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4381 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4382 hud_color_bg_team = cvar("hud_color_bg_team");
4384 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4385 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4387 hud_configure = cvar("_hud_configure");
4391 // HUD configure visible grid
4392 if(hud_configure && cvar("hud_configure_grid") && cvar("hud_configure_grid_alpha"))
4396 for(i = 0; i < 1/bound(0.005, bound(0.005, cvar("hud_configure_grid_x"), 0.2), 0.2); ++i)
4398 drawfill(eX * i * vid_conwidth * bound(0.005, bound(0.005, cvar("hud_configure_grid_x"), 0.2), 0.2), eX + eY * vid_conheight, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
4401 for(i = 0; i < 1/bound(0.005, bound(0.005, cvar("hud_configure_grid_y"), 0.2), 0.2); ++i)
4403 drawfill(eY * i * vid_conheight * bound(0.005, bound(0.005, cvar("hud_configure_grid_y"), 0.2), 0.2), eY + eX * vid_conwidth, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
4407 if(cvar_string("hud_dock") != "")
4408 drawpic_skin('0 0 0', cvar_string("hud_dock"), eX * vid_conwidth + eY * vid_conheight, HUD_Panel_Dock_GetColor(), cvar("hud_dock_alpha") * menu_fade_alpha, DRAWFLAG_NORMAL);
4410 if(HUD_Panel_CheckActive(HUD_PANEL_WEAPONICONS) || hud_configure)
4412 if(HUD_Panel_CheckActive(HUD_PANEL_INVENTORY) || hud_configure)
4414 if(HUD_Panel_CheckActive(HUD_PANEL_POWERUPS) || hud_configure)
4416 if(HUD_Panel_CheckActive(HUD_PANEL_HEALTHARMOR) || hud_configure)
4418 if(HUD_Panel_CheckActive(HUD_PANEL_NOTIFY) || hud_configure)
4420 if(HUD_Panel_CheckActive(HUD_PANEL_TIMER) || hud_configure)
4423 if(HUD_Panel_CheckActive(HUD_PANEL_RADAR) || hud_configure)
4424 if(cvar_string("hud_radar") != "0" && (cvar("hud_radar") == 2 || teamplay))
4426 if(HUD_Panel_CheckActive(HUD_PANEL_SCORE) || hud_configure)
4428 if(HUD_Panel_CheckActive(HUD_PANEL_RACETIMER) || hud_configure)
4429 if(gametype == GAME_RACE || gametype == GAME_CTS || hud_configure)
4431 if(HUD_Panel_CheckActive(HUD_PANEL_VOTE) || hud_configure)
4433 if(HUD_Panel_CheckActive(HUD_PANEL_MODICONS) || hud_configure)
4436 if(HUD_Panel_CheckActive(HUD_PANEL_PRESSEDKEYS) || hud_configure)
4437 if(spectatee_status > 0 || cvar("hud_pressedkeys") >= 2 || hud_configure)
4438 HUD_DrawPressedKeys();
4439 if(HUD_Panel_CheckActive(HUD_PANEL_CHAT) || hud_configure)
4442 cvar_set("con_csqcpositioning", "0");
4443 if(HUD_Panel_CheckActive(HUD_PANEL_ENGINEINFO) || hud_configure)
4446 // TODO hud_'ify these
4447 if (cvar("cl_showspeed"))
4449 if (cvar("cl_showacceleration"))
4450 HUD_ShowAcceleration();
4452 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)
4453 localcmd("cmd selectteam auto; cmd join\n");
4455 if (!hud_configure) // hud config mode disabled, enable normal alpha stuff again
4456 disable_menu_alphacheck = 0;