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"));
623 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_foreground_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_foreground_alpha"))), "\n"));
625 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha"))), "\n"));
631 print("^2Successfully exported to hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
636 vector HUD_Panel_GetMinSize(float id)
639 // note: please only set mySize_y on aspect ratio forced panels
642 mySize_x = 1/10; // at least 1/10 * height
643 mySize_y = 1/26; // at least 1/26 * width
646 if(cvar("hud_inventory_onlycurrent"))
647 mySize_y = 2/5; // 2/5 width
649 mySize_x = 0.7; // at least 0.7 * height
652 if(cvar("hud_healtharmor") == 2)
654 mySize_x = 4.35; // 4.35 * height, trial and error...
655 mySize_y = 0.01; // "unlimited" ;)
659 mySize_x = 4/5; // 4/5 * height, trial and error...
660 mySize_y = 1/3; // 1/3 * width, trial and error...
663 mySize_y = 1/4.1; // 1/4.1 * width, trial and error...
666 mySize_y = 1/4; // 1/4 * width
669 mySize_y = 1/4; // 1/4 * width
672 mySize_y = 1/4; // 1/4 * width
675 mySize_y = 1/2; // 1/2 * width
678 mySize_y = 0.5898; // 0.5898 * width, reason: bg has weird dimensions...
681 mySize_y = 0.25; // 0.25 * width, trial and error...
684 if(!mySize_x && mySize_y)
685 mySize_x = 1/mySize_y;
689 // return active status of panel
690 float HUD_Panel_CheckActive(float id)
692 if (cvar_or(strcat("hud_", HUD_Panel_GetName(id)), 1))
697 // return size of given panel
698 vector HUD_Panel_GetSize(float id)
701 mySize = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_size")));
703 mySize = eX * mySize_x * vid_conwidth + eY * mySize_y * vid_conheight;
705 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
707 vector menu_enable_maxsize, menu_enable_size;
708 menu_enable_maxsize = '0 0 0'; // shut up FTEQCC
709 menu_enable_maxsize_x = 0.3 * vid_conwidth;
710 menu_enable_maxsize_y = 0.18 * vid_conheight;
711 if(mySize_x > mySize_y)
713 if(mySize_y > menu_enable_maxsize_y)
715 menu_enable_size_y = menu_enable_maxsize_y;
716 menu_enable_size_x = mySize_x * (menu_enable_maxsize_y/mySize_y);
717 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
722 if(mySize_x > menu_enable_maxsize_x)
724 menu_enable_size_x = menu_enable_maxsize_x;
725 menu_enable_size_y = mySize_y * (menu_enable_maxsize_x/mySize_x);
726 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
733 // return pos of given panel
734 vector HUD_Panel_GetPos(float id)
737 pos = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_pos")));
739 pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
742 pos_x = vid_conwidth + pos_x;
744 pos_y = vid_conheight + pos_y;
746 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
748 vector mySize, menu_enable_panelpos;
749 mySize = HUD_Panel_GetSize(id);
750 if(mySize_x > mySize_y)
751 menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * mySize_x + eY * 0.82 * vid_conheight;
753 menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * mySize_y + eX * 0.7 * vid_conwidth;
754 pos = (1 - cvar("_menu_alpha")) * pos + (cvar("_menu_alpha")) * menu_enable_panelpos;
759 float HUD_Panel_GetBorder(float id)
762 border = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_border"));
764 border = cvar_string("hud_bg_border");
768 vector HUD_Panel_GetColor(float id)
774 // fetch per-panel color
775 if(teamplay && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")) != "") {
776 f = stof(getplayerkey(self.sv_entnum, "colors"));
777 color = vtos(colormapPaletteColor(mod(f, 16), 1) * cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")));
780 color = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color"));
781 color_vec = stov(color);
783 if(color == "") { // fetch default color
784 color = cvar_string("hud_bg_color");
785 color_vec = stov(color);
786 if(teamplay && cvar(strcat("hud_bg_color_team"))) {
787 f = stof(getplayerkey(self.sv_entnum, "colors"));
788 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_bg_color_team");
790 else if(color == "shirt") {
791 f = stof(getplayerkey(self.sv_entnum, "colors"));
792 color_vec = colormapPaletteColor(floor(f / 16), 0);
794 else if(color == "pants") {
795 f = stof(getplayerkey(self.sv_entnum, "colors"));
796 color_vec = colormapPaletteColor(mod(f, 16), 1);
799 else if(color == "shirt") {
800 f = stof(getplayerkey(self.sv_entnum, "colors"));
801 color_vec = colormapPaletteColor(floor(f / 16), 0);
803 else if(color == "pants") {
804 f = stof(getplayerkey(self.sv_entnum, "colors"));
805 color_vec = colormapPaletteColor(mod(f, 16), 1);
810 vector HUD_Panel_Dock_GetColor(void)
815 color = cvar_string("hud_dock_color");
816 color_vec = stov(color);
817 if(teamplay && cvar(strcat("hud_dock_color_team"))) {
818 f = stof(getplayerkey(self.sv_entnum, "colors"));
819 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_dock_color_team");
821 else if(color == "shirt") {
822 f = stof(getplayerkey(self.sv_entnum, "colors"));
823 color_vec = colormapPaletteColor(floor(f / 16), 0);
825 else if(color == "pants") {
826 f = stof(getplayerkey(self.sv_entnum, "colors"));
827 color_vec = colormapPaletteColor(mod(f, 16), 1);
832 float HUD_Panel_GetBgAlpha(float id)
835 alpha = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_alpha"));
837 alpha = cvar_string("hud_bg_alpha");
839 if(hud_configure && disable_menu_alphacheck == 2 && highlightedPanel == id) // do not set a minalpha cap when showing the config dialog for this panel
840 alpha = ftos((1 - cvar("_menu_alpha")) * max(cvar("hud_configure_bg_minalpha"), stof(alpha)) + (cvar("_menu_alpha")) * stof(alpha));
841 else if(hud_configure)
842 alpha = ftos(max(cvar("hud_configure_bg_minalpha"), stof(alpha)));
844 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
847 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
850 return stof(alpha) * menu_fade_alpha;
853 float HUD_Panel_GetFgAlpha(float id)
856 alpha = hud_fg_alpha;
858 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
861 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
864 return alpha * menu_fade_alpha;
867 float HUD_Panel_GetPadding(float id)
870 padding = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
872 padding = cvar_string("hud_bg_padding");
875 mySize = HUD_Panel_GetSize(id);
877 smallestsize = min(mySize_x, mySize_y);
878 return min(smallestsize/2 - 5, stof(padding));
881 // draw the background/borders
882 void HUD_Panel_DrawBg(float id, vector pos, vector mySize, float alpha)
884 if(!hud_configure && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg")) == "0")
888 bg = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg"));
890 bg = cvar_string("hud_bg");
892 if(bg == "0" && hud_configure) {
893 bg = "border"; // we probably want to see a background in config mode at all times...
899 border = max(0.0000001, HUD_Panel_GetBorder(id)); // draw_BorderPicture does not like border = 0
902 color = HUD_Panel_GetColor(id);
905 alpha = HUD_Panel_GetBgAlpha(id) * alpha; // allow panels to fade in/out by passing an alpha value
907 alpha = HUD_Panel_GetBgAlpha(id);
909 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));
913 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
915 //float drawsubpic(vector position, vector size, string pic, vector srcPosition, vector srcSize, vector rgb, float alpha, float flag) = #328;
917 pic = strcat("gfx/hud/", cvar_string("hud_skin"), "/");
919 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);
920 if(mySize_y/mySize_x > 2)
921 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);
922 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);
924 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);
925 if(mySize_x/mySize_y > 2)
926 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);
927 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);
931 vector HUD_Panel_GetProgressBarColor(string item)
933 return stov(cvar_string(strcat("hud_progressbar_", item, "_color")));
936 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
937 vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
948 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
949 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
951 for (i = 0; i < HUD_PANEL_NUM; ++i) {
952 if(i == id || !HUD_Panel_CheckActive(i))
955 targPos = HUD_Panel_GetPos(i) - '1 1 0' * HUD_Panel_GetBorder(id);
956 targSize = HUD_Panel_GetSize(i) + '2 2 0' * HUD_Panel_GetBorder(id);
958 if(myPos_y + mySize_y < targPos_y)
960 if(myPos_y > targPos_y + targSize_y)
963 if(myPos_x + mySize_x < targPos_x)
965 if(myPos_x > targPos_x + targSize_x)
968 // OK, there IS a collision.
970 myCenter_x = myPos_x + 0.5 * mySize_x;
971 myCenter_y = myPos_y + 0.5 * mySize_y;
973 targCenter_x = targPos_x + 0.5 * targSize_x;
974 targCenter_y = targPos_y + 0.5 * targSize_y;
976 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
978 if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
979 myTarget_x = targPos_x - mySize_x;
980 else // push it upwards
981 myTarget_y = targPos_y - mySize_y;
983 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
985 if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
986 myTarget_x = targPos_x + targSize_x;
987 else // push it upwards
988 myTarget_y = targPos_y - mySize_y;
990 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
992 if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
993 myTarget_x = targPos_x - mySize_x;
994 else // push it downwards
995 myTarget_y = targPos_y + targSize_y;
997 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
999 if(targPos_x + targSize_x - myPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
1000 myTarget_x = targPos_x + targSize_x;
1001 else // push it downwards
1002 myTarget_y = targPos_y + targSize_y;
1009 void HUD_Panel_SetPos(float id, vector pos)
1012 oldPos = HUD_Panel_GetPos(id);
1015 mySize = HUD_Panel_GetSize(id);
1017 if(cvar("hud_configure_checkcollisions"))
1018 pos = HUD_Panel_CheckMove(id, pos, mySize);
1020 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
1021 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
1023 if(cvar("hud_configure_grid"))
1025 pos_x = floor(pos_x/cvar("hud_configure_grid_x") + 0.5) * cvar("hud_configure_grid_x");
1026 pos_y = floor(pos_y/cvar("hud_configure_grid_y") + 0.5) * cvar("hud_configure_grid_y");
1029 if (pos_x + 0.5 * mySize_x > 0.5 * vid_conwidth)
1030 pos_x = pos_x - vid_conwidth;
1031 if (pos_y + 0.5 * mySize_y > 0.5 * vid_conheight)
1032 pos_y = pos_y - vid_conheight;
1035 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
1037 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
1040 float HUD_Panel_CheckValidity_of_ResizeSuggestion(float id, vector mySize)
1045 // copy pasta from SetPosSize:
1046 // minimum panel size cap
1047 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1048 mySize_y = max(0.025 * vid_conheight, mySize_y);
1050 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.
1052 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
1053 mySize_y = max(2 * cvar("con_chatsize") + 2 * HUD_Panel_GetPadding(id), mySize_y);
1056 // cap against panel's own limits
1058 minSize = HUD_Panel_GetMinSize(id); // mySize_x at least minSize_x * mySize_y, and vice versa
1060 mySize_x = max(minSize_x * mySize_y, mySize_x);
1061 mySize_y = max(minSize_y * mySize_x, mySize_y);
1063 if(mySize == oldSize)
1069 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
1070 vector HUD_Panel_CheckResize(float id, vector myPos, vector mySize, vector resizeorigin)
1078 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
1079 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
1081 for (i = 0; i < HUD_PANEL_NUM; ++i) {
1082 if(i == id || !HUD_Panel_CheckActive(i))
1085 targPos = HUD_Panel_GetPos(i) - '1 1 0' * HUD_Panel_GetBorder(id);
1086 targSize = HUD_Panel_GetSize(i) + '2 2 0' * HUD_Panel_GetBorder(id);
1088 if(myPos_y + mySize_y < targPos_y)
1090 if(myPos_y > targPos_y + targSize_y)
1093 if(myPos_x + mySize_x < targPos_x)
1095 if(myPos_x > targPos_x + targSize_x)
1098 // OK, there IS a collision.
1101 // Now check some special cases
1102 // If the resizeorigin is too close to the target panel on either axis, we do not want to perform any collision avoidance on that axis
1103 float Check_X, Check_Y;
1104 Check_X = Check_Y = 1;
1105 // check upper/left edges of targ panel
1106 if(fabs(targPos_x - resizeorigin_x) < 0.025 * vid_conwidth)
1108 if(fabs(targPos_y - resizeorigin_y) < 0.025 * vid_conheight)
1110 // check lower/right edges of targ panel
1111 if(fabs(resizeorigin_x - (targPos_x + targSize_x)) < 0.025 * vid_conwidth)
1113 if(fabs(resizeorigin_y - (targPos_y + targSize_y)) < 0.025 * vid_conheight)
1116 myCenter_x = myPos_x + 0.5 * mySize_x;
1117 myCenter_y = myPos_y + 0.5 * mySize_y;
1119 targCenter_x = targPos_x + 0.5 * targSize_x;
1120 targCenter_y = targPos_y + 0.5 * targSize_y;
1122 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of target panel)
1124 //if(!HUD_Panel_CheckValidity_of_ResizeSuggestion(id, eX * (targPos_x - myPos_x) + eY * (targPos_y - resizeorigin_y)))
1127 if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y && Check_X) // push it to the side
1128 mySize_x = targPos_x - myPos_x;
1129 else if(Check_Y) // push it upwards
1130 mySize_y = targPos_y - resizeorigin_y;
1132 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
1134 //if(!HUD_Panel_CheckValidity_of_ResizeSuggestion(id, eX * (resizeorigin_x - (targPos_x + targSize_x)) + eY * (targPos_y - resizeorigin_y)))
1137 if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y && Check_X) // push it to the side
1138 mySize_x = resizeorigin_x - (targPos_x + targSize_x);
1139 else if(Check_Y) // push it upwards
1140 mySize_y = targPos_y - resizeorigin_y;
1142 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
1144 //if(!HUD_Panel_CheckValidity_of_ResizeSuggestion(id, eX * (targPos_x - resizeorigin_x) + eY * (resizeorigin_y - (targPos_y + targSize_y))))
1147 if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y && Check_X) // push it to the side
1148 mySize_x = targPos_x - resizeorigin_x;
1149 else if(Check_Y) // push it upwards
1150 mySize_y = resizeorigin_y - (targPos_y + targSize_y);
1152 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
1154 //if(!HUD_Panel_CheckValidity_of_ResizeSuggestion(id, eX * (resizeorigin_x - (targPos_x + targSize_x)) + eY * (resizeorigin_y - (targPos_y + targSize_y))))
1157 if(targPos_x + targSize_x - myPos_x < targPos_y + targSize_y - myPos_y && Check_X) // push it to the side
1158 mySize_x = resizeorigin_x - (targPos_x + targSize_x);
1159 else if(Check_Y) // push it upwards
1160 mySize_y = resizeorigin_y - (targPos_y + targSize_y);
1167 void HUD_Panel_SetPosSize(float id, vector resizeorigin)
1169 vector mySize, myPos;
1171 if(resizeCorner == 1) {
1172 mySize_x = resizeorigin_x - (mousepos_x - panel_click_distance_x);
1173 mySize_y = resizeorigin_y - (mousepos_y - panel_click_distance_y);
1174 } else if(resizeCorner == 2) {
1175 mySize_x = mousepos_x + panel_click_distance_x - resizeorigin_x;
1176 mySize_y = panel_click_distance_y + resizeorigin_y - mousepos_y;
1177 } else if(resizeCorner == 3) {
1178 mySize_x = resizeorigin_x + panel_click_distance_x - mousepos_x;
1179 mySize_y = mousepos_y + panel_click_distance_y - resizeorigin_y;
1180 } else { // resizeCorner == 4
1181 mySize_x = mousepos_x - (resizeorigin_x - panel_click_distance_x);
1182 mySize_y = mousepos_y - (resizeorigin_y - panel_click_distance_y);
1185 // minimum panel size cap
1186 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1187 mySize_y = max(0.025 * vid_conheight, mySize_y);
1189 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.
1191 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
1192 mySize_y = max(2 * cvar("con_chatsize") + 2 * HUD_Panel_GetPadding(id), mySize_y);
1195 // cap against panel's own limits
1197 minSize = HUD_Panel_GetMinSize(id); // mySize_x at least minSize_x * mySize_y, and vice versa
1199 mySize_x = max(minSize_x * mySize_y, mySize_x);
1200 mySize_y = max(minSize_y * mySize_x, mySize_y);
1202 // collision testing|
1203 // -----------------+
1205 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
1206 if(resizeCorner == 1) {
1207 myPos_x = resizeorigin_x - mySize_x;
1208 myPos_y = resizeorigin_y - mySize_y;
1209 } else if(resizeCorner == 2) {
1210 myPos_x = resizeorigin_x;
1211 myPos_y = resizeorigin_y - mySize_y;
1212 } else if(resizeCorner == 3) {
1213 myPos_x = resizeorigin_x - mySize_x;
1214 myPos_y = resizeorigin_y;
1215 } else { // resizeCorner == 4
1216 myPos_x = resizeorigin_x;
1217 myPos_y = resizeorigin_y;
1220 // left/top screen edges
1221 mySize_x = min(myPos_x + mySize_x, mySize_x);
1222 mySize_y = min(myPos_y + mySize_y, mySize_y);
1224 // bottom/right screen edges
1225 mySize_x = min(vid_conwidth - myPos_x, mySize_x);
1226 mySize_y = min(vid_conheight - myPos_y, mySize_y);
1228 if(cvar("hud_configure_checkcollisions"))
1229 mySize = HUD_Panel_CheckResize(id, myPos, mySize, resizeorigin);
1231 if(cvar("hud_configure_grid"))
1233 mySize_x = floor(mySize_x/cvar("hud_configure_grid_x") + 0.5) * cvar("hud_configure_grid_x");
1234 mySize_y = floor(mySize_y/cvar("hud_configure_grid_y") + 0.5) * cvar("hud_configure_grid_y");
1237 // do another pos check, as size might have changed by now
1238 if(resizeCorner == 1) {
1239 myPos_x = resizeorigin_x - mySize_x;
1240 myPos_y = resizeorigin_y - mySize_y;
1241 } else if(resizeCorner == 2) {
1242 myPos_x = resizeorigin_x;
1243 myPos_y = resizeorigin_y - mySize_y;
1244 } else if(resizeCorner == 3) {
1245 myPos_x = resizeorigin_x - mySize_x;
1246 myPos_y = resizeorigin_y;
1247 } else { // resizeCorner == 4
1248 myPos_x = resizeorigin_x;
1249 myPos_y = resizeorigin_y;
1253 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
1254 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_size"), s);
1256 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
1257 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
1261 float prevMouseClicked; // previous state
1262 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
1263 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
1266 float menu_enabled_time;
1267 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1272 // allow console bind to work
1275 con_keys = findkeysforcommand("toggleconsole");
1276 keys = tokenize(con_keys);
1278 float hit_con_bind, i;
1279 for (i = 0; i < keys; ++i)
1281 if(nPrimary == stof(argv(i)))
1285 if(nPrimary == K_MOUSE1)
1287 if(bInputType == 0) { // key pressed
1291 else if(bInputType == 1) {// key released
1296 else if(nPrimary == K_ESCAPE)
1298 disable_menu_alphacheck = 1;
1300 menu_enabled_time = time;
1301 localcmd("menu_showhudexit\n");
1304 else if(hit_con_bind)
1307 return true; // Suppress ALL other input
1310 void HUD_Panel_Mouse()
1312 // 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
1313 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1314 disable_menu_alphacheck = 0;
1315 if (cvar("_menu_alpha") == 0 && time - menu_enabled_time > 0.5)
1319 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1320 print("Highlighted: ", ftos(highlightedPanel), "\n");
1321 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1324 if(mouseClicked == 0 && disable_menu_alphacheck != 2) { // don't reset these variables in disable_menu_alphacheck mode 2!
1325 highlightedPanel = -1;
1326 highlightedAction = 0;
1329 mousepos = mousepos + getmousepos();
1331 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1332 mousepos_y = bound(0, mousepos_y, vid_conheight);
1334 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1342 for(i = 0; i < HUD_PANEL_NUM; ++i)
1344 panelPos = HUD_Panel_GetPos(i);
1345 panelSize = HUD_Panel_GetSize(i);
1346 border = HUD_Panel_GetBorder(i);
1347 if(prevMouseClicked == 0) {
1349 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1351 highlightedPanel = i;
1352 highlightedAction = 1;
1354 // resize from topleft border
1355 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)
1357 highlightedPanel = i;
1358 highlightedAction = 2;
1361 // resize from topright border
1362 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)
1364 highlightedPanel = i;
1365 highlightedAction = 2;
1368 // resize from bottomleft border
1369 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)
1371 highlightedPanel = i;
1372 highlightedAction = 2;
1375 // resize from bottomright border
1376 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)
1378 highlightedPanel = i;
1379 highlightedAction = 2;
1384 if(highlightedPanel == i)
1386 if(prevMouseClicked == 0)
1388 if(highlightedAction == 1)
1389 panel_click_distance = mousepos - panelPos;
1390 else if(highlightedAction == 2)
1392 if(resizeCorner == 1) {
1393 panel_click_distance = mousepos - panelPos;
1394 panel_click_resizeorigin = panelPos + panelSize;
1395 } else if(resizeCorner == 2) {
1396 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1397 panel_click_distance_y = mousepos_y - panelPos_y;
1398 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1399 } else if(resizeCorner == 3) {
1400 panel_click_distance_x = mousepos_x - panelPos_x;
1401 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1402 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1403 } else if(resizeCorner == 4) {
1404 panel_click_distance = panelSize - mousepos + panelPos;
1405 panel_click_resizeorigin = panelPos;
1410 if(highlightedAction == 1)
1411 HUD_Panel_SetPos(i, mousepos - panel_click_distance);
1412 else if(highlightedAction == 2)
1413 HUD_Panel_SetPosSize(i, panel_click_resizeorigin);
1417 // doubleclick check
1418 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1420 mouseClicked = 0; // to prevent spam, I guess.
1421 disable_menu_alphacheck = 2;
1423 menu_enabled_time = time;
1424 localcmd("menu_showhudoptions ", ftos(highlightedPanel), "\n");
1427 if(prevMouseClicked == 0)
1429 prevMouseClickedTime = time;
1430 prevMouseClickedPos = mousepos;
1433 prevMouseClicked = mouseClicked;
1436 // Weapon icons (#0)
1438 float weaponspace[10];
1439 void HUD_WeaponIcons_Clear()
1442 for(idx = 0; idx < 10; ++idx)
1443 weaponspace[idx] = 0;
1446 entity weaponorder[WEP_MAXCOUNT];
1448 void weaponorder_swap(float i, float j, entity pass)
1452 weaponorder[i] = weaponorder[j];
1456 string weaponorder_cmp_str;
1457 float weaponorder_cmp(float i, float j, entity pass)
1460 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1461 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1462 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)
1465 void HUD_WeaponIcons(void)
1467 float id = HUD_PANEL_WEAPONICONS;
1468 float alpha, stat_weapons; // "constants"
1469 vector pos, mySize, accuracy_color;
1470 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1472 pos = HUD_Panel_GetPos(id);
1473 mySize = HUD_Panel_GetSize(id);
1475 stat_weapons = getstati(STAT_WEAPONS);
1476 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1478 self = get_weaponinfo(i);
1479 if(self.weapons && (self.impulse >= 0) && (stat_weapons & self.weapons) || hud_configure)
1481 weaponorder[weapon_cnt] = self;
1486 // TODO make this configurable
1487 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1488 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1490 HUD_Panel_DrawBg(id, pos, mySize, 0);
1492 padding = HUD_Panel_GetPadding(id);
1495 pos += '1 1 0' * padding;
1496 mySize -= '2 2 0' * padding;
1500 weapon_stats = getstati(STAT_DAMAGE_HITS);
1501 weapon_number = weapon_stats & 63;
1502 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1504 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1505 weapon_number = weapon_stats & 63;
1506 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1508 if(cvar_or("hud_weaponicons_fade", 1))
1510 fade = 3.2 - 2 * (time - weapontime);
1511 fade = bound(0.7, fade, 1);
1516 HUD_WeaponIcons_Clear();
1518 float rows, columns;
1519 rows = mySize_y/mySize_x;
1520 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1521 // ^^^ weapon icon aspect goes here
1523 columns = ceil(WEP_COUNT/rows);
1525 for(i = 0; i < weapon_cnt; ++i)
1527 self = weaponorder[i];
1528 if((self.weapons && (self.impulse >= 0) && (stat_weapons & self.weapons)) || hud_configure)
1530 weapid = self.impulse;
1532 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1534 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1535 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1537 // draw background behind currently selected weapon
1538 if(self.weapon == activeweapon)
1539 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);
1541 // draw the weapon accuracy on the HUD
1542 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1545 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1547 accuracy_color = HUD_AccuracyColor(weapon_stats);
1549 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);
1552 // draw the weapon icon
1553 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);
1555 if(cvar_or("hud_weaponicons_number", 1))
1556 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);
1571 float GetAmmoStat(float i)
1575 case 0: return STAT_SHELLS;
1576 case 1: return STAT_NAILS;
1577 case 2: return STAT_ROCKETS;
1578 case 3: return STAT_CELLS;
1579 case 4: return STAT_FUEL;
1584 float GetAmmoItemCode(float i)
1588 case 0: return IT_SHELLS;
1589 case 1: return IT_NAILS;
1590 case 2: return IT_ROCKETS;
1591 case 3: return IT_CELLS;
1592 case 4: return IT_FUEL;
1597 string GetAmmoPicture(float i)
1601 case 0: return "ammo_shells";
1602 case 1: return "ammo_bullets";
1603 case 2: return "ammo_rockets";
1604 case 3: return "ammo_cells";
1605 case 4: return "ammo_fuel";
1610 void HUD_Inventory(void)
1612 float id = HUD_PANEL_INVENTORY;
1616 vector pos, mySize, mysize, mypos;
1617 pos = HUD_Panel_GetPos(id);
1618 mySize = HUD_Panel_GetSize(id);
1620 HUD_Panel_DrawBg(id, pos, mySize, 0);
1622 padding = HUD_Panel_GetPadding(id);
1625 pos += '1 1 0' * padding;
1626 mySize -= '2 2 0' * padding;
1630 stat_items = getstati(STAT_ITEMS);
1631 for (i = 0; i < 4; ++i) {
1633 a = getstati(GetAmmoStat(i)); // how much ammo do we have of type i?
1637 if(cvar("hud_inventory_onlycurrent")) {
1640 if (stat_items & GetAmmoItemCode(i) || hud_configure) {
1641 drawpic_skin(pos, GetAmmoPicture(i), '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1643 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);
1645 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);
1651 if(mySize_x/mySize_y >= 10) { // arrange horizontally
1653 case 0: mypos_x = pos_x; mypos_y = pos_y; break; // shells
1654 case 1: mypos_x = pos_x + 0.25 * mySize_x; mypos_y = pos_y; break; // bullets
1655 case 2: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y; break; // rockets
1656 case 3: mypos_x = pos_x + 0.75 * mySize_x; mypos_y = pos_y; break; // cells
1658 mysize_x = 0.25 * mySize_x;
1659 mysize_y = mySize_y;
1660 } else if(mySize_x/mySize_y >= 2.5) { // arrange in a 2x2 grid
1662 case 0: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y + 0.5 * mySize_y; break; // shells
1663 case 1: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y; break; // bullets
1664 case 2: mypos_x = pos_x; mypos_y = pos_y + 0.5 * mySize_y; break; // rockets
1665 case 3: mypos_x = pos_x; mypos_y = pos_y; break; // cells
1667 mysize_x = 0.5 * mySize_x;
1668 mysize_y = 0.5 * mySize_y;
1669 } else { // arrange vertically
1671 case 0: mypos_x = pos_x; mypos_y = pos_y; break; // shells
1672 case 1: mypos_x = pos_x; mypos_y = pos_y + 0.25 * mySize_y; break; // bullets
1673 case 2: mypos_x = pos_x; mypos_y = pos_y + 0.5 * mySize_y; break; // rockets
1674 case 3: mypos_x = pos_x; mypos_y = pos_y + 0.75 * mySize_y; break; // cells
1676 mysize_x = mySize_x;
1677 mysize_y = 0.25 * mySize_y;
1680 if (stat_items & GetAmmoItemCode(i))
1681 drawpic_skin(mypos, "ammo_current_bg", mysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1682 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);
1684 if(stat_items & GetAmmoItemCode(i))
1685 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);
1687 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);
1689 if(stat_items & GetAmmoItemCode(i))
1690 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);
1692 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);
1702 void HUD_Powerups(void) {
1703 float id = HUD_PANEL_POWERUPS;
1705 stat_items = getstati(STAT_ITEMS);
1709 if not(stat_items & IT_STRENGTH)
1710 if not(stat_items & IT_INVINCIBLE)
1713 if (getstati(STAT_HEALTH) <= 0)
1718 pos = HUD_Panel_GetPos(id);
1719 mySize = HUD_Panel_GetSize(id);
1721 HUD_Panel_DrawBg(id, pos, mySize, 0);
1723 padding = HUD_Panel_GetPadding(id);
1726 pos += '1 1 0' * padding;
1727 mySize -= '2 2 0' * padding;
1730 float strength_time, shield_time;
1732 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1733 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1743 vector barpos, barsize;
1747 string leftname, rightname;
1748 float leftcnt, rightcnt;
1749 float leftexact, rightexact;
1750 float leftalpha, rightalpha;
1751 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) {
1752 leftname = "strength";
1753 leftcnt = ceil(strength_time);
1754 leftexact = strength_time;
1756 rightname = "shield";
1757 rightcnt = ceil(shield_time);
1758 rightexact = shield_time;
1760 leftname = "shield";
1761 leftcnt = ceil(shield_time);
1762 leftexact = shield_time;
1764 rightname = "strength";
1765 rightcnt = ceil(strength_time);
1766 rightexact = strength_time;
1768 leftalpha = bound(0, leftexact, 1);
1769 rightalpha = bound(0, rightexact, 1);
1771 if (mySize_x/mySize_y > 4)
1775 len = strlen(ftos(leftcnt));
1777 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1778 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1779 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1780 picpos = pos + eX * 0.5 * mySize_x - eX * mySize_y;
1781 numpos = picpos - eX * 2 * 0.5 * mySize_y + eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1784 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1786 numpos = picpos + eX * mySize_y - eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1789 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1791 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));
1793 drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1794 HUD_DrawXNum(numpos, leftcnt, 2, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1799 len = strlen(ftos(rightcnt));
1801 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1802 barpos = pos + eX * 0.5 * mySize_x;
1803 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1804 picpos = pos + eX * 0.5 * mySize_x;
1805 numpos = picpos + eX * mySize_y - eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1807 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1808 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1809 picpos = pos + eX * mySize_x - eX * mySize_y;
1810 numpos = picpos - eX * mySize_y + eY * 0.25 * mySize_y;
1813 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1815 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));
1817 drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1818 HUD_DrawXNum(numpos, rightcnt, 2, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1821 else if (mySize_x/mySize_y > 1.5)
1825 len = strlen(ftos(leftcnt));
1827 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1828 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1829 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1830 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y;
1831 numpos = picpos - eX * len * 0.5 * mySize_y;
1834 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1836 numpos = picpos + eX * 0.5 * mySize_y;
1839 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1841 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));
1843 drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1844 HUD_DrawXNum(numpos, leftcnt, len, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1849 len = strlen(ftos(rightcnt));
1851 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1852 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1853 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1854 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y + eY * 0.5 * mySize_y;
1855 numpos = picpos - eX * len * 0.5 * mySize_y;
1857 barpos = pos + eY * 0.5 * mySize_y;
1858 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1859 picpos = pos + eY * 0.5 * mySize_y;
1860 numpos = picpos + eX * 0.5 * mySize_y;
1863 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1865 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));
1867 drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1868 HUD_DrawXNum(numpos, rightcnt, len, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1875 len = strlen(ftos(leftcnt));
1877 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1879 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1880 picpos = pos + eX * 0.05 * mySize_x;
1881 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x;
1883 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1884 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1885 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.65 * mySize_x;
1886 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.25 * mySize_x;
1889 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1891 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));
1893 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1894 HUD_DrawXNum(numpos, leftcnt, len, 0, 0.25 * mySize_x, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1899 len = strlen(ftos(rightcnt));
1901 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1902 barpos = pos + eX * 0.5 * mySize_x;
1903 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1904 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1905 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1907 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1908 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1909 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.65 * mySize_x + eX * 0.5 * mySize_x;
1910 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
1913 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1915 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));
1917 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1918 HUD_DrawXNum(numpos, rightcnt, len, 0, 0.25 * mySize_x, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1923 // Health/armor (#3)
1925 void HUD_HealthArmor(void)
1927 float id = HUD_PANEL_HEALTHARMOR;
1929 pos = HUD_Panel_GetPos(id);
1930 mySize = HUD_Panel_GetSize(id);
1932 HUD_Panel_DrawBg(id, pos, mySize, 0);
1934 padding = HUD_Panel_GetPadding(id);
1937 pos += '1 1 0' * padding;
1938 mySize -= '2 2 0' * padding;
1941 float armor, health;
1942 armor = getstati(STAT_ARMOR);
1943 health = getstati(STAT_HEALTH);
1946 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
1959 vector barpos, barsize;
1963 if(cvar("hud_healtharmor") == 2) // combined health and armor display
1966 v = healtharmor_maxdamage(health, armor, armorblockpercent);
1971 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1972 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
1973 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
1975 numpos = picpos + eX * 1.5 * mySize_y;
1978 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
1979 picpos = pos + eX * 3 * mySize_y;
1983 if(v_z) // NOT fully armored
1985 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("health"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1986 drawpic_skin(picpos, "health", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1988 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);
1992 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("armor"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1993 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);
1995 drawpic_skin(picpos, "armor", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1997 HUD_DrawXNum_Colored(numpos, x, 3, mySize_y, HUD_Panel_GetFgAlpha(id)); // draw the combined health and armor
2000 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2001 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2002 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2005 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2008 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2013 string leftname, rightname;
2014 float leftcnt, rightcnt;
2015 float leftactive, rightactive;
2016 float leftalpha, rightalpha;
2017 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) { // old style layout with armor left/top of health
2022 leftalpha = min((armor+10)/55, 1);
2024 rightname = "health";
2029 leftname = "health";
2034 rightname = "armor";
2038 rightalpha = min((armor+10)/55, 1);
2041 if (mySize_x/mySize_y > 5)
2045 len = strlen(ftos(leftcnt));
2047 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2048 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2049 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2050 picpos = pos + eX * 0.5 * mySize_x - eX * mySize_y;
2051 numpos = picpos - eX * 3 * 0.5 * mySize_y + eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
2054 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2056 numpos = picpos + eX * mySize_y + eY * 0.25 * mySize_y;
2059 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2060 drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2061 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2066 len = strlen(ftos(rightcnt));
2068 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2069 barpos = pos + eX * 0.5 * mySize_x;
2070 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2071 picpos = pos + eX * 0.5 * mySize_x;
2072 numpos = picpos + eX * mySize_y - eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
2074 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2075 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2076 picpos = pos + eX * mySize_x - eX * mySize_y;
2077 numpos = picpos - eX * 1.5 * mySize_y + eY * 0.25 * mySize_y;
2080 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2081 drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2082 HUD_DrawXNum_Colored(numpos, rightcnt, 3, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2085 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2086 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2087 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2090 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2093 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2095 else if (mySize_x/mySize_y > 2)
2099 len = strlen(ftos(leftcnt));
2101 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2102 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2103 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2104 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y;
2105 numpos = picpos - eX * len * 0.5 * mySize_y;
2108 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2110 numpos = picpos + eX * 0.5 * mySize_y;
2113 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2114 drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2115 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2120 len = strlen(ftos(rightcnt));
2122 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2123 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2124 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2125 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y + eY * 0.5 * mySize_y;
2126 numpos = picpos - eX * len * 0.5 * mySize_y;
2128 barpos = pos + eY * 0.5 * mySize_y;
2129 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2130 picpos = pos + eY * 0.5 * mySize_y;
2131 numpos = picpos + eX * 0.5 * mySize_y;
2134 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2135 drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2136 HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2139 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2140 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2141 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2144 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2147 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2153 len = strlen(ftos(leftcnt));
2155 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2157 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2158 picpos = pos + eX * 0.05 * mySize_x;
2159 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x;
2161 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2162 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2163 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x;
2164 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x;
2167 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2168 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2169 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.166 * mySize_x, HUD_Panel_GetFgAlpha(id));
2174 len = strlen(ftos(rightcnt));
2176 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2177 barpos = pos + eX * 0.5 * mySize_x;
2178 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2179 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2180 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2182 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2183 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2184 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x + eX * 0.5 * mySize_x;
2185 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x + eX * 0.5 * mySize_x;
2188 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2189 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2190 HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.166 * mySize_x, HUD_Panel_GetFgAlpha(id));
2193 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2195 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2197 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2198 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2201 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2207 // Notification area (#4)
2210 string Weapon_SuicideMessage(float deathtype)
2212 w_deathtype = deathtype;
2213 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2214 return w_deathtypestring;
2217 string Weapon_KillMessage(float deathtype)
2219 w_deathtype = deathtype;
2220 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2221 return w_deathtypestring;
2224 float killnotify_times[10];
2225 float killnotify_deathtype[10];
2226 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2227 string killnotify_attackers[10];
2228 string killnotify_victims[10];
2229 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2232 for (i = 9; i > 0; --i) {
2233 killnotify_times[i] = killnotify_times[i-1];
2234 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2235 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2236 if(killnotify_attackers[i])
2237 strunzone(killnotify_attackers[i]);
2238 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2239 if(killnotify_victims[i])
2240 strunzone(killnotify_victims[i]);
2241 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2243 killnotify_times[0] = time;
2244 killnotify_deathtype[0] = wpn;
2245 killnotify_actiontype[0] = actiontype;
2246 if(killnotify_attackers[0])
2247 strunzone(killnotify_attackers[0]);
2248 killnotify_attackers[0] = strzone(attacker);
2249 if(killnotify_victims[0])
2250 strunzone(killnotify_victims[0]);
2251 killnotify_victims[0] = strzone(victim);
2254 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2258 alsoprint = (cvar("hud_notify_print") || !HUD_Panel_CheckActive(4)); // print message to console if: notify panel disabled, or cvar to do so enabled
2260 if(msg == MSG_SUICIDE) {
2262 w = DEATH_WEAPONOF(type);
2264 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2266 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2267 } else if (type == DEATH_KILL) {
2268 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2270 print ("^1",s1, "^1 couldn't take it anymore\n");
2271 } else if (type == DEATH_ROT) {
2272 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2274 print ("^1",s1, "^1 died\n");
2275 } else if (type == DEATH_NOAMMO) {
2276 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2278 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2279 } else if (type == DEATH_CAMP) {
2280 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2282 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2283 } else if (type == DEATH_MIRRORDAMAGE) {
2284 HUD_KillNotify_Push(s1, "", 0, DEATH_MIRRORDAMAGE);
2286 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2287 } else if (type == DEATH_CHEAT) {
2288 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2290 print ("^1",s1, "^1 unfairly eliminated themself\n");
2291 } else if (type == DEATH_FIRE) {
2292 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2294 print ("^1",s1, "^1 burned to death\n");
2295 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2296 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2298 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2301 if (stof(s2) > 2) // killcount > 2
2302 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2303 } else if(msg == MSG_KILL) {
2304 w = DEATH_WEAPONOF(type);
2306 HUD_KillNotify_Push(s2, s1, 1, w);
2308 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2310 else if(type == KILL_TEAM || type == KILL_TEAM_SPREE) {
2311 HUD_KillNotify_Push(s1, s2, 1, DEATH_MIRRORDAMAGE);
2314 if(cvar("cl_gentle")) {
2315 print ("^1", s1, "^1 took action against a team mate\n");
2317 print ("^1", s1, "^1 mows down a team mate\n");
2320 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2321 if(cvar("cl_gentle"))
2322 print ("^1",s1,"^1 ended a ",s2," scoring spree by going against a team mate\n");
2324 print ("^1",s1,"^1 ended a ",s2," kill spree by killing a team mate\n");
2326 else if (stof(s2) > 2) {
2327 if(cvar("cl_gentle"))
2328 print ("^1",s1,"'s ^1",s2," scoring spree was ended by a team mate!\n");
2330 print ("^1",s1,"'s ^1",s2," kill spree was ended by a team mate!\n");
2333 else if(type == KILL_FIRST_BLOOD)
2334 print("^1",s1, "^1 drew first blood", "\n");
2336 else if (type == DEATH_TELEFRAG)
2337 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2338 else if (type == DEATH_DROWN) {
2339 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2341 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2343 else if (type == DEATH_SLIME) {
2344 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2346 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2348 else if (type == DEATH_LAVA) {
2349 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2351 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2353 else if (type == DEATH_FALL) {
2354 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2356 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2358 else if (type == DEATH_SHOOTING_STAR) {
2359 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2361 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2363 else if (type == DEATH_SWAMP) {
2364 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2366 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2368 else if (type == DEATH_HURTTRIGGER)
2370 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2372 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2373 } else if(type == DEATH_SBCRUSH) {
2374 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2376 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2377 } else if(type == DEATH_SBMINIGUN) {
2378 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2380 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2381 } else if(type == DEATH_SBROCKET) {
2382 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2384 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2385 } else if(type == DEATH_SBBLOWUP) {
2386 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2388 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2389 } else if(type == DEATH_WAKIGUN) {
2390 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2392 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2393 } else if(type == DEATH_WAKIROCKET) {
2394 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2396 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2397 } else if(type == DEATH_WAKIBLOWUP) {
2398 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2400 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2401 } else if(type == DEATH_TURRET) {
2402 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2404 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2405 } else if(type == DEATH_TOUCHEXPLODE) {
2406 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2408 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2409 } else if(type == DEATH_CHEAT) {
2410 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2412 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2413 } else if (type == DEATH_FIRE) {
2414 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2416 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2417 } else if (type == DEATH_CUSTOM) {
2418 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2420 print ("^1",s1, "^1 ", s2, "\n");
2422 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2424 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2426 } else if(msg == MSG_SPREE) {
2427 if(type == KILL_END_SPREE) {
2428 if(cvar("cl_gentle"))
2429 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2431 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2432 } else if(type == KILL_SPREE) {
2433 if(cvar("cl_gentle"))
2434 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2436 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2437 } else if(type == KILL_SPREE_3) {
2438 if(cvar("cl_gentle"))
2439 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2441 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2442 } else if(type == KILL_SPREE_5) {
2443 if(cvar("cl_gentle"))
2444 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2446 print (s1,"^7 unleashes ^1RAGE\n");
2447 } else if(type == KILL_SPREE_10) {
2448 if(cvar("cl_gentle"))
2449 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2451 print (s1,"^7 starts the ^1MASSACRE!\n");
2452 } else if(type == KILL_SPREE_15) {
2453 if(cvar("cl_gentle"))
2454 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2456 print (s1,"^7 executes ^1MAYHEM!\n");
2457 } else if(type == KILL_SPREE_20) {
2458 if(cvar("cl_gentle"))
2459 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2461 print (s1,"^7 is a ^1BERSERKER!\n");
2462 } else if(type == KILL_SPREE_25) {
2463 if(cvar("cl_gentle"))
2464 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2466 print (s1,"^7 inflicts ^1CARNAGE!\n");
2467 } else if(type == KILL_SPREE_30) {
2468 if(cvar("cl_gentle"))
2469 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2471 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2473 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2474 if (type == DEATH_DROWN) {
2475 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2478 if(cvar("cl_gentle"))
2479 print ("^1",s1, "^1 was in the water for too long\n");
2481 print ("^1",s1, "^1 drowned\n");
2483 } else if (type == DEATH_SLIME) {
2484 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2486 print ("^1",s1, "^1 was slimed\n");
2487 } else if (type == DEATH_LAVA) {
2488 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2491 if(cvar("cl_gentle"))
2492 print ("^1",s1, "^1 found a hot place\n");
2494 print ("^1",s1, "^1 turned into hot slag\n");
2496 } else if (type == DEATH_FALL) {
2497 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2500 if(cvar("cl_gentle"))
2501 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2503 print ("^1",s1, "^1 hit the ground with a crunch\n");
2505 } else if (type == DEATH_SHOOTING_STAR) {
2506 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2508 print ("^1",s1, "^1 became a shooting star\n");
2509 } else if (type == DEATH_SWAMP) {
2510 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2513 if(cvar("cl_gentle"))
2514 print ("^1",s1, "^1 discovered a swamp\n");
2516 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2518 } else if(type == DEATH_TURRET) {
2519 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2521 print ("^1",s1, "^1 was mowed down by a turret \n");
2522 } else if (type == DEATH_CUSTOM) {
2523 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2525 print ("^1",s1, "^1 ", s2, "\n");
2526 } else if (type == DEATH_HURTTRIGGER) {
2527 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2529 print ("^1",s1, "^1 was in the wrong place\n");
2530 } else if(type == DEATH_TOUCHEXPLODE) {
2531 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2533 print ("^1",s1, "^1 died in an accident\n");
2534 } else if(type == DEATH_CHEAT) {
2535 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2537 print ("^1",s1, "^1 was unfairly eliminated\n");
2538 } else if(type == DEATH_FIRE) {
2539 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2542 if(cvar("cl_gentle"))
2543 print ("^1",s1, "^1 felt a little hot\n");
2545 print ("^1",s1, "^1 burnt to death\n");
2548 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2551 if(cvar("cl_gentle"))
2552 print ("^1",s1, "^1 needs a restart\n");
2554 print ("^1",s1, "^1 died\n");
2557 } else if(msg == MSG_KILL_ACTION_SPREE) {
2558 if(cvar("cl_gentle"))
2559 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2561 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2562 } else if(msg == MSG_INFO) {
2563 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2564 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2565 print(s1, "^7 got the ", s2, "\n");
2566 } else if(type == INFO_LOSTFLAG) {
2567 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2568 print(s1, "^7 lost the ", s2, "\n");
2569 } else if(type == INFO_PICKUPFLAG) {
2570 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2571 print(s1, "^7 picked up the ", s2, "\n");
2572 } else if(type == INFO_RETURNFLAG) {
2573 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2574 print(s1, "^7 returned the ", s2, "\n");
2579 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2581 void HUD_Centerprint(string s1, string s2, float type, float msg)
2583 if(msg == MSG_SUICIDE) {
2584 if (type == DEATH_TEAMCHANGE) {
2585 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2586 } else if (type == DEATH_AUTOTEAMCHANGE) {
2587 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2588 } else if (type == DEATH_CAMP) {
2589 if(cvar("cl_gentle"))
2590 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2592 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2593 } else if (type == DEATH_NOAMMO) {
2594 if(cvar("cl_gentle"))
2595 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2597 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2598 } else if (type == DEATH_ROT) {
2599 if(cvar("cl_gentle"))
2600 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2602 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2603 } else if (type == DEATH_MIRRORDAMAGE) {
2604 if(cvar("cl_gentle"))
2605 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2607 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2608 } else if (type == DEATH_QUIET) {
2610 } else if (type == DEATH_KILL) {
2611 if(cvar("cl_gentle"))
2612 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2614 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2616 } else if(msg == MSG_KILL) {
2617 if (type == KILL_TEAM) {
2618 if(cvar("cl_gentle")) {
2619 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against a team mate!"));
2621 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2623 } else if (type == KILL_FIRST_BLOOD) {
2624 if(cvar("cl_gentle")) {
2625 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2627 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2629 } else if (type == KILL_FIRST_VICTIM) {
2630 if(cvar("cl_gentle")) {
2631 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2633 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2635 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2636 if(cvar("cl_gentle")) {
2637 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^7 who was typing!", s2));
2639 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2641 } else if (type == KILL_TYPEFRAGGED) {
2642 if(cvar("cl_gentle")) {
2643 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^7 while you were typing!", s2));
2645 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2647 } else if (type == KILL_FRAG) {
2648 if(cvar("cl_gentle")) {
2649 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2651 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2653 } else if (type == KILL_FRAGGED) {
2654 if(cvar("cl_gentle")) {
2655 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You were scored against by ^7", s1, s2));
2657 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You were fragged by ^7", s1, s2));
2660 } else if(msg == MSG_KILL_ACTION) {
2661 // TODO: invent more centerprints here?
2662 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!", s1));
2666 void HUD_Notify (void)
2668 float id = HUD_PANEL_NOTIFY;
2670 pos = HUD_Panel_GetPos(id);
2671 mySize = HUD_Panel_GetSize(id);
2673 HUD_Panel_DrawBg(id, pos, mySize, 0);
2675 padding = HUD_Panel_GetPadding(id);
2678 pos += '1 1 0' * padding;
2679 mySize -= '2 2 0' * padding;
2682 float entries, height;
2683 entries = bound(1, floor(14 * mySize_y/mySize_x), 12);
2684 height = mySize_y/entries;
2685 entries -= 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2688 fontsize = '0.5 0.5 0' * height;
2692 when = cvar("hud_notify_time");
2694 fadetime = cvar("hud_notify_fadetime");
2698 vector pos_attacker, pos_victim;
2700 float width_attacker, width_victim;
2701 string attacker, victim;
2704 for(j = 0; j < entries; ++j)
2706 if(cvar("hud_notify_flip"))
2708 else // rather nasty hack for ordering items from the bottom up
2709 i = entries - j - 1;
2710 if(cvar("hud_notify_info_top"))
2711 i += 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2715 if(killnotify_times[j] + when > time)
2718 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2722 if(killnotify_times[j] + when > time)
2728 // TODO: maybe print in team colors?
2729 // TODO: maybe this could be cleaned up somehow...
2730 // TODO: less copypaste code below
2733 if(killnotify_actiontype[j] == 0 && !hud_configure)
2735 attacker = textShortenToWidth(killnotify_attackers[j], mySize_x - 2 * height, fontsize, stringwidth_colors);
2737 width_attacker = stringwidth(attacker, TRUE, fontsize);
2738 pos_attacker = pos + eX * 0.5 * (mySize_x - width_attacker + 2 * height) + eY * 0.5 * fontsize_y + eY * i * height;
2740 weap_pos = pos + eX * 0.5 * (mySize_x - width_attacker) - eX * height + eY * i * height;
2741 if(killnotify_deathtype[j] == DEATH_GENERIC)
2743 drawpic_skin(weap_pos, "notify_death", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2744 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2746 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2748 drawpic_skin(weap_pos, "notify_outofammo", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2749 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2751 else if(killnotify_deathtype[j] == DEATH_KILL)
2753 drawpic_skin(weap_pos, "notify_selfkill", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2754 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2756 else if(killnotify_deathtype[j] == DEATH_CAMP)
2758 drawpic_skin(weap_pos, "notify_camping", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2759 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2761 else if(killnotify_deathtype[j] == DEATH_MIRRORDAMAGE)
2763 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2764 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2766 else if(killnotify_deathtype[j] == DEATH_DROWN)
2768 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2769 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2771 else if(killnotify_deathtype[j] == DEATH_SLIME)
2773 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2774 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2776 else if(killnotify_deathtype[j] == DEATH_LAVA)
2778 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2779 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2781 else if(killnotify_deathtype[j] == DEATH_FALL)
2783 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2784 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2786 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2788 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2789 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2791 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2793 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2794 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2796 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2798 if(killnotify_victims[j] == "^1RED^7 flag")
2802 drawpic_skin(weap_pos, strcat("flag_", s, "_carrying"), '1 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] == INFO_RETURNFLAG)
2807 if(killnotify_victims[j] == "^1RED^7 flag")
2811 drawpic_skin(weap_pos, strcat("flag_", s, "_taken"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2812 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2814 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2816 if(killnotify_victims[j] == "^1RED^7 flag")
2820 drawpic_skin(weap_pos, strcat("flag_", s, "_lost"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2821 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2824 // X [did action to] Y
2829 attacker = textShortenToWidth("Player1", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2830 victim = textShortenToWidth("Player2", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2831 a = bound(0, (when - j) / 4, 1);
2835 attacker = textShortenToWidth(killnotify_attackers[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2836 victim = textShortenToWidth(killnotify_victims[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2838 width_attacker = stringwidth(attacker, TRUE, fontsize);
2839 width_victim = stringwidth(victim, TRUE, fontsize);
2840 pos_attacker = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_attacker) + eY * 0.5 * fontsize_y + eY * i * height;
2841 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;
2842 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2844 if(hud_configure) // example actions for config mode
2846 drawpic_skin(weap_pos, strcat("weapon", "electro"), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2847 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2848 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2850 else if(WEP_VALID(killnotify_deathtype[j]))
2852 self = get_weaponinfo(killnotify_deathtype[j]);
2853 drawpic_skin(weap_pos, strcat("weapon", self.netname), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2854 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2855 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2857 else if(killnotify_deathtype[j] == DEATH_MIRRORDAMAGE)
2859 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2860 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2861 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2863 else if(killnotify_deathtype[j] == DEATH_DROWN)
2865 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2866 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2867 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2869 else if(killnotify_deathtype[j] == DEATH_SLIME)
2871 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2872 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2873 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2875 else if(killnotify_deathtype[j] == DEATH_LAVA)
2877 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2878 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2879 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2881 else if(killnotify_deathtype[j] == DEATH_FALL)
2883 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2884 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2885 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2887 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2889 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2890 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2891 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2893 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2895 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2896 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2897 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2908 if(cvar("hud_notify_info_top"))
2911 o = pos + eY * mySize_y - eY * 2 * height;
2913 if(spectatee_status && !intermission)
2915 //drawfont = hud_bigfont;
2916 if(spectatee_status == -1)
2919 s = GetPlayerName(spectatee_status - 1);
2921 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
2922 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2923 //drawfont = hud_font;
2925 // spectator text in the upper right corner
2926 if(spectatee_status == -1)
2927 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
2929 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
2930 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2931 o += eY * fontsize_y;
2933 if(spectatee_status == -1)
2934 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
2936 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
2937 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2938 o += eY * fontsize_y;
2940 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
2941 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2942 o += eY * fontsize_y;
2944 if(gametype == GAME_ARENA)
2945 s = "^1Wait for your turn to join";
2946 else if(gametype == GAME_LMS)
2949 sk = playerslots[player_localentnum - 1];
2950 if(sk.(scores[ps_primary]) >= 666)
2951 s = "^1Match has already begun";
2952 else if(sk.(scores[ps_primary]) > 0)
2953 s = "^1You have no more lives left";
2955 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
2958 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
2959 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2960 o += eY * fontsize_y;
2962 //show restart countdown:
2963 if (time < getstatf(STAT_GAMESTARTTIME)) {
2965 //we need to ceil, otherwise the countdown would be off by .5 when using round()
2966 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
2967 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
2968 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2969 o += eY * fontsize_y;
2972 if(warmup_stage && !intermission)
2974 s = "^2Currently in ^1warmup^2 stage!";
2975 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2976 o += eY * fontsize_y;
2980 if(mod(time, 1) >= 0.5)
2985 if(ready_waiting && !intermission && !spectatee_status)
2987 if(ready_waiting_for_me)
2990 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
2992 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
2997 s = strcat("^2Waiting for others to ready up to end warmup...");
2999 s = strcat("^2Waiting for others to ready up...");
3001 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3002 o += eY * fontsize_y;
3004 else if(warmup_stage && !intermission && !spectatee_status)
3006 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
3007 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3008 o += eY * fontsize_y;
3011 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
3013 float ts_min, ts_max;
3014 tm = teams.sort_next;
3017 for(; tm.sort_next; tm = tm.sort_next)
3019 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
3021 if(!ts_min) ts_min = tm.team_size;
3022 else ts_min = min(ts_min, tm.team_size);
3023 if(!ts_max) ts_max = tm.team_size;
3024 else ts_max = max(ts_max, tm.team_size);
3026 if ((ts_max - ts_min) > 1)
3028 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
3029 tm = GetTeam(myteam, false);
3031 if (tm.team != COLOR_SPECTATOR)
3032 if (tm.team_size == ts_max)
3033 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
3035 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3036 o += eY * fontsize_y;
3042 s = "^7Press ^3ESC ^7to show HUD options.";
3043 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3044 o += eY * fontsize_y;
3045 s = "^3Doubleclick a panel for panel-specific options.";
3046 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3047 o += eY * fontsize_y;
3053 void HUD_Timer(void)
3055 float id = HUD_PANEL_TIMER;
3057 pos = HUD_Panel_GetPos(id);
3058 mySize = HUD_Panel_GetSize(id);
3060 HUD_Panel_DrawBg(id, pos, mySize, 0);
3062 padding = HUD_Panel_GetPadding(id);
3065 pos += '1 1 0' * padding;
3066 mySize -= '2 2 0' * padding;
3069 float timelimit, elapsedTime, minutes, seconds, timeleft, minutesLeft, secondsLeft;
3071 timelimit = getstatf(STAT_TIMELIMIT);
3073 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3074 timeleft = ceil(timeleft);
3075 minutesLeft = floor(timeleft / 60);
3076 secondsLeft = timeleft - minutesLeft*60;
3079 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3080 timer_color = '1 1 1'; //white
3081 else if(minutesLeft >= 1)
3082 timer_color = '1 1 0'; //yellow
3084 timer_color = '1 0 0'; //red
3086 if (cvar("hud_timer_increment") || timelimit == 0 || warmup_stage) {
3087 if (time < getstatf(STAT_GAMESTARTTIME)) {
3088 //while restart is still active, show 00:00
3089 minutes = seconds = 0;
3091 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3092 minutes = floor(elapsedTime / 60);
3093 seconds = elapsedTime - minutes*60;
3096 minutes = minutesLeft;
3097 seconds = secondsLeft;
3102 minutes = min(minutes, 999);
3103 if(minutesLeft >= 1 || cvar("hud_timer_increment") || timelimit == 0 || warmup_stage) {
3104 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);
3105 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);
3107 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);
3112 void HUD_Radar(void)
3114 float id = HUD_PANEL_RADAR;
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 local float color1, color2; // color already declared as a global in hud.qc
3131 float scale2d, normalsize, bigsize;
3134 teamradar_origin2d = pos + 0.5 * mySize;
3135 teamradar_size2d = mySize;
3137 if(minimapname == "")
3140 teamradar_loadcvars();
3142 switch(hud_radar_zoommode)
3146 f = current_zoomfraction;
3149 f = 1 - current_zoomfraction;
3159 switch(hud_radar_rotation)
3162 teamradar_angle = view_angles_y - 90;
3165 teamradar_angle = 90 * hud_radar_rotation;
3169 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3170 teamradar_size2d = mySize;
3172 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3174 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3175 if(hud_radar_rotation == 0)
3177 // max-min distance must fit the radar in any rotation
3178 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3182 vector c0, c1, c2, c3, span;
3183 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3184 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3185 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3186 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3188 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3189 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3191 // max-min distance must fit the radar in x=x, y=y
3193 teamradar_size2d_x * scale2d / (1.05 * span_x),
3194 teamradar_size2d_y * scale2d / (1.05 * span_y)
3198 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3199 if(bigsize > normalsize)
3200 normalsize = bigsize;
3204 + (1 - f) * normalsize;
3205 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3206 f * (mi_min + mi_max) * 0.5
3207 + (1 - f) * view_origin);
3209 color1 = GetPlayerColor(player_localentnum-1);
3210 rgb = GetTeamRGB(color1);
3219 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3221 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3222 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3223 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3224 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, HUD_Panel_GetFgAlpha(id));
3225 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3227 color2 = GetPlayerColor(tm.sv_entnum);
3228 //if(color == COLOR_SPECTATOR || color == color2)
3229 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3231 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3233 drawresetcliparea();
3238 void HUD_Score(void)
3240 float id = HUD_PANEL_SCORE;
3242 pos = HUD_Panel_GetPos(id);
3243 mySize = HUD_Panel_GetSize(id);
3245 HUD_Panel_DrawBg(id, pos, mySize, 0);
3247 padding = HUD_Panel_GetPadding(id);
3250 pos += '1 1 0' * padding;
3251 mySize -= '2 2 0' * padding;
3254 float score, distribution, leader;
3255 float score_len, distr_len;
3256 vector distribution_color;
3258 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3260 // TODO... this (race part) still uses constant coordinates :/
3261 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3262 /*pl = players.sort_next;
3265 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3266 if(pl.scores[ps_primary] == 0)
3269 score = me.(scores[ps_primary]);
3271 float racemin, racesec, racemsec;
3272 float distsec, distmsec, minusplus;
3274 racemin = floor(score/(60 * TIME_FACTOR));
3275 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
3276 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
3278 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3279 // distribution display
3280 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3282 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
3283 distmsec = fabs(distribution);
3285 distsec = floor(fabs(distribution)/TIME_FACTOR);
3286 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
3287 if (distribution < 0)
3291 if (distribution <= 0) {
3292 distribution_color = eY;
3293 minusplus = 1; // minusplus 1: always prefix with minus sign
3296 distribution_color = eX;
3297 minusplus = 2; // minusplus 1: always prefix with plus sign
3299 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);
3300 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);
3301 drawpic_skin(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "num_dot", '16 16 0', distribution_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE);
3303 // race record display
3304 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
3305 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);
3307 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);
3308 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);
3309 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);
3311 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);
3312 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);
3314 } else if (!teamplay) { // non-teamgames
3315 // me vector := [team/connected frags id]
3316 pl = players.sort_next;
3323 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3327 score = me.(scores[ps_primary]);
3331 if(distribution >= 5) {
3332 distribution_color = eY;
3334 } else if(distribution >= 0) {
3335 distribution_color = '1 1 1';
3337 } else if(distribution >= -5)
3338 distribution_color = '1 1 0';
3340 distribution_color = eX;
3342 score_len = strlen(ftos(score));
3343 distr_len = strlen(ftos(distribution));
3345 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);
3347 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);
3348 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);
3349 } else { // teamgames
3350 float max_fragcount;
3351 max_fragcount = -99;
3354 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3355 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !hud_configure)) // no players? don't display
3357 score = tm.(teamscores[ts_primary]);
3362 score_len = strlen(ftos(score));
3364 if (score > max_fragcount)
3365 max_fragcount = score;
3367 if(tm.team == myteam) {
3368 if (max_fragcount == score)
3371 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);
3372 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);
3374 if (max_fragcount == score)
3377 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);
3378 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);
3387 void HUD_RaceTimer (void) {
3388 float id = HUD_PANEL_RACETIMER;
3390 pos = HUD_Panel_GetPos(id);
3391 mySize = HUD_Panel_GetSize(id);
3393 HUD_Panel_DrawBg(id, pos, mySize, 0);
3395 padding = HUD_Panel_GetPadding(id);
3398 pos += '1 1 0' * padding;
3399 mySize -= '2 2 0' * padding;
3402 drawfont = hud_bigfont;
3404 string s, forcetime;
3409 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);
3410 s = "^1Intermediate 1 (+15.42)";
3411 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);
3412 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3413 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);
3415 else if(race_checkpointtime)
3417 a = bound(0, 2 - (time - race_checkpointtime), 1);
3420 if(a > 0) // just hit a checkpoint?
3422 if(race_checkpoint != 254)
3424 if(race_time && race_previousbesttime)
3425 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3427 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3429 forcetime = TIME_ENCODED_TOSTRING(race_time);
3434 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3436 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3437 if(a > 0) // next one?
3439 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3444 if(s != "" && a > 0)
3446 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3447 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3448 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);
3451 if(race_penaltytime)
3453 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3456 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3457 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3458 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3459 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);
3465 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3466 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id), 0, a);
3467 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);
3472 if(race_laptime && race_checkpoint != 255)
3474 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3475 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3476 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);
3481 if(race_mycheckpointtime)
3483 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3484 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3485 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3486 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3487 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);
3489 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3491 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3492 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3493 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3494 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3495 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);
3498 if(race_penaltytime && !race_penaltyaccumulator)
3500 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3501 a = bound(0, (1 + t - time), 1);
3505 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3507 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3508 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3509 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3510 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);
3515 drawfont = hud_font;
3520 float vote_yescount;
3523 float vote_highlighted; // currently selected vote
3525 float vote_active; // is there an active vote?
3526 float vote_prev; // previous state of vote_active to check for a change
3528 float vote_change; // "time" when vote_active changed
3530 void HUD_VoteWindow(void)
3532 float id = HUD_PANEL_VOTE;
3534 pos = HUD_Panel_GetPos(id);
3535 mySize = HUD_Panel_GetSize(id);
3539 if(vote_active != vote_prev) {
3541 vote_prev = vote_active;
3544 if(vote_active || hud_configure)
3545 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3547 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3559 a = vote_alpha * bound(cvar_or("hud_vote_alreadyvoted_alpha", 0.75), 1 - vote_highlighted, 1);
3561 HUD_Panel_DrawBg(id, pos, mySize, a);
3563 padding = HUD_Panel_GetPadding(id);
3566 pos += '1 1 0' * padding;
3567 mySize -= '2 2 0' * padding;
3570 drawpic_skin(pos, "voteprogress_back", mySize, '1 1 1', a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3572 s = "A vote has been called for: ";
3573 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);
3574 s = textShortenToWidth(vote_called_vote, mySize_x * 0.96, '1 1 0' * mySize_y*(1/5), stringwidth_colors); // TODO: broken?
3576 s = "Configure the HUD";
3577 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);
3579 // print the yes/no counts
3580 s = strcat("Yes: ", ftos(vote_yescount));
3581 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);
3582 s = strcat("No: ", ftos(vote_nocount));
3583 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);
3585 // draw the progress bars
3586 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3587 drawpic_skin(pos, "voteprogress_prog", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3589 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3590 drawpic_skin(pos, "voteprogress_prog", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3592 // draw the highlights
3593 if(vote_highlighted == 1) {
3594 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3595 drawpic_skin(pos, "voteprogress_voted", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3597 else if(vote_highlighted == 2) {
3598 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3599 drawpic_skin(pos, "voteprogress_voted", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3602 drawresetcliparea();
3605 vote_highlighted = 0;
3609 // Mod icons panel (#10)
3612 float mod_active; // is there any active mod icon?
3614 // CTF HUD modicon section
3615 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3616 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3617 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3619 void HUD_Mod_CTF_Reset(void)
3621 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3624 void HUD_Mod_CTF(vector pos, vector mySize)
3626 vector redflag_pos, blueflag_pos;
3627 float f; // every function should have that
3629 float redflag, blueflag; // current status
3630 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3633 stat_items = getstati(STAT_ITEMS);
3634 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3635 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3637 if(redflag || blueflag)
3648 // when status CHANGES, set old status into prevstatus and current status into status
3649 if (redflag != redflag_prevframe)
3651 redflag_statuschange_time = time;
3652 redflag_prevstatus = redflag_prevframe;
3653 redflag_prevframe = redflag;
3656 if (blueflag != blueflag_prevframe)
3658 blueflag_statuschange_time = time;
3659 blueflag_prevstatus = blueflag_prevframe;
3660 blueflag_prevframe = blueflag;
3663 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3664 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3666 float BLINK_FACTOR = 0.15;
3667 float BLINK_BASE = 0.85;
3669 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3671 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3673 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3675 string red_icon, red_icon_prevstatus;
3676 float red_alpha, red_alpha_prevstatus;
3677 red_alpha = red_alpha_prevstatus = 1;
3679 case 1: red_icon = "flag_red_taken"; break;
3680 case 2: red_icon = "flag_red_lost"; break;
3681 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3683 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3684 red_icon = "flag_red_shielded";
3686 red_icon = string_null;
3689 switch(redflag_prevstatus) {
3690 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3691 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3692 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3695 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3696 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3697 red_icon_prevstatus = "flag_red_shielded";
3699 red_icon_prevstatus = string_null;
3703 string blue_icon, blue_icon_prevstatus;
3704 float blue_alpha, blue_alpha_prevstatus;
3705 blue_alpha = blue_alpha_prevstatus = 1;
3707 case 1: blue_icon = "flag_blue_taken"; break;
3708 case 2: blue_icon = "flag_blue_lost"; break;
3709 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3711 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3712 blue_icon = "flag_blue_shielded";
3714 blue_icon = string_null;
3717 switch(blueflag_prevstatus) {
3718 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3719 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3720 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3723 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3724 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3725 blue_icon_prevstatus = "flag_blue_shielded";
3727 blue_icon_prevstatus = string_null;
3731 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3733 blueflag_pos = pos + eX * mySize_y;
3736 redflag_pos = pos + eX * mySize_y;
3739 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3740 if(red_icon_prevstatus && f < 1)
3741 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);
3743 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);
3745 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3746 if(blue_icon_prevstatus && f < 1)
3747 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);
3749 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);
3752 // Keyhunt HUD modicon section
3753 float kh_runheretime;
3755 void HUD_Mod_KH_Reset(void)
3760 void HUD_Mod_KH(vector pos, vector mySize)
3762 mod_active = 1; // keyhunt should never hide the mod icons panel
3766 vector p, pa, kh_size, kh_asize;
3769 p_y = pos_y + 0.25 * mySize_y;
3771 kh_keys = getstati(STAT_KH_KEYS);
3773 kh_size_x = mySize_x * 0.25;
3774 kh_size_y = 0.75 * mySize_y;
3776 pa = p - eY * 0.25 * mySize_y;
3778 kh_asize_x = mySize_x * 0.25;
3779 kh_asize_y = mySize_y * 0.25;
3785 for(i = 0; i < 4; ++i)
3787 key = floor(kh_keys / pow(32, i)) & 31;
3789 if(keyteam == 30 && keycount <= 4)
3791 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3795 // this yields 8 exactly if "RUN HERE" shows
3800 kh_runheretime = time;
3801 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3806 for(i = 0; i < 4; ++i)
3808 key = floor(kh_keys / pow(32, i)) & 31;
3821 default: // owned or dropped
3826 a = a * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3827 aa = aa * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3833 drawpic_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3836 drawpic_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3839 drawpic_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3842 drawpic_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3847 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3850 drawpic_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3853 drawpic_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3856 drawpic_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3859 drawpic_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3863 p_x += 0.25 * mySize_x;
3864 pa_x += 0.25 * mySize_x;
3868 // Nexball HUD mod icon
3869 void HUD_Mod_NexBall(vector pos, vector mySize)
3871 float stat_items, nb_pb_starttime, dt, p;
3873 stat_items = getstati(STAT_ITEMS);
3874 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3876 if (stat_items & IT_KEY1)
3881 //Manage the progress bar if any
3882 if (nb_pb_starttime > 0)
3884 dt = mod(time - nb_pb_starttime, nb_pb_period);
3885 // one period of positive triangle
3886 p = 2 * dt / nb_pb_period;
3891 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);
3894 pos_x += 0.5 * mySize_x - 0.5 * mySize_y; //horizontal margin to the picture
3896 if (stat_items & IT_KEY1)
3897 drawpic_skin(pos, "nexball_carrying", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3900 // Race/CTS HUD mod icons
3901 float crecordtime_prev; // last remembered crecordtime
3902 float crecordtime_change_time; // time when crecordtime last changed
3903 float srecordtime_prev; // last remembered srecordtime
3904 float srecordtime_change_time; // time when srecordtime last changed
3906 float race_status_time;
3907 float race_status_prev;
3908 string race_status_name_prev;
3909 void HUD_Mod_Race(vector pos, vector mySize)
3911 mod_active = 1; // race should never hide the mod icons panel
3913 me = playerslots[player_localentnum - 1];
3915 float f; // yet another function has this
3916 score = me.(scores[ps_primary]);
3918 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3919 return; // no records in the actual race
3921 drawfont = hud_bigfont;
3923 // clientside personal record
3925 if(gametype == GAME_CTS)
3929 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3931 if(score && (score < t || !t)) {
3932 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3933 if(cvar("cl_autodemo_delete_keeprecords"))
3935 f = cvar("cl_autodemo_delete");
3937 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3941 if(t != crecordtime_prev) {
3942 crecordtime_prev = t;
3943 crecordtime_change_time = time;
3945 f = time - crecordtime_change_time;
3948 drawstring(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3949 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);
3951 drawstring(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3952 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);
3953 drawstring_expanding(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL, f);
3954 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);
3958 t = race_server_record;
3959 if(t != srecordtime_prev) {
3960 srecordtime_prev = t;
3961 srecordtime_change_time = time;
3963 f = time - srecordtime_change_time;
3966 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);
3967 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);
3969 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);
3970 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);
3971 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);
3972 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);
3975 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
3976 race_status_time = time + 5;
3977 race_status_prev = race_status;
3978 if (race_status_name_prev)
3979 strunzone(race_status_name_prev);
3980 race_status_name_prev = strzone(race_status_name);
3983 pos_x += mySize_x/2;
3986 a = bound(0, race_status_time - time, 1);
3989 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
3993 rank = race_CheckName(race_status_name);
3995 rankname = race_PlaceName(rank);
3998 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4000 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4002 if(race_status == 0)
4003 drawpic_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4004 else if(race_status == 1) {
4005 drawpic_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4006 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4007 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4008 } else if(race_status == 2) {
4009 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4010 drawpic_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4012 drawpic_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4013 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4014 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4015 } else if(race_status == 3) {
4016 drawpic_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4017 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4018 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4021 if (race_status_time - time <= 0) {
4022 race_status_prev = -1;
4024 if(race_status_name)
4025 strunzone(race_status_name);
4026 race_status_name = string_null;
4027 if(race_status_name_prev)
4028 strunzone(race_status_name_prev);
4029 race_status_name_prev = string_null;
4031 drawfont = hud_font;
4034 float mod_prev; // previous state of mod_active to check for a change
4036 float mod_change; // "time" when mod_active changed
4038 void HUD_ModIcons(void)
4040 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !hud_configure)
4043 float id = HUD_PANEL_MODICONS;
4045 pos = HUD_Panel_GetPos(id);
4046 mySize = HUD_Panel_GetSize(id);
4048 if(mod_active != mod_prev) {
4050 mod_prev = mod_active;
4053 if(mod_active || hud_configure)
4054 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4056 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4059 HUD_Panel_DrawBg(id, pos, mySize, mod_alpha);
4062 padding = HUD_Panel_GetPadding(id);
4065 pos += '1 1 0' * padding;
4066 mySize -= '2 2 0' * padding;
4069 // these MUST be ran in order to update mod_active
4070 if(gametype == GAME_KEYHUNT)
4071 HUD_Mod_KH(pos, mySize);
4072 else if(gametype == GAME_CTF || hud_configure)
4073 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4074 else if(gametype == GAME_NEXBALL)
4075 HUD_Mod_NexBall(pos, mySize);
4076 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4077 HUD_Mod_Race(pos, mySize);
4080 // Draw pressed keys (#11)
4082 void HUD_DrawPressedKeys(void)
4084 float id = HUD_PANEL_PRESSEDKEYS;
4086 pos = HUD_Panel_GetPos(id);
4087 mySize = HUD_Panel_GetSize(id);
4089 HUD_Panel_DrawBg(id, pos, mySize, 0);
4091 padding = HUD_Panel_GetPadding(id);
4094 pos += '1 1 0' * padding;
4095 mySize -= '2 2 0' * padding;
4100 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4101 drawpic_skin(pos, "key_bg.tga", mySize, '1 1 1', 0.1 * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4102 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);
4103 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);
4104 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);
4105 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);
4106 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);
4107 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);
4110 // Handle chat as a panel (#12)
4114 float id = HUD_PANEL_CHAT;
4116 pos = HUD_Panel_GetPos(id);
4117 mySize = HUD_Panel_GetSize(id);
4119 HUD_Panel_DrawBg(id, pos, mySize, 0);
4121 padding = HUD_Panel_GetPadding(id);
4124 pos += '1 1 0' * padding;
4125 mySize -= '2 2 0' * padding;
4128 cvar_set("con_chatrect", "1");
4130 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4131 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4133 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4134 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4139 chatsize = cvar("con_chatsize");
4140 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4142 for(i = 0; i < cvar("con_chat"); ++i)
4144 if(i == cvar("con_chat") - 1)
4145 a = HUD_Panel_GetFgAlpha(id);
4147 a = HUD_Panel_GetFgAlpha(id) * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4148 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);
4153 // Engine info panel (#13)
4160 float frametimeavg1; // 1 frame ago
4161 float frametimeavg2; // 2 frames ago
4162 void HUD_EngineInfo(void)
4164 float id = HUD_PANEL_ENGINEINFO;
4166 pos = HUD_Panel_GetPos(id);
4167 mySize = HUD_Panel_GetSize(id);
4169 HUD_Panel_DrawBg(id, pos, mySize, 0);
4171 padding = HUD_Panel_GetPadding(id);
4174 pos += '1 1 0' * padding;
4175 mySize -= '2 2 0' * padding;
4178 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4180 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4181 frametimeavg2 = frametimeavg1;
4182 frametimeavg1 = frametimeavg;
4185 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4186 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.
4188 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
4189 prevfps = (1/frametime);
4190 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"
4196 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4198 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4200 prevfps_time = time;
4205 color = HUD_Get_Num_Color (prevfps, 100);
4206 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);
4214 void HUD_ShowSpeed(void)
4217 float pos, conversion_factor;
4218 string speed, zspeed, unit;
4220 switch(cvar("cl_showspeed_unit"))
4225 conversion_factor = 1.0;
4229 conversion_factor = 1.0;
4233 conversion_factor = 0.0254;
4237 conversion_factor = 0.0254 * 3.6;
4241 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4245 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4249 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4251 numsize_x = numsize_y = cvar("cl_showspeed_size");
4252 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4254 drawfont = hud_bigfont;
4255 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4257 if (cvar("cl_showspeed_z") == 1) {
4258 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4259 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4262 drawfont = hud_font;
4265 vector acc_prevspeed;
4269 void HUD_ShowAcceleration(void)
4271 float acceleration, sz, scale, alpha, f;
4272 vector pos, top, rgb;
4273 top_x = vid_conwidth/2;
4276 f = time - acc_prevtime;
4277 if(cvar("cl_showacceleration_z"))
4278 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4280 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4281 acc_prevspeed = pmove_vel;
4282 acc_prevtime = time;
4284 f = bound(0, f * 10, 1);
4285 acc_avg = acc_avg * (1 - f) + acceleration * f;
4286 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4288 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4290 sz = cvar("cl_showacceleration_size");
4291 scale = cvar("cl_showacceleration_scale");
4292 alpha = cvar("cl_showacceleration_alpha");
4293 if (cvar("cl_showacceleration_color_custom"))
4294 rgb = stov(cvar_string("cl_showacceleration_color"));
4297 if (acceleration < 0) {
4298 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4299 } else if (acceleration > 0) {
4300 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4304 if (acceleration > 0)
4305 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4306 else if (acceleration < 0)
4307 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4310 void HUD_Reset (void)
4312 // reset gametype specific icons
4313 if(gametype == GAME_KEYHUNT)
4315 else if(gametype == GAME_CTF)
4316 HUD_Mod_CTF_Reset();
4319 void HUD_Main (void)
4321 if(disable_menu_alphacheck == 1)
4322 menu_fade_alpha = 1;
4324 menu_fade_alpha = (1 - cvar("_menu_alpha"));
4325 hud_fg_alpha = cvar("hud_fg_alpha");
4327 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4328 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4329 hud_color_bg_team = cvar("hud_color_bg_team");
4331 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4332 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4334 hud_configure = cvar("_hud_configure");
4338 // HUD configure visible grid
4339 if(hud_configure && cvar("hud_configure_grid") && cvar("hud_configure_grid_alpha"))
4343 for(i = 0; i < vid_conwidth/max(2, cvar("hud_configure_grid_x")); ++i)
4345 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);
4348 for(i = 0; i < vid_conheight/max(2, cvar("hud_configure_grid_y")); ++i)
4350 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);
4354 if(cvar_string("hud_dock") != "")
4355 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);
4357 if(HUD_Panel_CheckActive(HUD_PANEL_WEAPONICONS) || hud_configure)
4359 if(HUD_Panel_CheckActive(HUD_PANEL_INVENTORY) || hud_configure)
4361 if(HUD_Panel_CheckActive(HUD_PANEL_POWERUPS) || hud_configure)
4363 if(HUD_Panel_CheckActive(HUD_PANEL_HEALTHARMOR) || hud_configure)
4365 if(HUD_Panel_CheckActive(HUD_PANEL_NOTIFY) || hud_configure)
4367 if(HUD_Panel_CheckActive(HUD_PANEL_TIMER) || hud_configure)
4370 if(HUD_Panel_CheckActive(HUD_PANEL_RADAR) || hud_configure)
4371 if(cvar_string("hud_radar") != "0" && (cvar("hud_radar") == 2 || teamplay))
4373 if(HUD_Panel_CheckActive(HUD_PANEL_SCORE) || hud_configure)
4375 if(HUD_Panel_CheckActive(HUD_PANEL_RACETIMER) || hud_configure)
4376 if(gametype == GAME_RACE || gametype == GAME_CTS || hud_configure)
4378 if(HUD_Panel_CheckActive(HUD_PANEL_VOTE) || hud_configure)
4380 if(HUD_Panel_CheckActive(HUD_PANEL_MODICONS) || hud_configure)
4383 if(HUD_Panel_CheckActive(HUD_PANEL_PRESSEDKEYS) || hud_configure)
4384 if(spectatee_status > 0 || cvar("hud_pressedkeys") >= 2 || hud_configure)
4385 HUD_DrawPressedKeys();
4386 if(HUD_Panel_CheckActive(HUD_PANEL_CHAT) || hud_configure)
4389 cvar_set("con_csqcpositioning", "0");
4390 if(HUD_Panel_CheckActive(HUD_PANEL_ENGINEINFO) || hud_configure)
4393 // TODO hud_'ify these
4394 if (cvar("cl_showspeed"))
4396 if (cvar("cl_showacceleration"))
4397 HUD_ShowAcceleration();
4399 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)
4400 localcmd("cmd selectteam auto; cmd join\n");
4402 if (!hud_configure) // hud config mode disabled, enable normal alpha stuff again
4403 disable_menu_alphacheck = 0;