7 // a border picture is a texture containing nine parts:
8 // 1/4 width: left part
9 // 1/2 width: middle part (stretched)
10 // 1/4 width: right part
12 // 1/4 height: top part
13 // 1/2 height: middle part (stretched)
14 // 1/4 height: bottom part
15 void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize)
20 //pic = draw_UseSkinFor(pic);
21 width = eX * theSize_x;
22 height = eY * theSize_y;
23 if(theSize_x <= theBorderSize_x * 2)
25 // not wide enough... draw just left and right then
26 bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
27 if(theSize_y <= theBorderSize_y * 2)
29 // not high enough... draw just corners
30 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
31 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
32 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
33 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
34 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
38 dY = theBorderSize_x * eY;
39 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
40 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
41 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
42 drawsubpic(theOrigin + width * 0.5 + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0' + eX - bW, '0 0.5 0' + bW, theColor, theAlpha, 0);
43 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
44 drawsubpic(theOrigin + width * 0.5 + height - dY, width * 0.5 + dY, pic, '0 0.75 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
49 if(theSize_y <= theBorderSize_y * 2)
51 // not high enough... draw just top and bottom then
52 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
53 dX = theBorderSize_x * eX;
54 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
55 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
56 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
57 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
58 drawsubpic(theOrigin + dX + height * 0.5, width - 2 * dX + height * 0.5, pic, '0.25 0 0' + eY - bH, '0.5 0 0' + bH, theColor, theAlpha, 0);
59 drawsubpic(theOrigin + width - dX + height * 0.5, dX + height * 0.5, pic, '0.75 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
63 dX = theBorderSize_x * eX;
64 dY = theBorderSize_x * eY;
65 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
66 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
67 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
68 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
69 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
70 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
71 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
72 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
73 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
78 // drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
79 void drawpic_aspect(vector pos, string pic, vector sz, vector color, float alpha, float drawflag) {
81 imgsize = drawgetimagesize(pic);
83 imgaspect = imgsize_x/imgsize_y;
90 if(aspect > imgaspect) {
91 sz_x = sz_y * imgaspect;
92 drawpic(pos + eX * (oldsz_x - sz_x) * 0.5, pic, sz, color, alpha, drawflag);
94 sz_y = sz_x / imgaspect;
95 drawpic(pos + eY * (oldsz_y - sz_y) * 0.5, pic, sz, color, alpha, drawflag);
99 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
100 void drawpic_skin(vector pos, string pic, vector sz, vector color, float alpha, float drawflag) {
101 drawpic_aspect(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, color, alpha, drawflag);
105 void drawpic_skin_expanding(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
106 drawpic_expanding(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
109 void drawpic_skin_expanding_two(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
110 drawpic_expanding_two(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
113 // return HUD background color
114 vector HUD_GetBgColor()
118 GetTeamRGB(myteam) * hud_color_bg_team;
120 // allow custom HUD colors in non-teamgames
121 color_x = cvar("hud_color_bg_r");
122 color_y = cvar("hud_color_bg_g");
123 color_z = cvar("hud_color_bg_b");
128 // return accuracy text color
129 vector HUD_AccuracyColor(float accuracy)
132 float yellow_accuracy = cvar("hud_weaponicons_accuracy_yellow"); // value at which this function returns yellow
133 if(accuracy >= 100) {
137 else if(accuracy > yellow_accuracy) {
138 rgb_x = 1 - (accuracy-yellow_accuracy)/(100-yellow_accuracy); // red value between 1 -> 0
143 rgb_y = accuracy/yellow_accuracy; // green value between 0 -> 1
149 vector HUD_Get_Num_Color (float x, float maxvalue)
157 else if(x > maxvalue * 0.75) {
158 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
159 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
162 else if(x > maxvalue * 0.5) {
163 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
164 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
165 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
167 else if(x > maxvalue * 0.25) {
170 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
172 else if(x > maxvalue * 0.1) {
174 color_y = (x-20)*90/27/100; // green value between 0 -> 1
175 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
185 float stringwidth_colors(string s, vector theSize)
187 return stringwidth(s, TRUE, theSize);
190 float stringwidth_nocolors(string s, vector theSize)
192 return stringwidth(s, FALSE, theSize);
195 #define CENTERPRINT_MAX_LINES 30
196 string centerprint_messages[CENTERPRINT_MAX_LINES];
197 float centerprint_width[CENTERPRINT_MAX_LINES];
198 vector centerprint_start;
199 float centerprint_expire;
200 float centerprint_num;
201 float centerprint_offset_hint;
202 vector centerprint_fontsize;
204 void centerprint(string strMessage)
206 float i, j, n, hcount;
209 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
211 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
213 if(cvar("scr_centertime") <= 0)
219 // strip trailing newlines
220 j = strlen(strMessage) - 1;
221 while(substring(strMessage, j, 1) == "\n" && j >= 0)
223 strMessage = substring(strMessage, 0, j + 1);
228 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
230 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
232 strMessage = substring(strMessage, j, strlen(strMessage) - j);
233 centerprint_offset_hint = j;
238 // if we get here, we have a message. Initialize its height.
241 n = tokenizebyseparator(strMessage, "\n");
243 for(j = 0; j < n; ++j)
245 getWrappedLine_remaining = argv(j);
246 while(getWrappedLine_remaining)
248 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
249 if(centerprint_messages[i])
250 strunzone(centerprint_messages[i]);
251 centerprint_messages[i] = strzone(s);
252 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
255 // half height for empty lines looks better
261 if(i >= CENTERPRINT_MAX_LINES)
267 h = centerprint_fontsize_y*hcount;
269 havail = vid_conheight;
270 if(cvar("con_chatpos") < 0)
271 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
272 if(havail > vid_conheight - 70)
273 havail = vid_conheight - 70; // avoid overlapping HUD
275 centerprint_start_x = 0;
278 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
280 // here, the centerprint would cover the crosshair. REALLY BAD.
281 forbiddenmin = vid_conheight * 0.5 - h - 16;
282 forbiddenmax = vid_conheight * 0.5 + 16;
284 allowedmin = scoreboard_bottom;
285 allowedmax = havail - h;
286 preferred = (havail - h)/2;
289 // possible orderings (total: 4! / 4 = 6)
290 // allowedmin allowedmax forbiddenmin forbiddenmax
291 // forbiddenmin forbiddenmax allowedmin allowedmax
292 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
294 // forbidden doesn't matter in this case
295 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
297 // allowedmin forbiddenmin allowedmax forbiddenmax
298 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
300 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
302 // allowedmin forbiddenmin forbiddenmax allowedmax
303 else if(allowedmin < forbiddenmin)
305 // make sure the forbidden zone is not covered
306 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
307 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
309 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
311 // forbiddenmin allowedmin allowedmax forbiddenmax
312 else if(allowedmax < forbiddenmax)
314 // it's better to leave the allowed zone (overlap with scoreboard) than
315 // to cover the forbidden zone (crosshair)
316 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
317 centerprint_start_y = forbiddenmax;
319 centerprint_start_y = forbiddenmin;
321 // forbiddenmin allowedmin forbiddenmax allowedmax
324 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
327 centerprint_start_y =
330 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
338 centerprint_expire = time + cvar("scr_centertime");
341 void HUD_DrawCenterPrint (void)
348 //if(time > centerprint_expire)
351 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
352 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
353 //sz = 1.2 / (a + 0.2);
358 pos = centerprint_start;
359 for (i=0; i<centerprint_num; i = i + 1)
361 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
362 ts = centerprint_messages[i];
365 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
366 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
367 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
368 pos_y = pos_y + centerprint_fontsize_y;
371 // half height for empty lines looks better
372 pos_y = pos_y + centerprint_fontsize_y * 0.5;
376 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
378 position_x -= 2 / 3 * strlen(text) * scale_x;
379 drawstring(position, text, scale, rgb, alpha, flag);
382 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
384 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
385 drawstring(position, text, scale, rgb, alpha, flag);
388 // return the string of the given race place
389 string race_PlaceName(float pos) {
397 return strcat(ftos(pos), "th");
400 // return the string of the onscreen race timer
401 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
409 if(histime == 0) // goal hit
413 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
423 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
429 lapstr = strcat(" (-", ftos(lapdelta), "L)");
432 else if(lapdelta < 0)
434 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
438 else if(histime > 0) // anticipation
440 if(mytime >= histime)
441 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
443 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
450 cpname = "Start line";
452 cpname = "Finish line";
454 cpname = strcat("Intermediate ", ftos(cp));
456 cpname = "Finish line";
459 return strcat(col, cpname);
460 else if(hisname == "")
461 return strcat(col, cpname, " (", timestr, ")");
463 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
466 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
467 float race_CheckName(string net_name) {
469 for (i=RANKINGS_CNT-1;i>=0;--i)
470 if(grecordholder[i] == net_name)
482 void HUD_Panel_ExportCfg(string cfgname)
485 fh = fopen(strcat("hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg"), FILE_WRITE);
488 fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
489 fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
490 fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
491 fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
492 fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
493 fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
494 fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
495 fputs(fh, strcat("seta hud_fg_alpha \"", cvar_string("hud_fg_alpha"), "\"", "\n"));
498 fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
499 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
500 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
501 fputs(fh, strcat("seta hud_dock_alpha \"", ftos(cvar("hud_dock_alpha")), "\"", "\n"));
504 fputs(fh, strcat("seta hud_progressbar_alpha ", ftos(cvar("hud_progressbar_alpha")), "\n"));
505 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
506 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
507 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
508 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
509 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
510 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
513 // common cvars for all panels
515 for (i = 0; i < HUD_PANEL_NUM; ++i)
517 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), " ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i)))), "\n"));
518 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_pos \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_pos")), "\"", "\n"));
519 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_size \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_size")), "\"", "\n"));
520 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg")), "\"", "\n"));
521 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color")), "\"", "\n"));
522 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color_team \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color_team")), "\"", "\n"));
523 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_alpha \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_alpha")), "\"", "\n"));
524 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_border \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_border")), "\"", "\n"));
525 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_padding \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_padding")), "\"", "\n"));
528 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_accuracy_yellow ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_accuracy_yellow"))), "\n"));
531 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_onlycurrent ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_onlycurrent"))), "\n"));
534 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
535 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_mirror ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
538 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
539 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_mirror ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
542 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
543 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_info_top ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_info_top"))), "\n"));
546 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_foreground_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_foreground_alpha"))), "\n"));
548 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha"))), "\n"));
554 print("^2Successfully exported to hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
559 // return active status of panel
560 float HUD_Panel_CheckActive(float id)
562 if (cvar_or(strcat("hud_", HUD_Panel_GetName(id)), 1))
567 // return size of given panel
568 vector HUD_Panel_GetSize(float id)
571 mySize = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_size")));
573 mySize = eX * mySize_x * vid_conwidth + eY * mySize_y * vid_conheight;
575 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
577 vector menu_enable_maxsize, menu_enable_size;
578 menu_enable_maxsize = '0 0 0'; // shut up FTEQCC
579 menu_enable_maxsize_x = 0.3 * vid_conwidth;
580 menu_enable_maxsize_y = 0.18 * vid_conheight;
581 if(mySize_x > mySize_y)
583 if(mySize_y > menu_enable_maxsize_y)
585 menu_enable_size_y = menu_enable_maxsize_y;
586 menu_enable_size_x = mySize_x * (menu_enable_maxsize_y/mySize_y);
587 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
592 if(mySize_x > menu_enable_maxsize_x)
594 menu_enable_size_x = menu_enable_maxsize_x;
595 menu_enable_size_y = mySize_y * (menu_enable_maxsize_x/mySize_x);
596 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
603 // return pos of given panel
604 vector HUD_Panel_GetPos(float id)
607 pos = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_pos")));
609 pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
611 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
613 vector mySize, menu_enable_panelpos;
614 mySize = HUD_Panel_GetSize(id);
615 if(mySize_x > mySize_y)
616 menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * mySize_x + eY * 0.82 * vid_conheight;
618 menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * mySize_y + eX * 0.7 * vid_conwidth;
619 pos = (1 - cvar("_menu_alpha")) * pos + (cvar("_menu_alpha")) * menu_enable_panelpos;
624 float HUD_Panel_GetBorder(float id)
627 border = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_border"));
629 border = cvar_string("hud_bg_border");
633 vector HUD_Panel_GetColor(float id)
639 // fetch per-panel color
640 if(teamplay && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")) != "") {
641 f = stof(getplayerkey(self.sv_entnum, "colors"));
642 color = vtos(colormapPaletteColor(mod(f, 16), 1) * cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")));
645 color = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color"));
646 color_vec = stov(color);
648 if(color == "") { // fetch default color
649 color = cvar_string("hud_bg_color");
650 color_vec = stov(color);
651 if(teamplay && cvar(strcat("hud_bg_color_team"))) {
652 f = stof(getplayerkey(self.sv_entnum, "colors"));
653 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_bg_color_team");
655 else if(color == "shirt") {
656 f = stof(getplayerkey(self.sv_entnum, "colors"));
657 color_vec = colormapPaletteColor(floor(f / 16), 0);
659 else if(color == "pants") {
660 f = stof(getplayerkey(self.sv_entnum, "colors"));
661 color_vec = colormapPaletteColor(mod(f, 16), 1);
664 else if(color == "shirt") {
665 f = stof(getplayerkey(self.sv_entnum, "colors"));
666 color_vec = colormapPaletteColor(floor(f / 16), 0);
668 else if(color == "pants") {
669 f = stof(getplayerkey(self.sv_entnum, "colors"));
670 color_vec = colormapPaletteColor(mod(f, 16), 1);
675 vector HUD_Panel_Dock_GetColor(void)
680 color = cvar_string("hud_dock_color");
681 color_vec = stov(color);
682 if(teamplay && cvar(strcat("hud_dock_color_team"))) {
683 f = stof(getplayerkey(self.sv_entnum, "colors"));
684 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_dock_color_team");
686 else if(color == "shirt") {
687 f = stof(getplayerkey(self.sv_entnum, "colors"));
688 color_vec = colormapPaletteColor(floor(f / 16), 0);
690 else if(color == "pants") {
691 f = stof(getplayerkey(self.sv_entnum, "colors"));
692 color_vec = colormapPaletteColor(mod(f, 16), 1);
697 float HUD_Panel_GetBgAlpha(float id)
700 alpha = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_alpha"));
702 alpha = cvar_string("hud_bg_alpha");
704 if(hud_configure && disable_menu_alphacheck == 2 && highlightedPanel == id) // do not set a minalpha cap when showing the config dialog for this panel
705 alpha = ftos((1 - cvar("_menu_alpha")) * max(cvar("hud_configure_bg_minalpha"), stof(alpha)) + (cvar("_menu_alpha")) * stof(alpha));
706 else if(hud_configure)
707 alpha = ftos(max(cvar("hud_configure_bg_minalpha"), stof(alpha)));
709 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
712 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
715 return stof(alpha) * menu_fade_alpha;
718 float HUD_Panel_GetFgAlpha(float id)
721 alpha = hud_fg_alpha;
723 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
726 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
729 return alpha * menu_fade_alpha;
732 float HUD_Panel_GetPadding(float id)
735 padding = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
737 padding = cvar_string("hud_bg_padding");
740 mySize = HUD_Panel_GetSize(id);
742 smallestsize = min(mySize_x, mySize_y);
743 return min(smallestsize/2 - 5, stof(padding));
746 // draw the background/borders
747 void HUD_Panel_DrawBg(float id, vector pos, vector mySize, float alpha)
749 if(!hud_configure && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg")) == "0")
753 bg = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg"));
755 bg = cvar_string("hud_bg");
757 if(bg == "0" && hud_configure) {
758 bg = "border"; // we probably want to see a background in config mode at all times...
764 border = max(0.0000001, HUD_Panel_GetBorder(id)); // draw_BorderPicture does not like border = 0
767 color = HUD_Panel_GetColor(id);
770 alpha = HUD_Panel_GetBgAlpha(id) * alpha; // allow panels to fade in/out by passing an alpha value
772 alpha = HUD_Panel_GetBgAlpha(id);
774 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));
778 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
784 pic = strcat("gfx/hud/", cvar_string("hud_skin"), "/");
786 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);
787 if(mySize_y/mySize_x > 2)
788 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);
789 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);
791 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);
792 if(mySize_x/mySize_y > 2)
793 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);
794 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);
798 vector HUD_Panel_GetProgressBarColor(string item)
800 return stov(cvar_string(strcat("hud_progressbar_", item, "_color")));
803 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
804 vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
815 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
816 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
818 for (i = 0; i < HUD_PANEL_NUM; ++i) {
819 if(i == id || !HUD_Panel_CheckActive(i))
822 targPos = HUD_Panel_GetPos(i) - '1 1 0' * HUD_Panel_GetBorder(id);
823 targSize = HUD_Panel_GetSize(i) + '2 2 0' * HUD_Panel_GetBorder(id);
825 if(myPos_y + mySize_y < targPos_y)
827 if(myPos_y > targPos_y + targSize_y)
830 if(myPos_x + mySize_x < targPos_x)
832 if(myPos_x > targPos_x + targSize_x)
835 // OK, there IS a collision.
837 myCenter_x = myPos_x + 0.5 * mySize_x;
838 myCenter_y = myPos_y + 0.5 * mySize_y;
840 targCenter_x = targPos_x + 0.5 * targSize_x;
841 targCenter_y = targPos_y + 0.5 * targSize_y;
843 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
845 if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
846 myTarget_x = targPos_x - mySize_x;
847 else // push it upwards
848 myTarget_y = targPos_y - mySize_y;
850 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
852 if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
853 myTarget_x = targPos_x + targSize_x;
854 else // push it upwards
855 myTarget_y = targPos_y - mySize_y;
857 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
859 if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
860 myTarget_x = targPos_x - mySize_x;
861 else // push it downwards
862 myTarget_y = targPos_y + targSize_y;
864 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
866 if(targPos_x + targSize_x - myPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
867 myTarget_x = targPos_x + targSize_x;
868 else // push it downwards
869 myTarget_y = targPos_y + targSize_y;
876 void HUD_Panel_SetPos(float id, vector pos)
879 oldPos = HUD_Panel_GetPos(id);
882 mySize = HUD_Panel_GetSize(id);
884 if(cvar("hud_configure_checkcollisions"))
885 pos = HUD_Panel_CheckMove(id, pos, mySize);
887 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
888 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
890 if(cvar("hud_configure_grid"))
892 pos_x = floor((pos_x/vid_conwidth)/bound(0.005, cvar("hud_configure_grid_x"), 0.2) + 0.5) * bound(0.005, cvar("hud_configure_grid_x"), 0.2) * vid_conwidth;
893 pos_y = floor((pos_y/vid_conheight)/bound(0.005, cvar("hud_configure_grid_y"), 0.2) + 0.5) * bound(0.005, cvar("hud_configure_grid_y"), 0.2) * vid_conheight;
897 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
899 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
902 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
903 vector HUD_Panel_CheckResize(float id, vector mySize, vector resizeorigin) {
912 for (i = 0; i < HUD_PANEL_NUM; ++i) {
913 if(i == id || !HUD_Panel_CheckActive(i))
916 targBorder = HUD_Panel_GetBorder(i);
917 targPos = HUD_Panel_GetPos(i) - '1 1 0' * targBorder;
918 targSize = HUD_Panel_GetSize(i) + '2 2 0' * targBorder;
919 targEndPos = targPos + targSize;
921 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
922 if(resizeorigin_x > targPos_x && resizeorigin_x < targPos_x + targSize_x && resizeorigin_y > targPos_y && resizeorigin_y < targPos_y + targSize_y)
925 if (resizeCorner == 1)
927 // check if this panel is on our way
928 if (resizeorigin_x <= targPos_x)
930 if (resizeorigin_y <= targPos_y)
932 if (targEndPos_x <= resizeorigin_x - mySize_x)
934 if (targEndPos_y <= resizeorigin_y - mySize_y)
937 // there is a collision:
938 // detect which side of the panel we are facing is actually limiting the resizing
939 // (which side the resize direction finds for first) and reduce the size up to there
941 // dist is the distance between resizeorigin and the "analogous" point of the panel
942 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
943 dist_x = resizeorigin_x - targEndPos_x;
944 dist_y = resizeorigin_y - targEndPos_y;
946 mySize_x = min(mySize_x, dist_x);
948 mySize_y = min(mySize_y, dist_y);
950 else if (resizeCorner == 2)
952 if (resizeorigin_x >= targEndPos_x)
954 if (resizeorigin_y <= targPos_y)
956 if (targPos_x >= resizeorigin_x + mySize_x)
958 if (targEndPos_y <= resizeorigin_y - mySize_y)
961 dist_x = targPos_x - resizeorigin_x;
962 dist_y = resizeorigin_y - targEndPos_y;
964 mySize_x = min(mySize_x, dist_x);
966 mySize_y = min(mySize_y, dist_y);
968 else if (resizeCorner == 3)
970 if (resizeorigin_x <= targPos_x)
972 if (resizeorigin_y >= targEndPos_y)
974 if (targEndPos_x <= resizeorigin_x - mySize_x)
976 if (targPos_y >= resizeorigin_y + mySize_y)
979 dist_x = resizeorigin_x - targEndPos_x;
980 dist_y = targPos_y - resizeorigin_y;
982 mySize_x = min(mySize_x, dist_x);
984 mySize_y = min(mySize_y, dist_y);
986 else if (resizeCorner == 4)
988 if (resizeorigin_x >= targEndPos_x)
990 if (resizeorigin_y >= targEndPos_y)
992 if (targPos_x >= resizeorigin_x + mySize_x)
994 if (targPos_y >= resizeorigin_y + mySize_y)
997 dist_x = targPos_x - resizeorigin_x;
998 dist_y = targPos_y - resizeorigin_y;
1000 mySize_x = min(mySize_x, dist_x);
1002 mySize_y = min(mySize_y, dist_y);
1004 if(cvar("hud_configure_checkcollisions_debug"))
1005 drawfill(targPos + '1 1 0' * targBorder, targSize - '2 2 0' * targBorder, '1 1 0', .3, DRAWFLAG_NORMAL);
1011 void HUD_Panel_SetPosSize(float id)
1013 vector resizeorigin;
1014 resizeorigin = panel_click_resizeorigin;
1015 vector mySize, myPos;
1017 if(resizeCorner == 1) {
1018 mySize_x = resizeorigin_x - (mousepos_x - panel_click_distance_x);
1019 mySize_y = resizeorigin_y - (mousepos_y - panel_click_distance_y);
1020 } else if(resizeCorner == 2) {
1021 mySize_x = mousepos_x + panel_click_distance_x - resizeorigin_x;
1022 mySize_y = panel_click_distance_y + resizeorigin_y - mousepos_y;
1023 } else if(resizeCorner == 3) {
1024 mySize_x = resizeorigin_x + panel_click_distance_x - mousepos_x;
1025 mySize_y = mousepos_y + panel_click_distance_y - resizeorigin_y;
1026 } else { // resizeCorner == 4
1027 mySize_x = mousepos_x - (resizeorigin_x - panel_click_distance_x);
1028 mySize_y = mousepos_y - (resizeorigin_y - panel_click_distance_y);
1031 // minimum panel size cap
1032 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1033 mySize_y = max(0.025 * vid_conheight, mySize_y);
1035 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.
1037 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
1038 mySize_y = max(2 * cvar("con_chatsize") + 2 * HUD_Panel_GetPadding(id), mySize_y);
1041 // collision testing|
1042 // -----------------+
1044 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
1045 if(resizeCorner == 1) {
1046 myPos_x = resizeorigin_x - mySize_x;
1047 myPos_y = resizeorigin_y - mySize_y;
1048 } else if(resizeCorner == 2) {
1049 myPos_x = resizeorigin_x;
1050 myPos_y = resizeorigin_y - mySize_y;
1051 } else if(resizeCorner == 3) {
1052 myPos_x = resizeorigin_x - mySize_x;
1053 myPos_y = resizeorigin_y;
1054 } else { // resizeCorner == 4
1055 myPos_x = resizeorigin_x;
1056 myPos_y = resizeorigin_y;
1059 // left/top screen edges
1061 mySize_x = mySize_x + myPos_x;
1063 mySize_y = mySize_y + myPos_y;
1065 // bottom/right screen edges
1066 if(myPos_x + mySize_x > vid_conwidth)
1067 mySize_x = vid_conwidth - myPos_x;
1068 if(myPos_y + mySize_y > vid_conheight)
1069 mySize_y = vid_conheight - myPos_y;
1071 if(cvar("hud_configure_checkcollisions_debug"))
1072 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
1074 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
1075 if(cvar("hud_configure_grid"))
1077 mySize_x = floor((mySize_x/vid_conwidth)/bound(0.005, cvar("hud_configure_grid_x"), 0.2) + 0.5) * bound(0.005, cvar("hud_configure_grid_x"), 0.2) * vid_conwidth;
1078 mySize_y = floor((mySize_y/vid_conheight)/bound(0.005, cvar("hud_configure_grid_y"), 0.2) + 0.5) * bound(0.005, cvar("hud_configure_grid_y"), 0.2) * vid_conheight;
1081 if(cvar("hud_configure_checkcollisions"))
1083 mySize = HUD_Panel_CheckResize(id, mySize, resizeorigin);
1086 // minimum panel size cap, do this once more so we NEVER EVER EVER have a panel smaller than this, JUST IN CASE above code still makes the panel eg negative (impossible to resize back without changing cvars manually then)
1087 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1088 mySize_y = max(0.025 * vid_conheight, mySize_y);
1090 // do another pos check, as size might have changed by now
1091 if(resizeCorner == 1) {
1092 myPos_x = resizeorigin_x - mySize_x;
1093 myPos_y = resizeorigin_y - mySize_y;
1094 } else if(resizeCorner == 2) {
1095 myPos_x = resizeorigin_x;
1096 myPos_y = resizeorigin_y - mySize_y;
1097 } else if(resizeCorner == 3) {
1098 myPos_x = resizeorigin_x - mySize_x;
1099 myPos_y = resizeorigin_y;
1100 } else { // resizeCorner == 4
1101 myPos_x = resizeorigin_x;
1102 myPos_y = resizeorigin_y;
1105 if(cvar("hud_configure_checkcollisions_debug"))
1106 if(cvar("hud_configure_checkcollisions"))
1107 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
1110 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
1111 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_size"), s);
1113 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
1114 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
1118 float prevMouseClicked; // previous state
1119 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
1120 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
1123 float menu_enabled_time;
1124 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1129 // allow console bind to work
1132 con_keys = findkeysforcommand("toggleconsole");
1133 keys = tokenize(con_keys);
1135 float hit_con_bind, i;
1136 for (i = 0; i < keys; ++i)
1138 if(nPrimary == stof(argv(i)))
1142 if(nPrimary == K_MOUSE1)
1144 if(bInputType == 0) { // key pressed
1148 else if(bInputType == 1) {// key released
1153 else if(nPrimary == K_ESCAPE)
1155 disable_menu_alphacheck = 1;
1157 menu_enabled_time = time;
1158 localcmd("menu_showhudexit\n");
1161 else if(hit_con_bind)
1164 return true; // Suppress ALL other input
1167 void HUD_Panel_Mouse()
1169 // 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
1170 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1171 disable_menu_alphacheck = 0;
1172 if (cvar("_menu_alpha") == 0 && time - menu_enabled_time > 0.5)
1176 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1177 print("Highlighted: ", ftos(highlightedPanel), "\n");
1178 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1181 if(mouseClicked == 0 && disable_menu_alphacheck != 2) { // don't reset these variables in disable_menu_alphacheck mode 2!
1182 highlightedPanel = -1;
1183 highlightedAction = 0;
1186 mousepos = mousepos + getmousepos();
1188 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1189 mousepos_y = bound(0, mousepos_y, vid_conheight);
1191 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1199 for(i = 0; i < HUD_PANEL_NUM; ++i)
1201 panelPos = HUD_Panel_GetPos(i);
1202 panelSize = HUD_Panel_GetSize(i);
1203 border = HUD_Panel_GetBorder(i);
1204 if(prevMouseClicked == 0) {
1206 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1208 highlightedPanel = i;
1209 highlightedAction = 1;
1211 // resize from topleft border
1212 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)
1214 highlightedPanel = i;
1215 highlightedAction = 2;
1218 // resize from topright border
1219 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)
1221 highlightedPanel = i;
1222 highlightedAction = 2;
1225 // resize from bottomleft border
1226 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)
1228 highlightedPanel = i;
1229 highlightedAction = 2;
1232 // resize from bottomright border
1233 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)
1235 highlightedPanel = i;
1236 highlightedAction = 2;
1241 if(highlightedPanel == i)
1243 if(prevMouseClicked == 0)
1245 if(highlightedAction == 1)
1246 panel_click_distance = mousepos - panelPos;
1247 else if(highlightedAction == 2)
1249 if(resizeCorner == 1) {
1250 panel_click_distance = mousepos - panelPos;
1251 panel_click_resizeorigin = panelPos + panelSize;
1252 } else if(resizeCorner == 2) {
1253 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1254 panel_click_distance_y = mousepos_y - panelPos_y;
1255 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1256 } else if(resizeCorner == 3) {
1257 panel_click_distance_x = mousepos_x - panelPos_x;
1258 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1259 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1260 } else if(resizeCorner == 4) {
1261 panel_click_distance = panelSize - mousepos + panelPos;
1262 panel_click_resizeorigin = panelPos;
1267 if(cvar("hud_configure_checkcollisions_debug"))
1268 drawfill(panelPos, panelSize, '1 0 0', .3, DRAWFLAG_NORMAL);
1270 if(highlightedAction == 1)
1271 HUD_Panel_SetPos(i, mousepos - panel_click_distance);
1272 else if(highlightedAction == 2)
1273 HUD_Panel_SetPosSize(i);
1277 // doubleclick check
1278 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1280 mouseClicked = 0; // to prevent spam, I guess.
1281 disable_menu_alphacheck = 2;
1283 menu_enabled_time = time;
1284 localcmd("menu_showhudoptions ", ftos(highlightedPanel), "\n");
1287 if(prevMouseClicked == 0)
1289 prevMouseClickedTime = time;
1290 prevMouseClickedPos = mousepos;
1293 prevMouseClicked = mouseClicked;
1296 // Weapon icons (#0)
1298 float weaponspace[10];
1299 void HUD_WeaponIcons_Clear()
1302 for(idx = 0; idx < 10; ++idx)
1303 weaponspace[idx] = 0;
1306 entity weaponorder[WEP_MAXCOUNT];
1308 void weaponorder_swap(float i, float j, entity pass)
1312 weaponorder[i] = weaponorder[j];
1316 string weaponorder_cmp_str;
1317 float weaponorder_cmp(float i, float j, entity pass)
1320 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1321 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1322 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)
1325 void HUD_WeaponIcons(void)
1327 float id = HUD_PANEL_WEAPONICONS;
1328 float alpha, stat_weapons; // "constants"
1329 vector pos, mySize, accuracy_color;
1330 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1332 pos = HUD_Panel_GetPos(id);
1333 mySize = HUD_Panel_GetSize(id);
1335 stat_weapons = getstati(STAT_WEAPONS);
1336 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1338 self = get_weaponinfo(i);
1339 if(self.impulse >= 0)
1341 weaponorder[weapon_cnt] = self;
1346 // TODO make this configurable
1347 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1348 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1350 HUD_Panel_DrawBg(id, pos, mySize, 0);
1352 padding = HUD_Panel_GetPadding(id);
1355 pos += '1 1 0' * padding;
1356 mySize -= '2 2 0' * padding;
1360 weapon_stats = getstati(STAT_DAMAGE_HITS);
1361 weapon_number = weapon_stats & 63;
1362 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1364 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1365 weapon_number = weapon_stats & 63;
1366 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1368 if(cvar_or("hud_weaponicons_fade", 1))
1370 fade = 3.2 - 2 * (time - weapontime);
1371 fade = bound(0.7, fade, 1);
1376 HUD_WeaponIcons_Clear();
1378 float rows, columns;
1379 rows = mySize_y/mySize_x;
1380 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1381 // ^^^ weapon icon aspect goes here
1383 columns = ceil(WEP_COUNT/rows);
1385 for(i = 0; i < weapon_cnt; ++i)
1387 self = weaponorder[i];
1388 weapid = self.impulse;
1390 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1392 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1393 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1395 // draw background behind currently selected weapon
1396 if(self.weapon == activeweapon)
1397 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);
1399 // draw the weapon accuracy on the HUD
1400 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1403 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1405 accuracy_color = HUD_AccuracyColor(weapon_stats);
1407 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);
1410 // draw the weapon icon
1411 if((self.impulse >= 0) && (stat_weapons & self.weapons))
1413 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);
1415 if(cvar_or("hud_weaponicons_number", 1))
1416 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);
1418 // draw a "ghost weapon icon" if you don't have the weapon
1421 drawpic_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), strcat("weapon", self.netname), eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), '0 0 0', HUD_Panel_GetFgAlpha(id) * 0.5, DRAWFLAG_NORMAL);
1436 float GetAmmoStat(float i)
1440 case 0: return STAT_SHELLS;
1441 case 1: return STAT_NAILS;
1442 case 2: return STAT_ROCKETS;
1443 case 3: return STAT_CELLS;
1444 case 4: return STAT_FUEL;
1449 float GetAmmoItemCode(float i)
1453 case 0: return IT_SHELLS;
1454 case 1: return IT_NAILS;
1455 case 2: return IT_ROCKETS;
1456 case 3: return IT_CELLS;
1457 case 4: return IT_FUEL;
1462 string GetAmmoPicture(float i)
1466 case 0: return "ammo_shells";
1467 case 1: return "ammo_bullets";
1468 case 2: return "ammo_rockets";
1469 case 3: return "ammo_cells";
1470 case 4: return "ammo_fuel";
1475 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1478 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1489 if(currently_selected)
1494 vector newSize, newPos;
1495 if(mySize_x/mySize_y > 4)
1497 newSize_x = 4 * mySize_y;
1498 newSize_y = mySize_y;
1500 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1505 newSize_y = 1/4 * mySize_x;
1506 newSize_x = mySize_x;
1508 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1512 vector picpos, numpos;
1513 if(cvar("hud_inventory_mirror"))
1516 picpos = newPos + eX * 3 * newSize_y;
1520 numpos = newPos + eX * newSize_y;
1524 if (currently_selected)
1525 drawpic_skin(newPos, "ammo_current_bg", newSize, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_INVENTORY), DRAWFLAG_NORMAL);
1527 drawstring_aspect(numpos, ftos(a), eX * 0.75 * newSize_x + eY * newSize_y, newSize_y, color, HUD_Panel_GetFgAlpha(HUD_PANEL_INVENTORY) * alpha, DRAWFLAG_NORMAL);
1528 drawpic_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_INVENTORY) * alpha, DRAWFLAG_NORMAL);
1531 void HUD_Inventory(void)
1533 float id = HUD_PANEL_INVENTORY;
1534 float i, currently_selected;
1537 pos = HUD_Panel_GetPos(id);
1538 mySize = HUD_Panel_GetSize(id);
1540 HUD_Panel_DrawBg(id, pos, mySize, 0);
1542 padding = HUD_Panel_GetPadding(id);
1545 pos += '1 1 0' * padding;
1546 mySize -= '2 2 0' * padding;
1549 float rows, columns;
1550 rows = mySize_y/mySize_x;
1551 rows = bound(1, floor((sqrt(4 * (4/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1552 // ^^^ ammo item aspect goes here
1554 columns = ceil(AMMO_COUNT/rows);
1558 for (i = 0; i < AMMO_COUNT; ++i) {
1559 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1560 if(cvar("hud_inventory_onlycurrent")) {
1563 if (currently_selected || hud_configure)
1564 DrawAmmoItem(pos, mySize, i, currently_selected);
1567 DrawAmmoItem(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), i, currently_selected);
1572 column = column + 1;
1581 void HUD_Powerups(void) {
1582 float id = HUD_PANEL_POWERUPS;
1584 stat_items = getstati(STAT_ITEMS);
1588 if not(stat_items & IT_STRENGTH)
1589 if not(stat_items & IT_INVINCIBLE)
1592 if (getstati(STAT_HEALTH) <= 0)
1597 pos = HUD_Panel_GetPos(id);
1598 mySize = HUD_Panel_GetSize(id);
1600 HUD_Panel_DrawBg(id, pos, mySize, 0);
1602 padding = HUD_Panel_GetPadding(id);
1605 pos += '1 1 0' * padding;
1606 mySize -= '2 2 0' * padding;
1609 float strength_time, shield_time;
1611 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1612 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1622 vector barpos, barsize;
1626 string leftname, rightname;
1627 float leftcnt, rightcnt;
1628 float leftexact, rightexact;
1629 float leftalpha, rightalpha;
1630 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) {
1631 leftname = "strength";
1632 leftcnt = ceil(strength_time);
1633 leftexact = strength_time;
1635 rightname = "shield";
1636 rightcnt = ceil(shield_time);
1637 rightexact = shield_time;
1639 leftname = "shield";
1640 leftcnt = ceil(shield_time);
1641 leftexact = shield_time;
1643 rightname = "strength";
1644 rightcnt = ceil(strength_time);
1645 rightexact = strength_time;
1647 leftalpha = bound(0, leftexact, 1);
1648 rightalpha = bound(0, rightexact, 1);
1650 if (mySize_x/mySize_y > 4)
1654 len = strlen(ftos(leftcnt));
1656 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1657 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1658 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1659 picpos = pos + eX * 0.5 * mySize_x - eX * mySize_y;
1660 numpos = picpos - eX * 2 * 0.5 * mySize_y + eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1663 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1665 numpos = picpos + eX * mySize_y - eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1668 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1670 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));
1672 drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1673 //drawstring_aspect(numpos, ftos(leftcnt), mySize, mySize_y, timer_color, HUD_Panel_GetFgAlpha(HUD_PANEL_TIMER), DRAWFLAG_NORMAL);
1674 //HUD_DrawXNum(numpos, leftcnt, 2, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1679 len = strlen(ftos(rightcnt));
1681 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1682 barpos = pos + eX * 0.5 * mySize_x;
1683 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1684 picpos = pos + eX * 0.5 * mySize_x;
1685 numpos = picpos + eX * mySize_y - eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1687 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1688 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1689 picpos = pos + eX * mySize_x - eX * mySize_y;
1690 numpos = picpos - eX * mySize_y + eY * 0.25 * mySize_y;
1693 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1695 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));
1697 drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1698 //HUD_DrawXNum(numpos, rightcnt, 2, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1701 else if (mySize_x/mySize_y > 1.5)
1705 len = strlen(ftos(leftcnt));
1707 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1708 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1709 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1710 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y;
1711 numpos = picpos - eX * len * 0.5 * mySize_y;
1714 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1716 numpos = picpos + eX * 0.5 * mySize_y;
1719 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1721 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));
1723 drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1724 //HUD_DrawXNum(numpos, leftcnt, len, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1729 len = strlen(ftos(rightcnt));
1731 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1732 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1733 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1734 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y + eY * 0.5 * mySize_y;
1735 numpos = picpos - eX * len * 0.5 * mySize_y;
1737 barpos = pos + eY * 0.5 * mySize_y;
1738 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1739 picpos = pos + eY * 0.5 * mySize_y;
1740 numpos = picpos + eX * 0.5 * mySize_y;
1743 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1745 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));
1747 drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1748 //HUD_DrawXNum(numpos, rightcnt, len, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1755 len = strlen(ftos(leftcnt));
1757 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1759 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1760 picpos = pos + eX * 0.05 * mySize_x;
1761 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x;
1763 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1764 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1765 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.65 * mySize_x;
1766 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.25 * mySize_x;
1769 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1771 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));
1773 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1774 //HUD_DrawXNum(numpos, leftcnt, len, 0, 0.25 * mySize_x, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1779 len = strlen(ftos(rightcnt));
1781 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1782 barpos = pos + eX * 0.5 * mySize_x;
1783 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1784 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1785 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1787 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1788 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1789 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.65 * mySize_x + eX * 0.5 * mySize_x;
1790 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
1793 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1795 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));
1797 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1798 //HUD_DrawXNum(numpos, rightcnt, len, 0, 0.25 * mySize_x, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1803 // Health/armor (#3)
1805 void HUD_HealthArmor(void)
1807 float id = HUD_PANEL_HEALTHARMOR;
1809 pos = HUD_Panel_GetPos(id);
1810 mySize = HUD_Panel_GetSize(id);
1812 HUD_Panel_DrawBg(id, pos, mySize, 0);
1814 padding = HUD_Panel_GetPadding(id);
1817 pos += '1 1 0' * padding;
1818 mySize -= '2 2 0' * padding;
1821 float armor, health;
1822 armor = getstati(STAT_ARMOR);
1823 health = getstati(STAT_HEALTH);
1826 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
1839 vector barpos, barsize;
1843 if(cvar("hud_healtharmor") == 2) // combined health and armor display
1846 v = healtharmor_maxdamage(health, armor, armorblockpercent);
1851 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1852 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
1853 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
1855 numpos = picpos + eX * 1.5 * mySize_y;
1858 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
1859 picpos = pos + eX * 3 * mySize_y;
1863 if(v_z) // NOT fully armored
1865 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("health"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1866 drawpic_skin(picpos, "health", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1868 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);
1872 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("armor"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1873 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);
1875 drawpic_skin(picpos, "armor", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1877 //HUD_DrawXNum_Colored(numpos, x, 3, mySize_y, HUD_Panel_GetFgAlpha(id)); // draw the combined health and armor
1880 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1881 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
1882 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
1885 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
1888 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
1893 string leftname, rightname;
1894 float leftcnt, rightcnt;
1895 float leftactive, rightactive;
1896 float leftalpha, rightalpha;
1897 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) { // old style layout with armor left/top of health
1902 leftalpha = min((armor+10)/55, 1);
1904 rightname = "health";
1909 leftname = "health";
1914 rightname = "armor";
1918 rightalpha = min((armor+10)/55, 1);
1921 if (mySize_x/mySize_y > 5)
1925 len = strlen(ftos(leftcnt));
1927 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1928 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
1929 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
1930 picpos = pos + eX * 0.5 * mySize_x - eX * mySize_y;
1931 numpos = picpos - eX * 3 * 0.5 * mySize_y + eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1934 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
1936 numpos = picpos + eX * mySize_y + eY * 0.25 * mySize_y;
1939 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1940 drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1941 //HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
1946 len = strlen(ftos(rightcnt));
1948 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1949 barpos = pos + eX * 0.5 * mySize_x;
1950 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
1951 picpos = pos + eX * 0.5 * mySize_x;
1952 numpos = picpos + eX * mySize_y - eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1954 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
1955 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
1956 picpos = pos + eX * mySize_x - eX * mySize_y;
1957 numpos = picpos - eX * 1.5 * mySize_y + eY * 0.25 * mySize_y;
1960 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1961 drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1962 //HUD_DrawXNum_Colored(numpos, rightcnt, 3, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
1965 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1966 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
1967 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
1970 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
1973 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
1975 else if (mySize_x/mySize_y > 2)
1979 len = strlen(ftos(leftcnt));
1981 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1982 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
1983 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
1984 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y;
1985 numpos = picpos - eX * len * 0.5 * mySize_y;
1988 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
1990 numpos = picpos + eX * 0.5 * mySize_y;
1993 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1994 drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1995 //HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2000 len = strlen(ftos(rightcnt));
2002 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2003 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2004 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2005 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y + eY * 0.5 * mySize_y;
2006 numpos = picpos - eX * len * 0.5 * mySize_y;
2008 barpos = pos + eY * 0.5 * mySize_y;
2009 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2010 picpos = pos + eY * 0.5 * mySize_y;
2011 numpos = picpos + eX * 0.5 * mySize_y;
2014 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2015 drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2016 //HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2019 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2020 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2021 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2024 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2027 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2033 len = strlen(ftos(leftcnt));
2035 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2037 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2038 picpos = pos + eX * 0.05 * mySize_x;
2039 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x;
2041 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2042 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2043 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x;
2044 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x;
2047 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2048 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2049 //HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.166 * mySize_x, HUD_Panel_GetFgAlpha(id));
2054 len = strlen(ftos(rightcnt));
2056 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2057 barpos = pos + eX * 0.5 * mySize_x;
2058 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2059 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2060 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2062 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2063 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2064 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x + eX * 0.5 * mySize_x;
2065 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x + eX * 0.5 * mySize_x;
2068 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2069 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2070 //HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.166 * mySize_x, HUD_Panel_GetFgAlpha(id));
2073 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2075 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2077 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2078 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2081 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2087 // Notification area (#4)
2090 string Weapon_SuicideMessage(float deathtype)
2092 w_deathtype = deathtype;
2093 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2094 return w_deathtypestring;
2097 string Weapon_KillMessage(float deathtype)
2099 w_deathtype = deathtype;
2100 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2101 return w_deathtypestring;
2104 float killnotify_times[10];
2105 float killnotify_deathtype[10];
2106 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2107 string killnotify_attackers[10];
2108 string killnotify_victims[10];
2109 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2112 for (i = 9; i > 0; --i) {
2113 killnotify_times[i] = killnotify_times[i-1];
2114 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2115 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2116 if(killnotify_attackers[i])
2117 strunzone(killnotify_attackers[i]);
2118 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2119 if(killnotify_victims[i])
2120 strunzone(killnotify_victims[i]);
2121 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2123 killnotify_times[0] = time;
2124 killnotify_deathtype[0] = wpn;
2125 killnotify_actiontype[0] = actiontype;
2126 if(killnotify_attackers[0])
2127 strunzone(killnotify_attackers[0]);
2128 killnotify_attackers[0] = strzone(attacker);
2129 if(killnotify_victims[0])
2130 strunzone(killnotify_victims[0]);
2131 killnotify_victims[0] = strzone(victim);
2134 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2138 alsoprint = (cvar("hud_notify_print") || !HUD_Panel_CheckActive(4)); // print message to console if: notify panel disabled, or cvar to do so enabled
2140 if(msg == MSG_SUICIDE) {
2142 w = DEATH_WEAPONOF(type);
2144 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2146 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2147 } else if (type == DEATH_KILL) {
2148 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2150 print ("^1",s1, "^1 couldn't take it anymore\n");
2151 } else if (type == DEATH_ROT) {
2152 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2154 print ("^1",s1, "^1 died\n");
2155 } else if (type == DEATH_NOAMMO) {
2156 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2158 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2159 } else if (type == DEATH_CAMP) {
2160 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2162 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2163 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2164 HUD_KillNotify_Push(s1, "", 0, type);
2166 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2167 } else if (type == DEATH_CHEAT) {
2168 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2170 print ("^1",s1, "^1 unfairly eliminated themself\n");
2171 } else if (type == DEATH_FIRE) {
2172 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2174 print ("^1",s1, "^1 burned to death\n");
2175 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2176 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2178 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2181 if (stof(s2) > 2) // killcount > 2
2182 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2183 } else if(msg == MSG_KILL) {
2184 w = DEATH_WEAPONOF(type);
2186 HUD_KillNotify_Push(s2, s1, 1, w);
2188 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2190 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2191 HUD_KillNotify_Push(s1, s2, 1, type);
2194 if(cvar("cl_gentle")) {
2195 print ("^1", s1, "^1 took action against a team mate\n");
2197 print ("^1", s1, "^1 mows down a team mate\n");
2200 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2201 if(cvar("cl_gentle"))
2202 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2204 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2206 else if (stof(s2) > 2) {
2207 if(cvar("cl_gentle"))
2208 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2210 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2213 else if(type == KILL_FIRST_BLOOD)
2214 print("^1",s1, "^1 drew first blood", "\n");
2216 else if (type == DEATH_TELEFRAG)
2217 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2218 else if (type == DEATH_DROWN) {
2219 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2221 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2223 else if (type == DEATH_SLIME) {
2224 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2226 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2228 else if (type == DEATH_LAVA) {
2229 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2231 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2233 else if (type == DEATH_FALL) {
2234 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2236 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2238 else if (type == DEATH_SHOOTING_STAR) {
2239 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2241 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2243 else if (type == DEATH_SWAMP) {
2244 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2246 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2248 else if (type == DEATH_HURTTRIGGER)
2250 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2252 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2253 } else if(type == DEATH_SBCRUSH) {
2254 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2256 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2257 } else if(type == DEATH_SBMINIGUN) {
2258 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2260 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2261 } else if(type == DEATH_SBROCKET) {
2262 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2264 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2265 } else if(type == DEATH_SBBLOWUP) {
2266 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2268 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2269 } else if(type == DEATH_WAKIGUN) {
2270 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2272 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2273 } else if(type == DEATH_WAKIROCKET) {
2274 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2276 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2277 } else if(type == DEATH_WAKIBLOWUP) {
2278 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2280 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2281 } else if(type == DEATH_TURRET) {
2282 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2284 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2285 } else if(type == DEATH_TOUCHEXPLODE) {
2286 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2288 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2289 } else if(type == DEATH_CHEAT) {
2290 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2292 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2293 } else if (type == DEATH_FIRE) {
2294 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2296 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2297 } else if (type == DEATH_CUSTOM) {
2298 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2300 print ("^1",s1, "^1 ", s2, "\n");
2302 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2304 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2306 } else if(msg == MSG_SPREE) {
2307 if(type == KILL_END_SPREE) {
2308 if(cvar("cl_gentle"))
2309 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2311 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2312 } else if(type == KILL_SPREE) {
2313 if(cvar("cl_gentle"))
2314 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2316 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2317 } else if(type == KILL_SPREE_3) {
2318 if(cvar("cl_gentle"))
2319 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2321 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2322 } else if(type == KILL_SPREE_5) {
2323 if(cvar("cl_gentle"))
2324 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2326 print (s1,"^7 unleashes ^1RAGE\n");
2327 } else if(type == KILL_SPREE_10) {
2328 if(cvar("cl_gentle"))
2329 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2331 print (s1,"^7 starts the ^1MASSACRE!\n");
2332 } else if(type == KILL_SPREE_15) {
2333 if(cvar("cl_gentle"))
2334 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2336 print (s1,"^7 executes ^1MAYHEM!\n");
2337 } else if(type == KILL_SPREE_20) {
2338 if(cvar("cl_gentle"))
2339 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2341 print (s1,"^7 is a ^1BERSERKER!\n");
2342 } else if(type == KILL_SPREE_25) {
2343 if(cvar("cl_gentle"))
2344 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2346 print (s1,"^7 inflicts ^1CARNAGE!\n");
2347 } else if(type == KILL_SPREE_30) {
2348 if(cvar("cl_gentle"))
2349 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2351 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2353 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2354 if (type == DEATH_DROWN) {
2355 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2358 if(cvar("cl_gentle"))
2359 print ("^1",s1, "^1 was in the water for too long\n");
2361 print ("^1",s1, "^1 drowned\n");
2363 } else if (type == DEATH_SLIME) {
2364 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2366 print ("^1",s1, "^1 was slimed\n");
2367 } else if (type == DEATH_LAVA) {
2368 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2371 if(cvar("cl_gentle"))
2372 print ("^1",s1, "^1 found a hot place\n");
2374 print ("^1",s1, "^1 turned into hot slag\n");
2376 } else if (type == DEATH_FALL) {
2377 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2380 if(cvar("cl_gentle"))
2381 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2383 print ("^1",s1, "^1 hit the ground with a crunch\n");
2385 } else if (type == DEATH_SHOOTING_STAR) {
2386 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2388 print ("^1",s1, "^1 became a shooting star\n");
2389 } else if (type == DEATH_SWAMP) {
2390 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2393 if(cvar("cl_gentle"))
2394 print ("^1",s1, "^1 discovered a swamp\n");
2396 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2398 } else if(type == DEATH_TURRET) {
2399 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2401 print ("^1",s1, "^1 was mowed down by a turret \n");
2402 } else if (type == DEATH_CUSTOM) {
2403 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2405 print ("^1",s1, "^1 ", s2, "\n");
2406 } else if (type == DEATH_HURTTRIGGER) {
2407 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2409 print ("^1",s1, "^1 was in the wrong place\n");
2410 } else if(type == DEATH_TOUCHEXPLODE) {
2411 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2413 print ("^1",s1, "^1 died in an accident\n");
2414 } else if(type == DEATH_CHEAT) {
2415 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2417 print ("^1",s1, "^1 was unfairly eliminated\n");
2418 } else if(type == DEATH_FIRE) {
2419 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2422 if(cvar("cl_gentle"))
2423 print ("^1",s1, "^1 felt a little hot\n");
2425 print ("^1",s1, "^1 burnt to death\n");
2428 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2431 if(cvar("cl_gentle"))
2432 print ("^1",s1, "^1 needs a restart\n");
2434 print ("^1",s1, "^1 died\n");
2437 } else if(msg == MSG_KILL_ACTION_SPREE) {
2438 if(cvar("cl_gentle"))
2439 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2441 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2442 } else if(msg == MSG_INFO) {
2443 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2444 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2445 print(s1, "^7 got the ", s2, "\n");
2446 } else if(type == INFO_LOSTFLAG) {
2447 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2448 print(s1, "^7 lost the ", s2, "\n");
2449 } else if(type == INFO_PICKUPFLAG) {
2450 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2451 print(s1, "^7 picked up the ", s2, "\n");
2452 } else if(type == INFO_RETURNFLAG) {
2453 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2454 print(s1, "^7 returned the ", s2, "\n");
2459 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2461 void HUD_Centerprint(string s1, string s2, float type, float msg)
2463 if(msg == MSG_SUICIDE) {
2464 if (type == DEATH_TEAMCHANGE) {
2465 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2466 } else if (type == DEATH_AUTOTEAMCHANGE) {
2467 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2468 } else if (type == DEATH_CAMP) {
2469 if(cvar("cl_gentle"))
2470 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2472 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2473 } else if (type == DEATH_NOAMMO) {
2474 if(cvar("cl_gentle"))
2475 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2477 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2478 } else if (type == DEATH_ROT) {
2479 if(cvar("cl_gentle"))
2480 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2482 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2483 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2484 if(cvar("cl_gentle"))
2485 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2487 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2488 } else if (type == DEATH_QUIET) {
2490 } else if (type == DEATH_KILL) {
2491 if(cvar("cl_gentle"))
2492 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2494 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2496 } else if(msg == MSG_KILL) {
2497 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2498 if(cvar("cl_gentle")) {
2499 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2501 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2503 } else if (type == KILL_FIRST_BLOOD) {
2504 if(cvar("cl_gentle")) {
2505 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2507 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2509 } else if (type == KILL_FIRST_VICTIM) {
2510 if(cvar("cl_gentle")) {
2511 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2513 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2515 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2516 if(cvar("cl_gentle")) {
2517 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2519 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2521 } else if (type == KILL_TYPEFRAGGED) {
2522 if(cvar("cl_gentle")) {
2523 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2525 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2527 } else if (type == KILL_FRAG) {
2528 if(cvar("cl_gentle")) {
2529 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2531 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2533 } else if (type == KILL_FRAGGED) {
2534 if(cvar("cl_gentle")) {
2535 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2537 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2540 } else if(msg == MSG_KILL_ACTION) {
2541 // TODO: invent more centerprints here?
2542 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2546 void HUD_Notify (void)
2548 float id = HUD_PANEL_NOTIFY;
2550 pos = HUD_Panel_GetPos(id);
2551 mySize = HUD_Panel_GetSize(id);
2553 HUD_Panel_DrawBg(id, pos, mySize, 0);
2555 padding = HUD_Panel_GetPadding(id);
2558 pos += '1 1 0' * padding;
2559 mySize -= '2 2 0' * padding;
2562 float entries, height;
2563 entries = bound(1, floor(14 * mySize_y/mySize_x), 12);
2564 height = mySize_y/entries;
2565 entries -= 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2568 fontsize = '0.5 0.5 0' * height;
2572 when = cvar("hud_notify_time");
2574 fadetime = cvar("hud_notify_fadetime");
2578 vector pos_attacker, pos_victim;
2580 float width_attacker, width_victim;
2581 string attacker, victim;
2584 for(j = 0; j < entries; ++j)
2586 if(cvar("hud_notify_flip"))
2588 else // rather nasty hack for ordering items from the bottom up
2589 i = entries - j - 1;
2590 if(cvar("hud_notify_info_top"))
2591 i += 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2595 if(killnotify_times[j] + when > time)
2598 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2602 if(killnotify_times[j] + when > time)
2608 // TODO: maybe print in team colors?
2609 // TODO: maybe this could be cleaned up somehow...
2610 // TODO: less copypaste code below
2613 if(killnotify_actiontype[j] == 0 && !hud_configure)
2615 attacker = textShortenToWidth(killnotify_attackers[j], mySize_x - 2 * height, fontsize, stringwidth_colors);
2617 width_attacker = stringwidth(attacker, TRUE, fontsize);
2618 pos_attacker = pos + eX * 0.5 * (mySize_x - width_attacker + 2 * height) + eY * 0.5 * fontsize_y + eY * i * height;
2620 weap_pos = pos + eX * 0.5 * (mySize_x - width_attacker) - eX * height + eY * i * height;
2621 if(killnotify_deathtype[j] == DEATH_GENERIC)
2623 drawpic_skin(weap_pos, "notify_death", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2624 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2626 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2628 drawpic_skin(weap_pos, "notify_outofammo", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2629 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2631 else if(killnotify_deathtype[j] == DEATH_KILL)
2633 drawpic_skin(weap_pos, "notify_selfkill", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2634 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2636 else if(killnotify_deathtype[j] == DEATH_CAMP)
2638 drawpic_skin(weap_pos, "notify_camping", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2639 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2641 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2643 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2644 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2646 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2648 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2649 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2651 else if(killnotify_deathtype[j] == DEATH_DROWN)
2653 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2654 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2656 else if(killnotify_deathtype[j] == DEATH_SLIME)
2658 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2659 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2661 else if(killnotify_deathtype[j] == DEATH_LAVA)
2663 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2664 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2666 else if(killnotify_deathtype[j] == DEATH_FALL)
2668 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2669 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2671 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2673 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2674 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2676 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2678 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2679 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2681 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2683 if(killnotify_victims[j] == "^1RED^7 flag")
2687 drawpic_skin(weap_pos, strcat("flag_", s, "_carrying"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2688 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2690 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2692 if(killnotify_victims[j] == "^1RED^7 flag")
2696 drawpic_skin(weap_pos, strcat("flag_", s, "_taken"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2697 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2699 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2701 if(killnotify_victims[j] == "^1RED^7 flag")
2705 drawpic_skin(weap_pos, strcat("flag_", s, "_lost"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2706 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2709 // X [did action to] Y
2714 attacker = textShortenToWidth("Player1", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2715 victim = textShortenToWidth("Player2", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2716 a = bound(0, (when - j) / 4, 1);
2720 attacker = textShortenToWidth(killnotify_attackers[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2721 victim = textShortenToWidth(killnotify_victims[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2723 width_attacker = stringwidth(attacker, TRUE, fontsize);
2724 width_victim = stringwidth(victim, TRUE, fontsize);
2725 pos_attacker = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_attacker) + eY * 0.5 * fontsize_y + eY * i * height;
2726 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;
2727 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2729 if(hud_configure) // example actions for config mode
2731 drawpic_skin(weap_pos, strcat("weapon", "electro"), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2732 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2733 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2735 else if(WEP_VALID(killnotify_deathtype[j]))
2737 self = get_weaponinfo(killnotify_deathtype[j]);
2738 drawpic_skin(weap_pos, strcat("weapon", self.netname), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2739 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2740 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2742 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2744 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2745 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2746 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2748 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2750 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2751 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2752 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2754 else if(killnotify_deathtype[j] == DEATH_DROWN)
2756 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2757 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2758 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2760 else if(killnotify_deathtype[j] == DEATH_SLIME)
2762 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2763 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2764 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2766 else if(killnotify_deathtype[j] == DEATH_LAVA)
2768 drawpic_skin(weap_pos, "notify_lava", '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);
2770 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2772 else if(killnotify_deathtype[j] == DEATH_FALL)
2774 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2775 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2776 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2778 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2780 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2781 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2782 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2784 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2786 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2787 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2788 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2799 if(cvar("hud_notify_info_top"))
2802 o = pos + eY * mySize_y - eY * 2 * height;
2804 if(spectatee_status && !intermission)
2806 //drawfont = hud_bigfont;
2807 if(spectatee_status == -1)
2810 s = GetPlayerName(spectatee_status - 1);
2812 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
2813 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2814 //drawfont = hud_font;
2816 // spectator text in the upper right corner
2817 if(spectatee_status == -1)
2818 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
2820 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
2821 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2822 o += eY * fontsize_y;
2824 if(spectatee_status == -1)
2825 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
2827 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
2828 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2829 o += eY * fontsize_y;
2831 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
2832 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2833 o += eY * fontsize_y;
2835 if(gametype == GAME_ARENA)
2836 s = "^1Wait for your turn to join";
2837 else if(gametype == GAME_LMS)
2840 sk = playerslots[player_localentnum - 1];
2841 if(sk.(scores[ps_primary]) >= 666)
2842 s = "^1Match has already begun";
2843 else if(sk.(scores[ps_primary]) > 0)
2844 s = "^1You have no more lives left";
2846 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
2849 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
2850 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2851 o += eY * fontsize_y;
2853 //show restart countdown:
2854 if (time < getstatf(STAT_GAMESTARTTIME)) {
2856 //we need to ceil, otherwise the countdown would be off by .5 when using round()
2857 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
2858 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
2859 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2860 o += eY * fontsize_y;
2863 if(warmup_stage && !intermission)
2865 s = "^2Currently in ^1warmup^2 stage!";
2866 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2867 o += eY * fontsize_y;
2871 if(mod(time, 1) >= 0.5)
2876 if(ready_waiting && !intermission && !spectatee_status)
2878 if(ready_waiting_for_me)
2881 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
2883 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
2888 s = strcat("^2Waiting for others to ready up to end warmup...");
2890 s = strcat("^2Waiting for others to ready up...");
2892 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2893 o += eY * fontsize_y;
2895 else if(warmup_stage && !intermission && !spectatee_status)
2897 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
2898 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2899 o += eY * fontsize_y;
2902 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
2904 float ts_min, ts_max;
2905 tm = teams.sort_next;
2908 for(; tm.sort_next; tm = tm.sort_next)
2910 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
2912 if(!ts_min) ts_min = tm.team_size;
2913 else ts_min = min(ts_min, tm.team_size);
2914 if(!ts_max) ts_max = tm.team_size;
2915 else ts_max = max(ts_max, tm.team_size);
2917 if ((ts_max - ts_min) > 1)
2919 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
2920 tm = GetTeam(myteam, false);
2922 if (tm.team != COLOR_SPECTATOR)
2923 if (tm.team_size == ts_max)
2924 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
2926 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2927 o += eY * fontsize_y;
2933 s = "^7Press ^3ESC ^7to show HUD options.";
2934 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2935 o += eY * fontsize_y;
2936 s = "^3Doubleclick a panel for panel-specific options.";
2937 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2938 o += eY * fontsize_y;
2944 string seconds_tostring(float sec)
2947 minutes = floor(sec / 60);
2949 sec -= minutes * 60;
2952 s = ftos(100 + sec);
2954 return strcat(ftos(minutes), ":", substring(s, 1, 3));
2957 void HUD_Timer(void)
2959 float id = HUD_PANEL_TIMER;
2961 pos = HUD_Panel_GetPos(id);
2962 mySize = HUD_Panel_GetSize(id);
2964 HUD_Panel_DrawBg(id, pos, mySize, 0);
2966 padding = HUD_Panel_GetPadding(id);
2969 pos += '1 1 0' * padding;
2970 mySize -= '2 2 0' * padding;
2974 float timelimit, elapsedTime, timeleft, minutesLeft;
2976 timelimit = getstatf(STAT_TIMELIMIT);
2978 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
2979 timeleft = ceil(timeleft);
2981 minutesLeft = floor(timeleft / 60);
2984 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
2985 timer_color = '1 1 1'; //white
2986 else if(minutesLeft >= 1)
2987 timer_color = '1 1 0'; //yellow
2989 timer_color = '1 0 0'; //red
2991 if (cvar("hud_timer_increment") || timelimit == 0 || warmup_stage) {
2992 if (time < getstatf(STAT_GAMESTARTTIME)) {
2993 //while restart is still active, show 00:00
2994 timer = seconds_tostring(0);
2996 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
2997 timer = seconds_tostring(elapsedTime);
3000 timer = seconds_tostring(timeleft);
3003 drawstring_aspect(pos, timer, mySize, mySize_y, timer_color, HUD_Panel_GetFgAlpha(HUD_PANEL_TIMER), DRAWFLAG_NORMAL);
3008 void HUD_Radar(void)
3010 float id = HUD_PANEL_RADAR;
3012 pos = HUD_Panel_GetPos(id);
3013 mySize = HUD_Panel_GetSize(id);
3015 HUD_Panel_DrawBg(id, pos, mySize, 0);
3017 padding = HUD_Panel_GetPadding(id);
3020 pos += '1 1 0' * padding;
3021 mySize -= '2 2 0' * padding;
3024 local float color1, color2; // color already declared as a global in hud.qc
3027 float scale2d, normalsize, bigsize;
3030 teamradar_origin2d = pos + 0.5 * mySize;
3031 teamradar_size2d = mySize;
3033 if(minimapname == "")
3036 teamradar_loadcvars();
3038 switch(hud_radar_zoommode)
3042 f = current_zoomfraction;
3045 f = 1 - current_zoomfraction;
3055 switch(hud_radar_rotation)
3058 teamradar_angle = view_angles_y - 90;
3061 teamradar_angle = 90 * hud_radar_rotation;
3065 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3066 teamradar_size2d = mySize;
3068 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3070 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3071 if(hud_radar_rotation == 0)
3073 // max-min distance must fit the radar in any rotation
3074 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3078 vector c0, c1, c2, c3, span;
3079 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3080 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3081 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3082 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3084 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3085 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3087 // max-min distance must fit the radar in x=x, y=y
3089 teamradar_size2d_x * scale2d / (1.05 * span_x),
3090 teamradar_size2d_y * scale2d / (1.05 * span_y)
3094 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3095 if(bigsize > normalsize)
3096 normalsize = bigsize;
3100 + (1 - f) * normalsize;
3101 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3102 f * (mi_min + mi_max) * 0.5
3103 + (1 - f) * view_origin);
3105 color1 = GetPlayerColor(player_localentnum-1);
3106 rgb = GetTeamRGB(color1);
3115 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3117 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3118 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3119 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3120 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, HUD_Panel_GetFgAlpha(id));
3121 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3123 color2 = GetPlayerColor(tm.sv_entnum);
3124 //if(color == COLOR_SPECTATOR || color == color2)
3125 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3127 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3129 drawresetcliparea();
3134 void HUD_Score(void)
3136 float id = HUD_PANEL_SCORE;
3138 pos = HUD_Panel_GetPos(id);
3139 mySize = HUD_Panel_GetSize(id);
3141 HUD_Panel_DrawBg(id, pos, mySize, 0);
3143 padding = HUD_Panel_GetPadding(id);
3146 pos += '1 1 0' * padding;
3147 mySize -= '2 2 0' * padding;
3150 float score, distribution, leader;
3152 vector distribution_color;
3154 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3156 // TODO... this (race part) still uses constant coordinates :/
3157 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3158 /*pl = players.sort_next;
3161 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3162 if(pl.scores[ps_primary] == 0)
3165 score = me.(scores[ps_primary]);
3167 float racemin, racesec, racemsec;
3168 float distsec, distmsec, minusplus;
3170 racemin = floor(score/(60 * TIME_FACTOR));
3171 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
3172 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
3174 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3175 // distribution display
3176 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3178 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
3179 distmsec = fabs(distribution);
3181 distsec = floor(fabs(distribution)/TIME_FACTOR);
3182 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
3183 if (distribution < 0)
3187 if (distribution <= 0) {
3188 distribution_color = eY;
3189 minusplus = 1; // minusplus 1: always prefix with minus sign
3192 distribution_color = eX;
3193 minusplus = 2; // minusplus 1: always prefix with plus sign
3195 //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);
3196 //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);
3197 drawpic_skin(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "num_dot", '16 16 0', distribution_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE);
3199 // race record display
3200 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
3201 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);
3203 //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);
3204 //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);
3205 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);
3207 //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);
3208 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);
3210 } else if (!teamplay) { // non-teamgames
3211 // me vector := [team/connected frags id]
3212 pl = players.sort_next;
3219 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3223 score = me.(scores[ps_primary]);
3227 if(distribution >= 5) {
3228 distribution_color = eY;
3230 } else if(distribution >= 0) {
3231 distribution_color = '1 1 1';
3233 } else if(distribution >= -5)
3234 distribution_color = '1 1 0';
3236 distribution_color = eX;
3238 score_len = strlen(ftos(score));
3240 drawstring_aspect(pos + eX * 0.75 * mySize_x, ftos(distribution), eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, (1/3) * mySize_y, distribution_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3242 drawpic_skin(pos, strcat("num_leading_", ftos(score_len)), eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3243 drawfont = hud_bigfont;
3244 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, mySize_y, distribution_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3245 drawfont = hud_font;
3246 } else { // teamgames
3247 float max_fragcount;
3248 max_fragcount = -99;
3251 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3252 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !hud_configure)) // no players? don't display
3254 score = tm.(teamscores[ts_primary]);
3259 score_len = strlen(ftos(score));
3261 if (score > max_fragcount)
3262 max_fragcount = score;
3264 if(tm.team == myteam) {
3265 if (max_fragcount == score)
3268 drawpic_skin(pos, strcat("num_leading_", ftos(score_len)), eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3269 drawfont = hud_bigfont;
3270 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, mySize_y, GetTeamRGB(tm.team) * 0.8, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3271 drawfont = hud_font;
3273 if (max_fragcount == score)
3276 drawpic_skin(pos + eX * 0.75 * mySize_x + eY * (1/3) * teamnum * mySize_y, strcat("num_leading_", ftos(score_len)), eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3277 drawstring_aspect(pos + eX * 0.75 * mySize_x + eY * (1/3) * teamnum * mySize_y, ftos(score), eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, (1/3) * mySize_y, GetTeamRGB(tm.team) * 0.8, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3286 void HUD_RaceTimer (void) {
3287 float id = HUD_PANEL_RACETIMER;
3289 pos = HUD_Panel_GetPos(id);
3290 mySize = HUD_Panel_GetSize(id);
3292 HUD_Panel_DrawBg(id, pos, mySize, 0);
3294 padding = HUD_Panel_GetPadding(id);
3297 pos += '1 1 0' * padding;
3298 mySize -= '2 2 0' * padding;
3301 drawfont = hud_bigfont;
3303 string s, forcetime;
3308 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);
3309 s = "^1Intermediate 1 (+15.42)";
3310 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);
3311 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3312 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);
3314 else if(race_checkpointtime)
3316 a = bound(0, 2 - (time - race_checkpointtime), 1);
3319 if(a > 0) // just hit a checkpoint?
3321 if(race_checkpoint != 254)
3323 if(race_time && race_previousbesttime)
3324 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3326 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3328 forcetime = TIME_ENCODED_TOSTRING(race_time);
3333 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3335 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3336 if(a > 0) // next one?
3338 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3343 if(s != "" && a > 0)
3345 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3346 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3347 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);
3350 if(race_penaltytime)
3352 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3355 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3356 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3357 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3358 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);
3364 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3365 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id), 0, a);
3366 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);
3371 if(race_laptime && race_checkpoint != 255)
3373 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3374 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3375 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);
3380 if(race_mycheckpointtime)
3382 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3383 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3384 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3385 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3386 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);
3388 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3390 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3391 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3392 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3393 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3394 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);
3397 if(race_penaltytime && !race_penaltyaccumulator)
3399 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3400 a = bound(0, (1 + t - time), 1);
3404 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3406 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3407 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3408 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3409 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);
3414 drawfont = hud_font;
3419 float vote_yescount;
3422 float vote_highlighted; // currently selected vote
3424 float vote_active; // is there an active vote?
3425 float vote_prev; // previous state of vote_active to check for a change
3427 float vote_change; // "time" when vote_active changed
3429 void HUD_VoteWindow(void)
3431 float id = HUD_PANEL_VOTE;
3433 pos = HUD_Panel_GetPos(id);
3434 mySize = HUD_Panel_GetSize(id);
3438 if(vote_active != vote_prev) {
3440 vote_prev = vote_active;
3443 if(vote_active || hud_configure)
3444 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3446 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3458 a = vote_alpha * bound(cvar_or("hud_vote_alreadyvoted_alpha", 0.75), 1 - vote_highlighted, 1);
3460 HUD_Panel_DrawBg(id, pos, mySize, a);
3462 padding = HUD_Panel_GetPadding(id);
3465 pos += '1 1 0' * padding;
3466 mySize -= '2 2 0' * padding;
3469 drawpic_skin(pos, "voteprogress_back", mySize, '1 1 1', a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3471 s = "A vote has been called for: ";
3472 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);
3473 s = textShortenToWidth(vote_called_vote, mySize_x * 0.96, '1 1 0' * mySize_y*(1/5), stringwidth_colors); // TODO: broken?
3475 s = "Configure the HUD";
3476 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);
3478 // print the yes/no counts
3479 s = strcat("Yes: ", ftos(vote_yescount));
3480 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);
3481 s = strcat("No: ", ftos(vote_nocount));
3482 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);
3484 // draw the progress bars
3485 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3486 drawpic_skin(pos, "voteprogress_prog", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3488 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3489 drawpic_skin(pos, "voteprogress_prog", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3491 // draw the highlights
3492 if(vote_highlighted == 1) {
3493 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3494 drawpic_skin(pos, "voteprogress_voted", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3496 else if(vote_highlighted == 2) {
3497 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3498 drawpic_skin(pos, "voteprogress_voted", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3501 drawresetcliparea();
3504 vote_highlighted = 0;
3508 // Mod icons panel (#10)
3511 float mod_active; // is there any active mod icon?
3513 // CTF HUD modicon section
3514 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3515 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3516 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3518 void HUD_Mod_CTF_Reset(void)
3520 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3523 void HUD_Mod_CTF(vector pos, vector mySize)
3525 vector redflag_pos, blueflag_pos;
3527 float f; // every function should have that
3529 float redflag, blueflag; // current status
3530 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3533 stat_items = getstati(STAT_ITEMS);
3534 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3535 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3537 if(redflag || blueflag)
3548 // when status CHANGES, set old status into prevstatus and current status into status
3549 if (redflag != redflag_prevframe)
3551 redflag_statuschange_time = time;
3552 redflag_prevstatus = redflag_prevframe;
3553 redflag_prevframe = redflag;
3556 if (blueflag != blueflag_prevframe)
3558 blueflag_statuschange_time = time;
3559 blueflag_prevstatus = blueflag_prevframe;
3560 blueflag_prevframe = blueflag;
3563 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3564 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3566 float BLINK_FACTOR = 0.15;
3567 float BLINK_BASE = 0.85;
3569 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3571 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3573 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3575 string red_icon, red_icon_prevstatus;
3576 float red_alpha, red_alpha_prevstatus;
3577 red_alpha = red_alpha_prevstatus = 1;
3579 case 1: red_icon = "flag_red_taken"; break;
3580 case 2: red_icon = "flag_red_lost"; break;
3581 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3583 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3584 red_icon = "flag_red_shielded";
3586 red_icon = string_null;
3589 switch(redflag_prevstatus) {
3590 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3591 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3592 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3595 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3596 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3597 red_icon_prevstatus = "flag_red_shielded";
3599 red_icon_prevstatus = string_null;
3603 string blue_icon, blue_icon_prevstatus;
3604 float blue_alpha, blue_alpha_prevstatus;
3605 blue_alpha = blue_alpha_prevstatus = 1;
3607 case 1: blue_icon = "flag_blue_taken"; break;
3608 case 2: blue_icon = "flag_blue_lost"; break;
3609 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3611 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3612 blue_icon = "flag_blue_shielded";
3614 blue_icon = string_null;
3617 switch(blueflag_prevstatus) {
3618 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3619 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3620 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3623 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3624 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3625 blue_icon_prevstatus = "flag_blue_shielded";
3627 blue_icon_prevstatus = string_null;
3631 if(mySize_x > mySize_y) {
3632 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3634 blueflag_pos = pos + eX * 0.5 * mySize_x;
3637 redflag_pos = pos + eX * 0.5 * mySize_x;
3639 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3641 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3643 blueflag_pos = pos + eY * 0.5 * mySize_y;
3646 redflag_pos = pos + eY * 0.5 * mySize_y;
3648 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3651 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3652 if(red_icon_prevstatus && f < 1)
3653 drawpic_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3655 drawpic_skin(redflag_pos, red_icon, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * red_alpha * f, DRAWFLAG_NORMAL);
3657 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3658 if(blue_icon_prevstatus && f < 1)
3659 drawpic_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3661 drawpic_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * blue_alpha * f, DRAWFLAG_NORMAL);
3664 // Keyhunt HUD modicon section
3665 float kh_runheretime;
3667 void HUD_Mod_KH_Reset(void)
3672 void HUD_Mod_KH(vector pos, vector mySize)
3674 mod_active = 1; // keyhunt should never hide the mod icons panel
3678 vector p, pa, kh_size, kh_asize;
3680 kh_keys = getstati(STAT_KH_KEYS);
3683 if(mySize_x > mySize_y)
3685 p_y = pos_y + 0.25 * mySize_y;
3686 pa = p - eY * 0.25 * mySize_y;
3688 kh_size_x = mySize_x * 0.25;
3689 kh_size_y = 0.75 * mySize_y;
3690 kh_asize_x = mySize_x * 0.25;
3691 kh_asize_y = mySize_y * 0.25;
3695 p_y = pos_y + 0.125 * mySize_y;
3696 pa = p - eY * 0.125 * mySize_y;
3698 kh_size_x = mySize_x * 0.5;
3699 kh_size_y = 0.375 * mySize_y;
3700 kh_asize_x = mySize_x * 0.5;
3701 kh_asize_y = mySize_y * 0.125;
3708 for(i = 0; i < 4; ++i)
3710 key = floor(kh_keys / pow(32, i)) & 31;
3712 if(keyteam == 30 && keycount <= 4)
3714 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3718 // this yields 8 exactly if "RUN HERE" shows
3723 kh_runheretime = time;
3724 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3729 for(i = 0; i < 4; ++i)
3731 key = floor(kh_keys / pow(32, i)) & 31;
3744 default: // owned or dropped
3749 a = a * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3750 aa = aa * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3756 drawpic_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3759 drawpic_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3762 drawpic_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3765 drawpic_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3770 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3773 drawpic_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3776 drawpic_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3779 drawpic_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3782 drawpic_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3786 if(mySize_x > mySize_y)
3788 p_x += 0.25 * mySize_x;
3789 pa_x += 0.25 * mySize_x;
3795 p_y = pos_y + 0.625 * mySize_y;
3796 pa_y = pos_y + 0.5 * mySize_y;
3802 p_x += 0.5 * mySize_x;
3803 pa_x += 0.5 * mySize_x;
3809 // Nexball HUD mod icon
3810 void HUD_Mod_NexBall(vector pos, vector mySize)
3812 float stat_items, nb_pb_starttime, dt, p;
3814 stat_items = getstati(STAT_ITEMS);
3815 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3817 if (stat_items & IT_KEY1)
3822 //Manage the progress bar if any
3823 if (nb_pb_starttime > 0)
3825 dt = mod(time - nb_pb_starttime, nb_pb_period);
3826 // one period of positive triangle
3827 p = 2 * dt / nb_pb_period;
3834 if(mySize_x > mySize_y)
3836 barsize = eX * p * mySize_x + eY * mySize_y;
3841 barsize = eX * mySize_x + eY * p * mySize_y;
3844 HUD_Panel_DrawProgressBar(pos, vertical, barsize, HUD_Panel_GetProgressBarColor("nexball"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3847 if (stat_items & IT_KEY1)
3848 drawpic_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3851 // Race/CTS HUD mod icons
3852 float crecordtime_prev; // last remembered crecordtime
3853 float crecordtime_change_time; // time when crecordtime last changed
3854 float srecordtime_prev; // last remembered srecordtime
3855 float srecordtime_change_time; // time when srecordtime last changed
3857 float race_status_time;
3858 float race_status_prev;
3859 string race_status_name_prev;
3860 void HUD_Mod_Race(vector pos, vector mySize)
3862 mod_active = 1; // race should never hide the mod icons panel
3864 me = playerslots[player_localentnum - 1];
3866 float f; // yet another function has this
3867 score = me.(scores[ps_primary]);
3869 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3870 return; // no records in the actual race
3872 drawfont = hud_bigfont;
3874 // clientside personal record
3876 if(gametype == GAME_CTS)
3880 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3882 if(score && (score < t || !t)) {
3883 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3884 if(cvar("cl_autodemo_delete_keeprecords"))
3886 f = cvar("cl_autodemo_delete");
3888 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3892 if(t != crecordtime_prev) {
3893 crecordtime_prev = t;
3894 crecordtime_change_time = time;
3896 f = time - crecordtime_change_time;
3899 drawstring_aspect(pos, "Personal best ", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3900 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);
3902 drawstring(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3903 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);
3904 drawstring_expanding(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL, f);
3905 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);
3909 t = race_server_record;
3910 if(t != srecordtime_prev) {
3911 srecordtime_prev = t;
3912 srecordtime_change_time = time;
3914 f = time - srecordtime_change_time;
3917 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);
3918 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);
3920 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);
3921 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);
3922 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);
3923 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);
3926 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
3927 race_status_time = time + 5;
3928 race_status_prev = race_status;
3929 if (race_status_name_prev)
3930 strunzone(race_status_name_prev);
3931 race_status_name_prev = strzone(race_status_name);
3934 pos_x += mySize_x/2;
3937 a = bound(0, race_status_time - time, 1);
3940 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
3944 rank = race_CheckName(race_status_name);
3946 rankname = race_PlaceName(rank);
3949 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
3951 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
3953 if(race_status == 0)
3954 drawpic_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3955 else if(race_status == 1) {
3956 drawpic_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3957 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3958 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3959 } else if(race_status == 2) {
3960 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
3961 drawpic_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3963 drawpic_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3964 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3965 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3966 } else if(race_status == 3) {
3967 drawpic_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3968 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3969 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3972 if (race_status_time - time <= 0) {
3973 race_status_prev = -1;
3975 if(race_status_name)
3976 strunzone(race_status_name);
3977 race_status_name = string_null;
3978 if(race_status_name_prev)
3979 strunzone(race_status_name_prev);
3980 race_status_name_prev = string_null;
3982 drawfont = hud_font;
3985 float mod_prev; // previous state of mod_active to check for a change
3987 float mod_change; // "time" when mod_active changed
3989 void HUD_ModIcons(void)
3991 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !hud_configure)
3994 float id = HUD_PANEL_MODICONS;
3996 pos = HUD_Panel_GetPos(id);
3997 mySize = HUD_Panel_GetSize(id);
3999 if(mod_active != mod_prev) {
4001 mod_prev = mod_active;
4004 if(mod_active || hud_configure)
4005 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4007 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4010 HUD_Panel_DrawBg(id, pos, mySize, mod_alpha);
4013 padding = HUD_Panel_GetPadding(id);
4016 pos += '1 1 0' * padding;
4017 mySize -= '2 2 0' * padding;
4020 // these MUST be ran in order to update mod_active
4021 if(gametype == GAME_KEYHUNT)
4022 HUD_Mod_KH(pos, mySize);
4023 else if(gametype == GAME_CTF || hud_configure)
4024 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4025 else if(gametype == GAME_NEXBALL)
4026 HUD_Mod_NexBall(pos, mySize);
4027 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4028 HUD_Mod_Race(pos, mySize);
4031 // Draw pressed keys (#11)
4033 void HUD_DrawPressedKeys(void)
4035 float id = HUD_PANEL_PRESSEDKEYS;
4037 pos = HUD_Panel_GetPos(id);
4038 mySize = HUD_Panel_GetSize(id);
4040 HUD_Panel_DrawBg(id, pos, mySize, 0);
4042 padding = HUD_Panel_GetPadding(id);
4045 pos += '1 1 0' * padding;
4046 mySize -= '2 2 0' * padding;
4050 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4053 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4054 drawpic_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4055 drawpic_skin(pos + eX * mySize_x * (1/3), ((pressedkeys & KEY_FORWARD) ? "key_forward_inv.tga" : "key_forward.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4056 drawpic_skin(pos + eX * mySize_x * (2/3), ((pressedkeys & KEY_JUMP) ? "key_jump_inv.tga" : "key_jump.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4057 drawpic_skin(pos + eY * 0.5 * mySize_y, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4058 drawpic_skin(pos + eY * 0.5 * mySize_y + eX * mySize_x * (1/3), ((pressedkeys & KEY_BACKWARD) ? "key_backward_inv.tga" : "key_backward.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4059 drawpic_skin(pos + eY * 0.5 * mySize_y + eX * mySize_x * (2/3), ((pressedkeys & KEY_RIGHT) ? "key_right_inv.tga" : "key_right.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4062 // Handle chat as a panel (#12)
4066 float id = HUD_PANEL_CHAT;
4068 pos = HUD_Panel_GetPos(id);
4069 mySize = HUD_Panel_GetSize(id);
4071 HUD_Panel_DrawBg(id, pos, mySize, 0);
4073 padding = HUD_Panel_GetPadding(id);
4076 pos += '1 1 0' * padding;
4077 mySize -= '2 2 0' * padding;
4080 cvar_set("con_chatrect", "1");
4082 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4083 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4085 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4086 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4091 chatsize = cvar("con_chatsize");
4092 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4094 for(i = 0; i < cvar("con_chat"); ++i)
4096 if(i == cvar("con_chat") - 1)
4097 a = HUD_Panel_GetFgAlpha(id);
4099 a = HUD_Panel_GetFgAlpha(id) * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4100 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);
4105 // Engine info panel (#13)
4112 float frametimeavg1; // 1 frame ago
4113 float frametimeavg2; // 2 frames ago
4114 void HUD_EngineInfo(void)
4116 float id = HUD_PANEL_ENGINEINFO;
4118 pos = HUD_Panel_GetPos(id);
4119 mySize = HUD_Panel_GetSize(id);
4121 HUD_Panel_DrawBg(id, pos, mySize, 0);
4123 padding = HUD_Panel_GetPadding(id);
4126 pos += '1 1 0' * padding;
4127 mySize -= '2 2 0' * padding;
4130 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4132 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4133 frametimeavg2 = frametimeavg1;
4134 frametimeavg1 = frametimeavg;
4137 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4138 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.
4140 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
4141 prevfps = (1/frametime);
4142 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"
4148 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4150 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4152 prevfps_time = time;
4157 color = HUD_Get_Num_Color (prevfps, 100);
4158 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), mySize, mySize_y, color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4166 void HUD_ShowSpeed(void)
4169 float pos, conversion_factor;
4170 string speed, zspeed, unit;
4172 switch(cvar("cl_showspeed_unit"))
4177 conversion_factor = 1.0;
4181 conversion_factor = 1.0;
4185 conversion_factor = 0.0254;
4189 conversion_factor = 0.0254 * 3.6;
4193 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4197 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4201 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4203 numsize_x = numsize_y = cvar("cl_showspeed_size");
4204 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4206 drawfont = hud_bigfont;
4207 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4209 if (cvar("cl_showspeed_z") == 1) {
4210 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4211 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4214 drawfont = hud_font;
4217 vector acc_prevspeed;
4221 void HUD_ShowAcceleration(void)
4223 float acceleration, sz, scale, alpha, f;
4224 vector pos, top, rgb;
4225 top_x = vid_conwidth/2;
4228 f = time - acc_prevtime;
4229 if(cvar("cl_showacceleration_z"))
4230 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4232 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4233 acc_prevspeed = pmove_vel;
4234 acc_prevtime = time;
4236 f = bound(0, f * 10, 1);
4237 acc_avg = acc_avg * (1 - f) + acceleration * f;
4238 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4240 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4242 sz = cvar("cl_showacceleration_size");
4243 scale = cvar("cl_showacceleration_scale");
4244 alpha = cvar("cl_showacceleration_alpha");
4245 if (cvar("cl_showacceleration_color_custom"))
4246 rgb = stov(cvar_string("cl_showacceleration_color"));
4249 if (acceleration < 0) {
4250 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4251 } else if (acceleration > 0) {
4252 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4256 if (acceleration > 0)
4257 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4258 else if (acceleration < 0)
4259 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4262 void HUD_Reset (void)
4264 // reset gametype specific icons
4265 if(gametype == GAME_KEYHUNT)
4267 else if(gametype == GAME_CTF)
4268 HUD_Mod_CTF_Reset();
4271 void HUD_Main (void)
4273 if(disable_menu_alphacheck == 1)
4274 menu_fade_alpha = 1;
4276 menu_fade_alpha = (1 - cvar("_menu_alpha"));
4277 hud_fg_alpha = cvar("hud_fg_alpha");
4279 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4280 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4281 hud_color_bg_team = cvar("hud_color_bg_team");
4283 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4284 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4286 hud_configure = cvar("_hud_configure");
4290 // HUD configure visible grid
4291 if(hud_configure && cvar("hud_configure_grid") && cvar("hud_configure_grid_alpha"))
4295 for(i = 0; i < 1/bound(0.005, cvar("hud_configure_grid_x"), 0.2); ++i)
4297 drawfill(eX * i * vid_conwidth * bound(0.005, cvar("hud_configure_grid_x"), 0.2), eX + eY * vid_conheight, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
4300 for(i = 0; i < 1/bound(0.005, cvar("hud_configure_grid_y"), 0.2); ++i)
4302 drawfill(eY * i * vid_conheight * bound(0.005, cvar("hud_configure_grid_y"), 0.2), eY + eX * vid_conwidth, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
4306 if(cvar_string("hud_dock") != "" && cvar_string("hud_dock") != "0")
4307 drawpic('0 0 0', strcat("gfx/hud/", cvar_string("hud_skin"), "/", cvar_string("hud_dock")), eX * vid_conwidth + eY * vid_conheight, HUD_Panel_Dock_GetColor(), cvar("hud_dock_alpha") * menu_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
4309 if(HUD_Panel_CheckActive(HUD_PANEL_RADAR) || hud_configure)
4310 if(cvar_string("hud_radar") != "0" && (cvar("hud_radar") == 2 || teamplay))
4312 if(HUD_Panel_CheckActive(HUD_PANEL_WEAPONICONS) || hud_configure)
4314 if(HUD_Panel_CheckActive(HUD_PANEL_INVENTORY) || hud_configure)
4316 if(HUD_Panel_CheckActive(HUD_PANEL_POWERUPS) || hud_configure)
4318 if(HUD_Panel_CheckActive(HUD_PANEL_HEALTHARMOR) || hud_configure)
4320 if(HUD_Panel_CheckActive(HUD_PANEL_NOTIFY) || hud_configure)
4322 if(HUD_Panel_CheckActive(HUD_PANEL_TIMER) || hud_configure)
4324 if(HUD_Panel_CheckActive(HUD_PANEL_SCORE) || hud_configure)
4326 if(HUD_Panel_CheckActive(HUD_PANEL_RACETIMER) || hud_configure)
4327 if(gametype == GAME_RACE || gametype == GAME_CTS || hud_configure)
4329 if(HUD_Panel_CheckActive(HUD_PANEL_VOTE) || hud_configure)
4331 if(HUD_Panel_CheckActive(HUD_PANEL_MODICONS) || hud_configure)
4334 if(HUD_Panel_CheckActive(HUD_PANEL_PRESSEDKEYS) || hud_configure)
4335 if(spectatee_status > 0 || cvar("hud_pressedkeys") >= 2 || hud_configure)
4336 HUD_DrawPressedKeys();
4337 if(HUD_Panel_CheckActive(HUD_PANEL_CHAT) || hud_configure)
4340 cvar_set("con_chatrect", "0");
4341 if(HUD_Panel_CheckActive(HUD_PANEL_ENGINEINFO) || hud_configure)
4344 // TODO hud_'ify these
4345 if (cvar("cl_showspeed"))
4347 if (cvar("cl_showacceleration"))
4348 HUD_ShowAcceleration();
4350 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)
4351 localcmd("cmd selectteam auto; cmd join\n");
4353 if (!hud_configure) // hud config mode disabled, enable normal alpha stuff again
4354 disable_menu_alphacheck = 0;