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"));
530 case HUD_PANEL_WEAPONICONS:
531 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_accuracy_yellow ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_accuracy_yellow"))), "\n"));
533 case HUD_PANEL_INVENTORY:
534 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_onlycurrent ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_onlycurrent"))), "\n"));
535 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_iconalign ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
537 case HUD_PANEL_POWERUPS:
538 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
539 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_iconalign ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
540 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_baralign ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
542 case HUD_PANEL_HEALTHARMOR:
543 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
544 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_iconalign ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
545 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_baralign ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
547 case HUD_PANEL_NOTIFY:
548 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
549 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_info_top ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_info_top"))), "\n"));
551 case HUD_PANEL_RADAR:
552 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_foreground_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_foreground_alpha"))), "\n"));
554 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha"))), "\n"));
560 print("^2Successfully exported to hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
565 // return active status of panel
566 float HUD_Panel_CheckActive(float id)
568 if (cvar_or(strcat("hud_", HUD_Panel_GetName(id)), 1))
573 // return size of given panel
574 vector HUD_Panel_GetSize(float id)
577 mySize = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_size")));
579 mySize = eX * mySize_x * vid_conwidth + eY * mySize_y * vid_conheight;
581 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
583 vector menu_enable_maxsize, menu_enable_size;
584 menu_enable_maxsize = '0 0 0'; // shut up FTEQCC
585 menu_enable_maxsize_x = 0.3 * vid_conwidth;
586 menu_enable_maxsize_y = 0.18 * vid_conheight;
587 if(mySize_x > mySize_y)
589 if(mySize_y > menu_enable_maxsize_y)
591 menu_enable_size_y = menu_enable_maxsize_y;
592 menu_enable_size_x = mySize_x * (menu_enable_maxsize_y/mySize_y);
593 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
598 if(mySize_x > menu_enable_maxsize_x)
600 menu_enable_size_x = menu_enable_maxsize_x;
601 menu_enable_size_y = mySize_y * (menu_enable_maxsize_x/mySize_x);
602 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
609 // return pos of given panel
610 vector HUD_Panel_GetPos(float id)
613 pos = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_pos")));
615 pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
617 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
619 vector mySize, menu_enable_panelpos;
620 mySize = HUD_Panel_GetSize(id);
621 if(mySize_x > mySize_y)
622 menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * mySize_x + eY * 0.82 * vid_conheight;
624 menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * mySize_y + eX * 0.7 * vid_conwidth;
625 pos = (1 - cvar("_menu_alpha")) * pos + (cvar("_menu_alpha")) * menu_enable_panelpos;
630 float HUD_Panel_GetBorder(float id)
633 border = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_border"));
635 border = cvar_string("hud_bg_border");
639 vector HUD_Panel_GetColor(float id)
645 // fetch per-panel color
646 if(teamplay && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")) != "") {
647 f = stof(getplayerkey(self.sv_entnum, "colors"));
648 color = vtos(colormapPaletteColor(mod(f, 16), 1) * cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")));
651 color = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color"));
652 color_vec = stov(color);
654 if(color == "") { // fetch default color
655 color = cvar_string("hud_bg_color");
656 color_vec = stov(color);
657 if(teamplay && cvar(strcat("hud_bg_color_team"))) {
658 f = stof(getplayerkey(self.sv_entnum, "colors"));
659 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_bg_color_team");
661 else if(color == "shirt") {
662 f = stof(getplayerkey(self.sv_entnum, "colors"));
663 color_vec = colormapPaletteColor(floor(f / 16), 0);
665 else if(color == "pants") {
666 f = stof(getplayerkey(self.sv_entnum, "colors"));
667 color_vec = colormapPaletteColor(mod(f, 16), 1);
670 else if(color == "shirt") {
671 f = stof(getplayerkey(self.sv_entnum, "colors"));
672 color_vec = colormapPaletteColor(floor(f / 16), 0);
674 else if(color == "pants") {
675 f = stof(getplayerkey(self.sv_entnum, "colors"));
676 color_vec = colormapPaletteColor(mod(f, 16), 1);
681 vector HUD_Panel_Dock_GetColor(void)
686 color = cvar_string("hud_dock_color");
687 color_vec = stov(color);
688 if(teamplay && cvar(strcat("hud_dock_color_team"))) {
689 f = stof(getplayerkey(self.sv_entnum, "colors"));
690 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_dock_color_team");
692 else if(color == "shirt") {
693 f = stof(getplayerkey(self.sv_entnum, "colors"));
694 color_vec = colormapPaletteColor(floor(f / 16), 0);
696 else if(color == "pants") {
697 f = stof(getplayerkey(self.sv_entnum, "colors"));
698 color_vec = colormapPaletteColor(mod(f, 16), 1);
703 float HUD_Panel_GetBgAlpha(float id)
706 alpha = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_alpha"));
708 alpha = cvar_string("hud_bg_alpha");
710 if(hud_configure && disable_menu_alphacheck == 2 && highlightedPanel == id) // do not set a minalpha cap when showing the config dialog for this panel
711 alpha = ftos((1 - cvar("_menu_alpha")) * max(cvar("hud_configure_bg_minalpha"), stof(alpha)) + (cvar("_menu_alpha")) * stof(alpha));
712 else if(hud_configure)
713 alpha = ftos(max(cvar("hud_configure_bg_minalpha"), stof(alpha)));
715 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
718 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
721 return stof(alpha) * menu_fade_alpha;
724 float HUD_Panel_GetFgAlpha(float id)
727 alpha = hud_fg_alpha;
729 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
732 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
735 return alpha * menu_fade_alpha;
738 float HUD_Panel_GetPadding(float id)
741 padding = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
743 padding = cvar_string("hud_bg_padding");
746 mySize = HUD_Panel_GetSize(id);
748 smallestsize = min(mySize_x, mySize_y);
749 return min(smallestsize/2 - 5, stof(padding));
752 // draw the background/borders
753 void HUD_Panel_DrawBg(float id, vector pos, vector mySize, float alpha)
755 if(!hud_configure && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg")) == "0")
759 bg = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg"));
761 bg = cvar_string("hud_bg");
763 if(bg == "0" && hud_configure) {
764 bg = "border"; // we probably want to see a background in config mode at all times...
770 border = max(0.0000001, HUD_Panel_GetBorder(id)); // draw_BorderPicture does not like border = 0
773 color = HUD_Panel_GetColor(id);
776 alpha = HUD_Panel_GetBgAlpha(id) * alpha; // allow panels to fade in/out by passing an alpha value
778 alpha = HUD_Panel_GetBgAlpha(id);
780 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));
784 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
790 pic = strcat("gfx/hud/", cvar_string("hud_skin"), "/");
792 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);
793 if(mySize_y/mySize_x > 2)
794 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);
795 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);
797 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);
798 if(mySize_x/mySize_y > 2)
799 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);
800 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);
804 vector HUD_Panel_GetProgressBarColor(string item)
806 return stov(cvar_string(strcat("hud_progressbar_", item, "_color")));
809 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
810 vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
821 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
822 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
824 for (i = 0; i < HUD_PANEL_NUM; ++i) {
825 if(i == id || !HUD_Panel_CheckActive(i))
828 targPos = HUD_Panel_GetPos(i) - '1 1 0' * HUD_Panel_GetBorder(id);
829 targSize = HUD_Panel_GetSize(i) + '2 2 0' * HUD_Panel_GetBorder(id);
831 if(myPos_y + mySize_y < targPos_y)
833 if(myPos_y > targPos_y + targSize_y)
836 if(myPos_x + mySize_x < targPos_x)
838 if(myPos_x > targPos_x + targSize_x)
841 // OK, there IS a collision.
843 myCenter_x = myPos_x + 0.5 * mySize_x;
844 myCenter_y = myPos_y + 0.5 * mySize_y;
846 targCenter_x = targPos_x + 0.5 * targSize_x;
847 targCenter_y = targPos_y + 0.5 * targSize_y;
849 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
851 if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
852 myTarget_x = targPos_x - mySize_x;
853 else // push it upwards
854 myTarget_y = targPos_y - mySize_y;
856 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
858 if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
859 myTarget_x = targPos_x + targSize_x;
860 else // push it upwards
861 myTarget_y = targPos_y - mySize_y;
863 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
865 if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
866 myTarget_x = targPos_x - mySize_x;
867 else // push it downwards
868 myTarget_y = targPos_y + targSize_y;
870 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
872 if(targPos_x + targSize_x - myPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
873 myTarget_x = targPos_x + targSize_x;
874 else // push it downwards
875 myTarget_y = targPos_y + targSize_y;
882 void HUD_Panel_SetPos(float id, vector pos)
885 oldPos = HUD_Panel_GetPos(id);
888 mySize = HUD_Panel_GetSize(id);
890 if(hud_configure_checkcollisions)
891 pos = HUD_Panel_CheckMove(id, pos, mySize);
893 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
894 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
896 if(cvar("hud_configure_grid"))
898 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;
899 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;
903 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
905 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
908 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
909 vector HUD_Panel_CheckResize(float id, vector mySize, vector resizeorigin) {
919 ratio = mySize_x/mySize_y;
921 for (i = 0; i < HUD_PANEL_NUM; ++i) {
922 if(i == id || !HUD_Panel_CheckActive(i))
925 targBorder = HUD_Panel_GetBorder(i);
926 targPos = HUD_Panel_GetPos(i) - '1 1 0' * targBorder;
927 targSize = HUD_Panel_GetSize(i) + '2 2 0' * targBorder;
928 targEndPos = targPos + targSize;
930 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
931 if(resizeorigin_x > targPos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > targPos_y && resizeorigin_y < targEndPos_y)
934 if (resizeCorner == 1)
936 // check if this panel is on our way
937 if (resizeorigin_x <= targPos_x)
939 if (resizeorigin_y <= targPos_y)
941 if (targEndPos_x <= resizeorigin_x - mySize_x)
943 if (targEndPos_y <= resizeorigin_y - mySize_y)
946 // there is a collision:
947 // detect which side of the panel we are facing is actually limiting the resizing
948 // (which side the resize direction finds for first) and reduce the size up to there
950 // dist is the distance between resizeorigin and the "analogous" point of the panel
951 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
952 dist_x = resizeorigin_x - targEndPos_x;
953 dist_y = resizeorigin_y - targEndPos_y;
954 if (dist_y < 0 || dist_x / dist_y > ratio)
955 mySize_x = min(mySize_x, dist_x);
957 mySize_y = min(mySize_y, dist_y);
959 else if (resizeCorner == 2)
961 if (resizeorigin_x >= targEndPos_x)
963 if (resizeorigin_y <= targPos_y)
965 if (targPos_x >= resizeorigin_x + mySize_x)
967 if (targEndPos_y <= resizeorigin_y - mySize_y)
970 dist_x = targPos_x - resizeorigin_x;
971 dist_y = resizeorigin_y - targEndPos_y;
972 if (dist_y < 0 || dist_x / dist_y > ratio)
973 mySize_x = min(mySize_x, dist_x);
975 mySize_y = min(mySize_y, dist_y);
977 else if (resizeCorner == 3)
979 if (resizeorigin_x <= targPos_x)
981 if (resizeorigin_y >= targEndPos_y)
983 if (targEndPos_x <= resizeorigin_x - mySize_x)
985 if (targPos_y >= resizeorigin_y + mySize_y)
988 dist_x = resizeorigin_x - targEndPos_x;
989 dist_y = targPos_y - resizeorigin_y;
990 if (dist_y < 0 || dist_x / dist_y > ratio)
991 mySize_x = min(mySize_x, dist_x);
993 mySize_y = min(mySize_y, dist_y);
995 else if (resizeCorner == 4)
997 if (resizeorigin_x >= targEndPos_x)
999 if (resizeorigin_y >= targEndPos_y)
1001 if (targPos_x >= resizeorigin_x + mySize_x)
1003 if (targPos_y >= resizeorigin_y + mySize_y)
1006 dist_x = targPos_x - resizeorigin_x;
1007 dist_y = targPos_y - resizeorigin_y;
1008 if (dist_y < 0 || dist_x / dist_y > ratio)
1009 mySize_x = min(mySize_x, dist_x);
1011 mySize_y = min(mySize_y, dist_y);
1013 if(cvar("hud_configure_checkcollisions_debug"))
1014 drawfill(targPos + '1 1 0' * targBorder, targSize - '2 2 0' * targBorder, '1 1 0', .3, DRAWFLAG_NORMAL);
1020 void HUD_Panel_SetPosSize(float id, vector mySize)
1022 vector resizeorigin;
1023 resizeorigin = panel_click_resizeorigin;
1026 // minimum panel size cap
1027 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1028 mySize_y = max(0.025 * vid_conheight, mySize_y);
1030 if(id == HUD_PANEL_CHAT) // 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.
1032 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
1033 mySize_y = max(2 * cvar("con_chatsize") + 2 * HUD_Panel_GetPadding(id), mySize_y);
1036 // collision testing|
1037 // -----------------+
1039 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
1040 if(resizeCorner == 1) {
1041 myPos_x = resizeorigin_x - mySize_x;
1042 myPos_y = resizeorigin_y - mySize_y;
1043 } else if(resizeCorner == 2) {
1044 myPos_x = resizeorigin_x;
1045 myPos_y = resizeorigin_y - mySize_y;
1046 } else if(resizeCorner == 3) {
1047 myPos_x = resizeorigin_x - mySize_x;
1048 myPos_y = resizeorigin_y;
1049 } else { // resizeCorner == 4
1050 myPos_x = resizeorigin_x;
1051 myPos_y = resizeorigin_y;
1054 // left/top screen edges
1056 mySize_x = mySize_x + myPos_x;
1058 mySize_y = mySize_y + myPos_y;
1060 // bottom/right screen edges
1061 if(myPos_x + mySize_x > vid_conwidth)
1062 mySize_x = vid_conwidth - myPos_x;
1063 if(myPos_y + mySize_y > vid_conheight)
1064 mySize_y = vid_conheight - myPos_y;
1066 if(cvar("hud_configure_checkcollisions_debug"))
1067 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
1069 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
1070 if(cvar("hud_configure_grid"))
1072 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;
1073 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;
1076 if(hud_configure_checkcollisions)
1077 mySize = HUD_Panel_CheckResize(id, mySize, resizeorigin);
1079 // 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)
1080 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1081 mySize_y = max(0.025 * vid_conheight, mySize_y);
1083 // do another pos check, as size might have changed by now
1084 if(resizeCorner == 1) {
1085 myPos_x = resizeorigin_x - mySize_x;
1086 myPos_y = resizeorigin_y - mySize_y;
1087 } else if(resizeCorner == 2) {
1088 myPos_x = resizeorigin_x;
1089 myPos_y = resizeorigin_y - mySize_y;
1090 } else if(resizeCorner == 3) {
1091 myPos_x = resizeorigin_x - mySize_x;
1092 myPos_y = resizeorigin_y;
1093 } else { // resizeCorner == 4
1094 myPos_x = resizeorigin_x;
1095 myPos_y = resizeorigin_y;
1098 if(cvar("hud_configure_checkcollisions_debug"))
1099 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
1102 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
1103 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_size"), s);
1105 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
1106 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
1109 float pressed_key_time;
1110 void HUD_Panel_Arrow_Action(float nPrimary)
1112 if (highlightedPanel_prev == -1)
1115 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
1118 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
1119 step = vid_conheight / 64;
1121 step = vid_conwidth / 64;
1123 highlightedPanel = highlightedPanel_prev;
1125 if (hudShiftState & S_ALT) // resize
1127 highlightedAction = 1;
1128 if(nPrimary == K_UPARROW)
1130 else if(nPrimary == K_RIGHTARROW)
1132 else if(nPrimary == K_LEFTARROW)
1134 else // if(nPrimary == K_DOWNARROW)
1137 // ctrl+arrow reduces the size, instead of increasing it
1138 // Note that ctrl disables collisions check too, but it's fine
1139 // since we don't collide with anything reducing the size
1140 if (hudShiftState & S_CTRL) {
1142 resizeCorner = 5 - resizeCorner;
1146 mySize = HUD_Panel_GetSize(highlightedPanel);
1147 panel_click_resizeorigin = HUD_Panel_GetPos(highlightedPanel);
1148 if(resizeCorner == 1) {
1149 panel_click_resizeorigin += mySize;
1151 } else if(resizeCorner == 2) {
1152 panel_click_resizeorigin_y += mySize_y;
1154 } else if(resizeCorner == 3) {
1155 panel_click_resizeorigin_x += mySize_x;
1157 } else { // resizeCorner == 4
1160 HUD_Panel_SetPosSize(highlightedPanel, mySize);
1164 highlightedAction = 2;
1166 pos = HUD_Panel_GetPos(highlightedPanel);
1167 if(nPrimary == K_UPARROW)
1169 else if(nPrimary == K_DOWNARROW)
1171 else if(nPrimary == K_LEFTARROW)
1173 else // if(nPrimary == K_RIGHTARROW)
1176 HUD_Panel_SetPos(highlightedPanel, pos);
1181 float prevMouseClicked; // previous state
1182 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
1183 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
1186 float menu_enabled_time;
1187 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1192 // allow console bind to work
1195 con_keys = findkeysforcommand("toggleconsole");
1196 keys = tokenize(con_keys);
1198 float hit_con_bind, i;
1199 for (i = 0; i < keys; ++i)
1201 if(nPrimary == stof(argv(i)))
1205 if(bInputType == 0) {
1206 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1207 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1208 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1210 else if(bInputType == 1) {
1211 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1212 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1213 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1216 if(nPrimary == K_MOUSE1)
1218 if(bInputType == 0) { // key pressed
1222 else if(bInputType == 1) {// key released
1227 else if(nPrimary == K_ESCAPE)
1229 if (bInputType == 1)
1231 disable_menu_alphacheck = 1;
1233 menu_enabled_time = time;
1234 localcmd("menu_showhudexit\n");
1236 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1238 if (bInputType == 1)
1240 pressed_key_time = 0;
1243 else if (pressed_key_time == 0)
1244 pressed_key_time = time;
1246 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1248 else if(hit_con_bind)
1251 return true; // Suppress ALL other input
1254 void HUD_Panel_Highlight()
1260 for(i = 0; i < HUD_PANEL_NUM; ++i)
1262 panelPos = HUD_Panel_GetPos(i);
1263 panelSize = HUD_Panel_GetSize(i);
1264 border = HUD_Panel_GetBorder(i);
1267 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1269 highlightedPanel = i;
1270 highlightedAction = 1;
1271 panel_click_distance = mousepos - panelPos;
1274 // resize from topleft border
1275 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)
1277 highlightedPanel = i;
1278 highlightedAction = 2;
1280 panel_click_distance = mousepos - panelPos;
1281 panel_click_resizeorigin = panelPos + panelSize;
1284 // resize from topright border
1285 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)
1287 highlightedPanel = i;
1288 highlightedAction = 2;
1290 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1291 panel_click_distance_y = mousepos_y - panelPos_y;
1292 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1295 // resize from bottomleft border
1296 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)
1298 highlightedPanel = i;
1299 highlightedAction = 2;
1301 panel_click_distance_x = mousepos_x - panelPos_x;
1302 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1303 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1306 // resize from bottomright border
1307 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)
1309 highlightedPanel = i;
1310 highlightedAction = 2;
1312 panel_click_distance = panelSize - mousepos + panelPos;
1313 panel_click_resizeorigin = panelPos;
1319 void HUD_Panel_Mouse()
1321 // 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
1322 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1323 disable_menu_alphacheck = 0;
1324 if (cvar("_menu_alpha") == 0 && time - menu_enabled_time > 0.5)
1328 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1329 print("Highlighted: ", ftos(highlightedPanel), "\n");
1330 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1333 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1334 highlightedPanel_prev = highlightedPanel;
1335 highlightedPanel = -1;
1336 highlightedAction = 0;
1339 mousepos = mousepos + getmousepos();
1341 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1342 mousepos_y = bound(0, mousepos_y, vid_conheight);
1344 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1348 if(prevMouseClicked == 0)
1349 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1351 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
1353 if(highlightedAction == 1)
1354 HUD_Panel_SetPos(highlightedPanel, mousepos - panel_click_distance);
1355 else if(highlightedAction == 2)
1358 if(resizeCorner == 1) {
1359 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1360 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1361 } else if(resizeCorner == 2) {
1362 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1363 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1364 } else if(resizeCorner == 3) {
1365 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1366 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1367 } else { // resizeCorner == 4
1368 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1369 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1371 HUD_Panel_SetPosSize(highlightedPanel, mySize);
1374 // doubleclick check
1375 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1377 mouseClicked = 0; // to prevent spam, I guess.
1378 disable_menu_alphacheck = 2;
1380 menu_enabled_time = time;
1381 localcmd("menu_showhudoptions ", ftos(highlightedPanel), "\n");
1384 if(prevMouseClicked == 0)
1386 prevMouseClickedTime = time;
1387 prevMouseClickedPos = mousepos;
1390 prevMouseClicked = mouseClicked;
1393 // Weapon icons (#0)
1395 float weaponspace[10];
1396 void HUD_WeaponIcons_Clear()
1399 for(idx = 0; idx < 10; ++idx)
1400 weaponspace[idx] = 0;
1403 entity weaponorder[WEP_MAXCOUNT];
1404 void weaponorder_swap(float i, float j, entity pass)
1408 weaponorder[i] = weaponorder[j];
1412 string weaponorder_cmp_str_save;
1413 string weaponorder_cmp_str;
1414 float weaponorder_cmp(float i, float j, entity pass)
1417 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1418 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1419 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)
1422 void HUD_WeaponIcons(void)
1424 float id = HUD_PANEL_WEAPONICONS;
1425 float alpha, stat_weapons; // "constants"
1426 vector pos, mySize, accuracy_color;
1427 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1429 pos = HUD_Panel_GetPos(id);
1430 mySize = HUD_Panel_GetSize(id);
1432 stat_weapons = getstati(STAT_WEAPONS);
1434 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1436 self = get_weaponinfo(i);
1437 if(self.impulse >= 0)
1441 // TODO make this configurable
1442 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1444 if(weaponorder_cmp_str != weaponorder_cmp_str_save)
1446 if(weaponorder_cmp_str_save)
1447 strunzone(weaponorder_cmp_str_save);
1448 weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
1450 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1452 self = get_weaponinfo(i);
1453 if(self.impulse >= 0)
1455 weaponorder[weapon_cnt] = self;
1459 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1462 HUD_Panel_DrawBg(id, pos, mySize, 0);
1464 padding = HUD_Panel_GetPadding(id);
1467 pos += '1 1 0' * padding;
1468 mySize -= '2 2 0' * padding;
1472 weapon_stats = getstati(STAT_DAMAGE_HITS);
1473 weapon_number = weapon_stats & 63;
1474 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1476 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1477 weapon_number = weapon_stats & 63;
1478 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1480 if(cvar_or("hud_weaponicons_fade", 1))
1482 fade = 3.2 - 2 * (time - weapontime);
1483 fade = bound(0.7, fade, 1);
1488 HUD_WeaponIcons_Clear();
1490 float rows, columns;
1491 rows = mySize_y/mySize_x;
1492 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1493 // ^^^ weapon icon aspect goes here
1495 columns = ceil(WEP_COUNT/rows);
1497 for(i = 0; i < weapon_cnt; ++i)
1499 self = weaponorder[i];
1500 weapid = self.impulse;
1502 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1504 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1505 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1507 // draw background behind currently selected weapon
1508 if(self.weapon == activeweapon)
1509 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);
1511 // draw the weapon accuracy on the HUD
1512 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1515 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1517 accuracy_color = HUD_AccuracyColor(weapon_stats);
1519 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);
1522 // draw the weapon icon
1523 if((self.impulse >= 0) && (stat_weapons & self.weapons))
1525 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);
1527 if(cvar_or("hud_weaponicons_number", 1))
1528 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);
1530 // draw a "ghost weapon icon" if you don't have the weapon
1533 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);
1548 float GetAmmoStat(float i)
1552 case 0: return STAT_SHELLS;
1553 case 1: return STAT_NAILS;
1554 case 2: return STAT_ROCKETS;
1555 case 3: return STAT_CELLS;
1556 case 4: return STAT_FUEL;
1561 float GetAmmoItemCode(float i)
1565 case 0: return IT_SHELLS;
1566 case 1: return IT_NAILS;
1567 case 2: return IT_ROCKETS;
1568 case 3: return IT_CELLS;
1569 case 4: return IT_FUEL;
1574 string GetAmmoPicture(float i)
1578 case 0: return "ammo_shells";
1579 case 1: return "ammo_bullets";
1580 case 2: return "ammo_rockets";
1581 case 3: return "ammo_cells";
1582 case 4: return "ammo_fuel";
1587 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1590 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1601 if(currently_selected)
1606 vector newSize, newPos;
1607 if(mySize_x/mySize_y > 3)
1609 newSize_x = 3 * mySize_y;
1610 newSize_y = mySize_y;
1612 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1617 newSize_y = 1/3 * mySize_x;
1618 newSize_x = mySize_x;
1620 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1624 vector picpos, numpos;
1625 if(cvar("hud_inventory_iconalign"))
1628 picpos = newPos + eX * 2 * newSize_y;
1632 numpos = newPos + eX * newSize_y;
1636 if (currently_selected)
1637 drawpic_skin(newPos, "ammo_current_bg", newSize, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_INVENTORY), DRAWFLAG_NORMAL);
1639 drawfont = hud_bigfont;
1640 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);
1641 drawfont = hud_font;
1642 drawpic_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_INVENTORY) * alpha, DRAWFLAG_NORMAL);
1645 void HUD_Inventory(void)
1647 float id = HUD_PANEL_INVENTORY;
1648 float i, currently_selected;
1651 pos = HUD_Panel_GetPos(id);
1652 mySize = HUD_Panel_GetSize(id);
1654 HUD_Panel_DrawBg(id, pos, mySize, 0);
1656 padding = HUD_Panel_GetPadding(id);
1659 pos += '1 1 0' * padding;
1660 mySize -= '2 2 0' * padding;
1663 float rows, columns;
1664 rows = mySize_y/mySize_x;
1665 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1666 // ^^^ ammo item aspect goes here
1668 columns = ceil(AMMO_COUNT/rows);
1672 for (i = 0; i < AMMO_COUNT; ++i) {
1673 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1674 if(cvar("hud_inventory_onlycurrent")) {
1677 if (currently_selected || hud_configure)
1678 DrawAmmoItem(pos, mySize, i, currently_selected);
1681 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);
1686 column = column + 1;
1692 void DrawNumIcon(float id, vector myPos, vector mySize, float x, string icon, float left, vector color)
1694 vector newSize, newPos;
1695 if(mySize_x/mySize_y > 3)
1697 newSize_x = 3 * mySize_y;
1698 newSize_y = mySize_y;
1700 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1705 newSize_y = 1/3 * mySize_x;
1706 newSize_x = mySize_x;
1708 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1712 vector picpos, numpos;
1714 iconalign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_iconalign"));
1717 if(iconalign == 1 || iconalign == 3) // right align
1720 picpos = newPos + eX * 2 * newSize_y;
1724 numpos = newPos + eX * newSize_y;
1730 if(iconalign == 0 || iconalign == 3) // left align
1732 numpos = newPos + eX * newSize_y;
1738 picpos = newPos + eX * 2 * newSize_y;
1742 drawfont = hud_bigfont;
1743 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, newSize_y, color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1744 drawfont = hud_font;
1745 drawpic_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1750 void HUD_Powerups(void) {
1751 float id = HUD_PANEL_POWERUPS;
1753 stat_items = getstati(STAT_ITEMS);
1757 if not(stat_items & IT_STRENGTH)
1758 if not(stat_items & IT_INVINCIBLE)
1761 if (getstati(STAT_HEALTH) <= 0)
1766 pos = HUD_Panel_GetPos(id);
1767 mySize = HUD_Panel_GetSize(id);
1769 HUD_Panel_DrawBg(id, pos, mySize, 0);
1771 padding = HUD_Panel_GetPadding(id);
1774 pos += '1 1 0' * padding;
1775 mySize -= '2 2 0' * padding;
1778 float strength_time, shield_time;
1780 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1781 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1789 vector barpos, barsize;
1793 string leftname, rightname;
1794 float leftcnt, rightcnt;
1795 float leftexact, rightexact;
1796 float leftalpha, rightalpha;
1797 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) {
1798 leftname = "strength";
1799 leftcnt = ceil(strength_time);
1800 leftexact = strength_time;
1802 rightname = "shield";
1803 rightcnt = ceil(shield_time);
1804 rightexact = shield_time;
1806 leftname = "shield";
1807 leftcnt = ceil(shield_time);
1808 leftexact = shield_time;
1810 rightname = "strength";
1811 rightcnt = ceil(strength_time);
1812 rightexact = strength_time;
1814 leftalpha = bound(0, leftexact, 1);
1815 rightalpha = bound(0, rightexact, 1);
1817 float baralign, iconalign;
1818 baralign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_baralign"));
1819 iconalign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_iconalign"));
1821 if (mySize_x/mySize_y > 4)
1825 if(baralign == 1 || baralign == 3) { // right align
1826 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1827 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1828 } else { // left align
1830 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1833 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1834 DrawNumIcon(id, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1');
1837 // 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));
1839 // drawpic_skin(picpos, leftname, eX * (1/6) * mySize_x + eY * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1844 if(baralign == 0 || baralign == 3) { // left align
1845 barpos = pos + eX * 0.5 * mySize_x;
1846 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1847 } else { // right align
1848 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1849 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1852 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1853 DrawNumIcon(id, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1');
1856 else if (mySize_x/mySize_y > 1.5)
1860 if(baralign == 1 || baralign == 3) { // right align
1861 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1862 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1863 } else { // left align
1865 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1868 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1869 DrawNumIcon(id, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1');
1874 if(baralign == 0 || baralign == 3) { // left align
1875 barpos = pos + eY * 0.5 * mySize_y;
1876 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1877 } else { // right align
1878 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1879 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1882 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1883 DrawNumIcon(id, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1');
1890 if(baralign == 1 || baralign == 3) { // down align
1891 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1892 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1893 } else { // up align
1895 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1898 if(iconalign == 1 || iconalign == 3) { // down align
1899 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
1900 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
1901 } else { // up align
1902 picpos = pos + eX * 0.05 * mySize_x;
1903 numpos = pos + eY * 0.4 * mySize_x;
1906 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1908 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));
1910 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1911 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);
1916 if(baralign == 0 || baralign == 3) { // up align
1917 barpos = pos + eX * 0.5 * mySize_x;
1918 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1919 } else { // down align
1920 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1921 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1924 if(iconalign == 0 || iconalign == 3) { // up align
1925 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1926 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1927 } else { // down align
1928 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
1929 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
1932 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1934 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));
1936 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1937 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);
1942 // Health/armor (#3)
1944 void HUD_HealthArmor(void)
1946 float id = HUD_PANEL_HEALTHARMOR;
1948 pos = HUD_Panel_GetPos(id);
1949 mySize = HUD_Panel_GetSize(id);
1951 HUD_Panel_DrawBg(id, pos, mySize, 0);
1953 padding = HUD_Panel_GetPadding(id);
1956 pos += '1 1 0' * padding;
1957 mySize -= '2 2 0' * padding;
1960 float armor, health;
1961 armor = getstati(STAT_ARMOR);
1962 health = getstati(STAT_HEALTH);
1965 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
1977 vector barpos, barsize;
1981 float baralign, iconalign;
1982 baralign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_baralign"));
1983 iconalign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_iconalign"));
1985 if(cvar("hud_healtharmor") == 2) // combined health and armor display
1988 v = healtharmor_maxdamage(health, armor, armorblockpercent);
1993 if(baralign == 1 || baralign == 3) { // right align
1994 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
1995 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
1996 } else { // left align
1998 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2002 if(v_z) // NOT fully armored
2004 biggercount = "health";
2005 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("health"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2007 drawpic_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "armor", '0.5 0.5 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id) * armor / health, DRAWFLAG_NORMAL);
2011 biggercount = "armor";
2012 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("armor"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2014 drawpic_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "health", '0.5 0.5 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2016 DrawNumIcon(id, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200));
2021 if(baralign == 0 || baralign == 3) { // left align
2022 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2023 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2026 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2028 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2033 string leftname, rightname;
2034 float leftcnt, rightcnt;
2035 float leftactive, rightactive;
2036 float leftalpha, rightalpha;
2037 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) { // old style layout with armor left/top of health
2042 leftalpha = min((armor+10)/55, 1);
2044 rightname = "health";
2049 leftname = "health";
2054 rightname = "armor";
2058 rightalpha = min((armor+10)/55, 1);
2061 if (mySize_x/mySize_y > 4)
2065 if(baralign == 1 || baralign == 3) { // right align
2066 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2067 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2068 } else { // left align
2070 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2073 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2074 DrawNumIcon(id, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2079 if(baralign == 0 || baralign == 3) { // left align
2080 barpos = pos + eX * 0.5 * mySize_x;
2081 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2082 } else { // right align
2083 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2084 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2087 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2088 DrawNumIcon(id, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(leftcnt, 200));
2093 if(baralign == 0 || baralign == 3) { // left align
2094 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2095 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2098 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2100 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2103 else if (mySize_x/mySize_y > 1.5)
2107 if(baralign == 1 || baralign == 3) { // right align
2108 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2109 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2110 } else { // left align
2112 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2115 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2116 DrawNumIcon(id, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2121 if(baralign == 0 || baralign == 3) { // left align
2122 barpos = pos + eY * 0.5 * mySize_y;
2123 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2124 } else { // right align
2125 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2126 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2129 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2130 DrawNumIcon(id, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(leftcnt, 200));
2135 if(baralign == 0 || baralign == 3) { // left align
2136 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2137 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2140 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2142 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2149 if(baralign == 1 || baralign == 3) { // down align
2150 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2151 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2152 } else { // up align
2154 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2157 if(iconalign == 1 || iconalign == 3) { // down align
2158 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2159 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2160 } else { // up align
2161 picpos = pos + eX * 0.05 * mySize_x;
2162 numpos = pos + eY * 0.4 * mySize_x;
2165 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2166 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2167 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);
2172 if(baralign == 0 || baralign == 3) { // up align
2173 barpos = pos + eX * 0.5 * mySize_x;
2174 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2175 } else { // down align
2176 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2177 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2180 if(iconalign == 0 || iconalign == 3) { // up align
2181 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2182 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2183 } else { // down align
2184 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2185 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2188 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2189 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2190 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);
2195 if(baralign == 0 || baralign == 3) { // left align
2197 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2199 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2200 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2202 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2209 // Notification area (#4)
2212 string Weapon_SuicideMessage(float deathtype)
2214 w_deathtype = deathtype;
2215 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2216 return w_deathtypestring;
2219 string Weapon_KillMessage(float deathtype)
2221 w_deathtype = deathtype;
2222 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2223 return w_deathtypestring;
2226 float killnotify_times[10];
2227 float killnotify_deathtype[10];
2228 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2229 string killnotify_attackers[10];
2230 string killnotify_victims[10];
2231 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2234 for (i = 9; i > 0; --i) {
2235 killnotify_times[i] = killnotify_times[i-1];
2236 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2237 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2238 if(killnotify_attackers[i])
2239 strunzone(killnotify_attackers[i]);
2240 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2241 if(killnotify_victims[i])
2242 strunzone(killnotify_victims[i]);
2243 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2245 killnotify_times[0] = time;
2246 killnotify_deathtype[0] = wpn;
2247 killnotify_actiontype[0] = actiontype;
2248 if(killnotify_attackers[0])
2249 strunzone(killnotify_attackers[0]);
2250 killnotify_attackers[0] = strzone(attacker);
2251 if(killnotify_victims[0])
2252 strunzone(killnotify_victims[0]);
2253 killnotify_victims[0] = strzone(victim);
2256 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2260 alsoprint = (cvar("hud_notify_print") || !HUD_Panel_CheckActive(4)); // print message to console if: notify panel disabled, or cvar to do so enabled
2262 if(msg == MSG_SUICIDE) {
2264 w = DEATH_WEAPONOF(type);
2266 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2268 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2269 } else if (type == DEATH_KILL) {
2270 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2272 print ("^1",s1, "^1 couldn't take it anymore\n");
2273 } else if (type == DEATH_ROT) {
2274 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2276 print ("^1",s1, "^1 died\n");
2277 } else if (type == DEATH_NOAMMO) {
2278 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2280 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2281 } else if (type == DEATH_CAMP) {
2282 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2284 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2285 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2286 HUD_KillNotify_Push(s1, "", 0, type);
2288 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2289 } else if (type == DEATH_CHEAT) {
2290 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2292 print ("^1",s1, "^1 unfairly eliminated themself\n");
2293 } else if (type == DEATH_FIRE) {
2294 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2296 print ("^1",s1, "^1 burned to death\n");
2297 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2298 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2300 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2303 if (stof(s2) > 2) // killcount > 2
2304 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2305 } else if(msg == MSG_KILL) {
2306 w = DEATH_WEAPONOF(type);
2308 HUD_KillNotify_Push(s2, s1, 1, w);
2310 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2312 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2313 HUD_KillNotify_Push(s1, s2, 1, type);
2316 if(cvar("cl_gentle")) {
2317 print ("^1", s1, "^1 took action against a team mate\n");
2319 print ("^1", s1, "^1 mows down a team mate\n");
2322 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2323 if(cvar("cl_gentle"))
2324 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2326 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2328 else if (stof(s2) > 2) {
2329 if(cvar("cl_gentle"))
2330 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2332 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2335 else if(type == KILL_FIRST_BLOOD)
2336 print("^1",s1, "^1 drew first blood", "\n");
2338 else if (type == DEATH_TELEFRAG)
2339 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2340 else if (type == DEATH_DROWN) {
2341 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2343 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2345 else if (type == DEATH_SLIME) {
2346 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2348 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2350 else if (type == DEATH_LAVA) {
2351 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2353 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2355 else if (type == DEATH_FALL) {
2356 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2358 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2360 else if (type == DEATH_SHOOTING_STAR) {
2361 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2363 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2365 else if (type == DEATH_SWAMP) {
2366 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2368 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2370 else if (type == DEATH_HURTTRIGGER)
2372 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2374 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2375 } else if(type == DEATH_SBCRUSH) {
2376 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2378 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2379 } else if(type == DEATH_SBMINIGUN) {
2380 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2382 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2383 } else if(type == DEATH_SBROCKET) {
2384 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2386 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2387 } else if(type == DEATH_SBBLOWUP) {
2388 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2390 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2391 } else if(type == DEATH_WAKIGUN) {
2392 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2394 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2395 } else if(type == DEATH_WAKIROCKET) {
2396 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2398 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2399 } else if(type == DEATH_WAKIBLOWUP) {
2400 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2402 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2403 } else if(type == DEATH_TURRET) {
2404 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2406 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2407 } else if(type == DEATH_TOUCHEXPLODE) {
2408 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2410 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2411 } else if(type == DEATH_CHEAT) {
2412 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2414 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2415 } else if (type == DEATH_FIRE) {
2416 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2418 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2419 } else if (type == DEATH_CUSTOM) {
2420 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2422 print ("^1",s1, "^1 ", s2, "\n");
2424 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2426 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2428 } else if(msg == MSG_SPREE) {
2429 if(type == KILL_END_SPREE) {
2430 if(cvar("cl_gentle"))
2431 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2433 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2434 } else if(type == KILL_SPREE) {
2435 if(cvar("cl_gentle"))
2436 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2438 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2439 } else if(type == KILL_SPREE_3) {
2440 if(cvar("cl_gentle"))
2441 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2443 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2444 } else if(type == KILL_SPREE_5) {
2445 if(cvar("cl_gentle"))
2446 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2448 print (s1,"^7 unleashes ^1RAGE\n");
2449 } else if(type == KILL_SPREE_10) {
2450 if(cvar("cl_gentle"))
2451 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2453 print (s1,"^7 starts the ^1MASSACRE!\n");
2454 } else if(type == KILL_SPREE_15) {
2455 if(cvar("cl_gentle"))
2456 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2458 print (s1,"^7 executes ^1MAYHEM!\n");
2459 } else if(type == KILL_SPREE_20) {
2460 if(cvar("cl_gentle"))
2461 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2463 print (s1,"^7 is a ^1BERSERKER!\n");
2464 } else if(type == KILL_SPREE_25) {
2465 if(cvar("cl_gentle"))
2466 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2468 print (s1,"^7 inflicts ^1CARNAGE!\n");
2469 } else if(type == KILL_SPREE_30) {
2470 if(cvar("cl_gentle"))
2471 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2473 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2475 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2476 if (type == DEATH_DROWN) {
2477 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2480 if(cvar("cl_gentle"))
2481 print ("^1",s1, "^1 was in the water for too long\n");
2483 print ("^1",s1, "^1 drowned\n");
2485 } else if (type == DEATH_SLIME) {
2486 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2488 print ("^1",s1, "^1 was slimed\n");
2489 } else if (type == DEATH_LAVA) {
2490 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2493 if(cvar("cl_gentle"))
2494 print ("^1",s1, "^1 found a hot place\n");
2496 print ("^1",s1, "^1 turned into hot slag\n");
2498 } else if (type == DEATH_FALL) {
2499 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2502 if(cvar("cl_gentle"))
2503 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2505 print ("^1",s1, "^1 hit the ground with a crunch\n");
2507 } else if (type == DEATH_SHOOTING_STAR) {
2508 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2510 print ("^1",s1, "^1 became a shooting star\n");
2511 } else if (type == DEATH_SWAMP) {
2512 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2515 if(cvar("cl_gentle"))
2516 print ("^1",s1, "^1 discovered a swamp\n");
2518 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2520 } else if(type == DEATH_TURRET) {
2521 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2523 print ("^1",s1, "^1 was mowed down by a turret \n");
2524 } else if (type == DEATH_CUSTOM) {
2525 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2527 print ("^1",s1, "^1 ", s2, "\n");
2528 } else if (type == DEATH_HURTTRIGGER) {
2529 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2531 print ("^1",s1, "^1 was in the wrong place\n");
2532 } else if(type == DEATH_TOUCHEXPLODE) {
2533 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2535 print ("^1",s1, "^1 died in an accident\n");
2536 } else if(type == DEATH_CHEAT) {
2537 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2539 print ("^1",s1, "^1 was unfairly eliminated\n");
2540 } else if(type == DEATH_FIRE) {
2541 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2544 if(cvar("cl_gentle"))
2545 print ("^1",s1, "^1 felt a little hot\n");
2547 print ("^1",s1, "^1 burnt to death\n");
2550 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2553 if(cvar("cl_gentle"))
2554 print ("^1",s1, "^1 needs a restart\n");
2556 print ("^1",s1, "^1 died\n");
2559 } else if(msg == MSG_KILL_ACTION_SPREE) {
2560 if(cvar("cl_gentle"))
2561 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2563 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2564 } else if(msg == MSG_INFO) {
2565 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2566 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2567 print(s1, "^7 got the ", s2, "\n");
2568 } else if(type == INFO_LOSTFLAG) {
2569 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2570 print(s1, "^7 lost the ", s2, "\n");
2571 } else if(type == INFO_PICKUPFLAG) {
2572 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2573 print(s1, "^7 picked up the ", s2, "\n");
2574 } else if(type == INFO_RETURNFLAG) {
2575 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2576 print(s1, "^7 returned the ", s2, "\n");
2581 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2583 void HUD_Centerprint(string s1, string s2, float type, float msg)
2585 if(msg == MSG_SUICIDE) {
2586 if (type == DEATH_TEAMCHANGE) {
2587 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2588 } else if (type == DEATH_AUTOTEAMCHANGE) {
2589 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2590 } else if (type == DEATH_CAMP) {
2591 if(cvar("cl_gentle"))
2592 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2594 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2595 } else if (type == DEATH_NOAMMO) {
2596 if(cvar("cl_gentle"))
2597 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2599 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2600 } else if (type == DEATH_ROT) {
2601 if(cvar("cl_gentle"))
2602 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2604 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2605 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2606 if(cvar("cl_gentle"))
2607 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2609 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2610 } else if (type == DEATH_QUIET) {
2612 } else if (type == DEATH_KILL) {
2613 if(cvar("cl_gentle"))
2614 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2616 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2618 } else if(msg == MSG_KILL) {
2619 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2620 if(cvar("cl_gentle")) {
2621 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2623 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2625 } else if (type == KILL_FIRST_BLOOD) {
2626 if(cvar("cl_gentle")) {
2627 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2629 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2631 } else if (type == KILL_FIRST_VICTIM) {
2632 if(cvar("cl_gentle")) {
2633 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2635 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2637 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2638 if(cvar("cl_gentle")) {
2639 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2641 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2643 } else if (type == KILL_TYPEFRAGGED) {
2644 if(cvar("cl_gentle")) {
2645 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2647 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2649 } else if (type == KILL_FRAG) {
2650 if(cvar("cl_gentle")) {
2651 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2653 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2655 } else if (type == KILL_FRAGGED) {
2656 if(cvar("cl_gentle")) {
2657 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2659 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2662 } else if(msg == MSG_KILL_ACTION) {
2663 // TODO: invent more centerprints here?
2664 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2668 void HUD_Notify (void)
2670 float id = HUD_PANEL_NOTIFY;
2672 pos = HUD_Panel_GetPos(id);
2673 mySize = HUD_Panel_GetSize(id);
2675 HUD_Panel_DrawBg(id, pos, mySize, 0);
2677 padding = HUD_Panel_GetPadding(id);
2680 pos += '1 1 0' * padding;
2681 mySize -= '2 2 0' * padding;
2684 float entries, height;
2685 entries = bound(1, floor(14 * mySize_y/mySize_x), 12);
2686 height = mySize_y/entries;
2687 entries -= 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2690 fontsize = '0.5 0.5 0' * height;
2694 when = cvar("hud_notify_time");
2696 fadetime = cvar("hud_notify_fadetime");
2700 vector pos_attacker, pos_victim;
2702 float width_attacker, width_victim;
2703 string attacker, victim;
2706 for(j = 0; j < entries; ++j)
2708 if(cvar("hud_notify_flip"))
2710 else // rather nasty hack for ordering items from the bottom up
2711 i = entries - j - 1;
2712 if(cvar("hud_notify_info_top"))
2713 i += 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2717 if(killnotify_times[j] + when > time)
2720 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2724 if(killnotify_times[j] + when > time)
2730 // TODO: maybe print in team colors?
2731 // TODO: maybe this could be cleaned up somehow...
2732 // TODO: less copypaste code below
2735 if(killnotify_actiontype[j] == 0 && !hud_configure)
2737 attacker = textShortenToWidth(killnotify_attackers[j], mySize_x - 2 * height, fontsize, stringwidth_colors);
2739 width_attacker = stringwidth(attacker, TRUE, fontsize);
2740 pos_attacker = pos + eX * 0.5 * (mySize_x - width_attacker + 2 * height) + eY * 0.5 * fontsize_y + eY * i * height;
2742 weap_pos = pos + eX * 0.5 * (mySize_x - width_attacker) - eX * height + eY * i * height;
2743 if(killnotify_deathtype[j] == DEATH_GENERIC)
2745 drawpic_skin(weap_pos, "notify_death", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2746 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2748 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2750 drawpic_skin(weap_pos, "notify_outofammo", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2751 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2753 else if(killnotify_deathtype[j] == DEATH_KILL)
2755 drawpic_skin(weap_pos, "notify_selfkill", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2756 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2758 else if(killnotify_deathtype[j] == DEATH_CAMP)
2760 drawpic_skin(weap_pos, "notify_camping", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2761 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2763 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2765 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2766 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2768 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2770 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2771 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2773 else if(killnotify_deathtype[j] == DEATH_DROWN)
2775 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2776 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2778 else if(killnotify_deathtype[j] == DEATH_SLIME)
2780 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2781 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2783 else if(killnotify_deathtype[j] == DEATH_LAVA)
2785 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2786 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2788 else if(killnotify_deathtype[j] == DEATH_FALL)
2790 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2791 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2793 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2795 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2796 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2798 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2800 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2801 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2803 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2805 if(killnotify_victims[j] == "^1RED^7 flag")
2809 drawpic_skin(weap_pos, strcat("flag_", s, "_carrying"), '1 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);
2812 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2814 if(killnotify_victims[j] == "^1RED^7 flag")
2818 drawpic_skin(weap_pos, strcat("flag_", s, "_taken"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2819 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2821 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2823 if(killnotify_victims[j] == "^1RED^7 flag")
2827 drawpic_skin(weap_pos, strcat("flag_", s, "_lost"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2828 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2831 // X [did action to] Y
2836 attacker = textShortenToWidth("Player1", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2837 victim = textShortenToWidth("Player2", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2838 a = bound(0, (when - j) / 4, 1);
2842 attacker = textShortenToWidth(killnotify_attackers[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2843 victim = textShortenToWidth(killnotify_victims[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2845 width_attacker = stringwidth(attacker, TRUE, fontsize);
2846 width_victim = stringwidth(victim, TRUE, fontsize);
2847 pos_attacker = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_attacker) + eY * 0.5 * fontsize_y + eY * i * height;
2848 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;
2849 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2851 if(hud_configure) // example actions for config mode
2853 drawpic_skin(weap_pos, strcat("weapon", "electro"), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2854 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2855 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2857 else if(WEP_VALID(killnotify_deathtype[j]))
2859 self = get_weaponinfo(killnotify_deathtype[j]);
2860 drawpic_skin(weap_pos, strcat("weapon", self.netname), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2861 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2862 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2864 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2866 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2867 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2868 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2870 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2872 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2873 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2874 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2876 else if(killnotify_deathtype[j] == DEATH_DROWN)
2878 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2879 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2880 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2882 else if(killnotify_deathtype[j] == DEATH_SLIME)
2884 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2885 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2886 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2888 else if(killnotify_deathtype[j] == DEATH_LAVA)
2890 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2891 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2892 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2894 else if(killnotify_deathtype[j] == DEATH_FALL)
2896 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2897 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2898 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2900 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2902 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2903 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2904 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2906 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2908 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2909 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2910 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2916 // TODO: separate panel for these?
2922 if(cvar("hud_notify_info_top"))
2925 o = pos + eY * mySize_y - eY * 2 * height;
2927 if(spectatee_status && !intermission)
2929 //drawfont = hud_bigfont;
2930 if(spectatee_status == -1)
2933 s = GetPlayerName(spectatee_status - 1);
2935 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
2936 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2937 //drawfont = hud_font;
2939 // spectator text in the upper right corner
2940 if(spectatee_status == -1)
2941 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
2943 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
2944 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2945 o += eY * fontsize_y;
2947 if(spectatee_status == -1)
2948 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
2950 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
2951 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2952 o += eY * fontsize_y;
2954 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
2955 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2956 o += eY * fontsize_y;
2958 if(gametype == GAME_ARENA)
2959 s = "^1Wait for your turn to join";
2960 else if(gametype == GAME_LMS)
2963 sk = playerslots[player_localentnum - 1];
2964 if(sk.(scores[ps_primary]) >= 666)
2965 s = "^1Match has already begun";
2966 else if(sk.(scores[ps_primary]) > 0)
2967 s = "^1You have no more lives left";
2969 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
2972 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
2973 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2974 o += eY * fontsize_y;
2976 //show restart countdown:
2977 if (time < getstatf(STAT_GAMESTARTTIME)) {
2979 //we need to ceil, otherwise the countdown would be off by .5 when using round()
2980 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
2981 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
2982 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2983 o += eY * fontsize_y;
2986 if(warmup_stage && !intermission)
2988 s = "^2Currently in ^1warmup^2 stage!";
2989 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2990 o += eY * fontsize_y;
2994 if(mod(time, 1) >= 0.5)
2999 if(ready_waiting && !intermission && !spectatee_status)
3001 if(ready_waiting_for_me)
3004 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
3006 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
3011 s = strcat("^2Waiting for others to ready up to end warmup...");
3013 s = strcat("^2Waiting for others to ready up...");
3015 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3016 o += eY * fontsize_y;
3018 else if(warmup_stage && !intermission && !spectatee_status)
3020 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
3021 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3022 o += eY * fontsize_y;
3025 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
3027 float ts_min, ts_max;
3028 tm = teams.sort_next;
3031 for(; tm.sort_next; tm = tm.sort_next)
3033 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
3035 if(!ts_min) ts_min = tm.team_size;
3036 else ts_min = min(ts_min, tm.team_size);
3037 if(!ts_max) ts_max = tm.team_size;
3038 else ts_max = max(ts_max, tm.team_size);
3040 if ((ts_max - ts_min) > 1)
3042 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
3043 tm = GetTeam(myteam, false);
3045 if (tm.team != COLOR_SPECTATOR)
3046 if (tm.team_size == ts_max)
3047 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
3049 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3050 o += eY * fontsize_y;
3056 s = "^7Press ^3ESC ^7to show HUD options.";
3057 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3058 o += eY * fontsize_y;
3059 s = "^3Doubleclick a panel for panel-specific options.";
3060 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3061 o += eY * fontsize_y;
3067 string seconds_tostring(float sec)
3070 minutes = floor(sec / 60);
3072 sec -= minutes * 60;
3075 s = ftos(100 + sec);
3077 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3080 void HUD_Timer(void)
3082 float id = HUD_PANEL_TIMER;
3084 pos = HUD_Panel_GetPos(id);
3085 mySize = HUD_Panel_GetSize(id);
3087 HUD_Panel_DrawBg(id, pos, mySize, 0);
3089 padding = HUD_Panel_GetPadding(id);
3092 pos += '1 1 0' * padding;
3093 mySize -= '2 2 0' * padding;
3097 float timelimit, elapsedTime, timeleft, minutesLeft;
3099 timelimit = getstatf(STAT_TIMELIMIT);
3101 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3102 timeleft = ceil(timeleft);
3104 minutesLeft = floor(timeleft / 60);
3107 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3108 timer_color = '1 1 1'; //white
3109 else if(minutesLeft >= 1)
3110 timer_color = '1 1 0'; //yellow
3112 timer_color = '1 0 0'; //red
3114 if (cvar("hud_timer_increment") || timelimit == 0 || warmup_stage) {
3115 if (time < getstatf(STAT_GAMESTARTTIME)) {
3116 //while restart is still active, show 00:00
3117 timer = seconds_tostring(0);
3119 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3120 timer = seconds_tostring(elapsedTime);
3123 timer = seconds_tostring(timeleft);
3126 drawfont = hud_bigfont;
3127 drawstring_aspect(pos, timer, mySize, mySize_y, timer_color, HUD_Panel_GetFgAlpha(HUD_PANEL_TIMER), DRAWFLAG_NORMAL);
3128 drawfont = hud_font;
3133 void HUD_Radar(void)
3135 float id = HUD_PANEL_RADAR;
3137 pos = HUD_Panel_GetPos(id);
3138 mySize = HUD_Panel_GetSize(id);
3140 HUD_Panel_DrawBg(id, pos, mySize, 0);
3142 padding = HUD_Panel_GetPadding(id);
3145 pos += '1 1 0' * padding;
3146 mySize -= '2 2 0' * padding;
3149 local float color1, color2; // color already declared as a global in hud.qc
3152 float scale2d, normalsize, bigsize;
3155 teamradar_origin2d = pos + 0.5 * mySize;
3156 teamradar_size2d = mySize;
3158 if(minimapname == "")
3161 teamradar_loadcvars();
3163 switch(hud_radar_zoommode)
3167 f = current_zoomfraction;
3170 f = 1 - current_zoomfraction;
3180 switch(hud_radar_rotation)
3183 teamradar_angle = view_angles_y - 90;
3186 teamradar_angle = 90 * hud_radar_rotation;
3190 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3191 teamradar_size2d = mySize;
3193 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3195 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3196 if(hud_radar_rotation == 0)
3198 // max-min distance must fit the radar in any rotation
3199 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3203 vector c0, c1, c2, c3, span;
3204 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3205 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3206 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3207 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3209 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3210 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3212 // max-min distance must fit the radar in x=x, y=y
3214 teamradar_size2d_x * scale2d / (1.05 * span_x),
3215 teamradar_size2d_y * scale2d / (1.05 * span_y)
3219 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3220 if(bigsize > normalsize)
3221 normalsize = bigsize;
3225 + (1 - f) * normalsize;
3226 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3227 f * (mi_min + mi_max) * 0.5
3228 + (1 - f) * view_origin);
3230 color1 = GetPlayerColor(player_localentnum-1);
3231 rgb = GetTeamRGB(color1);
3240 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3242 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3243 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3244 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3245 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, HUD_Panel_GetFgAlpha(id));
3246 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3248 color2 = GetPlayerColor(tm.sv_entnum);
3249 //if(color == COLOR_SPECTATOR || color == color2)
3250 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3252 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3254 drawresetcliparea();
3259 void HUD_Score(void)
3261 float id = HUD_PANEL_SCORE;
3263 pos = HUD_Panel_GetPos(id);
3264 mySize = HUD_Panel_GetSize(id);
3266 HUD_Panel_DrawBg(id, pos, mySize, 0);
3268 padding = HUD_Panel_GetPadding(id);
3271 pos += '1 1 0' * padding;
3272 mySize -= '2 2 0' * padding;
3275 float score, distribution, leader;
3277 vector distribution_color;
3279 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3281 // TODO... this (race part) still uses constant coordinates :/
3282 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3283 /*pl = players.sort_next;
3286 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3287 if(pl.scores[ps_primary] == 0)
3290 score = me.(scores[ps_primary]);
3292 float racemin, racesec, racemsec;
3293 float distsec, distmsec, minusplus;
3295 racemin = floor(score/(60 * TIME_FACTOR));
3296 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
3297 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
3299 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3300 // distribution display
3301 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3303 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
3304 distmsec = fabs(distribution);
3306 distsec = floor(fabs(distribution)/TIME_FACTOR);
3307 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
3308 if (distribution < 0)
3312 if (distribution <= 0) {
3313 distribution_color = eY;
3314 minusplus = 1; // minusplus 1: always prefix with minus sign
3317 distribution_color = eX;
3318 minusplus = 2; // minusplus 1: always prefix with plus sign
3320 //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);
3321 //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);
3322 drawpic_skin(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "num_dot", '16 16 0', distribution_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE);
3324 // race record display
3325 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
3326 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);
3328 //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);
3329 //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);
3330 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);
3332 //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);
3333 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);
3335 } else if (!teamplay) { // non-teamgames
3336 // me vector := [team/connected frags id]
3337 pl = players.sort_next;
3344 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3348 score = me.(scores[ps_primary]);
3352 if(distribution >= 5) {
3353 distribution_color = eY;
3355 } else if(distribution >= 0) {
3356 distribution_color = '1 1 1';
3358 } else if(distribution >= -5)
3359 distribution_color = '1 1 0';
3361 distribution_color = eX;
3363 score_len = strlen(ftos(score));
3365 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);
3367 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);
3368 drawfont = hud_bigfont;
3369 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, mySize_y, distribution_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3370 drawfont = hud_font;
3371 } else { // teamgames
3372 float max_fragcount;
3373 max_fragcount = -99;
3376 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3377 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !hud_configure)) // no players? don't display
3379 score = tm.(teamscores[ts_primary]);
3384 score_len = strlen(ftos(score));
3386 if (score > max_fragcount)
3387 max_fragcount = score;
3389 if(tm.team == myteam) {
3390 if (max_fragcount == score)
3393 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);
3394 drawfont = hud_bigfont;
3395 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);
3396 drawfont = hud_font;
3398 if (max_fragcount == score)
3401 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);
3402 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);
3411 void HUD_RaceTimer (void) {
3412 float id = HUD_PANEL_RACETIMER;
3414 pos = HUD_Panel_GetPos(id);
3415 mySize = HUD_Panel_GetSize(id);
3417 HUD_Panel_DrawBg(id, pos, mySize, 0);
3419 padding = HUD_Panel_GetPadding(id);
3422 pos += '1 1 0' * padding;
3423 mySize -= '2 2 0' * padding;
3426 // always force 2:1 aspect
3428 if(mySize_x/mySize_y > 2)
3430 newSize_x = 2 * mySize_y;
3431 newSize_y = mySize_y;
3433 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3437 newSize_y = 1/2 * mySize_x;
3438 newSize_x = mySize_x;
3440 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3444 drawfont = hud_bigfont;
3446 string s, forcetime;
3451 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);
3452 s = "^1Intermediate 1 (+15.42)";
3453 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);
3454 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3455 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);
3457 else if(race_checkpointtime)
3459 a = bound(0, 2 - (time - race_checkpointtime), 1);
3462 if(a > 0) // just hit a checkpoint?
3464 if(race_checkpoint != 254)
3466 if(race_time && race_previousbesttime)
3467 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3469 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3471 forcetime = TIME_ENCODED_TOSTRING(race_time);
3476 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3478 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3479 if(a > 0) // next one?
3481 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3486 if(s != "" && a > 0)
3488 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3489 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3490 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);
3493 if(race_penaltytime)
3495 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3498 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3499 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3500 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3501 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.8 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3507 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3508 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id), 0, a);
3509 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);
3514 if(race_laptime && race_checkpoint != 255)
3516 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3517 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3518 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);
3523 if(race_mycheckpointtime)
3525 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3526 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3527 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3528 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3529 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);
3531 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3533 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3534 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3535 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3536 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3537 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);
3540 if(race_penaltytime && !race_penaltyaccumulator)
3542 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3543 a = bound(0, (1 + t - time), 1);
3547 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3549 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3550 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3551 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3552 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3557 drawfont = hud_font;
3562 float vote_yescount;
3565 float vote_highlighted; // currently selected vote
3567 float vote_active; // is there an active vote?
3568 float vote_prev; // previous state of vote_active to check for a change
3570 float vote_change; // "time" when vote_active changed
3572 void HUD_VoteWindow(void)
3574 float id = HUD_PANEL_VOTE;
3576 pos = HUD_Panel_GetPos(id);
3577 mySize = HUD_Panel_GetSize(id);
3581 if(vote_active != vote_prev) {
3583 vote_prev = vote_active;
3586 if(vote_active || hud_configure)
3587 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3589 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3601 a = vote_alpha * bound(cvar_or("hud_vote_alreadyvoted_alpha", 0.75), 1 - vote_highlighted, 1);
3603 HUD_Panel_DrawBg(id, pos, mySize, a);
3605 padding = HUD_Panel_GetPadding(id);
3608 pos += '1 1 0' * padding;
3609 mySize -= '2 2 0' * padding;
3612 // always force 2:1 aspect
3614 if(mySize_x/mySize_y > 2)
3616 newSize_x = 2 * mySize_y;
3617 newSize_y = mySize_y;
3619 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3623 newSize_y = 1/2 * mySize_x;
3624 newSize_x = mySize_x;
3626 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3630 drawpic_skin(pos, "voteprogress_back", mySize, '1 1 1', a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3632 s = "A vote has been called for: ";
3633 drawstring_aspect(pos + eY * (1/12) * mySize_y, s, eX * mySize_x + eY * (3/12) * mySize_y, mySize_y*(3/12), '1 1 1', a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3634 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (3/12), stringwidth_colors); // TODO: broken?
3636 s = "Configure the HUD";
3637 drawstring_aspect(pos + eY * (4/12) * mySize_y, s, eX * mySize_x + eY * (2/12) * mySize_y, mySize_y*(2/12), '1 1 1', a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3639 // print the yes/no counts
3640 s = strcat("Yes: ", ftos(vote_yescount));
3641 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);
3642 s = strcat("No: ", ftos(vote_nocount));
3643 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);
3645 // draw the progress bars
3646 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3647 drawpic_skin(pos, "voteprogress_prog", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3649 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3650 drawpic_skin(pos, "voteprogress_prog", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3652 // draw the highlights
3653 if(vote_highlighted == 1) {
3654 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3655 drawpic_skin(pos, "voteprogress_voted", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3657 else if(vote_highlighted == 2) {
3658 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3659 drawpic_skin(pos, "voteprogress_voted", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3662 drawresetcliparea();
3665 vote_highlighted = 0;
3669 // Mod icons panel (#10)
3672 float mod_active; // is there any active mod icon?
3674 // CTF HUD modicon section
3675 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3676 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3677 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3679 void HUD_Mod_CTF_Reset(void)
3681 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3684 void HUD_Mod_CTF(vector pos, vector mySize)
3686 vector redflag_pos, blueflag_pos;
3688 float f; // every function should have that
3690 float redflag, blueflag; // current status
3691 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3694 stat_items = getstati(STAT_ITEMS);
3695 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3696 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3698 if(redflag || blueflag)
3709 // when status CHANGES, set old status into prevstatus and current status into status
3710 if (redflag != redflag_prevframe)
3712 redflag_statuschange_time = time;
3713 redflag_prevstatus = redflag_prevframe;
3714 redflag_prevframe = redflag;
3717 if (blueflag != blueflag_prevframe)
3719 blueflag_statuschange_time = time;
3720 blueflag_prevstatus = blueflag_prevframe;
3721 blueflag_prevframe = blueflag;
3724 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3725 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3727 float BLINK_FACTOR = 0.15;
3728 float BLINK_BASE = 0.85;
3730 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3732 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3734 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3736 string red_icon, red_icon_prevstatus;
3737 float red_alpha, red_alpha_prevstatus;
3738 red_alpha = red_alpha_prevstatus = 1;
3740 case 1: red_icon = "flag_red_taken"; break;
3741 case 2: red_icon = "flag_red_lost"; break;
3742 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3744 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3745 red_icon = "flag_red_shielded";
3747 red_icon = string_null;
3750 switch(redflag_prevstatus) {
3751 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3752 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3753 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3756 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3757 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3758 red_icon_prevstatus = "flag_red_shielded";
3760 red_icon_prevstatus = string_null;
3764 string blue_icon, blue_icon_prevstatus;
3765 float blue_alpha, blue_alpha_prevstatus;
3766 blue_alpha = blue_alpha_prevstatus = 1;
3768 case 1: blue_icon = "flag_blue_taken"; break;
3769 case 2: blue_icon = "flag_blue_lost"; break;
3770 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3772 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3773 blue_icon = "flag_blue_shielded";
3775 blue_icon = string_null;
3778 switch(blueflag_prevstatus) {
3779 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3780 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3781 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3784 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3785 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3786 blue_icon_prevstatus = "flag_blue_shielded";
3788 blue_icon_prevstatus = string_null;
3792 if(mySize_x > mySize_y) {
3793 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3795 blueflag_pos = pos + eX * 0.5 * mySize_x;
3798 redflag_pos = pos + eX * 0.5 * mySize_x;
3800 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3802 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3804 blueflag_pos = pos + eY * 0.5 * mySize_y;
3807 redflag_pos = pos + eY * 0.5 * mySize_y;
3809 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3812 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3813 if(red_icon_prevstatus && f < 1)
3814 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);
3816 drawpic_skin(redflag_pos, red_icon, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * red_alpha * f, DRAWFLAG_NORMAL);
3818 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3819 if(blue_icon_prevstatus && f < 1)
3820 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);
3822 drawpic_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * blue_alpha * f, DRAWFLAG_NORMAL);
3825 // Keyhunt HUD modicon section
3826 float kh_runheretime;
3828 void HUD_Mod_KH_Reset(void)
3833 void HUD_Mod_KH(vector pos, vector mySize)
3835 mod_active = 1; // keyhunt should never hide the mod icons panel
3839 vector p, pa, kh_size, kh_asize;
3841 kh_keys = getstati(STAT_KH_KEYS);
3844 if(mySize_x > mySize_y)
3846 p_y = pos_y + 0.25 * mySize_y;
3847 pa = p - eY * 0.25 * mySize_y;
3849 kh_size_x = mySize_x * 0.25;
3850 kh_size_y = 0.75 * mySize_y;
3851 kh_asize_x = mySize_x * 0.25;
3852 kh_asize_y = mySize_y * 0.25;
3856 p_y = pos_y + 0.125 * mySize_y;
3857 pa = p - eY * 0.125 * mySize_y;
3859 kh_size_x = mySize_x * 0.5;
3860 kh_size_y = 0.375 * mySize_y;
3861 kh_asize_x = mySize_x * 0.5;
3862 kh_asize_y = mySize_y * 0.125;
3869 for(i = 0; i < 4; ++i)
3871 key = floor(kh_keys / pow(32, i)) & 31;
3873 if(keyteam == 30 && keycount <= 4)
3875 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3879 // this yields 8 exactly if "RUN HERE" shows
3884 kh_runheretime = time;
3885 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3890 for(i = 0; i < 4; ++i)
3892 key = floor(kh_keys / pow(32, i)) & 31;
3905 default: // owned or dropped
3910 a = a * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3911 aa = aa * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3917 drawpic_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3920 drawpic_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3923 drawpic_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3926 drawpic_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3931 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3934 drawpic_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3937 drawpic_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3940 drawpic_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3943 drawpic_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3947 if(mySize_x > mySize_y)
3949 p_x += 0.25 * mySize_x;
3950 pa_x += 0.25 * mySize_x;
3956 p_y = pos_y + 0.625 * mySize_y;
3957 pa_y = pos_y + 0.5 * mySize_y;
3963 p_x += 0.5 * mySize_x;
3964 pa_x += 0.5 * mySize_x;
3970 // Nexball HUD mod icon
3971 void HUD_Mod_NexBall(vector pos, vector mySize)
3973 float stat_items, nb_pb_starttime, dt, p;
3975 stat_items = getstati(STAT_ITEMS);
3976 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3978 if (stat_items & IT_KEY1)
3983 //Manage the progress bar if any
3984 if (nb_pb_starttime > 0)
3986 dt = mod(time - nb_pb_starttime, nb_pb_period);
3987 // one period of positive triangle
3988 p = 2 * dt / nb_pb_period;
3995 if(mySize_x > mySize_y)
3997 barsize = eX * p * mySize_x + eY * mySize_y;
4002 barsize = eX * mySize_x + eY * p * mySize_y;
4005 HUD_Panel_DrawProgressBar(pos, vertical, barsize, HUD_Panel_GetProgressBarColor("nexball"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4008 if (stat_items & IT_KEY1)
4009 drawpic_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4012 // Race/CTS HUD mod icons
4013 float crecordtime_prev; // last remembered crecordtime
4014 float crecordtime_change_time; // time when crecordtime last changed
4015 float srecordtime_prev; // last remembered srecordtime
4016 float srecordtime_change_time; // time when srecordtime last changed
4018 float race_status_time;
4019 float race_status_prev;
4020 string race_status_name_prev;
4021 void HUD_Mod_Race(vector pos, vector mySize)
4023 mod_active = 1; // race should never hide the mod icons panel
4025 me = playerslots[player_localentnum - 1];
4027 float f; // yet another function has this
4028 score = me.(scores[ps_primary]);
4030 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
4031 return; // no records in the actual race
4033 drawfont = hud_bigfont;
4035 // clientside personal record
4037 if(gametype == GAME_CTS)
4041 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4043 if(score && (score < t || !t)) {
4044 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4045 if(cvar("cl_autodemo_delete_keeprecords"))
4047 f = cvar("cl_autodemo_delete");
4049 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4053 if(t != crecordtime_prev) {
4054 crecordtime_prev = t;
4055 crecordtime_change_time = time;
4057 f = time - crecordtime_change_time;
4060 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);
4061 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);
4063 drawstring(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4064 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);
4065 drawstring_expanding(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL, f);
4066 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);
4070 t = race_server_record;
4071 if(t != srecordtime_prev) {
4072 srecordtime_prev = t;
4073 srecordtime_change_time = time;
4075 f = time - srecordtime_change_time;
4078 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);
4079 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);
4081 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);
4082 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);
4083 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);
4084 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);
4087 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4088 race_status_time = time + 5;
4089 race_status_prev = race_status;
4090 if (race_status_name_prev)
4091 strunzone(race_status_name_prev);
4092 race_status_name_prev = strzone(race_status_name);
4095 pos_x += mySize_x/2;
4098 a = bound(0, race_status_time - time, 1);
4101 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4105 rank = race_CheckName(race_status_name);
4107 rankname = race_PlaceName(rank);
4110 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4112 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4114 if(race_status == 0)
4115 drawpic_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4116 else if(race_status == 1) {
4117 drawpic_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4118 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4119 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4120 } else if(race_status == 2) {
4121 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4122 drawpic_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4124 drawpic_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4125 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4126 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4127 } else if(race_status == 3) {
4128 drawpic_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4129 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4130 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4133 if (race_status_time - time <= 0) {
4134 race_status_prev = -1;
4136 if(race_status_name)
4137 strunzone(race_status_name);
4138 race_status_name = string_null;
4139 if(race_status_name_prev)
4140 strunzone(race_status_name_prev);
4141 race_status_name_prev = string_null;
4143 drawfont = hud_font;
4146 float mod_prev; // previous state of mod_active to check for a change
4148 float mod_change; // "time" when mod_active changed
4150 void HUD_ModIcons(void)
4152 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !hud_configure)
4155 float id = HUD_PANEL_MODICONS;
4157 pos = HUD_Panel_GetPos(id);
4158 mySize = HUD_Panel_GetSize(id);
4160 if(mod_active != mod_prev) {
4162 mod_prev = mod_active;
4165 if(mod_active || hud_configure)
4166 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4168 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4171 HUD_Panel_DrawBg(id, pos, mySize, mod_alpha);
4174 padding = HUD_Panel_GetPadding(id);
4177 pos += '1 1 0' * padding;
4178 mySize -= '2 2 0' * padding;
4181 // these MUST be ran in order to update mod_active
4182 if(gametype == GAME_KEYHUNT)
4183 HUD_Mod_KH(pos, mySize);
4184 else if(gametype == GAME_CTF || hud_configure)
4185 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4186 else if(gametype == GAME_NEXBALL)
4187 HUD_Mod_NexBall(pos, mySize);
4188 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4189 HUD_Mod_Race(pos, mySize);
4192 // Draw pressed keys (#11)
4194 void HUD_DrawPressedKeys(void)
4196 float id = HUD_PANEL_PRESSEDKEYS;
4198 pos = HUD_Panel_GetPos(id);
4199 mySize = HUD_Panel_GetSize(id);
4201 HUD_Panel_DrawBg(id, pos, mySize, 0);
4203 padding = HUD_Panel_GetPadding(id);
4206 pos += '1 1 0' * padding;
4207 mySize -= '2 2 0' * padding;
4211 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4214 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4215 drawpic_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4216 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);
4217 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);
4218 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);
4219 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);
4220 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);
4223 // Handle chat as a panel (#12)
4227 float id = HUD_PANEL_CHAT;
4229 pos = HUD_Panel_GetPos(id);
4230 mySize = HUD_Panel_GetSize(id);
4232 HUD_Panel_DrawBg(id, pos, mySize, 0);
4234 padding = HUD_Panel_GetPadding(id);
4237 pos += '1 1 0' * padding;
4238 mySize -= '2 2 0' * padding;
4241 cvar_set("con_chatrect", "1");
4243 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4244 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4246 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4247 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4252 chatsize = cvar("con_chatsize");
4253 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4255 for(i = 0; i < cvar("con_chat"); ++i)
4257 if(i == cvar("con_chat") - 1)
4258 a = HUD_Panel_GetFgAlpha(id);
4260 a = HUD_Panel_GetFgAlpha(id) * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4261 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);
4266 // Engine info panel (#13)
4273 float frametimeavg1; // 1 frame ago
4274 float frametimeavg2; // 2 frames ago
4275 void HUD_EngineInfo(void)
4277 float id = HUD_PANEL_ENGINEINFO;
4279 pos = HUD_Panel_GetPos(id);
4280 mySize = HUD_Panel_GetSize(id);
4282 HUD_Panel_DrawBg(id, pos, mySize, 0);
4284 padding = HUD_Panel_GetPadding(id);
4287 pos += '1 1 0' * padding;
4288 mySize -= '2 2 0' * padding;
4291 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4293 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4294 frametimeavg2 = frametimeavg1;
4295 frametimeavg1 = frametimeavg;
4298 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4299 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.
4301 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
4302 prevfps = (1/frametime);
4303 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"
4309 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4311 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4313 prevfps_time = time;
4318 color = HUD_Get_Num_Color (prevfps, 100);
4319 drawfont = hud_bigfont;
4320 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), mySize, mySize_y, color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4321 drawfont = hud_font;
4329 void HUD_ShowSpeed(void)
4332 float pos, conversion_factor;
4333 string speed, zspeed, unit;
4335 switch(cvar("cl_showspeed_unit"))
4340 conversion_factor = 1.0;
4344 conversion_factor = 1.0;
4348 conversion_factor = 0.0254;
4352 conversion_factor = 0.0254 * 3.6;
4356 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4360 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4364 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4366 numsize_x = numsize_y = cvar("cl_showspeed_size");
4367 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4369 drawfont = hud_bigfont;
4370 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4372 if (cvar("cl_showspeed_z") == 1) {
4373 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4374 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4377 drawfont = hud_font;
4380 vector acc_prevspeed;
4384 void HUD_ShowAcceleration(void)
4386 float acceleration, sz, scale, alpha, f;
4387 vector pos, top, rgb;
4388 top_x = vid_conwidth/2;
4391 f = time - acc_prevtime;
4392 if(cvar("cl_showacceleration_z"))
4393 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4395 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4396 acc_prevspeed = pmove_vel;
4397 acc_prevtime = time;
4399 f = bound(0, f * 10, 1);
4400 acc_avg = acc_avg * (1 - f) + acceleration * f;
4401 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4403 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4405 sz = cvar("cl_showacceleration_size");
4406 scale = cvar("cl_showacceleration_scale");
4407 alpha = cvar("cl_showacceleration_alpha");
4408 if (cvar("cl_showacceleration_color_custom"))
4409 rgb = stov(cvar_string("cl_showacceleration_color"));
4412 if (acceleration < 0) {
4413 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4414 } else if (acceleration > 0) {
4415 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4419 if (acceleration > 0)
4420 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4421 else if (acceleration < 0)
4422 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4425 void HUD_Reset (void)
4427 // reset gametype specific icons
4428 if(gametype == GAME_KEYHUNT)
4430 else if(gametype == GAME_CTF)
4431 HUD_Mod_CTF_Reset();
4434 void HUD_Main (void)
4436 if(disable_menu_alphacheck == 1)
4437 menu_fade_alpha = 1;
4439 menu_fade_alpha = (1 - cvar("_menu_alpha"));
4440 hud_fg_alpha = cvar("hud_fg_alpha");
4442 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4443 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4444 hud_color_bg_team = cvar("hud_color_bg_team");
4446 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4447 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4449 hud_configure = cvar("_hud_configure");
4453 // HUD configure visible grid
4454 if(hud_configure && cvar("hud_configure_grid") && cvar("hud_configure_grid_alpha"))
4458 for(i = 0; i < 1/bound(0.005, cvar("hud_configure_grid_x"), 0.2); ++i)
4460 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);
4463 for(i = 0; i < 1/bound(0.005, cvar("hud_configure_grid_y"), 0.2); ++i)
4465 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);
4469 if(cvar_string("hud_dock") != "" && cvar_string("hud_dock") != "0")
4470 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...
4472 if(HUD_Panel_CheckActive(HUD_PANEL_RADAR) || hud_configure)
4473 if(cvar_string("hud_radar") != "0" && (cvar("hud_radar") == 2 || teamplay))
4475 if(HUD_Panel_CheckActive(HUD_PANEL_WEAPONICONS) || hud_configure)
4477 if(HUD_Panel_CheckActive(HUD_PANEL_INVENTORY) || hud_configure)
4479 if(HUD_Panel_CheckActive(HUD_PANEL_POWERUPS) || hud_configure)
4481 if(HUD_Panel_CheckActive(HUD_PANEL_HEALTHARMOR) || hud_configure)
4483 if(HUD_Panel_CheckActive(HUD_PANEL_NOTIFY) || hud_configure)
4485 if(HUD_Panel_CheckActive(HUD_PANEL_TIMER) || hud_configure)
4487 if(HUD_Panel_CheckActive(HUD_PANEL_SCORE) || hud_configure)
4489 if(HUD_Panel_CheckActive(HUD_PANEL_RACETIMER) || hud_configure)
4490 if(gametype == GAME_RACE || gametype == GAME_CTS || hud_configure)
4492 if(HUD_Panel_CheckActive(HUD_PANEL_VOTE) || hud_configure)
4494 if(HUD_Panel_CheckActive(HUD_PANEL_MODICONS) || hud_configure)
4497 if(HUD_Panel_CheckActive(HUD_PANEL_PRESSEDKEYS) || hud_configure)
4498 if(spectatee_status > 0 || cvar("hud_pressedkeys") >= 2 || hud_configure)
4499 HUD_DrawPressedKeys();
4500 if(HUD_Panel_CheckActive(HUD_PANEL_CHAT) || hud_configure)
4503 cvar_set("con_chatrect", "0");
4504 if(HUD_Panel_CheckActive(HUD_PANEL_ENGINEINFO) || hud_configure)
4507 // TODO hud_'ify these
4508 if (cvar("cl_showspeed"))
4510 if (cvar("cl_showacceleration"))
4511 HUD_ShowAcceleration();
4513 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)
4514 localcmd("cmd selectteam auto; cmd join\n");
4516 if (!hud_configure) // hud config mode disabled, enable normal alpha stuff again
4517 disable_menu_alphacheck = 0;