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;
741 pos_x = vid_conwidth + pos_x;
743 pos_y = vid_conheight + pos_y;
745 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
747 vector mySize, menu_enable_panelpos;
748 mySize = HUD_Panel_GetSize(id);
749 if(mySize_x > mySize_y)
750 menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * mySize_x + eY * 0.82 * vid_conheight;
752 menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * mySize_y + eX * 0.7 * vid_conwidth;
753 pos = (1 - cvar("_menu_alpha")) * pos + (cvar("_menu_alpha")) * menu_enable_panelpos;
758 float HUD_Panel_GetBorder(float id)
761 border = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_border"));
763 border = cvar_string("hud_bg_border");
767 vector HUD_Panel_GetColor(float id)
773 // fetch per-panel color
774 if(teamplay && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")) != "") {
775 f = stof(getplayerkey(self.sv_entnum, "colors"));
776 color = vtos(colormapPaletteColor(mod(f, 16), 1) * cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")));
779 color = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color"));
780 color_vec = stov(color);
782 if(color == "") { // fetch default color
783 color = cvar_string("hud_bg_color");
784 color_vec = stov(color);
785 if(teamplay && cvar(strcat("hud_bg_color_team"))) {
786 f = stof(getplayerkey(self.sv_entnum, "colors"));
787 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_bg_color_team");
789 else if(color == "shirt") {
790 f = stof(getplayerkey(self.sv_entnum, "colors"));
791 color_vec = colormapPaletteColor(floor(f / 16), 0);
793 else if(color == "pants") {
794 f = stof(getplayerkey(self.sv_entnum, "colors"));
795 color_vec = colormapPaletteColor(mod(f, 16), 1);
798 else if(color == "shirt") {
799 f = stof(getplayerkey(self.sv_entnum, "colors"));
800 color_vec = colormapPaletteColor(floor(f / 16), 0);
802 else if(color == "pants") {
803 f = stof(getplayerkey(self.sv_entnum, "colors"));
804 color_vec = colormapPaletteColor(mod(f, 16), 1);
809 vector HUD_Panel_Dock_GetColor(void)
814 color = cvar_string("hud_dock_color");
815 color_vec = stov(color);
816 if(teamplay && cvar(strcat("hud_dock_color_team"))) {
817 f = stof(getplayerkey(self.sv_entnum, "colors"));
818 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_dock_color_team");
820 else if(color == "shirt") {
821 f = stof(getplayerkey(self.sv_entnum, "colors"));
822 color_vec = colormapPaletteColor(floor(f / 16), 0);
824 else if(color == "pants") {
825 f = stof(getplayerkey(self.sv_entnum, "colors"));
826 color_vec = colormapPaletteColor(mod(f, 16), 1);
831 float HUD_Panel_GetBgAlpha(float id)
834 alpha = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_alpha"));
836 alpha = cvar_string("hud_bg_alpha");
838 if(hud_configure && disable_menu_alphacheck == 2 && highlightedPanel == id) // do not set a minalpha cap when showing the config dialog for this panel
839 alpha = ftos((1 - cvar("_menu_alpha")) * max(cvar("hud_configure_bg_minalpha"), stof(alpha)) + (cvar("_menu_alpha")) * stof(alpha));
840 else if(hud_configure)
841 alpha = ftos(max(cvar("hud_configure_bg_minalpha"), stof(alpha)));
843 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
846 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
849 return stof(alpha) * menu_fade_alpha;
852 float HUD_Panel_GetFgAlpha(float id)
855 alpha = hud_fg_alpha;
857 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
860 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
863 return alpha * menu_fade_alpha;
866 float HUD_Panel_GetPadding(float id)
869 padding = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
871 padding = cvar_string("hud_bg_padding");
874 mySize = HUD_Panel_GetSize(id);
876 smallestsize = min(mySize_x, mySize_y);
877 return min(smallestsize/2 - 5, stof(padding));
880 // draw the background/borders
881 void HUD_Panel_DrawBg(float id, vector pos, vector mySize, float alpha)
883 if(!hud_configure && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg")) == "0")
887 bg = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg"));
889 bg = cvar_string("hud_bg");
891 if(bg == "0" && hud_configure) {
892 bg = "border"; // we probably want to see a background in config mode at all times...
898 border = max(0.0000001, HUD_Panel_GetBorder(id)); // draw_BorderPicture does not like border = 0
901 color = HUD_Panel_GetColor(id);
904 alpha = HUD_Panel_GetBgAlpha(id) * alpha; // allow panels to fade in/out by passing an alpha value
906 alpha = HUD_Panel_GetBgAlpha(id);
908 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));
912 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
914 //float drawsubpic(vector position, vector size, string pic, vector srcPosition, vector srcSize, vector rgb, float alpha, float flag) = #328;
916 pic = strcat("gfx/hud/", cvar_string("hud_skin"), "/");
918 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);
919 if(mySize_y/mySize_x > 2)
920 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);
921 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);
923 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);
924 if(mySize_x/mySize_y > 2)
925 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);
926 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);
930 vector HUD_Panel_GetProgressBarColor(string item)
932 return stov(cvar_string(strcat("hud_progressbar_", item, "_color")));
935 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
936 vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
947 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
948 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
950 for (i = 0; i < HUD_PANEL_NUM; ++i) {
951 if(i == id || !HUD_Panel_CheckActive(i))
954 targPos = HUD_Panel_GetPos(i) - '1 1 0' * HUD_Panel_GetBorder(id);
955 targSize = HUD_Panel_GetSize(i) + '2 2 0' * HUD_Panel_GetBorder(id);
957 if(myPos_y + mySize_y < targPos_y)
959 if(myPos_y > targPos_y + targSize_y)
962 if(myPos_x + mySize_x < targPos_x)
964 if(myPos_x > targPos_x + targSize_x)
967 // OK, there IS a collision.
969 myCenter_x = myPos_x + 0.5 * mySize_x;
970 myCenter_y = myPos_y + 0.5 * mySize_y;
972 targCenter_x = targPos_x + 0.5 * targSize_x;
973 targCenter_y = targPos_y + 0.5 * targSize_y;
975 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
977 if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
978 myTarget_x = targPos_x - mySize_x;
979 else // push it upwards
980 myTarget_y = targPos_y - mySize_y;
982 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
984 if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
985 myTarget_x = targPos_x + targSize_x;
986 else // push it upwards
987 myTarget_y = targPos_y - mySize_y;
989 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
991 if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
992 myTarget_x = targPos_x - mySize_x;
993 else // push it downwards
994 myTarget_y = targPos_y + targSize_y;
996 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
998 if(targPos_x + targSize_x - myPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
999 myTarget_x = targPos_x + targSize_x;
1000 else // push it downwards
1001 myTarget_y = targPos_y + targSize_y;
1008 void HUD_Panel_SetPos(float id, vector pos)
1011 oldPos = HUD_Panel_GetPos(id);
1014 mySize = HUD_Panel_GetSize(id);
1016 if(cvar("hud_configure_checkcollisions"))
1017 pos = HUD_Panel_CheckMove(id, pos, mySize);
1019 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
1020 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
1022 if(cvar("hud_configure_grid"))
1024 pos_x = floor(pos_x/cvar("hud_configure_grid_x") + 0.5) * cvar("hud_configure_grid_x");
1025 pos_y = floor(pos_y/cvar("hud_configure_grid_y") + 0.5) * cvar("hud_configure_grid_y");
1028 if (pos_x + 0.5 * mySize_x > 0.5 * vid_conwidth)
1029 pos_x = pos_x - vid_conwidth;
1030 if (pos_y + 0.5 * mySize_y > 0.5 * vid_conheight)
1031 pos_y = pos_y - vid_conheight;
1034 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
1036 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
1039 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
1040 vector HUD_Panel_CheckResize(float id, vector mySize, vector resizeorigin, float ratio) {
1049 for (i = 0; i < HUD_PANEL_NUM; ++i) {
1050 if(i == id || !HUD_Panel_CheckActive(i))
1053 targBorder = HUD_Panel_GetBorder(i);
1054 targPos = HUD_Panel_GetPos(i) - '1 1 0' * targBorder;
1055 targSize = HUD_Panel_GetSize(i) + '2 2 0' * targBorder;
1056 targEndPos = targPos + targSize;
1058 if (resizeCorner == 1)
1060 // check if this panel is on our way
1061 if (resizeorigin_x <= targPos_x)
1063 if (resizeorigin_y <= targPos_y)
1065 if (targEndPos_x <= resizeorigin_x - mySize_x)
1067 if (targEndPos_y <= resizeorigin_y - mySize_y)
1070 // there is a collision:
1071 // detect which side of the panel we are facing is actually limiting the resizing
1072 // (which side the resize direction finds for first) and reduce the size up to there
1074 // dist is the distance between resizeorigin and the "analogous" point of the panel
1075 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
1076 dist_x = resizeorigin_x - targEndPos_x;
1077 dist_y = resizeorigin_y - targEndPos_y;
1078 if (dist_y < 0 || dist_x / dist_y > ratio)
1079 mySize_x = min(mySize_x, dist_x);
1081 mySize_y = min(mySize_y, dist_y);
1083 else if (resizeCorner == 2)
1085 if (resizeorigin_x >= targEndPos_x)
1087 if (resizeorigin_y <= targPos_y)
1089 if (targPos_x >= resizeorigin_x + mySize_x)
1091 if (targEndPos_y <= resizeorigin_y - mySize_y)
1094 dist_x = targPos_x - resizeorigin_x;
1095 dist_y = resizeorigin_y - targEndPos_y;
1096 if (dist_y < 0 || dist_x / dist_y > ratio)
1097 mySize_x = min(mySize_x, dist_x);
1099 mySize_y = min(mySize_y, dist_y);
1101 else if (resizeCorner == 3)
1103 if (resizeorigin_x <= targPos_x)
1105 if (resizeorigin_y >= targEndPos_y)
1107 if (targEndPos_x <= resizeorigin_x - mySize_x)
1109 if (targPos_y >= resizeorigin_y + mySize_y)
1112 dist_x = resizeorigin_x - targEndPos_x;
1113 dist_y = targPos_y - resizeorigin_y;
1114 if (dist_y < 0 || dist_x / dist_y > ratio)
1115 mySize_x = min(mySize_x, dist_x);
1117 mySize_y = min(mySize_y, dist_y);
1119 else if (resizeCorner == 4)
1121 if (resizeorigin_x >= targEndPos_x)
1123 if (resizeorigin_y >= targEndPos_y)
1125 if (targPos_x >= resizeorigin_x + mySize_x)
1127 if (targPos_y >= resizeorigin_y + mySize_y)
1130 dist_x = targPos_x - resizeorigin_x;
1131 dist_y = targPos_y - resizeorigin_y;
1132 if (dist_y < 0 || dist_x / dist_y > ratio)
1133 mySize_x = min(mySize_x, dist_x);
1135 mySize_y = min(mySize_y, dist_y);
1137 if(cvar("hud_configure_checkcollisions_debug"))
1138 drawfill(targPos + '1 1 0' * targBorder, targSize - '2 2 0' * targBorder, '1 1 0', .3, DRAWFLAG_NORMAL);
1144 void HUD_Panel_SetPosSize(float id)
1146 vector resizeorigin;
1147 resizeorigin = panel_click_resizeorigin;
1148 vector mySize, myPos;
1150 if(resizeCorner == 1) {
1151 mySize_x = resizeorigin_x - (mousepos_x - panel_click_distance_x);
1152 mySize_y = resizeorigin_y - (mousepos_y - panel_click_distance_y);
1153 } else if(resizeCorner == 2) {
1154 mySize_x = mousepos_x + panel_click_distance_x - resizeorigin_x;
1155 mySize_y = panel_click_distance_y + resizeorigin_y - mousepos_y;
1156 } else if(resizeCorner == 3) {
1157 mySize_x = resizeorigin_x + panel_click_distance_x - mousepos_x;
1158 mySize_y = mousepos_y + panel_click_distance_y - resizeorigin_y;
1159 } else { // resizeCorner == 4
1160 mySize_x = mousepos_x - (resizeorigin_x - panel_click_distance_x);
1161 mySize_y = mousepos_y - (resizeorigin_y - panel_click_distance_y);
1164 // minimum panel size cap
1165 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1166 mySize_y = max(0.025 * vid_conheight, mySize_y);
1168 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.
1170 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
1171 mySize_y = max(2 * cvar("con_chatsize") + 2 * HUD_Panel_GetPadding(id), mySize_y);
1174 // cap against panel's own limits
1176 minSize = HUD_Panel_GetMinSize(id); // mySize_x at least minSize_x * mySize_y, and vice versa
1178 if(!minSize_x && minSize_y) // forced aspect ratio
1180 minSize_x = 1/minSize_y;
1181 fixedRatio = minSize_x;
1182 mySize_x = max(minSize_x * mySize_y, mySize_x);
1183 mySize_y = max(minSize_y * mySize_x, mySize_y);
1185 else if(minSize_x && !minSize_y) // hybrid aspect ratio, currently supported only in one dimension
1187 if (mySize_x/mySize_y < minSize_x) // resizing in x direction allows free aspect ratio
1189 fixedRatio = minSize_x;
1190 minSize_y = 1/minSize_x;
1191 mySize_y = max(minSize_y * mySize_x, mySize_y);
1192 mySize_x = max(minSize_x * mySize_y, mySize_x);
1195 fixedRatio = -minSize_x; //negative so that it will be used ONLY after checkResize
1198 // collision testing|
1199 // -----------------+
1201 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
1202 if(resizeCorner == 1) {
1203 myPos_x = resizeorigin_x - mySize_x;
1204 myPos_y = resizeorigin_y - mySize_y;
1205 } else if(resizeCorner == 2) {
1206 myPos_x = resizeorigin_x;
1207 myPos_y = resizeorigin_y - mySize_y;
1208 } else if(resizeCorner == 3) {
1209 myPos_x = resizeorigin_x - mySize_x;
1210 myPos_y = resizeorigin_y;
1211 } else { // resizeCorner == 4
1212 myPos_x = resizeorigin_x;
1213 myPos_y = resizeorigin_y;
1216 // left/top screen edges
1218 mySize_x = mySize_x + myPos_x;
1220 mySize_y = mySize_y + myPos_y;
1222 // bottom/right screen edges
1223 if(myPos_x + mySize_x > vid_conwidth)
1224 mySize_x = vid_conwidth - myPos_x;
1225 if(myPos_y + mySize_y > vid_conheight)
1226 mySize_y = vid_conheight - myPos_y;
1228 if(cvar("hud_configure_checkcollisions_debug"))
1229 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
1231 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
1232 if(cvar("hud_configure_grid"))
1234 mySize_x = floor(mySize_x/cvar("hud_configure_grid_x") + 0.5) * cvar("hud_configure_grid_x");
1235 mySize_y = floor(mySize_y/cvar("hud_configure_grid_y") + 0.5) * cvar("hud_configure_grid_y");
1240 // keep aspect ratio _MAXIMIZING_ the size
1241 if (mySize_x / mySize_y > fixedRatio)
1242 mySize_y = mySize_x / fixedRatio;
1244 mySize_x = mySize_y * fixedRatio;
1247 if(cvar("hud_configure_checkcollisions"))
1251 mySize = HUD_Panel_CheckResize(id, mySize, resizeorigin, fixedRatio);
1253 // Make sure once more that we DON'T cross the screen edges
1254 // left/top screen edges
1256 mySize_x = mySize_x + myPos_x;
1258 mySize_y = mySize_y + myPos_y;
1260 // bottom/right screen edges
1261 if(myPos_x + mySize_x > vid_conwidth)
1262 mySize_x = vid_conwidth - myPos_x;
1263 if(myPos_y + mySize_y > vid_conheight)
1264 mySize_y = vid_conheight - myPos_y;
1266 // restore again aspect ratio, _minimizing_ the size
1267 if (mySize_x / mySize_y < fixedRatio)
1268 mySize_y = mySize_x / fixedRatio;
1270 mySize_x = mySize_y * fixedRatio;
1274 mySize = HUD_Panel_CheckResize(id, mySize, resizeorigin, mySize_x / mySize_y);
1277 fixedRatio = -fixedRatio;
1278 // restore again aspect ratio, _minimizing_ the size
1279 if (mySize_x / mySize_y < fixedRatio)
1280 mySize_y = mySize_x / fixedRatio;
1285 // 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)
1286 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1287 mySize_y = max(0.025 * vid_conheight, mySize_y);
1289 // do another pos check, as size might have changed by now
1290 if(resizeCorner == 1) {
1291 myPos_x = resizeorigin_x - mySize_x;
1292 myPos_y = resizeorigin_y - mySize_y;
1293 } else if(resizeCorner == 2) {
1294 myPos_x = resizeorigin_x;
1295 myPos_y = resizeorigin_y - mySize_y;
1296 } else if(resizeCorner == 3) {
1297 myPos_x = resizeorigin_x - mySize_x;
1298 myPos_y = resizeorigin_y;
1299 } else { // resizeCorner == 4
1300 myPos_x = resizeorigin_x;
1301 myPos_y = resizeorigin_y;
1304 if(cvar("hud_configure_checkcollisions_debug"))
1305 if(cvar("hud_configure_checkcollisions"))
1306 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
1309 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
1310 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_size"), s);
1312 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
1313 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
1317 float prevMouseClicked; // previous state
1318 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
1319 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
1322 float menu_enabled_time;
1323 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1328 // allow console bind to work
1331 con_keys = findkeysforcommand("toggleconsole");
1332 keys = tokenize(con_keys);
1334 float hit_con_bind, i;
1335 for (i = 0; i < keys; ++i)
1337 if(nPrimary == stof(argv(i)))
1341 if(nPrimary == K_MOUSE1)
1343 if(bInputType == 0) { // key pressed
1347 else if(bInputType == 1) {// key released
1352 else if(nPrimary == K_ESCAPE)
1354 disable_menu_alphacheck = 1;
1356 menu_enabled_time = time;
1357 localcmd("menu_showhudexit\n");
1360 else if(hit_con_bind)
1363 return true; // Suppress ALL other input
1366 void HUD_Panel_Mouse()
1368 // 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
1369 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1370 disable_menu_alphacheck = 0;
1371 if (cvar("_menu_alpha") == 0 && time - menu_enabled_time > 0.5)
1375 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1376 print("Highlighted: ", ftos(highlightedPanel), "\n");
1377 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1380 if(mouseClicked == 0 && disable_menu_alphacheck != 2) { // don't reset these variables in disable_menu_alphacheck mode 2!
1381 highlightedPanel = -1;
1382 highlightedAction = 0;
1385 mousepos = mousepos + getmousepos();
1387 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1388 mousepos_y = bound(0, mousepos_y, vid_conheight);
1390 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1398 for(i = 0; i < HUD_PANEL_NUM; ++i)
1400 panelPos = HUD_Panel_GetPos(i);
1401 panelSize = HUD_Panel_GetSize(i);
1402 border = HUD_Panel_GetBorder(i);
1403 if(prevMouseClicked == 0) {
1405 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1407 highlightedPanel = i;
1408 highlightedAction = 1;
1410 // resize from topleft border
1411 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)
1413 highlightedPanel = i;
1414 highlightedAction = 2;
1417 // resize from topright border
1418 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)
1420 highlightedPanel = i;
1421 highlightedAction = 2;
1424 // resize from bottomleft border
1425 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)
1427 highlightedPanel = i;
1428 highlightedAction = 2;
1431 // resize from bottomright border
1432 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)
1434 highlightedPanel = i;
1435 highlightedAction = 2;
1440 if(highlightedPanel == i)
1442 if(prevMouseClicked == 0)
1444 if(highlightedAction == 1)
1445 panel_click_distance = mousepos - panelPos;
1446 else if(highlightedAction == 2)
1448 if(resizeCorner == 1) {
1449 panel_click_distance = mousepos - panelPos;
1450 panel_click_resizeorigin = panelPos + panelSize;
1451 } else if(resizeCorner == 2) {
1452 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1453 panel_click_distance_y = mousepos_y - panelPos_y;
1454 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1455 } else if(resizeCorner == 3) {
1456 panel_click_distance_x = mousepos_x - panelPos_x;
1457 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1458 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1459 } else if(resizeCorner == 4) {
1460 panel_click_distance = panelSize - mousepos + panelPos;
1461 panel_click_resizeorigin = panelPos;
1466 if(cvar("hud_configure_checkcollisions_debug"))
1467 drawfill(panelPos, panelSize, '1 0 0', .3, DRAWFLAG_NORMAL);
1469 if(highlightedAction == 1)
1470 HUD_Panel_SetPos(i, mousepos - panel_click_distance);
1471 else if(highlightedAction == 2)
1472 HUD_Panel_SetPosSize(i);
1476 // doubleclick check
1477 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1479 mouseClicked = 0; // to prevent spam, I guess.
1480 disable_menu_alphacheck = 2;
1482 menu_enabled_time = time;
1483 localcmd("menu_showhudoptions ", ftos(highlightedPanel), "\n");
1486 if(prevMouseClicked == 0)
1488 prevMouseClickedTime = time;
1489 prevMouseClickedPos = mousepos;
1492 prevMouseClicked = mouseClicked;
1495 // Weapon icons (#0)
1497 float weaponspace[10];
1498 void HUD_WeaponIcons_Clear()
1501 for(idx = 0; idx < 10; ++idx)
1502 weaponspace[idx] = 0;
1505 entity weaponorder[WEP_MAXCOUNT];
1507 void weaponorder_swap(float i, float j, entity pass)
1511 weaponorder[i] = weaponorder[j];
1515 string weaponorder_cmp_str;
1516 float weaponorder_cmp(float i, float j, entity pass)
1519 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1520 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1521 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)
1524 void HUD_WeaponIcons(void)
1526 float id = HUD_PANEL_WEAPONICONS;
1527 float alpha, stat_weapons; // "constants"
1528 vector pos, mySize, accuracy_color;
1529 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1531 pos = HUD_Panel_GetPos(id);
1532 mySize = HUD_Panel_GetSize(id);
1534 stat_weapons = getstati(STAT_WEAPONS);
1535 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1537 self = get_weaponinfo(i);
1538 if(self.weapons && (self.impulse >= 0) && (stat_weapons & self.weapons) || hud_configure)
1540 weaponorder[weapon_cnt] = self;
1545 // TODO make this configurable
1546 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1547 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1549 HUD_Panel_DrawBg(id, pos, mySize, 0);
1551 padding = HUD_Panel_GetPadding(id);
1554 pos += '1 1 0' * padding;
1555 mySize -= '2 2 0' * padding;
1559 weapon_stats = getstati(STAT_DAMAGE_HITS);
1560 weapon_number = weapon_stats & 63;
1561 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1563 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1564 weapon_number = weapon_stats & 63;
1565 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1567 if(cvar_or("hud_weaponicons_fade", 1))
1569 fade = 3.2 - 2 * (time - weapontime);
1570 fade = bound(0.7, fade, 1);
1575 HUD_WeaponIcons_Clear();
1577 float rows, columns;
1578 rows = mySize_y/mySize_x;
1579 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1580 // ^^^ weapon icon aspect goes here
1582 columns = ceil(WEP_COUNT/rows);
1584 for(i = 0; i < weapon_cnt; ++i)
1586 self = weaponorder[i];
1587 if((self.weapons && (self.impulse >= 0) && (stat_weapons & self.weapons)) || hud_configure)
1589 weapid = self.impulse;
1591 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1593 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1594 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1596 // draw background behind currently selected weapon
1597 if(self.weapon == activeweapon)
1598 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);
1600 // draw the weapon accuracy on the HUD
1601 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1604 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1606 accuracy_color = HUD_AccuracyColor(weapon_stats);
1608 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);
1611 // draw the weapon icon
1612 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);
1614 if(cvar_or("hud_weaponicons_number", 1))
1615 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);
1630 float GetAmmoStat(float i)
1634 case 0: return STAT_SHELLS;
1635 case 1: return STAT_NAILS;
1636 case 2: return STAT_ROCKETS;
1637 case 3: return STAT_CELLS;
1638 case 4: return STAT_FUEL;
1643 float GetAmmoItemCode(float i)
1647 case 0: return IT_SHELLS;
1648 case 1: return IT_NAILS;
1649 case 2: return IT_ROCKETS;
1650 case 3: return IT_CELLS;
1651 case 4: return IT_FUEL;
1656 string GetAmmoPicture(float i)
1660 case 0: return "ammo_shells";
1661 case 1: return "ammo_bullets";
1662 case 2: return "ammo_rockets";
1663 case 3: return "ammo_cells";
1664 case 4: return "ammo_fuel";
1669 void HUD_Inventory(void)
1671 float id = HUD_PANEL_INVENTORY;
1675 vector pos, mySize, mysize, mypos;
1676 pos = HUD_Panel_GetPos(id);
1677 mySize = HUD_Panel_GetSize(id);
1679 HUD_Panel_DrawBg(id, pos, mySize, 0);
1681 padding = HUD_Panel_GetPadding(id);
1684 pos += '1 1 0' * padding;
1685 mySize -= '2 2 0' * padding;
1689 stat_items = getstati(STAT_ITEMS);
1690 for (i = 0; i < 4; ++i) {
1692 a = getstati(GetAmmoStat(i)); // how much ammo do we have of type i?
1696 if(cvar("hud_inventory_onlycurrent")) {
1699 if (stat_items & GetAmmoItemCode(i) || hud_configure) {
1700 drawpic_skin(pos, GetAmmoPicture(i), '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1702 HUD_DrawXNum(pos + eX * mySize_y + eY * 0.25 * mySize_y, a, strlen(ftos(a)), 0, 0.5 * mySize_y, '0.7 0 0', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1704 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);
1710 if(mySize_x/mySize_y >= 10) { // arrange horizontally
1712 case 0: mypos_x = pos_x; mypos_y = pos_y; break; // shells
1713 case 1: mypos_x = pos_x + 0.25 * mySize_x; mypos_y = pos_y; break; // bullets
1714 case 2: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y; break; // rockets
1715 case 3: mypos_x = pos_x + 0.75 * mySize_x; mypos_y = pos_y; break; // cells
1717 mysize_x = 0.25 * mySize_x;
1718 mysize_y = mySize_y;
1719 } else if(mySize_x/mySize_y >= 2.5) { // arrange in a 2x2 grid
1721 case 0: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y + 0.5 * mySize_y; break; // shells
1722 case 1: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y; break; // bullets
1723 case 2: mypos_x = pos_x; mypos_y = pos_y + 0.5 * mySize_y; break; // rockets
1724 case 3: mypos_x = pos_x; mypos_y = pos_y; break; // cells
1726 mysize_x = 0.5 * mySize_x;
1727 mysize_y = 0.5 * mySize_y;
1728 } else { // arrange vertically
1730 case 0: mypos_x = pos_x; mypos_y = pos_y; break; // shells
1731 case 1: mypos_x = pos_x; mypos_y = pos_y + 0.25 * mySize_y; break; // bullets
1732 case 2: mypos_x = pos_x; mypos_y = pos_y + 0.5 * mySize_y; break; // rockets
1733 case 3: mypos_x = pos_x; mypos_y = pos_y + 0.75 * mySize_y; break; // cells
1735 mysize_x = mySize_x;
1736 mysize_y = 0.25 * mySize_y;
1739 if (stat_items & GetAmmoItemCode(i))
1740 drawpic_skin(mypos, "ammo_current_bg", mysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1741 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);
1743 if(stat_items & GetAmmoItemCode(i))
1744 HUD_DrawXNum(mypos + eX * 0.8 * mysize_y + eY * 0.25 * mysize_y, a, strlen(ftos(a)), 0, 0.5 * mysize_y, '0.7 0 0', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1746 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);
1748 if(stat_items & GetAmmoItemCode(i))
1749 HUD_DrawXNum(mypos + eX * 0.8 * mysize_y + eY * 0.25 * mysize_y, a, strlen(ftos(a)), 0, 0.5 * mysize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1751 HUD_DrawXNum(mypos + eX * 0.8 * mysize_y + eY * 0.25 * mysize_y, a, strlen(ftos(a)), 0, 0.5 * mysize_y, '0.7 0.7 0.7', 0, 0, HUD_Panel_GetFgAlpha(id) * 0.7, DRAWFLAG_NORMAL);
1761 void HUD_Powerups(void) {
1762 float id = HUD_PANEL_POWERUPS;
1764 stat_items = getstati(STAT_ITEMS);
1768 if not(stat_items & IT_STRENGTH)
1769 if not(stat_items & IT_INVINCIBLE)
1772 if (getstati(STAT_HEALTH) <= 0)
1777 pos = HUD_Panel_GetPos(id);
1778 mySize = HUD_Panel_GetSize(id);
1780 HUD_Panel_DrawBg(id, pos, mySize, 0);
1782 padding = HUD_Panel_GetPadding(id);
1785 pos += '1 1 0' * padding;
1786 mySize -= '2 2 0' * padding;
1789 float strength_time, shield_time;
1791 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1792 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1802 vector barpos, barsize;
1806 string leftname, rightname;
1807 float leftcnt, rightcnt;
1808 float leftexact, rightexact;
1809 float leftalpha, rightalpha;
1810 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) {
1811 leftname = "strength";
1812 leftcnt = ceil(strength_time);
1813 leftexact = strength_time;
1815 rightname = "shield";
1816 rightcnt = ceil(shield_time);
1817 rightexact = shield_time;
1819 leftname = "shield";
1820 leftcnt = ceil(shield_time);
1821 leftexact = shield_time;
1823 rightname = "strength";
1824 rightcnt = ceil(strength_time);
1825 rightexact = strength_time;
1827 leftalpha = bound(0, leftexact, 1);
1828 rightalpha = bound(0, rightexact, 1);
1830 if (mySize_x/mySize_y > 4)
1834 len = strlen(ftos(leftcnt));
1836 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1837 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1838 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1839 picpos = pos + eX * 0.5 * mySize_x - eX * mySize_y;
1840 numpos = picpos - eX * 2 * 0.5 * mySize_y + eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1843 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1845 numpos = picpos + eX * mySize_y - eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1848 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1850 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));
1852 drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1853 HUD_DrawXNum(numpos, leftcnt, 2, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1858 len = strlen(ftos(rightcnt));
1860 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1861 barpos = pos + eX * 0.5 * mySize_x;
1862 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1863 picpos = pos + eX * 0.5 * mySize_x;
1864 numpos = picpos + eX * mySize_y - eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1866 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1867 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1868 picpos = pos + eX * mySize_x - eX * mySize_y;
1869 numpos = picpos - eX * mySize_y + eY * 0.25 * mySize_y;
1872 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1874 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));
1876 drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1877 HUD_DrawXNum(numpos, rightcnt, 2, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1880 else if (mySize_x/mySize_y > 1.5)
1884 len = strlen(ftos(leftcnt));
1886 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1887 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1888 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1889 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y;
1890 numpos = picpos - eX * len * 0.5 * mySize_y;
1893 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1895 numpos = picpos + eX * 0.5 * mySize_y;
1898 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1900 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));
1902 drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1903 HUD_DrawXNum(numpos, leftcnt, len, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1908 len = strlen(ftos(rightcnt));
1910 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1911 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1912 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1913 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y + eY * 0.5 * mySize_y;
1914 numpos = picpos - eX * len * 0.5 * mySize_y;
1916 barpos = pos + eY * 0.5 * mySize_y;
1917 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1918 picpos = pos + eY * 0.5 * mySize_y;
1919 numpos = picpos + eX * 0.5 * mySize_y;
1922 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1924 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));
1926 drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1927 HUD_DrawXNum(numpos, rightcnt, len, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1934 len = strlen(ftos(leftcnt));
1936 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1938 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1939 picpos = pos + eX * 0.05 * mySize_x;
1940 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x;
1942 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1943 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1944 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.65 * mySize_x;
1945 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.25 * mySize_x;
1948 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1950 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));
1952 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1953 HUD_DrawXNum(numpos, leftcnt, len, 0, 0.25 * mySize_x, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1958 len = strlen(ftos(rightcnt));
1960 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1961 barpos = pos + eX * 0.5 * mySize_x;
1962 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1963 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1964 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1966 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1967 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1968 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.65 * mySize_x + eX * 0.5 * mySize_x;
1969 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
1972 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1974 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));
1976 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1977 HUD_DrawXNum(numpos, rightcnt, len, 0, 0.25 * mySize_x, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1982 // Health/armor (#3)
1984 void HUD_HealthArmor(void)
1986 float id = HUD_PANEL_HEALTHARMOR;
1988 pos = HUD_Panel_GetPos(id);
1989 mySize = HUD_Panel_GetSize(id);
1991 HUD_Panel_DrawBg(id, pos, mySize, 0);
1993 padding = HUD_Panel_GetPadding(id);
1996 pos += '1 1 0' * padding;
1997 mySize -= '2 2 0' * padding;
2000 float armor, health;
2001 armor = getstati(STAT_ARMOR);
2002 health = getstati(STAT_HEALTH);
2005 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
2018 vector barpos, barsize;
2022 if(cvar("hud_healtharmor") == 2) // combined health and armor display
2025 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2030 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2031 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2032 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2034 numpos = picpos + eX * 1.5 * mySize_y;
2037 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2038 picpos = pos + eX * 3 * mySize_y;
2042 if(v_z) // NOT fully armored
2044 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("health"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2045 drawpic_skin(picpos, "health", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2047 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);
2051 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("armor"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2052 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);
2054 drawpic_skin(picpos, "armor", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2056 HUD_DrawXNum_Colored(numpos, x, 3, mySize_y, HUD_Panel_GetFgAlpha(id)); // draw the combined health and armor
2059 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2060 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2061 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2064 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2067 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2072 string leftname, rightname;
2073 float leftcnt, rightcnt;
2074 float leftactive, rightactive;
2075 float leftalpha, rightalpha;
2076 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) { // old style layout with armor left/top of health
2081 leftalpha = min((armor+10)/55, 1);
2083 rightname = "health";
2088 leftname = "health";
2093 rightname = "armor";
2097 rightalpha = min((armor+10)/55, 1);
2100 if (mySize_x/mySize_y > 5)
2104 len = strlen(ftos(leftcnt));
2106 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2107 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2108 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2109 picpos = pos + eX * 0.5 * mySize_x - eX * mySize_y;
2110 numpos = picpos - eX * 3 * 0.5 * mySize_y + eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
2113 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2115 numpos = picpos + eX * mySize_y + eY * 0.25 * mySize_y;
2118 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2119 drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2120 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2125 len = strlen(ftos(rightcnt));
2127 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2128 barpos = pos + eX * 0.5 * mySize_x;
2129 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2130 picpos = pos + eX * 0.5 * mySize_x;
2131 numpos = picpos + eX * mySize_y - eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
2133 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2134 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2135 picpos = pos + eX * mySize_x - eX * mySize_y;
2136 numpos = picpos - eX * 1.5 * mySize_y + eY * 0.25 * mySize_y;
2139 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2140 drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2141 HUD_DrawXNum_Colored(numpos, rightcnt, 3, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2144 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2145 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2146 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2149 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2152 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2154 else if (mySize_x/mySize_y > 2)
2158 len = strlen(ftos(leftcnt));
2160 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2161 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2162 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2163 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y;
2164 numpos = picpos - eX * len * 0.5 * mySize_y;
2167 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2169 numpos = picpos + eX * 0.5 * mySize_y;
2172 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2173 drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2174 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2179 len = strlen(ftos(rightcnt));
2181 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2182 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2183 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2184 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y + eY * 0.5 * mySize_y;
2185 numpos = picpos - eX * len * 0.5 * mySize_y;
2187 barpos = pos + eY * 0.5 * mySize_y;
2188 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2189 picpos = pos + eY * 0.5 * mySize_y;
2190 numpos = picpos + eX * 0.5 * mySize_y;
2193 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2194 drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2195 HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2198 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2199 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2200 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2203 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2206 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2212 len = strlen(ftos(leftcnt));
2214 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2216 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2217 picpos = pos + eX * 0.05 * mySize_x;
2218 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x;
2220 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2221 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2222 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x;
2223 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x;
2226 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2227 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2228 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.166 * mySize_x, HUD_Panel_GetFgAlpha(id));
2233 len = strlen(ftos(rightcnt));
2235 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2236 barpos = pos + eX * 0.5 * mySize_x;
2237 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2238 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2239 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2241 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2242 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2243 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x + eX * 0.5 * mySize_x;
2244 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x + eX * 0.5 * mySize_x;
2247 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2248 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2249 HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.166 * mySize_x, HUD_Panel_GetFgAlpha(id));
2252 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2254 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2256 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2257 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2260 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2266 // Notification area (#4)
2269 string Weapon_SuicideMessage(float deathtype)
2271 w_deathtype = deathtype;
2272 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2273 return w_deathtypestring;
2276 string Weapon_KillMessage(float deathtype)
2278 w_deathtype = deathtype;
2279 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2280 return w_deathtypestring;
2283 float killnotify_times[10];
2284 float killnotify_deathtype[10];
2285 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2286 string killnotify_attackers[10];
2287 string killnotify_victims[10];
2288 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2291 for (i = 9; i > 0; --i) {
2292 killnotify_times[i] = killnotify_times[i-1];
2293 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2294 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2295 if(killnotify_attackers[i])
2296 strunzone(killnotify_attackers[i]);
2297 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2298 if(killnotify_victims[i])
2299 strunzone(killnotify_victims[i]);
2300 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2302 killnotify_times[0] = time;
2303 killnotify_deathtype[0] = wpn;
2304 killnotify_actiontype[0] = actiontype;
2305 if(killnotify_attackers[0])
2306 strunzone(killnotify_attackers[0]);
2307 killnotify_attackers[0] = strzone(attacker);
2308 if(killnotify_victims[0])
2309 strunzone(killnotify_victims[0]);
2310 killnotify_victims[0] = strzone(victim);
2313 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2317 alsoprint = (cvar("hud_notify_print") || !HUD_Panel_CheckActive(4)); // print message to console if: notify panel disabled, or cvar to do so enabled
2319 if(msg == MSG_SUICIDE) {
2321 w = DEATH_WEAPONOF(type);
2323 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2325 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2326 } else if (type == DEATH_KILL) {
2327 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2329 print ("^1",s1, "^1 couldn't take it anymore\n");
2330 } else if (type == DEATH_ROT) {
2331 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2333 print ("^1",s1, "^1 died\n");
2334 } else if (type == DEATH_NOAMMO) {
2335 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2337 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2338 } else if (type == DEATH_CAMP) {
2339 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2341 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2342 } else if (type == DEATH_MIRRORDAMAGE) {
2343 HUD_KillNotify_Push(s1, "", 0, DEATH_MIRRORDAMAGE);
2345 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2346 } else if (type == DEATH_CHEAT) {
2347 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2349 print ("^1",s1, "^1 unfairly eliminated themself\n");
2350 } else if (type == DEATH_FIRE) {
2351 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2353 print ("^1",s1, "^1 burned to death\n");
2354 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2355 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2357 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2360 if (stof(s2) > 2) // killcount > 2
2361 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2362 } else if(msg == MSG_KILL) {
2363 w = DEATH_WEAPONOF(type);
2365 HUD_KillNotify_Push(s2, s1, 1, w);
2367 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2369 else if(type == KILL_TEAM || type == KILL_TEAM_SPREE) {
2370 HUD_KillNotify_Push(s1, s2, 1, DEATH_MIRRORDAMAGE);
2373 if(cvar("cl_gentle")) {
2374 print ("^1", s1, "^1 took action against a team mate\n");
2376 print ("^1", s1, "^1 mows down a team mate\n");
2379 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2380 if(cvar("cl_gentle"))
2381 print ("^1",s1,"^1 ended a ",s2," scoring spree by going against a team mate\n");
2383 print ("^1",s1,"^1 ended a ",s2," kill spree by killing a team mate\n");
2385 else if (stof(s2) > 2) {
2386 if(cvar("cl_gentle"))
2387 print ("^1",s1,"'s ^1",s2," scoring spree was ended by a team mate!\n");
2389 print ("^1",s1,"'s ^1",s2," kill spree was ended by a team mate!\n");
2392 else if(type == KILL_FIRST_BLOOD)
2393 print("^1",s1, "^1 drew first blood", "\n");
2395 else if (type == DEATH_TELEFRAG)
2396 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2397 else if (type == DEATH_DROWN) {
2398 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2400 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2402 else if (type == DEATH_SLIME) {
2403 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2405 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2407 else if (type == DEATH_LAVA) {
2408 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2410 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2412 else if (type == DEATH_FALL) {
2413 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2415 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2417 else if (type == DEATH_SHOOTING_STAR) {
2418 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2420 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2422 else if (type == DEATH_SWAMP) {
2423 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2425 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2427 else if (type == DEATH_HURTTRIGGER)
2429 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2431 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2432 } else if(type == DEATH_SBCRUSH) {
2433 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2435 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2436 } else if(type == DEATH_SBMINIGUN) {
2437 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2439 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2440 } else if(type == DEATH_SBROCKET) {
2441 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2443 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2444 } else if(type == DEATH_SBBLOWUP) {
2445 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2447 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2448 } else if(type == DEATH_WAKIGUN) {
2449 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2451 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2452 } else if(type == DEATH_WAKIROCKET) {
2453 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2455 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2456 } else if(type == DEATH_WAKIBLOWUP) {
2457 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2459 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2460 } else if(type == DEATH_TURRET) {
2461 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2463 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2464 } else if(type == DEATH_TOUCHEXPLODE) {
2465 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2467 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2468 } else if(type == DEATH_CHEAT) {
2469 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2471 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2472 } else if (type == DEATH_FIRE) {
2473 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2475 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2476 } else if (type == DEATH_CUSTOM) {
2477 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2479 print ("^1",s1, "^1 ", s2, "\n");
2481 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2483 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2485 } else if(msg == MSG_SPREE) {
2486 if(type == KILL_END_SPREE) {
2487 if(cvar("cl_gentle"))
2488 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2490 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2491 } else if(type == KILL_SPREE) {
2492 if(cvar("cl_gentle"))
2493 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2495 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2496 } else if(type == KILL_SPREE_3) {
2497 if(cvar("cl_gentle"))
2498 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2500 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2501 } else if(type == KILL_SPREE_5) {
2502 if(cvar("cl_gentle"))
2503 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2505 print (s1,"^7 unleashes ^1RAGE\n");
2506 } else if(type == KILL_SPREE_10) {
2507 if(cvar("cl_gentle"))
2508 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2510 print (s1,"^7 starts the ^1MASSACRE!\n");
2511 } else if(type == KILL_SPREE_15) {
2512 if(cvar("cl_gentle"))
2513 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2515 print (s1,"^7 executes ^1MAYHEM!\n");
2516 } else if(type == KILL_SPREE_20) {
2517 if(cvar("cl_gentle"))
2518 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2520 print (s1,"^7 is a ^1BERSERKER!\n");
2521 } else if(type == KILL_SPREE_25) {
2522 if(cvar("cl_gentle"))
2523 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2525 print (s1,"^7 inflicts ^1CARNAGE!\n");
2526 } else if(type == KILL_SPREE_30) {
2527 if(cvar("cl_gentle"))
2528 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2530 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2532 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2533 if (type == DEATH_DROWN) {
2534 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2537 if(cvar("cl_gentle"))
2538 print ("^1",s1, "^1 was in the water for too long\n");
2540 print ("^1",s1, "^1 drowned\n");
2542 } else if (type == DEATH_SLIME) {
2543 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2545 print ("^1",s1, "^1 was slimed\n");
2546 } else if (type == DEATH_LAVA) {
2547 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2550 if(cvar("cl_gentle"))
2551 print ("^1",s1, "^1 found a hot place\n");
2553 print ("^1",s1, "^1 turned into hot slag\n");
2555 } else if (type == DEATH_FALL) {
2556 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2559 if(cvar("cl_gentle"))
2560 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2562 print ("^1",s1, "^1 hit the ground with a crunch\n");
2564 } else if (type == DEATH_SHOOTING_STAR) {
2565 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2567 print ("^1",s1, "^1 became a shooting star\n");
2568 } else if (type == DEATH_SWAMP) {
2569 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2572 if(cvar("cl_gentle"))
2573 print ("^1",s1, "^1 discovered a swamp\n");
2575 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2577 } else if(type == DEATH_TURRET) {
2578 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2580 print ("^1",s1, "^1 was mowed down by a turret \n");
2581 } else if (type == DEATH_CUSTOM) {
2582 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2584 print ("^1",s1, "^1 ", s2, "\n");
2585 } else if (type == DEATH_HURTTRIGGER) {
2586 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2588 print ("^1",s1, "^1 was in the wrong place\n");
2589 } else if(type == DEATH_TOUCHEXPLODE) {
2590 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2592 print ("^1",s1, "^1 died in an accident\n");
2593 } else if(type == DEATH_CHEAT) {
2594 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2596 print ("^1",s1, "^1 was unfairly eliminated\n");
2597 } else if(type == DEATH_FIRE) {
2598 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2601 if(cvar("cl_gentle"))
2602 print ("^1",s1, "^1 felt a little hot\n");
2604 print ("^1",s1, "^1 burnt to death\n");
2607 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2610 if(cvar("cl_gentle"))
2611 print ("^1",s1, "^1 needs a restart\n");
2613 print ("^1",s1, "^1 died\n");
2616 } else if(msg == MSG_KILL_ACTION_SPREE) {
2617 if(cvar("cl_gentle"))
2618 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2620 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2621 } else if(msg == MSG_INFO) {
2622 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2623 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2624 print(s1, "^7 got the ", s2, "\n");
2625 } else if(type == INFO_LOSTFLAG) {
2626 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2627 print(s1, "^7 lost the ", s2, "\n");
2628 } else if(type == INFO_PICKUPFLAG) {
2629 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2630 print(s1, "^7 picked up the ", s2, "\n");
2631 } else if(type == INFO_RETURNFLAG) {
2632 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2633 print(s1, "^7 returned the ", s2, "\n");
2638 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2640 void HUD_Centerprint(string s1, string s2, float type, float msg)
2642 if(msg == MSG_SUICIDE) {
2643 if (type == DEATH_TEAMCHANGE) {
2644 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2645 } else if (type == DEATH_AUTOTEAMCHANGE) {
2646 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2647 } else if (type == DEATH_CAMP) {
2648 if(cvar("cl_gentle"))
2649 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2651 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2652 } else if (type == DEATH_NOAMMO) {
2653 if(cvar("cl_gentle"))
2654 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2656 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2657 } else if (type == DEATH_ROT) {
2658 if(cvar("cl_gentle"))
2659 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2661 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2662 } else if (type == DEATH_MIRRORDAMAGE) {
2663 if(cvar("cl_gentle"))
2664 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2666 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2667 } else if (type == DEATH_QUIET) {
2669 } else if (type == DEATH_KILL) {
2670 if(cvar("cl_gentle"))
2671 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2673 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2675 } else if(msg == MSG_KILL) {
2676 if (type == KILL_TEAM) {
2677 if(cvar("cl_gentle")) {
2678 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against a team mate!"));
2680 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2682 } else if (type == KILL_FIRST_BLOOD) {
2683 if(cvar("cl_gentle")) {
2684 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2686 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2688 } else if (type == KILL_FIRST_VICTIM) {
2689 if(cvar("cl_gentle")) {
2690 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2692 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2694 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2695 if(cvar("cl_gentle")) {
2696 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^7 who was typing!", s2));
2698 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2700 } else if (type == KILL_TYPEFRAGGED) {
2701 if(cvar("cl_gentle")) {
2702 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^7 while you were typing!", s2));
2704 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2706 } else if (type == KILL_FRAG) {
2707 if(cvar("cl_gentle")) {
2708 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2710 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2712 } else if (type == KILL_FRAGGED) {
2713 if(cvar("cl_gentle")) {
2714 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You were scored against by ^7", s1, s2));
2716 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You were fragged by ^7", s1, s2));
2719 } else if(msg == MSG_KILL_ACTION) {
2720 // TODO: invent more centerprints here?
2721 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!", s1));
2725 void HUD_Notify (void)
2727 float id = HUD_PANEL_NOTIFY;
2729 pos = HUD_Panel_GetPos(id);
2730 mySize = HUD_Panel_GetSize(id);
2732 HUD_Panel_DrawBg(id, pos, mySize, 0);
2734 padding = HUD_Panel_GetPadding(id);
2737 pos += '1 1 0' * padding;
2738 mySize -= '2 2 0' * padding;
2741 float entries, height;
2742 entries = bound(1, floor(14 * mySize_y/mySize_x), 12);
2743 height = mySize_y/entries;
2744 entries -= 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2747 fontsize = '0.5 0.5 0' * height;
2751 when = cvar("hud_notify_time");
2753 fadetime = cvar("hud_notify_fadetime");
2757 vector pos_attacker, pos_victim;
2759 float width_attacker, width_victim;
2760 string attacker, victim;
2763 for(j = 0; j < entries; ++j)
2765 if(cvar("hud_notify_flip"))
2767 else // rather nasty hack for ordering items from the bottom up
2768 i = entries - j - 1;
2769 if(cvar("hud_notify_info_top"))
2770 i += 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2774 if(killnotify_times[j] + when > time)
2777 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2781 if(killnotify_times[j] + when > time)
2787 // TODO: maybe print in team colors?
2788 // TODO: maybe this could be cleaned up somehow...
2789 // TODO: less copypaste code below
2792 if(killnotify_actiontype[j] == 0 && !hud_configure)
2794 attacker = textShortenToWidth(killnotify_attackers[j], mySize_x - 2 * height, fontsize, stringwidth_colors);
2796 width_attacker = stringwidth(attacker, TRUE, fontsize);
2797 pos_attacker = pos + eX * 0.5 * (mySize_x - width_attacker + 2 * height) + eY * 0.5 * fontsize_y + eY * i * height;
2799 weap_pos = pos + eX * 0.5 * (mySize_x - width_attacker) - eX * height + eY * i * height;
2800 if(killnotify_deathtype[j] == DEATH_GENERIC)
2802 drawpic_skin(weap_pos, "notify_death", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2803 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2805 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2807 drawpic_skin(weap_pos, "notify_outofammo", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2808 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2810 else if(killnotify_deathtype[j] == DEATH_KILL)
2812 drawpic_skin(weap_pos, "notify_selfkill", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2813 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2815 else if(killnotify_deathtype[j] == DEATH_CAMP)
2817 drawpic_skin(weap_pos, "notify_camping", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2818 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2820 else if(killnotify_deathtype[j] == DEATH_MIRRORDAMAGE)
2822 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2823 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2825 else if(killnotify_deathtype[j] == DEATH_DROWN)
2827 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2828 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2830 else if(killnotify_deathtype[j] == DEATH_SLIME)
2832 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2833 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2835 else if(killnotify_deathtype[j] == DEATH_LAVA)
2837 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2838 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2840 else if(killnotify_deathtype[j] == DEATH_FALL)
2842 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2843 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2845 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2847 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2848 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2850 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2852 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2853 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2855 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2857 if(killnotify_victims[j] == "^1RED^7 flag")
2861 drawpic_skin(weap_pos, strcat("flag_", s, "_carrying"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2862 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2864 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2866 if(killnotify_victims[j] == "^1RED^7 flag")
2870 drawpic_skin(weap_pos, strcat("flag_", s, "_taken"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2871 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2873 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2875 if(killnotify_victims[j] == "^1RED^7 flag")
2879 drawpic_skin(weap_pos, strcat("flag_", s, "_lost"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2880 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2883 // X [did action to] Y
2888 attacker = textShortenToWidth("Player1", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2889 victim = textShortenToWidth("Player2", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2890 a = bound(0, (when - j) / 4, 1);
2894 attacker = textShortenToWidth(killnotify_attackers[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2895 victim = textShortenToWidth(killnotify_victims[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2897 width_attacker = stringwidth(attacker, TRUE, fontsize);
2898 width_victim = stringwidth(victim, TRUE, fontsize);
2899 pos_attacker = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_attacker) + eY * 0.5 * fontsize_y + eY * i * height;
2900 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;
2901 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2903 if(hud_configure) // example actions for config mode
2905 drawpic_skin(weap_pos, strcat("weapon", "electro"), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2906 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2907 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2909 else if(WEP_VALID(killnotify_deathtype[j]))
2911 self = get_weaponinfo(killnotify_deathtype[j]);
2912 drawpic_skin(weap_pos, strcat("weapon", self.netname), '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_MIRRORDAMAGE)
2918 drawpic_skin(weap_pos, "notify_teamkill", '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_DROWN)
2924 drawpic_skin(weap_pos, "notify_water", '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_SLIME)
2930 drawpic_skin(weap_pos, "notify_slime", '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_LAVA)
2936 drawpic_skin(weap_pos, "notify_lava", '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_FALL)
2942 drawpic_skin(weap_pos, "notify_fall", '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_SHOOTING_STAR)
2948 drawpic_skin(weap_pos, "notify_shootingstar", '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);
2952 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2954 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2955 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2956 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2967 if(cvar("hud_notify_info_top"))
2970 o = pos + eY * mySize_y - eY * 2 * height;
2972 if(spectatee_status && !intermission)
2974 //drawfont = hud_bigfont;
2975 if(spectatee_status == -1)
2978 s = GetPlayerName(spectatee_status - 1);
2980 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
2981 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2982 //drawfont = hud_font;
2984 // spectator text in the upper right corner
2985 if(spectatee_status == -1)
2986 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
2988 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
2989 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2990 o += eY * fontsize_y;
2992 if(spectatee_status == -1)
2993 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
2995 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
2996 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2997 o += eY * fontsize_y;
2999 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
3000 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3001 o += eY * fontsize_y;
3003 if(gametype == GAME_ARENA)
3004 s = "^1Wait for your turn to join";
3005 else if(gametype == GAME_LMS)
3008 sk = playerslots[player_localentnum - 1];
3009 if(sk.(scores[ps_primary]) >= 666)
3010 s = "^1Match has already begun";
3011 else if(sk.(scores[ps_primary]) > 0)
3012 s = "^1You have no more lives left";
3014 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
3017 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
3018 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3019 o += eY * fontsize_y;
3021 //show restart countdown:
3022 if (time < getstatf(STAT_GAMESTARTTIME)) {
3024 //we need to ceil, otherwise the countdown would be off by .5 when using round()
3025 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
3026 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
3027 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3028 o += eY * fontsize_y;
3031 if(warmup_stage && !intermission)
3033 s = "^2Currently in ^1warmup^2 stage!";
3034 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3035 o += eY * fontsize_y;
3039 if(mod(time, 1) >= 0.5)
3044 if(ready_waiting && !intermission && !spectatee_status)
3046 if(ready_waiting_for_me)
3049 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
3051 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
3056 s = strcat("^2Waiting for others to ready up to end warmup...");
3058 s = strcat("^2Waiting for others to ready up...");
3060 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3061 o += eY * fontsize_y;
3063 else if(warmup_stage && !intermission && !spectatee_status)
3065 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
3066 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3067 o += eY * fontsize_y;
3070 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
3072 float ts_min, ts_max;
3073 tm = teams.sort_next;
3076 for(; tm.sort_next; tm = tm.sort_next)
3078 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
3080 if(!ts_min) ts_min = tm.team_size;
3081 else ts_min = min(ts_min, tm.team_size);
3082 if(!ts_max) ts_max = tm.team_size;
3083 else ts_max = max(ts_max, tm.team_size);
3085 if ((ts_max - ts_min) > 1)
3087 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
3088 tm = GetTeam(myteam, false);
3090 if (tm.team != COLOR_SPECTATOR)
3091 if (tm.team_size == ts_max)
3092 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
3094 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3095 o += eY * fontsize_y;
3101 s = "^7Press ^3ESC ^7to show HUD options.";
3102 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3103 o += eY * fontsize_y;
3104 s = "^3Doubleclick a panel for panel-specific options.";
3105 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3106 o += eY * fontsize_y;
3112 void HUD_Timer(void)
3114 float id = HUD_PANEL_TIMER;
3116 pos = HUD_Panel_GetPos(id);
3117 mySize = HUD_Panel_GetSize(id);
3119 HUD_Panel_DrawBg(id, pos, mySize, 0);
3121 padding = HUD_Panel_GetPadding(id);
3124 pos += '1 1 0' * padding;
3125 mySize -= '2 2 0' * padding;
3128 float timelimit, elapsedTime, minutes, seconds, timeleft, minutesLeft, secondsLeft;
3130 timelimit = getstatf(STAT_TIMELIMIT);
3132 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3133 timeleft = ceil(timeleft);
3134 minutesLeft = floor(timeleft / 60);
3135 secondsLeft = timeleft - minutesLeft*60;
3138 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3139 timer_color = '1 1 1'; //white
3140 else if(minutesLeft >= 1)
3141 timer_color = '1 1 0'; //yellow
3143 timer_color = '1 0 0'; //red
3145 if (cvar("hud_timer_increment") || timelimit == 0 || warmup_stage) {
3146 if (time < getstatf(STAT_GAMESTARTTIME)) {
3147 //while restart is still active, show 00:00
3148 minutes = seconds = 0;
3150 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3151 minutes = floor(elapsedTime / 60);
3152 seconds = elapsedTime - minutes*60;
3155 minutes = minutesLeft;
3156 seconds = secondsLeft;
3161 minutes = min(minutes, 999);
3162 if(minutesLeft >= 1 || cvar("hud_timer_increment") || timelimit == 0 || warmup_stage) {
3163 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);
3164 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);
3166 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);
3171 void HUD_Radar(void)
3173 float id = HUD_PANEL_RADAR;
3175 pos = HUD_Panel_GetPos(id);
3176 mySize = HUD_Panel_GetSize(id);
3178 HUD_Panel_DrawBg(id, pos, mySize, 0);
3180 padding = HUD_Panel_GetPadding(id);
3183 pos += '1 1 0' * padding;
3184 mySize -= '2 2 0' * padding;
3187 local float color1, color2; // color already declared as a global in hud.qc
3190 float scale2d, normalsize, bigsize;
3193 teamradar_origin2d = pos + 0.5 * mySize;
3194 teamradar_size2d = mySize;
3196 if(minimapname == "")
3199 teamradar_loadcvars();
3201 switch(hud_radar_zoommode)
3205 f = current_zoomfraction;
3208 f = 1 - current_zoomfraction;
3218 switch(hud_radar_rotation)
3221 teamradar_angle = view_angles_y - 90;
3224 teamradar_angle = 90 * hud_radar_rotation;
3228 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3229 teamradar_size2d = mySize;
3231 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3233 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3234 if(hud_radar_rotation == 0)
3236 // max-min distance must fit the radar in any rotation
3237 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3241 vector c0, c1, c2, c3, span;
3242 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3243 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3244 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3245 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3247 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3248 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3250 // max-min distance must fit the radar in x=x, y=y
3252 teamradar_size2d_x * scale2d / (1.05 * span_x),
3253 teamradar_size2d_y * scale2d / (1.05 * span_y)
3257 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3258 if(bigsize > normalsize)
3259 normalsize = bigsize;
3263 + (1 - f) * normalsize;
3264 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3265 f * (mi_min + mi_max) * 0.5
3266 + (1 - f) * view_origin);
3268 color1 = GetPlayerColor(player_localentnum-1);
3269 rgb = GetTeamRGB(color1);
3278 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3280 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3281 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3282 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3283 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, HUD_Panel_GetFgAlpha(id));
3284 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3286 color2 = GetPlayerColor(tm.sv_entnum);
3287 //if(color == COLOR_SPECTATOR || color == color2)
3288 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3290 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3292 drawresetcliparea();
3297 void HUD_Score(void)
3299 float id = HUD_PANEL_SCORE;
3301 pos = HUD_Panel_GetPos(id);
3302 mySize = HUD_Panel_GetSize(id);
3304 HUD_Panel_DrawBg(id, pos, mySize, 0);
3306 padding = HUD_Panel_GetPadding(id);
3309 pos += '1 1 0' * padding;
3310 mySize -= '2 2 0' * padding;
3313 float score, distribution, leader;
3314 float score_len, distr_len;
3315 vector distribution_color;
3317 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3319 // TODO... this (race part) still uses constant coordinates :/
3320 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3321 /*pl = players.sort_next;
3324 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3325 if(pl.scores[ps_primary] == 0)
3328 score = me.(scores[ps_primary]);
3330 float racemin, racesec, racemsec;
3331 float distsec, distmsec, minusplus;
3333 racemin = floor(score/(60 * TIME_FACTOR));
3334 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
3335 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
3337 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3338 // distribution display
3339 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3341 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
3342 distmsec = fabs(distribution);
3344 distsec = floor(fabs(distribution)/TIME_FACTOR);
3345 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
3346 if (distribution < 0)
3350 if (distribution <= 0) {
3351 distribution_color = eY;
3352 minusplus = 1; // minusplus 1: always prefix with minus sign
3355 distribution_color = eX;
3356 minusplus = 2; // minusplus 1: always prefix with plus sign
3358 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);
3359 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);
3360 drawpic_skin(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "num_dot", '16 16 0', distribution_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE);
3362 // race record display
3363 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
3364 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);
3366 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);
3367 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);
3368 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);
3370 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);
3371 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);
3373 } else if (!teamplay) { // non-teamgames
3374 // me vector := [team/connected frags id]
3375 pl = players.sort_next;
3382 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3386 score = me.(scores[ps_primary]);
3390 if(distribution >= 5) {
3391 distribution_color = eY;
3393 } else if(distribution >= 0) {
3394 distribution_color = '1 1 1';
3396 } else if(distribution >= -5)
3397 distribution_color = '1 1 0';
3399 distribution_color = eX;
3401 score_len = strlen(ftos(score));
3402 distr_len = strlen(ftos(distribution));
3404 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);
3406 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);
3407 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);
3408 } else { // teamgames
3409 float max_fragcount;
3410 max_fragcount = -99;
3413 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3414 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !hud_configure)) // no players? don't display
3416 score = tm.(teamscores[ts_primary]);
3421 score_len = strlen(ftos(score));
3423 if (score > max_fragcount)
3424 max_fragcount = score;
3426 if(tm.team == myteam) {
3427 if (max_fragcount == score)
3430 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);
3431 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);
3433 if (max_fragcount == score)
3436 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);
3437 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);
3446 void HUD_RaceTimer (void) {
3447 float id = HUD_PANEL_RACETIMER;
3449 pos = HUD_Panel_GetPos(id);
3450 mySize = HUD_Panel_GetSize(id);
3452 HUD_Panel_DrawBg(id, pos, mySize, 0);
3454 padding = HUD_Panel_GetPadding(id);
3457 pos += '1 1 0' * padding;
3458 mySize -= '2 2 0' * padding;
3461 drawfont = hud_bigfont;
3463 string s, forcetime;
3468 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);
3469 s = "^1Intermediate 1 (+15.42)";
3470 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);
3471 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3472 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);
3474 else if(race_checkpointtime)
3476 a = bound(0, 2 - (time - race_checkpointtime), 1);
3479 if(a > 0) // just hit a checkpoint?
3481 if(race_checkpoint != 254)
3483 if(race_time && race_previousbesttime)
3484 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3486 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3488 forcetime = TIME_ENCODED_TOSTRING(race_time);
3493 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3495 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3496 if(a > 0) // next one?
3498 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3503 if(s != "" && a > 0)
3505 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3506 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3507 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);
3510 if(race_penaltytime)
3512 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3515 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3516 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3517 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3518 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);
3524 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3525 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id), 0, a);
3526 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);
3531 if(race_laptime && race_checkpoint != 255)
3533 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3534 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3535 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);
3540 if(race_mycheckpointtime)
3542 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3543 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3544 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3545 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3546 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);
3548 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3550 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3551 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3552 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3553 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3554 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);
3557 if(race_penaltytime && !race_penaltyaccumulator)
3559 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3560 a = bound(0, (1 + t - time), 1);
3564 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3566 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3567 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3568 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3569 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);
3574 drawfont = hud_font;
3579 float vote_yescount;
3582 float vote_highlighted; // currently selected vote
3584 float vote_active; // is there an active vote?
3585 float vote_prev; // previous state of vote_active to check for a change
3587 float vote_change; // "time" when vote_active changed
3589 void HUD_VoteWindow(void)
3591 float id = HUD_PANEL_VOTE;
3593 pos = HUD_Panel_GetPos(id);
3594 mySize = HUD_Panel_GetSize(id);
3598 if(vote_active != vote_prev) {
3600 vote_prev = vote_active;
3603 if(vote_active || hud_configure)
3604 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3606 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3618 a = vote_alpha * bound(cvar_or("hud_vote_alreadyvoted_alpha", 0.75), 1 - vote_highlighted, 1);
3620 HUD_Panel_DrawBg(id, pos, mySize, a);
3622 padding = HUD_Panel_GetPadding(id);
3625 pos += '1 1 0' * padding;
3626 mySize -= '2 2 0' * padding;
3629 drawpic_skin(pos, "voteprogress_back", mySize, '1 1 1', a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3631 s = "A vote has been called for: ";
3632 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);
3633 s = textShortenToWidth(vote_called_vote, mySize_x * 0.96, '1 1 0' * mySize_y*(1/5), stringwidth_colors); // TODO: broken?
3635 s = "Configure the HUD";
3636 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);
3638 // print the yes/no counts
3639 s = strcat("Yes: ", ftos(vote_yescount));
3640 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);
3641 s = strcat("No: ", ftos(vote_nocount));
3642 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);
3644 // draw the progress bars
3645 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3646 drawpic_skin(pos, "voteprogress_prog", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3648 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3649 drawpic_skin(pos, "voteprogress_prog", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3651 // draw the highlights
3652 if(vote_highlighted == 1) {
3653 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3654 drawpic_skin(pos, "voteprogress_voted", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3656 else if(vote_highlighted == 2) {
3657 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3658 drawpic_skin(pos, "voteprogress_voted", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3661 drawresetcliparea();
3664 vote_highlighted = 0;
3668 // Mod icons panel (#10)
3671 float mod_active; // is there any active mod icon?
3673 // CTF HUD modicon section
3674 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3675 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3676 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3678 void HUD_Mod_CTF_Reset(void)
3680 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3683 void HUD_Mod_CTF(vector pos, vector mySize)
3685 vector redflag_pos, blueflag_pos;
3686 float f; // every function should have that
3688 float redflag, blueflag; // current status
3689 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3692 stat_items = getstati(STAT_ITEMS);
3693 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3694 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3696 if(redflag || blueflag)
3707 // when status CHANGES, set old status into prevstatus and current status into status
3708 if (redflag != redflag_prevframe)
3710 redflag_statuschange_time = time;
3711 redflag_prevstatus = redflag_prevframe;
3712 redflag_prevframe = redflag;
3715 if (blueflag != blueflag_prevframe)
3717 blueflag_statuschange_time = time;
3718 blueflag_prevstatus = blueflag_prevframe;
3719 blueflag_prevframe = blueflag;
3722 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3723 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3725 float BLINK_FACTOR = 0.15;
3726 float BLINK_BASE = 0.85;
3728 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3730 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3732 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3734 string red_icon, red_icon_prevstatus;
3735 float red_alpha, red_alpha_prevstatus;
3736 red_alpha = red_alpha_prevstatus = 1;
3738 case 1: red_icon = "flag_red_taken"; break;
3739 case 2: red_icon = "flag_red_lost"; break;
3740 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3742 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3743 red_icon = "flag_red_shielded";
3745 red_icon = string_null;
3748 switch(redflag_prevstatus) {
3749 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3750 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3751 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3754 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3755 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3756 red_icon_prevstatus = "flag_red_shielded";
3758 red_icon_prevstatus = string_null;
3762 string blue_icon, blue_icon_prevstatus;
3763 float blue_alpha, blue_alpha_prevstatus;
3764 blue_alpha = blue_alpha_prevstatus = 1;
3766 case 1: blue_icon = "flag_blue_taken"; break;
3767 case 2: blue_icon = "flag_blue_lost"; break;
3768 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3770 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3771 blue_icon = "flag_blue_shielded";
3773 blue_icon = string_null;
3776 switch(blueflag_prevstatus) {
3777 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3778 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3779 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3782 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3783 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3784 blue_icon_prevstatus = "flag_blue_shielded";
3786 blue_icon_prevstatus = string_null;
3790 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3792 blueflag_pos = pos + eX * mySize_y;
3795 redflag_pos = pos + eX * mySize_y;
3798 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3799 if(red_icon_prevstatus && f < 1)
3800 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);
3802 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);
3804 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3805 if(blue_icon_prevstatus && f < 1)
3806 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);
3808 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);
3811 // Keyhunt HUD modicon section
3812 float kh_runheretime;
3814 void HUD_Mod_KH_Reset(void)
3819 void HUD_Mod_KH(vector pos, vector mySize)
3821 mod_active = 1; // keyhunt should never hide the mod icons panel
3825 vector p, pa, kh_size, kh_asize;
3828 p_y = pos_y + 0.25 * mySize_y;
3830 kh_keys = getstati(STAT_KH_KEYS);
3832 kh_size_x = mySize_x * 0.25;
3833 kh_size_y = 0.75 * mySize_y;
3835 pa = p - eY * 0.25 * mySize_y;
3837 kh_asize_x = mySize_x * 0.25;
3838 kh_asize_y = mySize_y * 0.25;
3844 for(i = 0; i < 4; ++i)
3846 key = floor(kh_keys / pow(32, i)) & 31;
3848 if(keyteam == 30 && keycount <= 4)
3850 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3854 // this yields 8 exactly if "RUN HERE" shows
3859 kh_runheretime = time;
3860 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3865 for(i = 0; i < 4; ++i)
3867 key = floor(kh_keys / pow(32, i)) & 31;
3880 default: // owned or dropped
3885 a = a * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3886 aa = aa * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3892 drawpic_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3895 drawpic_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3898 drawpic_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3901 drawpic_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3906 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3909 drawpic_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3912 drawpic_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3915 drawpic_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3918 drawpic_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3922 p_x += 0.25 * mySize_x;
3923 pa_x += 0.25 * mySize_x;
3927 // Nexball HUD mod icon
3928 void HUD_Mod_NexBall(vector pos, vector mySize)
3930 float stat_items, nb_pb_starttime, dt, p;
3932 stat_items = getstati(STAT_ITEMS);
3933 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3935 if (stat_items & IT_KEY1)
3940 //Manage the progress bar if any
3941 if (nb_pb_starttime > 0)
3943 dt = mod(time - nb_pb_starttime, nb_pb_period);
3944 // one period of positive triangle
3945 p = 2 * dt / nb_pb_period;
3950 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);
3953 pos_x += 0.5 * mySize_x - 0.5 * mySize_y; //horizontal margin to the picture
3955 if (stat_items & IT_KEY1)
3956 drawpic_skin(pos, "nexball_carrying", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3959 // Race/CTS HUD mod icons
3960 float crecordtime_prev; // last remembered crecordtime
3961 float crecordtime_change_time; // time when crecordtime last changed
3962 float srecordtime_prev; // last remembered srecordtime
3963 float srecordtime_change_time; // time when srecordtime last changed
3965 float race_status_time;
3966 float race_status_prev;
3967 string race_status_name_prev;
3968 void HUD_Mod_Race(vector pos, vector mySize)
3970 mod_active = 1; // race should never hide the mod icons panel
3972 me = playerslots[player_localentnum - 1];
3974 float f; // yet another function has this
3975 score = me.(scores[ps_primary]);
3977 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3978 return; // no records in the actual race
3980 drawfont = hud_bigfont;
3982 // clientside personal record
3984 if(gametype == GAME_CTS)
3988 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3990 if(score && (score < t || !t)) {
3991 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3992 if(cvar("cl_autodemo_delete_keeprecords"))
3994 f = cvar("cl_autodemo_delete");
3996 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4000 if(t != crecordtime_prev) {
4001 crecordtime_prev = t;
4002 crecordtime_change_time = time;
4004 f = time - crecordtime_change_time;
4007 drawstring(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4008 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);
4010 drawstring(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4011 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);
4012 drawstring_expanding(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL, f);
4013 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);
4017 t = race_server_record;
4018 if(t != srecordtime_prev) {
4019 srecordtime_prev = t;
4020 srecordtime_change_time = time;
4022 f = time - srecordtime_change_time;
4025 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);
4026 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);
4028 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);
4029 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);
4030 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);
4031 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);
4034 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4035 race_status_time = time + 5;
4036 race_status_prev = race_status;
4037 if (race_status_name_prev)
4038 strunzone(race_status_name_prev);
4039 race_status_name_prev = strzone(race_status_name);
4042 pos_x += mySize_x/2;
4045 a = bound(0, race_status_time - time, 1);
4048 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4052 rank = race_CheckName(race_status_name);
4054 rankname = race_PlaceName(rank);
4057 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4059 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4061 if(race_status == 0)
4062 drawpic_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4063 else if(race_status == 1) {
4064 drawpic_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4065 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4066 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4067 } else if(race_status == 2) {
4068 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4069 drawpic_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4071 drawpic_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4072 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4073 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4074 } else if(race_status == 3) {
4075 drawpic_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4076 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4077 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4080 if (race_status_time - time <= 0) {
4081 race_status_prev = -1;
4083 if(race_status_name)
4084 strunzone(race_status_name);
4085 race_status_name = string_null;
4086 if(race_status_name_prev)
4087 strunzone(race_status_name_prev);
4088 race_status_name_prev = string_null;
4090 drawfont = hud_font;
4093 float mod_prev; // previous state of mod_active to check for a change
4095 float mod_change; // "time" when mod_active changed
4097 void HUD_ModIcons(void)
4099 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !hud_configure)
4102 float id = HUD_PANEL_MODICONS;
4104 pos = HUD_Panel_GetPos(id);
4105 mySize = HUD_Panel_GetSize(id);
4107 if(mod_active != mod_prev) {
4109 mod_prev = mod_active;
4112 if(mod_active || hud_configure)
4113 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4115 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4118 HUD_Panel_DrawBg(id, pos, mySize, mod_alpha);
4121 padding = HUD_Panel_GetPadding(id);
4124 pos += '1 1 0' * padding;
4125 mySize -= '2 2 0' * padding;
4128 // these MUST be ran in order to update mod_active
4129 if(gametype == GAME_KEYHUNT)
4130 HUD_Mod_KH(pos, mySize);
4131 else if(gametype == GAME_CTF || hud_configure)
4132 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4133 else if(gametype == GAME_NEXBALL)
4134 HUD_Mod_NexBall(pos, mySize);
4135 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4136 HUD_Mod_Race(pos, mySize);
4139 // Draw pressed keys (#11)
4141 void HUD_DrawPressedKeys(void)
4143 float id = HUD_PANEL_PRESSEDKEYS;
4145 pos = HUD_Panel_GetPos(id);
4146 mySize = HUD_Panel_GetSize(id);
4148 HUD_Panel_DrawBg(id, pos, mySize, 0);
4150 padding = HUD_Panel_GetPadding(id);
4153 pos += '1 1 0' * padding;
4154 mySize -= '2 2 0' * padding;
4159 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4160 drawpic_skin(pos, "key_bg.tga", mySize, '1 1 1', 0.1 * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4161 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);
4162 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);
4163 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);
4164 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);
4165 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);
4166 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);
4169 // Handle chat as a panel (#12)
4173 float id = HUD_PANEL_CHAT;
4175 pos = HUD_Panel_GetPos(id);
4176 mySize = HUD_Panel_GetSize(id);
4178 HUD_Panel_DrawBg(id, pos, mySize, 0);
4180 padding = HUD_Panel_GetPadding(id);
4183 pos += '1 1 0' * padding;
4184 mySize -= '2 2 0' * padding;
4187 cvar_set("con_chatrect", "1");
4189 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4190 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4192 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4193 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4198 chatsize = cvar("con_chatsize");
4199 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4201 for(i = 0; i < cvar("con_chat"); ++i)
4203 if(i == cvar("con_chat") - 1)
4204 a = HUD_Panel_GetFgAlpha(id);
4206 a = HUD_Panel_GetFgAlpha(id) * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4207 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);
4212 // Engine info panel (#13)
4219 float frametimeavg1; // 1 frame ago
4220 float frametimeavg2; // 2 frames ago
4221 void HUD_EngineInfo(void)
4223 float id = HUD_PANEL_ENGINEINFO;
4225 pos = HUD_Panel_GetPos(id);
4226 mySize = HUD_Panel_GetSize(id);
4228 HUD_Panel_DrawBg(id, pos, mySize, 0);
4230 padding = HUD_Panel_GetPadding(id);
4233 pos += '1 1 0' * padding;
4234 mySize -= '2 2 0' * padding;
4237 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4239 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4240 frametimeavg2 = frametimeavg1;
4241 frametimeavg1 = frametimeavg;
4244 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4245 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.
4247 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
4248 prevfps = (1/frametime);
4249 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"
4255 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4257 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4259 prevfps_time = time;
4264 color = HUD_Get_Num_Color (prevfps, 100);
4265 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);
4273 void HUD_ShowSpeed(void)
4276 float pos, conversion_factor;
4277 string speed, zspeed, unit;
4279 switch(cvar("cl_showspeed_unit"))
4284 conversion_factor = 1.0;
4288 conversion_factor = 1.0;
4292 conversion_factor = 0.0254;
4296 conversion_factor = 0.0254 * 3.6;
4300 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4304 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4308 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4310 numsize_x = numsize_y = cvar("cl_showspeed_size");
4311 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4313 drawfont = hud_bigfont;
4314 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4316 if (cvar("cl_showspeed_z") == 1) {
4317 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4318 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4321 drawfont = hud_font;
4324 vector acc_prevspeed;
4328 void HUD_ShowAcceleration(void)
4330 float acceleration, sz, scale, alpha, f;
4331 vector pos, top, rgb;
4332 top_x = vid_conwidth/2;
4335 f = time - acc_prevtime;
4336 if(cvar("cl_showacceleration_z"))
4337 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4339 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4340 acc_prevspeed = pmove_vel;
4341 acc_prevtime = time;
4343 f = bound(0, f * 10, 1);
4344 acc_avg = acc_avg * (1 - f) + acceleration * f;
4345 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4347 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4349 sz = cvar("cl_showacceleration_size");
4350 scale = cvar("cl_showacceleration_scale");
4351 alpha = cvar("cl_showacceleration_alpha");
4352 if (cvar("cl_showacceleration_color_custom"))
4353 rgb = stov(cvar_string("cl_showacceleration_color"));
4356 if (acceleration < 0) {
4357 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4358 } else if (acceleration > 0) {
4359 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4363 if (acceleration > 0)
4364 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4365 else if (acceleration < 0)
4366 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4369 void HUD_Reset (void)
4371 // reset gametype specific icons
4372 if(gametype == GAME_KEYHUNT)
4374 else if(gametype == GAME_CTF)
4375 HUD_Mod_CTF_Reset();
4378 void HUD_Main (void)
4380 if(disable_menu_alphacheck == 1)
4381 menu_fade_alpha = 1;
4383 menu_fade_alpha = (1 - cvar("_menu_alpha"));
4384 hud_fg_alpha = cvar("hud_fg_alpha");
4386 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4387 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4388 hud_color_bg_team = cvar("hud_color_bg_team");
4390 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4391 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4393 hud_configure = cvar("_hud_configure");
4397 // HUD configure visible grid
4398 if(hud_configure && cvar("hud_configure_grid") && cvar("hud_configure_grid_alpha"))
4402 for(i = 0; i < vid_conwidth/max(2, cvar("hud_configure_grid_x")); ++i)
4404 drawfill(eX * i * max(2, cvar("hud_configure_grid_x")), eX + eY * vid_conheight, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
4407 for(i = 0; i < vid_conheight/max(2, cvar("hud_configure_grid_y")); ++i)
4409 drawfill(eY * i * max(2, cvar("hud_configure_grid_y")), eY + eX * vid_conwidth, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
4413 if(cvar_string("hud_dock") != "")
4414 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);
4416 if(HUD_Panel_CheckActive(HUD_PANEL_WEAPONICONS) || hud_configure)
4418 if(HUD_Panel_CheckActive(HUD_PANEL_INVENTORY) || hud_configure)
4420 if(HUD_Panel_CheckActive(HUD_PANEL_POWERUPS) || hud_configure)
4422 if(HUD_Panel_CheckActive(HUD_PANEL_HEALTHARMOR) || hud_configure)
4424 if(HUD_Panel_CheckActive(HUD_PANEL_NOTIFY) || hud_configure)
4426 if(HUD_Panel_CheckActive(HUD_PANEL_TIMER) || hud_configure)
4429 if(HUD_Panel_CheckActive(HUD_PANEL_RADAR) || hud_configure)
4430 if(cvar_string("hud_radar") != "0" && (cvar("hud_radar") == 2 || teamplay))
4432 if(HUD_Panel_CheckActive(HUD_PANEL_SCORE) || hud_configure)
4434 if(HUD_Panel_CheckActive(HUD_PANEL_RACETIMER) || hud_configure)
4435 if(gametype == GAME_RACE || gametype == GAME_CTS || hud_configure)
4437 if(HUD_Panel_CheckActive(HUD_PANEL_VOTE) || hud_configure)
4439 if(HUD_Panel_CheckActive(HUD_PANEL_MODICONS) || hud_configure)
4442 if(HUD_Panel_CheckActive(HUD_PANEL_PRESSEDKEYS) || hud_configure)
4443 if(spectatee_status > 0 || cvar("hud_pressedkeys") >= 2 || hud_configure)
4444 HUD_DrawPressedKeys();
4445 if(HUD_Panel_CheckActive(HUD_PANEL_CHAT) || hud_configure)
4448 cvar_set("con_csqcpositioning", "0");
4449 if(HUD_Panel_CheckActive(HUD_PANEL_ENGINEINFO) || hud_configure)
4452 // TODO hud_'ify these
4453 if (cvar("cl_showspeed"))
4455 if (cvar("cl_showacceleration"))
4456 HUD_ShowAcceleration();
4458 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)
4459 localcmd("cmd selectteam auto; cmd join\n");
4461 if (!hud_configure) // hud config mode disabled, enable normal alpha stuff again
4462 disable_menu_alphacheck = 0;