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)
17 if (theBorderSize_x <= 0 && theBorderSize_y <= 0) // no border
19 // draw only the central part
20 drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
27 //pic = draw_UseSkinFor(pic);
28 width = eX * theSize_x;
29 height = eY * theSize_y;
30 if(theSize_x <= theBorderSize_x * 2)
32 // not wide enough... draw just left and right then
33 bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
34 if(theSize_y <= theBorderSize_y * 2)
36 // not high enough... draw just corners
37 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
38 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
39 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
40 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
41 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
45 dY = theBorderSize_x * eY;
46 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
47 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
48 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
49 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);
50 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
51 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);
56 if(theSize_y <= theBorderSize_y * 2)
58 // not high enough... draw just top and bottom then
59 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
60 dX = theBorderSize_x * eX;
61 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
62 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
63 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
64 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
65 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);
66 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);
70 dX = theBorderSize_x * eX;
71 dY = theBorderSize_x * eY;
72 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
73 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
74 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
75 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
76 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
77 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
78 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
79 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
80 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
85 vector HUD_Get_Num_Color (float x, float maxvalue)
93 else if(x > maxvalue * 0.75) {
94 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
95 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
98 else if(x > maxvalue * 0.5) {
99 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
100 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
101 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
103 else if(x > maxvalue * 0.25) {
106 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
108 else if(x > maxvalue * 0.1) {
110 color_y = (x-20)*90/27/100; // green value between 0 -> 1
111 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
121 float stringwidth_colors(string s, vector theSize)
123 return stringwidth(s, TRUE, theSize);
126 float stringwidth_nocolors(string s, vector theSize)
128 return stringwidth(s, FALSE, theSize);
131 #define CENTERPRINT_MAX_LINES 30
132 string centerprint_messages[CENTERPRINT_MAX_LINES];
133 float centerprint_width[CENTERPRINT_MAX_LINES];
134 float centerprint_time;
135 float centerprint_expire;
136 float centerprint_num;
137 float centerprint_offset_hint;
138 vector centerprint_fontsize;
140 void centerprint(string strMessage)
142 float i, j, n, hcount;
145 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
147 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
149 if(cvar("scr_centertime") <= 0)
155 // strip trailing newlines
156 j = strlen(strMessage) - 1;
157 while(substring(strMessage, j, 1) == "\n" && j >= 0)
159 strMessage = substring(strMessage, 0, j + 1);
164 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
166 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
168 strMessage = substring(strMessage, j, strlen(strMessage) - j);
169 centerprint_offset_hint = j;
174 // if we get here, we have a message. Initialize its height.
177 n = tokenizebyseparator(strMessage, "\n");
179 for(j = 0; j < n; ++j)
181 getWrappedLine_remaining = argv(j);
182 while(getWrappedLine_remaining)
184 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
185 if(centerprint_messages[i] != s) // don't fade the same message in, looks stupid
186 centerprint_time = time;
187 if(centerprint_messages[i])
188 strunzone(centerprint_messages[i]);
189 centerprint_messages[i] = strzone(s);
190 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
193 // half height for empty lines looks better
199 if(i >= CENTERPRINT_MAX_LINES)
205 h = centerprint_fontsize_y*hcount;
207 havail = vid_conheight;
208 if(cvar("con_chatpos") < 0)
209 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
210 if(havail > vid_conheight - 70)
211 havail = vid_conheight - 70; // avoid overlapping HUD
214 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
216 // here, the centerprint would cover the crosshair. REALLY BAD.
217 forbiddenmin = vid_conheight * 0.5 - h - 16;
218 forbiddenmax = vid_conheight * 0.5 + 16;
220 allowedmin = scoreboard_bottom;
221 allowedmax = havail - h;
222 preferred = (havail - h)/2;
225 // possible orderings (total: 4! / 4 = 6)
226 // allowedmin allowedmax forbiddenmin forbiddenmax
227 // forbiddenmin forbiddenmax allowedmin allowedmax
228 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
230 // forbidden doesn't matter in this case
231 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
233 // allowedmin forbiddenmin allowedmax forbiddenmax
234 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
236 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
238 // allowedmin forbiddenmin forbiddenmax allowedmax
239 else if(allowedmin < forbiddenmin)
241 // make sure the forbidden zone is not covered
242 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
243 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
245 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
247 // forbiddenmin allowedmin allowedmax forbiddenmax
248 else if(allowedmax < forbiddenmax)
250 // it's better to leave the allowed zone (overlap with scoreboard) than
251 // to cover the forbidden zone (crosshair)
252 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
253 centerprint_start_y = forbiddenmax;
255 centerprint_start_y = forbiddenmin;
257 // forbiddenmin allowedmin forbiddenmax allowedmax
260 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
267 centerprint_expire = time + cvar("scr_centertime");
270 void HUD_DrawCenterPrint (void)
277 if(time - centerprint_time < 0.25)
278 a = (time - centerprint_time) / 0.25;
280 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
287 if(centerprint_num * cvar("scr_centersize") > 24 && scoreboard_active) // 24 = height of Scoreboard text
288 centerprint_start_y = scoreboard_bottom + centerprint_fontsize_y;
290 pos = centerprint_start;
291 for (i=0; i<centerprint_num; i = i + 1)
293 ts = centerprint_messages[i];
294 drawfontscale = sz * '1 1 0';
295 drawfont = hud_bigfont;
296 pos_x = (vid_conwidth - stringwidth(ts, TRUE, centerprint_fontsize)) * 0.5;
299 drawcolorcodedstring(pos + '0 1 0' * (1 - sz) * 0.5 *centerprint_fontsize_y, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
300 pos_y = pos_y + centerprint_fontsize_y;
303 // half height for empty lines looks better
304 pos_y = pos_y + sz * centerprint_fontsize_y * 0.5;
305 drawfontscale = '1 1 0';
310 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
312 position_x -= 2 / 3 * strlen(text) * scale_x;
313 drawstring(position, text, scale, rgb, alpha, flag);
316 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
318 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
319 drawstring(position, text, scale, rgb, alpha, flag);
322 // return the string of the given race place
323 string race_PlaceName(float pos) {
331 return strcat(ftos(pos), "th");
334 // return the string of the onscreen race timer
335 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
343 if(histime == 0) // goal hit
347 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
357 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
363 lapstr = strcat(" (-", ftos(lapdelta), "L)");
366 else if(lapdelta < 0)
368 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
372 else if(histime > 0) // anticipation
374 if(mytime >= histime)
375 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
377 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
384 cpname = "Start line";
386 cpname = "Finish line";
388 cpname = strcat("Intermediate ", ftos(cp));
390 cpname = "Finish line";
393 return strcat(col, cpname);
394 else if(hisname == "")
395 return strcat(col, cpname, " (", timestr, ")");
397 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
400 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
401 float race_CheckName(string net_name) {
403 for (i=RANKINGS_CNT-1;i>=0;--i)
404 if(grecordholder[i] == net_name)
416 void HUD_Panel_ExportCfg(string cfgname)
419 fh = fopen(strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg"), FILE_WRITE);
422 fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
423 fputs(fh, strcat("seta hud_panel_bg \"", cvar_string("hud_panel_bg"), "\"", "\n"));
424 fputs(fh, strcat("seta hud_panel_bg_color \"", cvar_string("hud_panel_bg_color"), "\"", "\n"));
425 fputs(fh, strcat("seta hud_panel_bg_color_team \"", cvar_string("hud_panel_bg_color_team"), "\"", "\n"));
426 fputs(fh, strcat("seta hud_panel_bg_alpha \"", cvar_string("hud_panel_bg_alpha"), "\"", "\n"));
427 fputs(fh, strcat("seta hud_panel_bg_border \"", cvar_string("hud_panel_bg_border"), "\"", "\n"));
428 fputs(fh, strcat("seta hud_panel_bg_padding \"", cvar_string("hud_panel_bg_padding"), "\"", "\n"));
429 fputs(fh, strcat("seta hud_panel_fg_alpha \"", cvar_string("hud_panel_fg_alpha"), "\"", "\n"));
432 fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
433 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
434 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
435 fputs(fh, strcat("seta hud_dock_alpha \"", cvar_string("hud_dock_alpha"), "\"", "\n"));
438 fputs(fh, strcat("seta hud_progressbar_alpha \"", cvar_string("hud_progressbar_alpha"), "\"", "\n"));
439 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
440 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
441 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
442 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
443 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
444 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
447 fputs(fh, strcat("seta _hud_panelorder \"", cvar_string("_hud_panelorder"), "\"", "\n"));
450 fputs(fh, strcat("seta hud_configure_grid \"", cvar_string("hud_configure_grid"), "\"", "\n"));
451 fputs(fh, strcat("seta hud_configure_grid_xsize \"", cvar_string("hud_configure_grid_xsize"), "\"", "\n"));
452 fputs(fh, strcat("seta hud_configure_grid_ysize \"", cvar_string("hud_configure_grid_ysize"), "\"", "\n"));
455 fputs(fh, strcat("seta scr_centerpos \"", cvar_string("scr_centerpos"), "\"", "\n"));
458 // common cvars for all panels
460 for (i = 0; i < HUD_PANEL_NUM; ++i)
464 fputs(fh, strcat("seta hud_panel_", panel_name, " ", cvar_string(strcat("hud_panel_", panel_name)), "\n"));
465 fputs(fh, strcat("seta hud_panel_", panel_name, "_pos \"", cvar_string(strcat("hud_panel_", panel_name, "_pos")), "\"", "\n"));
466 fputs(fh, strcat("seta hud_panel_", panel_name, "_size \"", cvar_string(strcat("hud_panel_", panel_name, "_size")), "\"", "\n"));
467 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg \"", cvar_string(strcat("hud_panel_", panel_name, "_bg")), "\"", "\n"));
468 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_color \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_color")), "\"", "\n"));
469 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_color_team \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_color_team")), "\"", "\n"));
470 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_alpha")), "\"", "\n"));
471 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_border \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_border")), "\"", "\n"));
472 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_padding \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_padding")), "\"", "\n"));
474 case HUD_PANEL_WEAPONS:
475 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble")), "\"", "\n"));
476 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_padding \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_padding")), "\"", "\n"));
477 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_outofammo \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_outofammo")), "\"", "\n"));
478 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_donthave \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_donthave")), "\"", "\n"));
479 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_unavailable \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_unavailable")), "\"", "\n"));
480 fputs(fh, strcat("seta hud_panel_", panel_name, "_ammo_color \"", cvar_string(strcat("hud_panel_", panel_name, "_ammo_color")), "\"", "\n"));
481 fputs(fh, strcat("seta hud_panel_", panel_name, "_ammo_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_ammo_alpha")), "\"", "\n"));
482 fputs(fh, strcat("seta hud_panel_", panel_name, "_aspect \"", cvar_string(strcat("hud_panel_", panel_name, "_aspect")), "\"", "\n"));
485 fputs(fh, strcat("seta hud_panel_", panel_name, "_onlycurrent \"", cvar_string(strcat("hud_panel_", panel_name, "_onlycurrent")), "\"", "\n"));
486 fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
488 case HUD_PANEL_POWERUPS:
489 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\"", "\n"));
490 fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
491 fputs(fh, strcat("seta hud_panel_", panel_name, "_baralign \"", cvar_string(strcat("hud_panel_", panel_name, "_baralign")), "\"", "\n"));
492 fputs(fh, strcat("seta hud_panel_", panel_name, "_progressbar \"", cvar_string(strcat("hud_panel_", panel_name, "_progressbar")), "\"", "\n"));
494 case HUD_PANEL_HEALTHARMOR:
495 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\n"));
496 fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
497 fputs(fh, strcat("seta hud_panel_", panel_name, "_baralign \"", cvar_string(strcat("hud_panel_", panel_name, "_baralign")), "\"", "\n"));
498 fputs(fh, strcat("seta hud_panel_", panel_name, "_progressbar \"", cvar_string(strcat("hud_panel_", panel_name, "_progressbar")), "\"", "\n"));
500 case HUD_PANEL_NOTIFY:
501 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\"", "\n"));
502 fputs(fh, strcat("seta hud_panel_", panel_name, "_print \"", cvar_string(strcat("hud_panel_", panel_name, "_print")), "\"", "\n"));
504 case HUD_PANEL_RADAR:
505 fputs(fh, strcat("seta hud_panel_", panel_name, "_foreground_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_foreground_alpha")), "\"", "\n"));
508 fputs(fh, strcat("seta hud_panel_", panel_name, "_alreadyvoted_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_alreadyvoted_alpha")), "\"", "\n"));
510 case HUD_PANEL_PRESSEDKEYS:
511 fputs(fh, strcat("seta hud_panel_", panel_name, "_aspect \"", cvar_string(strcat("hud_panel_", panel_name, "_aspect")), "\"", "\n"));
513 case HUD_PANEL_INFOMESSAGES:
514 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\"", "\n"));
519 fputs(fh, strcat("menu_sync", "\n")); // force the menu to reread the cvars, so that the dialogs are updated
521 print("^2Successfully exported to hud_", autocvar_hud_skin, "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
526 const float hlBorderSize = 4;
527 const string hlBorder = "gfx/hud/default/border_highlighted";
528 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
529 void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
531 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
532 drawpic_tiled(panel_pos - '1 1 0' * myBorder, hlBorder, '8 1 0' * hlBorderSize, eX * (panel_size_x + 2 * myBorder) + eY * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
533 drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * (panel_size_y + 2 * myBorder - hlBorderSize), hlBorder, '8 1 0' * hlBorderSize, eX * (panel_size_x + 2 * myBorder) + eY * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
534 drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * hlBorderSize, hlBorder2, '1 8 0' * hlBorderSize, eY * (panel_size_y + 2 * myBorder - 2 * hlBorderSize) + eX * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
535 drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * hlBorderSize + eX * (panel_size_x + 2 * myBorder - hlBorderSize), hlBorder2, '1 8 0' * hlBorderSize, eY * (panel_size_y + 2 * myBorder - 2 * hlBorderSize) + eX * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
538 // draw the background/borders
539 #define HUD_Panel_DrawBg(alpha)\
541 draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * alpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));\
542 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
543 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);
545 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
552 pic = strcat(hud_skin_path, "/statusbar_vertical");
553 if(precache_pic(pic) == "") {
554 pic = "gfx/hud/default/statusbar_vertical";
556 drawsubpic(pos, eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, pic, '0 0 0', '1 0.25 0', color, alpha, drawflag);
557 if(mySize_y/mySize_x > 2)
558 drawsubpic(pos + eY * mySize_x, eY * (mySize_y - 2 * mySize_x) + eX * mySize_x, pic, '0 0.25 0', '1 0.5 0', color, alpha, drawflag);
559 drawsubpic(pos + eY * mySize_y - eY * min(mySize_y * 0.5, mySize_x), eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, pic, '0 0.75 0', '1 0.25 0', color, alpha, drawflag);
561 pic = strcat(hud_skin_path, "/statusbar");
562 if(precache_pic(pic) == "") {
563 pic = "gfx/hud/default/statusbar";
565 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
566 if(mySize_x/mySize_y > 2)
567 drawsubpic(pos + eX * mySize_y, eX * (mySize_x - 2 * mySize_y) + eY * mySize_y, pic, '0.25 0 0', '0.5 1 0', color, alpha, drawflag);
568 drawsubpic(pos + eX * mySize_x - eX * min(mySize_x * 0.5, mySize_y), eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0.75 0 0', '0.25 1 0', color, alpha, drawflag);
572 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
578 pic = strcat(hud_skin_path, "/num_leading");
579 if(precache_pic(pic) == "") {
580 pic = "gfx/hud/default/num_leading";
583 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
584 if(mySize_x/mySize_y > 2)
585 drawsubpic(pos + eX * mySize_y, eX * (mySize_x - 2 * mySize_y) + eY * mySize_y, pic, '0.25 0 0', '0.5 1 0', color, alpha, drawflag);
586 drawsubpic(pos + eX * mySize_x - eX * min(mySize_x * 0.5, mySize_y), eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0.75 0 0', '0.25 1 0', color, alpha, drawflag);
589 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
590 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
601 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
602 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
604 for (i = 0; i < HUD_PANEL_NUM; ++i) {
605 if(i == highlightedPanel || !panel_enabled)
608 HUD_Panel_UpdatePosSizeForId(i)
610 panel_pos -= '1 1 0' * panel_bg_border;
611 panel_size += '2 2 0' * panel_bg_border;
613 if(myPos_y + mySize_y < panel_pos_y)
615 if(myPos_y > panel_pos_y + panel_size_y)
618 if(myPos_x + mySize_x < panel_pos_x)
620 if(myPos_x > panel_pos_x + panel_size_x)
623 // OK, there IS a collision.
625 myCenter_x = myPos_x + 0.5 * mySize_x;
626 myCenter_y = myPos_y + 0.5 * mySize_y;
628 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
629 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
631 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
633 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
634 myTarget_x = panel_pos_x - mySize_x;
635 else // push it upwards
636 myTarget_y = panel_pos_y - mySize_y;
638 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
640 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
641 myTarget_x = panel_pos_x + panel_size_x;
642 else // push it upwards
643 myTarget_y = panel_pos_y - mySize_y;
645 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
647 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
648 myTarget_x = panel_pos_x - mySize_x;
649 else // push it downwards
650 myTarget_y = panel_pos_y + panel_size_y;
652 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
654 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
655 myTarget_x = panel_pos_x + panel_size_x;
656 else // push it downwards
657 myTarget_y = panel_pos_y + panel_size_y;
659 if(cvar("hud_configure_checkcollisions_debug"))
660 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
666 void HUD_Panel_SetPos(vector pos)
668 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
672 if(cvar("hud_configure_checkcollisions_debug"))
673 drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
675 if(autocvar_hud_configure_grid)
677 pos_x = floor((pos_x/vid_conwidth)/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
678 pos_y = floor((pos_y/vid_conheight)/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
681 if(hud_configure_checkcollisions)
682 pos = HUD_Panel_CheckMove(pos, mySize);
684 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
685 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
688 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
690 HUD_Panel_GetName(highlightedPanel);
691 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
694 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
695 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
705 ratio = mySize_x/mySize_y;
707 for (i = 0; i < HUD_PANEL_NUM; ++i) {
708 if(i == highlightedPanel || !panel_enabled)
711 HUD_Panel_UpdatePosSizeForId(i)
713 panel_pos -= '1 1 0' * panel_bg_border;
714 panel_size += '2 2 0' * panel_bg_border;
716 targEndPos = panel_pos + panel_size;
718 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
719 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
722 if (resizeCorner == 1)
724 // check if this panel is on our way
725 if (resizeorigin_x <= panel_pos_x)
727 if (resizeorigin_y <= panel_pos_y)
729 if (targEndPos_x <= resizeorigin_x - mySize_x)
731 if (targEndPos_y <= resizeorigin_y - mySize_y)
734 // there is a collision:
735 // detect which side of the panel we are facing is actually limiting the resizing
736 // (which side the resize direction finds for first) and reduce the size up to there
738 // dist is the distance between resizeorigin and the "analogous" point of the panel
739 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
740 dist_x = resizeorigin_x - targEndPos_x;
741 dist_y = resizeorigin_y - targEndPos_y;
742 if (dist_y <= 0 || dist_x / dist_y > ratio)
743 mySize_x = min(mySize_x, dist_x);
745 mySize_y = min(mySize_y, dist_y);
747 else if (resizeCorner == 2)
749 if (resizeorigin_x >= targEndPos_x)
751 if (resizeorigin_y <= panel_pos_y)
753 if (panel_pos_x >= resizeorigin_x + mySize_x)
755 if (targEndPos_y <= resizeorigin_y - mySize_y)
758 dist_x = panel_pos_x - resizeorigin_x;
759 dist_y = resizeorigin_y - targEndPos_y;
760 if (dist_y <= 0 || dist_x / dist_y > ratio)
761 mySize_x = min(mySize_x, dist_x);
763 mySize_y = min(mySize_y, dist_y);
765 else if (resizeCorner == 3)
767 if (resizeorigin_x <= panel_pos_x)
769 if (resizeorigin_y >= targEndPos_y)
771 if (targEndPos_x <= resizeorigin_x - mySize_x)
773 if (panel_pos_y >= resizeorigin_y + mySize_y)
776 dist_x = resizeorigin_x - targEndPos_x;
777 dist_y = panel_pos_y - resizeorigin_y;
778 if (dist_y <= 0 || dist_x / dist_y > ratio)
779 mySize_x = min(mySize_x, dist_x);
781 mySize_y = min(mySize_y, dist_y);
783 else if (resizeCorner == 4)
785 if (resizeorigin_x >= targEndPos_x)
787 if (resizeorigin_y >= targEndPos_y)
789 if (panel_pos_x >= resizeorigin_x + mySize_x)
791 if (panel_pos_y >= resizeorigin_y + mySize_y)
794 dist_x = panel_pos_x - resizeorigin_x;
795 dist_y = panel_pos_y - resizeorigin_y;
796 if (dist_y <= 0 || dist_x / dist_y > ratio)
797 mySize_x = min(mySize_x, dist_x);
799 mySize_y = min(mySize_y, dist_y);
801 if(cvar("hud_configure_checkcollisions_debug"))
802 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
808 void HUD_Panel_SetPosSize(vector mySize)
810 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
812 resizeorigin = panel_click_resizeorigin;
815 // minimum panel size cap
816 mySize_x = max(0.025 * vid_conwidth, mySize_x);
817 mySize_y = max(0.025 * vid_conheight, mySize_y);
819 if(highlightedPanel == 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.
821 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
822 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
825 // collision testing|
826 // -----------------+
828 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
829 if(resizeCorner == 1) {
830 myPos_x = resizeorigin_x - mySize_x;
831 myPos_y = resizeorigin_y - mySize_y;
832 } else if(resizeCorner == 2) {
833 myPos_x = resizeorigin_x;
834 myPos_y = resizeorigin_y - mySize_y;
835 } else if(resizeCorner == 3) {
836 myPos_x = resizeorigin_x - mySize_x;
837 myPos_y = resizeorigin_y;
838 } else { // resizeCorner == 4
839 myPos_x = resizeorigin_x;
840 myPos_y = resizeorigin_y;
843 // left/top screen edges
845 mySize_x = mySize_x + myPos_x;
847 mySize_y = mySize_y + myPos_y;
849 // bottom/right screen edges
850 if(myPos_x + mySize_x > vid_conwidth)
851 mySize_x = vid_conwidth - myPos_x;
852 if(myPos_y + mySize_y > vid_conheight)
853 mySize_y = vid_conheight - myPos_y;
855 if(cvar("hud_configure_checkcollisions_debug"))
856 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
858 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
859 if(autocvar_hud_configure_grid)
861 mySize_x = floor((mySize_x/vid_conwidth)/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
862 mySize_y = floor((mySize_y/vid_conheight)/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
865 if(hud_configure_checkcollisions)
866 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
868 // 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)
869 mySize_x = max(0.025 * vid_conwidth, mySize_x);
870 mySize_y = max(0.025 * vid_conheight, mySize_y);
872 // do another pos check, as size might have changed by now
873 if(resizeCorner == 1) {
874 myPos_x = resizeorigin_x - mySize_x;
875 myPos_y = resizeorigin_y - mySize_y;
876 } else if(resizeCorner == 2) {
877 myPos_x = resizeorigin_x;
878 myPos_y = resizeorigin_y - mySize_y;
879 } else if(resizeCorner == 3) {
880 myPos_x = resizeorigin_x - mySize_x;
881 myPos_y = resizeorigin_y;
882 } else { // resizeCorner == 4
883 myPos_x = resizeorigin_x;
884 myPos_y = resizeorigin_y;
887 if(cvar("hud_configure_checkcollisions_debug"))
888 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
890 HUD_Panel_GetName(highlightedPanel);
892 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
893 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
895 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
896 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
900 float prevMouseClicked; // previous state
901 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
902 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
905 float menu_enabled_time;
906 float pressed_key_time;
907 void HUD_Panel_Arrow_Action(float nPrimary)
909 if (highlightedPanel_prev == -1 || mouseClicked)
912 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
915 if(autocvar_hud_configure_grid)
917 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
919 if (hudShiftState & S_SHIFT)
920 step = bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
922 step = 2 * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
926 if (hudShiftState & S_SHIFT)
927 step = bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
929 step = 2 * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
934 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
935 step = vid_conheight;
938 if (hudShiftState & S_SHIFT)
939 step = (step / 256); // more precision
941 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
944 highlightedPanel = highlightedPanel_prev;
946 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
948 vector prev_pos, prev_size;
949 prev_pos = panel_pos;
950 prev_size = panel_size;
952 if (hudShiftState & S_ALT) // resize
954 highlightedAction = 1;
955 if(nPrimary == K_UPARROW)
957 else if(nPrimary == K_RIGHTARROW)
959 else if(nPrimary == K_LEFTARROW)
961 else // if(nPrimary == K_DOWNARROW)
964 // ctrl+arrow reduces the size, instead of increasing it
965 // Note that ctrl disables collisions check too, but it's fine
966 // since we don't collide with anything reducing the size
967 if (hudShiftState & S_CTRL) {
969 resizeCorner = 5 - resizeCorner;
974 panel_click_resizeorigin = panel_pos;
975 if(resizeCorner == 1) {
976 panel_click_resizeorigin += mySize;
978 } else if(resizeCorner == 2) {
979 panel_click_resizeorigin_y += mySize_y;
981 } else if(resizeCorner == 3) {
982 panel_click_resizeorigin_x += mySize_x;
984 } else { // resizeCorner == 4
987 HUD_Panel_SetPosSize(mySize);
991 highlightedAction = 2;
994 if(nPrimary == K_UPARROW)
996 else if(nPrimary == K_DOWNARROW)
998 else if(nPrimary == K_LEFTARROW)
1000 else // if(nPrimary == K_RIGHTARROW)
1003 HUD_Panel_SetPos(pos);
1006 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
1008 if (prev_pos != panel_pos || prev_size != panel_size)
1011 panel_pos_backup = prev_pos;
1012 panel_size_backup = prev_size;
1013 highlightedPanel_backup = highlightedPanel;
1017 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1019 if(!autocvar__hud_configure)
1022 // allow console bind to work
1025 con_keys = findkeysforcommand("toggleconsole");
1026 keys = tokenize(con_keys);
1028 float hit_con_bind, i;
1029 for (i = 0; i < keys; ++i)
1031 if(nPrimary == stof(argv(i)))
1035 if(bInputType == 0) {
1036 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1037 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1038 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1040 else if(bInputType == 1) {
1041 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1042 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1043 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1046 if(nPrimary == K_MOUSE1)
1048 if(bInputType == 0) { // key pressed
1052 else if(bInputType == 1) {// key released
1057 else if(nPrimary == K_ESCAPE)
1059 if (bInputType == 1)
1061 disable_menu_alphacheck = 1;
1063 menu_enabled_time = time;
1064 localcmd("menu_showhudexit\n");
1066 else if(hudShiftState & S_CTRL)
1071 if(nPrimary == K_SPACE) // enable/disable highlighted panel or dock
1073 if (bInputType == 1)
1076 if (highlightedPanel_prev != -1)
1077 cvar_set(strcat("hud_panel_", panel_name), ftos(!(panel_enabled)));
1079 cvar_set(strcat("hud_dock"), (autocvar_hud_dock == "") ? "dock" : "");
1081 if(nPrimary == 'c') // copy highlighted panel size
1083 if (bInputType == 1)
1086 if (highlightedPanel_prev != -1)
1088 panel_size_copied = panel_size;
1089 highlightedPanel_copied = highlightedPanel_prev;
1092 else if(nPrimary == 'v') // past copied size on the highlighted panel
1094 if (bInputType == 1)
1097 if (highlightedPanel_copied == -1 || highlightedPanel_prev == -1)
1100 HUD_Panel_UpdatePosSizeForId(highlightedPanel_prev)
1102 // reduce size if it'd go beyond screen boundaries
1103 vector tmp_size = panel_size_copied;
1104 if (panel_pos_x + panel_size_copied_x > vid_conwidth)
1105 tmp_size_x = vid_conwidth - panel_pos_x;
1106 if (panel_pos_y + panel_size_copied_y > vid_conheight)
1107 tmp_size_y = vid_conheight - panel_pos_y;
1109 if (panel_size == tmp_size)
1113 panel_pos_backup = panel_pos;
1114 panel_size_backup = panel_size;
1115 highlightedPanel_backup = highlightedPanel_prev;
1118 s = strcat(ftos(tmp_size_x/vid_conwidth), " ", ftos(tmp_size_y/vid_conheight));
1119 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
1121 else if(nPrimary == 'z') // undo last action
1123 if (bInputType == 1)
1125 //restore previous values
1126 if (highlightedPanel_backup != -1)
1128 HUD_Panel_GetName(highlightedPanel_backup)
1130 s = strcat(ftos(panel_pos_backup_x/vid_conwidth), " ", ftos(panel_pos_backup_y/vid_conheight));
1131 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
1132 s = strcat(ftos(panel_size_backup_x/vid_conwidth), " ", ftos(panel_size_backup_y/vid_conheight));
1133 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
1134 highlightedPanel_backup = -1;
1138 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1140 if (bInputType == 1)
1142 pressed_key_time = 0;
1145 else if (pressed_key_time == 0)
1146 pressed_key_time = time;
1148 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1150 else if(hit_con_bind)
1153 return true; // Suppress ALL other input
1156 float HUD_Panel_HighlightCheck()
1162 while(j <= HUD_PANEL_NUM)
1167 HUD_Panel_UpdatePosSizeForId(i)
1169 panelPos = panel_pos;
1170 panelSize = panel_size;
1171 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1174 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1178 // resize from topleft border
1179 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)
1183 // resize from topright border
1184 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)
1188 // resize from bottomleft border
1189 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)
1193 // resize from bottomright border
1194 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)
1202 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1203 void HUD_Panel_FirstInDrawQ(float id)
1206 var float place = -1;
1207 // find out where in the array our current id is, save into place
1208 for(i = 0; i < HUD_PANEL_NUM; ++i)
1210 if(panel_order[i] == id)
1216 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1218 place = HUD_PANEL_NUM - 1;
1220 // move all ids up by one step in the array until "place"
1221 for(i = place; i > 0; --i)
1223 panel_order[i] = panel_order[i-1];
1225 // now save the new top id
1226 panel_order[0] = id;
1228 // let's save them into the cvar by some strcat trickery
1230 for(i = 0; i < HUD_PANEL_NUM; ++i)
1232 s = strcat(s, ftos(panel_order[i]), " ");
1234 cvar_set("_hud_panelorder", s);
1235 if(hud_panelorder_prev)
1236 strunzone(hud_panelorder_prev);
1237 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1240 void HUD_Panel_Highlight()
1246 while(j <= HUD_PANEL_NUM)
1251 HUD_Panel_UpdatePosSizeForId(i)
1253 panelPos = panel_pos;
1254 panelSize = panel_size;
1255 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1258 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1260 highlightedPanel = i;
1261 HUD_Panel_FirstInDrawQ(i);
1262 highlightedAction = 1;
1263 panel_click_distance = mousepos - panelPos;
1266 // resize from topleft border
1267 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)
1269 highlightedPanel = i;
1270 HUD_Panel_FirstInDrawQ(i);
1271 highlightedAction = 2;
1273 panel_click_distance = mousepos - panelPos;
1274 panel_click_resizeorigin = panelPos + panelSize;
1277 // resize from topright border
1278 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)
1280 highlightedPanel = i;
1281 HUD_Panel_FirstInDrawQ(i);
1282 highlightedAction = 2;
1284 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1285 panel_click_distance_y = mousepos_y - panelPos_y;
1286 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1289 // resize from bottomleft border
1290 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)
1292 highlightedPanel = i;
1293 HUD_Panel_FirstInDrawQ(i);
1294 highlightedAction = 2;
1296 panel_click_distance_x = mousepos_x - panelPos_x;
1297 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1298 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1301 // resize from bottomright border
1302 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)
1304 highlightedPanel = i;
1305 HUD_Panel_FirstInDrawQ(i);
1306 highlightedAction = 2;
1308 panel_click_distance = panelSize - mousepos + panelPos;
1309 panel_click_resizeorigin = panelPos;
1314 highlightedPanel_prev = -1;
1319 float highlightcheck;
1320 vector prev_pos, prev_size;
1321 void HUD_Panel_Mouse()
1323 // 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
1324 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1325 disable_menu_alphacheck = 0;
1326 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1330 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1331 print("Highlighted: ", ftos(highlightedPanel), "\n");
1332 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1338 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1339 highlightedPanel = -1;
1340 highlightedAction = 0;
1342 if(highlightedPanel != -1)
1343 highlightedPanel_prev = highlightedPanel;
1345 mousepos = mousepos + getmousepos() * cvar("menu_mouse_speed");
1347 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1348 mousepos_y = bound(0, mousepos_y, vid_conheight);
1352 if(prevMouseClicked == 0)
1354 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1355 // and calls HUD_Panel_UpdatePosSizeForId() for the highlighted panel
1356 prev_pos = panel_pos;
1357 prev_size = panel_size;
1360 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
1362 if (prev_pos != panel_pos || prev_size != panel_size)
1364 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1366 panel_pos_backup = prev_pos;
1367 panel_size_backup = prev_size;
1368 highlightedPanel_backup = highlightedPanel;
1371 // in case the clicked panel is inside another panel and we aren't
1372 // moving it, avoid the immediate "fix" of its position/size
1373 // (often unwanted and hateful) by disabling collisions check
1374 hud_configure_checkcollisions = false;
1376 if(highlightedAction == 1)
1377 HUD_Panel_SetPos(mousepos - panel_click_distance);
1378 else if(highlightedAction == 2)
1381 if(resizeCorner == 1) {
1382 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1383 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1384 } else if(resizeCorner == 2) {
1385 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1386 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1387 } else if(resizeCorner == 3) {
1388 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1389 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1390 } else { // resizeCorner == 4
1391 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1392 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1394 HUD_Panel_SetPosSize(mySize);
1397 // doubleclick check
1398 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1400 mouseClicked = 0; // to prevent spam, I guess.
1401 disable_menu_alphacheck = 2;
1403 menu_enabled_time = time;
1404 HUD_Panel_GetName(highlightedPanel)
1405 localcmd("menu_showhudoptions ", panel_name, "\n");
1408 if(prevMouseClicked == 0)
1410 prevMouseClickedTime = time;
1411 prevMouseClickedPos = mousepos;
1416 highlightcheck = HUD_Panel_HighlightCheck();
1418 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1421 cursorsize = '32 32 0';
1423 if(highlightcheck == 0)
1424 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1425 else if(highlightcheck == 1)
1426 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1427 else if(highlightcheck == 2)
1428 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1430 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1432 prevMouseClicked = mouseClicked;
1435 // Weapon icons (#0)
1437 float weaponspace[10];
1438 #define HUD_Weapons_Clear()\
1440 for(idx = 0; idx < 10; ++idx)\
1441 weaponspace[idx] = 0;
1443 entity weaponorder[WEP_MAXCOUNT];
1444 void weaponorder_swap(float i, float j, entity pass)
1448 weaponorder[i] = weaponorder[j];
1452 string weaponorder_cmp_str_save;
1453 string weaponorder_cmp_str;
1454 float weaponorder_cmp(float i, float j, entity pass)
1457 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1458 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1459 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)
1462 float GetAmmoStat(float i)
1466 case 0: return STAT_SHELLS;
1467 case 1: return STAT_NAILS;
1468 case 2: return STAT_ROCKETS;
1469 case 3: return STAT_CELLS;
1470 case 4: return STAT_FUEL;
1475 float GetAmmoTypeForWep(float i)
1479 case WEP_SHOTGUN: return 0;
1480 case WEP_UZI: return 1;
1481 case WEP_CAMPINGRIFLE: return 1;
1482 case WEP_GRENADE_LAUNCHER: return 2;
1483 case WEP_MINE_LAYER: return 2;
1484 case WEP_ELECTRO: return 3;
1485 case WEP_CRYLINK: return 3;
1486 case WEP_HLAC: return 3;
1487 case WEP_MINSTANEX: return 3;
1488 case WEP_NEX: return 3;
1489 case WEP_HAGAR: return 2;
1490 case WEP_ROCKET_LAUNCHER: return 2;
1491 case WEP_SEEKER: return 2;
1492 case WEP_FIREBALL: return 4;
1493 case WEP_HOOK: return 3;
1498 void HUD_Weapons(void)
1500 if(!autocvar_hud_panel_weapons && !autocvar__hud_configure)
1503 float timeout = cvar("hud_panel_weapons_timeout");
1504 float timeout_effect_length, timein_effect_length;
1505 if (cvar("hud_panel_weapons_timeout_effect") == 0)
1507 timeout_effect_length = 0;
1508 timein_effect_length = 0;
1512 timeout_effect_length = 0.75;
1513 timein_effect_length = 0.375;
1516 if (timeout && time >= weapontime + timeout + timeout_effect_length && !autocvar__hud_configure)
1518 weaponprevtime = time;
1522 active_panel = HUD_PANEL_WEAPONS;
1523 HUD_Panel_UpdateCvars(weapons);
1525 if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
1527 float f = (time - (weapontime + timeout)) / timeout_effect_length;
1528 if (cvar("hud_panel_weapons_timeout_effect"))
1530 panel_bg_alpha *= (1 - f);
1531 panel_fg_alpha *= (1 - f);
1533 if (cvar("hud_panel_weapons_timeout_effect") == 1)
1535 f *= f; // for a cooler movement
1537 center_x = panel_pos_x + panel_size_x/2;
1538 center_y = panel_pos_y + panel_size_y/2;
1539 float screen_ar = vid_conwidth/vid_conheight;
1540 if (center_x/center_y < screen_ar) //bottom left
1542 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
1543 panel_pos_y += f * (vid_conheight - panel_pos_y);
1545 panel_pos_x -= f * (panel_pos_x + panel_size_x);
1549 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
1550 panel_pos_x += f * (vid_conwidth - panel_pos_x);
1552 panel_pos_y -= f * (panel_pos_y + panel_size_y);
1555 weaponprevtime = time - (1 - f) * timein_effect_length;
1557 else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure)
1559 float f = (time - weaponprevtime) / timein_effect_length;
1560 if (cvar("hud_panel_weapons_timeout_effect"))
1562 panel_bg_alpha *= (f);
1563 panel_fg_alpha *= (f);
1565 if (cvar("hud_panel_weapons_timeout_effect") == 1)
1567 f *= f; // for a cooler movement
1570 center_x = panel_pos_x + panel_size_x/2;
1571 center_y = panel_pos_y + panel_size_y/2;
1572 float screen_ar = vid_conwidth/vid_conheight;
1573 if (center_x/center_y < screen_ar) //bottom left
1575 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
1576 panel_pos_y += f * (vid_conheight - panel_pos_y);
1578 panel_pos_x -= f * (panel_pos_x + panel_size_x);
1582 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
1583 panel_pos_x += f * (vid_conwidth - panel_pos_x);
1585 panel_pos_y -= f * (panel_pos_y + panel_size_y);
1590 float i, weapid, fade, weapon_stats, weapon_number, weapon_cnt;
1592 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1594 self = get_weaponinfo(i);
1595 if(self.impulse >= 0)
1599 // TODO make this configurable
1600 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1602 if(weaponorder_cmp_str != weaponorder_cmp_str_save)
1604 if(weaponorder_cmp_str_save)
1605 strunzone(weaponorder_cmp_str_save);
1606 weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
1608 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1610 self = get_weaponinfo(i);
1611 if(self.impulse >= 0)
1613 weaponorder[weapon_cnt] = self;
1617 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1620 HUD_Panel_DrawBg(1);
1621 if(panel_bg_padding)
1623 panel_pos += '1 1 0' * panel_bg_padding;
1624 panel_size -= '2 2 0' * panel_bg_padding;
1628 weapon_stats = getstati(STAT_DAMAGE_HITS);
1629 weapon_number = weapon_stats & 63;
1630 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1632 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1633 weapon_number = weapon_stats & 63;
1634 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1636 if(cvar_or("hud_panel_weapons_fade", 1))
1638 fade = 3.2 - 2 * (time - weapontime);
1639 fade = bound(0.7, fade, 1);
1644 HUD_Weapons_Clear();
1646 float rows, columns;
1647 rows = panel_size_y/panel_size_x;
1648 rows = bound(1, floor((sqrt(4 * autocvar_hud_panel_weapons_aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1650 columns = ceil(WEP_COUNT/rows);
1653 float a, type, fullammo;
1655 when = autocvar_hud_panel_weapons_complainbubble_time;
1657 fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
1663 float show_accuracy;
1664 if(autocvar_hud_panel_weapons_accuracy && acc_levels)
1665 show_accuracy = true;
1667 for(i = 0; i < weapon_cnt; ++i)
1669 wpnpos = panel_pos + eX * column * panel_size_x*(1/columns) + eY * row * panel_size_y*(1/rows);
1670 wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
1672 self = weaponorder[i];
1673 weapid = self.impulse;
1675 // draw background behind currently selected weapon
1676 if(self.weapon == activeweapon)
1677 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1679 // draw the weapon accuracy
1682 float weapon_hit, weapon_damage;
1683 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1686 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1687 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1690 // find the max level lower than weapon_stats
1693 while ( j && weapon_stats < acc_lev[j] )
1696 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
1698 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
1699 color = acc_color(j);
1700 color = color + factor * (acc_color(j+1) - color);
1703 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1706 // draw the weapon icon
1707 if((self.impulse >= 0) && (getstati(STAT_WEAPONS) & self.weapons))
1709 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1711 if(autocvar_hud_panel_weapons_label == 1) // weapon number
1712 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * panel_size_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1713 else if(autocvar_hud_panel_weapons_label == 2) // bind
1714 drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * panel_size_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1716 // draw ammo status bar
1717 if(autocvar_hud_panel_weapons_ammo && weapid != WEP_TUBA && weapid != WEP_LASER && weapid != WEP_PORTO)
1720 type = GetAmmoTypeForWep(weapid);
1722 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
1727 case 0: fullammo = autocvar_hud_panel_weapons_ammo_full_shells; break;
1728 case 1: fullammo = autocvar_hud_panel_weapons_ammo_full_nails; break;
1729 case 2: fullammo = autocvar_hud_panel_weapons_ammo_full_rockets; break;
1730 case 3: fullammo = autocvar_hud_panel_weapons_ammo_full_cells; break;
1731 case 4: fullammo = autocvar_hud_panel_weapons_ammo_full_fuel; break;
1732 default: fullammo = 60;
1737 if(wpnsize_x/wpnsize_y > autocvar_hud_panel_weapons_aspect)
1739 barsize_x = autocvar_hud_panel_weapons_aspect * wpnsize_y;
1740 barsize_y = wpnsize_y;
1742 barpos_x = wpnpos_x + (wpnsize_x - barsize_x) / 2;
1743 barpos_y = wpnpos_y;
1747 barsize_y = 1/autocvar_hud_panel_weapons_aspect * wpnsize_x;
1748 barsize_x = wpnsize_x;
1750 barpos_y = wpnpos_y + (wpnsize_y - barsize_y) / 2;
1751 barpos_x = wpnpos_x;
1757 barsize_x * bound(0, a/fullammo, 1),
1759 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, autocvar_hud_panel_weapons_ammo_color, panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha, DRAWFLAG_NORMAL);
1760 drawresetcliparea();
1765 // draw a "ghost weapon icon" if you don't have the weapon
1768 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
1771 // draw the complain message
1772 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
1776 if(complain_weapon_time + when > time)
1779 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1783 if(complain_weapon_time + when > time)
1790 if(complain_weapon_type == 0) {
1792 color = autocvar_hud_panel_weapons_complainbubble_color_outofammo;
1794 else if(complain_weapon_type == 1) {
1796 color = autocvar_hud_panel_weapons_complainbubble_color_donthave;
1800 color = autocvar_hud_panel_weapons_complainbubble_color_unavailable;
1802 drawpic_aspect_skin(wpnpos + '1 1 0' * autocvar_hud_panel_weapons_complainbubble_padding, "weapon_complainbubble", wpnsize - '2 2 0' * autocvar_hud_panel_weapons_complainbubble_padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
1803 drawstring_aspect(wpnpos + '1 1 0' * autocvar_hud_panel_weapons_complainbubble_padding, s, wpnsize - '2 2 0' * autocvar_hud_panel_weapons_complainbubble_padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
1819 float GetAmmoItemCode(float i)
1823 case 0: return IT_SHELLS;
1824 case 1: return IT_NAILS;
1825 case 2: return IT_ROCKETS;
1826 case 3: return IT_CELLS;
1827 case 4: return IT_FUEL;
1832 string GetAmmoPicture(float i)
1836 case 0: return "ammo_shells";
1837 case 1: return "ammo_bullets";
1838 case 2: return "ammo_rockets";
1839 case 3: return "ammo_cells";
1840 case 4: return "ammo_fuel";
1845 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1848 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1849 if(autocvar__hud_configure)
1859 if(currently_selected)
1864 vector newSize, newPos;
1865 if(mySize_x/mySize_y > 3)
1867 newSize_x = 3 * mySize_y;
1868 newSize_y = mySize_y;
1870 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1875 newSize_y = 1/3 * mySize_x;
1876 newSize_x = mySize_x;
1878 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1882 vector picpos, numpos;
1883 if(autocvar_hud_panel_ammo_iconalign)
1886 picpos = newPos + eX * 2 * newSize_y;
1890 numpos = newPos + eX * newSize_y;
1894 if (currently_selected)
1895 drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1897 drawfont = hud_bigfont;
1899 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1900 else // "ghost" ammo count
1901 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1902 drawfont = hud_font;
1904 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1905 else // "ghost" ammo icon
1906 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1911 if(!autocvar_hud_panel_ammo && !autocvar__hud_configure)
1914 active_panel = HUD_PANEL_AMMO;
1915 HUD_Panel_UpdateCvars(ammo);
1916 float i, currently_selected;
1920 mySize = panel_size;
1922 HUD_Panel_DrawBg(1);
1923 if(panel_bg_padding)
1925 pos += '1 1 0' * panel_bg_padding;
1926 mySize -= '2 2 0' * panel_bg_padding;
1929 float rows, columns;
1930 rows = mySize_y/mySize_x;
1931 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1932 // ^^^ ammo item aspect goes here
1934 columns = ceil(AMMO_COUNT/rows);
1938 for (i = 0; i < AMMO_COUNT; ++i) {
1939 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1940 if(autocvar_hud_panel_ammo_onlycurrent) {
1941 if(autocvar__hud_configure)
1943 if (currently_selected || autocvar__hud_configure)
1945 DrawAmmoItem(pos, mySize, i, currently_selected);
1949 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);
1954 column = column + 1;
1960 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float alpha)
1962 vector newSize, newPos;
1963 if(mySize_x/mySize_y > 3)
1965 newSize_x = 3 * mySize_y;
1966 newSize_y = mySize_y;
1968 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1973 newSize_y = 1/3 * mySize_x;
1974 newSize_x = mySize_x;
1976 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1980 vector picpos, numpos;
1983 if(iconalign == 1 || iconalign == 3) // right align
1986 picpos = newPos + eX * 2 * newSize_y;
1990 numpos = newPos + eX * newSize_y;
1996 if(iconalign == 0 || iconalign == 3) // left align
1998 numpos = newPos + eX * newSize_y;
2004 picpos = newPos + eX * 2 * newSize_y;
2008 drawfont = hud_bigfont;
2009 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
2010 drawfont = hud_font;
2011 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
2014 void DrawNumIcon_expanding(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float fadelerp)
2017 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
2019 DrawNumIcon(iconalign, myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, left, color, (1 - fadelerp));
2024 void HUD_Powerups(void) {
2025 if(!autocvar_hud_panel_powerups && !autocvar__hud_configure)
2028 active_panel = HUD_PANEL_POWERUPS;
2029 HUD_Panel_UpdateCvars(powerups);
2031 stat_items = getstati(STAT_ITEMS);
2033 if(!autocvar__hud_configure)
2035 if not(stat_items & IT_STRENGTH)
2036 if not(stat_items & IT_INVINCIBLE)
2039 if (getstati(STAT_HEALTH) <= 0)
2045 mySize = panel_size;
2047 float strength_time, shield_time;
2048 if(autocvar__hud_configure)
2055 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
2056 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
2059 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
2060 if(panel_bg_padding)
2062 pos += '1 1 0' * panel_bg_padding;
2063 mySize -= '2 2 0' * panel_bg_padding;
2066 vector barpos, barsize;
2070 string leftname, rightname;
2071 float leftcnt, rightcnt;
2072 float leftexact, rightexact;
2073 if (autocvar_hud_panel_powerups_flip) {
2074 leftname = "strength";
2075 leftcnt = ceil(strength_time);
2076 leftexact = strength_time;
2078 rightname = "shield";
2079 rightcnt = ceil(shield_time);
2080 rightexact = shield_time;
2082 leftname = "shield";
2083 leftcnt = ceil(shield_time);
2084 leftexact = shield_time;
2086 rightname = "strength";
2087 rightcnt = ceil(strength_time);
2088 rightexact = strength_time;
2091 drawfont = hud_bigfont;
2092 if (mySize_x/mySize_y > 4)
2096 if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // right align
2097 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
2098 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
2099 } else { // left align
2101 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
2104 if(autocvar_hud_panel_powerups_progressbar)
2106 HUD_Panel_GetProgressBarColor(leftname)
2107 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
2110 DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
2112 DrawNumIcon_expanding(autocvar_hud_panel_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
2117 if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // left align
2118 barpos = pos + eX * 0.5 * mySize_x;
2119 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
2120 } else { // right align
2121 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
2122 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
2125 if(autocvar_hud_panel_powerups_progressbar)
2127 HUD_Panel_GetProgressBarColor(rightname)
2128 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1) * panel_fg_alpha, DRAWFLAG_NORMAL);
2131 DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
2133 DrawNumIcon_expanding(autocvar_hud_panel_powerups_iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1));
2136 else if (mySize_x/mySize_y > 1.5)
2140 if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // right align
2141 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
2142 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
2143 } else { // left align
2145 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
2148 if(autocvar_hud_panel_powerups_progressbar)
2150 HUD_Panel_GetProgressBarColor(leftname)
2151 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1) * panel_fg_alpha, DRAWFLAG_NORMAL);
2154 DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
2156 DrawNumIcon_expanding(autocvar_hud_panel_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
2161 if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // left align
2162 barpos = pos + eY * 0.5 * mySize_y;
2163 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
2164 } else { // right align
2165 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
2166 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
2169 if(autocvar_hud_panel_powerups_progressbar)
2171 HUD_Panel_GetProgressBarColor(rightname)
2172 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1) * panel_fg_alpha, DRAWFLAG_NORMAL);
2175 DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
2177 DrawNumIcon_expanding(autocvar_hud_panel_powerups_iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1));
2184 if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // down align
2185 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
2186 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
2187 } else { // up align
2189 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
2192 if(autocvar_hud_panel_powerups_iconalign == 1 || autocvar_hud_panel_powerups_iconalign == 3) { // down align
2193 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2194 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2195 } else { // up align
2196 picpos = pos + eX * 0.05 * mySize_x;
2197 numpos = pos + eY * 0.4 * mySize_x;
2200 if(autocvar_hud_panel_powerups_progressbar)
2202 HUD_Panel_GetProgressBarColor(leftname)
2203 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1) * panel_fg_alpha, DRAWFLAG_NORMAL);
2206 drawpic_aspect_skin_expanding(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, bound(0, (leftcnt - leftexact) / 0.5, 1));
2208 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2209 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2214 if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // up align
2215 barpos = pos + eX * 0.5 * mySize_x;
2216 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2217 } else { // down align
2218 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
2219 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2222 if(autocvar_hud_panel_powerups_iconalign == 0 || autocvar_hud_panel_powerups_iconalign == 3) { // up align
2223 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2224 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2225 } else { // down align
2226 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2227 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2230 if(autocvar_hud_panel_powerups_progressbar)
2232 HUD_Panel_GetProgressBarColor(rightname)
2233 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1) * panel_fg_alpha, DRAWFLAG_NORMAL);
2236 drawpic_aspect_skin_expanding(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, bound(0, (rightcnt - rightexact) / 0.5, 1));
2238 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2239 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2242 drawfont = hud_font;
2245 // Health/armor (#3)
2247 void HUD_HealthArmor(void)
2249 if(!autocvar_hud_panel_healtharmor && !autocvar__hud_configure)
2252 active_panel = HUD_PANEL_HEALTHARMOR;
2253 HUD_Panel_UpdateCvars(healtharmor);
2256 mySize = panel_size;
2258 HUD_Panel_DrawBg(1);
2259 if(panel_bg_padding)
2261 pos += '1 1 0' * panel_bg_padding;
2262 mySize -= '2 2 0' * panel_bg_padding;
2265 float armor, health, fuel;
2266 armor = getstati(STAT_ARMOR);
2267 health = getstati(STAT_HEALTH);
2268 fuel = getstati(STAT_FUEL);
2270 if(autocvar__hud_configure)
2280 vector barpos, barsize;
2284 drawfont = hud_bigfont;
2285 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
2288 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2293 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
2294 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2295 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2296 } else { // left align
2298 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2302 if(v_z) // NOT fully armored
2304 biggercount = "health";
2305 if(autocvar_hud_panel_healtharmor_progressbar)
2307 HUD_Panel_GetProgressBarColor("health")
2308 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2311 drawpic_aspect_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "armor", '0.5 0.5 0' * mySize_y, '1 1 1', panel_fg_alpha * armor / health, DRAWFLAG_NORMAL);
2315 biggercount = "armor";
2316 if(autocvar_hud_panel_healtharmor_progressbar)
2318 HUD_Panel_GetProgressBarColor("armor")
2319 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2322 drawpic_aspect_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "health", '0.5 0.5 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2324 DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200), 1);
2329 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2330 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2331 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2334 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2336 HUD_Panel_GetProgressBarColor("fuel")
2337 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2342 string leftname, rightname;
2343 float leftcnt, rightcnt;
2344 float leftactive, rightactive;
2345 float leftalpha, rightalpha;
2346 if (autocvar_hud_panel_healtharmor_flip) { // old style layout with armor left/top of health
2351 leftalpha = min((armor+10)/55, 1);
2353 rightname = "health";
2358 leftname = "health";
2363 rightname = "armor";
2367 rightalpha = min((armor+10)/55, 1);
2370 if (mySize_x/mySize_y > 4)
2374 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
2375 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2376 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2377 } else { // left align
2379 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2382 if(autocvar_hud_panel_healtharmor_progressbar)
2384 HUD_Panel_GetProgressBarColor(leftname)
2385 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2387 DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
2392 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2393 barpos = pos + eX * 0.5 * mySize_x;
2394 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2395 } else { // right align
2396 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2397 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2400 if(autocvar_hud_panel_healtharmor_progressbar)
2402 HUD_Panel_GetProgressBarColor(rightname)
2403 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2405 DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(rightcnt, 200), 1);
2410 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2411 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2412 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2415 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2417 HUD_Panel_GetProgressBarColor("fuel")
2418 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2421 else if (mySize_x/mySize_y > 1.5)
2425 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
2426 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2427 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2428 } else { // left align
2430 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2433 if(autocvar_hud_panel_healtharmor_progressbar)
2435 HUD_Panel_GetProgressBarColor(leftname)
2436 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2438 DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
2443 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2444 barpos = pos + eY * 0.5 * mySize_y;
2445 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2446 } else { // right align
2447 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2448 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2451 if(autocvar_hud_panel_healtharmor_progressbar)
2453 HUD_Panel_GetProgressBarColor(rightname)
2454 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2456 DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(rightcnt, 200), 1);
2461 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2462 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2463 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2466 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2468 HUD_Panel_GetProgressBarColor("fuel")
2469 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2476 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // down align
2477 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2478 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2479 } else { // up align
2481 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2484 if(autocvar_hud_panel_healtharmor_iconalign == 1 || autocvar_hud_panel_healtharmor_iconalign == 3) { // down align
2485 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2486 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2487 } else { // up align
2488 picpos = pos + eX * 0.05 * mySize_x;
2489 numpos = pos + eY * 0.4 * mySize_x;
2492 if(autocvar_hud_panel_healtharmor_progressbar)
2494 HUD_Panel_GetProgressBarColor(leftname)
2495 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2497 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2498 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, HUD_Get_Num_Color(leftcnt, 200), panel_fg_alpha, DRAWFLAG_NORMAL);
2503 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // up align
2504 barpos = pos + eX * 0.5 * mySize_x;
2505 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2506 } else { // down align
2507 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2508 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2511 if(autocvar_hud_panel_healtharmor_iconalign == 0 || autocvar_hud_panel_healtharmor_iconalign == 3) { // up align
2512 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2513 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2514 } else { // down align
2515 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2516 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2519 if(autocvar_hud_panel_healtharmor_progressbar)
2521 HUD_Panel_GetProgressBarColor(rightname)
2522 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2524 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2525 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, HUD_Get_Num_Color(rightcnt, 200), panel_fg_alpha, DRAWFLAG_NORMAL);
2530 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2532 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2534 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2535 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2537 HUD_Panel_GetProgressBarColor("fuel")
2538 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2542 drawfont = hud_font;
2545 // Notification area (#4)
2548 string Weapon_SuicideMessage(float deathtype)
2550 w_deathtype = deathtype;
2551 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2552 return w_deathtypestring;
2555 string Weapon_KillMessage(float deathtype)
2557 w_deathtype = deathtype;
2558 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2559 return w_deathtypestring;
2562 float killnotify_times[10];
2563 float killnotify_deathtype[10];
2564 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2565 string killnotify_attackers[10];
2566 string killnotify_victims[10];
2567 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2570 for (i = 9; i > 0; --i) {
2571 killnotify_times[i] = killnotify_times[i-1];
2572 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2573 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2574 if(killnotify_attackers[i])
2575 strunzone(killnotify_attackers[i]);
2576 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2577 if(killnotify_victims[i])
2578 strunzone(killnotify_victims[i]);
2579 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2581 killnotify_times[0] = time;
2582 killnotify_deathtype[0] = wpn;
2583 killnotify_actiontype[0] = actiontype;
2584 if(killnotify_attackers[0])
2585 strunzone(killnotify_attackers[0]);
2586 killnotify_attackers[0] = strzone(attacker);
2587 if(killnotify_victims[0])
2588 strunzone(killnotify_victims[0]);
2589 killnotify_victims[0] = strzone(victim);
2592 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
2595 float alsoprint, gentle;
2596 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2597 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2599 if(msg == MSG_SUICIDE) {
2600 w = DEATH_WEAPONOF(type);
2602 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2604 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
2605 } else if (type == DEATH_KILL) {
2606 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2608 print ("^1",s1, "^1 couldn't take it anymore\n");
2609 } else if (type == DEATH_ROT) {
2610 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2612 print ("^1",s1, "^1 died\n");
2613 } else if (type == DEATH_NOAMMO) {
2614 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2616 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2617 } else if (type == DEATH_CAMP) {
2618 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2620 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2621 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2622 HUD_KillNotify_Push(s1, "", 0, type);
2624 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2625 } else if (type == DEATH_CHEAT) {
2626 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2628 print ("^1",s1, "^1 unfairly eliminated themself\n");
2629 } else if (type == DEATH_FIRE) {
2630 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2632 print ("^1",s1, "^1 burned to death\n");
2633 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2634 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2636 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2639 if (stof(s2) > 2) // killcount > 2
2640 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2641 } else if(msg == MSG_KILL) {
2642 w = DEATH_WEAPONOF(type);
2644 HUD_KillNotify_Push(s1, s2, 1, type);
2646 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
2648 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2649 HUD_KillNotify_Push(s1, s2, 1, type);
2653 print ("^1", s1, "^1 took action against a team mate\n");
2655 print ("^1", s1, "^1 mows down a team mate\n");
2658 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2660 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2662 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2664 else if (stof(s2) > 2) {
2666 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2668 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2671 else if(type == KILL_FIRST_BLOOD)
2672 print("^1",s1, "^1 drew first blood", "\n");
2673 else if (type == DEATH_TELEFRAG) {
2674 HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
2676 print ("^1",s2, "^1 tried to occupy ", s1, "^1's teleport destination space\n");
2678 print ("^1",s2, "^1 was telefragged by ", s1, "\n");
2680 else if (type == DEATH_DROWN) {
2681 HUD_KillNotify_Push(s1, s2, 1, DEATH_DROWN);
2683 print ("^1",s2, "^1 was drowned by ", s1, "\n");
2685 else if (type == DEATH_SLIME) {
2686 HUD_KillNotify_Push(s1, s2, 1, DEATH_SLIME);
2688 print ("^1",s2, "^1 was slimed by ", s1, "\n");
2690 else if (type == DEATH_LAVA) {
2691 HUD_KillNotify_Push(s1, s2, 1, DEATH_LAVA);
2693 print ("^1",s2, "^1 was cooked by ", s1, "\n");
2695 else if (type == DEATH_FALL) {
2696 HUD_KillNotify_Push(s1, s2, 1, DEATH_FALL);
2698 print ("^1",s2, "^1 was grounded by ", s1, "\n");
2700 else if (type == DEATH_SHOOTING_STAR) {
2701 HUD_KillNotify_Push(s1, s2, 1, DEATH_SHOOTING_STAR);
2703 print ("^1",s2, "^1 was shot into space by ", s1, "\n");
2705 else if (type == DEATH_SWAMP) {
2706 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2708 print ("^1",s2, "^1 was conserved by ", s1, "\n");
2710 else if (type == DEATH_HURTTRIGGER)
2712 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
2714 print("^1",s2, "^1 was thrown into a world of hurt by ", s1, "\n");
2715 } else if(type == DEATH_SBCRUSH) {
2716 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2718 print ("^1",s2, "^1 was crushed by ^1", s1, "\n");
2719 } else if(type == DEATH_SBMINIGUN) {
2720 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2722 print ("^1",s2, "^1 got shredded by ^1", s1, "\n");
2723 } else if(type == DEATH_SBROCKET) {
2724 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2726 print ("^1",s2, "^1 was blased to bits by ^1", s1, "\n");
2727 } else if(type == DEATH_SBBLOWUP) {
2728 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2730 print ("^1",s2, "^1 got caught in the destruction of ^1", s1, "'s vehicle\n");
2731 } else if(type == DEATH_WAKIGUN) {
2732 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2734 print ("^1",s2, "^1 was bolted down by ^1", s1, "\n");
2735 } else if(type == DEATH_WAKIROCKET) {
2736 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2738 print ("^1",s2, "^1 could find no shelter from ^1", s1, "'s rockets\n");
2739 } else if(type == DEATH_WAKIBLOWUP) {
2740 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2742 print ("^1",s2, "^1 dies when ^1", s1, "'s wakizashi dies.\n");
2743 } else if(type == DEATH_TURRET) {
2744 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2746 print ("^1",s2, "^1 was pushed into the line of fire by ^1", s1, "\n");
2747 } else if(type == DEATH_TOUCHEXPLODE) {
2748 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2750 print ("^1",s2, "^1 was pushed into an accident by ^1", s1, "\n");
2751 } else if(type == DEATH_CHEAT) {
2752 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2754 print ("^1",s2, "^1 was unfairly eliminated by ^1", s1, "\n");
2755 } else if (type == DEATH_FIRE) {
2756 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2758 print ("^1",s2, "^1 was burnt to death by ^1", s1, "\n");
2759 } else if (type == DEATH_CUSTOM) {
2760 HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM);
2762 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
2763 } else if (type == DEATH_HURTTRIGGER) {
2764 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
2766 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
2768 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2770 print ("^1",s2, "^1 was fragged by ", s1, "\n");
2772 } else if(msg == MSG_SPREE) {
2773 if(type == KILL_END_SPREE) {
2775 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2777 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2778 } else if(type == KILL_SPREE) {
2780 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2782 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2783 } else if(type == KILL_SPREE_3) {
2785 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2787 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2788 } else if(type == KILL_SPREE_5) {
2790 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2792 print (s1,"^7 unleashes ^1RAGE\n");
2793 } else if(type == KILL_SPREE_10) {
2795 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2797 print (s1,"^7 starts the ^1MASSACRE!\n");
2798 } else if(type == KILL_SPREE_15) {
2800 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2802 print (s1,"^7 executes ^1MAYHEM!\n");
2803 } else if(type == KILL_SPREE_20) {
2805 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2807 print (s1,"^7 is a ^1BERSERKER!\n");
2808 } else if(type == KILL_SPREE_25) {
2810 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2812 print (s1,"^7 inflicts ^1CARNAGE!\n");
2813 } else if(type == KILL_SPREE_30) {
2815 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2817 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2819 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2820 if (type == DEATH_DROWN) {
2821 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2825 print ("^1",s1, "^1 was in the water for too long\n");
2827 print ("^1",s1, "^1 drowned\n");
2829 } else if (type == DEATH_SLIME) {
2830 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2832 print ("^1",s1, "^1 was slimed\n");
2833 } else if (type == DEATH_LAVA) {
2834 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2838 print ("^1",s1, "^1 found a hot place\n");
2840 print ("^1",s1, "^1 turned into hot slag\n");
2842 } else if (type == DEATH_FALL) {
2843 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2847 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2849 print ("^1",s1, "^1 hit the ground with a crunch\n");
2851 } else if (type == DEATH_SHOOTING_STAR) {
2852 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2854 print ("^1",s1, "^1 became a shooting star\n");
2855 } else if (type == DEATH_SWAMP) {
2856 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2860 print ("^1",s1, "^1 discovered a swamp\n");
2862 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2864 } else if(type == DEATH_TURRET) {
2865 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2867 print ("^1",s1, "^1 was mowed down by a turret \n");
2868 } else if (type == DEATH_CUSTOM) {
2869 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2871 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
2872 } else if (type == DEATH_HURTTRIGGER) {
2873 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2875 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
2876 } else if(type == DEATH_TOUCHEXPLODE) {
2877 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2879 print ("^1",s1, "^1 died in an accident\n");
2880 } else if(type == DEATH_CHEAT) {
2881 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2883 print ("^1",s1, "^1 was unfairly eliminated\n");
2884 } else if(type == DEATH_FIRE) {
2885 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2889 print ("^1",s1, "^1 felt a little hot\n");
2891 print ("^1",s1, "^1 burnt to death\n");
2894 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2898 print ("^1",s1, "^1 needs a restart\n");
2900 print ("^1",s1, "^1 died\n");
2903 } else if(msg == MSG_KILL_ACTION_SPREE) {
2905 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2907 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2908 } else if(msg == MSG_INFO) {
2909 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2910 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2911 print(s1, "^7 got the ", s2, "\n");
2912 } else if(type == INFO_LOSTFLAG) {
2913 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2914 print(s1, "^7 lost the ", s2, "\n");
2915 } else if(type == INFO_PICKUPFLAG) {
2916 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2917 print(s1, "^7 picked up the ", s2, "\n");
2918 } else if(type == INFO_RETURNFLAG) {
2919 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2920 print(s1, "^7 returned the ", s2, "\n");
2921 } else if(type == INFO_CAPTUREFLAG) {
2922 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
2923 print(s1, "^7 captured the ", s2, s3, "\n");
2928 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2930 void HUD_Centerprint(string s1, string s2, float type, float msg)
2933 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2934 if(msg == MSG_SUICIDE) {
2935 if (type == DEATH_TEAMCHANGE) {
2936 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2937 } else if (type == DEATH_AUTOTEAMCHANGE) {
2938 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2939 } else if (type == DEATH_CAMP) {
2941 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2943 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2944 } else if (type == DEATH_NOAMMO) {
2946 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2948 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2949 } else if (type == DEATH_ROT) {
2951 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2953 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2954 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2956 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2958 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2959 } else if (type == DEATH_QUIET) {
2961 } else { // generic message
2963 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2965 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2967 } else if(msg == MSG_KILL) {
2968 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2970 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2972 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2974 } else if (type == KILL_FIRST_BLOOD) {
2976 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2978 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2980 } else if (type == KILL_FIRST_VICTIM) {
2982 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2984 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2986 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2988 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2990 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2992 } else if (type == KILL_TYPEFRAGGED) {
2994 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2996 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2998 } else if (type == KILL_FRAG) {
3000 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
3002 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
3004 } else { // generic message
3006 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
3008 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
3011 } else if(msg == MSG_KILL_ACTION) {
3012 // TODO: invent more centerprints here?
3013 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
3017 void HUD_Notify (void)
3019 if(!autocvar_hud_panel_notify && !autocvar__hud_configure)
3022 active_panel = HUD_PANEL_NOTIFY;
3023 HUD_Panel_UpdateCvars(notify);
3026 mySize = panel_size;
3028 HUD_Panel_DrawBg(1);
3029 if(panel_bg_padding)
3031 pos += '1 1 0' * panel_bg_padding;
3032 mySize -= '2 2 0' * panel_bg_padding;
3035 float entries, height;
3036 entries = bound(1, floor(10 * mySize_y/mySize_x), 10);
3037 height = mySize_y/entries;
3040 fontsize = '0.5 0.5 0' * height;
3044 when = autocvar_hud_panel_notify_time;
3046 fadetime = autocvar_hud_panel_notify_fadetime;
3050 vector pos_attacker, pos_victim;
3052 float width_attacker;
3053 string attacker, victim;
3056 for(j = 0; j < entries; ++j)
3059 if(autocvar_hud_panel_notify_flip)
3061 else // rather nasty hack for ordering items from the bottom up
3062 i = entries - j - 1;
3066 if(killnotify_times[j] + when > time)
3069 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
3073 if(killnotify_times[j] + when > time)
3080 w = DEATH_WEAPONOF(killnotify_deathtype[j]);
3082 // TODO: maybe print in team colors?
3085 if(killnotify_actiontype[j] == 0 && !autocvar__hud_configure)
3087 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3088 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
3089 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
3091 if(killnotify_deathtype[j] == DEATH_GENERIC)
3095 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
3097 s = "notify_outofammo";
3099 else if(killnotify_deathtype[j] == DEATH_KILL)
3101 s = "notify_selfkill";
3103 else if(killnotify_deathtype[j] == DEATH_CAMP)
3105 s = "notify_camping";
3107 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
3109 s = "notify_teamkill_red";
3111 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
3113 s = "notify_teamkill_blue";
3115 else if(killnotify_deathtype[j] == DEATH_DROWN)
3119 else if(killnotify_deathtype[j] == DEATH_SLIME)
3123 else if(killnotify_deathtype[j] == DEATH_LAVA)
3127 else if(killnotify_deathtype[j] == DEATH_FALL)
3131 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
3133 s = "notify_shootingstar";
3135 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
3139 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
3141 if(killnotify_victims[j] == "^1RED^7 flag")
3143 s = "notify_red_taken";
3147 s = "notify_blue_taken";
3150 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
3152 if(killnotify_victims[j] == "^1RED^7 flag")
3154 s = "notify_red_returned";
3158 s = "notify_blue_returned";
3161 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
3163 if(killnotify_victims[j] == "^1RED^7 flag")
3165 s = "notify_red_lost";
3169 s = "notify_blue_lost";
3172 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
3174 if(killnotify_victims[j] == "^1RED^7 flag")
3176 s = "notify_red_captured";
3180 s = "notify_blue_captured";
3185 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3186 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3189 // X [did action to] Y
3192 if(autocvar__hud_configure)
3194 attacker = textShortenToWidth("Player1", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3195 victim = textShortenToWidth("Player2", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3196 a = bound(0, (when - j) / 4, 1);
3200 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3201 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3203 width_attacker = stringwidth(attacker, TRUE, fontsize);
3204 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
3205 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
3206 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
3208 if(autocvar__hud_configure) // example actions for config mode
3210 s = "weaponelectro";
3212 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
3214 s = "notify_melee_laser";
3216 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_SHOTGUN)
3218 s = "notify_melee_shotgun";
3220 else if(WEP_VALID(w))
3222 self = get_weaponinfo(w);
3223 s = strcat("weapon", self.netname);
3225 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
3227 s = "notify_teamkill_red";
3229 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
3231 s = "notify_teamkill_red";
3233 else if(killnotify_deathtype[j] == DEATH_TELEFRAG)
3235 s = "notify_telefrag";
3237 else if(killnotify_deathtype[j] == DEATH_DROWN)
3241 else if(killnotify_deathtype[j] == DEATH_SLIME)
3245 else if(killnotify_deathtype[j] == DEATH_LAVA)
3249 else if(killnotify_deathtype[j] == DEATH_FALL)
3253 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
3255 s = "notify_shootingstar";
3257 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
3263 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3264 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3265 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3274 string seconds_tostring(float sec)
3277 minutes = floor(sec / 60);
3279 sec -= minutes * 60;
3282 s = ftos(100 + sec);
3284 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3287 void HUD_Timer(void)
3289 if(!autocvar_hud_panel_timer && !autocvar__hud_configure)
3292 active_panel = HUD_PANEL_TIMER;
3293 HUD_Panel_UpdateCvars(timer);
3296 mySize = panel_size;
3298 HUD_Panel_DrawBg(1);
3299 if(panel_bg_padding)
3301 pos += '1 1 0' * panel_bg_padding;
3302 mySize -= '2 2 0' * panel_bg_padding;
3306 float timelimit, elapsedTime, timeleft, minutesLeft;
3308 timelimit = getstatf(STAT_TIMELIMIT);
3310 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3311 timeleft = ceil(timeleft);
3313 minutesLeft = floor(timeleft / 60);
3316 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3317 timer_color = '1 1 1'; //white
3318 else if(minutesLeft >= 1)
3319 timer_color = '1 1 0'; //yellow
3321 timer_color = '1 0 0'; //red
3323 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
3324 if (time < getstatf(STAT_GAMESTARTTIME)) {
3325 //while restart is still active, show 00:00
3326 timer = seconds_tostring(0);
3328 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3329 timer = seconds_tostring(elapsedTime);
3332 timer = seconds_tostring(timeleft);
3335 drawfont = hud_bigfont;
3336 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3337 drawfont = hud_font;
3342 void HUD_Radar(void)
3344 if ((autocvar_hud_panel_radar == 0 || (autocvar_hud_panel_radar != 2 && !teamplay)) && !autocvar__hud_configure)
3347 active_panel = HUD_PANEL_RADAR;
3348 HUD_Panel_UpdateCvars(radar);
3351 mySize = panel_size;
3353 HUD_Panel_DrawBg(1);
3354 if(panel_bg_padding)
3356 pos += '1 1 0' * panel_bg_padding;
3357 mySize -= '2 2 0' * panel_bg_padding;
3360 local float color1, color2; // color already declared as a global in hud.qc
3363 float scale2d, normalsize, bigsize;
3366 teamradar_origin2d = pos + 0.5 * mySize;
3367 teamradar_size2d = mySize;
3369 if(minimapname == "")
3372 teamradar_loadcvars();
3374 switch(hud_panel_radar_zoommode)
3378 f = current_zoomfraction;
3381 f = 1 - current_zoomfraction;
3391 switch(hud_panel_radar_rotation)
3394 teamradar_angle = view_angles_y - 90;
3397 teamradar_angle = 90 * hud_panel_radar_rotation;
3401 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3402 teamradar_size2d = mySize;
3404 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3406 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3407 if(hud_panel_radar_rotation == 0)
3409 // max-min distance must fit the radar in any rotation
3410 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3414 vector c0, c1, c2, c3, span;
3415 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3416 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3417 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3418 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3420 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3421 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3423 // max-min distance must fit the radar in x=x, y=y
3425 teamradar_size2d_x * scale2d / (1.05 * span_x),
3426 teamradar_size2d_y * scale2d / (1.05 * span_y)
3430 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
3431 if(bigsize > normalsize)
3432 normalsize = bigsize;
3436 + (1 - f) * normalsize;
3437 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3438 f * (mi_min + mi_max) * 0.5
3439 + (1 - f) * view_origin);
3441 color1 = GetPlayerColor(player_localentnum-1);
3442 rgb = GetTeamRGB(color1);
3451 draw_teamradar_background(hud_panel_radar_foreground_alpha);
3453 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3454 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3455 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3456 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3457 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3459 color2 = GetPlayerColor(tm.sv_entnum);
3460 //if(color == COLOR_SPECTATOR || color == color2)
3461 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3463 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3465 drawresetcliparea();
3470 void HUD_Score(void)
3472 if(!autocvar_hud_panel_score && !autocvar__hud_configure)
3475 active_panel = HUD_PANEL_SCORE;
3476 HUD_Panel_UpdateCvars(score);
3479 mySize = panel_size;
3481 HUD_Panel_DrawBg(1);
3482 if(panel_bg_padding)
3484 pos += '1 1 0' * panel_bg_padding;
3485 mySize -= '2 2 0' * panel_bg_padding;
3488 float score, distribution, leader;
3489 vector distribution_color;
3491 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3493 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3494 string timer, distrtimer;
3496 pl = players.sort_next;
3499 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3500 if(pl.scores[ps_primary] == 0)
3503 score = me.(scores[ps_primary]);
3504 timer = TIME_ENCODED_TOSTRING(score);
3506 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3507 // distribution display
3508 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3510 distrtimer = ftos(distribution/pow(10, TIME_DECIMALS));
3512 if (distribution <= 0) {
3513 distribution_color = '0 1 0';
3516 distribution_color = '1 0 0';
3518 drawstring_aspect(pos + eX * 0.75 * mySize_x, distrtimer, eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3520 // race record display
3521 if (distribution <= 0)
3522 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3523 drawfont = hud_bigfont;
3524 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3525 drawfont = hud_font;
3526 } else if (!teamplay) { // non-teamgames
3527 // me vector := [team/connected frags id]
3528 pl = players.sort_next;
3532 if(autocvar__hud_configure)
3535 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3539 score = me.(scores[ps_primary]);
3540 if(autocvar__hud_configure)
3543 if(distribution >= 5) {
3544 distribution_color = eY;
3546 } else if(distribution >= 0) {
3547 distribution_color = '1 1 1';
3549 } else if(distribution >= -5)
3550 distribution_color = '1 1 0';
3552 distribution_color = eX;
3554 drawstring_aspect(pos + eX * 0.75 * mySize_x, ftos(distribution), eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3556 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3557 drawfont = hud_bigfont;
3558 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3559 drawfont = hud_font;
3560 } else { // teamgames
3561 float max_fragcount;
3562 max_fragcount = -99;
3565 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3566 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !autocvar__hud_configure)) // no players? don't display
3568 score = tm.(teamscores[ts_primary]);
3569 if(autocvar__hud_configure)
3573 if (score > max_fragcount)
3574 max_fragcount = score;
3576 if(tm.team == myteam) {
3577 if (max_fragcount == score)
3580 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3581 drawfont = hud_bigfont;
3582 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3583 drawfont = hud_font;
3585 if (max_fragcount == score)
3588 HUD_Panel_DrawHighlight(pos + eX * 0.75 * mySize_x + eY * (1/3) * teamnum * mySize_y, eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3589 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, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3598 void HUD_RaceTimer (void) {
3599 if(!autocvar_hud_panel_racetimer && !(gametype == GAME_RACE || gametype == GAME_CTS) && !autocvar__hud_configure)
3602 active_panel = HUD_PANEL_RACETIMER;
3603 HUD_Panel_UpdateCvars(racetimer);
3606 mySize = panel_size;
3608 HUD_Panel_DrawBg(1);
3609 if(panel_bg_padding)
3611 pos += '1 1 0' * panel_bg_padding;
3612 mySize -= '2 2 0' * panel_bg_padding;
3615 // always force 4:1 aspect
3617 if(mySize_x/mySize_y > 4)
3619 newSize_x = 4 * mySize_y;
3620 newSize_y = mySize_y;
3622 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3626 newSize_y = 1/4 * mySize_x;
3627 newSize_x = mySize_x;
3629 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3633 drawfont = hud_bigfont;
3635 string s, forcetime;
3637 if(autocvar__hud_configure)
3640 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', panel_fg_alpha, DRAWFLAG_NORMAL);
3641 s = "^1Intermediate 1 (+15.42)";
3642 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, panel_fg_alpha, DRAWFLAG_NORMAL);
3643 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3644 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, panel_fg_alpha, DRAWFLAG_NORMAL);
3646 else if(race_checkpointtime)
3648 a = bound(0, 2 - (time - race_checkpointtime), 1);
3651 if(a > 0) // just hit a checkpoint?
3653 if(race_checkpoint != 254)
3655 if(race_time && race_previousbesttime)
3656 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3658 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3660 forcetime = TIME_ENCODED_TOSTRING(race_time);
3665 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3667 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3668 if(a > 0) // next one?
3670 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3675 if(s != "" && a > 0)
3677 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, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3680 if(race_penaltytime)
3682 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3685 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3686 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, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3692 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3693 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', panel_fg_alpha, 0, a);
3698 if(race_laptime && race_checkpoint != 255)
3700 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3701 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', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3706 if(race_mycheckpointtime)
3708 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3709 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3710 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, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3712 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3714 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3715 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3716 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, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3719 if(race_penaltytime && !race_penaltyaccumulator)
3721 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3722 a = bound(0, (1 + t - time), 1);
3726 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3728 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3729 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, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3734 drawfont = hud_font;
3739 float vote_yescount;
3742 float vote_highlighted; // currently selected vote
3744 float vote_active; // is there an active vote?
3745 float vote_prev; // previous state of vote_active to check for a change
3747 float vote_change; // "time" when vote_active changed
3749 void HUD_VoteWindow(void)
3751 if(!autocvar_hud_panel_vote && !autocvar__hud_configure)
3754 active_panel = HUD_PANEL_VOTE;
3755 HUD_Panel_UpdateCvars(vote);
3758 mySize = panel_size;
3760 if(!autocvar__hud_configure)
3762 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
3763 panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha;
3765 if(panel_bg_alpha_str == "") {
3766 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
3768 panel_bg_alpha = stof(panel_bg_alpha_str);
3773 if(vote_active != vote_prev) {
3775 vote_prev = vote_active;
3778 if(vote_active || autocvar__hud_configure)
3779 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3781 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3783 if(autocvar__hud_configure)
3793 a = panel_bg_alpha * vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3794 HUD_Panel_DrawBg(a);
3795 a = panel_fg_alpha * vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3796 if(panel_bg_padding)
3798 pos += '1 1 0' * panel_bg_padding;
3799 mySize -= '2 2 0' * panel_bg_padding;
3802 // always force 3:1 aspect
3804 if(mySize_x/mySize_y > 3)
3806 newSize_x = 3 * mySize_y;
3807 newSize_y = mySize_y;
3809 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3813 newSize_y = 1/3 * mySize_x;
3814 newSize_x = mySize_x;
3816 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3820 s = "A vote has been called for:";
3821 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3822 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1.75/8), stringwidth_colors);
3823 if(autocvar__hud_configure)
3824 s = "^1Configure the HUD";
3825 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
3827 // print the yes/no counts
3828 s = strcat("Yes (", getcommandkey("vyes", "vyes"), "): ", ftos(vote_yescount));
3829 drawstring_aspect(pos + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '0 1 0', a, DRAWFLAG_NORMAL);
3830 s = strcat("No (", getcommandkey("vno", "vno"), "): ", ftos(vote_nocount));
3831 drawstring_aspect(pos + eX * 0.5 * mySize_x + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '1 0 0', a, DRAWFLAG_NORMAL);
3833 // draw the progress bar backgrounds
3834 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3836 // draw the highlights
3837 if(vote_highlighted == 1) {
3838 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3839 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3841 else if(vote_highlighted == 2) {
3842 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3843 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3846 // draw the progress bars
3847 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3848 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3850 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3851 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3853 drawresetcliparea();
3856 vote_highlighted = 0;
3860 // Mod icons panel (#10)
3863 float mod_active; // is there any active mod icon?
3865 // CTF HUD modicon section
3866 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3867 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3868 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3870 void HUD_Mod_CTF_Reset(void)
3872 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3875 void HUD_Mod_CTF(vector pos, vector mySize)
3877 vector redflag_pos, blueflag_pos;
3879 float f; // every function should have that
3881 float redflag, blueflag; // current status
3882 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3885 stat_items = getstati(STAT_ITEMS);
3886 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3887 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3889 if(redflag || blueflag)
3894 if(autocvar__hud_configure)
3900 // when status CHANGES, set old status into prevstatus and current status into status
3901 if (redflag != redflag_prevframe)
3903 redflag_statuschange_time = time;
3904 redflag_prevstatus = redflag_prevframe;
3905 redflag_prevframe = redflag;
3908 if (blueflag != blueflag_prevframe)
3910 blueflag_statuschange_time = time;
3911 blueflag_prevstatus = blueflag_prevframe;
3912 blueflag_prevframe = blueflag;
3915 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3916 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3918 float BLINK_FACTOR = 0.15;
3919 float BLINK_BASE = 0.85;
3921 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3923 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3925 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3927 string red_icon, red_icon_prevstatus;
3928 float red_alpha, red_alpha_prevstatus;
3929 red_alpha = red_alpha_prevstatus = 1;
3931 case 1: red_icon = "flag_red_taken"; break;
3932 case 2: red_icon = "flag_red_lost"; break;
3933 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3935 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3936 red_icon = "flag_red_shielded";
3938 red_icon = string_null;
3941 switch(redflag_prevstatus) {
3942 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3943 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3944 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3947 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3948 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3949 red_icon_prevstatus = "flag_red_shielded";
3951 red_icon_prevstatus = string_null;
3955 string blue_icon, blue_icon_prevstatus;
3956 float blue_alpha, blue_alpha_prevstatus;
3957 blue_alpha = blue_alpha_prevstatus = 1;
3959 case 1: blue_icon = "flag_blue_taken"; break;
3960 case 2: blue_icon = "flag_blue_lost"; break;
3961 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3963 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3964 blue_icon = "flag_blue_shielded";
3966 blue_icon = string_null;
3969 switch(blueflag_prevstatus) {
3970 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3971 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3972 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3975 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3976 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3977 blue_icon_prevstatus = "flag_blue_shielded";
3979 blue_icon_prevstatus = string_null;
3983 if(mySize_x > mySize_y) {
3984 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3986 blueflag_pos = pos + eX * 0.5 * mySize_x;
3989 redflag_pos = pos + eX * 0.5 * mySize_x;
3991 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3993 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3995 blueflag_pos = pos + eY * 0.5 * mySize_y;
3998 redflag_pos = pos + eY * 0.5 * mySize_y;
4000 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
4003 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
4004 if(red_icon_prevstatus && f < 1)
4005 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
4007 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
4009 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
4010 if(blue_icon_prevstatus && f < 1)
4011 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
4013 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
4016 // Keyhunt HUD modicon section
4017 float kh_runheretime;
4019 void HUD_Mod_KH_Reset(void)
4024 void HUD_Mod_KH(vector pos, vector mySize)
4026 mod_active = 1; // keyhunt should never hide the mod icons panel
4030 vector p, pa, kh_size, kh_asize;
4032 kh_keys = getstati(STAT_KH_KEYS);
4035 if(mySize_x > mySize_y)
4037 p_y = pos_y + 0.25 * mySize_y;
4038 pa = p - eY * 0.25 * mySize_y;
4040 kh_size_x = mySize_x * 0.25;
4041 kh_size_y = 0.75 * mySize_y;
4042 kh_asize_x = mySize_x * 0.25;
4043 kh_asize_y = mySize_y * 0.25;
4047 p_y = pos_y + 0.125 * mySize_y;
4048 pa = p - eY * 0.125 * mySize_y;
4050 kh_size_x = mySize_x * 0.5;
4051 kh_size_y = 0.375 * mySize_y;
4052 kh_asize_x = mySize_x * 0.5;
4053 kh_asize_y = mySize_y * 0.125;
4060 for(i = 0; i < 4; ++i)
4062 key = floor(kh_keys / pow(32, i)) & 31;
4064 if(keyteam == 30 && keycount <= 4)
4066 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
4070 // this yields 8 exactly if "RUN HERE" shows
4075 kh_runheretime = time;
4076 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
4081 for(i = 0; i < 4; ++i)
4083 key = floor(kh_keys / pow(32, i)) & 31;
4096 default: // owned or dropped
4101 a = a * panel_fg_alpha;
4102 aa = aa * panel_fg_alpha;
4108 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4111 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4114 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4117 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4122 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
4125 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4128 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4131 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4134 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4138 if(mySize_x > mySize_y)
4140 p_x += 0.25 * mySize_x;
4141 pa_x += 0.25 * mySize_x;
4147 p_y = pos_y + 0.625 * mySize_y;
4148 pa_y = pos_y + 0.5 * mySize_y;
4154 p_x += 0.5 * mySize_x;
4155 pa_x += 0.5 * mySize_x;
4161 // Nexball HUD mod icon
4162 void HUD_Mod_NexBall(vector pos, vector mySize)
4164 float stat_items, nb_pb_starttime, dt, p;
4166 stat_items = getstati(STAT_ITEMS);
4167 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
4169 if (stat_items & IT_KEY1)
4174 //Manage the progress bar if any
4175 if (nb_pb_starttime > 0)
4177 dt = mod(time - nb_pb_starttime, nb_pb_period);
4178 // one period of positive triangle
4179 p = 2 * dt / nb_pb_period;
4186 if(mySize_x > mySize_y)
4188 barsize = eX * p * mySize_x + eY * mySize_y;
4193 barsize = eX * mySize_x + eY * p * mySize_y;
4196 HUD_Panel_GetProgressBarColor("nexball")
4197 HUD_Panel_DrawProgressBar(pos, vertical, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4200 if (stat_items & IT_KEY1)
4201 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4204 // Race/CTS HUD mod icons
4205 float crecordtime_prev; // last remembered crecordtime
4206 float crecordtime_change_time; // time when crecordtime last changed
4207 float srecordtime_prev; // last remembered srecordtime
4208 float srecordtime_change_time; // time when srecordtime last changed
4210 float race_status_time;
4211 float race_status_prev;
4212 string race_status_name_prev;
4213 void HUD_Mod_Race(vector pos, vector mySize)
4215 mod_active = 1; // race should never hide the mod icons panel
4217 me = playerslots[player_localentnum - 1];
4219 float f; // yet another function has this
4220 score = me.(scores[ps_primary]);
4222 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
4223 return; // no records in the actual race
4225 drawfont = hud_bigfont;
4227 // clientside personal record
4229 if(gametype == GAME_CTS)
4233 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4235 if(score && (score < t || !t)) {
4236 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4237 if(cvar("cl_autodemo_delete_keeprecords"))
4239 f = cvar("cl_autodemo_delete");
4241 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4245 if(t != crecordtime_prev) {
4246 crecordtime_prev = t;
4247 crecordtime_change_time = time;
4249 f = time - crecordtime_change_time;
4252 drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4253 drawstring_aspect(pos + eY * 0.25 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4255 drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4256 drawstring_aspect(pos + eY * 0.25 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4257 drawstring_aspect_expanding(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4258 drawstring_aspect_expanding(pos + eY * 0.25 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4262 t = race_server_record;
4263 if(t != srecordtime_prev) {
4264 srecordtime_prev = t;
4265 srecordtime_change_time = time;
4267 f = time - srecordtime_change_time;
4270 drawstring_aspect(pos + eY * 0.5 * mySize_y, "Server best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4271 drawstring_aspect(pos + eY * 0.75 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4273 drawstring_aspect(pos + eY * 0.5 * mySize_y, "Server best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4274 drawstring_aspect(pos + eY * 0.75 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4275 drawstring_aspect_expanding(pos + eY * 0.5 * mySize_y, "Server best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4276 drawstring_aspect_expanding(pos + eY * 0.75 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4279 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4280 race_status_time = time + 5;
4281 race_status_prev = race_status;
4282 if (race_status_name_prev)
4283 strunzone(race_status_name_prev);
4284 race_status_name_prev = strzone(race_status_name);
4287 pos_x += mySize_x/2;
4290 a = bound(0, race_status_time - time, 1);
4293 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4297 rank = race_CheckName(race_status_name);
4299 rankname = race_PlaceName(rank);
4302 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4304 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4306 if(race_status == 0)
4307 drawpic_aspect_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4308 else if(race_status == 1) {
4309 drawpic_aspect_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4310 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4311 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4312 } else if(race_status == 2) {
4313 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4314 drawpic_aspect_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4316 drawpic_aspect_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4317 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4318 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4319 } else if(race_status == 3) {
4320 drawpic_aspect_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4321 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4322 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4325 if (race_status_time - time <= 0) {
4326 race_status_prev = -1;
4328 if(race_status_name)
4329 strunzone(race_status_name);
4330 race_status_name = string_null;
4331 if(race_status_name_prev)
4332 strunzone(race_status_name_prev);
4333 race_status_name_prev = string_null;
4335 drawfont = hud_font;
4338 float mod_prev; // previous state of mod_active to check for a change
4340 float mod_change; // "time" when mod_active changed
4342 void HUD_ModIcons(void)
4344 if(!autocvar_hud_panel_modicons && !autocvar__hud_configure)
4347 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !autocvar__hud_configure)
4350 active_panel = HUD_PANEL_MODICONS;
4351 HUD_Panel_UpdateCvars(modicons);
4354 mySize = panel_size;
4356 if(mod_active != mod_prev) {
4358 mod_prev = mod_active;
4361 if(mod_active || autocvar__hud_configure)
4362 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4364 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4367 HUD_Panel_DrawBg(mod_alpha);
4369 if(panel_bg_padding)
4371 pos += '1 1 0' * panel_bg_padding;
4372 mySize -= '2 2 0' * panel_bg_padding;
4375 // these MUST be ran in order to update mod_active
4376 if(gametype == GAME_KEYHUNT)
4377 HUD_Mod_KH(pos, mySize);
4378 else if(gametype == GAME_CTF || autocvar__hud_configure)
4379 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4380 else if(gametype == GAME_NEXBALL)
4381 HUD_Mod_NexBall(pos, mySize);
4382 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4383 HUD_Mod_Race(pos, mySize);
4386 // Draw pressed keys (#11)
4388 void HUD_DrawPressedKeys(void)
4390 if(!autocvar_hud_panel_pressedkeys && !autocvar__hud_configure)
4393 if(!(spectatee_status > 0 || autocvar_hud_panel_pressedkeys >= 2 || autocvar__hud_configure))
4396 active_panel = HUD_PANEL_PRESSEDKEYS;
4397 HUD_Panel_UpdateCvars(pressedkeys);
4400 mySize = panel_size;
4402 HUD_Panel_DrawBg(1);
4403 if(panel_bg_padding)
4405 pos += '1 1 0' * panel_bg_padding;
4406 mySize -= '2 2 0' * panel_bg_padding;
4409 // force custom aspect
4410 if(autocvar_hud_panel_pressedkeys_aspect)
4413 if(mySize_x/mySize_y > autocvar_hud_panel_pressedkeys_aspect)
4415 newSize_x = autocvar_hud_panel_pressedkeys_aspect * mySize_y;
4416 newSize_y = mySize_y;
4418 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4422 newSize_y = 1/autocvar_hud_panel_pressedkeys_aspect * mySize_x;
4423 newSize_x = mySize_x;
4425 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4431 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4434 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4435 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4436 drawpic_aspect_skin(pos + eX * mySize_x * (1/3), ((pressedkeys & KEY_FORWARD) ? "key_forward_inv.tga" : "key_forward.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4437 drawpic_aspect_skin(pos + eX * mySize_x * (2/3), ((pressedkeys & KEY_JUMP) ? "key_jump_inv.tga" : "key_jump.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4438 drawpic_aspect_skin(pos + eY * 0.5 * mySize_y, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4439 drawpic_aspect_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', panel_fg_alpha, DRAWFLAG_NORMAL);
4440 drawpic_aspect_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', panel_fg_alpha, DRAWFLAG_NORMAL);
4443 // Handle chat as a panel (#12)
4447 if(!autocvar_hud_panel_chat && !autocvar__hud_configure)
4449 cvar_set("con_chatrect", "0");
4453 active_panel = HUD_PANEL_CHAT;
4454 HUD_Panel_UpdateCvars(chat);
4456 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
4458 panel_pos_y = panel_bg_border;
4459 panel_size_y = vid_conheight - panel_bg_border * 2;
4460 if(panel_bg == "0") // force a border when maximized
4462 if(precache_pic(panel_bg) == "") {
4463 panel_bg = strcat(hud_skin_path, "/border_default");
4464 if(precache_pic(panel_bg) == "") {
4465 panel_bg = "gfx/hud/default/border_default";
4469 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an alpha of at least 0.75
4474 mySize = panel_size;
4476 HUD_Panel_DrawBg(1);
4478 if(panel_bg_padding)
4480 pos += '1 1 0' * panel_bg_padding;
4481 mySize -= '2 2 0' * panel_bg_padding;
4484 cvar_set("con_chatrect", "1");
4486 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4487 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4489 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4490 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4492 if(autocvar__hud_configure)
4495 chatsize = cvar("con_chatsize");
4496 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4498 for(i = 0; i < cvar("con_chat"); ++i)
4500 if(i == cvar("con_chat") - 1)
4503 a = panel_fg_alpha * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4504 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);
4509 // Engine info panel (#13)
4516 float frametimeavg1; // 1 frame ago
4517 float frametimeavg2; // 2 frames ago
4518 void HUD_EngineInfo(void)
4520 if(!autocvar_hud_panel_engineinfo && !autocvar__hud_configure)
4523 active_panel = HUD_PANEL_ENGINEINFO;
4524 HUD_Panel_UpdateCvars(engineinfo);
4527 mySize = panel_size;
4529 HUD_Panel_DrawBg(1);
4530 if(panel_bg_padding)
4532 pos += '1 1 0' * panel_bg_padding;
4533 mySize -= '2 2 0' * panel_bg_padding;
4536 float currentTime = gettime(GETTIME_REALTIME);
4537 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
4539 float currentframetime = currentTime - prevfps_time;
4540 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4541 frametimeavg2 = frametimeavg1;
4542 frametimeavg1 = frametimeavg;
4545 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4546 if(currentframetime > 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.
4548 if(fabs(prevfps - (1/frametimeavg)) > prevfps * cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_instantupdate_change_threshold")) // if there was a big jump in fps, just force prevfps at current (1/currentframetime) to make big updates instant
4549 prevfps = (1/currentframetime);
4550 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"
4552 prevfps_time = currentTime;
4557 if(currentTime - prevfps_time > cvar("hud_panel_engineinfo_framecounter_time"))
4559 prevfps = framecounter/(currentTime - prevfps_time);
4561 prevfps_time = currentTime;
4566 color = HUD_Get_Num_Color (prevfps, 100);
4567 drawfont = hud_bigfont;
4568 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_panel_engineinfo_framecounter_decimals"))), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4569 drawfont = hud_font;
4572 // Info messages panel (#14)
4574 #define drawInfoMessage(s)\
4575 if(autocvar_hud_panel_infomessages_flip)\
4576 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);\
4577 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
4579 void HUD_InfoMessages(void)
4581 if(!autocvar_hud_panel_infomessages && !autocvar__hud_configure)
4584 active_panel = HUD_PANEL_INFOMESSAGES;
4585 HUD_Panel_UpdateCvars(infomessages);
4588 mySize = panel_size;
4590 HUD_Panel_DrawBg(1);
4591 if(panel_bg_padding)
4593 pos += '1 1 0' * panel_bg_padding;
4594 mySize -= '2 2 0' * panel_bg_padding;
4597 // always force 5:1 aspect
4599 if(mySize_x/mySize_y > 5)
4601 newSize_x = 5 * mySize_y;
4602 newSize_y = mySize_y;
4604 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4608 newSize_y = 1/5 * mySize_x;
4609 newSize_x = mySize_x;
4611 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4620 fontsize = '0.20 0.20 0' * mySize_y;
4623 if(spectatee_status != 0)
4629 if(!autocvar__hud_configure)
4631 if(spectatee_status && !intermission)
4633 if(spectatee_status == -1)
4636 s = strcat("^1Spectating: ^7", GetPlayerName(spectatee_status - 1));
4639 if(spectatee_status == -1)
4640 s = strcat("^1Press ^3", getcommandkey("primary fire", "+fire"), "^1 to spectate");
4642 s = strcat("^1Press ^3", getcommandkey("primary fire", "+fire"), "^1 for another player");
4645 if(spectatee_status == -1)
4646 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
4648 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+fire2"), "^1 to observe");
4651 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
4654 if(gametype == GAME_ARENA)
4655 s = "^1Wait for your turn to join";
4656 else if(gametype == GAME_LMS)
4659 sk = playerslots[player_localentnum - 1];
4660 if(sk.(scores[ps_primary]) >= 666)
4661 s = "^1Match has already begun";
4662 else if(sk.(scores[ps_primary]) > 0)
4663 s = "^1You have no more lives left";
4665 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4668 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4671 //show restart countdown:
4672 if (time < getstatf(STAT_GAMESTARTTIME)) {
4674 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4675 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4676 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
4677 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4681 if(warmup_stage && !intermission)
4683 s = "^2Currently in ^1warmup^2 stage!";
4688 if(mod(time, 1) >= 0.5)
4693 if(ready_waiting && !intermission && !spectatee_status)
4695 if(ready_waiting_for_me)
4698 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
4700 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
4705 s = strcat("^2Waiting for others to ready up to end warmup...");
4707 s = strcat("^2Waiting for others to ready up...");
4711 else if(warmup_stage && !intermission && !spectatee_status)
4713 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
4717 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4719 float ts_min, ts_max;
4720 tm = teams.sort_next;
4723 for(; tm.sort_next; tm = tm.sort_next)
4725 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4727 if(!ts_min) ts_min = tm.team_size;
4728 else ts_min = min(ts_min, tm.team_size);
4729 if(!ts_max) ts_max = tm.team_size;
4730 else ts_max = max(ts_max, tm.team_size);
4732 if ((ts_max - ts_min) > 1)
4734 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
4735 tm = GetTeam(myteam, false);
4737 if (tm.team != COLOR_SPECTATOR)
4738 if (tm.team_size == ts_max)
4739 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
4747 s = "^7Press ^3ESC ^7to show HUD options.";
4749 s = "^3Doubleclick ^7a panel for panel-specific options.";
4751 s = "^3CTRL ^7to disable collision testing, ^3SHIFT ^7and";
4753 s = "^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.";
4764 void HUD_ShowSpeed(void)
4767 float pos, conversion_factor;
4768 string speed, zspeed, unit;
4770 switch(cvar("cl_showspeed_unit"))
4775 conversion_factor = 1.0;
4779 conversion_factor = 1.0;
4783 conversion_factor = 0.0254;
4787 conversion_factor = 0.0254 * 3.6;
4791 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4795 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4799 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4801 numsize_x = numsize_y = cvar("cl_showspeed_size");
4802 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4804 drawfont = hud_bigfont;
4805 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
4807 if (cvar("cl_showspeed_z") == 1) {
4808 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4809 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
4812 drawfont = hud_font;
4815 vector acc_prevspeed;
4819 void HUD_ShowAcceleration(void)
4821 float acceleration, sz, scale, alpha, f;
4822 vector pos, top, rgb;
4823 top_x = vid_conwidth/2;
4826 f = time - acc_prevtime;
4827 if(cvar("cl_showacceleration_z"))
4828 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4830 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4831 acc_prevspeed = pmove_vel;
4832 acc_prevtime = time;
4834 f = bound(0, f * 10, 1);
4835 acc_avg = acc_avg * (1 - f) + acceleration * f;
4836 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4837 if (acceleration == 0)
4840 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4842 sz = cvar("cl_showacceleration_size");
4843 scale = cvar("cl_showacceleration_scale");
4844 alpha = cvar("cl_showacceleration_alpha");
4845 if (cvar("cl_showacceleration_color_custom"))
4846 rgb = stov(cvar_string("cl_showacceleration_color"));
4848 if (acceleration < 0)
4849 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4851 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4854 if (acceleration > 0)
4855 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
4857 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
4860 void HUD_Reset (void)
4862 // reset gametype specific icons
4863 if(gametype == GAME_KEYHUNT)
4865 else if(gametype == GAME_CTF)
4866 HUD_Mod_CTF_Reset();
4869 #define HUD_DrawPanel(id)\
4871 case (HUD_PANEL_RADAR):\
4872 HUD_Radar(); break;\
4873 case (HUD_PANEL_WEAPONS):\
4874 HUD_Weapons(); break;\
4875 case (HUD_PANEL_AMMO):\
4877 case (HUD_PANEL_POWERUPS):\
4878 HUD_Powerups(); break;\
4879 case (HUD_PANEL_HEALTHARMOR):\
4880 HUD_HealthArmor(); break;\
4881 case (HUD_PANEL_NOTIFY):\
4882 HUD_Notify(); break;\
4883 case (HUD_PANEL_TIMER):\
4884 HUD_Timer(); break;\
4885 case (HUD_PANEL_SCORE):\
4886 HUD_Score(); break;\
4887 case (HUD_PANEL_RACETIMER):\
4888 HUD_RaceTimer(); break;\
4889 case (HUD_PANEL_VOTE):\
4890 HUD_VoteWindow(); break;\
4891 case (HUD_PANEL_MODICONS):\
4892 HUD_ModIcons(); break;\
4893 case (HUD_PANEL_PRESSEDKEYS):\
4894 HUD_DrawPressedKeys(); break;\
4895 case (HUD_PANEL_CHAT):\
4897 case (HUD_PANEL_ENGINEINFO):\
4898 HUD_EngineInfo(); break;\
4899 case (HUD_PANEL_INFOMESSAGES):\
4900 HUD_InfoMessages(); break;\
4903 void HUD_Main (void)
4905 hud_skin_path = strcat("gfx/hud/", autocvar_hud_skin);
4907 // global hud alpha fade
4908 if(disable_menu_alphacheck == 1)
4911 hud_fade_alpha = (1 - autocvar__menu_alpha);
4913 if(scoreboard_fade_alpha)
4914 hud_fade_alpha = (1 - scoreboard_fade_alpha);
4916 if(intermission == 2) // no hud during mapvote
4918 else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
4921 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4922 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4924 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4928 // HUD configure visible grid
4929 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4933 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2); ++i)
4935 drawfill(eX * i * vid_conwidth * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2), eX + eY * vid_conheight, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4938 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2); ++i)
4940 drawfill(eY * i * vid_conheight * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2), eY + eX * vid_conwidth, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4946 if((teamplay) && autocvar_hud_dock_color_team) {
4947 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4948 color = colormapPaletteColor(mod(f, 16), 1) * autocvar_hud_dock_color_team;
4950 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && autocvar_hud_dock_color_team) {
4951 color = '1 0 0' * autocvar_hud_dock_color_team;
4953 else if(autocvar_hud_dock_color == "shirt") {
4954 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4955 color = colormapPaletteColor(floor(f / 16), 0);
4957 else if(autocvar_hud_dock_color == "pants") {
4958 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4959 color = colormapPaletteColor(mod(f, 16), 1);
4962 color = stov(autocvar_hud_dock_color);
4965 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4968 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4969 if(precache_pic(pic) == "") {
4970 pic = strcat(hud_skin_path, "/dock_medium");
4971 if(precache_pic(pic) == "") {
4972 pic = "gfx/hud/default/dock_medium";
4975 drawpic('0 0 0', pic, eX * vid_conwidth + eY * vid_conheight, color, autocvar_hud_dock_alpha * hud_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
4978 // cache the panel order into the panel_order array
4979 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4980 if(hud_panelorder_prev)
4981 strunzone(hud_panelorder_prev);
4982 hud_panelorder_prev = strzone(autocvar__hud_panelorder);
4983 tokenize_console(autocvar__hud_panelorder);
4984 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4985 panel_order[i] = stof(argv(i));
4988 // draw panels in order specified by panel_order array
4989 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
4990 if(i != HUD_PANEL_CHAT || !autocvar__con_chat_maximized) // don't draw maximized chat panel twice!
4991 HUD_DrawPanel(panel_order[i]);
4994 // draw chat panel on top if it is maximized
4995 if(autocvar__con_chat_maximized)
4996 HUD_DrawPanel(HUD_PANEL_CHAT);
4998 // TODO hud_'ify these
4999 if (cvar("cl_showspeed"))
5001 if (cvar("cl_showacceleration"))
5002 HUD_ShowAcceleration();
5004 if (autocvar__hud_configure && spectatee_status && hud_configure_prev == -1) // try to join if we are in hud_configure mode, but still spectating, and in the first frame (in order to get rid of motd when launching a server via the menu "HUD Setup" button)
5005 localcmd("cmd selectteam auto; cmd join\n");
5007 hud_configure_prev = autocvar__hud_configure;
5009 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again
5010 disable_menu_alphacheck = 0;