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 && HUD_WouldDrawScoreboard()) // 24 = height of Scoreboard text
289 centerprint_start_y = scoreboard_bottom + centerprint_fontsize_y;
291 pos = centerprint_start;
292 for (i=0; i<centerprint_num; i = i + 1)
294 ts = centerprint_messages[i];
295 drawfontscale = sz * '1 1 0';
296 drawfont = hud_bigfont;
297 pos_x = (vid_conwidth - stringwidth(ts, TRUE, centerprint_fontsize)) * 0.5;
300 drawcolorcodedstring(pos + '0 1 0' * (1 - sz) * 0.5 *centerprint_fontsize_y, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
301 pos_y = pos_y + centerprint_fontsize_y;
304 // half height for empty lines looks better
305 pos_y = pos_y + sz * centerprint_fontsize_y * 0.5;
306 drawfontscale = '1 1 0';
311 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
313 position_x -= 2 / 3 * strlen(text) * scale_x;
314 drawstring(position, text, scale, rgb, alpha, flag);
317 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
319 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
320 drawstring(position, text, scale, rgb, alpha, flag);
323 // return the string of the given race place
324 string race_PlaceName(float pos) {
332 return strcat(ftos(pos), "th");
335 // return the string of the onscreen race timer
336 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
344 if(histime == 0) // goal hit
348 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
358 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
364 lapstr = strcat(" (-", ftos(lapdelta), "L)");
367 else if(lapdelta < 0)
369 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
373 else if(histime > 0) // anticipation
375 if(mytime >= histime)
376 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
378 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
385 cpname = "Start line";
387 cpname = "Finish line";
389 cpname = strcat("Intermediate ", ftos(cp));
391 cpname = "Finish line";
394 return strcat(col, cpname);
395 else if(hisname == "")
396 return strcat(col, cpname, " (", timestr, ")");
398 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
401 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
402 float race_CheckName(string net_name) {
404 for (i=RANKINGS_CNT-1;i>=0;--i)
405 if(grecordholder[i] == net_name)
417 void HUD_Panel_ExportCfg(string cfgname)
420 fh = fopen(strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg"), FILE_WRITE);
423 fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
424 fputs(fh, strcat("seta hud_panel_bg \"", cvar_string("hud_panel_bg"), "\"", "\n"));
425 fputs(fh, strcat("seta hud_panel_bg_color \"", cvar_string("hud_panel_bg_color"), "\"", "\n"));
426 fputs(fh, strcat("seta hud_panel_bg_color_team \"", cvar_string("hud_panel_bg_color_team"), "\"", "\n"));
427 fputs(fh, strcat("seta hud_panel_bg_alpha \"", cvar_string("hud_panel_bg_alpha"), "\"", "\n"));
428 fputs(fh, strcat("seta hud_panel_bg_border \"", cvar_string("hud_panel_bg_border"), "\"", "\n"));
429 fputs(fh, strcat("seta hud_panel_bg_padding \"", cvar_string("hud_panel_bg_padding"), "\"", "\n"));
430 fputs(fh, strcat("seta hud_panel_fg_alpha \"", cvar_string("hud_panel_fg_alpha"), "\"", "\n"));
433 fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
434 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
435 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
436 fputs(fh, strcat("seta hud_dock_alpha \"", cvar_string("hud_dock_alpha"), "\"", "\n"));
439 fputs(fh, strcat("seta hud_progressbar_alpha \"", cvar_string("hud_progressbar_alpha"), "\"", "\n"));
440 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
441 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
442 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
443 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
444 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
445 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
448 fputs(fh, strcat("seta _hud_panelorder \"", cvar_string("_hud_panelorder"), "\"", "\n"));
451 fputs(fh, strcat("seta hud_configure_grid \"", cvar_string("hud_configure_grid"), "\"", "\n"));
452 fputs(fh, strcat("seta hud_configure_grid_xsize \"", cvar_string("hud_configure_grid_xsize"), "\"", "\n"));
453 fputs(fh, strcat("seta hud_configure_grid_ysize \"", cvar_string("hud_configure_grid_ysize"), "\"", "\n"));
456 fputs(fh, strcat("seta scr_centerpos \"", cvar_string("scr_centerpos"), "\"", "\n"));
459 // common cvars for all panels
461 for (i = 0; i < HUD_PANEL_NUM; ++i)
465 fputs(fh, strcat("seta hud_panel_", panel_name, " ", cvar_string(strcat("hud_panel_", panel_name)), "\n"));
466 fputs(fh, strcat("seta hud_panel_", panel_name, "_pos \"", cvar_string(strcat("hud_panel_", panel_name, "_pos")), "\"", "\n"));
467 fputs(fh, strcat("seta hud_panel_", panel_name, "_size \"", cvar_string(strcat("hud_panel_", panel_name, "_size")), "\"", "\n"));
468 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg \"", cvar_string(strcat("hud_panel_", panel_name, "_bg")), "\"", "\n"));
469 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_color \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_color")), "\"", "\n"));
470 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_color_team \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_color_team")), "\"", "\n"));
471 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_alpha")), "\"", "\n"));
472 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_border \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_border")), "\"", "\n"));
473 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_padding \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_padding")), "\"", "\n"));
475 case HUD_PANEL_WEAPONS:
476 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble")), "\"", "\n"));
477 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_padding \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_padding")), "\"", "\n"));
478 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_outofammo \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_outofammo")), "\"", "\n"));
479 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_donthave \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_donthave")), "\"", "\n"));
480 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_unavailable \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_unavailable")), "\"", "\n"));
481 fputs(fh, strcat("seta hud_panel_", panel_name, "_ammo_color \"", cvar_string(strcat("hud_panel_", panel_name, "_ammo_color")), "\"", "\n"));
482 fputs(fh, strcat("seta hud_panel_", panel_name, "_ammo_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_ammo_alpha")), "\"", "\n"));
483 fputs(fh, strcat("seta hud_panel_", panel_name, "_aspect \"", cvar_string(strcat("hud_panel_", panel_name, "_aspect")), "\"", "\n"));
486 fputs(fh, strcat("seta hud_panel_", panel_name, "_onlycurrent \"", cvar_string(strcat("hud_panel_", panel_name, "_onlycurrent")), "\"", "\n"));
487 fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
489 case HUD_PANEL_POWERUPS:
490 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\"", "\n"));
491 fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
492 fputs(fh, strcat("seta hud_panel_", panel_name, "_baralign \"", cvar_string(strcat("hud_panel_", panel_name, "_baralign")), "\"", "\n"));
493 fputs(fh, strcat("seta hud_panel_", panel_name, "_progressbar \"", cvar_string(strcat("hud_panel_", panel_name, "_progressbar")), "\"", "\n"));
495 case HUD_PANEL_HEALTHARMOR:
496 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\n"));
497 fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
498 fputs(fh, strcat("seta hud_panel_", panel_name, "_baralign \"", cvar_string(strcat("hud_panel_", panel_name, "_baralign")), "\"", "\n"));
499 fputs(fh, strcat("seta hud_panel_", panel_name, "_progressbar \"", cvar_string(strcat("hud_panel_", panel_name, "_progressbar")), "\"", "\n"));
501 case HUD_PANEL_NOTIFY:
502 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\"", "\n"));
503 fputs(fh, strcat("seta hud_panel_", panel_name, "_print \"", cvar_string(strcat("hud_panel_", panel_name, "_print")), "\"", "\n"));
505 case HUD_PANEL_RADAR:
506 fputs(fh, strcat("seta hud_panel_", panel_name, "_foreground_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_foreground_alpha")), "\"", "\n"));
509 fputs(fh, strcat("seta hud_panel_", panel_name, "_alreadyvoted_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_alreadyvoted_alpha")), "\"", "\n"));
511 case HUD_PANEL_PRESSEDKEYS:
512 fputs(fh, strcat("seta hud_panel_", panel_name, "_aspect \"", cvar_string(strcat("hud_panel_", panel_name, "_aspect")), "\"", "\n"));
514 case HUD_PANEL_INFOMESSAGES:
515 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\"", "\n"));
520 fputs(fh, strcat("menu_restart", "\n")); // force a menu update when execing config, so that the dialogs are updated
522 print("^2Successfully exported to hud_", autocvar_hud_skin, "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
527 const float hlBorderSize = 4;
528 const string hlBorder = "gfx/hud/default/border_highlighted";
529 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
530 void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
532 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
533 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);
534 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);
535 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);
536 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);
539 // draw the background/borders
540 #define HUD_Panel_DrawBg(alpha)\
542 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));\
543 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
544 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);
546 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
553 pic = strcat(hud_skin_path, "/statusbar_vertical");
554 if(precache_pic(pic) == "") {
555 pic = "gfx/hud/default/statusbar_vertical";
557 drawsubpic(pos, eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, pic, '0 0 0', '1 0.25 0', color, alpha, drawflag);
558 if(mySize_y/mySize_x > 2)
559 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);
560 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);
562 pic = strcat(hud_skin_path, "/statusbar");
563 if(precache_pic(pic) == "") {
564 pic = "gfx/hud/default/statusbar";
566 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
567 if(mySize_x/mySize_y > 2)
568 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);
569 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);
573 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
579 pic = strcat(hud_skin_path, "/num_leading");
580 if(precache_pic(pic) == "") {
581 pic = "gfx/hud/default/num_leading";
584 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
585 if(mySize_x/mySize_y > 2)
586 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);
587 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);
590 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
591 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
602 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
603 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
605 for (i = 0; i < HUD_PANEL_NUM; ++i) {
606 if(i == highlightedPanel || !panel_enabled)
609 HUD_Panel_UpdatePosSizeForId(i)
611 panel_pos -= '1 1 0' * panel_bg_border;
612 panel_size += '2 2 0' * panel_bg_border;
614 if(myPos_y + mySize_y < panel_pos_y)
616 if(myPos_y > panel_pos_y + panel_size_y)
619 if(myPos_x + mySize_x < panel_pos_x)
621 if(myPos_x > panel_pos_x + panel_size_x)
624 // OK, there IS a collision.
626 myCenter_x = myPos_x + 0.5 * mySize_x;
627 myCenter_y = myPos_y + 0.5 * mySize_y;
629 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
630 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
632 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
634 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
635 myTarget_x = panel_pos_x - mySize_x;
636 else // push it upwards
637 myTarget_y = panel_pos_y - mySize_y;
639 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
641 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
642 myTarget_x = panel_pos_x + panel_size_x;
643 else // push it upwards
644 myTarget_y = panel_pos_y - mySize_y;
646 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
648 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
649 myTarget_x = panel_pos_x - mySize_x;
650 else // push it downwards
651 myTarget_y = panel_pos_y + panel_size_y;
653 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
655 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
656 myTarget_x = panel_pos_x + panel_size_x;
657 else // push it downwards
658 myTarget_y = panel_pos_y + panel_size_y;
660 if(cvar("hud_configure_checkcollisions_debug"))
661 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
667 void HUD_Panel_SetPos(vector pos)
669 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
673 if(cvar("hud_configure_checkcollisions_debug"))
674 drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
676 if(autocvar_hud_configure_grid)
678 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;
679 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;
682 if(hud_configure_checkcollisions)
683 pos = HUD_Panel_CheckMove(pos, mySize);
685 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
686 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
689 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
691 HUD_Panel_GetName(highlightedPanel);
692 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
695 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
696 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
706 ratio = mySize_x/mySize_y;
708 for (i = 0; i < HUD_PANEL_NUM; ++i) {
709 if(i == highlightedPanel || !panel_enabled)
712 HUD_Panel_UpdatePosSizeForId(i)
714 panel_pos -= '1 1 0' * panel_bg_border;
715 panel_size += '2 2 0' * panel_bg_border;
717 targEndPos = panel_pos + panel_size;
719 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
720 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
723 if (resizeCorner == 1)
725 // check if this panel is on our way
726 if (resizeorigin_x <= panel_pos_x)
728 if (resizeorigin_y <= panel_pos_y)
730 if (targEndPos_x <= resizeorigin_x - mySize_x)
732 if (targEndPos_y <= resizeorigin_y - mySize_y)
735 // there is a collision:
736 // detect which side of the panel we are facing is actually limiting the resizing
737 // (which side the resize direction finds for first) and reduce the size up to there
739 // dist is the distance between resizeorigin and the "analogous" point of the panel
740 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
741 dist_x = resizeorigin_x - targEndPos_x;
742 dist_y = resizeorigin_y - targEndPos_y;
743 if (dist_y <= 0 || dist_x / dist_y > ratio)
744 mySize_x = min(mySize_x, dist_x);
746 mySize_y = min(mySize_y, dist_y);
748 else if (resizeCorner == 2)
750 if (resizeorigin_x >= targEndPos_x)
752 if (resizeorigin_y <= panel_pos_y)
754 if (panel_pos_x >= resizeorigin_x + mySize_x)
756 if (targEndPos_y <= resizeorigin_y - mySize_y)
759 dist_x = panel_pos_x - resizeorigin_x;
760 dist_y = resizeorigin_y - targEndPos_y;
761 if (dist_y <= 0 || dist_x / dist_y > ratio)
762 mySize_x = min(mySize_x, dist_x);
764 mySize_y = min(mySize_y, dist_y);
766 else if (resizeCorner == 3)
768 if (resizeorigin_x <= panel_pos_x)
770 if (resizeorigin_y >= targEndPos_y)
772 if (targEndPos_x <= resizeorigin_x - mySize_x)
774 if (panel_pos_y >= resizeorigin_y + mySize_y)
777 dist_x = resizeorigin_x - targEndPos_x;
778 dist_y = panel_pos_y - resizeorigin_y;
779 if (dist_y <= 0 || dist_x / dist_y > ratio)
780 mySize_x = min(mySize_x, dist_x);
782 mySize_y = min(mySize_y, dist_y);
784 else if (resizeCorner == 4)
786 if (resizeorigin_x >= targEndPos_x)
788 if (resizeorigin_y >= targEndPos_y)
790 if (panel_pos_x >= resizeorigin_x + mySize_x)
792 if (panel_pos_y >= resizeorigin_y + mySize_y)
795 dist_x = panel_pos_x - resizeorigin_x;
796 dist_y = panel_pos_y - resizeorigin_y;
797 if (dist_y <= 0 || dist_x / dist_y > ratio)
798 mySize_x = min(mySize_x, dist_x);
800 mySize_y = min(mySize_y, dist_y);
802 if(cvar("hud_configure_checkcollisions_debug"))
803 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
809 void HUD_Panel_SetPosSize(vector mySize)
811 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
813 resizeorigin = panel_click_resizeorigin;
816 // minimum panel size cap
817 mySize_x = max(0.025 * vid_conwidth, mySize_x);
818 mySize_y = max(0.025 * vid_conheight, mySize_y);
820 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.
822 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
823 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
826 // collision testing|
827 // -----------------+
829 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
830 if(resizeCorner == 1) {
831 myPos_x = resizeorigin_x - mySize_x;
832 myPos_y = resizeorigin_y - mySize_y;
833 } else if(resizeCorner == 2) {
834 myPos_x = resizeorigin_x;
835 myPos_y = resizeorigin_y - mySize_y;
836 } else if(resizeCorner == 3) {
837 myPos_x = resizeorigin_x - mySize_x;
838 myPos_y = resizeorigin_y;
839 } else { // resizeCorner == 4
840 myPos_x = resizeorigin_x;
841 myPos_y = resizeorigin_y;
844 // left/top screen edges
846 mySize_x = mySize_x + myPos_x;
848 mySize_y = mySize_y + myPos_y;
850 // bottom/right screen edges
851 if(myPos_x + mySize_x > vid_conwidth)
852 mySize_x = vid_conwidth - myPos_x;
853 if(myPos_y + mySize_y > vid_conheight)
854 mySize_y = vid_conheight - myPos_y;
856 if(cvar("hud_configure_checkcollisions_debug"))
857 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
859 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
860 if(autocvar_hud_configure_grid)
862 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;
863 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;
866 if(hud_configure_checkcollisions)
867 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
869 // 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)
870 mySize_x = max(0.025 * vid_conwidth, mySize_x);
871 mySize_y = max(0.025 * vid_conheight, mySize_y);
873 // do another pos check, as size might have changed by now
874 if(resizeCorner == 1) {
875 myPos_x = resizeorigin_x - mySize_x;
876 myPos_y = resizeorigin_y - mySize_y;
877 } else if(resizeCorner == 2) {
878 myPos_x = resizeorigin_x;
879 myPos_y = resizeorigin_y - mySize_y;
880 } else if(resizeCorner == 3) {
881 myPos_x = resizeorigin_x - mySize_x;
882 myPos_y = resizeorigin_y;
883 } else { // resizeCorner == 4
884 myPos_x = resizeorigin_x;
885 myPos_y = resizeorigin_y;
888 if(cvar("hud_configure_checkcollisions_debug"))
889 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
891 HUD_Panel_GetName(highlightedPanel);
893 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
894 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
896 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
897 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
901 float prevMouseClicked; // previous state
902 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
903 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
906 float menu_enabled_time;
907 float pressed_key_time;
908 void HUD_Panel_Arrow_Action(float nPrimary)
910 if (highlightedPanel_prev == -1 || mouseClicked)
913 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
916 if(autocvar_hud_configure_grid)
918 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
920 if (hudShiftState & S_SHIFT)
921 step = bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
923 step = 2 * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
927 if (hudShiftState & S_SHIFT)
928 step = bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
930 step = 2 * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
935 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
936 step = vid_conheight;
939 if (hudShiftState & S_SHIFT)
940 step = (step / 256); // more precision
942 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
945 highlightedPanel = highlightedPanel_prev;
947 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
949 vector prev_pos, prev_size;
950 prev_pos = panel_pos;
951 prev_size = panel_size;
953 if (hudShiftState & S_ALT) // resize
955 highlightedAction = 1;
956 if(nPrimary == K_UPARROW)
958 else if(nPrimary == K_RIGHTARROW)
960 else if(nPrimary == K_LEFTARROW)
962 else // if(nPrimary == K_DOWNARROW)
965 // ctrl+arrow reduces the size, instead of increasing it
966 // Note that ctrl disables collisions check too, but it's fine
967 // since we don't collide with anything reducing the size
968 if (hudShiftState & S_CTRL) {
970 resizeCorner = 5 - resizeCorner;
975 panel_click_resizeorigin = panel_pos;
976 if(resizeCorner == 1) {
977 panel_click_resizeorigin += mySize;
979 } else if(resizeCorner == 2) {
980 panel_click_resizeorigin_y += mySize_y;
982 } else if(resizeCorner == 3) {
983 panel_click_resizeorigin_x += mySize_x;
985 } else { // resizeCorner == 4
988 HUD_Panel_SetPosSize(mySize);
992 highlightedAction = 2;
995 if(nPrimary == K_UPARROW)
997 else if(nPrimary == K_DOWNARROW)
999 else if(nPrimary == K_LEFTARROW)
1001 else // if(nPrimary == K_RIGHTARROW)
1004 HUD_Panel_SetPos(pos);
1007 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
1009 if (prev_pos != panel_pos || prev_size != panel_size)
1012 panel_pos_backup = prev_pos;
1013 panel_size_backup = prev_size;
1014 highlightedPanel_backup = highlightedPanel;
1018 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1020 if(!autocvar__hud_configure)
1023 // allow console bind to work
1026 con_keys = findkeysforcommand("toggleconsole");
1027 keys = tokenize(con_keys);
1029 float hit_con_bind, i;
1030 for (i = 0; i < keys; ++i)
1032 if(nPrimary == stof(argv(i)))
1036 if(bInputType == 0) {
1037 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1038 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1039 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1041 else if(bInputType == 1) {
1042 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1043 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1044 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1047 if(nPrimary == K_MOUSE1)
1049 if(bInputType == 0) { // key pressed
1053 else if(bInputType == 1) {// key released
1058 else if(nPrimary == K_ESCAPE)
1060 if (bInputType == 1)
1062 disable_menu_alphacheck = 1;
1064 menu_enabled_time = time;
1065 localcmd("menu_showhudexit\n");
1067 else if(hudShiftState & S_CTRL)
1072 if(nPrimary == K_SPACE) // enable/disable highlighted panel or dock
1074 if (bInputType == 1)
1077 if (highlightedPanel_prev != -1)
1078 cvar_set(strcat("hud_panel_", panel_name), ftos(!(panel_enabled)));
1080 cvar_set(strcat("hud_dock"), (autocvar_hud_dock == "") ? "dock" : "");
1082 if(nPrimary == 'c') // copy highlighted panel size
1084 if (bInputType == 1)
1087 if (highlightedPanel_prev != -1)
1089 panel_size_copied = panel_size;
1090 highlightedPanel_copied = highlightedPanel_prev;
1093 else if(nPrimary == 'v') // past copied size on the highlighted panel
1095 if (bInputType == 1)
1098 if (highlightedPanel_copied != -1 && highlightedPanel_prev != -1)
1101 panel_pos_backup = panel_pos;
1102 panel_size_backup = panel_size;
1103 highlightedPanel_backup = highlightedPanel_prev;
1106 s = strcat(ftos(panel_size_copied_x/vid_conwidth), " ", ftos(panel_size_copied_y/vid_conheight));
1107 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
1110 else if(nPrimary == 'z') // undo last action
1112 if (bInputType == 1)
1114 //restore previous values
1115 if (highlightedPanel_backup != -1)
1117 HUD_Panel_GetName(highlightedPanel_backup)
1119 s = strcat(ftos(panel_pos_backup_x/vid_conwidth), " ", ftos(panel_pos_backup_y/vid_conheight));
1120 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
1121 s = strcat(ftos(panel_size_backup_x/vid_conwidth), " ", ftos(panel_size_backup_y/vid_conheight));
1122 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
1123 highlightedPanel_backup = -1;
1127 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1129 if (bInputType == 1)
1131 pressed_key_time = 0;
1134 else if (pressed_key_time == 0)
1135 pressed_key_time = time;
1137 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1139 else if(hit_con_bind)
1142 return true; // Suppress ALL other input
1145 float HUD_Panel_HighlightCheck()
1151 while(j <= HUD_PANEL_NUM)
1156 HUD_Panel_UpdatePosSizeForId(i)
1158 panelPos = panel_pos;
1159 panelSize = panel_size;
1160 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1163 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1167 // resize from topleft border
1168 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)
1172 // resize from topright border
1173 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)
1177 // resize from bottomleft border
1178 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)
1182 // resize from bottomright border
1183 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)
1191 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1192 void HUD_Panel_FirstInDrawQ(float id)
1195 var float place = -1;
1196 // find out where in the array our current id is, save into place
1197 for(i = 0; i < HUD_PANEL_NUM; ++i)
1199 if(panel_order[i] == id)
1205 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1207 place = HUD_PANEL_NUM - 1;
1209 // move all ids up by one step in the array until "place"
1210 for(i = place; i > 0; --i)
1212 panel_order[i] = panel_order[i-1];
1214 // now save the new top id
1215 panel_order[0] = id;
1217 // let's save them into the cvar by some strcat trickery
1219 for(i = 0; i < HUD_PANEL_NUM; ++i)
1221 s = strcat(s, ftos(panel_order[i]), " ");
1223 cvar_set("_hud_panelorder", s);
1224 if(hud_panelorder_prev)
1225 strunzone(hud_panelorder_prev);
1226 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1229 void HUD_Panel_Highlight()
1235 while(j <= HUD_PANEL_NUM)
1240 HUD_Panel_UpdatePosSizeForId(i)
1242 panelPos = panel_pos;
1243 panelSize = panel_size;
1244 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1247 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1249 highlightedPanel = i;
1250 HUD_Panel_FirstInDrawQ(i);
1251 highlightedAction = 1;
1252 panel_click_distance = mousepos - panelPos;
1255 // resize from topleft border
1256 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)
1258 highlightedPanel = i;
1259 HUD_Panel_FirstInDrawQ(i);
1260 highlightedAction = 2;
1262 panel_click_distance = mousepos - panelPos;
1263 panel_click_resizeorigin = panelPos + panelSize;
1266 // resize from topright border
1267 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)
1269 highlightedPanel = i;
1270 HUD_Panel_FirstInDrawQ(i);
1271 highlightedAction = 2;
1273 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1274 panel_click_distance_y = mousepos_y - panelPos_y;
1275 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1278 // resize from bottomleft border
1279 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)
1281 highlightedPanel = i;
1282 HUD_Panel_FirstInDrawQ(i);
1283 highlightedAction = 2;
1285 panel_click_distance_x = mousepos_x - panelPos_x;
1286 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1287 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1290 // resize from bottomright border
1291 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)
1293 highlightedPanel = i;
1294 HUD_Panel_FirstInDrawQ(i);
1295 highlightedAction = 2;
1297 panel_click_distance = panelSize - mousepos + panelPos;
1298 panel_click_resizeorigin = panelPos;
1303 highlightedPanel_prev = -1;
1308 float highlightcheck;
1310 void HUD_Panel_Mouse()
1312 // TODO: needs better check... is there any float that contains the current state of the menu? _menu_alpha isn't apparently updated the frame the menu gets enabled
1313 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1314 disable_menu_alphacheck = 0;
1315 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1319 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1320 print("Highlighted: ", ftos(highlightedPanel), "\n");
1321 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1324 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1325 highlightedPanel = -1;
1326 highlightedAction = 0;
1328 if(highlightedPanel != -1)
1329 highlightedPanel_prev = highlightedPanel;
1331 mousepos = mousepos + getmousepos() * cvar("menu_mouse_speed");
1333 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1334 mousepos_y = bound(0, mousepos_y, vid_conheight);
1338 vector prev_pos, prev_size;
1339 if(prevMouseClicked == 0)
1341 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1342 // and calls HUD_Panel_UpdatePosSizeForId() for the highlighted panel
1343 would_backup = TRUE;
1345 else if (would_backup)
1347 // this is not the actual backup! Saving pos and size values
1348 // only to check later if they are different from new values
1349 prev_pos = panel_pos;
1350 prev_size = panel_size;
1353 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1355 if(highlightedAction == 1)
1356 HUD_Panel_SetPos(mousepos - panel_click_distance);
1357 else if(highlightedAction == 2)
1360 if(resizeCorner == 1) {
1361 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1362 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1363 } else if(resizeCorner == 2) {
1364 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1365 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1366 } else if(resizeCorner == 3) {
1367 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1368 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1369 } else { // resizeCorner == 4
1370 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1371 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1373 HUD_Panel_SetPosSize(mySize);
1376 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
1377 if (prevMouseClicked)
1379 if (prev_pos != panel_pos || prev_size != panel_size)
1382 panel_pos_backup = prev_pos;
1383 panel_size_backup = prev_size;
1384 highlightedPanel_backup = highlightedPanel;
1385 would_backup = FALSE;
1388 // doubleclick check
1389 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1391 mouseClicked = 0; // to prevent spam, I guess.
1392 disable_menu_alphacheck = 2;
1394 menu_enabled_time = time;
1395 HUD_Panel_GetName(highlightedPanel)
1396 localcmd("menu_showhudoptions ", panel_name, "\n");
1399 if(prevMouseClicked == 0)
1401 prevMouseClickedTime = time;
1402 prevMouseClickedPos = mousepos;
1407 highlightcheck = HUD_Panel_HighlightCheck();
1409 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1412 cursorsize = '32 32 0';
1414 if(highlightcheck == 0)
1415 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1416 else if(highlightcheck == 1)
1417 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1418 else if(highlightcheck == 2)
1419 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1421 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1423 prevMouseClicked = mouseClicked;
1426 // Weapon icons (#0)
1428 float weaponspace[10];
1429 #define HUD_Weapons_Clear()\
1431 for(idx = 0; idx < 10; ++idx)\
1432 weaponspace[idx] = 0;
1434 entity weaponorder[WEP_MAXCOUNT];
1435 void weaponorder_swap(float i, float j, entity pass)
1439 weaponorder[i] = weaponorder[j];
1443 string weaponorder_cmp_str_save;
1444 string weaponorder_cmp_str;
1445 float weaponorder_cmp(float i, float j, entity pass)
1448 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1449 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1450 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)
1453 float GetAmmoStat(float i)
1457 case 0: return STAT_SHELLS;
1458 case 1: return STAT_NAILS;
1459 case 2: return STAT_ROCKETS;
1460 case 3: return STAT_CELLS;
1461 case 4: return STAT_FUEL;
1466 float GetAmmoTypeForWep(float i)
1470 case WEP_SHOTGUN: return 0;
1471 case WEP_UZI: return 1;
1472 case WEP_CAMPINGRIFLE: return 1;
1473 case WEP_GRENADE_LAUNCHER: return 2;
1474 case WEP_ELECTRO: return 3;
1475 case WEP_CRYLINK: return 3;
1476 case WEP_HLAC: return 3;
1477 case WEP_MINSTANEX: return 3;
1478 case WEP_NEX: return 3;
1479 case WEP_HAGAR: return 2;
1480 case WEP_ROCKET_LAUNCHER: return 2;
1481 case WEP_SEEKER: return 2;
1482 case WEP_FIREBALL: return 4;
1483 case WEP_HOOK: return 3;
1488 void HUD_Weapons(void)
1490 if(!autocvar_hud_panel_weapons && !autocvar__hud_configure)
1493 float timeout = cvar("hud_panel_weapons_timeout");
1494 float timeout_effect_length, timein_effect_length;
1495 if (cvar("hud_panel_weapons_timeout_effect") == 0)
1497 timeout_effect_length = 0;
1498 timein_effect_length = 0;
1502 timeout_effect_length = 0.75;
1503 timein_effect_length = 0.375;
1506 if (timeout && time >= weapontime + timeout + timeout_effect_length && !autocvar__hud_configure)
1508 weaponprevtime = time;
1512 active_panel = HUD_PANEL_WEAPONS;
1513 HUD_Panel_UpdateCvars(weapons);
1515 if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
1517 float f = (time - (weapontime + timeout)) / timeout_effect_length;
1518 if (cvar("hud_panel_weapons_timeout_effect"))
1520 panel_bg_alpha *= (1 - f);
1521 panel_fg_alpha *= (1 - f);
1523 if (cvar("hud_panel_weapons_timeout_effect") == 1)
1525 f *= f; // for a cooler movement
1527 center_x = panel_pos_x + panel_size_x/2;
1528 center_y = panel_pos_y + panel_size_y/2;
1529 float screen_ar = vid_conwidth/vid_conheight;
1530 if (center_x/center_y < screen_ar) //bottom left
1532 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
1533 panel_pos_y += f * (vid_conheight - panel_pos_y);
1535 panel_pos_x -= f * (panel_pos_x + panel_size_x);
1539 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
1540 panel_pos_x += f * (vid_conwidth - panel_pos_x);
1542 panel_pos_y -= f * (panel_pos_y + panel_size_y);
1545 weaponprevtime = time - (1 - f) * timein_effect_length;
1547 else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure)
1549 float f = (time - weaponprevtime) / timein_effect_length;
1550 if (cvar("hud_panel_weapons_timeout_effect"))
1552 panel_bg_alpha *= (f);
1553 panel_fg_alpha *= (f);
1555 if (cvar("hud_panel_weapons_timeout_effect") == 1)
1557 f *= f; // for a cooler movement
1560 center_x = panel_pos_x + panel_size_x/2;
1561 center_y = panel_pos_y + panel_size_y/2;
1562 float screen_ar = vid_conwidth/vid_conheight;
1563 if (center_x/center_y < screen_ar) //bottom left
1565 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
1566 panel_pos_y += f * (vid_conheight - panel_pos_y);
1568 panel_pos_x -= f * (panel_pos_x + panel_size_x);
1572 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
1573 panel_pos_x += f * (vid_conwidth - panel_pos_x);
1575 panel_pos_y -= f * (panel_pos_y + panel_size_y);
1580 float i, weapid, fade, weapon_stats, weapon_number, weapon_cnt;
1582 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1584 self = get_weaponinfo(i);
1585 if(self.impulse >= 0)
1589 // TODO make this configurable
1590 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1592 if(weaponorder_cmp_str != weaponorder_cmp_str_save)
1594 if(weaponorder_cmp_str_save)
1595 strunzone(weaponorder_cmp_str_save);
1596 weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
1598 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1600 self = get_weaponinfo(i);
1601 if(self.impulse >= 0)
1603 weaponorder[weapon_cnt] = self;
1607 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1610 HUD_Panel_DrawBg(1);
1611 if(panel_bg_padding)
1613 panel_pos += '1 1 0' * panel_bg_padding;
1614 panel_size -= '2 2 0' * panel_bg_padding;
1618 weapon_stats = getstati(STAT_DAMAGE_HITS);
1619 weapon_number = weapon_stats & 63;
1620 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1622 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1623 weapon_number = weapon_stats & 63;
1624 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1626 if(cvar_or("hud_panel_weapons_fade", 1))
1628 fade = 3.2 - 2 * (time - weapontime);
1629 fade = bound(0.7, fade, 1);
1634 HUD_Weapons_Clear();
1636 float rows, columns;
1637 rows = panel_size_y/panel_size_x;
1638 rows = bound(1, floor((sqrt(4 * autocvar_hud_panel_weapons_aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1640 columns = ceil(WEP_COUNT/rows);
1643 float a, type, fullammo;
1645 when = autocvar_hud_panel_weapons_complainbubble_time;
1647 fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
1653 for(i = 0; i < weapon_cnt; ++i)
1655 wpnpos = panel_pos + eX * column * panel_size_x*(1/columns) + eY * row * panel_size_y*(1/rows);
1656 wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
1658 self = weaponorder[i];
1659 weapid = self.impulse;
1661 // draw background behind currently selected weapon
1662 if(self.weapon == activeweapon)
1663 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1665 // draw the weapon accuracy
1668 float weapon_hit, weapon_damage;
1669 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1672 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1673 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1676 // find the max level lower than weapon_stats
1679 while ( j && weapon_stats < acc_lev[j] )
1682 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
1684 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
1685 color = acc_color(j);
1686 color = color + factor * (acc_color(j+1) - color);
1689 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1692 // draw the weapon icon
1693 if((self.impulse >= 0) && (getstati(STAT_WEAPONS) & self.weapons))
1695 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1697 if(autocvar_hud_panel_weapons_label == 1) // weapon number
1698 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * panel_size_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1699 else if(autocvar_hud_panel_weapons_label == 2) // bind
1700 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);
1702 // draw ammo status bar
1703 if(autocvar_hud_panel_weapons_ammo && weapid != WEP_TUBA && weapid != WEP_LASER && weapid != WEP_PORTO)
1706 type = GetAmmoTypeForWep(weapid);
1708 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
1713 case 0: fullammo = autocvar_hud_panel_weapons_ammo_full_shells; break;
1714 case 1: fullammo = autocvar_hud_panel_weapons_ammo_full_nails; break;
1715 case 2: fullammo = autocvar_hud_panel_weapons_ammo_full_rockets; break;
1716 case 3: fullammo = autocvar_hud_panel_weapons_ammo_full_cells; break;
1717 case 4: fullammo = autocvar_hud_panel_weapons_ammo_full_fuel; break;
1718 default: fullammo = 60;
1723 if(wpnsize_x/wpnsize_y > autocvar_hud_panel_weapons_aspect)
1725 barsize_x = autocvar_hud_panel_weapons_aspect * wpnsize_y;
1726 barsize_y = wpnsize_y;
1728 barpos_x = wpnpos_x + (wpnsize_x - barsize_x) / 2;
1729 barpos_y = wpnpos_y;
1733 barsize_y = 1/autocvar_hud_panel_weapons_aspect * wpnsize_x;
1734 barsize_x = wpnsize_x;
1736 barpos_y = wpnpos_y + (wpnsize_y - barsize_y) / 2;
1737 barpos_x = wpnpos_x;
1743 barsize_x * bound(0, a/fullammo, 1),
1745 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, autocvar_hud_panel_weapons_ammo_color, panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha, DRAWFLAG_NORMAL);
1746 drawresetcliparea();
1751 // draw a "ghost weapon icon" if you don't have the weapon
1754 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
1757 // draw the complain message
1758 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
1762 if(complain_weapon_time + when > time)
1765 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1769 if(complain_weapon_time + when > time)
1776 if(complain_weapon_type == 0) {
1778 color = autocvar_hud_panel_weapons_complainbubble_color_outofammo;
1780 else if(complain_weapon_type == 1) {
1782 color = autocvar_hud_panel_weapons_complainbubble_color_donthave;
1786 color = autocvar_hud_panel_weapons_complainbubble_color_unavailable;
1788 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);
1789 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);
1805 float GetAmmoItemCode(float i)
1809 case 0: return IT_SHELLS;
1810 case 1: return IT_NAILS;
1811 case 2: return IT_ROCKETS;
1812 case 3: return IT_CELLS;
1813 case 4: return IT_FUEL;
1818 string GetAmmoPicture(float i)
1822 case 0: return "ammo_shells";
1823 case 1: return "ammo_bullets";
1824 case 2: return "ammo_rockets";
1825 case 3: return "ammo_cells";
1826 case 4: return "ammo_fuel";
1831 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1834 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1835 if(autocvar__hud_configure)
1845 if(currently_selected)
1850 vector newSize, newPos;
1851 if(mySize_x/mySize_y > 3)
1853 newSize_x = 3 * mySize_y;
1854 newSize_y = mySize_y;
1856 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1861 newSize_y = 1/3 * mySize_x;
1862 newSize_x = mySize_x;
1864 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1868 vector picpos, numpos;
1869 if(autocvar_hud_panel_ammo_iconalign)
1872 picpos = newPos + eX * 2 * newSize_y;
1876 numpos = newPos + eX * newSize_y;
1880 if (currently_selected)
1881 drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1883 drawfont = hud_bigfont;
1885 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1886 else // "ghost" ammo count
1887 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1888 drawfont = hud_font;
1890 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1891 else // "ghost" ammo icon
1892 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1897 if(!autocvar_hud_panel_ammo && !autocvar__hud_configure)
1900 active_panel = HUD_PANEL_AMMO;
1901 HUD_Panel_UpdateCvars(ammo);
1902 float i, currently_selected;
1906 mySize = panel_size;
1908 HUD_Panel_DrawBg(1);
1909 if(panel_bg_padding)
1911 pos += '1 1 0' * panel_bg_padding;
1912 mySize -= '2 2 0' * panel_bg_padding;
1915 float rows, columns;
1916 rows = mySize_y/mySize_x;
1917 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1918 // ^^^ ammo item aspect goes here
1920 columns = ceil(AMMO_COUNT/rows);
1924 for (i = 0; i < AMMO_COUNT; ++i) {
1925 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1926 if(autocvar_hud_panel_ammo_onlycurrent) {
1927 if(autocvar__hud_configure)
1929 if (currently_selected || autocvar__hud_configure)
1931 DrawAmmoItem(pos, mySize, i, currently_selected);
1935 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);
1940 column = column + 1;
1946 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float alpha)
1948 vector newSize, newPos;
1949 if(mySize_x/mySize_y > 3)
1951 newSize_x = 3 * mySize_y;
1952 newSize_y = mySize_y;
1954 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1959 newSize_y = 1/3 * mySize_x;
1960 newSize_x = mySize_x;
1962 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1966 vector picpos, numpos;
1969 if(iconalign == 1 || iconalign == 3) // right align
1972 picpos = newPos + eX * 2 * newSize_y;
1976 numpos = newPos + eX * newSize_y;
1982 if(iconalign == 0 || iconalign == 3) // left align
1984 numpos = newPos + eX * newSize_y;
1990 picpos = newPos + eX * 2 * newSize_y;
1994 drawfont = hud_bigfont;
1995 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1996 drawfont = hud_font;
1997 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
2000 void DrawNumIcon_expanding(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float fadelerp)
2003 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
2005 DrawNumIcon(iconalign, myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, left, color, (1 - fadelerp));
2010 void HUD_Powerups(void) {
2011 if(!autocvar_hud_panel_powerups && !autocvar__hud_configure)
2014 active_panel = HUD_PANEL_POWERUPS;
2015 HUD_Panel_UpdateCvars(powerups);
2017 stat_items = getstati(STAT_ITEMS);
2019 if(!autocvar__hud_configure)
2021 if not(stat_items & IT_STRENGTH)
2022 if not(stat_items & IT_INVINCIBLE)
2025 if (getstati(STAT_HEALTH) <= 0)
2031 mySize = panel_size;
2033 float strength_time, shield_time;
2034 if(autocvar__hud_configure)
2041 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
2042 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
2045 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
2046 if(panel_bg_padding)
2048 pos += '1 1 0' * panel_bg_padding;
2049 mySize -= '2 2 0' * panel_bg_padding;
2052 vector barpos, barsize;
2056 string leftname, rightname;
2057 float leftcnt, rightcnt;
2058 float leftexact, rightexact;
2059 if (autocvar_hud_panel_powerups_flip) {
2060 leftname = "strength";
2061 leftcnt = ceil(strength_time);
2062 leftexact = strength_time;
2064 rightname = "shield";
2065 rightcnt = ceil(shield_time);
2066 rightexact = shield_time;
2068 leftname = "shield";
2069 leftcnt = ceil(shield_time);
2070 leftexact = shield_time;
2072 rightname = "strength";
2073 rightcnt = ceil(strength_time);
2074 rightexact = strength_time;
2077 drawfont = hud_bigfont;
2078 if (mySize_x/mySize_y > 4)
2082 if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // right align
2083 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
2084 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
2085 } else { // left align
2087 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
2090 if(autocvar_hud_panel_powerups_progressbar)
2092 HUD_Panel_GetProgressBarColor(leftname)
2093 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);
2096 DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
2098 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));
2103 if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // left align
2104 barpos = pos + eX * 0.5 * mySize_x;
2105 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
2106 } else { // right align
2107 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
2108 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
2111 if(autocvar_hud_panel_powerups_progressbar)
2113 HUD_Panel_GetProgressBarColor(rightname)
2114 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);
2117 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);
2119 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));
2122 else if (mySize_x/mySize_y > 1.5)
2126 if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // right align
2127 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
2128 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
2129 } else { // left align
2131 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
2134 if(autocvar_hud_panel_powerups_progressbar)
2136 HUD_Panel_GetProgressBarColor(leftname)
2137 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);
2140 DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
2142 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));
2147 if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // left align
2148 barpos = pos + eY * 0.5 * mySize_y;
2149 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
2150 } else { // right align
2151 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
2152 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
2155 if(autocvar_hud_panel_powerups_progressbar)
2157 HUD_Panel_GetProgressBarColor(rightname)
2158 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);
2161 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);
2163 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));
2170 if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // down align
2171 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
2172 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
2173 } else { // up align
2175 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
2178 if(autocvar_hud_panel_powerups_iconalign == 1 || autocvar_hud_panel_powerups_iconalign == 3) { // down align
2179 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2180 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2181 } else { // up align
2182 picpos = pos + eX * 0.05 * mySize_x;
2183 numpos = pos + eY * 0.4 * mySize_x;
2186 if(autocvar_hud_panel_powerups_progressbar)
2188 HUD_Panel_GetProgressBarColor(leftname)
2189 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);
2192 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));
2194 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2195 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2200 if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // up align
2201 barpos = pos + eX * 0.5 * mySize_x;
2202 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2203 } else { // down align
2204 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
2205 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2208 if(autocvar_hud_panel_powerups_iconalign == 0 || autocvar_hud_panel_powerups_iconalign == 3) { // up align
2209 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2210 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2211 } else { // down align
2212 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2213 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2216 if(autocvar_hud_panel_powerups_progressbar)
2218 HUD_Panel_GetProgressBarColor(rightname)
2219 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);
2222 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));
2224 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2225 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2228 drawfont = hud_font;
2231 // Health/armor (#3)
2233 void HUD_HealthArmor(void)
2235 if(!autocvar_hud_panel_healtharmor && !autocvar__hud_configure)
2238 active_panel = HUD_PANEL_HEALTHARMOR;
2239 HUD_Panel_UpdateCvars(healtharmor);
2242 mySize = panel_size;
2244 HUD_Panel_DrawBg(1);
2245 if(panel_bg_padding)
2247 pos += '1 1 0' * panel_bg_padding;
2248 mySize -= '2 2 0' * panel_bg_padding;
2251 float armor, health;
2252 armor = getstati(STAT_ARMOR);
2253 health = getstati(STAT_HEALTH);
2256 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
2258 if(autocvar__hud_configure)
2268 vector barpos, barsize;
2272 drawfont = hud_bigfont;
2273 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
2276 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2281 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
2282 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2283 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2284 } else { // left align
2286 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2290 if(v_z) // NOT fully armored
2292 biggercount = "health";
2293 if(autocvar_hud_panel_healtharmor_progressbar)
2295 HUD_Panel_GetProgressBarColor("health")
2296 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2299 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);
2303 biggercount = "armor";
2304 if(autocvar_hud_panel_healtharmor_progressbar)
2306 HUD_Panel_GetProgressBarColor("armor")
2307 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2310 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);
2312 DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200), 1);
2317 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2318 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2319 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2322 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2324 HUD_Panel_GetProgressBarColor("fuel")
2325 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2330 string leftname, rightname;
2331 float leftcnt, rightcnt;
2332 float leftactive, rightactive;
2333 float leftalpha, rightalpha;
2334 if (autocvar_hud_panel_healtharmor_flip) { // old style layout with armor left/top of health
2339 leftalpha = min((armor+10)/55, 1);
2341 rightname = "health";
2346 leftname = "health";
2351 rightname = "armor";
2355 rightalpha = min((armor+10)/55, 1);
2358 if (mySize_x/mySize_y > 4)
2362 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
2363 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2364 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2365 } else { // left align
2367 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2370 if(autocvar_hud_panel_healtharmor_progressbar)
2372 HUD_Panel_GetProgressBarColor(leftname)
2373 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2375 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);
2380 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2381 barpos = pos + eX * 0.5 * mySize_x;
2382 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2383 } else { // right align
2384 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2385 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2388 if(autocvar_hud_panel_healtharmor_progressbar)
2390 HUD_Panel_GetProgressBarColor(rightname)
2391 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2393 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);
2398 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2399 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2400 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2403 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2405 HUD_Panel_GetProgressBarColor("fuel")
2406 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2409 else if (mySize_x/mySize_y > 1.5)
2413 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
2414 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2415 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2416 } else { // left align
2418 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2421 if(autocvar_hud_panel_healtharmor_progressbar)
2423 HUD_Panel_GetProgressBarColor(leftname)
2424 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2426 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);
2431 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2432 barpos = pos + eY * 0.5 * mySize_y;
2433 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2434 } else { // right align
2435 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2436 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2439 if(autocvar_hud_panel_healtharmor_progressbar)
2441 HUD_Panel_GetProgressBarColor(rightname)
2442 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2444 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);
2449 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2450 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2451 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2454 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2456 HUD_Panel_GetProgressBarColor("fuel")
2457 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2464 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // down align
2465 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2466 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2467 } else { // up align
2469 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2472 if(autocvar_hud_panel_healtharmor_iconalign == 1 || autocvar_hud_panel_healtharmor_iconalign == 3) { // down align
2473 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2474 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2475 } else { // up align
2476 picpos = pos + eX * 0.05 * mySize_x;
2477 numpos = pos + eY * 0.4 * mySize_x;
2480 if(autocvar_hud_panel_healtharmor_progressbar)
2482 HUD_Panel_GetProgressBarColor(leftname)
2483 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2485 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2486 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);
2491 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // up align
2492 barpos = pos + eX * 0.5 * mySize_x;
2493 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2494 } else { // down align
2495 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2496 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2499 if(autocvar_hud_panel_healtharmor_iconalign == 0 || autocvar_hud_panel_healtharmor_iconalign == 3) { // up align
2500 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2501 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2502 } else { // down align
2503 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2504 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2507 if(autocvar_hud_panel_healtharmor_progressbar)
2509 HUD_Panel_GetProgressBarColor(rightname)
2510 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2512 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2513 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);
2518 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2520 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2522 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2523 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2525 HUD_Panel_GetProgressBarColor("fuel")
2526 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2530 drawfont = hud_font;
2533 // Notification area (#4)
2536 string Weapon_SuicideMessage(float deathtype)
2538 w_deathtype = deathtype;
2539 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2540 return w_deathtypestring;
2543 string Weapon_KillMessage(float deathtype)
2545 w_deathtype = deathtype;
2546 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2547 return w_deathtypestring;
2550 float killnotify_times[10];
2551 float killnotify_deathtype[10];
2552 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2553 string killnotify_attackers[10];
2554 string killnotify_victims[10];
2555 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2558 for (i = 9; i > 0; --i) {
2559 killnotify_times[i] = killnotify_times[i-1];
2560 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2561 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2562 if(killnotify_attackers[i])
2563 strunzone(killnotify_attackers[i]);
2564 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2565 if(killnotify_victims[i])
2566 strunzone(killnotify_victims[i]);
2567 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2569 killnotify_times[0] = time;
2570 killnotify_deathtype[0] = wpn;
2571 killnotify_actiontype[0] = actiontype;
2572 if(killnotify_attackers[0])
2573 strunzone(killnotify_attackers[0]);
2574 killnotify_attackers[0] = strzone(attacker);
2575 if(killnotify_victims[0])
2576 strunzone(killnotify_victims[0]);
2577 killnotify_victims[0] = strzone(victim);
2580 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
2583 float alsoprint, gentle;
2584 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2585 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2587 if(msg == MSG_SUICIDE) {
2588 w = DEATH_WEAPONOF(type);
2590 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2592 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
2593 } else if (type == DEATH_KILL) {
2594 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2596 print ("^1",s1, "^1 couldn't take it anymore\n");
2597 } else if (type == DEATH_ROT) {
2598 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2600 print ("^1",s1, "^1 died\n");
2601 } else if (type == DEATH_NOAMMO) {
2602 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2604 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2605 } else if (type == DEATH_CAMP) {
2606 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2608 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2609 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2610 HUD_KillNotify_Push(s1, "", 0, type);
2612 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2613 } else if (type == DEATH_CHEAT) {
2614 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2616 print ("^1",s1, "^1 unfairly eliminated themself\n");
2617 } else if (type == DEATH_FIRE) {
2618 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2620 print ("^1",s1, "^1 burned to death\n");
2621 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2622 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2624 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2627 if (stof(s2) > 2) // killcount > 2
2628 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2629 } else if(msg == MSG_KILL) {
2630 w = DEATH_WEAPONOF(type);
2632 HUD_KillNotify_Push(s1, s2, 1, type);
2634 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
2636 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2637 HUD_KillNotify_Push(s1, s2, 1, type);
2641 print ("^1", s1, "^1 took action against a team mate\n");
2643 print ("^1", s1, "^1 mows down a team mate\n");
2646 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2648 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2650 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2652 else if (stof(s2) > 2) {
2654 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2656 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2659 else if(type == KILL_FIRST_BLOOD)
2660 print("^1",s1, "^1 drew first blood", "\n");
2661 else if (type == DEATH_TELEFRAG) {
2662 HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
2664 print ("^1",s2, "^1 tried to occupy ", s1, "^1's teleport destination space\n");
2666 print ("^1",s2, "^1 was telefragged by ", s1, "\n");
2668 else if (type == DEATH_DROWN) {
2669 HUD_KillNotify_Push(s1, s2, 1, DEATH_DROWN);
2671 print ("^1",s2, "^1 was drowned by ", s1, "\n");
2673 else if (type == DEATH_SLIME) {
2674 HUD_KillNotify_Push(s1, s2, 1, DEATH_SLIME);
2676 print ("^1",s2, "^1 was slimed by ", s1, "\n");
2678 else if (type == DEATH_LAVA) {
2679 HUD_KillNotify_Push(s1, s2, 1, DEATH_LAVA);
2681 print ("^1",s2, "^1 was cooked by ", s1, "\n");
2683 else if (type == DEATH_FALL) {
2684 HUD_KillNotify_Push(s1, s2, 1, DEATH_FALL);
2686 print ("^1",s2, "^1 was grounded by ", s1, "\n");
2688 else if (type == DEATH_SHOOTING_STAR) {
2689 HUD_KillNotify_Push(s1, s2, 1, DEATH_SHOOTING_STAR);
2691 print ("^1",s2, "^1 was shot into space by ", s1, "\n");
2693 else if (type == DEATH_SWAMP) {
2694 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2696 print ("^1",s2, "^1 was conserved by ", s1, "\n");
2698 else if (type == DEATH_HURTTRIGGER)
2700 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
2702 print("^1",s2, "^1 was thrown into a world of hurt by ", s1, "\n");
2703 } else if(type == DEATH_SBCRUSH) {
2704 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2706 print ("^1",s2, "^1 was crushed by ^1", s1, "\n");
2707 } else if(type == DEATH_SBMINIGUN) {
2708 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2710 print ("^1",s2, "^1 got shredded by ^1", s1, "\n");
2711 } else if(type == DEATH_SBROCKET) {
2712 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2714 print ("^1",s2, "^1 was blased to bits by ^1", s1, "\n");
2715 } else if(type == DEATH_SBBLOWUP) {
2716 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2718 print ("^1",s2, "^1 got caught in the destruction of ^1", s1, "'s vehicle\n");
2719 } else if(type == DEATH_WAKIGUN) {
2720 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2722 print ("^1",s2, "^1 was bolted down by ^1", s1, "\n");
2723 } else if(type == DEATH_WAKIROCKET) {
2724 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2726 print ("^1",s2, "^1 could find no shelter from ^1", s1, "'s rockets\n");
2727 } else if(type == DEATH_WAKIBLOWUP) {
2728 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2730 print ("^1",s2, "^1 dies when ^1", s1, "'s wakizashi dies.\n");
2731 } else if(type == DEATH_TURRET) {
2732 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2734 print ("^1",s2, "^1 was pushed into the line of fire by ^1", s1, "\n");
2735 } else if(type == DEATH_TOUCHEXPLODE) {
2736 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2738 print ("^1",s2, "^1 was pushed into an accident by ^1", s1, "\n");
2739 } else if(type == DEATH_CHEAT) {
2740 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2742 print ("^1",s2, "^1 was unfairly eliminated by ^1", s1, "\n");
2743 } else if (type == DEATH_FIRE) {
2744 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2746 print ("^1",s2, "^1 was burnt to death by ^1", s1, "\n");
2747 } else if (type == DEATH_CUSTOM) {
2748 HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM);
2750 print ("^1",s2, "^1 ", s1, "\n");
2752 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2754 print ("^1",s2, "^1 was fragged by ", s1, "\n");
2756 } else if(msg == MSG_SPREE) {
2757 if(type == KILL_END_SPREE) {
2759 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2761 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2762 } else if(type == KILL_SPREE) {
2764 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2766 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2767 } else if(type == KILL_SPREE_3) {
2769 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2771 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2772 } else if(type == KILL_SPREE_5) {
2774 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2776 print (s1,"^7 unleashes ^1RAGE\n");
2777 } else if(type == KILL_SPREE_10) {
2779 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2781 print (s1,"^7 starts the ^1MASSACRE!\n");
2782 } else if(type == KILL_SPREE_15) {
2784 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2786 print (s1,"^7 executes ^1MAYHEM!\n");
2787 } else if(type == KILL_SPREE_20) {
2789 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2791 print (s1,"^7 is a ^1BERSERKER!\n");
2792 } else if(type == KILL_SPREE_25) {
2794 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2796 print (s1,"^7 inflicts ^1CARNAGE!\n");
2797 } else if(type == KILL_SPREE_30) {
2799 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2801 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2803 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2804 if (type == DEATH_DROWN) {
2805 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2809 print ("^1",s1, "^1 was in the water for too long\n");
2811 print ("^1",s1, "^1 drowned\n");
2813 } else if (type == DEATH_SLIME) {
2814 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2816 print ("^1",s1, "^1 was slimed\n");
2817 } else if (type == DEATH_LAVA) {
2818 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2822 print ("^1",s1, "^1 found a hot place\n");
2824 print ("^1",s1, "^1 turned into hot slag\n");
2826 } else if (type == DEATH_FALL) {
2827 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2831 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2833 print ("^1",s1, "^1 hit the ground with a crunch\n");
2835 } else if (type == DEATH_SHOOTING_STAR) {
2836 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2838 print ("^1",s1, "^1 became a shooting star\n");
2839 } else if (type == DEATH_SWAMP) {
2840 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2844 print ("^1",s1, "^1 discovered a swamp\n");
2846 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2848 } else if(type == DEATH_TURRET) {
2849 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2851 print ("^1",s1, "^1 was mowed down by a turret \n");
2852 } else if (type == DEATH_CUSTOM) {
2853 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2855 print ("^1",s1, "^1 ", s2, "\n");
2856 } else if (type == DEATH_HURTTRIGGER) {
2857 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2859 print ("^1",s1, "^1 was in the wrong place\n");
2860 } else if(type == DEATH_TOUCHEXPLODE) {
2861 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2863 print ("^1",s1, "^1 died in an accident\n");
2864 } else if(type == DEATH_CHEAT) {
2865 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2867 print ("^1",s1, "^1 was unfairly eliminated\n");
2868 } else if(type == DEATH_FIRE) {
2869 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2873 print ("^1",s1, "^1 felt a little hot\n");
2875 print ("^1",s1, "^1 burnt to death\n");
2878 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2882 print ("^1",s1, "^1 needs a restart\n");
2884 print ("^1",s1, "^1 died\n");
2887 } else if(msg == MSG_KILL_ACTION_SPREE) {
2889 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2891 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2892 } else if(msg == MSG_INFO) {
2893 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2894 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2895 print(s1, "^7 got the ", s2, "\n");
2896 } else if(type == INFO_LOSTFLAG) {
2897 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2898 print(s1, "^7 lost the ", s2, "\n");
2899 } else if(type == INFO_PICKUPFLAG) {
2900 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2901 print(s1, "^7 picked up the ", s2, "\n");
2902 } else if(type == INFO_RETURNFLAG) {
2903 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2904 print(s1, "^7 returned the ", s2, "\n");
2905 } else if(type == INFO_CAPTUREFLAG) {
2906 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
2907 print(s1, "^7 captured the ", s2, s3, "\n");
2912 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2914 void HUD_Centerprint(string s1, string s2, float type, float msg)
2917 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2918 if(msg == MSG_SUICIDE) {
2919 if (type == DEATH_TEAMCHANGE) {
2920 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2921 } else if (type == DEATH_AUTOTEAMCHANGE) {
2922 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2923 } else if (type == DEATH_CAMP) {
2925 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2927 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2928 } else if (type == DEATH_NOAMMO) {
2930 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2932 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2933 } else if (type == DEATH_ROT) {
2935 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2937 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2938 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2940 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2942 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2943 } else if (type == DEATH_QUIET) {
2945 } else { // generic message
2947 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2949 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2951 } else if(msg == MSG_KILL) {
2952 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2954 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2956 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2958 } else if (type == KILL_FIRST_BLOOD) {
2960 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2962 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2964 } else if (type == KILL_FIRST_VICTIM) {
2966 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2968 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2970 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2972 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2974 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2976 } else if (type == KILL_TYPEFRAGGED) {
2978 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2980 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2982 } else if (type == KILL_FRAG) {
2984 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2986 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2988 } else { // generic message
2990 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2992 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2995 } else if(msg == MSG_KILL_ACTION) {
2996 // TODO: invent more centerprints here?
2997 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
3001 void HUD_Notify (void)
3003 if(!autocvar_hud_panel_notify && !autocvar__hud_configure)
3006 active_panel = HUD_PANEL_NOTIFY;
3007 HUD_Panel_UpdateCvars(notify);
3010 mySize = panel_size;
3012 HUD_Panel_DrawBg(1);
3013 if(panel_bg_padding)
3015 pos += '1 1 0' * panel_bg_padding;
3016 mySize -= '2 2 0' * panel_bg_padding;
3019 float entries, height;
3020 entries = bound(1, floor(10 * mySize_y/mySize_x), 10);
3021 height = mySize_y/entries;
3024 fontsize = '0.5 0.5 0' * height;
3028 when = autocvar_hud_panel_notify_time;
3030 fadetime = autocvar_hud_panel_notify_fadetime;
3034 vector pos_attacker, pos_victim;
3036 float width_attacker;
3037 string attacker, victim;
3040 for(j = 0; j < entries; ++j)
3043 if(autocvar_hud_panel_notify_flip)
3045 else // rather nasty hack for ordering items from the bottom up
3046 i = entries - j - 1;
3050 if(killnotify_times[j] + when > time)
3053 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
3057 if(killnotify_times[j] + when > time)
3064 w = DEATH_WEAPONOF(killnotify_deathtype[j]);
3066 // TODO: maybe print in team colors?
3069 if(killnotify_actiontype[j] == 0 && !autocvar__hud_configure)
3071 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3072 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
3073 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
3075 if(killnotify_deathtype[j] == DEATH_GENERIC)
3079 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
3081 s = "notify_outofammo";
3083 else if(killnotify_deathtype[j] == DEATH_KILL)
3085 s = "notify_selfkill";
3087 else if(killnotify_deathtype[j] == DEATH_CAMP)
3089 s = "notify_camping";
3091 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
3093 s = "notify_teamkill_red";
3095 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
3097 s = "notify_teamkill_blue";
3099 else if(killnotify_deathtype[j] == DEATH_DROWN)
3103 else if(killnotify_deathtype[j] == DEATH_SLIME)
3107 else if(killnotify_deathtype[j] == DEATH_LAVA)
3111 else if(killnotify_deathtype[j] == DEATH_FALL)
3115 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
3117 s = "notify_shootingstar";
3119 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
3123 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
3125 if(killnotify_victims[j] == "^1RED^7 flag")
3127 s = "notify_red_taken";
3131 s = "notify_blue_taken";
3134 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
3136 if(killnotify_victims[j] == "^1RED^7 flag")
3138 s = "notify_red_returned";
3142 s = "notify_blue_returned";
3145 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
3147 if(killnotify_victims[j] == "^1RED^7 flag")
3149 s = "notify_red_lost";
3153 s = "notify_blue_lost";
3156 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
3158 if(killnotify_victims[j] == "^1RED^7 flag")
3160 s = "notify_red_captured";
3164 s = "notify_blue_captured";
3169 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3170 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3173 // X [did action to] Y
3176 if(autocvar__hud_configure)
3178 attacker = textShortenToWidth("Player1", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3179 victim = textShortenToWidth("Player2", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3180 a = bound(0, (when - j) / 4, 1);
3184 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3185 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3187 width_attacker = stringwidth(attacker, TRUE, fontsize);
3188 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
3189 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
3190 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
3192 if(autocvar__hud_configure) // example actions for config mode
3194 s = "weaponelectro";
3196 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
3198 s = "notify_melee_laser";
3200 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_SHOTGUN)
3202 s = "notify_melee_shotgun";
3204 else if(WEP_VALID(w))
3206 self = get_weaponinfo(w);
3207 s = strcat("weapon", self.netname);
3209 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
3211 s = "notify_teamkill_red";
3213 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
3215 s = "notify_teamkill_red";
3217 else if(killnotify_deathtype[j] == DEATH_TELEFRAG)
3219 s = "notify_telefrag";
3221 else if(killnotify_deathtype[j] == DEATH_DROWN)
3225 else if(killnotify_deathtype[j] == DEATH_SLIME)
3229 else if(killnotify_deathtype[j] == DEATH_LAVA)
3233 else if(killnotify_deathtype[j] == DEATH_FALL)
3237 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
3239 s = "notify_shootingstar";
3241 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
3247 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3248 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3249 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3258 string seconds_tostring(float sec)
3261 minutes = floor(sec / 60);
3263 sec -= minutes * 60;
3266 s = ftos(100 + sec);
3268 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3271 void HUD_Timer(void)
3273 if(!autocvar_hud_panel_timer && !autocvar__hud_configure)
3276 active_panel = HUD_PANEL_TIMER;
3277 HUD_Panel_UpdateCvars(timer);
3280 mySize = panel_size;
3282 HUD_Panel_DrawBg(1);
3283 if(panel_bg_padding)
3285 pos += '1 1 0' * panel_bg_padding;
3286 mySize -= '2 2 0' * panel_bg_padding;
3290 float timelimit, elapsedTime, timeleft, minutesLeft;
3292 timelimit = getstatf(STAT_TIMELIMIT);
3294 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3295 timeleft = ceil(timeleft);
3297 minutesLeft = floor(timeleft / 60);
3300 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3301 timer_color = '1 1 1'; //white
3302 else if(minutesLeft >= 1)
3303 timer_color = '1 1 0'; //yellow
3305 timer_color = '1 0 0'; //red
3307 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
3308 if (time < getstatf(STAT_GAMESTARTTIME)) {
3309 //while restart is still active, show 00:00
3310 timer = seconds_tostring(0);
3312 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3313 timer = seconds_tostring(elapsedTime);
3316 timer = seconds_tostring(timeleft);
3319 drawfont = hud_bigfont;
3320 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3321 drawfont = hud_font;
3326 void HUD_Radar(void)
3328 if ((autocvar_hud_panel_radar == 0 || (autocvar_hud_panel_radar != 2 && !teamplay)) && !autocvar__hud_configure)
3331 active_panel = HUD_PANEL_RADAR;
3332 HUD_Panel_UpdateCvars(radar);
3335 mySize = panel_size;
3337 HUD_Panel_DrawBg(1);
3338 if(panel_bg_padding)
3340 pos += '1 1 0' * panel_bg_padding;
3341 mySize -= '2 2 0' * panel_bg_padding;
3344 local float color1, color2; // color already declared as a global in hud.qc
3347 float scale2d, normalsize, bigsize;
3350 teamradar_origin2d = pos + 0.5 * mySize;
3351 teamradar_size2d = mySize;
3353 if(minimapname == "")
3356 teamradar_loadcvars();
3358 switch(hud_panel_radar_zoommode)
3362 f = current_zoomfraction;
3365 f = 1 - current_zoomfraction;
3375 switch(hud_panel_radar_rotation)
3378 teamradar_angle = view_angles_y - 90;
3381 teamradar_angle = 90 * hud_panel_radar_rotation;
3385 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3386 teamradar_size2d = mySize;
3388 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3390 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3391 if(hud_panel_radar_rotation == 0)
3393 // max-min distance must fit the radar in any rotation
3394 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3398 vector c0, c1, c2, c3, span;
3399 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3400 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3401 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3402 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3404 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3405 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3407 // max-min distance must fit the radar in x=x, y=y
3409 teamradar_size2d_x * scale2d / (1.05 * span_x),
3410 teamradar_size2d_y * scale2d / (1.05 * span_y)
3414 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
3415 if(bigsize > normalsize)
3416 normalsize = bigsize;
3420 + (1 - f) * normalsize;
3421 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3422 f * (mi_min + mi_max) * 0.5
3423 + (1 - f) * view_origin);
3425 color1 = GetPlayerColor(player_localentnum-1);
3426 rgb = GetTeamRGB(color1);
3435 draw_teamradar_background(hud_panel_radar_foreground_alpha);
3437 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3438 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3439 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3440 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3441 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3443 color2 = GetPlayerColor(tm.sv_entnum);
3444 //if(color == COLOR_SPECTATOR || color == color2)
3445 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3447 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3449 drawresetcliparea();
3454 void HUD_Score(void)
3456 if(!autocvar_hud_panel_score && !autocvar__hud_configure)
3459 active_panel = HUD_PANEL_SCORE;
3460 HUD_Panel_UpdateCvars(score);
3463 mySize = panel_size;
3465 HUD_Panel_DrawBg(1);
3466 if(panel_bg_padding)
3468 pos += '1 1 0' * panel_bg_padding;
3469 mySize -= '2 2 0' * panel_bg_padding;
3472 float score, distribution, leader;
3473 vector distribution_color;
3475 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3477 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3478 string timer, distrtimer;
3480 pl = players.sort_next;
3483 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3484 if(pl.scores[ps_primary] == 0)
3487 score = me.(scores[ps_primary]);
3488 timer = TIME_ENCODED_TOSTRING(score);
3490 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3491 // distribution display
3492 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3494 distrtimer = ftos(distribution/pow(10, TIME_DECIMALS));
3496 if (distribution <= 0) {
3497 distribution_color = '0 1 0';
3500 distribution_color = '1 0 0';
3502 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);
3504 // race record display
3505 if (distribution <= 0)
3506 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3507 drawfont = hud_bigfont;
3508 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3509 drawfont = hud_font;
3510 } else if (!teamplay) { // non-teamgames
3511 // me vector := [team/connected frags id]
3512 pl = players.sort_next;
3516 if(autocvar__hud_configure)
3519 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3523 score = me.(scores[ps_primary]);
3524 if(autocvar__hud_configure)
3527 if(distribution >= 5) {
3528 distribution_color = eY;
3530 } else if(distribution >= 0) {
3531 distribution_color = '1 1 1';
3533 } else if(distribution >= -5)
3534 distribution_color = '1 1 0';
3536 distribution_color = eX;
3538 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);
3540 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3541 drawfont = hud_bigfont;
3542 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3543 drawfont = hud_font;
3544 } else { // teamgames
3545 float max_fragcount;
3546 max_fragcount = -99;
3549 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3550 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !autocvar__hud_configure)) // no players? don't display
3552 score = tm.(teamscores[ts_primary]);
3553 if(autocvar__hud_configure)
3557 if (score > max_fragcount)
3558 max_fragcount = score;
3560 if(tm.team == myteam) {
3561 if (max_fragcount == score)
3564 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3565 drawfont = hud_bigfont;
3566 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3567 drawfont = hud_font;
3569 if (max_fragcount == score)
3572 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);
3573 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);
3582 void HUD_RaceTimer (void) {
3583 if(!autocvar_hud_panel_racetimer && !(gametype == GAME_RACE || gametype == GAME_CTS) && !autocvar__hud_configure)
3586 active_panel = HUD_PANEL_RACETIMER;
3587 HUD_Panel_UpdateCvars(racetimer);
3590 mySize = panel_size;
3592 HUD_Panel_DrawBg(1);
3593 if(panel_bg_padding)
3595 pos += '1 1 0' * panel_bg_padding;
3596 mySize -= '2 2 0' * panel_bg_padding;
3599 // always force 4:1 aspect
3601 if(mySize_x/mySize_y > 4)
3603 newSize_x = 4 * mySize_y;
3604 newSize_y = mySize_y;
3606 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3610 newSize_y = 1/4 * mySize_x;
3611 newSize_x = mySize_x;
3613 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3617 drawfont = hud_bigfont;
3619 string s, forcetime;
3621 if(autocvar__hud_configure)
3624 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);
3625 s = "^1Intermediate 1 (+15.42)";
3626 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);
3627 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3628 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);
3630 else if(race_checkpointtime)
3632 a = bound(0, 2 - (time - race_checkpointtime), 1);
3635 if(a > 0) // just hit a checkpoint?
3637 if(race_checkpoint != 254)
3639 if(race_time && race_previousbesttime)
3640 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3642 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3644 forcetime = TIME_ENCODED_TOSTRING(race_time);
3649 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3651 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3652 if(a > 0) // next one?
3654 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3659 if(s != "" && a > 0)
3661 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);
3664 if(race_penaltytime)
3666 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3669 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3670 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);
3676 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3677 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);
3682 if(race_laptime && race_checkpoint != 255)
3684 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3685 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);
3690 if(race_mycheckpointtime)
3692 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3693 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3694 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);
3696 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3698 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3699 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3700 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);
3703 if(race_penaltytime && !race_penaltyaccumulator)
3705 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3706 a = bound(0, (1 + t - time), 1);
3710 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3712 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3713 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);
3718 drawfont = hud_font;
3723 float vote_yescount;
3726 float vote_highlighted; // currently selected vote
3728 float vote_active; // is there an active vote?
3729 float vote_prev; // previous state of vote_active to check for a change
3731 float vote_change; // "time" when vote_active changed
3733 void HUD_VoteWindow(void)
3735 if(!autocvar_hud_panel_vote && !autocvar__hud_configure)
3738 active_panel = HUD_PANEL_VOTE;
3739 HUD_Panel_UpdateCvars(vote);
3742 mySize = panel_size;
3744 if(!autocvar__hud_configure)
3746 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
3747 panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha;
3749 if(panel_bg_alpha_str == "") {
3750 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
3752 panel_bg_alpha = stof(panel_bg_alpha_str);
3757 if(vote_active != vote_prev) {
3759 vote_prev = vote_active;
3762 if(vote_active || autocvar__hud_configure)
3763 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3765 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3767 if(autocvar__hud_configure)
3777 a = panel_bg_alpha * vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3778 HUD_Panel_DrawBg(a);
3779 a = panel_fg_alpha * vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3780 if(panel_bg_padding)
3782 pos += '1 1 0' * panel_bg_padding;
3783 mySize -= '2 2 0' * panel_bg_padding;
3786 // always force 3:1 aspect
3788 if(mySize_x/mySize_y > 3)
3790 newSize_x = 3 * mySize_y;
3791 newSize_y = mySize_y;
3793 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3797 newSize_y = 1/3 * mySize_x;
3798 newSize_x = mySize_x;
3800 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3804 s = "A vote has been called for:";
3805 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3806 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1.75/8), stringwidth_colors);
3807 if(autocvar__hud_configure)
3808 s = "^1Configure the HUD";
3809 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
3811 // print the yes/no counts
3812 s = strcat("Yes (", getcommandkey("not bound", "vyes"), "): ", ftos(vote_yescount));
3813 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);
3814 s = strcat("No (", getcommandkey("not bound", "vno"), "): ", ftos(vote_nocount));
3815 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);
3817 // draw the progress bar backgrounds
3818 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3820 // draw the highlights
3821 if(vote_highlighted == 1) {
3822 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3823 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3825 else if(vote_highlighted == 2) {
3826 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3827 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3830 // draw the progress bars
3831 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3832 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3834 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3835 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3837 drawresetcliparea();
3840 vote_highlighted = 0;
3844 // Mod icons panel (#10)
3847 float mod_active; // is there any active mod icon?
3849 // CTF HUD modicon section
3850 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3851 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3852 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3854 void HUD_Mod_CTF_Reset(void)
3856 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3859 void HUD_Mod_CTF(vector pos, vector mySize)
3861 vector redflag_pos, blueflag_pos;
3863 float f; // every function should have that
3865 float redflag, blueflag; // current status
3866 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3869 stat_items = getstati(STAT_ITEMS);
3870 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3871 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3873 if(redflag || blueflag)
3878 if(autocvar__hud_configure)
3884 // when status CHANGES, set old status into prevstatus and current status into status
3885 if (redflag != redflag_prevframe)
3887 redflag_statuschange_time = time;
3888 redflag_prevstatus = redflag_prevframe;
3889 redflag_prevframe = redflag;
3892 if (blueflag != blueflag_prevframe)
3894 blueflag_statuschange_time = time;
3895 blueflag_prevstatus = blueflag_prevframe;
3896 blueflag_prevframe = blueflag;
3899 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3900 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3902 float BLINK_FACTOR = 0.15;
3903 float BLINK_BASE = 0.85;
3905 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3907 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3909 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3911 string red_icon, red_icon_prevstatus;
3912 float red_alpha, red_alpha_prevstatus;
3913 red_alpha = red_alpha_prevstatus = 1;
3915 case 1: red_icon = "flag_red_taken"; break;
3916 case 2: red_icon = "flag_red_lost"; break;
3917 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3919 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3920 red_icon = "flag_red_shielded";
3922 red_icon = string_null;
3925 switch(redflag_prevstatus) {
3926 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3927 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3928 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3931 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3932 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3933 red_icon_prevstatus = "flag_red_shielded";
3935 red_icon_prevstatus = string_null;
3939 string blue_icon, blue_icon_prevstatus;
3940 float blue_alpha, blue_alpha_prevstatus;
3941 blue_alpha = blue_alpha_prevstatus = 1;
3943 case 1: blue_icon = "flag_blue_taken"; break;
3944 case 2: blue_icon = "flag_blue_lost"; break;
3945 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3947 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3948 blue_icon = "flag_blue_shielded";
3950 blue_icon = string_null;
3953 switch(blueflag_prevstatus) {
3954 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3955 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3956 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3959 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3960 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3961 blue_icon_prevstatus = "flag_blue_shielded";
3963 blue_icon_prevstatus = string_null;
3967 if(mySize_x > mySize_y) {
3968 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3970 blueflag_pos = pos + eX * 0.5 * mySize_x;
3973 redflag_pos = pos + eX * 0.5 * mySize_x;
3975 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3977 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3979 blueflag_pos = pos + eY * 0.5 * mySize_y;
3982 redflag_pos = pos + eY * 0.5 * mySize_y;
3984 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3987 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3988 if(red_icon_prevstatus && f < 1)
3989 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3991 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3993 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3994 if(blue_icon_prevstatus && f < 1)
3995 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3997 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
4000 // Keyhunt HUD modicon section
4001 float kh_runheretime;
4003 void HUD_Mod_KH_Reset(void)
4008 void HUD_Mod_KH(vector pos, vector mySize)
4010 mod_active = 1; // keyhunt should never hide the mod icons panel
4014 vector p, pa, kh_size, kh_asize;
4016 kh_keys = getstati(STAT_KH_KEYS);
4019 if(mySize_x > mySize_y)
4021 p_y = pos_y + 0.25 * mySize_y;
4022 pa = p - eY * 0.25 * mySize_y;
4024 kh_size_x = mySize_x * 0.25;
4025 kh_size_y = 0.75 * mySize_y;
4026 kh_asize_x = mySize_x * 0.25;
4027 kh_asize_y = mySize_y * 0.25;
4031 p_y = pos_y + 0.125 * mySize_y;
4032 pa = p - eY * 0.125 * mySize_y;
4034 kh_size_x = mySize_x * 0.5;
4035 kh_size_y = 0.375 * mySize_y;
4036 kh_asize_x = mySize_x * 0.5;
4037 kh_asize_y = mySize_y * 0.125;
4044 for(i = 0; i < 4; ++i)
4046 key = floor(kh_keys / pow(32, i)) & 31;
4048 if(keyteam == 30 && keycount <= 4)
4050 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
4054 // this yields 8 exactly if "RUN HERE" shows
4059 kh_runheretime = time;
4060 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
4065 for(i = 0; i < 4; ++i)
4067 key = floor(kh_keys / pow(32, i)) & 31;
4080 default: // owned or dropped
4085 a = a * panel_fg_alpha;
4086 aa = aa * panel_fg_alpha;
4092 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4095 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4098 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4101 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4106 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
4109 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4112 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4115 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4118 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4122 if(mySize_x > mySize_y)
4124 p_x += 0.25 * mySize_x;
4125 pa_x += 0.25 * mySize_x;
4131 p_y = pos_y + 0.625 * mySize_y;
4132 pa_y = pos_y + 0.5 * mySize_y;
4138 p_x += 0.5 * mySize_x;
4139 pa_x += 0.5 * mySize_x;
4145 // Nexball HUD mod icon
4146 void HUD_Mod_NexBall(vector pos, vector mySize)
4148 float stat_items, nb_pb_starttime, dt, p;
4150 stat_items = getstati(STAT_ITEMS);
4151 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
4153 if (stat_items & IT_KEY1)
4158 //Manage the progress bar if any
4159 if (nb_pb_starttime > 0)
4161 dt = mod(time - nb_pb_starttime, nb_pb_period);
4162 // one period of positive triangle
4163 p = 2 * dt / nb_pb_period;
4170 if(mySize_x > mySize_y)
4172 barsize = eX * p * mySize_x + eY * mySize_y;
4177 barsize = eX * mySize_x + eY * p * mySize_y;
4180 HUD_Panel_GetProgressBarColor("nexball")
4181 HUD_Panel_DrawProgressBar(pos, vertical, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4184 if (stat_items & IT_KEY1)
4185 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4188 // Race/CTS HUD mod icons
4189 float crecordtime_prev; // last remembered crecordtime
4190 float crecordtime_change_time; // time when crecordtime last changed
4191 float srecordtime_prev; // last remembered srecordtime
4192 float srecordtime_change_time; // time when srecordtime last changed
4194 float race_status_time;
4195 float race_status_prev;
4196 string race_status_name_prev;
4197 void HUD_Mod_Race(vector pos, vector mySize)
4199 mod_active = 1; // race should never hide the mod icons panel
4201 me = playerslots[player_localentnum - 1];
4203 float f; // yet another function has this
4204 score = me.(scores[ps_primary]);
4206 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
4207 return; // no records in the actual race
4209 drawfont = hud_bigfont;
4211 // clientside personal record
4213 if(gametype == GAME_CTS)
4217 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4219 if(score && (score < t || !t)) {
4220 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4221 if(cvar("cl_autodemo_delete_keeprecords"))
4223 f = cvar("cl_autodemo_delete");
4225 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4229 if(t != crecordtime_prev) {
4230 crecordtime_prev = t;
4231 crecordtime_change_time = time;
4233 f = time - crecordtime_change_time;
4236 drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4237 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);
4239 drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4240 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);
4241 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);
4242 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);
4246 t = race_server_record;
4247 if(t != srecordtime_prev) {
4248 srecordtime_prev = t;
4249 srecordtime_change_time = time;
4251 f = time - srecordtime_change_time;
4254 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);
4255 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);
4257 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);
4258 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);
4259 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);
4260 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);
4263 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4264 race_status_time = time + 5;
4265 race_status_prev = race_status;
4266 if (race_status_name_prev)
4267 strunzone(race_status_name_prev);
4268 race_status_name_prev = strzone(race_status_name);
4271 pos_x += mySize_x/2;
4274 a = bound(0, race_status_time - time, 1);
4277 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4281 rank = race_CheckName(race_status_name);
4283 rankname = race_PlaceName(rank);
4286 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4288 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4290 if(race_status == 0)
4291 drawpic_aspect_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4292 else if(race_status == 1) {
4293 drawpic_aspect_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4294 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4295 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4296 } else if(race_status == 2) {
4297 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4298 drawpic_aspect_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4300 drawpic_aspect_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4301 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4302 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4303 } else if(race_status == 3) {
4304 drawpic_aspect_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4305 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4306 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4309 if (race_status_time - time <= 0) {
4310 race_status_prev = -1;
4312 if(race_status_name)
4313 strunzone(race_status_name);
4314 race_status_name = string_null;
4315 if(race_status_name_prev)
4316 strunzone(race_status_name_prev);
4317 race_status_name_prev = string_null;
4319 drawfont = hud_font;
4322 float mod_prev; // previous state of mod_active to check for a change
4324 float mod_change; // "time" when mod_active changed
4326 void HUD_ModIcons(void)
4328 if(!autocvar_hud_panel_modicons && !autocvar__hud_configure)
4331 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !autocvar__hud_configure)
4334 active_panel = HUD_PANEL_MODICONS;
4335 HUD_Panel_UpdateCvars(modicons);
4338 mySize = panel_size;
4340 if(mod_active != mod_prev) {
4342 mod_prev = mod_active;
4345 if(mod_active || autocvar__hud_configure)
4346 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4348 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4351 HUD_Panel_DrawBg(mod_alpha);
4353 if(panel_bg_padding)
4355 pos += '1 1 0' * panel_bg_padding;
4356 mySize -= '2 2 0' * panel_bg_padding;
4359 // these MUST be ran in order to update mod_active
4360 if(gametype == GAME_KEYHUNT)
4361 HUD_Mod_KH(pos, mySize);
4362 else if(gametype == GAME_CTF || autocvar__hud_configure)
4363 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4364 else if(gametype == GAME_NEXBALL)
4365 HUD_Mod_NexBall(pos, mySize);
4366 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4367 HUD_Mod_Race(pos, mySize);
4370 // Draw pressed keys (#11)
4372 void HUD_DrawPressedKeys(void)
4374 if(!autocvar_hud_panel_pressedkeys && !autocvar__hud_configure)
4377 if(!(spectatee_status > 0 || autocvar_hud_panel_pressedkeys >= 2 || autocvar__hud_configure))
4380 active_panel = HUD_PANEL_PRESSEDKEYS;
4381 HUD_Panel_UpdateCvars(pressedkeys);
4384 mySize = panel_size;
4386 HUD_Panel_DrawBg(1);
4387 if(panel_bg_padding)
4389 pos += '1 1 0' * panel_bg_padding;
4390 mySize -= '2 2 0' * panel_bg_padding;
4393 // force custom aspect
4394 if(autocvar_hud_panel_pressedkeys_aspect)
4397 if(mySize_x/mySize_y > autocvar_hud_panel_pressedkeys_aspect)
4399 newSize_x = autocvar_hud_panel_pressedkeys_aspect * mySize_y;
4400 newSize_y = mySize_y;
4402 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4406 newSize_y = 1/autocvar_hud_panel_pressedkeys_aspect * mySize_x;
4407 newSize_x = mySize_x;
4409 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4415 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4418 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4419 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4420 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);
4421 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);
4422 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);
4423 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);
4424 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);
4427 // Handle chat as a panel (#12)
4431 if(!autocvar_hud_panel_chat && !autocvar__hud_configure)
4433 cvar_set("con_chatrect", "0");
4437 active_panel = HUD_PANEL_CHAT;
4438 HUD_Panel_UpdateCvars(chat);
4440 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
4442 panel_pos_y = panel_bg_border;
4443 panel_size_y = vid_conheight - panel_bg_border * 2;
4444 if(panel_bg == "0") // force a border when maximized
4446 if(precache_pic(panel_bg) == "") {
4447 panel_bg = strcat(hud_skin_path, "/border_default");
4448 if(precache_pic(panel_bg) == "") {
4449 panel_bg = "gfx/hud/default/border_default";
4453 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an alpha of at least 0.75
4458 mySize = panel_size;
4460 HUD_Panel_DrawBg(1);
4462 if(panel_bg_padding)
4464 pos += '1 1 0' * panel_bg_padding;
4465 mySize -= '2 2 0' * panel_bg_padding;
4468 cvar_set("con_chatrect", "1");
4470 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4471 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4473 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4474 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4476 if(autocvar__hud_configure)
4479 chatsize = cvar("con_chatsize");
4480 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4482 for(i = 0; i < cvar("con_chat"); ++i)
4484 if(i == cvar("con_chat") - 1)
4487 a = panel_fg_alpha * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4488 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);
4493 // Engine info panel (#13)
4500 float frametimeavg1; // 1 frame ago
4501 float frametimeavg2; // 2 frames ago
4502 void HUD_EngineInfo(void)
4504 if(!autocvar_hud_panel_engineinfo && !autocvar__hud_configure)
4507 active_panel = HUD_PANEL_ENGINEINFO;
4508 HUD_Panel_UpdateCvars(engineinfo);
4511 mySize = panel_size;
4513 HUD_Panel_DrawBg(1);
4514 if(panel_bg_padding)
4516 pos += '1 1 0' * panel_bg_padding;
4517 mySize -= '2 2 0' * panel_bg_padding;
4520 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
4522 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4523 frametimeavg2 = frametimeavg1;
4524 frametimeavg1 = frametimeavg;
4527 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4528 if(frametime > 0.0001) // filter out insane values which sometimes seem to occur and throw off the average? If you are getting 10,000 fps or more, then you don't need a framerate counter.
4530 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/frametime) to make big updates instant
4531 prevfps = (1/frametime);
4532 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"
4538 if(time - prevfps_time > cvar("hud_panel_engineinfo_framecounter_time"))
4540 prevfps = framecounter/cvar("hud_panel_engineinfo_framecounter_time");
4542 prevfps_time = time;
4547 color = HUD_Get_Num_Color (prevfps, 100);
4548 drawfont = hud_bigfont;
4549 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_panel_engineinfo_framecounter_decimals"))), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4550 drawfont = hud_font;
4553 // Info messages panel (#14)
4555 void HUD_InfoMessages(void)
4557 if(!autocvar_hud_panel_infomessages && !autocvar__hud_configure)
4560 active_panel = HUD_PANEL_INFOMESSAGES;
4561 HUD_Panel_UpdateCvars(infomessages);
4564 mySize = panel_size;
4566 HUD_Panel_DrawBg(1);
4567 if(panel_bg_padding)
4569 pos += '1 1 0' * panel_bg_padding;
4570 mySize -= '2 2 0' * panel_bg_padding;
4573 // always force 5:1 aspect
4575 if(mySize_x/mySize_y > 5)
4577 newSize_x = 5 * mySize_y;
4578 newSize_y = mySize_y;
4580 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4584 newSize_y = 1/5 * mySize_x;
4585 newSize_x = mySize_x;
4587 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4596 fontsize = '0.20 0.20 0' * mySize_y;
4599 if(spectatee_status != 0)
4605 if(!autocvar__hud_configure)
4607 if(spectatee_status && !intermission)
4609 if(spectatee_status == -1)
4612 s = strcat("^1Spectating: ^7", GetPlayerName(spectatee_status - 1));
4614 if(autocvar_hud_panel_infomessages_flip)
4615 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4616 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4617 o += eY * fontsize_y;
4619 if(spectatee_status == -1)
4620 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
4622 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
4623 if(autocvar_hud_panel_infomessages_flip)
4624 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4625 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4626 o += eY * fontsize_y;
4628 if(spectatee_status == -1)
4629 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
4631 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
4632 if(autocvar_hud_panel_infomessages_flip)
4633 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4634 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4635 o += eY * fontsize_y;
4637 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
4638 if(autocvar_hud_panel_infomessages_flip)
4639 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4640 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4641 o += eY * fontsize_y;
4643 if(gametype == GAME_ARENA)
4644 s = "^1Wait for your turn to join";
4645 else if(gametype == GAME_LMS)
4648 sk = playerslots[player_localentnum - 1];
4649 if(sk.(scores[ps_primary]) >= 666)
4650 s = "^1Match has already begun";
4651 else if(sk.(scores[ps_primary]) > 0)
4652 s = "^1You have no more lives left";
4654 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4657 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4658 if(autocvar_hud_panel_infomessages_flip)
4659 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4660 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4661 o += eY * fontsize_y;
4663 //show restart countdown:
4664 if (time < getstatf(STAT_GAMESTARTTIME)) {
4666 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4667 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4668 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
4669 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4670 o += eY * fontsize_y;
4673 if(warmup_stage && !intermission)
4675 s = "^2Currently in ^1warmup^2 stage!";
4676 if(autocvar_hud_panel_infomessages_flip)
4677 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4678 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4679 o += eY * fontsize_y;
4683 if(mod(time, 1) >= 0.5)
4688 if(ready_waiting && !intermission && !spectatee_status)
4690 if(ready_waiting_for_me)
4693 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
4695 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
4700 s = strcat("^2Waiting for others to ready up to end warmup...");
4702 s = strcat("^2Waiting for others to ready up...");
4704 if(autocvar_hud_panel_infomessages_flip)
4705 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4706 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4707 o += eY * fontsize_y;
4709 else if(warmup_stage && !intermission && !spectatee_status)
4711 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
4712 if(autocvar_hud_panel_infomessages_flip)
4713 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4714 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4715 o += eY * fontsize_y;
4718 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4720 float ts_min, ts_max;
4721 tm = teams.sort_next;
4724 for(; tm.sort_next; tm = tm.sort_next)
4726 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4728 if(!ts_min) ts_min = tm.team_size;
4729 else ts_min = min(ts_min, tm.team_size);
4730 if(!ts_max) ts_max = tm.team_size;
4731 else ts_max = max(ts_max, tm.team_size);
4733 if ((ts_max - ts_min) > 1)
4735 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
4736 tm = GetTeam(myteam, false);
4738 if (tm.team != COLOR_SPECTATOR)
4739 if (tm.team_size == ts_max)
4740 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
4742 if(autocvar_hud_panel_infomessages_flip)
4743 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4744 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4745 o += eY * fontsize_y;
4752 s = "^7Press ^3ESC ^7to show HUD options.";
4753 if(autocvar_hud_panel_infomessages_flip)
4754 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4755 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4756 o += eY * fontsize_y;
4757 s = "^3Doubleclick ^7a panel for panel-specific options.";
4758 if(autocvar_hud_panel_infomessages_flip)
4759 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4760 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4761 o += eY * fontsize_y;
4762 s = "^3CTRL ^7to disable collision testing, ^3SHIFT ^7and";
4763 if(autocvar_hud_panel_infomessages_flip)
4764 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4765 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4766 o += eY * fontsize_y;
4767 s = "^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.";
4768 if(autocvar_hud_panel_infomessages_flip)
4769 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4770 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4771 o += eY * fontsize_y;
4781 void HUD_ShowSpeed(void)
4784 float pos, conversion_factor;
4785 string speed, zspeed, unit;
4787 switch(cvar("cl_showspeed_unit"))
4792 conversion_factor = 1.0;
4796 conversion_factor = 1.0;
4800 conversion_factor = 0.0254;
4804 conversion_factor = 0.0254 * 3.6;
4808 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4812 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4816 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4818 numsize_x = numsize_y = cvar("cl_showspeed_size");
4819 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4821 drawfont = hud_bigfont;
4822 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
4824 if (cvar("cl_showspeed_z") == 1) {
4825 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4826 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
4829 drawfont = hud_font;
4832 vector acc_prevspeed;
4836 void HUD_ShowAcceleration(void)
4838 float acceleration, sz, scale, alpha, f;
4839 vector pos, top, rgb;
4840 top_x = vid_conwidth/2;
4843 f = time - acc_prevtime;
4844 if(cvar("cl_showacceleration_z"))
4845 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4847 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4848 acc_prevspeed = pmove_vel;
4849 acc_prevtime = time;
4851 f = bound(0, f * 10, 1);
4852 acc_avg = acc_avg * (1 - f) + acceleration * f;
4853 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4855 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4857 sz = cvar("cl_showacceleration_size");
4858 scale = cvar("cl_showacceleration_scale");
4859 alpha = cvar("cl_showacceleration_alpha");
4860 if (cvar("cl_showacceleration_color_custom"))
4861 rgb = stov(cvar_string("cl_showacceleration_color"));
4864 if (acceleration < 0) {
4865 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4866 } else if (acceleration > 0) {
4867 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4871 if (acceleration > 0)
4872 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
4873 else if (acceleration < 0)
4874 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);
4877 void HUD_Reset (void)
4879 // reset gametype specific icons
4880 if(gametype == GAME_KEYHUNT)
4882 else if(gametype == GAME_CTF)
4883 HUD_Mod_CTF_Reset();
4886 #define HUD_DrawPanel(id)\
4888 case (HUD_PANEL_RADAR):\
4889 HUD_Radar(); break;\
4890 case (HUD_PANEL_WEAPONS):\
4891 HUD_Weapons(); break;\
4892 case (HUD_PANEL_AMMO):\
4894 case (HUD_PANEL_POWERUPS):\
4895 HUD_Powerups(); break;\
4896 case (HUD_PANEL_HEALTHARMOR):\
4897 HUD_HealthArmor(); break;\
4898 case (HUD_PANEL_NOTIFY):\
4899 HUD_Notify(); break;\
4900 case (HUD_PANEL_TIMER):\
4901 HUD_Timer(); break;\
4902 case (HUD_PANEL_SCORE):\
4903 HUD_Score(); break;\
4904 case (HUD_PANEL_RACETIMER):\
4905 HUD_RaceTimer(); break;\
4906 case (HUD_PANEL_VOTE):\
4907 HUD_VoteWindow(); break;\
4908 case (HUD_PANEL_MODICONS):\
4909 HUD_ModIcons(); break;\
4910 case (HUD_PANEL_PRESSEDKEYS):\
4911 HUD_DrawPressedKeys(); break;\
4912 case (HUD_PANEL_CHAT):\
4914 case (HUD_PANEL_ENGINEINFO):\
4915 HUD_EngineInfo(); break;\
4916 case (HUD_PANEL_INFOMESSAGES):\
4917 HUD_InfoMessages(); break;\
4920 void HUD_Main (void)
4922 hud_skin_path = strcat("gfx/hud/", autocvar_hud_skin);
4924 // global hud alpha fade
4925 if(disable_menu_alphacheck == 1)
4928 hud_fade_alpha = (1 - autocvar__menu_alpha);
4930 if(scoreboard_fade_alpha)
4931 hud_fade_alpha = (1 - scoreboard_fade_alpha);
4933 if(intermission == 2) // no hud during mapvote
4935 else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
4938 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4939 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4941 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4942 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4946 // HUD configure visible grid
4947 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4951 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2); ++i)
4953 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);
4956 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2); ++i)
4958 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);
4964 if((teamplay) && autocvar_hud_dock_color_team) {
4965 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4966 color = colormapPaletteColor(mod(f, 16), 1) * autocvar_hud_dock_color_team;
4968 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && autocvar_hud_dock_color_team) {
4969 color = '1 0 0' * autocvar_hud_dock_color_team;
4971 else if(autocvar_hud_dock_color == "shirt") {
4972 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4973 color = colormapPaletteColor(floor(f / 16), 0);
4975 else if(autocvar_hud_dock_color == "pants") {
4976 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4977 color = colormapPaletteColor(mod(f, 16), 1);
4980 color = stov(autocvar_hud_dock_color);
4983 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4986 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4987 if(precache_pic(pic) == "") {
4988 pic = strcat(hud_skin_path, "/dock_medium");
4989 if(precache_pic(pic) == "") {
4990 pic = "gfx/hud/default/dock_medium";
4993 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...
4996 // cache the panel order into the panel_order array
4997 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4998 if(hud_panelorder_prev)
4999 strunzone(hud_panelorder_prev);
5000 hud_panelorder_prev = strzone(autocvar__hud_panelorder);
5001 tokenize_console(autocvar__hud_panelorder);
5002 for(i = 0; i < HUD_PANEL_NUM; ++i) {
5003 panel_order[i] = stof(argv(i));
5006 // draw panels in order specified by panel_order array
5007 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
5008 if(i != HUD_PANEL_CHAT || !autocvar__con_chat_maximized) // don't draw maximized chat panel twice!
5009 HUD_DrawPanel(panel_order[i]);
5012 // draw chat panel on top if it is maximized
5013 if(autocvar__con_chat_maximized)
5014 HUD_DrawPanel(HUD_PANEL_CHAT);
5016 // TODO hud_'ify these
5017 if (cvar("cl_showspeed"))
5019 if (cvar("cl_showacceleration"))
5020 HUD_ShowAcceleration();
5022 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)
5023 localcmd("cmd selectteam auto; cmd join\n");
5025 hud_configure_prev = autocvar__hud_configure;
5027 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again
5028 disable_menu_alphacheck = 0;