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 // TODO: make a default skin, and fallback to these!
101 void drawpic_skin(vector pos, string pic, vector sz, vector color, float alpha, float drawflag) {
102 drawpic_aspect(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, color, alpha, drawflag);
106 void drawpic_skin_expanding(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
108 //drawpic_aspect_expanding(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
111 void drawpic_skin_expanding_two(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
113 //drawpic_aspect_expanding_two(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
116 // return HUD background color
117 vector HUD_GetBgColor()
121 GetTeamRGB(myteam) * hud_color_bg_team;
123 // allow custom HUD colors in non-teamgames
124 color_x = cvar("hud_color_bg_r");
125 color_y = cvar("hud_color_bg_g");
126 color_z = cvar("hud_color_bg_b");
131 // return accuracy text color
132 vector HUD_AccuracyColor(float accuracy)
135 float yellow_accuracy = cvar("hud_weaponicons_accuracy_yellow"); // value at which this function returns yellow
136 if(accuracy >= 100) {
140 else if(accuracy > yellow_accuracy) {
141 rgb_x = 1 - (accuracy-yellow_accuracy)/(100-yellow_accuracy); // red value between 1 -> 0
146 rgb_y = accuracy/yellow_accuracy; // green value between 0 -> 1
152 vector HUD_Get_Num_Color (float x, float maxvalue)
160 else if(x > maxvalue * 0.75) {
161 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
162 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
165 else if(x > maxvalue * 0.5) {
166 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
167 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
168 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
170 else if(x > maxvalue * 0.25) {
173 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
175 else if(x > maxvalue * 0.1) {
177 color_y = (x-20)*90/27/100; // green value between 0 -> 1
178 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
188 float stringwidth_colors(string s, vector theSize)
190 return stringwidth(s, TRUE, theSize);
193 float stringwidth_nocolors(string s, vector theSize)
195 return stringwidth(s, FALSE, theSize);
198 #define CENTERPRINT_MAX_LINES 30
199 string centerprint_messages[CENTERPRINT_MAX_LINES];
200 float centerprint_width[CENTERPRINT_MAX_LINES];
201 vector centerprint_start;
202 float centerprint_expire;
203 float centerprint_num;
204 float centerprint_offset_hint;
205 vector centerprint_fontsize;
207 void centerprint(string strMessage)
209 float i, j, n, hcount;
212 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
214 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
216 if(cvar("scr_centertime") <= 0)
222 // strip trailing newlines
223 j = strlen(strMessage) - 1;
224 while(substring(strMessage, j, 1) == "\n" && j >= 0)
226 strMessage = substring(strMessage, 0, j + 1);
231 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
233 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
235 strMessage = substring(strMessage, j, strlen(strMessage) - j);
236 centerprint_offset_hint = j;
241 // if we get here, we have a message. Initialize its height.
244 n = tokenizebyseparator(strMessage, "\n");
246 for(j = 0; j < n; ++j)
248 getWrappedLine_remaining = argv(j);
249 while(getWrappedLine_remaining)
251 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
252 if(centerprint_messages[i])
253 strunzone(centerprint_messages[i]);
254 centerprint_messages[i] = strzone(s);
255 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
258 // half height for empty lines looks better
264 if(i >= CENTERPRINT_MAX_LINES)
270 h = centerprint_fontsize_y*hcount;
272 havail = vid_conheight;
273 if(cvar("con_chatpos") < 0)
274 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
275 if(havail > vid_conheight - 70)
276 havail = vid_conheight - 70; // avoid overlapping HUD
278 centerprint_start_x = 0;
281 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
283 // here, the centerprint would cover the crosshair. REALLY BAD.
284 forbiddenmin = vid_conheight * 0.5 - h - 16;
285 forbiddenmax = vid_conheight * 0.5 + 16;
287 allowedmin = scoreboard_bottom;
288 allowedmax = havail - h;
289 preferred = (havail - h)/2;
292 // possible orderings (total: 4! / 4 = 6)
293 // allowedmin allowedmax forbiddenmin forbiddenmax
294 // forbiddenmin forbiddenmax allowedmin allowedmax
295 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
297 // forbidden doesn't matter in this case
298 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
300 // allowedmin forbiddenmin allowedmax forbiddenmax
301 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
303 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
305 // allowedmin forbiddenmin forbiddenmax allowedmax
306 else if(allowedmin < forbiddenmin)
308 // make sure the forbidden zone is not covered
309 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
310 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
312 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
314 // forbiddenmin allowedmin allowedmax forbiddenmax
315 else if(allowedmax < forbiddenmax)
317 // it's better to leave the allowed zone (overlap with scoreboard) than
318 // to cover the forbidden zone (crosshair)
319 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
320 centerprint_start_y = forbiddenmax;
322 centerprint_start_y = forbiddenmin;
324 // forbiddenmin allowedmin forbiddenmax allowedmax
327 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
330 centerprint_start_y =
333 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
341 centerprint_expire = time + cvar("scr_centertime");
344 void HUD_DrawCenterPrint (void)
351 //if(time > centerprint_expire)
354 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
355 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
356 //sz = 1.2 / (a + 0.2);
361 pos = centerprint_start;
362 for (i=0; i<centerprint_num; i = i + 1)
364 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
365 ts = centerprint_messages[i];
368 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
369 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
370 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
371 pos_y = pos_y + centerprint_fontsize_y;
374 // half height for empty lines looks better
375 pos_y = pos_y + centerprint_fontsize_y * 0.5;
379 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
381 position_x -= 2 / 3 * strlen(text) * scale_x;
382 drawstring(position, text, scale, rgb, alpha, flag);
385 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
387 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
388 drawstring(position, text, scale, rgb, alpha, flag);
391 // return the string of the given race place
392 string race_PlaceName(float pos) {
400 return strcat(ftos(pos), "th");
403 // return the string of the onscreen race timer
404 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
412 if(histime == 0) // goal hit
416 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
426 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
432 lapstr = strcat(" (-", ftos(lapdelta), "L)");
435 else if(lapdelta < 0)
437 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
441 else if(histime > 0) // anticipation
443 if(mytime >= histime)
444 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
446 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
453 cpname = "Start line";
455 cpname = "Finish line";
457 cpname = strcat("Intermediate ", ftos(cp));
459 cpname = "Finish line";
462 return strcat(col, cpname);
463 else if(hisname == "")
464 return strcat(col, cpname, " (", timestr, ")");
466 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
469 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
470 float race_CheckName(string net_name) {
472 for (i=RANKINGS_CNT-1;i>=0;--i)
473 if(grecordholder[i] == net_name)
485 void HUD_Panel_ExportCfg(string cfgname)
488 fh = fopen(strcat("hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg"), FILE_WRITE);
491 fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
492 fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
493 fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
494 fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
495 fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
496 fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
497 fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
498 fputs(fh, strcat("seta hud_fg_alpha \"", cvar_string("hud_fg_alpha"), "\"", "\n"));
501 fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
502 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
503 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
504 fputs(fh, strcat("seta hud_dock_alpha \"", ftos(cvar("hud_dock_alpha")), "\"", "\n"));
507 fputs(fh, strcat("seta hud_progressbar_alpha ", ftos(cvar("hud_progressbar_alpha")), "\n"));
508 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
509 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
510 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
511 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
512 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
513 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
516 // common cvars for all panels
518 for (i = 0; i < HUD_PANEL_NUM; ++i)
520 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), " ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i)))), "\n"));
521 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_pos \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_pos")), "\"", "\n"));
522 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_size \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_size")), "\"", "\n"));
523 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg")), "\"", "\n"));
524 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color")), "\"", "\n"));
525 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color_team \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color_team")), "\"", "\n"));
526 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_alpha \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_alpha")), "\"", "\n"));
527 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_border \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_border")), "\"", "\n"));
528 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_padding \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_padding")), "\"", "\n"));
531 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_accuracy_yellow ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_accuracy_yellow"))), "\n"));
534 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_onlycurrent ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_onlycurrent"))), "\n"));
537 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
538 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_mirror ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
541 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
542 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_mirror ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
545 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
546 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_info_top ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_info_top"))), "\n"));
549 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_foreground_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_foreground_alpha"))), "\n"));
551 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha"))), "\n"));
557 print("^2Successfully exported to hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
562 // return active status of panel
563 float HUD_Panel_CheckActive(float id)
565 if (cvar_or(strcat("hud_", HUD_Panel_GetName(id)), 1))
570 // return size of given panel
571 vector HUD_Panel_GetSize(float id)
574 mySize = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_size")));
576 mySize = eX * mySize_x * vid_conwidth + eY * mySize_y * vid_conheight;
578 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
580 vector menu_enable_maxsize, menu_enable_size;
581 menu_enable_maxsize = '0 0 0'; // shut up FTEQCC
582 menu_enable_maxsize_x = 0.3 * vid_conwidth;
583 menu_enable_maxsize_y = 0.18 * vid_conheight;
584 if(mySize_x > mySize_y)
586 if(mySize_y > menu_enable_maxsize_y)
588 menu_enable_size_y = menu_enable_maxsize_y;
589 menu_enable_size_x = mySize_x * (menu_enable_maxsize_y/mySize_y);
590 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
595 if(mySize_x > menu_enable_maxsize_x)
597 menu_enable_size_x = menu_enable_maxsize_x;
598 menu_enable_size_y = mySize_y * (menu_enable_maxsize_x/mySize_x);
599 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
606 // return pos of given panel
607 vector HUD_Panel_GetPos(float id)
610 pos = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_pos")));
612 pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
614 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
616 vector mySize, menu_enable_panelpos;
617 mySize = HUD_Panel_GetSize(id);
618 if(mySize_x > mySize_y)
619 menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * mySize_x + eY * 0.82 * vid_conheight;
621 menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * mySize_y + eX * 0.7 * vid_conwidth;
622 pos = (1 - cvar("_menu_alpha")) * pos + (cvar("_menu_alpha")) * menu_enable_panelpos;
627 float HUD_Panel_GetBorder(float id)
630 border = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_border"));
632 border = cvar_string("hud_bg_border");
636 vector HUD_Panel_GetColor(float id)
642 // fetch per-panel color
643 if(teamplay && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")) != "") {
644 f = stof(getplayerkey(self.sv_entnum, "colors"));
645 color = vtos(colormapPaletteColor(mod(f, 16), 1) * cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")));
648 color = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color"));
649 color_vec = stov(color);
651 if(color == "") { // fetch default color
652 color = cvar_string("hud_bg_color");
653 color_vec = stov(color);
654 if(teamplay && cvar(strcat("hud_bg_color_team"))) {
655 f = stof(getplayerkey(self.sv_entnum, "colors"));
656 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_bg_color_team");
658 else if(color == "shirt") {
659 f = stof(getplayerkey(self.sv_entnum, "colors"));
660 color_vec = colormapPaletteColor(floor(f / 16), 0);
662 else if(color == "pants") {
663 f = stof(getplayerkey(self.sv_entnum, "colors"));
664 color_vec = colormapPaletteColor(mod(f, 16), 1);
667 else if(color == "shirt") {
668 f = stof(getplayerkey(self.sv_entnum, "colors"));
669 color_vec = colormapPaletteColor(floor(f / 16), 0);
671 else if(color == "pants") {
672 f = stof(getplayerkey(self.sv_entnum, "colors"));
673 color_vec = colormapPaletteColor(mod(f, 16), 1);
678 vector HUD_Panel_Dock_GetColor(void)
683 color = cvar_string("hud_dock_color");
684 color_vec = stov(color);
685 if(teamplay && cvar(strcat("hud_dock_color_team"))) {
686 f = stof(getplayerkey(self.sv_entnum, "colors"));
687 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_dock_color_team");
689 else if(color == "shirt") {
690 f = stof(getplayerkey(self.sv_entnum, "colors"));
691 color_vec = colormapPaletteColor(floor(f / 16), 0);
693 else if(color == "pants") {
694 f = stof(getplayerkey(self.sv_entnum, "colors"));
695 color_vec = colormapPaletteColor(mod(f, 16), 1);
700 float HUD_Panel_GetBgAlpha(float id)
703 alpha = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_alpha"));
705 alpha = cvar_string("hud_bg_alpha");
707 if(hud_configure && disable_menu_alphacheck == 2 && highlightedPanel == id) // do not set a minalpha cap when showing the config dialog for this panel
708 alpha = ftos((1 - cvar("_menu_alpha")) * max(cvar("hud_configure_bg_minalpha"), stof(alpha)) + (cvar("_menu_alpha")) * stof(alpha));
709 else if(hud_configure)
710 alpha = ftos(max(cvar("hud_configure_bg_minalpha"), stof(alpha)));
712 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
715 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
718 return stof(alpha) * menu_fade_alpha;
721 float HUD_Panel_GetFgAlpha(float id)
724 alpha = hud_fg_alpha;
726 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
729 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
732 return alpha * menu_fade_alpha;
735 float HUD_Panel_GetPadding(float id)
738 padding = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
740 padding = cvar_string("hud_bg_padding");
743 mySize = HUD_Panel_GetSize(id);
745 smallestsize = min(mySize_x, mySize_y);
746 return min(smallestsize/2 - 5, stof(padding));
749 // draw the background/borders
750 void HUD_Panel_DrawBg(float id, vector pos, vector mySize, float alpha)
752 if(!hud_configure && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg")) == "0")
756 bg = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg"));
758 bg = cvar_string("hud_bg");
760 if(bg == "0" && hud_configure) {
761 bg = "border"; // we probably want to see a background in config mode at all times...
767 border = max(0.0000001, HUD_Panel_GetBorder(id)); // draw_BorderPicture does not like border = 0
770 color = HUD_Panel_GetColor(id);
773 alpha = HUD_Panel_GetBgAlpha(id) * alpha; // allow panels to fade in/out by passing an alpha value
775 alpha = HUD_Panel_GetBgAlpha(id);
777 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));
781 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
787 pic = strcat("gfx/hud/", cvar_string("hud_skin"), "/");
789 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);
790 if(mySize_y/mySize_x > 2)
791 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);
792 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);
794 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);
795 if(mySize_x/mySize_y > 2)
796 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);
797 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);
801 vector HUD_Panel_GetProgressBarColor(string item)
803 return stov(cvar_string(strcat("hud_progressbar_", item, "_color")));
806 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
807 vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
818 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
819 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
821 for (i = 0; i < HUD_PANEL_NUM; ++i) {
822 if(i == id || !HUD_Panel_CheckActive(i))
825 targPos = HUD_Panel_GetPos(i) - '1 1 0' * HUD_Panel_GetBorder(id);
826 targSize = HUD_Panel_GetSize(i) + '2 2 0' * HUD_Panel_GetBorder(id);
828 if(myPos_y + mySize_y < targPos_y)
830 if(myPos_y > targPos_y + targSize_y)
833 if(myPos_x + mySize_x < targPos_x)
835 if(myPos_x > targPos_x + targSize_x)
838 // OK, there IS a collision.
840 myCenter_x = myPos_x + 0.5 * mySize_x;
841 myCenter_y = myPos_y + 0.5 * mySize_y;
843 targCenter_x = targPos_x + 0.5 * targSize_x;
844 targCenter_y = targPos_y + 0.5 * targSize_y;
846 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
848 if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
849 myTarget_x = targPos_x - mySize_x;
850 else // push it upwards
851 myTarget_y = targPos_y - mySize_y;
853 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
855 if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
856 myTarget_x = targPos_x + targSize_x;
857 else // push it upwards
858 myTarget_y = targPos_y - mySize_y;
860 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
862 if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
863 myTarget_x = targPos_x - mySize_x;
864 else // push it downwards
865 myTarget_y = targPos_y + targSize_y;
867 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
869 if(targPos_x + targSize_x - myPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
870 myTarget_x = targPos_x + targSize_x;
871 else // push it downwards
872 myTarget_y = targPos_y + targSize_y;
879 void HUD_Panel_SetPos(float id, vector pos)
882 oldPos = HUD_Panel_GetPos(id);
885 mySize = HUD_Panel_GetSize(id);
887 if(cvar("hud_configure_checkcollisions"))
888 pos = HUD_Panel_CheckMove(id, pos, mySize);
890 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
891 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
893 if(cvar("hud_configure_grid"))
895 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;
896 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;
900 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
902 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
905 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
906 vector HUD_Panel_CheckResize(float id, vector mySize, vector resizeorigin) {
915 for (i = 0; i < HUD_PANEL_NUM; ++i) {
916 if(i == id || !HUD_Panel_CheckActive(i))
919 targBorder = HUD_Panel_GetBorder(i);
920 targPos = HUD_Panel_GetPos(i) - '1 1 0' * targBorder;
921 targSize = HUD_Panel_GetSize(i) + '2 2 0' * targBorder;
922 targEndPos = targPos + targSize;
924 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
925 if(resizeorigin_x > targPos_x && resizeorigin_x < targPos_x + targSize_x && resizeorigin_y > targPos_y && resizeorigin_y < targPos_y + targSize_y)
928 if (resizeCorner == 1)
930 // check if this panel is on our way
931 if (resizeorigin_x <= targPos_x)
933 if (resizeorigin_y <= targPos_y)
935 if (targEndPos_x <= resizeorigin_x - mySize_x)
937 if (targEndPos_y <= resizeorigin_y - mySize_y)
940 // there is a collision:
941 // detect which side of the panel we are facing is actually limiting the resizing
942 // (which side the resize direction finds for first) and reduce the size up to there
944 // dist is the distance between resizeorigin and the "analogous" point of the panel
945 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
946 dist_x = resizeorigin_x - targEndPos_x;
947 dist_y = resizeorigin_y - targEndPos_y;
949 mySize_x = min(mySize_x, dist_x);
951 mySize_y = min(mySize_y, dist_y);
953 else if (resizeCorner == 2)
955 if (resizeorigin_x >= targEndPos_x)
957 if (resizeorigin_y <= targPos_y)
959 if (targPos_x >= resizeorigin_x + mySize_x)
961 if (targEndPos_y <= resizeorigin_y - mySize_y)
964 dist_x = targPos_x - resizeorigin_x;
965 dist_y = resizeorigin_y - targEndPos_y;
967 mySize_x = min(mySize_x, dist_x);
969 mySize_y = min(mySize_y, dist_y);
971 else if (resizeCorner == 3)
973 if (resizeorigin_x <= targPos_x)
975 if (resizeorigin_y >= targEndPos_y)
977 if (targEndPos_x <= resizeorigin_x - mySize_x)
979 if (targPos_y >= resizeorigin_y + mySize_y)
982 dist_x = resizeorigin_x - targEndPos_x;
983 dist_y = targPos_y - resizeorigin_y;
985 mySize_x = min(mySize_x, dist_x);
987 mySize_y = min(mySize_y, dist_y);
989 else if (resizeCorner == 4)
991 if (resizeorigin_x >= targEndPos_x)
993 if (resizeorigin_y >= targEndPos_y)
995 if (targPos_x >= resizeorigin_x + mySize_x)
997 if (targPos_y >= resizeorigin_y + mySize_y)
1000 dist_x = targPos_x - resizeorigin_x;
1001 dist_y = targPos_y - resizeorigin_y;
1003 mySize_x = min(mySize_x, dist_x);
1005 mySize_y = min(mySize_y, dist_y);
1007 if(cvar("hud_configure_checkcollisions_debug"))
1008 drawfill(targPos + '1 1 0' * targBorder, targSize - '2 2 0' * targBorder, '1 1 0', .3, DRAWFLAG_NORMAL);
1014 void HUD_Panel_SetPosSize(float id)
1016 vector resizeorigin;
1017 resizeorigin = panel_click_resizeorigin;
1018 vector mySize, myPos;
1020 if(resizeCorner == 1) {
1021 mySize_x = resizeorigin_x - (mousepos_x - panel_click_distance_x);
1022 mySize_y = resizeorigin_y - (mousepos_y - panel_click_distance_y);
1023 } else if(resizeCorner == 2) {
1024 mySize_x = mousepos_x + panel_click_distance_x - resizeorigin_x;
1025 mySize_y = panel_click_distance_y + resizeorigin_y - mousepos_y;
1026 } else if(resizeCorner == 3) {
1027 mySize_x = resizeorigin_x + panel_click_distance_x - mousepos_x;
1028 mySize_y = mousepos_y + panel_click_distance_y - resizeorigin_y;
1029 } else { // resizeCorner == 4
1030 mySize_x = mousepos_x - (resizeorigin_x - panel_click_distance_x);
1031 mySize_y = mousepos_y - (resizeorigin_y - panel_click_distance_y);
1034 // minimum panel size cap
1035 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1036 mySize_y = max(0.025 * vid_conheight, mySize_y);
1038 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.
1040 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
1041 mySize_y = max(2 * cvar("con_chatsize") + 2 * HUD_Panel_GetPadding(id), mySize_y);
1044 // collision testing|
1045 // -----------------+
1047 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
1048 if(resizeCorner == 1) {
1049 myPos_x = resizeorigin_x - mySize_x;
1050 myPos_y = resizeorigin_y - mySize_y;
1051 } else if(resizeCorner == 2) {
1052 myPos_x = resizeorigin_x;
1053 myPos_y = resizeorigin_y - mySize_y;
1054 } else if(resizeCorner == 3) {
1055 myPos_x = resizeorigin_x - mySize_x;
1056 myPos_y = resizeorigin_y;
1057 } else { // resizeCorner == 4
1058 myPos_x = resizeorigin_x;
1059 myPos_y = resizeorigin_y;
1062 // left/top screen edges
1064 mySize_x = mySize_x + myPos_x;
1066 mySize_y = mySize_y + myPos_y;
1068 // bottom/right screen edges
1069 if(myPos_x + mySize_x > vid_conwidth)
1070 mySize_x = vid_conwidth - myPos_x;
1071 if(myPos_y + mySize_y > vid_conheight)
1072 mySize_y = vid_conheight - myPos_y;
1074 if(cvar("hud_configure_checkcollisions_debug"))
1075 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
1077 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
1078 if(cvar("hud_configure_grid"))
1080 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;
1081 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;
1084 if(cvar("hud_configure_checkcollisions"))
1086 mySize = HUD_Panel_CheckResize(id, mySize, resizeorigin);
1089 // 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)
1090 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1091 mySize_y = max(0.025 * vid_conheight, mySize_y);
1093 // do another pos check, as size might have changed by now
1094 if(resizeCorner == 1) {
1095 myPos_x = resizeorigin_x - mySize_x;
1096 myPos_y = resizeorigin_y - mySize_y;
1097 } else if(resizeCorner == 2) {
1098 myPos_x = resizeorigin_x;
1099 myPos_y = resizeorigin_y - mySize_y;
1100 } else if(resizeCorner == 3) {
1101 myPos_x = resizeorigin_x - mySize_x;
1102 myPos_y = resizeorigin_y;
1103 } else { // resizeCorner == 4
1104 myPos_x = resizeorigin_x;
1105 myPos_y = resizeorigin_y;
1108 if(cvar("hud_configure_checkcollisions_debug"))
1109 if(cvar("hud_configure_checkcollisions"))
1110 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
1113 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
1114 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_size"), s);
1116 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
1117 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
1121 float prevMouseClicked; // previous state
1122 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
1123 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
1126 float menu_enabled_time;
1127 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1132 // allow console bind to work
1135 con_keys = findkeysforcommand("toggleconsole");
1136 keys = tokenize(con_keys);
1138 float hit_con_bind, i;
1139 for (i = 0; i < keys; ++i)
1141 if(nPrimary == stof(argv(i)))
1145 if(nPrimary == K_MOUSE1)
1147 if(bInputType == 0) { // key pressed
1151 else if(bInputType == 1) {// key released
1156 else if(nPrimary == K_ESCAPE)
1158 disable_menu_alphacheck = 1;
1160 menu_enabled_time = time;
1161 localcmd("menu_showhudexit\n");
1164 else if(hit_con_bind)
1167 return true; // Suppress ALL other input
1170 void HUD_Panel_Mouse()
1172 // 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
1173 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1174 disable_menu_alphacheck = 0;
1175 if (cvar("_menu_alpha") == 0 && time - menu_enabled_time > 0.5)
1179 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1180 print("Highlighted: ", ftos(highlightedPanel), "\n");
1181 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1184 if(mouseClicked == 0 && disable_menu_alphacheck != 2) { // don't reset these variables in disable_menu_alphacheck mode 2!
1185 highlightedPanel = -1;
1186 highlightedAction = 0;
1189 mousepos = mousepos + getmousepos();
1191 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1192 mousepos_y = bound(0, mousepos_y, vid_conheight);
1194 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1202 for(i = 0; i < HUD_PANEL_NUM; ++i)
1204 panelPos = HUD_Panel_GetPos(i);
1205 panelSize = HUD_Panel_GetSize(i);
1206 border = HUD_Panel_GetBorder(i);
1207 if(prevMouseClicked == 0) {
1209 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1211 highlightedPanel = i;
1212 highlightedAction = 1;
1214 // resize from topleft border
1215 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)
1217 highlightedPanel = i;
1218 highlightedAction = 2;
1221 // resize from topright border
1222 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)
1224 highlightedPanel = i;
1225 highlightedAction = 2;
1228 // resize from bottomleft border
1229 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)
1231 highlightedPanel = i;
1232 highlightedAction = 2;
1235 // resize from bottomright border
1236 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)
1238 highlightedPanel = i;
1239 highlightedAction = 2;
1244 if(highlightedPanel == i)
1246 if(prevMouseClicked == 0)
1248 if(highlightedAction == 1)
1249 panel_click_distance = mousepos - panelPos;
1250 else if(highlightedAction == 2)
1252 if(resizeCorner == 1) {
1253 panel_click_distance = mousepos - panelPos;
1254 panel_click_resizeorigin = panelPos + panelSize;
1255 } else if(resizeCorner == 2) {
1256 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1257 panel_click_distance_y = mousepos_y - panelPos_y;
1258 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1259 } else if(resizeCorner == 3) {
1260 panel_click_distance_x = mousepos_x - panelPos_x;
1261 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1262 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1263 } else if(resizeCorner == 4) {
1264 panel_click_distance = panelSize - mousepos + panelPos;
1265 panel_click_resizeorigin = panelPos;
1270 if(cvar("hud_configure_checkcollisions_debug"))
1271 drawfill(panelPos, panelSize, '1 0 0', .3, DRAWFLAG_NORMAL);
1273 if(highlightedAction == 1)
1274 HUD_Panel_SetPos(i, mousepos - panel_click_distance);
1275 else if(highlightedAction == 2)
1276 HUD_Panel_SetPosSize(i);
1280 // doubleclick check
1281 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1283 mouseClicked = 0; // to prevent spam, I guess.
1284 disable_menu_alphacheck = 2;
1286 menu_enabled_time = time;
1287 localcmd("menu_showhudoptions ", ftos(highlightedPanel), "\n");
1290 if(prevMouseClicked == 0)
1292 prevMouseClickedTime = time;
1293 prevMouseClickedPos = mousepos;
1296 prevMouseClicked = mouseClicked;
1299 // Weapon icons (#0)
1301 float weaponspace[10];
1302 void HUD_WeaponIcons_Clear()
1305 for(idx = 0; idx < 10; ++idx)
1306 weaponspace[idx] = 0;
1309 entity weaponorder[WEP_MAXCOUNT];
1311 void weaponorder_swap(float i, float j, entity pass)
1315 weaponorder[i] = weaponorder[j];
1319 string weaponorder_cmp_str;
1320 float weaponorder_cmp(float i, float j, entity pass)
1323 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1324 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1325 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)
1328 void HUD_WeaponIcons(void)
1330 float id = HUD_PANEL_WEAPONICONS;
1331 float alpha, stat_weapons; // "constants"
1332 vector pos, mySize, accuracy_color;
1333 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1335 pos = HUD_Panel_GetPos(id);
1336 mySize = HUD_Panel_GetSize(id);
1338 stat_weapons = getstati(STAT_WEAPONS);
1339 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1341 self = get_weaponinfo(i);
1342 if(self.impulse >= 0)
1344 weaponorder[weapon_cnt] = self;
1349 // TODO make this configurable
1350 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1351 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1353 HUD_Panel_DrawBg(id, pos, mySize, 0);
1355 padding = HUD_Panel_GetPadding(id);
1358 pos += '1 1 0' * padding;
1359 mySize -= '2 2 0' * padding;
1363 weapon_stats = getstati(STAT_DAMAGE_HITS);
1364 weapon_number = weapon_stats & 63;
1365 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1367 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1368 weapon_number = weapon_stats & 63;
1369 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1371 if(cvar_or("hud_weaponicons_fade", 1))
1373 fade = 3.2 - 2 * (time - weapontime);
1374 fade = bound(0.7, fade, 1);
1379 HUD_WeaponIcons_Clear();
1381 float rows, columns;
1382 rows = mySize_y/mySize_x;
1383 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1384 // ^^^ weapon icon aspect goes here
1386 columns = ceil(WEP_COUNT/rows);
1388 for(i = 0; i < weapon_cnt; ++i)
1390 self = weaponorder[i];
1391 weapid = self.impulse;
1393 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1395 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1396 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1398 // draw background behind currently selected weapon
1399 if(self.weapon == activeweapon)
1400 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);
1402 // draw the weapon accuracy on the HUD
1403 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1406 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1408 accuracy_color = HUD_AccuracyColor(weapon_stats);
1410 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);
1413 // draw the weapon icon
1414 if((self.impulse >= 0) && (stat_weapons & self.weapons))
1416 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);
1418 if(cvar_or("hud_weaponicons_number", 1))
1419 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);
1421 // draw a "ghost weapon icon" if you don't have the weapon
1424 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);
1439 float GetAmmoStat(float i)
1443 case 0: return STAT_SHELLS;
1444 case 1: return STAT_NAILS;
1445 case 2: return STAT_ROCKETS;
1446 case 3: return STAT_CELLS;
1447 case 4: return STAT_FUEL;
1452 float GetAmmoItemCode(float i)
1456 case 0: return IT_SHELLS;
1457 case 1: return IT_NAILS;
1458 case 2: return IT_ROCKETS;
1459 case 3: return IT_CELLS;
1460 case 4: return IT_FUEL;
1465 string GetAmmoPicture(float i)
1469 case 0: return "ammo_shells";
1470 case 1: return "ammo_bullets";
1471 case 2: return "ammo_rockets";
1472 case 3: return "ammo_cells";
1473 case 4: return "ammo_fuel";
1478 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1481 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1492 if(currently_selected)
1497 vector newSize, newPos;
1498 if(mySize_x/mySize_y > 3)
1500 newSize_x = 3 * mySize_y;
1501 newSize_y = mySize_y;
1503 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1508 newSize_y = 1/3 * mySize_x;
1509 newSize_x = mySize_x;
1511 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1515 vector picpos, numpos;
1516 if(cvar("hud_inventory_iconalign"))
1519 picpos = newPos + eX * 2 * newSize_y;
1523 numpos = newPos + eX * newSize_y;
1527 if (currently_selected)
1528 drawpic_skin(newPos, "ammo_current_bg", newSize, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_INVENTORY), DRAWFLAG_NORMAL);
1530 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, newSize_y, color, HUD_Panel_GetFgAlpha(HUD_PANEL_INVENTORY) * alpha, DRAWFLAG_NORMAL);
1531 drawpic_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_INVENTORY) * alpha, DRAWFLAG_NORMAL);
1534 void HUD_Inventory(void)
1536 float id = HUD_PANEL_INVENTORY;
1537 float i, currently_selected;
1540 pos = HUD_Panel_GetPos(id);
1541 mySize = HUD_Panel_GetSize(id);
1543 HUD_Panel_DrawBg(id, pos, mySize, 0);
1545 padding = HUD_Panel_GetPadding(id);
1548 pos += '1 1 0' * padding;
1549 mySize -= '2 2 0' * padding;
1552 float rows, columns;
1553 rows = mySize_y/mySize_x;
1554 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1555 // ^^^ ammo item aspect goes here
1557 columns = ceil(AMMO_COUNT/rows);
1561 for (i = 0; i < AMMO_COUNT; ++i) {
1562 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1563 if(cvar("hud_inventory_onlycurrent")) {
1566 if (currently_selected || hud_configure)
1567 DrawAmmoItem(pos, mySize, i, currently_selected);
1570 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);
1575 column = column + 1;
1583 void HUD_Powerups(void) {
1584 float id = HUD_PANEL_POWERUPS;
1586 stat_items = getstati(STAT_ITEMS);
1590 if not(stat_items & IT_STRENGTH)
1591 if not(stat_items & IT_INVINCIBLE)
1594 if (getstati(STAT_HEALTH) <= 0)
1599 pos = HUD_Panel_GetPos(id);
1600 mySize = HUD_Panel_GetSize(id);
1602 HUD_Panel_DrawBg(id, pos, mySize, 0);
1604 padding = HUD_Panel_GetPadding(id);
1607 pos += '1 1 0' * padding;
1608 mySize -= '2 2 0' * padding;
1611 float strength_time, shield_time;
1613 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1614 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 float baralign, iconalign;
1651 baralign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_baralign"));
1652 iconalign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_iconalign"));
1654 if (mySize_x/mySize_y > 4)
1658 if(baralign == 1 || baralign == 3) { // right align
1659 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1660 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1661 } else { // left align
1663 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1666 if(iconalign == 1 || iconalign == 3) { // right align
1667 picpos = pos + eX * (2/6) * mySize_x;
1669 } else { // left align
1671 numpos = pos + eX * (1/6) * mySize_x;
1674 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1676 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));
1678 drawpic_skin(picpos, leftname, eX * (1/6) * mySize_x + eY * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1679 drawstring_aspect(numpos, ftos(leftcnt), eX * (2/6) * mySize_x + eY * mySize_y, mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1684 if(baralign == 0 || baralign == 3) { // left align
1685 barpos = pos + eX * 0.5 * mySize_x;
1686 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1687 } else { // right align
1688 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1689 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1692 if(iconalign == 0 || iconalign == 3) { // left align
1693 picpos = pos + eX * (3/6) * mySize_x;
1694 numpos = pos + eX * (4/6) * mySize_x;
1695 } else { // right align
1696 picpos = pos + eX * (5/6) * mySize_x;
1697 numpos = pos + eX * (3/6) * mySize_x;
1700 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1702 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));
1704 drawpic_skin(picpos, rightname, eX * (1/6) * mySize_x + eY * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1705 drawstring_aspect(numpos, ftos(rightcnt), eX * (2/6) * mySize_x + eY * mySize_y, mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1708 else if (mySize_x/mySize_y > 1.5)
1712 if(baralign == 1 || baralign == 3) { // right align
1713 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1714 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1715 } else { // left align
1717 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1720 if(iconalign == 1 || iconalign == 3) { // right align
1721 picpos = pos + eX * (2/3) * mySize_x;
1723 } else { // left align
1725 numpos = pos + eX * (1/3) * mySize_x;
1728 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1730 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));
1732 drawpic_skin(picpos, leftname, eX * (1/3) * mySize_x + eY * 0.5 * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1733 drawstring_aspect(numpos, ftos(leftcnt), eX * (2/3) * mySize_x + eY * 0.5 * mySize_y, mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1738 if(baralign == 0 || baralign == 3) { // left align
1739 barpos = pos + eY * 0.5 * mySize_y;
1740 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1741 } else { // right align
1742 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1743 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1746 if(iconalign == 0 || iconalign == 3) { // left align
1747 picpos = pos + eY * 0.5 * mySize_y;
1748 numpos = pos + eX * (1/3) * mySize_x + eY * 0.5 * mySize_y;
1749 } else { // right align
1750 picpos = pos + eX * (2/3) * mySize_x + eY * 0.5 * mySize_y;
1751 numpos = pos + eY * 0.5 * mySize_y;
1754 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1756 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));
1758 drawpic_skin(picpos, rightname, eX * (1/3) * mySize_x + eY * 0.5 * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1759 drawstring_aspect(numpos, ftos(rightcnt), eX * (2/3) * mySize_x + eY * 0.5 * mySize_y, mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1766 if(baralign == 1 || baralign == 3) { // down align
1767 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1768 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1769 } else { // up align
1771 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1774 if(iconalign == 1 || iconalign == 3) { // down align
1775 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
1776 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
1777 } else { // up align
1778 picpos = pos + eX * 0.05 * mySize_x;
1779 numpos = pos + eY * 0.4 * mySize_x;
1782 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1784 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));
1786 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1787 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, 0.25 * mySize_x, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1792 if(baralign == 0 || baralign == 3) { // up align
1793 barpos = pos + eX * 0.5 * mySize_x;
1794 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1795 } else { // down align
1796 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1797 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1800 if(iconalign == 0 || iconalign == 3) { // up align
1801 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1802 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1803 } else { // down align
1804 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
1805 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
1808 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1810 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));
1812 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1813 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, 0.25 * mySize_x, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1818 // Health/armor (#3)
1820 void HUD_HealthArmor(void)
1822 float id = HUD_PANEL_HEALTHARMOR;
1824 pos = HUD_Panel_GetPos(id);
1825 mySize = HUD_Panel_GetSize(id);
1827 HUD_Panel_DrawBg(id, pos, mySize, 0);
1829 padding = HUD_Panel_GetPadding(id);
1832 pos += '1 1 0' * padding;
1833 mySize -= '2 2 0' * padding;
1836 float armor, health;
1837 armor = getstati(STAT_ARMOR);
1838 health = getstati(STAT_HEALTH);
1841 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
1853 vector barpos, barsize;
1857 if(cvar("hud_healtharmor") == 2) // combined health and armor display
1860 v = healtharmor_maxdamage(health, armor, armorblockpercent);
1865 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1866 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
1867 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
1869 numpos = picpos + eX * 1.5 * mySize_y;
1872 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
1873 picpos = pos + eX * 3 * mySize_y;
1877 if(v_z) // NOT fully armored
1879 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("health"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1880 drawpic_skin(picpos, "health", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1882 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);
1886 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("armor"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1887 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);
1889 drawpic_skin(picpos, "armor", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1891 //HUD_DrawXNum_Colored(numpos, x, 3, mySize_y, HUD_Panel_GetFgAlpha(id)); // draw the combined health and armor
1894 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1895 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
1896 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
1899 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
1902 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
1906 string leftname, rightname;
1907 float leftcnt, rightcnt;
1908 float leftactive, rightactive;
1909 float leftalpha, rightalpha;
1910 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) { // old style layout with armor left/top of health
1915 leftalpha = min((armor+10)/55, 1);
1917 rightname = "health";
1922 leftname = "health";
1927 rightname = "armor";
1931 rightalpha = min((armor+10)/55, 1);
1934 float baralign, iconalign;
1935 baralign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_baralign"));
1936 iconalign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_iconalign"));
1938 if (mySize_x/mySize_y > 5)
1942 if(baralign == 1 || baralign == 3) { // right align
1943 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
1944 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
1945 } else { // left align
1947 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
1950 if(iconalign == 1 || iconalign == 3) { // right align
1951 picpos = pos + eX * (2/6) * mySize_x;
1953 } else { // left align
1955 numpos = pos + eX * (1/6) * mySize_x;
1958 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1959 drawpic_skin(picpos, leftname, eX * (1/6) * mySize_x + eY * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1960 drawstring_aspect(numpos, ftos(leftcnt), eX * (2/6) * mySize_x + eY * mySize_y, mySize_y, HUD_Get_Num_Color(leftcnt, 200), HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1965 if(baralign == 0 || baralign == 3) { // left align
1966 barpos = pos + eX * 0.5 * mySize_x;
1967 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
1968 } else { // right align
1969 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
1970 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
1973 if(iconalign == 0 || iconalign == 3) { // left align
1974 picpos = pos + eX * (3/6) * mySize_x;
1975 numpos = pos + eX * (4/6) * mySize_x;
1976 } else { // right align
1977 picpos = pos + eX * (5/6) * mySize_x;
1978 numpos = pos + eX * (3/6) * mySize_x;
1981 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1982 drawpic_skin(picpos, rightname, eX * (1/6) * mySize_x + eY * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1983 drawstring_aspect(numpos, ftos(rightcnt), eX * (2/6) * mySize_x + eY * mySize_y, mySize_y, HUD_Get_Num_Color(rightcnt, 200), HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1988 if(baralign == 0 || baralign == 3) { // left align
1989 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
1990 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
1993 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
1995 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
1998 else if (mySize_x/mySize_y > 2)
2002 if(baralign == 1 || baralign == 3) { // right align
2003 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2004 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2005 } else { // left align
2007 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2010 if(iconalign == 1 || iconalign == 3) { // right align
2011 picpos = pos + eX * (2/3) * mySize_x;
2013 } else { // left align
2015 numpos = pos + eX * (1/3) * mySize_x;
2018 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2019 drawpic_skin(picpos, leftname, eX * (1/3) * mySize_x + eY * 0.5 * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2020 drawstring_aspect(numpos, ftos(leftcnt), eX * (2/3) * mySize_x + eY * 0.5 * mySize_y, mySize_y, HUD_Get_Num_Color(leftcnt, 200), HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2025 if(baralign == 0 || baralign == 3) { // left align
2026 barpos = pos + eY * 0.5 * mySize_y;
2027 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2028 } else { // right align
2029 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2030 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2033 if(iconalign == 0 || iconalign == 3) { // left align
2034 picpos = pos + eY * 0.5 * mySize_y;
2035 numpos = pos + eX * (1/3) * mySize_x + eY * 0.5 * mySize_y;
2036 } else { // right align
2037 picpos = pos + eX * (2/3) * mySize_x + eY * 0.5 * mySize_y;
2038 numpos = pos + eY * 0.5 * mySize_y;
2041 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2042 drawpic_skin(picpos, rightname, eX * (1/3) * mySize_x + eY * 0.5 * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2043 drawstring_aspect(numpos, ftos(rightcnt), eX * (2/3) * mySize_x + eY * 0.5 * mySize_y, mySize_y, HUD_Get_Num_Color(rightcnt, 200), HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2048 if(baralign == 0 || baralign == 3) { // left align
2049 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2050 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2053 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2055 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2062 if(baralign == 1 || baralign == 3) { // down align
2063 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2064 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2065 } else { // up align
2067 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2070 if(iconalign == 1 || iconalign == 3) { // down align
2071 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2072 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2073 } else { // up align
2074 picpos = pos + eX * 0.05 * mySize_x;
2075 numpos = pos + eY * 0.4 * mySize_x;
2078 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2079 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2080 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, 0.25 * mySize_x, HUD_Get_Num_Color(leftcnt, 200), HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2085 if(baralign == 0 || baralign == 3) { // up align
2086 barpos = pos + eX * 0.5 * mySize_x;
2087 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2088 } else { // down align
2089 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2090 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2093 if(iconalign == 0 || iconalign == 3) { // up align
2094 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2095 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2096 } else { // down align
2097 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2098 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2101 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2102 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2103 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, 0.25 * mySize_x, HUD_Get_Num_Color(rightcnt, 200), HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2108 if(baralign == 0 || baralign == 3) { // left align
2110 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2112 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2113 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2115 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2122 // Notification area (#4)
2125 string Weapon_SuicideMessage(float deathtype)
2127 w_deathtype = deathtype;
2128 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2129 return w_deathtypestring;
2132 string Weapon_KillMessage(float deathtype)
2134 w_deathtype = deathtype;
2135 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2136 return w_deathtypestring;
2139 float killnotify_times[10];
2140 float killnotify_deathtype[10];
2141 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2142 string killnotify_attackers[10];
2143 string killnotify_victims[10];
2144 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2147 for (i = 9; i > 0; --i) {
2148 killnotify_times[i] = killnotify_times[i-1];
2149 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2150 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2151 if(killnotify_attackers[i])
2152 strunzone(killnotify_attackers[i]);
2153 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2154 if(killnotify_victims[i])
2155 strunzone(killnotify_victims[i]);
2156 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2158 killnotify_times[0] = time;
2159 killnotify_deathtype[0] = wpn;
2160 killnotify_actiontype[0] = actiontype;
2161 if(killnotify_attackers[0])
2162 strunzone(killnotify_attackers[0]);
2163 killnotify_attackers[0] = strzone(attacker);
2164 if(killnotify_victims[0])
2165 strunzone(killnotify_victims[0]);
2166 killnotify_victims[0] = strzone(victim);
2169 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2173 alsoprint = (cvar("hud_notify_print") || !HUD_Panel_CheckActive(4)); // print message to console if: notify panel disabled, or cvar to do so enabled
2175 if(msg == MSG_SUICIDE) {
2177 w = DEATH_WEAPONOF(type);
2179 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2181 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2182 } else if (type == DEATH_KILL) {
2183 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2185 print ("^1",s1, "^1 couldn't take it anymore\n");
2186 } else if (type == DEATH_ROT) {
2187 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2189 print ("^1",s1, "^1 died\n");
2190 } else if (type == DEATH_NOAMMO) {
2191 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2193 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2194 } else if (type == DEATH_CAMP) {
2195 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2197 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2198 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2199 HUD_KillNotify_Push(s1, "", 0, type);
2201 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2202 } else if (type == DEATH_CHEAT) {
2203 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2205 print ("^1",s1, "^1 unfairly eliminated themself\n");
2206 } else if (type == DEATH_FIRE) {
2207 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2209 print ("^1",s1, "^1 burned to death\n");
2210 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2211 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2213 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2216 if (stof(s2) > 2) // killcount > 2
2217 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2218 } else if(msg == MSG_KILL) {
2219 w = DEATH_WEAPONOF(type);
2221 HUD_KillNotify_Push(s2, s1, 1, w);
2223 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2225 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2226 HUD_KillNotify_Push(s1, s2, 1, type);
2229 if(cvar("cl_gentle")) {
2230 print ("^1", s1, "^1 took action against a team mate\n");
2232 print ("^1", s1, "^1 mows down a team mate\n");
2235 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2236 if(cvar("cl_gentle"))
2237 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2239 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2241 else if (stof(s2) > 2) {
2242 if(cvar("cl_gentle"))
2243 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2245 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2248 else if(type == KILL_FIRST_BLOOD)
2249 print("^1",s1, "^1 drew first blood", "\n");
2251 else if (type == DEATH_TELEFRAG)
2252 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2253 else if (type == DEATH_DROWN) {
2254 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2256 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2258 else if (type == DEATH_SLIME) {
2259 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2261 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2263 else if (type == DEATH_LAVA) {
2264 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2266 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2268 else if (type == DEATH_FALL) {
2269 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2271 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2273 else if (type == DEATH_SHOOTING_STAR) {
2274 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2276 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2278 else if (type == DEATH_SWAMP) {
2279 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2281 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2283 else if (type == DEATH_HURTTRIGGER)
2285 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2287 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2288 } else if(type == DEATH_SBCRUSH) {
2289 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2291 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2292 } else if(type == DEATH_SBMINIGUN) {
2293 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2295 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2296 } else if(type == DEATH_SBROCKET) {
2297 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2299 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2300 } else if(type == DEATH_SBBLOWUP) {
2301 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2303 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2304 } else if(type == DEATH_WAKIGUN) {
2305 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2307 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2308 } else if(type == DEATH_WAKIROCKET) {
2309 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2311 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2312 } else if(type == DEATH_WAKIBLOWUP) {
2313 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2315 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2316 } else if(type == DEATH_TURRET) {
2317 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2319 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2320 } else if(type == DEATH_TOUCHEXPLODE) {
2321 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2323 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2324 } else if(type == DEATH_CHEAT) {
2325 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2327 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2328 } else if (type == DEATH_FIRE) {
2329 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2331 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2332 } else if (type == DEATH_CUSTOM) {
2333 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2335 print ("^1",s1, "^1 ", s2, "\n");
2337 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2339 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2341 } else if(msg == MSG_SPREE) {
2342 if(type == KILL_END_SPREE) {
2343 if(cvar("cl_gentle"))
2344 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2346 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2347 } else if(type == KILL_SPREE) {
2348 if(cvar("cl_gentle"))
2349 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2351 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2352 } else if(type == KILL_SPREE_3) {
2353 if(cvar("cl_gentle"))
2354 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2356 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2357 } else if(type == KILL_SPREE_5) {
2358 if(cvar("cl_gentle"))
2359 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2361 print (s1,"^7 unleashes ^1RAGE\n");
2362 } else if(type == KILL_SPREE_10) {
2363 if(cvar("cl_gentle"))
2364 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2366 print (s1,"^7 starts the ^1MASSACRE!\n");
2367 } else if(type == KILL_SPREE_15) {
2368 if(cvar("cl_gentle"))
2369 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2371 print (s1,"^7 executes ^1MAYHEM!\n");
2372 } else if(type == KILL_SPREE_20) {
2373 if(cvar("cl_gentle"))
2374 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2376 print (s1,"^7 is a ^1BERSERKER!\n");
2377 } else if(type == KILL_SPREE_25) {
2378 if(cvar("cl_gentle"))
2379 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2381 print (s1,"^7 inflicts ^1CARNAGE!\n");
2382 } else if(type == KILL_SPREE_30) {
2383 if(cvar("cl_gentle"))
2384 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2386 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2388 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2389 if (type == DEATH_DROWN) {
2390 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2393 if(cvar("cl_gentle"))
2394 print ("^1",s1, "^1 was in the water for too long\n");
2396 print ("^1",s1, "^1 drowned\n");
2398 } else if (type == DEATH_SLIME) {
2399 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2401 print ("^1",s1, "^1 was slimed\n");
2402 } else if (type == DEATH_LAVA) {
2403 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2406 if(cvar("cl_gentle"))
2407 print ("^1",s1, "^1 found a hot place\n");
2409 print ("^1",s1, "^1 turned into hot slag\n");
2411 } else if (type == DEATH_FALL) {
2412 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2415 if(cvar("cl_gentle"))
2416 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2418 print ("^1",s1, "^1 hit the ground with a crunch\n");
2420 } else if (type == DEATH_SHOOTING_STAR) {
2421 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2423 print ("^1",s1, "^1 became a shooting star\n");
2424 } else if (type == DEATH_SWAMP) {
2425 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2428 if(cvar("cl_gentle"))
2429 print ("^1",s1, "^1 discovered a swamp\n");
2431 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2433 } else if(type == DEATH_TURRET) {
2434 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2436 print ("^1",s1, "^1 was mowed down by a turret \n");
2437 } else if (type == DEATH_CUSTOM) {
2438 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2440 print ("^1",s1, "^1 ", s2, "\n");
2441 } else if (type == DEATH_HURTTRIGGER) {
2442 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2444 print ("^1",s1, "^1 was in the wrong place\n");
2445 } else if(type == DEATH_TOUCHEXPLODE) {
2446 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2448 print ("^1",s1, "^1 died in an accident\n");
2449 } else if(type == DEATH_CHEAT) {
2450 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2452 print ("^1",s1, "^1 was unfairly eliminated\n");
2453 } else if(type == DEATH_FIRE) {
2454 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2457 if(cvar("cl_gentle"))
2458 print ("^1",s1, "^1 felt a little hot\n");
2460 print ("^1",s1, "^1 burnt to death\n");
2463 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2466 if(cvar("cl_gentle"))
2467 print ("^1",s1, "^1 needs a restart\n");
2469 print ("^1",s1, "^1 died\n");
2472 } else if(msg == MSG_KILL_ACTION_SPREE) {
2473 if(cvar("cl_gentle"))
2474 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2476 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2477 } else if(msg == MSG_INFO) {
2478 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2479 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2480 print(s1, "^7 got the ", s2, "\n");
2481 } else if(type == INFO_LOSTFLAG) {
2482 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2483 print(s1, "^7 lost the ", s2, "\n");
2484 } else if(type == INFO_PICKUPFLAG) {
2485 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2486 print(s1, "^7 picked up the ", s2, "\n");
2487 } else if(type == INFO_RETURNFLAG) {
2488 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2489 print(s1, "^7 returned the ", s2, "\n");
2494 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2496 void HUD_Centerprint(string s1, string s2, float type, float msg)
2498 if(msg == MSG_SUICIDE) {
2499 if (type == DEATH_TEAMCHANGE) {
2500 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2501 } else if (type == DEATH_AUTOTEAMCHANGE) {
2502 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2503 } else if (type == DEATH_CAMP) {
2504 if(cvar("cl_gentle"))
2505 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2507 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2508 } else if (type == DEATH_NOAMMO) {
2509 if(cvar("cl_gentle"))
2510 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2512 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2513 } else if (type == DEATH_ROT) {
2514 if(cvar("cl_gentle"))
2515 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2517 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2518 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2519 if(cvar("cl_gentle"))
2520 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2522 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2523 } else if (type == DEATH_QUIET) {
2525 } else if (type == DEATH_KILL) {
2526 if(cvar("cl_gentle"))
2527 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2529 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2531 } else if(msg == MSG_KILL) {
2532 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2533 if(cvar("cl_gentle")) {
2534 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2536 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2538 } else if (type == KILL_FIRST_BLOOD) {
2539 if(cvar("cl_gentle")) {
2540 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2542 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2544 } else if (type == KILL_FIRST_VICTIM) {
2545 if(cvar("cl_gentle")) {
2546 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2548 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2550 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2551 if(cvar("cl_gentle")) {
2552 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2554 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2556 } else if (type == KILL_TYPEFRAGGED) {
2557 if(cvar("cl_gentle")) {
2558 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2560 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2562 } else if (type == KILL_FRAG) {
2563 if(cvar("cl_gentle")) {
2564 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2566 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2568 } else if (type == KILL_FRAGGED) {
2569 if(cvar("cl_gentle")) {
2570 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2572 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2575 } else if(msg == MSG_KILL_ACTION) {
2576 // TODO: invent more centerprints here?
2577 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2581 void HUD_Notify (void)
2583 float id = HUD_PANEL_NOTIFY;
2585 pos = HUD_Panel_GetPos(id);
2586 mySize = HUD_Panel_GetSize(id);
2588 HUD_Panel_DrawBg(id, pos, mySize, 0);
2590 padding = HUD_Panel_GetPadding(id);
2593 pos += '1 1 0' * padding;
2594 mySize -= '2 2 0' * padding;
2597 float entries, height;
2598 entries = bound(1, floor(14 * mySize_y/mySize_x), 12);
2599 height = mySize_y/entries;
2600 entries -= 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2603 fontsize = '0.5 0.5 0' * height;
2607 when = cvar("hud_notify_time");
2609 fadetime = cvar("hud_notify_fadetime");
2613 vector pos_attacker, pos_victim;
2615 float width_attacker, width_victim;
2616 string attacker, victim;
2619 for(j = 0; j < entries; ++j)
2621 if(cvar("hud_notify_flip"))
2623 else // rather nasty hack for ordering items from the bottom up
2624 i = entries - j - 1;
2625 if(cvar("hud_notify_info_top"))
2626 i += 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2630 if(killnotify_times[j] + when > time)
2633 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2637 if(killnotify_times[j] + when > time)
2643 // TODO: maybe print in team colors?
2644 // TODO: maybe this could be cleaned up somehow...
2645 // TODO: less copypaste code below
2648 if(killnotify_actiontype[j] == 0 && !hud_configure)
2650 attacker = textShortenToWidth(killnotify_attackers[j], mySize_x - 2 * height, fontsize, stringwidth_colors);
2652 width_attacker = stringwidth(attacker, TRUE, fontsize);
2653 pos_attacker = pos + eX * 0.5 * (mySize_x - width_attacker + 2 * height) + eY * 0.5 * fontsize_y + eY * i * height;
2655 weap_pos = pos + eX * 0.5 * (mySize_x - width_attacker) - eX * height + eY * i * height;
2656 if(killnotify_deathtype[j] == DEATH_GENERIC)
2658 drawpic_skin(weap_pos, "notify_death", '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_NOAMMO)
2663 drawpic_skin(weap_pos, "notify_outofammo", '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_KILL)
2668 drawpic_skin(weap_pos, "notify_selfkill", '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_CAMP)
2673 drawpic_skin(weap_pos, "notify_camping", '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] == KILL_TEAM_RED)
2678 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', 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] == KILL_TEAM_BLUE)
2683 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2684 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2686 else if(killnotify_deathtype[j] == DEATH_DROWN)
2688 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2689 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2691 else if(killnotify_deathtype[j] == DEATH_SLIME)
2693 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2694 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2696 else if(killnotify_deathtype[j] == DEATH_LAVA)
2698 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2699 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2701 else if(killnotify_deathtype[j] == DEATH_FALL)
2703 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2704 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2706 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2708 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2709 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2711 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2713 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2714 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2716 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2718 if(killnotify_victims[j] == "^1RED^7 flag")
2722 drawpic_skin(weap_pos, strcat("flag_", s, "_carrying"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2723 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2725 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2727 if(killnotify_victims[j] == "^1RED^7 flag")
2731 drawpic_skin(weap_pos, strcat("flag_", s, "_taken"), '1 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);
2734 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2736 if(killnotify_victims[j] == "^1RED^7 flag")
2740 drawpic_skin(weap_pos, strcat("flag_", s, "_lost"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2741 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2744 // X [did action to] Y
2749 attacker = textShortenToWidth("Player1", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2750 victim = textShortenToWidth("Player2", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2751 a = bound(0, (when - j) / 4, 1);
2755 attacker = textShortenToWidth(killnotify_attackers[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2756 victim = textShortenToWidth(killnotify_victims[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2758 width_attacker = stringwidth(attacker, TRUE, fontsize);
2759 width_victim = stringwidth(victim, TRUE, fontsize);
2760 pos_attacker = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_attacker) + eY * 0.5 * fontsize_y + eY * i * height;
2761 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;
2762 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2764 if(hud_configure) // example actions for config mode
2766 drawpic_skin(weap_pos, strcat("weapon", "electro"), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2767 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2768 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2770 else if(WEP_VALID(killnotify_deathtype[j]))
2772 self = get_weaponinfo(killnotify_deathtype[j]);
2773 drawpic_skin(weap_pos, strcat("weapon", self.netname), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2774 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2775 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2777 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2779 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2780 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2781 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2783 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2785 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2786 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2787 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2789 else if(killnotify_deathtype[j] == DEATH_DROWN)
2791 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2792 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2793 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2795 else if(killnotify_deathtype[j] == DEATH_SLIME)
2797 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2798 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2799 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2801 else if(killnotify_deathtype[j] == DEATH_LAVA)
2803 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2804 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2805 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2807 else if(killnotify_deathtype[j] == DEATH_FALL)
2809 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2810 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2811 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2813 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2815 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2816 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2817 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2819 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2821 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2822 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2823 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2834 if(cvar("hud_notify_info_top"))
2837 o = pos + eY * mySize_y - eY * 2 * height;
2839 if(spectatee_status && !intermission)
2841 //drawfont = hud_bigfont;
2842 if(spectatee_status == -1)
2845 s = GetPlayerName(spectatee_status - 1);
2847 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
2848 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2849 //drawfont = hud_font;
2851 // spectator text in the upper right corner
2852 if(spectatee_status == -1)
2853 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
2855 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
2856 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2857 o += eY * fontsize_y;
2859 if(spectatee_status == -1)
2860 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
2862 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
2863 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2864 o += eY * fontsize_y;
2866 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
2867 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2868 o += eY * fontsize_y;
2870 if(gametype == GAME_ARENA)
2871 s = "^1Wait for your turn to join";
2872 else if(gametype == GAME_LMS)
2875 sk = playerslots[player_localentnum - 1];
2876 if(sk.(scores[ps_primary]) >= 666)
2877 s = "^1Match has already begun";
2878 else if(sk.(scores[ps_primary]) > 0)
2879 s = "^1You have no more lives left";
2881 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
2884 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
2885 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2886 o += eY * fontsize_y;
2888 //show restart countdown:
2889 if (time < getstatf(STAT_GAMESTARTTIME)) {
2891 //we need to ceil, otherwise the countdown would be off by .5 when using round()
2892 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
2893 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
2894 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2895 o += eY * fontsize_y;
2898 if(warmup_stage && !intermission)
2900 s = "^2Currently in ^1warmup^2 stage!";
2901 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2902 o += eY * fontsize_y;
2906 if(mod(time, 1) >= 0.5)
2911 if(ready_waiting && !intermission && !spectatee_status)
2913 if(ready_waiting_for_me)
2916 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
2918 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
2923 s = strcat("^2Waiting for others to ready up to end warmup...");
2925 s = strcat("^2Waiting for others to ready up...");
2927 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2928 o += eY * fontsize_y;
2930 else if(warmup_stage && !intermission && !spectatee_status)
2932 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
2933 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2934 o += eY * fontsize_y;
2937 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
2939 float ts_min, ts_max;
2940 tm = teams.sort_next;
2943 for(; tm.sort_next; tm = tm.sort_next)
2945 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
2947 if(!ts_min) ts_min = tm.team_size;
2948 else ts_min = min(ts_min, tm.team_size);
2949 if(!ts_max) ts_max = tm.team_size;
2950 else ts_max = max(ts_max, tm.team_size);
2952 if ((ts_max - ts_min) > 1)
2954 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
2955 tm = GetTeam(myteam, false);
2957 if (tm.team != COLOR_SPECTATOR)
2958 if (tm.team_size == ts_max)
2959 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
2961 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2962 o += eY * fontsize_y;
2968 s = "^7Press ^3ESC ^7to show HUD options.";
2969 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2970 o += eY * fontsize_y;
2971 s = "^3Doubleclick a panel for panel-specific options.";
2972 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2973 o += eY * fontsize_y;
2979 string seconds_tostring(float sec)
2982 minutes = floor(sec / 60);
2984 sec -= minutes * 60;
2987 s = ftos(100 + sec);
2989 return strcat(ftos(minutes), ":", substring(s, 1, 3));
2992 void HUD_Timer(void)
2994 float id = HUD_PANEL_TIMER;
2996 pos = HUD_Panel_GetPos(id);
2997 mySize = HUD_Panel_GetSize(id);
2999 HUD_Panel_DrawBg(id, pos, mySize, 0);
3001 padding = HUD_Panel_GetPadding(id);
3004 pos += '1 1 0' * padding;
3005 mySize -= '2 2 0' * padding;
3009 float timelimit, elapsedTime, timeleft, minutesLeft;
3011 timelimit = getstatf(STAT_TIMELIMIT);
3013 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3014 timeleft = ceil(timeleft);
3016 minutesLeft = floor(timeleft / 60);
3019 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3020 timer_color = '1 1 1'; //white
3021 else if(minutesLeft >= 1)
3022 timer_color = '1 1 0'; //yellow
3024 timer_color = '1 0 0'; //red
3026 if (cvar("hud_timer_increment") || timelimit == 0 || warmup_stage) {
3027 if (time < getstatf(STAT_GAMESTARTTIME)) {
3028 //while restart is still active, show 00:00
3029 timer = seconds_tostring(0);
3031 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3032 timer = seconds_tostring(elapsedTime);
3035 timer = seconds_tostring(timeleft);
3038 drawstring_aspect(pos, timer, mySize, mySize_y, timer_color, HUD_Panel_GetFgAlpha(HUD_PANEL_TIMER), DRAWFLAG_NORMAL);
3043 void HUD_Radar(void)
3045 float id = HUD_PANEL_RADAR;
3047 pos = HUD_Panel_GetPos(id);
3048 mySize = HUD_Panel_GetSize(id);
3050 HUD_Panel_DrawBg(id, pos, mySize, 0);
3052 padding = HUD_Panel_GetPadding(id);
3055 pos += '1 1 0' * padding;
3056 mySize -= '2 2 0' * padding;
3059 local float color1, color2; // color already declared as a global in hud.qc
3062 float scale2d, normalsize, bigsize;
3065 teamradar_origin2d = pos + 0.5 * mySize;
3066 teamradar_size2d = mySize;
3068 if(minimapname == "")
3071 teamradar_loadcvars();
3073 switch(hud_radar_zoommode)
3077 f = current_zoomfraction;
3080 f = 1 - current_zoomfraction;
3090 switch(hud_radar_rotation)
3093 teamradar_angle = view_angles_y - 90;
3096 teamradar_angle = 90 * hud_radar_rotation;
3100 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3101 teamradar_size2d = mySize;
3103 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3105 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3106 if(hud_radar_rotation == 0)
3108 // max-min distance must fit the radar in any rotation
3109 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3113 vector c0, c1, c2, c3, span;
3114 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3115 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3116 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3117 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3119 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3120 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3122 // max-min distance must fit the radar in x=x, y=y
3124 teamradar_size2d_x * scale2d / (1.05 * span_x),
3125 teamradar_size2d_y * scale2d / (1.05 * span_y)
3129 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3130 if(bigsize > normalsize)
3131 normalsize = bigsize;
3135 + (1 - f) * normalsize;
3136 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3137 f * (mi_min + mi_max) * 0.5
3138 + (1 - f) * view_origin);
3140 color1 = GetPlayerColor(player_localentnum-1);
3141 rgb = GetTeamRGB(color1);
3150 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3152 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3153 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3154 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3155 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, HUD_Panel_GetFgAlpha(id));
3156 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3158 color2 = GetPlayerColor(tm.sv_entnum);
3159 //if(color == COLOR_SPECTATOR || color == color2)
3160 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3162 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3164 drawresetcliparea();
3169 void HUD_Score(void)
3171 float id = HUD_PANEL_SCORE;
3173 pos = HUD_Panel_GetPos(id);
3174 mySize = HUD_Panel_GetSize(id);
3176 HUD_Panel_DrawBg(id, pos, mySize, 0);
3178 padding = HUD_Panel_GetPadding(id);
3181 pos += '1 1 0' * padding;
3182 mySize -= '2 2 0' * padding;
3185 float score, distribution, leader;
3187 vector distribution_color;
3189 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3191 // TODO... this (race part) still uses constant coordinates :/
3192 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3193 /*pl = players.sort_next;
3196 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3197 if(pl.scores[ps_primary] == 0)
3200 score = me.(scores[ps_primary]);
3202 float racemin, racesec, racemsec;
3203 float distsec, distmsec, minusplus;
3205 racemin = floor(score/(60 * TIME_FACTOR));
3206 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
3207 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
3209 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3210 // distribution display
3211 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3213 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
3214 distmsec = fabs(distribution);
3216 distsec = floor(fabs(distribution)/TIME_FACTOR);
3217 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
3218 if (distribution < 0)
3222 if (distribution <= 0) {
3223 distribution_color = eY;
3224 minusplus = 1; // minusplus 1: always prefix with minus sign
3227 distribution_color = eX;
3228 minusplus = 2; // minusplus 1: always prefix with plus sign
3230 //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);
3231 //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);
3232 drawpic_skin(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "num_dot", '16 16 0', distribution_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE);
3234 // race record display
3235 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
3236 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);
3238 //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);
3239 //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);
3240 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);
3242 //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);
3243 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);
3245 } else if (!teamplay) { // non-teamgames
3246 // me vector := [team/connected frags id]
3247 pl = players.sort_next;
3254 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3258 score = me.(scores[ps_primary]);
3262 if(distribution >= 5) {
3263 distribution_color = eY;
3265 } else if(distribution >= 0) {
3266 distribution_color = '1 1 1';
3268 } else if(distribution >= -5)
3269 distribution_color = '1 1 0';
3271 distribution_color = eX;
3273 score_len = strlen(ftos(score));
3275 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);
3277 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);
3278 drawfont = hud_bigfont;
3279 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, mySize_y, distribution_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3280 drawfont = hud_font;
3281 } else { // teamgames
3282 float max_fragcount;
3283 max_fragcount = -99;
3286 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3287 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !hud_configure)) // no players? don't display
3289 score = tm.(teamscores[ts_primary]);
3294 score_len = strlen(ftos(score));
3296 if (score > max_fragcount)
3297 max_fragcount = score;
3299 if(tm.team == myteam) {
3300 if (max_fragcount == score)
3303 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);
3304 drawfont = hud_bigfont;
3305 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);
3306 drawfont = hud_font;
3308 if (max_fragcount == score)
3311 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);
3312 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);
3321 void HUD_RaceTimer (void) {
3322 float id = HUD_PANEL_RACETIMER;
3324 pos = HUD_Panel_GetPos(id);
3325 mySize = HUD_Panel_GetSize(id);
3327 HUD_Panel_DrawBg(id, pos, mySize, 0);
3329 padding = HUD_Panel_GetPadding(id);
3332 pos += '1 1 0' * padding;
3333 mySize -= '2 2 0' * padding;
3336 drawfont = hud_bigfont;
3338 string s, forcetime;
3343 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);
3344 s = "^1Intermediate 1 (+15.42)";
3345 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);
3346 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3347 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);
3349 else if(race_checkpointtime)
3351 a = bound(0, 2 - (time - race_checkpointtime), 1);
3354 if(a > 0) // just hit a checkpoint?
3356 if(race_checkpoint != 254)
3358 if(race_time && race_previousbesttime)
3359 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3361 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3363 forcetime = TIME_ENCODED_TOSTRING(race_time);
3368 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3370 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3371 if(a > 0) // next one?
3373 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3378 if(s != "" && a > 0)
3380 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3381 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3382 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);
3385 if(race_penaltytime)
3387 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3390 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3391 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3392 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3393 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);
3399 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3400 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id), 0, a);
3401 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);
3406 if(race_laptime && race_checkpoint != 255)
3408 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3409 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3410 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);
3415 if(race_mycheckpointtime)
3417 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3418 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3419 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3420 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3421 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);
3423 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3425 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3426 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3427 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3428 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3429 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);
3432 if(race_penaltytime && !race_penaltyaccumulator)
3434 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3435 a = bound(0, (1 + t - time), 1);
3439 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3441 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3442 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3443 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3444 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);
3449 drawfont = hud_font;
3454 float vote_yescount;
3457 float vote_highlighted; // currently selected vote
3459 float vote_active; // is there an active vote?
3460 float vote_prev; // previous state of vote_active to check for a change
3462 float vote_change; // "time" when vote_active changed
3464 void HUD_VoteWindow(void)
3466 float id = HUD_PANEL_VOTE;
3468 pos = HUD_Panel_GetPos(id);
3469 mySize = HUD_Panel_GetSize(id);
3473 if(vote_active != vote_prev) {
3475 vote_prev = vote_active;
3478 if(vote_active || hud_configure)
3479 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3481 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3493 a = vote_alpha * bound(cvar_or("hud_vote_alreadyvoted_alpha", 0.75), 1 - vote_highlighted, 1);
3495 HUD_Panel_DrawBg(id, pos, mySize, a);
3497 padding = HUD_Panel_GetPadding(id);
3500 pos += '1 1 0' * padding;
3501 mySize -= '2 2 0' * padding;
3504 drawpic_skin(pos, "voteprogress_back", mySize, '1 1 1', a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3506 s = "A vote has been called for: ";
3507 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);
3508 s = textShortenToWidth(vote_called_vote, mySize_x * 0.96, '1 1 0' * mySize_y*(1/5), stringwidth_colors); // TODO: broken?
3510 s = "Configure the HUD";
3511 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);
3513 // print the yes/no counts
3514 s = strcat("Yes: ", ftos(vote_yescount));
3515 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);
3516 s = strcat("No: ", ftos(vote_nocount));
3517 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);
3519 // draw the progress bars
3520 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3521 drawpic_skin(pos, "voteprogress_prog", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3523 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3524 drawpic_skin(pos, "voteprogress_prog", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3526 // draw the highlights
3527 if(vote_highlighted == 1) {
3528 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3529 drawpic_skin(pos, "voteprogress_voted", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3531 else if(vote_highlighted == 2) {
3532 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3533 drawpic_skin(pos, "voteprogress_voted", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3536 drawresetcliparea();
3539 vote_highlighted = 0;
3543 // Mod icons panel (#10)
3546 float mod_active; // is there any active mod icon?
3548 // CTF HUD modicon section
3549 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3550 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3551 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3553 void HUD_Mod_CTF_Reset(void)
3555 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3558 void HUD_Mod_CTF(vector pos, vector mySize)
3560 vector redflag_pos, blueflag_pos;
3562 float f; // every function should have that
3564 float redflag, blueflag; // current status
3565 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3568 stat_items = getstati(STAT_ITEMS);
3569 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3570 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3572 if(redflag || blueflag)
3583 // when status CHANGES, set old status into prevstatus and current status into status
3584 if (redflag != redflag_prevframe)
3586 redflag_statuschange_time = time;
3587 redflag_prevstatus = redflag_prevframe;
3588 redflag_prevframe = redflag;
3591 if (blueflag != blueflag_prevframe)
3593 blueflag_statuschange_time = time;
3594 blueflag_prevstatus = blueflag_prevframe;
3595 blueflag_prevframe = blueflag;
3598 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3599 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3601 float BLINK_FACTOR = 0.15;
3602 float BLINK_BASE = 0.85;
3604 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3606 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3608 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3610 string red_icon, red_icon_prevstatus;
3611 float red_alpha, red_alpha_prevstatus;
3612 red_alpha = red_alpha_prevstatus = 1;
3614 case 1: red_icon = "flag_red_taken"; break;
3615 case 2: red_icon = "flag_red_lost"; break;
3616 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3618 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3619 red_icon = "flag_red_shielded";
3621 red_icon = string_null;
3624 switch(redflag_prevstatus) {
3625 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3626 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3627 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3630 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3631 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3632 red_icon_prevstatus = "flag_red_shielded";
3634 red_icon_prevstatus = string_null;
3638 string blue_icon, blue_icon_prevstatus;
3639 float blue_alpha, blue_alpha_prevstatus;
3640 blue_alpha = blue_alpha_prevstatus = 1;
3642 case 1: blue_icon = "flag_blue_taken"; break;
3643 case 2: blue_icon = "flag_blue_lost"; break;
3644 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3646 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3647 blue_icon = "flag_blue_shielded";
3649 blue_icon = string_null;
3652 switch(blueflag_prevstatus) {
3653 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3654 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3655 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3658 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3659 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3660 blue_icon_prevstatus = "flag_blue_shielded";
3662 blue_icon_prevstatus = string_null;
3666 if(mySize_x > mySize_y) {
3667 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3669 blueflag_pos = pos + eX * 0.5 * mySize_x;
3672 redflag_pos = pos + eX * 0.5 * mySize_x;
3674 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3676 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3678 blueflag_pos = pos + eY * 0.5 * mySize_y;
3681 redflag_pos = pos + eY * 0.5 * mySize_y;
3683 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3686 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3687 if(red_icon_prevstatus && f < 1)
3688 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);
3690 drawpic_skin(redflag_pos, red_icon, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * red_alpha * f, DRAWFLAG_NORMAL);
3692 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3693 if(blue_icon_prevstatus && f < 1)
3694 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);
3696 drawpic_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * blue_alpha * f, DRAWFLAG_NORMAL);
3699 // Keyhunt HUD modicon section
3700 float kh_runheretime;
3702 void HUD_Mod_KH_Reset(void)
3707 void HUD_Mod_KH(vector pos, vector mySize)
3709 mod_active = 1; // keyhunt should never hide the mod icons panel
3713 vector p, pa, kh_size, kh_asize;
3715 kh_keys = getstati(STAT_KH_KEYS);
3718 if(mySize_x > mySize_y)
3720 p_y = pos_y + 0.25 * mySize_y;
3721 pa = p - eY * 0.25 * mySize_y;
3723 kh_size_x = mySize_x * 0.25;
3724 kh_size_y = 0.75 * mySize_y;
3725 kh_asize_x = mySize_x * 0.25;
3726 kh_asize_y = mySize_y * 0.25;
3730 p_y = pos_y + 0.125 * mySize_y;
3731 pa = p - eY * 0.125 * mySize_y;
3733 kh_size_x = mySize_x * 0.5;
3734 kh_size_y = 0.375 * mySize_y;
3735 kh_asize_x = mySize_x * 0.5;
3736 kh_asize_y = mySize_y * 0.125;
3743 for(i = 0; i < 4; ++i)
3745 key = floor(kh_keys / pow(32, i)) & 31;
3747 if(keyteam == 30 && keycount <= 4)
3749 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3753 // this yields 8 exactly if "RUN HERE" shows
3758 kh_runheretime = time;
3759 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3764 for(i = 0; i < 4; ++i)
3766 key = floor(kh_keys / pow(32, i)) & 31;
3779 default: // owned or dropped
3784 a = a * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3785 aa = aa * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3791 drawpic_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3794 drawpic_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3797 drawpic_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3800 drawpic_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3805 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3808 drawpic_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3811 drawpic_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3814 drawpic_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3817 drawpic_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3821 if(mySize_x > mySize_y)
3823 p_x += 0.25 * mySize_x;
3824 pa_x += 0.25 * mySize_x;
3830 p_y = pos_y + 0.625 * mySize_y;
3831 pa_y = pos_y + 0.5 * mySize_y;
3837 p_x += 0.5 * mySize_x;
3838 pa_x += 0.5 * mySize_x;
3844 // Nexball HUD mod icon
3845 void HUD_Mod_NexBall(vector pos, vector mySize)
3847 float stat_items, nb_pb_starttime, dt, p;
3849 stat_items = getstati(STAT_ITEMS);
3850 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3852 if (stat_items & IT_KEY1)
3857 //Manage the progress bar if any
3858 if (nb_pb_starttime > 0)
3860 dt = mod(time - nb_pb_starttime, nb_pb_period);
3861 // one period of positive triangle
3862 p = 2 * dt / nb_pb_period;
3869 if(mySize_x > mySize_y)
3871 barsize = eX * p * mySize_x + eY * mySize_y;
3876 barsize = eX * mySize_x + eY * p * mySize_y;
3879 HUD_Panel_DrawProgressBar(pos, vertical, barsize, HUD_Panel_GetProgressBarColor("nexball"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3882 if (stat_items & IT_KEY1)
3883 drawpic_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3886 // Race/CTS HUD mod icons
3887 float crecordtime_prev; // last remembered crecordtime
3888 float crecordtime_change_time; // time when crecordtime last changed
3889 float srecordtime_prev; // last remembered srecordtime
3890 float srecordtime_change_time; // time when srecordtime last changed
3892 float race_status_time;
3893 float race_status_prev;
3894 string race_status_name_prev;
3895 void HUD_Mod_Race(vector pos, vector mySize)
3897 mod_active = 1; // race should never hide the mod icons panel
3899 me = playerslots[player_localentnum - 1];
3901 float f; // yet another function has this
3902 score = me.(scores[ps_primary]);
3904 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3905 return; // no records in the actual race
3907 drawfont = hud_bigfont;
3909 // clientside personal record
3911 if(gametype == GAME_CTS)
3915 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3917 if(score && (score < t || !t)) {
3918 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3919 if(cvar("cl_autodemo_delete_keeprecords"))
3921 f = cvar("cl_autodemo_delete");
3923 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3927 if(t != crecordtime_prev) {
3928 crecordtime_prev = t;
3929 crecordtime_change_time = time;
3931 f = time - crecordtime_change_time;
3934 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);
3935 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);
3937 drawstring(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3938 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);
3939 drawstring_expanding(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL, f);
3940 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);
3944 t = race_server_record;
3945 if(t != srecordtime_prev) {
3946 srecordtime_prev = t;
3947 srecordtime_change_time = time;
3949 f = time - srecordtime_change_time;
3952 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);
3953 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);
3955 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);
3956 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);
3957 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);
3958 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);
3961 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
3962 race_status_time = time + 5;
3963 race_status_prev = race_status;
3964 if (race_status_name_prev)
3965 strunzone(race_status_name_prev);
3966 race_status_name_prev = strzone(race_status_name);
3969 pos_x += mySize_x/2;
3972 a = bound(0, race_status_time - time, 1);
3975 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
3979 rank = race_CheckName(race_status_name);
3981 rankname = race_PlaceName(rank);
3984 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
3986 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
3988 if(race_status == 0)
3989 drawpic_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3990 else if(race_status == 1) {
3991 drawpic_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3992 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3993 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3994 } else if(race_status == 2) {
3995 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
3996 drawpic_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3998 drawpic_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3999 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4000 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4001 } else if(race_status == 3) {
4002 drawpic_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4003 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4004 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4007 if (race_status_time - time <= 0) {
4008 race_status_prev = -1;
4010 if(race_status_name)
4011 strunzone(race_status_name);
4012 race_status_name = string_null;
4013 if(race_status_name_prev)
4014 strunzone(race_status_name_prev);
4015 race_status_name_prev = string_null;
4017 drawfont = hud_font;
4020 float mod_prev; // previous state of mod_active to check for a change
4022 float mod_change; // "time" when mod_active changed
4024 void HUD_ModIcons(void)
4026 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !hud_configure)
4029 float id = HUD_PANEL_MODICONS;
4031 pos = HUD_Panel_GetPos(id);
4032 mySize = HUD_Panel_GetSize(id);
4034 if(mod_active != mod_prev) {
4036 mod_prev = mod_active;
4039 if(mod_active || hud_configure)
4040 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4042 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4045 HUD_Panel_DrawBg(id, pos, mySize, mod_alpha);
4048 padding = HUD_Panel_GetPadding(id);
4051 pos += '1 1 0' * padding;
4052 mySize -= '2 2 0' * padding;
4055 // these MUST be ran in order to update mod_active
4056 if(gametype == GAME_KEYHUNT)
4057 HUD_Mod_KH(pos, mySize);
4058 else if(gametype == GAME_CTF || hud_configure)
4059 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4060 else if(gametype == GAME_NEXBALL)
4061 HUD_Mod_NexBall(pos, mySize);
4062 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4063 HUD_Mod_Race(pos, mySize);
4066 // Draw pressed keys (#11)
4068 void HUD_DrawPressedKeys(void)
4070 float id = HUD_PANEL_PRESSEDKEYS;
4072 pos = HUD_Panel_GetPos(id);
4073 mySize = HUD_Panel_GetSize(id);
4075 HUD_Panel_DrawBg(id, pos, mySize, 0);
4077 padding = HUD_Panel_GetPadding(id);
4080 pos += '1 1 0' * padding;
4081 mySize -= '2 2 0' * padding;
4085 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4088 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4089 drawpic_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4090 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);
4091 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);
4092 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);
4093 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);
4094 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);
4097 // Handle chat as a panel (#12)
4101 float id = HUD_PANEL_CHAT;
4103 pos = HUD_Panel_GetPos(id);
4104 mySize = HUD_Panel_GetSize(id);
4106 HUD_Panel_DrawBg(id, pos, mySize, 0);
4108 padding = HUD_Panel_GetPadding(id);
4111 pos += '1 1 0' * padding;
4112 mySize -= '2 2 0' * padding;
4115 cvar_set("con_chatrect", "1");
4117 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4118 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4120 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4121 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4126 chatsize = cvar("con_chatsize");
4127 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4129 for(i = 0; i < cvar("con_chat"); ++i)
4131 if(i == cvar("con_chat") - 1)
4132 a = HUD_Panel_GetFgAlpha(id);
4134 a = HUD_Panel_GetFgAlpha(id) * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4135 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);
4140 // Engine info panel (#13)
4147 float frametimeavg1; // 1 frame ago
4148 float frametimeavg2; // 2 frames ago
4149 void HUD_EngineInfo(void)
4151 float id = HUD_PANEL_ENGINEINFO;
4153 pos = HUD_Panel_GetPos(id);
4154 mySize = HUD_Panel_GetSize(id);
4156 HUD_Panel_DrawBg(id, pos, mySize, 0);
4158 padding = HUD_Panel_GetPadding(id);
4161 pos += '1 1 0' * padding;
4162 mySize -= '2 2 0' * padding;
4165 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4167 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4168 frametimeavg2 = frametimeavg1;
4169 frametimeavg1 = frametimeavg;
4172 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4173 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.
4175 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
4176 prevfps = (1/frametime);
4177 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"
4183 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4185 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4187 prevfps_time = time;
4192 color = HUD_Get_Num_Color (prevfps, 100);
4193 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), mySize, mySize_y, color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4201 void HUD_ShowSpeed(void)
4204 float pos, conversion_factor;
4205 string speed, zspeed, unit;
4207 switch(cvar("cl_showspeed_unit"))
4212 conversion_factor = 1.0;
4216 conversion_factor = 1.0;
4220 conversion_factor = 0.0254;
4224 conversion_factor = 0.0254 * 3.6;
4228 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4232 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4236 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4238 numsize_x = numsize_y = cvar("cl_showspeed_size");
4239 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4241 drawfont = hud_bigfont;
4242 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4244 if (cvar("cl_showspeed_z") == 1) {
4245 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4246 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4249 drawfont = hud_font;
4252 vector acc_prevspeed;
4256 void HUD_ShowAcceleration(void)
4258 float acceleration, sz, scale, alpha, f;
4259 vector pos, top, rgb;
4260 top_x = vid_conwidth/2;
4263 f = time - acc_prevtime;
4264 if(cvar("cl_showacceleration_z"))
4265 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4267 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4268 acc_prevspeed = pmove_vel;
4269 acc_prevtime = time;
4271 f = bound(0, f * 10, 1);
4272 acc_avg = acc_avg * (1 - f) + acceleration * f;
4273 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4275 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4277 sz = cvar("cl_showacceleration_size");
4278 scale = cvar("cl_showacceleration_scale");
4279 alpha = cvar("cl_showacceleration_alpha");
4280 if (cvar("cl_showacceleration_color_custom"))
4281 rgb = stov(cvar_string("cl_showacceleration_color"));
4284 if (acceleration < 0) {
4285 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4286 } else if (acceleration > 0) {
4287 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4291 if (acceleration > 0)
4292 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4293 else if (acceleration < 0)
4294 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4297 void HUD_Reset (void)
4299 // reset gametype specific icons
4300 if(gametype == GAME_KEYHUNT)
4302 else if(gametype == GAME_CTF)
4303 HUD_Mod_CTF_Reset();
4306 void HUD_Main (void)
4308 if(disable_menu_alphacheck == 1)
4309 menu_fade_alpha = 1;
4311 menu_fade_alpha = (1 - cvar("_menu_alpha"));
4312 hud_fg_alpha = cvar("hud_fg_alpha");
4314 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4315 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4316 hud_color_bg_team = cvar("hud_color_bg_team");
4318 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4319 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4321 hud_configure = cvar("_hud_configure");
4325 // HUD configure visible grid
4326 if(hud_configure && cvar("hud_configure_grid") && cvar("hud_configure_grid_alpha"))
4330 for(i = 0; i < 1/bound(0.005, cvar("hud_configure_grid_x"), 0.2); ++i)
4332 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);
4335 for(i = 0; i < 1/bound(0.005, cvar("hud_configure_grid_y"), 0.2); ++i)
4337 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);
4341 if(cvar_string("hud_dock") != "" && cvar_string("hud_dock") != "0")
4342 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...
4344 if(HUD_Panel_CheckActive(HUD_PANEL_RADAR) || hud_configure)
4345 if(cvar_string("hud_radar") != "0" && (cvar("hud_radar") == 2 || teamplay))
4347 if(HUD_Panel_CheckActive(HUD_PANEL_WEAPONICONS) || hud_configure)
4349 if(HUD_Panel_CheckActive(HUD_PANEL_INVENTORY) || hud_configure)
4351 if(HUD_Panel_CheckActive(HUD_PANEL_POWERUPS) || hud_configure)
4353 if(HUD_Panel_CheckActive(HUD_PANEL_HEALTHARMOR) || hud_configure)
4355 if(HUD_Panel_CheckActive(HUD_PANEL_NOTIFY) || hud_configure)
4357 if(HUD_Panel_CheckActive(HUD_PANEL_TIMER) || hud_configure)
4359 if(HUD_Panel_CheckActive(HUD_PANEL_SCORE) || hud_configure)
4361 if(HUD_Panel_CheckActive(HUD_PANEL_RACETIMER) || hud_configure)
4362 if(gametype == GAME_RACE || gametype == GAME_CTS || hud_configure)
4364 if(HUD_Panel_CheckActive(HUD_PANEL_VOTE) || hud_configure)
4366 if(HUD_Panel_CheckActive(HUD_PANEL_MODICONS) || hud_configure)
4369 if(HUD_Panel_CheckActive(HUD_PANEL_PRESSEDKEYS) || hud_configure)
4370 if(spectatee_status > 0 || cvar("hud_pressedkeys") >= 2 || hud_configure)
4371 HUD_DrawPressedKeys();
4372 if(HUD_Panel_CheckActive(HUD_PANEL_CHAT) || hud_configure)
4375 cvar_set("con_chatrect", "0");
4376 if(HUD_Panel_CheckActive(HUD_PANEL_ENGINEINFO) || hud_configure)
4379 // TODO hud_'ify these
4380 if (cvar("cl_showspeed"))
4382 if (cvar("cl_showacceleration"))
4383 HUD_ShowAcceleration();
4385 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)
4386 localcmd("cmd selectteam auto; cmd join\n");
4388 if (!hud_configure) // hud config mode disabled, enable normal alpha stuff again
4389 disable_menu_alphacheck = 0;