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 vector centerprint_start;
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])
186 strunzone(centerprint_messages[i]);
187 centerprint_messages[i] = strzone(s);
188 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
191 // half height for empty lines looks better
197 if(i >= CENTERPRINT_MAX_LINES)
203 h = centerprint_fontsize_y*hcount;
205 havail = vid_conheight;
206 if(cvar("con_chatpos") < 0)
207 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
208 if(havail > vid_conheight - 70)
209 havail = vid_conheight - 70; // avoid overlapping HUD
211 centerprint_start_x = 0;
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);
263 centerprint_start_y =
266 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
274 centerprint_expire = time + cvar("scr_centertime");
277 void HUD_DrawCenterPrint (void)
284 //if(time > centerprint_expire)
287 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
288 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
289 //sz = 1.2 / (a + 0.2);
294 pos = centerprint_start;
295 for (i=0; i<centerprint_num; i = i + 1)
297 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
298 ts = centerprint_messages[i];
301 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
302 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
303 pos_y = pos_y + centerprint_fontsize_y;
306 // half height for empty lines looks better
307 pos_y = pos_y + centerprint_fontsize_y * 0.5;
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 // common cvars for all panels
458 for (i = 0; i < HUD_PANEL_NUM; ++i)
462 fputs(fh, strcat("seta hud_panel_", panel_name, " ", cvar_string(strcat("hud_panel_", panel_name)), "\n"));
463 fputs(fh, strcat("seta hud_panel_", panel_name, "_pos \"", cvar_string(strcat("hud_panel_", panel_name, "_pos")), "\"", "\n"));
464 fputs(fh, strcat("seta hud_panel_", panel_name, "_size \"", cvar_string(strcat("hud_panel_", panel_name, "_size")), "\"", "\n"));
465 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg \"", cvar_string(strcat("hud_panel_", panel_name, "_bg")), "\"", "\n"));
466 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_color \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_color")), "\"", "\n"));
467 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_color_team \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_color_team")), "\"", "\n"));
468 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_alpha")), "\"", "\n"));
469 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_border \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_border")), "\"", "\n"));
470 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_padding \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_padding")), "\"", "\n"));
472 case HUD_PANEL_WEAPONS:
473 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble")), "\"", "\n"));
474 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_padding \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_padding")), "\"", "\n"));
475 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_outofammo \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_outofammo")), "\"", "\n"));
476 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_donthave \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_donthave")), "\"", "\n"));
477 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_unavailable \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_unavailable")), "\"", "\n"));
478 fputs(fh, strcat("seta hud_panel_", panel_name, "_ammo_color \"", cvar_string(strcat("hud_panel_", panel_name, "_ammo_color")), "\"", "\n"));
479 fputs(fh, strcat("seta hud_panel_", panel_name, "_ammo_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_ammo_alpha")), "\"", "\n"));
480 fputs(fh, strcat("seta hud_panel_", panel_name, "_aspect \"", cvar_string(strcat("hud_panel_", panel_name, "_aspect")), "\"", "\n"));
483 fputs(fh, strcat("seta hud_panel_", panel_name, "_onlycurrent \"", cvar_string(strcat("hud_panel_", panel_name, "_onlycurrent")), "\"", "\n"));
484 fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
486 case HUD_PANEL_POWERUPS:
487 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\"", "\n"));
488 fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
489 fputs(fh, strcat("seta hud_panel_", panel_name, "_baralign \"", cvar_string(strcat("hud_panel_", panel_name, "_baralign")), "\"", "\n"));
490 fputs(fh, strcat("seta hud_panel_", panel_name, "_progressbar \"", cvar_string(strcat("hud_panel_", panel_name, "_progressbar")), "\"", "\n"));
492 case HUD_PANEL_HEALTHARMOR:
493 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\n"));
494 fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
495 fputs(fh, strcat("seta hud_panel_", panel_name, "_baralign \"", cvar_string(strcat("hud_panel_", panel_name, "_baralign")), "\"", "\n"));
496 fputs(fh, strcat("seta hud_panel_", panel_name, "_progressbar \"", cvar_string(strcat("hud_panel_", panel_name, "_progressbar")), "\"", "\n"));
498 case HUD_PANEL_NOTIFY:
499 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\"", "\n"));
500 fputs(fh, strcat("seta hud_panel_", panel_name, "_print \"", cvar_string(strcat("hud_panel_", panel_name, "_print")), "\"", "\n"));
502 case HUD_PANEL_RADAR:
503 fputs(fh, strcat("seta hud_panel_", panel_name, "_foreground_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_foreground_alpha")), "\"", "\n"));
506 fputs(fh, strcat("seta hud_panel_", panel_name, "_alreadyvoted_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_alreadyvoted_alpha")), "\"", "\n"));
508 case HUD_PANEL_PRESSEDKEYS:
509 fputs(fh, strcat("seta hud_panel_", panel_name, "_aspect \"", cvar_string(strcat("hud_panel_", panel_name, "_aspect")), "\"", "\n"));
514 fputs(fh, strcat("menu_restart", "\n")); // force a menu update when execing config, so that the dialogs are updated
516 print("^2Successfully exported to hud_", autocvar_hud_skin, "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
521 const float hlBorderSize = 4;
522 const string hlBorder = "gfx/hud/default/border_highlighted";
523 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
524 void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
526 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
527 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);
528 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);
529 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);
530 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);
533 // draw the background/borders
534 #define HUD_Panel_DrawBg(alpha)\
536 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));\
537 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
538 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);
540 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
547 pic = strcat(hud_skin_path, "/statusbar_vertical");
548 if(precache_pic(pic) == "") {
549 pic = "gfx/hud/default/statusbar_vertical";
551 drawsubpic(pos, eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, pic, '0 0 0', '1 0.25 0', color, alpha, drawflag);
552 if(mySize_y/mySize_x > 2)
553 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);
554 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);
556 pic = strcat(hud_skin_path, "/statusbar");
557 if(precache_pic(pic) == "") {
558 pic = "gfx/hud/default/statusbar";
560 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
561 if(mySize_x/mySize_y > 2)
562 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);
563 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);
567 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
573 pic = strcat(hud_skin_path, "/num_leading");
574 if(precache_pic(pic) == "") {
575 pic = "gfx/hud/default/num_leading";
578 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
579 if(mySize_x/mySize_y > 2)
580 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);
581 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);
584 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
585 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
596 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
597 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
599 for (i = 0; i < HUD_PANEL_NUM; ++i) {
600 if(i == highlightedPanel || !panel_enabled)
603 HUD_Panel_UpdatePosSizeForId(i)
605 panel_pos -= '1 1 0' * panel_bg_border;
606 panel_size += '2 2 0' * panel_bg_border;
608 if(myPos_y + mySize_y < panel_pos_y)
610 if(myPos_y > panel_pos_y + panel_size_y)
613 if(myPos_x + mySize_x < panel_pos_x)
615 if(myPos_x > panel_pos_x + panel_size_x)
618 // OK, there IS a collision.
620 myCenter_x = myPos_x + 0.5 * mySize_x;
621 myCenter_y = myPos_y + 0.5 * mySize_y;
623 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
624 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
626 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
628 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
629 myTarget_x = panel_pos_x - mySize_x;
630 else // push it upwards
631 myTarget_y = panel_pos_y - mySize_y;
633 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
635 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
636 myTarget_x = panel_pos_x + panel_size_x;
637 else // push it upwards
638 myTarget_y = panel_pos_y - mySize_y;
640 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
642 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
643 myTarget_x = panel_pos_x - mySize_x;
644 else // push it downwards
645 myTarget_y = panel_pos_y + panel_size_y;
647 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
649 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
650 myTarget_x = panel_pos_x + panel_size_x;
651 else // push it downwards
652 myTarget_y = panel_pos_y + panel_size_y;
654 if(cvar("hud_configure_checkcollisions_debug"))
655 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
661 void HUD_Panel_SetPos(vector pos)
663 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
667 if(cvar("hud_configure_checkcollisions_debug"))
668 drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
670 if(autocvar_hud_configure_grid)
672 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;
673 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;
676 if(hud_configure_checkcollisions)
677 pos = HUD_Panel_CheckMove(pos, mySize);
679 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
680 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
683 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
685 HUD_Panel_GetName(highlightedPanel);
686 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
689 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
690 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
700 ratio = mySize_x/mySize_y;
702 for (i = 0; i < HUD_PANEL_NUM; ++i) {
703 if(i == highlightedPanel || !panel_enabled)
706 HUD_Panel_UpdatePosSizeForId(i)
708 panel_pos -= '1 1 0' * panel_bg_border;
709 panel_size += '2 2 0' * panel_bg_border;
711 targEndPos = panel_pos + panel_size;
713 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
714 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
717 if (resizeCorner == 1)
719 // check if this panel is on our way
720 if (resizeorigin_x <= panel_pos_x)
722 if (resizeorigin_y <= panel_pos_y)
724 if (targEndPos_x <= resizeorigin_x - mySize_x)
726 if (targEndPos_y <= resizeorigin_y - mySize_y)
729 // there is a collision:
730 // detect which side of the panel we are facing is actually limiting the resizing
731 // (which side the resize direction finds for first) and reduce the size up to there
733 // dist is the distance between resizeorigin and the "analogous" point of the panel
734 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
735 dist_x = resizeorigin_x - targEndPos_x;
736 dist_y = resizeorigin_y - targEndPos_y;
737 if (dist_y <= 0 || dist_x / dist_y > ratio)
738 mySize_x = min(mySize_x, dist_x);
740 mySize_y = min(mySize_y, dist_y);
742 else if (resizeCorner == 2)
744 if (resizeorigin_x >= targEndPos_x)
746 if (resizeorigin_y <= panel_pos_y)
748 if (panel_pos_x >= resizeorigin_x + mySize_x)
750 if (targEndPos_y <= resizeorigin_y - mySize_y)
753 dist_x = panel_pos_x - resizeorigin_x;
754 dist_y = resizeorigin_y - targEndPos_y;
755 if (dist_y <= 0 || dist_x / dist_y > ratio)
756 mySize_x = min(mySize_x, dist_x);
758 mySize_y = min(mySize_y, dist_y);
760 else if (resizeCorner == 3)
762 if (resizeorigin_x <= panel_pos_x)
764 if (resizeorigin_y >= targEndPos_y)
766 if (targEndPos_x <= resizeorigin_x - mySize_x)
768 if (panel_pos_y >= resizeorigin_y + mySize_y)
771 dist_x = resizeorigin_x - targEndPos_x;
772 dist_y = panel_pos_y - resizeorigin_y;
773 if (dist_y <= 0 || dist_x / dist_y > ratio)
774 mySize_x = min(mySize_x, dist_x);
776 mySize_y = min(mySize_y, dist_y);
778 else if (resizeCorner == 4)
780 if (resizeorigin_x >= targEndPos_x)
782 if (resizeorigin_y >= targEndPos_y)
784 if (panel_pos_x >= resizeorigin_x + mySize_x)
786 if (panel_pos_y >= resizeorigin_y + mySize_y)
789 dist_x = panel_pos_x - resizeorigin_x;
790 dist_y = panel_pos_y - resizeorigin_y;
791 if (dist_y <= 0 || dist_x / dist_y > ratio)
792 mySize_x = min(mySize_x, dist_x);
794 mySize_y = min(mySize_y, dist_y);
796 if(cvar("hud_configure_checkcollisions_debug"))
797 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
803 void HUD_Panel_SetPosSize(vector mySize)
805 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
807 resizeorigin = panel_click_resizeorigin;
810 // minimum panel size cap
811 mySize_x = max(0.025 * vid_conwidth, mySize_x);
812 mySize_y = max(0.025 * vid_conheight, mySize_y);
814 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.
816 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
817 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
820 // collision testing|
821 // -----------------+
823 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
824 if(resizeCorner == 1) {
825 myPos_x = resizeorigin_x - mySize_x;
826 myPos_y = resizeorigin_y - mySize_y;
827 } else if(resizeCorner == 2) {
828 myPos_x = resizeorigin_x;
829 myPos_y = resizeorigin_y - mySize_y;
830 } else if(resizeCorner == 3) {
831 myPos_x = resizeorigin_x - mySize_x;
832 myPos_y = resizeorigin_y;
833 } else { // resizeCorner == 4
834 myPos_x = resizeorigin_x;
835 myPos_y = resizeorigin_y;
838 // left/top screen edges
840 mySize_x = mySize_x + myPos_x;
842 mySize_y = mySize_y + myPos_y;
844 // bottom/right screen edges
845 if(myPos_x + mySize_x > vid_conwidth)
846 mySize_x = vid_conwidth - myPos_x;
847 if(myPos_y + mySize_y > vid_conheight)
848 mySize_y = vid_conheight - myPos_y;
850 if(cvar("hud_configure_checkcollisions_debug"))
851 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
853 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
854 if(autocvar_hud_configure_grid)
856 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;
857 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;
860 if(hud_configure_checkcollisions)
861 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
863 // 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)
864 mySize_x = max(0.025 * vid_conwidth, mySize_x);
865 mySize_y = max(0.025 * vid_conheight, mySize_y);
867 // do another pos check, as size might have changed by now
868 if(resizeCorner == 1) {
869 myPos_x = resizeorigin_x - mySize_x;
870 myPos_y = resizeorigin_y - mySize_y;
871 } else if(resizeCorner == 2) {
872 myPos_x = resizeorigin_x;
873 myPos_y = resizeorigin_y - mySize_y;
874 } else if(resizeCorner == 3) {
875 myPos_x = resizeorigin_x - mySize_x;
876 myPos_y = resizeorigin_y;
877 } else { // resizeCorner == 4
878 myPos_x = resizeorigin_x;
879 myPos_y = resizeorigin_y;
882 if(cvar("hud_configure_checkcollisions_debug"))
883 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
885 HUD_Panel_GetName(highlightedPanel);
887 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
888 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
890 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
891 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
895 float prevMouseClicked; // previous state
896 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
897 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
900 float menu_enabled_time;
901 float pressed_key_time;
902 void HUD_Panel_Arrow_Action(float nPrimary)
904 if (highlightedPanel_prev == -1 || mouseClicked)
907 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
910 if(autocvar_hud_configure_grid)
912 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
914 if (hudShiftState & S_SHIFT)
915 step = bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
917 step = 2 * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
921 if (hudShiftState & S_SHIFT)
922 step = bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
924 step = 2 * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
929 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
930 step = vid_conheight;
933 if (hudShiftState & S_SHIFT)
934 step = (step / 256); // more precision
936 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
939 highlightedPanel = highlightedPanel_prev;
941 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
943 vector prev_pos, prev_size;
944 prev_pos = panel_pos;
945 prev_size = panel_size;
947 if (hudShiftState & S_ALT) // resize
949 highlightedAction = 1;
950 if(nPrimary == K_UPARROW)
952 else if(nPrimary == K_RIGHTARROW)
954 else if(nPrimary == K_LEFTARROW)
956 else // if(nPrimary == K_DOWNARROW)
959 // ctrl+arrow reduces the size, instead of increasing it
960 // Note that ctrl disables collisions check too, but it's fine
961 // since we don't collide with anything reducing the size
962 if (hudShiftState & S_CTRL) {
964 resizeCorner = 5 - resizeCorner;
969 panel_click_resizeorigin = panel_pos;
970 if(resizeCorner == 1) {
971 panel_click_resizeorigin += mySize;
973 } else if(resizeCorner == 2) {
974 panel_click_resizeorigin_y += mySize_y;
976 } else if(resizeCorner == 3) {
977 panel_click_resizeorigin_x += mySize_x;
979 } else { // resizeCorner == 4
982 HUD_Panel_SetPosSize(mySize);
986 highlightedAction = 2;
989 if(nPrimary == K_UPARROW)
991 else if(nPrimary == K_DOWNARROW)
993 else if(nPrimary == K_LEFTARROW)
995 else // if(nPrimary == K_RIGHTARROW)
998 HUD_Panel_SetPos(pos);
1001 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
1003 if (prev_pos != panel_pos || prev_size != panel_size)
1006 panel_pos_backup = prev_pos;
1007 panel_size_backup = prev_size;
1008 highlightedPanel_backup = highlightedPanel;
1012 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1014 if(!autocvar__hud_configure)
1017 // allow console bind to work
1020 con_keys = findkeysforcommand("toggleconsole");
1021 keys = tokenize(con_keys);
1023 float hit_con_bind, i;
1024 for (i = 0; i < keys; ++i)
1026 if(nPrimary == stof(argv(i)))
1030 if(bInputType == 0) {
1031 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1032 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1033 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1035 else if(bInputType == 1) {
1036 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1037 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1038 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1041 if(nPrimary == K_MOUSE1)
1043 if(bInputType == 0) { // key pressed
1047 else if(bInputType == 1) {// key released
1052 else if(nPrimary == K_ESCAPE)
1054 if (bInputType == 1)
1056 disable_menu_alphacheck = 1;
1058 menu_enabled_time = time;
1059 localcmd("menu_showhudexit\n");
1061 else if(hudShiftState & S_CTRL)
1066 if(nPrimary == K_SPACE) // enable/disable highlighted panel or dock
1068 if (bInputType == 1)
1071 if (highlightedPanel_prev != -1)
1072 cvar_set(strcat("hud_panel_", panel_name), ftos(!(panel_enabled)));
1074 cvar_set(strcat("hud_dock"), (autocvar_hud_dock == "") ? "dock" : "");
1076 if(nPrimary == 'c') // copy highlighted panel size
1078 if (bInputType == 1)
1081 if (highlightedPanel_prev != -1)
1083 panel_size_copied = panel_size;
1084 highlightedPanel_copied = highlightedPanel_prev;
1087 else if(nPrimary == 'v') // past copied size on the highlighted panel
1089 if (bInputType == 1)
1092 if (highlightedPanel_copied != -1 && highlightedPanel_prev != -1)
1095 panel_pos_backup = panel_pos;
1096 panel_size_backup = panel_size;
1097 highlightedPanel_backup = highlightedPanel_prev;
1100 s = strcat(ftos(panel_size_copied_x/vid_conwidth), " ", ftos(panel_size_copied_y/vid_conheight));
1101 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
1104 else if(nPrimary == 'z') // undo last action
1106 if (bInputType == 1)
1108 //restore previous values
1109 if (highlightedPanel_backup != -1)
1111 HUD_Panel_GetName(highlightedPanel_backup)
1113 s = strcat(ftos(panel_pos_backup_x/vid_conwidth), " ", ftos(panel_pos_backup_y/vid_conheight));
1114 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
1115 s = strcat(ftos(panel_size_backup_x/vid_conwidth), " ", ftos(panel_size_backup_y/vid_conheight));
1116 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
1117 highlightedPanel_backup = -1;
1121 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1123 if (bInputType == 1)
1125 pressed_key_time = 0;
1128 else if (pressed_key_time == 0)
1129 pressed_key_time = time;
1131 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1133 else if(hit_con_bind)
1136 return true; // Suppress ALL other input
1139 float HUD_Panel_HighlightCheck()
1145 while(j <= HUD_PANEL_NUM)
1150 HUD_Panel_UpdatePosSizeForId(i)
1152 panelPos = panel_pos;
1153 panelSize = panel_size;
1154 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1157 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1161 // resize from topleft border
1162 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)
1166 // resize from topright border
1167 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)
1171 // resize from bottomleft border
1172 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)
1176 // resize from bottomright border
1177 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)
1185 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1186 void HUD_Panel_FirstInDrawQ(float id)
1189 var float place = -1;
1190 // find out where in the array our current id is, save into place
1191 for(i = 0; i < HUD_PANEL_NUM; ++i)
1193 if(panel_order[i] == id)
1199 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1201 place = HUD_PANEL_NUM - 1;
1203 // move all ids up by one step in the array until "place"
1204 for(i = place; i > 0; --i)
1206 panel_order[i] = panel_order[i-1];
1208 // now save the new top id
1209 panel_order[0] = id;
1211 // let's save them into the cvar by some strcat trickery
1213 for(i = 0; i < HUD_PANEL_NUM; ++i)
1215 s = strcat(s, ftos(panel_order[i]), " ");
1217 cvar_set("_hud_panelorder", s);
1218 if(hud_panelorder_prev)
1219 strunzone(hud_panelorder_prev);
1220 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1223 void HUD_Panel_Highlight()
1229 while(j <= HUD_PANEL_NUM)
1234 HUD_Panel_UpdatePosSizeForId(i)
1236 panelPos = panel_pos;
1237 panelSize = panel_size;
1238 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1241 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1243 highlightedPanel = i;
1244 HUD_Panel_FirstInDrawQ(i);
1245 highlightedAction = 1;
1246 panel_click_distance = mousepos - panelPos;
1249 // resize from topleft border
1250 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)
1252 highlightedPanel = i;
1253 HUD_Panel_FirstInDrawQ(i);
1254 highlightedAction = 2;
1256 panel_click_distance = mousepos - panelPos;
1257 panel_click_resizeorigin = panelPos + panelSize;
1260 // resize from topright border
1261 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)
1263 highlightedPanel = i;
1264 HUD_Panel_FirstInDrawQ(i);
1265 highlightedAction = 2;
1267 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1268 panel_click_distance_y = mousepos_y - panelPos_y;
1269 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1272 // resize from bottomleft border
1273 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)
1275 highlightedPanel = i;
1276 HUD_Panel_FirstInDrawQ(i);
1277 highlightedAction = 2;
1279 panel_click_distance_x = mousepos_x - panelPos_x;
1280 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1281 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1284 // resize from bottomright border
1285 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)
1287 highlightedPanel = i;
1288 HUD_Panel_FirstInDrawQ(i);
1289 highlightedAction = 2;
1291 panel_click_distance = panelSize - mousepos + panelPos;
1292 panel_click_resizeorigin = panelPos;
1297 highlightedPanel_prev = -1;
1302 float highlightcheck;
1304 void HUD_Panel_Mouse()
1306 // 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
1307 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1308 disable_menu_alphacheck = 0;
1309 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1313 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1314 print("Highlighted: ", ftos(highlightedPanel), "\n");
1315 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1318 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1319 highlightedPanel = -1;
1320 highlightedAction = 0;
1322 if(highlightedPanel != -1)
1323 highlightedPanel_prev = highlightedPanel;
1325 mousepos = mousepos + getmousepos() * cvar("menu_mouse_speed");
1327 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1328 mousepos_y = bound(0, mousepos_y, vid_conheight);
1332 vector prev_pos, prev_size;
1333 if(prevMouseClicked == 0)
1335 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1336 // and calls HUD_Panel_UpdatePosSizeForId() for the highlighted panel
1337 would_backup = TRUE;
1339 else if (would_backup)
1341 // this is not the actual backup! Saving pos and size values
1342 // only to check later if they are different from new values
1343 prev_pos = panel_pos;
1344 prev_size = panel_size;
1347 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1349 if(highlightedAction == 1)
1350 HUD_Panel_SetPos(mousepos - panel_click_distance);
1351 else if(highlightedAction == 2)
1354 if(resizeCorner == 1) {
1355 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1356 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1357 } else if(resizeCorner == 2) {
1358 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1359 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1360 } else if(resizeCorner == 3) {
1361 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1362 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1363 } else { // resizeCorner == 4
1364 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1365 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1367 HUD_Panel_SetPosSize(mySize);
1370 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
1371 if (prevMouseClicked)
1373 if (prev_pos != panel_pos || prev_size != panel_size)
1376 panel_pos_backup = prev_pos;
1377 panel_size_backup = prev_size;
1378 highlightedPanel_backup = highlightedPanel;
1379 would_backup = FALSE;
1382 // doubleclick check
1383 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1385 mouseClicked = 0; // to prevent spam, I guess.
1386 disable_menu_alphacheck = 2;
1388 menu_enabled_time = time;
1389 HUD_Panel_GetName(highlightedPanel)
1390 localcmd("menu_showhudoptions ", panel_name, "\n");
1393 if(prevMouseClicked == 0)
1395 prevMouseClickedTime = time;
1396 prevMouseClickedPos = mousepos;
1401 highlightcheck = HUD_Panel_HighlightCheck();
1403 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1406 cursorsize = '32 32 0';
1408 if(highlightcheck == 0)
1409 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1410 else if(highlightcheck == 1)
1411 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1412 else if(highlightcheck == 2)
1413 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1415 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1417 prevMouseClicked = mouseClicked;
1420 // Weapon icons (#0)
1422 float weaponspace[10];
1423 #define HUD_Weapons_Clear()\
1425 for(idx = 0; idx < 10; ++idx)\
1426 weaponspace[idx] = 0;
1428 entity weaponorder[WEP_MAXCOUNT];
1429 void weaponorder_swap(float i, float j, entity pass)
1433 weaponorder[i] = weaponorder[j];
1437 string weaponorder_cmp_str_save;
1438 string weaponorder_cmp_str;
1439 float weaponorder_cmp(float i, float j, entity pass)
1442 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1443 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1444 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)
1447 float GetAmmoStat(float i)
1451 case 0: return STAT_SHELLS;
1452 case 1: return STAT_NAILS;
1453 case 2: return STAT_ROCKETS;
1454 case 3: return STAT_CELLS;
1455 case 4: return STAT_FUEL;
1460 float GetAmmoTypeForWep(float i)
1464 case WEP_SHOTGUN: return 0;
1465 case WEP_UZI: return 1;
1466 case WEP_CAMPINGRIFLE: return 1;
1467 case WEP_GRENADE_LAUNCHER: return 2;
1468 case WEP_ELECTRO: return 3;
1469 case WEP_CRYLINK: return 3;
1470 case WEP_HLAC: return 3;
1471 case WEP_MINSTANEX: return 3;
1472 case WEP_NEX: return 3;
1473 case WEP_HAGAR: return 2;
1474 case WEP_ROCKET_LAUNCHER: return 2;
1475 case WEP_SEEKER: return 2;
1476 case WEP_FIREBALL: return 4;
1477 case WEP_HOOK: return 3;
1482 void HUD_Weapons(void)
1484 if(!autocvar_hud_panel_weapons && !autocvar__hud_configure)
1487 float timeout = cvar("hud_panel_weapons_timeout");
1488 float timeout_effect_lenght;
1489 if (cvar("hud_panel_weapons_timeout_effect") == 0)
1490 timeout_effect_lenght = 0;
1492 timeout_effect_lenght = 0.75;
1494 if (timeout && time >= weapontime + timeout + timeout_effect_lenght && !autocvar__hud_configure)
1497 active_panel = HUD_PANEL_WEAPONS;
1498 HUD_Panel_UpdateCvars(weapons);
1500 if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
1502 float f = (time - (weapontime + timeout)) / timeout_effect_lenght;
1503 if (cvar("hud_panel_weapons_timeout_effect") == 2)
1505 panel_bg_alpha *= (1 - f);
1506 panel_fg_alpha *= (1 - f);
1510 f *= f; // for a cooler movement
1512 center_x = panel_pos_x + panel_size_x/2;
1513 center_y = panel_pos_y + panel_size_y/2;
1514 float screen_ar = vid_conwidth/vid_conheight;
1515 if (center_x/center_y < screen_ar) //bottom left
1517 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
1518 panel_pos_y += f * (vid_conheight - panel_pos_y);
1520 panel_pos_x -= f * (panel_pos_x + panel_size_x);
1524 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
1525 panel_pos_x += f * (vid_conwidth - panel_pos_x);
1527 panel_pos_y -= f * (panel_pos_y + panel_size_y);
1532 float i, weapid, fade, weapon_stats, weapon_number, weapon_cnt;
1534 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1536 self = get_weaponinfo(i);
1537 if(self.impulse >= 0)
1541 // TODO make this configurable
1542 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1544 if(weaponorder_cmp_str != weaponorder_cmp_str_save)
1546 if(weaponorder_cmp_str_save)
1547 strunzone(weaponorder_cmp_str_save);
1548 weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
1550 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1552 self = get_weaponinfo(i);
1553 if(self.impulse >= 0)
1555 weaponorder[weapon_cnt] = self;
1559 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1562 HUD_Panel_DrawBg(1);
1563 if(panel_bg_padding)
1565 panel_pos += '1 1 0' * panel_bg_padding;
1566 panel_size -= '2 2 0' * panel_bg_padding;
1570 weapon_stats = getstati(STAT_DAMAGE_HITS);
1571 weapon_number = weapon_stats & 63;
1572 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1574 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1575 weapon_number = weapon_stats & 63;
1576 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1578 if(cvar_or("hud_panel_weapons_fade", 1))
1580 fade = 3.2 - 2 * (time - weapontime);
1581 fade = bound(0.7, fade, 1);
1586 HUD_Weapons_Clear();
1588 float rows, columns;
1589 rows = panel_size_y/panel_size_x;
1590 rows = bound(1, floor((sqrt(4 * autocvar_hud_panel_weapons_aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1592 columns = ceil(WEP_COUNT/rows);
1595 float a, type, fullammo;
1597 when = autocvar_hud_panel_weapons_complainbubble_time;
1599 fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
1605 for(i = 0; i < weapon_cnt; ++i)
1607 wpnpos = panel_pos + eX * column * panel_size_x*(1/columns) + eY * row * panel_size_y*(1/rows);
1608 wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
1610 self = weaponorder[i];
1611 weapid = self.impulse;
1613 // draw background behind currently selected weapon
1614 if(self.weapon == activeweapon)
1615 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1617 // draw the weapon accuracy
1620 float weapon_hit, weapon_damage;
1621 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1624 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1625 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1628 // find the max level lower than weapon_stats
1631 while ( j && weapon_stats < acc_lev[j] )
1634 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
1636 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
1637 color = acc_color(j);
1638 color = color + factor * (acc_color(j+1) - color);
1641 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1644 // draw the weapon icon
1645 if((self.impulse >= 0) && (getstati(STAT_WEAPONS) & self.weapons))
1647 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1649 if(autocvar_hud_panel_weapons_label == 1) // weapon number
1650 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * panel_size_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1651 else if(autocvar_hud_panel_weapons_label == 2) // bind
1652 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);
1654 // draw ammo status bar
1655 if(autocvar_hud_panel_weapons_ammo && weapid != WEP_TUBA && weapid != WEP_LASER && weapid != WEP_PORTO)
1658 type = GetAmmoTypeForWep(weapid);
1660 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
1665 case 0: fullammo = autocvar_hud_panel_weapons_ammo_full_shells; break;
1666 case 1: fullammo = autocvar_hud_panel_weapons_ammo_full_nails; break;
1667 case 2: fullammo = autocvar_hud_panel_weapons_ammo_full_rockets; break;
1668 case 3: fullammo = autocvar_hud_panel_weapons_ammo_full_cells; break;
1669 case 4: fullammo = autocvar_hud_panel_weapons_ammo_full_fuel; break;
1670 default: fullammo = 60;
1675 if(wpnsize_x/wpnsize_y > autocvar_hud_panel_weapons_aspect)
1677 barsize_x = autocvar_hud_panel_weapons_aspect * wpnsize_y;
1678 barsize_y = wpnsize_y;
1680 barpos_x = wpnpos_x + (wpnsize_x - barsize_x) / 2;
1681 barpos_y = wpnpos_y;
1685 barsize_y = 1/autocvar_hud_panel_weapons_aspect * wpnsize_x;
1686 barsize_x = wpnsize_x;
1688 barpos_y = wpnpos_y + (wpnsize_y - barsize_y) / 2;
1689 barpos_x = wpnpos_x;
1695 barsize_x * bound(0, a/fullammo, 1),
1697 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, autocvar_hud_panel_weapons_ammo_color, panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha, DRAWFLAG_NORMAL);
1698 drawresetcliparea();
1703 // draw a "ghost weapon icon" if you don't have the weapon
1706 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
1709 // draw the complain message
1710 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
1714 if(complain_weapon_time + when > time)
1717 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1721 if(complain_weapon_time + when > time)
1728 if(complain_weapon_type == 0) {
1730 color = autocvar_hud_panel_weapons_complainbubble_color_outofammo;
1732 else if(complain_weapon_type == 1) {
1734 color = autocvar_hud_panel_weapons_complainbubble_color_donthave;
1738 color = autocvar_hud_panel_weapons_complainbubble_color_unavailable;
1740 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);
1741 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);
1757 float GetAmmoItemCode(float i)
1761 case 0: return IT_SHELLS;
1762 case 1: return IT_NAILS;
1763 case 2: return IT_ROCKETS;
1764 case 3: return IT_CELLS;
1765 case 4: return IT_FUEL;
1770 string GetAmmoPicture(float i)
1774 case 0: return "ammo_shells";
1775 case 1: return "ammo_bullets";
1776 case 2: return "ammo_rockets";
1777 case 3: return "ammo_cells";
1778 case 4: return "ammo_fuel";
1783 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1786 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1787 if(autocvar__hud_configure)
1797 if(currently_selected)
1802 vector newSize, newPos;
1803 if(mySize_x/mySize_y > 3)
1805 newSize_x = 3 * mySize_y;
1806 newSize_y = mySize_y;
1808 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1813 newSize_y = 1/3 * mySize_x;
1814 newSize_x = mySize_x;
1816 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1820 vector picpos, numpos;
1821 if(autocvar_hud_panel_ammo_iconalign)
1824 picpos = newPos + eX * 2 * newSize_y;
1828 numpos = newPos + eX * newSize_y;
1832 if (currently_selected)
1833 drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1835 drawfont = hud_bigfont;
1837 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1838 else // "ghost" ammo count
1839 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1840 drawfont = hud_font;
1842 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1843 else // "ghost" ammo icon
1844 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1849 if(!autocvar_hud_panel_ammo && !autocvar__hud_configure)
1852 active_panel = HUD_PANEL_AMMO;
1853 HUD_Panel_UpdateCvars(ammo);
1854 float i, currently_selected;
1858 mySize = panel_size;
1860 HUD_Panel_DrawBg(1);
1861 if(panel_bg_padding)
1863 pos += '1 1 0' * panel_bg_padding;
1864 mySize -= '2 2 0' * panel_bg_padding;
1867 float rows, columns;
1868 rows = mySize_y/mySize_x;
1869 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1870 // ^^^ ammo item aspect goes here
1872 columns = ceil(AMMO_COUNT/rows);
1876 for (i = 0; i < AMMO_COUNT; ++i) {
1877 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1878 if(autocvar_hud_panel_ammo_onlycurrent) {
1879 if(autocvar__hud_configure)
1881 if (currently_selected || autocvar__hud_configure)
1883 DrawAmmoItem(pos, mySize, i, currently_selected);
1887 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);
1892 column = column + 1;
1898 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float alpha)
1900 vector newSize, newPos;
1901 if(mySize_x/mySize_y > 3)
1903 newSize_x = 3 * mySize_y;
1904 newSize_y = mySize_y;
1906 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1911 newSize_y = 1/3 * mySize_x;
1912 newSize_x = mySize_x;
1914 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1918 vector picpos, numpos;
1921 if(iconalign == 1 || iconalign == 3) // right align
1924 picpos = newPos + eX * 2 * newSize_y;
1928 numpos = newPos + eX * newSize_y;
1934 if(iconalign == 0 || iconalign == 3) // left align
1936 numpos = newPos + eX * newSize_y;
1942 picpos = newPos + eX * 2 * newSize_y;
1946 drawfont = hud_bigfont;
1947 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1948 drawfont = hud_font;
1949 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1952 void DrawNumIcon_expanding(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float fadelerp)
1955 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
1957 DrawNumIcon(iconalign, myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, left, color, (1 - fadelerp));
1962 void HUD_Powerups(void) {
1963 if(!autocvar_hud_panel_powerups && !autocvar__hud_configure)
1966 active_panel = HUD_PANEL_POWERUPS;
1967 HUD_Panel_UpdateCvars(powerups);
1969 stat_items = getstati(STAT_ITEMS);
1971 if(!autocvar__hud_configure)
1973 if not(stat_items & IT_STRENGTH)
1974 if not(stat_items & IT_INVINCIBLE)
1977 if (getstati(STAT_HEALTH) <= 0)
1983 mySize = panel_size;
1985 float strength_time, shield_time;
1986 if(autocvar__hud_configure)
1993 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1994 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1997 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
1998 if(panel_bg_padding)
2000 pos += '1 1 0' * panel_bg_padding;
2001 mySize -= '2 2 0' * panel_bg_padding;
2004 vector barpos, barsize;
2008 string leftname, rightname;
2009 float leftcnt, rightcnt;
2010 float leftexact, rightexact;
2011 if (autocvar_hud_panel_powerups_flip) {
2012 leftname = "strength";
2013 leftcnt = ceil(strength_time);
2014 leftexact = strength_time;
2016 rightname = "shield";
2017 rightcnt = ceil(shield_time);
2018 rightexact = shield_time;
2020 leftname = "shield";
2021 leftcnt = ceil(shield_time);
2022 leftexact = shield_time;
2024 rightname = "strength";
2025 rightcnt = ceil(strength_time);
2026 rightexact = strength_time;
2029 drawfont = hud_bigfont;
2030 if (mySize_x/mySize_y > 4)
2034 if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // right align
2035 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
2036 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
2037 } else { // left align
2039 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
2042 if(autocvar_hud_panel_powerups_progressbar)
2044 HUD_Panel_GetProgressBarColor(leftname)
2045 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);
2048 DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
2050 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));
2055 if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // left align
2056 barpos = pos + eX * 0.5 * mySize_x;
2057 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
2058 } else { // right align
2059 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
2060 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
2063 if(autocvar_hud_panel_powerups_progressbar)
2065 HUD_Panel_GetProgressBarColor(rightname)
2066 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);
2069 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);
2071 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));
2074 else if (mySize_x/mySize_y > 1.5)
2078 if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // right align
2079 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
2080 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
2081 } else { // left align
2083 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
2086 if(autocvar_hud_panel_powerups_progressbar)
2088 HUD_Panel_GetProgressBarColor(leftname)
2089 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);
2092 DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
2094 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));
2099 if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // left align
2100 barpos = pos + eY * 0.5 * mySize_y;
2101 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
2102 } else { // right align
2103 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
2104 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
2107 if(autocvar_hud_panel_powerups_progressbar)
2109 HUD_Panel_GetProgressBarColor(rightname)
2110 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);
2113 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);
2115 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));
2122 if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // down align
2123 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
2124 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
2125 } else { // up align
2127 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
2130 if(autocvar_hud_panel_powerups_iconalign == 1 || autocvar_hud_panel_powerups_iconalign == 3) { // down align
2131 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2132 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2133 } else { // up align
2134 picpos = pos + eX * 0.05 * mySize_x;
2135 numpos = pos + eY * 0.4 * mySize_x;
2138 if(autocvar_hud_panel_powerups_progressbar)
2140 HUD_Panel_GetProgressBarColor(leftname)
2141 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);
2144 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));
2146 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2147 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2152 if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // up align
2153 barpos = pos + eX * 0.5 * mySize_x;
2154 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2155 } else { // down align
2156 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
2157 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2160 if(autocvar_hud_panel_powerups_iconalign == 0 || autocvar_hud_panel_powerups_iconalign == 3) { // up align
2161 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2162 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2163 } else { // down align
2164 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2165 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2168 if(autocvar_hud_panel_powerups_progressbar)
2170 HUD_Panel_GetProgressBarColor(rightname)
2171 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);
2174 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));
2176 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2177 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2180 drawfont = hud_font;
2183 // Health/armor (#3)
2185 void HUD_HealthArmor(void)
2187 if(!autocvar_hud_panel_healtharmor && !autocvar__hud_configure)
2190 active_panel = HUD_PANEL_HEALTHARMOR;
2191 HUD_Panel_UpdateCvars(healtharmor);
2194 mySize = panel_size;
2196 HUD_Panel_DrawBg(1);
2197 if(panel_bg_padding)
2199 pos += '1 1 0' * panel_bg_padding;
2200 mySize -= '2 2 0' * panel_bg_padding;
2203 float armor, health;
2204 armor = getstati(STAT_ARMOR);
2205 health = getstati(STAT_HEALTH);
2208 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
2210 if(autocvar__hud_configure)
2220 vector barpos, barsize;
2224 drawfont = hud_bigfont;
2225 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
2228 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2233 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
2234 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2235 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2236 } else { // left align
2238 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2242 if(v_z) // NOT fully armored
2244 biggercount = "health";
2245 if(autocvar_hud_panel_healtharmor_progressbar)
2247 HUD_Panel_GetProgressBarColor("health")
2248 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2251 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);
2255 biggercount = "armor";
2256 if(autocvar_hud_panel_healtharmor_progressbar)
2258 HUD_Panel_GetProgressBarColor("armor")
2259 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2262 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);
2264 DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200), 1);
2269 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2270 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2271 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2274 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2276 HUD_Panel_GetProgressBarColor("fuel")
2277 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2282 string leftname, rightname;
2283 float leftcnt, rightcnt;
2284 float leftactive, rightactive;
2285 float leftalpha, rightalpha;
2286 if (autocvar_hud_panel_healtharmor_flip) { // old style layout with armor left/top of health
2291 leftalpha = min((armor+10)/55, 1);
2293 rightname = "health";
2298 leftname = "health";
2303 rightname = "armor";
2307 rightalpha = min((armor+10)/55, 1);
2310 if (mySize_x/mySize_y > 4)
2314 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
2315 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2316 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2317 } else { // left align
2319 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2322 if(autocvar_hud_panel_healtharmor_progressbar)
2324 HUD_Panel_GetProgressBarColor(leftname)
2325 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2327 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);
2332 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2333 barpos = pos + eX * 0.5 * mySize_x;
2334 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2335 } else { // right align
2336 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2337 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2340 if(autocvar_hud_panel_healtharmor_progressbar)
2342 HUD_Panel_GetProgressBarColor(rightname)
2343 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2345 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);
2350 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2351 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2352 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2355 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2357 HUD_Panel_GetProgressBarColor("fuel")
2358 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2361 else if (mySize_x/mySize_y > 1.5)
2365 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
2366 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2367 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2368 } else { // left align
2370 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2373 if(autocvar_hud_panel_healtharmor_progressbar)
2375 HUD_Panel_GetProgressBarColor(leftname)
2376 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2378 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);
2383 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2384 barpos = pos + eY * 0.5 * mySize_y;
2385 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2386 } else { // right align
2387 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2388 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2391 if(autocvar_hud_panel_healtharmor_progressbar)
2393 HUD_Panel_GetProgressBarColor(rightname)
2394 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2396 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);
2401 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2402 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2403 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2406 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2408 HUD_Panel_GetProgressBarColor("fuel")
2409 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2416 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // down align
2417 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2418 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2419 } else { // up align
2421 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2424 if(autocvar_hud_panel_healtharmor_iconalign == 1 || autocvar_hud_panel_healtharmor_iconalign == 3) { // down align
2425 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2426 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2427 } else { // up align
2428 picpos = pos + eX * 0.05 * mySize_x;
2429 numpos = pos + eY * 0.4 * mySize_x;
2432 if(autocvar_hud_panel_healtharmor_progressbar)
2434 HUD_Panel_GetProgressBarColor(leftname)
2435 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2437 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2438 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);
2443 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // up align
2444 barpos = pos + eX * 0.5 * mySize_x;
2445 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2446 } else { // down align
2447 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2448 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2451 if(autocvar_hud_panel_healtharmor_iconalign == 0 || autocvar_hud_panel_healtharmor_iconalign == 3) { // up align
2452 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2453 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2454 } else { // down align
2455 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2456 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2459 if(autocvar_hud_panel_healtharmor_progressbar)
2461 HUD_Panel_GetProgressBarColor(rightname)
2462 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2464 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2465 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);
2470 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2472 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2474 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2475 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2477 HUD_Panel_GetProgressBarColor("fuel")
2478 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2482 drawfont = hud_font;
2485 // Notification area (#4)
2488 string Weapon_SuicideMessage(float deathtype)
2490 w_deathtype = deathtype;
2491 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2492 return w_deathtypestring;
2495 string Weapon_KillMessage(float deathtype)
2497 w_deathtype = deathtype;
2498 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2499 return w_deathtypestring;
2502 float killnotify_times[10];
2503 float killnotify_deathtype[10];
2504 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2505 string killnotify_attackers[10];
2506 string killnotify_victims[10];
2507 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2510 for (i = 9; i > 0; --i) {
2511 killnotify_times[i] = killnotify_times[i-1];
2512 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2513 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2514 if(killnotify_attackers[i])
2515 strunzone(killnotify_attackers[i]);
2516 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2517 if(killnotify_victims[i])
2518 strunzone(killnotify_victims[i]);
2519 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2521 killnotify_times[0] = time;
2522 killnotify_deathtype[0] = wpn;
2523 killnotify_actiontype[0] = actiontype;
2524 if(killnotify_attackers[0])
2525 strunzone(killnotify_attackers[0]);
2526 killnotify_attackers[0] = strzone(attacker);
2527 if(killnotify_victims[0])
2528 strunzone(killnotify_victims[0]);
2529 killnotify_victims[0] = strzone(victim);
2532 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2535 float alsoprint, gentle;
2536 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2537 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2539 if(msg == MSG_SUICIDE) {
2540 w = DEATH_WEAPONOF(type);
2542 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2544 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
2545 } else if (type == DEATH_KILL) {
2546 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2548 print ("^1",s1, "^1 couldn't take it anymore\n");
2549 } else if (type == DEATH_ROT) {
2550 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2552 print ("^1",s1, "^1 died\n");
2553 } else if (type == DEATH_NOAMMO) {
2554 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2556 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2557 } else if (type == DEATH_CAMP) {
2558 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2560 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2561 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2562 HUD_KillNotify_Push(s1, "", 0, type);
2564 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2565 } else if (type == DEATH_CHEAT) {
2566 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2568 print ("^1",s1, "^1 unfairly eliminated themself\n");
2569 } else if (type == DEATH_FIRE) {
2570 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2572 print ("^1",s1, "^1 burned to death\n");
2573 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2574 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2576 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2579 if (stof(s2) > 2) // killcount > 2
2580 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2581 } else if(msg == MSG_KILL) {
2582 w = DEATH_WEAPONOF(type);
2584 HUD_KillNotify_Push(s1, s2, 1, type);
2586 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
2588 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2589 HUD_KillNotify_Push(s1, s2, 1, type);
2593 print ("^1", s1, "^1 took action against a team mate\n");
2595 print ("^1", s1, "^1 mows down a team mate\n");
2598 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2600 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2602 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2604 else if (stof(s2) > 2) {
2606 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2608 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2611 else if(type == KILL_FIRST_BLOOD)
2612 print("^1",s1, "^1 drew first blood", "\n");
2614 else if (type == DEATH_TELEFRAG)
2615 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2616 else if (type == DEATH_DROWN) {
2617 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2619 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2621 else if (type == DEATH_SLIME) {
2622 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2624 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2626 else if (type == DEATH_LAVA) {
2627 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2629 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2631 else if (type == DEATH_FALL) {
2632 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2634 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2636 else if (type == DEATH_SHOOTING_STAR) {
2637 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2639 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2641 else if (type == DEATH_SWAMP) {
2642 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2644 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2646 else if (type == DEATH_HURTTRIGGER)
2648 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2650 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2651 } else if(type == DEATH_SBCRUSH) {
2652 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2654 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2655 } else if(type == DEATH_SBMINIGUN) {
2656 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2658 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2659 } else if(type == DEATH_SBROCKET) {
2660 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2662 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2663 } else if(type == DEATH_SBBLOWUP) {
2664 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2666 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2667 } else if(type == DEATH_WAKIGUN) {
2668 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2670 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2671 } else if(type == DEATH_WAKIROCKET) {
2672 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2674 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2675 } else if(type == DEATH_WAKIBLOWUP) {
2676 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2678 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2679 } else if(type == DEATH_TURRET) {
2680 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2682 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2683 } else if(type == DEATH_TOUCHEXPLODE) {
2684 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2686 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2687 } else if(type == DEATH_CHEAT) {
2688 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2690 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2691 } else if (type == DEATH_FIRE) {
2692 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2694 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2695 } else if (type == DEATH_CUSTOM) {
2696 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2698 print ("^1",s1, "^1 ", s2, "\n");
2700 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2702 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2704 } else if(msg == MSG_SPREE) {
2705 if(type == KILL_END_SPREE) {
2707 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2709 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2710 } else if(type == KILL_SPREE) {
2712 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2714 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2715 } else if(type == KILL_SPREE_3) {
2717 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2719 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2720 } else if(type == KILL_SPREE_5) {
2722 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2724 print (s1,"^7 unleashes ^1RAGE\n");
2725 } else if(type == KILL_SPREE_10) {
2727 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2729 print (s1,"^7 starts the ^1MASSACRE!\n");
2730 } else if(type == KILL_SPREE_15) {
2732 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2734 print (s1,"^7 executes ^1MAYHEM!\n");
2735 } else if(type == KILL_SPREE_20) {
2737 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2739 print (s1,"^7 is a ^1BERSERKER!\n");
2740 } else if(type == KILL_SPREE_25) {
2742 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2744 print (s1,"^7 inflicts ^1CARNAGE!\n");
2745 } else if(type == KILL_SPREE_30) {
2747 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2749 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2751 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2752 if (type == DEATH_DROWN) {
2753 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2757 print ("^1",s1, "^1 was in the water for too long\n");
2759 print ("^1",s1, "^1 drowned\n");
2761 } else if (type == DEATH_SLIME) {
2762 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2764 print ("^1",s1, "^1 was slimed\n");
2765 } else if (type == DEATH_LAVA) {
2766 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2770 print ("^1",s1, "^1 found a hot place\n");
2772 print ("^1",s1, "^1 turned into hot slag\n");
2774 } else if (type == DEATH_FALL) {
2775 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2779 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2781 print ("^1",s1, "^1 hit the ground with a crunch\n");
2783 } else if (type == DEATH_SHOOTING_STAR) {
2784 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2786 print ("^1",s1, "^1 became a shooting star\n");
2787 } else if (type == DEATH_SWAMP) {
2788 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2792 print ("^1",s1, "^1 discovered a swamp\n");
2794 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2796 } else if(type == DEATH_TURRET) {
2797 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2799 print ("^1",s1, "^1 was mowed down by a turret \n");
2800 } else if (type == DEATH_CUSTOM) {
2801 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2803 print ("^1",s1, "^1 ", s2, "\n");
2804 } else if (type == DEATH_HURTTRIGGER) {
2805 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2807 print ("^1",s1, "^1 was in the wrong place\n");
2808 } else if(type == DEATH_TOUCHEXPLODE) {
2809 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2811 print ("^1",s1, "^1 died in an accident\n");
2812 } else if(type == DEATH_CHEAT) {
2813 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2815 print ("^1",s1, "^1 was unfairly eliminated\n");
2816 } else if(type == DEATH_FIRE) {
2817 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2821 print ("^1",s1, "^1 felt a little hot\n");
2823 print ("^1",s1, "^1 burnt to death\n");
2826 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2830 print ("^1",s1, "^1 needs a restart\n");
2832 print ("^1",s1, "^1 died\n");
2835 } else if(msg == MSG_KILL_ACTION_SPREE) {
2837 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2839 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2840 } else if(msg == MSG_INFO) {
2841 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2842 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2843 print(s1, "^7 got the ", s2, "\n");
2844 } else if(type == INFO_LOSTFLAG) {
2845 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2846 print(s1, "^7 lost the ", s2, "\n");
2847 } else if(type == INFO_PICKUPFLAG) {
2848 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2849 print(s1, "^7 picked up the ", s2, "\n");
2850 } else if(type == INFO_RETURNFLAG) {
2851 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2852 print(s1, "^7 returned the ", s2, "\n");
2853 } else if(type == INFO_CAPTUREFLAG) {
2854 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
2855 print(s1, "^7 captured the ", s2, s3, "\n");
2860 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2862 void HUD_Centerprint(string s1, string s2, float type, float msg)
2865 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2866 if(msg == MSG_SUICIDE) {
2867 if (type == DEATH_TEAMCHANGE) {
2868 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2869 } else if (type == DEATH_AUTOTEAMCHANGE) {
2870 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2871 } else if (type == DEATH_CAMP) {
2873 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2875 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2876 } else if (type == DEATH_NOAMMO) {
2878 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2880 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2881 } else if (type == DEATH_ROT) {
2883 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2885 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2886 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2888 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2890 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2891 } else if (type == DEATH_QUIET) {
2893 } else if (type == DEATH_KILL) {
2895 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2897 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2899 } else if(msg == MSG_KILL) {
2900 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2902 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2904 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2906 } else if (type == KILL_FIRST_BLOOD) {
2908 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2910 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2912 } else if (type == KILL_FIRST_VICTIM) {
2914 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2916 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2918 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2920 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2922 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2924 } else if (type == KILL_TYPEFRAGGED) {
2926 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2928 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2930 } else if (type == KILL_FRAG) {
2932 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2934 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2936 } else if (type == KILL_FRAGGED) {
2938 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2940 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2943 } else if(msg == MSG_KILL_ACTION) {
2944 // TODO: invent more centerprints here?
2945 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2949 void HUD_Notify (void)
2951 if(!autocvar_hud_panel_notify && !autocvar__hud_configure)
2954 active_panel = HUD_PANEL_NOTIFY;
2955 HUD_Panel_UpdateCvars(notify);
2958 mySize = panel_size;
2960 HUD_Panel_DrawBg(1);
2961 if(panel_bg_padding)
2963 pos += '1 1 0' * panel_bg_padding;
2964 mySize -= '2 2 0' * panel_bg_padding;
2967 float entries, height;
2968 entries = bound(1, floor(10 * mySize_y/mySize_x), 10);
2969 height = mySize_y/entries;
2972 fontsize = '0.5 0.5 0' * height;
2976 when = autocvar_hud_panel_notify_time;
2978 fadetime = autocvar_hud_panel_notify_fadetime;
2982 vector pos_attacker, pos_victim;
2984 float width_attacker;
2985 string attacker, victim;
2988 for(j = 0; j < entries; ++j)
2991 if(autocvar_hud_panel_notify_flip)
2993 else // rather nasty hack for ordering items from the bottom up
2994 i = entries - j - 1;
2998 if(killnotify_times[j] + when > time)
3001 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
3005 if(killnotify_times[j] + when > time)
3012 w = DEATH_WEAPONOF(killnotify_deathtype[j]);
3014 // TODO: maybe print in team colors?
3017 if(killnotify_actiontype[j] == 0 && !autocvar__hud_configure)
3019 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3020 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
3021 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
3023 if(killnotify_deathtype[j] == DEATH_GENERIC)
3027 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
3029 s = "notify_outofammo";
3031 else if(killnotify_deathtype[j] == DEATH_KILL)
3033 s = "notify_selfkill";
3035 else if(killnotify_deathtype[j] == DEATH_CAMP)
3037 s = "notify_camping";
3039 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
3041 s = "notify_teamkill_red";
3043 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
3045 s = "notify_teamkill_blue";
3047 else if(killnotify_deathtype[j] == DEATH_DROWN)
3051 else if(killnotify_deathtype[j] == DEATH_SLIME)
3055 else if(killnotify_deathtype[j] == DEATH_LAVA)
3059 else if(killnotify_deathtype[j] == DEATH_FALL)
3063 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
3065 s = "notify_shootingstar";
3067 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
3071 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
3073 if(killnotify_victims[j] == "^1RED^7 flag")
3075 s = "notify_red_taken";
3079 s = "notify_blue_taken";
3082 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
3084 if(killnotify_victims[j] == "^1RED^7 flag")
3086 s = "notify_red_returned";
3090 s = "notify_blue_returned";
3093 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
3095 if(killnotify_victims[j] == "^1RED^7 flag")
3097 s = "notify_red_lost";
3101 s = "notify_blue_lost";
3104 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
3106 if(killnotify_victims[j] == "^1RED^7 flag")
3108 s = "notify_red_captured";
3112 s = "notify_blue_captured";
3117 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3118 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3121 // X [did action to] Y
3124 if(autocvar__hud_configure)
3126 attacker = textShortenToWidth("Player1", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3127 victim = textShortenToWidth("Player2", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3128 a = bound(0, (when - j) / 4, 1);
3132 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3133 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
3135 width_attacker = stringwidth(attacker, TRUE, fontsize);
3136 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
3137 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
3138 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
3140 if(autocvar__hud_configure) // example actions for config mode
3142 s = "weaponelectro";
3144 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
3146 s = "notify_melee_laser";
3148 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_SHOTGUN)
3150 s = "notify_melee_shotgun";
3152 else if(WEP_VALID(w))
3154 self = get_weaponinfo(w);
3155 s = strcat("weapon", self.netname);
3157 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
3159 s = "notify_teamkill_red";
3161 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
3163 s = "notify_teamkill_red";
3165 else if(killnotify_deathtype[j] == DEATH_DROWN)
3169 else if(killnotify_deathtype[j] == DEATH_SLIME)
3173 else if(killnotify_deathtype[j] == DEATH_LAVA)
3177 else if(killnotify_deathtype[j] == DEATH_FALL)
3181 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
3183 s = "notify_shootingstar";
3185 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
3191 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3192 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3193 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3202 string seconds_tostring(float sec)
3205 minutes = floor(sec / 60);
3207 sec -= minutes * 60;
3210 s = ftos(100 + sec);
3212 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3215 void HUD_Timer(void)
3217 if(!autocvar_hud_panel_timer && !autocvar__hud_configure)
3220 active_panel = HUD_PANEL_TIMER;
3221 HUD_Panel_UpdateCvars(timer);
3224 mySize = panel_size;
3226 HUD_Panel_DrawBg(1);
3227 if(panel_bg_padding)
3229 pos += '1 1 0' * panel_bg_padding;
3230 mySize -= '2 2 0' * panel_bg_padding;
3234 float timelimit, elapsedTime, timeleft, minutesLeft;
3236 timelimit = getstatf(STAT_TIMELIMIT);
3238 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3239 timeleft = ceil(timeleft);
3241 minutesLeft = floor(timeleft / 60);
3244 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3245 timer_color = '1 1 1'; //white
3246 else if(minutesLeft >= 1)
3247 timer_color = '1 1 0'; //yellow
3249 timer_color = '1 0 0'; //red
3251 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
3252 if (time < getstatf(STAT_GAMESTARTTIME)) {
3253 //while restart is still active, show 00:00
3254 timer = seconds_tostring(0);
3256 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3257 timer = seconds_tostring(elapsedTime);
3260 timer = seconds_tostring(timeleft);
3263 drawfont = hud_bigfont;
3264 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3265 drawfont = hud_font;
3270 void HUD_Radar(void)
3272 if ((autocvar_hud_panel_radar == 0 || (autocvar_hud_panel_radar != 2 && !teamplay)) && !autocvar__hud_configure)
3275 active_panel = HUD_PANEL_RADAR;
3276 HUD_Panel_UpdateCvars(radar);
3279 mySize = panel_size;
3281 HUD_Panel_DrawBg(1);
3282 if(panel_bg_padding)
3284 pos += '1 1 0' * panel_bg_padding;
3285 mySize -= '2 2 0' * panel_bg_padding;
3288 local float color1, color2; // color already declared as a global in hud.qc
3291 float scale2d, normalsize, bigsize;
3294 teamradar_origin2d = pos + 0.5 * mySize;
3295 teamradar_size2d = mySize;
3297 if(minimapname == "")
3300 teamradar_loadcvars();
3302 switch(hud_panel_radar_zoommode)
3306 f = current_zoomfraction;
3309 f = 1 - current_zoomfraction;
3319 switch(hud_panel_radar_rotation)
3322 teamradar_angle = view_angles_y - 90;
3325 teamradar_angle = 90 * hud_panel_radar_rotation;
3329 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3330 teamradar_size2d = mySize;
3332 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3334 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3335 if(hud_panel_radar_rotation == 0)
3337 // max-min distance must fit the radar in any rotation
3338 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3342 vector c0, c1, c2, c3, span;
3343 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3344 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3345 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3346 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3348 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3349 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3351 // max-min distance must fit the radar in x=x, y=y
3353 teamradar_size2d_x * scale2d / (1.05 * span_x),
3354 teamradar_size2d_y * scale2d / (1.05 * span_y)
3358 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
3359 if(bigsize > normalsize)
3360 normalsize = bigsize;
3364 + (1 - f) * normalsize;
3365 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3366 f * (mi_min + mi_max) * 0.5
3367 + (1 - f) * view_origin);
3369 color1 = GetPlayerColor(player_localentnum-1);
3370 rgb = GetTeamRGB(color1);
3379 draw_teamradar_background(hud_panel_radar_foreground_alpha);
3381 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3382 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3383 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3384 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3385 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3387 color2 = GetPlayerColor(tm.sv_entnum);
3388 //if(color == COLOR_SPECTATOR || color == color2)
3389 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3391 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3393 drawresetcliparea();
3398 void HUD_Score(void)
3400 if(!autocvar_hud_panel_score && !autocvar__hud_configure)
3403 active_panel = HUD_PANEL_SCORE;
3404 HUD_Panel_UpdateCvars(score);
3407 mySize = panel_size;
3409 HUD_Panel_DrawBg(1);
3410 if(panel_bg_padding)
3412 pos += '1 1 0' * panel_bg_padding;
3413 mySize -= '2 2 0' * panel_bg_padding;
3416 float score, distribution, leader;
3417 vector distribution_color;
3419 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3421 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3422 string timer, distrtimer;
3424 pl = players.sort_next;
3427 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3428 if(pl.scores[ps_primary] == 0)
3431 score = me.(scores[ps_primary]);
3432 timer = TIME_ENCODED_TOSTRING(score);
3434 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3435 // distribution display
3436 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3438 distrtimer = ftos(distribution/pow(10, TIME_DECIMALS));
3440 if (distribution <= 0) {
3441 distribution_color = '0 1 0';
3444 distribution_color = '1 0 0';
3446 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);
3448 // race record display
3449 if (distribution <= 0)
3450 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3451 drawfont = hud_bigfont;
3452 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3453 drawfont = hud_font;
3454 } else if (!teamplay) { // non-teamgames
3455 // me vector := [team/connected frags id]
3456 pl = players.sort_next;
3460 if(autocvar__hud_configure)
3463 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3467 score = me.(scores[ps_primary]);
3468 if(autocvar__hud_configure)
3471 if(distribution >= 5) {
3472 distribution_color = eY;
3474 } else if(distribution >= 0) {
3475 distribution_color = '1 1 1';
3477 } else if(distribution >= -5)
3478 distribution_color = '1 1 0';
3480 distribution_color = eX;
3482 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);
3484 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3485 drawfont = hud_bigfont;
3486 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3487 drawfont = hud_font;
3488 } else { // teamgames
3489 float max_fragcount;
3490 max_fragcount = -99;
3493 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3494 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !autocvar__hud_configure)) // no players? don't display
3496 score = tm.(teamscores[ts_primary]);
3497 if(autocvar__hud_configure)
3501 if (score > max_fragcount)
3502 max_fragcount = score;
3504 if(tm.team == myteam) {
3505 if (max_fragcount == score)
3508 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3509 drawfont = hud_bigfont;
3510 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3511 drawfont = hud_font;
3513 if (max_fragcount == score)
3516 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);
3517 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);
3526 void HUD_RaceTimer (void) {
3527 if(!autocvar_hud_panel_racetimer && !(gametype == GAME_RACE || gametype == GAME_CTS) && !autocvar__hud_configure)
3530 active_panel = HUD_PANEL_RACETIMER;
3531 HUD_Panel_UpdateCvars(racetimer);
3534 mySize = panel_size;
3536 HUD_Panel_DrawBg(1);
3537 if(panel_bg_padding)
3539 pos += '1 1 0' * panel_bg_padding;
3540 mySize -= '2 2 0' * panel_bg_padding;
3543 // always force 4:1 aspect
3545 if(mySize_x/mySize_y > 4)
3547 newSize_x = 4 * mySize_y;
3548 newSize_y = mySize_y;
3550 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3554 newSize_y = 1/4 * mySize_x;
3555 newSize_x = mySize_x;
3557 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3561 drawfont = hud_bigfont;
3563 string s, forcetime;
3565 if(autocvar__hud_configure)
3568 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);
3569 s = "^1Intermediate 1 (+15.42)";
3570 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);
3571 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3572 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);
3574 else if(race_checkpointtime)
3576 a = bound(0, 2 - (time - race_checkpointtime), 1);
3579 if(a > 0) // just hit a checkpoint?
3581 if(race_checkpoint != 254)
3583 if(race_time && race_previousbesttime)
3584 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3586 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3588 forcetime = TIME_ENCODED_TOSTRING(race_time);
3593 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3595 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3596 if(a > 0) // next one?
3598 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3603 if(s != "" && a > 0)
3605 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);
3608 if(race_penaltytime)
3610 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3613 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3614 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);
3620 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3621 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);
3626 if(race_laptime && race_checkpoint != 255)
3628 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3629 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);
3634 if(race_mycheckpointtime)
3636 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3637 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3638 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);
3640 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3642 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3643 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3644 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);
3647 if(race_penaltytime && !race_penaltyaccumulator)
3649 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3650 a = bound(0, (1 + t - time), 1);
3654 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3656 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3657 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);
3662 drawfont = hud_font;
3667 float vote_yescount;
3670 float vote_highlighted; // currently selected vote
3672 float vote_active; // is there an active vote?
3673 float vote_prev; // previous state of vote_active to check for a change
3675 float vote_change; // "time" when vote_active changed
3677 void HUD_VoteWindow(void)
3679 if(!autocvar_hud_panel_vote && !autocvar__hud_configure)
3682 active_panel = HUD_PANEL_VOTE;
3683 HUD_Panel_UpdateCvars(vote);
3686 mySize = panel_size;
3690 if(vote_active != vote_prev) {
3692 vote_prev = vote_active;
3695 if(vote_active || autocvar__hud_configure)
3696 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3698 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3700 if(autocvar__hud_configure)
3710 a = vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3712 HUD_Panel_DrawBg(a);
3713 if(panel_bg_padding)
3715 pos += '1 1 0' * panel_bg_padding;
3716 mySize -= '2 2 0' * panel_bg_padding;
3719 // always force 3:1 aspect
3721 if(mySize_x/mySize_y > 3)
3723 newSize_x = 3 * mySize_y;
3724 newSize_y = mySize_y;
3726 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3730 newSize_y = 1/3 * mySize_x;
3731 newSize_x = mySize_x;
3733 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3737 s = "A vote has been called for:";
3738 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3739 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1.75/8), stringwidth_colors);
3740 if(autocvar__hud_configure)
3741 s = "^1Configure the HUD";
3742 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3744 // print the yes/no counts
3745 s = strcat("Yes (", getcommandkey("not bound", "vyes"), "): ", ftos(vote_yescount));
3746 drawstring_aspect(pos + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '0 1 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3747 s = strcat("No (", getcommandkey("not bound", "vno"), "): ", ftos(vote_nocount));
3748 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 * panel_fg_alpha, DRAWFLAG_NORMAL);
3750 // draw the progress bar backgrounds
3751 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3753 // draw the highlights
3754 if(vote_highlighted == 1) {
3755 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3756 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '0 1 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3758 else if(vote_highlighted == 2) {
3759 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3760 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '0 1 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3763 // draw the progress bars
3764 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3765 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '0 1 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3767 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3768 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 0 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3770 drawresetcliparea();
3773 vote_highlighted = 0;
3777 // Mod icons panel (#10)
3780 float mod_active; // is there any active mod icon?
3782 // CTF HUD modicon section
3783 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3784 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3785 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3787 void HUD_Mod_CTF_Reset(void)
3789 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3792 void HUD_Mod_CTF(vector pos, vector mySize)
3794 vector redflag_pos, blueflag_pos;
3796 float f; // every function should have that
3798 float redflag, blueflag; // current status
3799 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3802 stat_items = getstati(STAT_ITEMS);
3803 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3804 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3806 if(redflag || blueflag)
3811 if(autocvar__hud_configure)
3817 // when status CHANGES, set old status into prevstatus and current status into status
3818 if (redflag != redflag_prevframe)
3820 redflag_statuschange_time = time;
3821 redflag_prevstatus = redflag_prevframe;
3822 redflag_prevframe = redflag;
3825 if (blueflag != blueflag_prevframe)
3827 blueflag_statuschange_time = time;
3828 blueflag_prevstatus = blueflag_prevframe;
3829 blueflag_prevframe = blueflag;
3832 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3833 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3835 float BLINK_FACTOR = 0.15;
3836 float BLINK_BASE = 0.85;
3838 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3840 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3842 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3844 string red_icon, red_icon_prevstatus;
3845 float red_alpha, red_alpha_prevstatus;
3846 red_alpha = red_alpha_prevstatus = 1;
3848 case 1: red_icon = "flag_red_taken"; break;
3849 case 2: red_icon = "flag_red_lost"; break;
3850 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3852 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3853 red_icon = "flag_red_shielded";
3855 red_icon = string_null;
3858 switch(redflag_prevstatus) {
3859 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3860 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3861 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3864 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3865 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3866 red_icon_prevstatus = "flag_red_shielded";
3868 red_icon_prevstatus = string_null;
3872 string blue_icon, blue_icon_prevstatus;
3873 float blue_alpha, blue_alpha_prevstatus;
3874 blue_alpha = blue_alpha_prevstatus = 1;
3876 case 1: blue_icon = "flag_blue_taken"; break;
3877 case 2: blue_icon = "flag_blue_lost"; break;
3878 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3880 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3881 blue_icon = "flag_blue_shielded";
3883 blue_icon = string_null;
3886 switch(blueflag_prevstatus) {
3887 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3888 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3889 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3892 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3893 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3894 blue_icon_prevstatus = "flag_blue_shielded";
3896 blue_icon_prevstatus = string_null;
3900 if(mySize_x > mySize_y) {
3901 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3903 blueflag_pos = pos + eX * 0.5 * mySize_x;
3906 redflag_pos = pos + eX * 0.5 * mySize_x;
3908 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3910 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3912 blueflag_pos = pos + eY * 0.5 * mySize_y;
3915 redflag_pos = pos + eY * 0.5 * mySize_y;
3917 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3920 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3921 if(red_icon_prevstatus && f < 1)
3922 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3924 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3926 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3927 if(blue_icon_prevstatus && f < 1)
3928 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3930 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3933 // Keyhunt HUD modicon section
3934 float kh_runheretime;
3936 void HUD_Mod_KH_Reset(void)
3941 void HUD_Mod_KH(vector pos, vector mySize)
3943 mod_active = 1; // keyhunt should never hide the mod icons panel
3947 vector p, pa, kh_size, kh_asize;
3949 kh_keys = getstati(STAT_KH_KEYS);
3952 if(mySize_x > mySize_y)
3954 p_y = pos_y + 0.25 * mySize_y;
3955 pa = p - eY * 0.25 * mySize_y;
3957 kh_size_x = mySize_x * 0.25;
3958 kh_size_y = 0.75 * mySize_y;
3959 kh_asize_x = mySize_x * 0.25;
3960 kh_asize_y = mySize_y * 0.25;
3964 p_y = pos_y + 0.125 * mySize_y;
3965 pa = p - eY * 0.125 * mySize_y;
3967 kh_size_x = mySize_x * 0.5;
3968 kh_size_y = 0.375 * mySize_y;
3969 kh_asize_x = mySize_x * 0.5;
3970 kh_asize_y = mySize_y * 0.125;
3977 for(i = 0; i < 4; ++i)
3979 key = floor(kh_keys / pow(32, i)) & 31;
3981 if(keyteam == 30 && keycount <= 4)
3983 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3987 // this yields 8 exactly if "RUN HERE" shows
3992 kh_runheretime = time;
3993 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3998 for(i = 0; i < 4; ++i)
4000 key = floor(kh_keys / pow(32, i)) & 31;
4013 default: // owned or dropped
4018 a = a * panel_fg_alpha;
4019 aa = aa * panel_fg_alpha;
4025 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4028 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4031 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4034 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4039 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
4042 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4045 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4048 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4051 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4055 if(mySize_x > mySize_y)
4057 p_x += 0.25 * mySize_x;
4058 pa_x += 0.25 * mySize_x;
4064 p_y = pos_y + 0.625 * mySize_y;
4065 pa_y = pos_y + 0.5 * mySize_y;
4071 p_x += 0.5 * mySize_x;
4072 pa_x += 0.5 * mySize_x;
4078 // Nexball HUD mod icon
4079 void HUD_Mod_NexBall(vector pos, vector mySize)
4081 float stat_items, nb_pb_starttime, dt, p;
4083 stat_items = getstati(STAT_ITEMS);
4084 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
4086 if (stat_items & IT_KEY1)
4091 //Manage the progress bar if any
4092 if (nb_pb_starttime > 0)
4094 dt = mod(time - nb_pb_starttime, nb_pb_period);
4095 // one period of positive triangle
4096 p = 2 * dt / nb_pb_period;
4103 if(mySize_x > mySize_y)
4105 barsize = eX * p * mySize_x + eY * mySize_y;
4110 barsize = eX * mySize_x + eY * p * mySize_y;
4113 HUD_Panel_GetProgressBarColor("nexball")
4114 HUD_Panel_DrawProgressBar(pos, vertical, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4117 if (stat_items & IT_KEY1)
4118 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4121 // Race/CTS HUD mod icons
4122 float crecordtime_prev; // last remembered crecordtime
4123 float crecordtime_change_time; // time when crecordtime last changed
4124 float srecordtime_prev; // last remembered srecordtime
4125 float srecordtime_change_time; // time when srecordtime last changed
4127 float race_status_time;
4128 float race_status_prev;
4129 string race_status_name_prev;
4130 void HUD_Mod_Race(vector pos, vector mySize)
4132 mod_active = 1; // race should never hide the mod icons panel
4134 me = playerslots[player_localentnum - 1];
4136 float f; // yet another function has this
4137 score = me.(scores[ps_primary]);
4139 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
4140 return; // no records in the actual race
4142 drawfont = hud_bigfont;
4144 // clientside personal record
4146 if(gametype == GAME_CTS)
4150 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4152 if(score && (score < t || !t)) {
4153 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4154 if(cvar("cl_autodemo_delete_keeprecords"))
4156 f = cvar("cl_autodemo_delete");
4158 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4162 if(t != crecordtime_prev) {
4163 crecordtime_prev = t;
4164 crecordtime_change_time = time;
4166 f = time - crecordtime_change_time;
4169 drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4170 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);
4172 drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4173 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);
4174 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);
4175 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);
4179 t = race_server_record;
4180 if(t != srecordtime_prev) {
4181 srecordtime_prev = t;
4182 srecordtime_change_time = time;
4184 f = time - srecordtime_change_time;
4187 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);
4188 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);
4190 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);
4191 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);
4192 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);
4193 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);
4196 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4197 race_status_time = time + 5;
4198 race_status_prev = race_status;
4199 if (race_status_name_prev)
4200 strunzone(race_status_name_prev);
4201 race_status_name_prev = strzone(race_status_name);
4204 pos_x += mySize_x/2;
4207 a = bound(0, race_status_time - time, 1);
4210 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4214 rank = race_CheckName(race_status_name);
4216 rankname = race_PlaceName(rank);
4219 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4221 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4223 if(race_status == 0)
4224 drawpic_aspect_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4225 else if(race_status == 1) {
4226 drawpic_aspect_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4227 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4228 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4229 } else if(race_status == 2) {
4230 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4231 drawpic_aspect_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4233 drawpic_aspect_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4234 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4235 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4236 } else if(race_status == 3) {
4237 drawpic_aspect_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4238 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4239 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4242 if (race_status_time - time <= 0) {
4243 race_status_prev = -1;
4245 if(race_status_name)
4246 strunzone(race_status_name);
4247 race_status_name = string_null;
4248 if(race_status_name_prev)
4249 strunzone(race_status_name_prev);
4250 race_status_name_prev = string_null;
4252 drawfont = hud_font;
4255 float mod_prev; // previous state of mod_active to check for a change
4257 float mod_change; // "time" when mod_active changed
4259 void HUD_ModIcons(void)
4261 if(!autocvar_hud_panel_modicons && !autocvar__hud_configure)
4264 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !autocvar__hud_configure)
4267 active_panel = HUD_PANEL_MODICONS;
4268 HUD_Panel_UpdateCvars(modicons);
4271 mySize = panel_size;
4273 if(mod_active != mod_prev) {
4275 mod_prev = mod_active;
4278 if(mod_active || autocvar__hud_configure)
4279 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4281 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4284 HUD_Panel_DrawBg(mod_alpha);
4286 if(panel_bg_padding)
4288 pos += '1 1 0' * panel_bg_padding;
4289 mySize -= '2 2 0' * panel_bg_padding;
4292 // these MUST be ran in order to update mod_active
4293 if(gametype == GAME_KEYHUNT)
4294 HUD_Mod_KH(pos, mySize);
4295 else if(gametype == GAME_CTF || autocvar__hud_configure)
4296 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4297 else if(gametype == GAME_NEXBALL)
4298 HUD_Mod_NexBall(pos, mySize);
4299 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4300 HUD_Mod_Race(pos, mySize);
4303 // Draw pressed keys (#11)
4305 void HUD_DrawPressedKeys(void)
4307 if(!autocvar_hud_panel_pressedkeys && !autocvar__hud_configure)
4310 if(!(spectatee_status > 0 || autocvar_hud_panel_pressedkeys >= 2 || autocvar__hud_configure))
4313 active_panel = HUD_PANEL_PRESSEDKEYS;
4314 HUD_Panel_UpdateCvars(pressedkeys);
4317 mySize = panel_size;
4319 HUD_Panel_DrawBg(1);
4320 if(panel_bg_padding)
4322 pos += '1 1 0' * panel_bg_padding;
4323 mySize -= '2 2 0' * panel_bg_padding;
4326 // force custom aspect
4327 if(autocvar_hud_panel_pressedkeys_aspect)
4330 if(mySize_x/mySize_y > autocvar_hud_panel_pressedkeys_aspect)
4332 newSize_x = autocvar_hud_panel_pressedkeys_aspect * mySize_y;
4333 newSize_y = mySize_y;
4335 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4339 newSize_y = 1/autocvar_hud_panel_pressedkeys_aspect * mySize_x;
4340 newSize_x = mySize_x;
4342 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4348 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4351 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4352 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4353 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);
4354 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);
4355 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);
4356 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);
4357 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);
4360 // Handle chat as a panel (#12)
4364 if(!autocvar_hud_panel_chat && !autocvar__hud_configure)
4366 cvar_set("con_chatrect", "0");
4370 active_panel = HUD_PANEL_CHAT;
4371 HUD_Panel_UpdateCvars(chat);
4373 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
4375 panel_pos_y = panel_bg_border;
4376 panel_size_y = vid_conheight - panel_bg_border * 2;
4378 panel_bg = "border"; // force a border when maximized
4379 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an alpha of at least 0.75
4384 mySize = panel_size;
4386 HUD_Panel_DrawBg(1);
4388 if(panel_bg_padding)
4390 pos += '1 1 0' * panel_bg_padding;
4391 mySize -= '2 2 0' * panel_bg_padding;
4394 cvar_set("con_chatrect", "1");
4396 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4397 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4399 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4400 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4402 if(autocvar__hud_configure)
4405 chatsize = cvar("con_chatsize");
4406 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4408 for(i = 0; i < cvar("con_chat"); ++i)
4410 if(i == cvar("con_chat") - 1)
4413 a = panel_fg_alpha * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4414 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);
4419 // Engine info panel (#13)
4426 float frametimeavg1; // 1 frame ago
4427 float frametimeavg2; // 2 frames ago
4428 void HUD_EngineInfo(void)
4430 if(!autocvar_hud_panel_engineinfo && !autocvar__hud_configure)
4433 active_panel = HUD_PANEL_ENGINEINFO;
4434 HUD_Panel_UpdateCvars(engineinfo);
4437 mySize = panel_size;
4439 HUD_Panel_DrawBg(1);
4440 if(panel_bg_padding)
4442 pos += '1 1 0' * panel_bg_padding;
4443 mySize -= '2 2 0' * panel_bg_padding;
4446 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
4448 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4449 frametimeavg2 = frametimeavg1;
4450 frametimeavg1 = frametimeavg;
4453 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4454 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.
4456 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
4457 prevfps = (1/frametime);
4458 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"
4464 if(time - prevfps_time > cvar("hud_panel_engineinfo_framecounter_time"))
4466 prevfps = framecounter/cvar("hud_panel_engineinfo_framecounter_time");
4468 prevfps_time = time;
4473 color = HUD_Get_Num_Color (prevfps, 100);
4474 drawfont = hud_bigfont;
4475 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_panel_engineinfo_framecounter_decimals"))), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4476 drawfont = hud_font;
4479 // Info messages panel (#14)
4481 void HUD_InfoMessages(void)
4483 if(!autocvar_hud_panel_infomessages && !autocvar__hud_configure)
4486 active_panel = HUD_PANEL_INFOMESSAGES;
4487 HUD_Panel_UpdateCvars(infomessages);
4490 mySize = panel_size;
4492 HUD_Panel_DrawBg(1);
4493 if(panel_bg_padding)
4495 pos += '1 1 0' * panel_bg_padding;
4496 mySize -= '2 2 0' * panel_bg_padding;
4499 // always force 5:1 aspect
4501 if(mySize_x/mySize_y > 5)
4503 newSize_x = 5 * mySize_y;
4504 newSize_y = mySize_y;
4506 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4510 newSize_y = 1/5 * mySize_x;
4511 newSize_x = mySize_x;
4513 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4522 fontsize = '0.20 0.20 0' * mySize_y;
4525 if(!autocvar__hud_configure)
4527 if(spectatee_status && !intermission)
4529 if(spectatee_status == -1)
4532 s = strcat("^1Spectating: ^7", GetPlayerName(spectatee_status - 1));
4534 if(autocvar_hud_panel_infomessages_flip)
4535 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4536 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4537 o += eY * fontsize_y;
4539 if(spectatee_status == -1)
4540 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
4542 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
4543 if(autocvar_hud_panel_infomessages_flip)
4544 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4545 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4546 o += eY * fontsize_y;
4548 if(spectatee_status == -1)
4549 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
4551 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
4552 if(autocvar_hud_panel_infomessages_flip)
4553 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4554 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4555 o += eY * fontsize_y;
4557 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
4558 if(autocvar_hud_panel_infomessages_flip)
4559 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4560 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4561 o += eY * fontsize_y;
4563 if(gametype == GAME_ARENA)
4564 s = "^1Wait for your turn to join";
4565 else if(gametype == GAME_LMS)
4568 sk = playerslots[player_localentnum - 1];
4569 if(sk.(scores[ps_primary]) >= 666)
4570 s = "^1Match has already begun";
4571 else if(sk.(scores[ps_primary]) > 0)
4572 s = "^1You have no more lives left";
4574 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4577 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4578 if(autocvar_hud_panel_infomessages_flip)
4579 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4580 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4581 o += eY * fontsize_y;
4583 //show restart countdown:
4584 if (time < getstatf(STAT_GAMESTARTTIME)) {
4586 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4587 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4588 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
4589 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4590 o += eY * fontsize_y;
4593 if(warmup_stage && !intermission)
4595 s = "^2Currently in ^1warmup^2 stage!";
4596 if(autocvar_hud_panel_infomessages_flip)
4597 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4598 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4599 o += eY * fontsize_y;
4603 if(mod(time, 1) >= 0.5)
4608 if(ready_waiting && !intermission && !spectatee_status)
4610 if(ready_waiting_for_me)
4613 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
4615 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
4620 s = strcat("^2Waiting for others to ready up to end warmup...");
4622 s = strcat("^2Waiting for others to ready up...");
4624 if(autocvar_hud_panel_infomessages_flip)
4625 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4626 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4627 o += eY * fontsize_y;
4629 else if(warmup_stage && !intermission && !spectatee_status)
4631 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
4632 if(autocvar_hud_panel_infomessages_flip)
4633 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4634 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4635 o += eY * fontsize_y;
4638 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4640 float ts_min, ts_max;
4641 tm = teams.sort_next;
4644 for(; tm.sort_next; tm = tm.sort_next)
4646 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4648 if(!ts_min) ts_min = tm.team_size;
4649 else ts_min = min(ts_min, tm.team_size);
4650 if(!ts_max) ts_max = tm.team_size;
4651 else ts_max = max(ts_max, tm.team_size);
4653 if ((ts_max - ts_min) > 1)
4655 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
4656 tm = GetTeam(myteam, false);
4658 if (tm.team != COLOR_SPECTATOR)
4659 if (tm.team_size == ts_max)
4660 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
4662 if(autocvar_hud_panel_infomessages_flip)
4663 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4664 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4665 o += eY * fontsize_y;
4672 s = "^7Press ^3ESC ^7to show HUD options.";
4673 if(autocvar_hud_panel_infomessages_flip)
4674 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4675 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4676 o += eY * fontsize_y;
4677 s = "^3Doubleclick ^7a panel for panel-specific options.";
4678 if(autocvar_hud_panel_infomessages_flip)
4679 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4680 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4681 o += eY * fontsize_y;
4682 s = "^3CTRL ^7to disable collision testing, ^3SHIFT ^7and";
4683 if(autocvar_hud_panel_infomessages_flip)
4684 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4685 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4686 o += eY * fontsize_y;
4687 s = "^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.";
4688 if(autocvar_hud_panel_infomessages_flip)
4689 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4690 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4691 o += eY * fontsize_y;
4701 void HUD_ShowSpeed(void)
4704 float pos, conversion_factor;
4705 string speed, zspeed, unit;
4707 switch(cvar("cl_showspeed_unit"))
4712 conversion_factor = 1.0;
4716 conversion_factor = 1.0;
4720 conversion_factor = 0.0254;
4724 conversion_factor = 0.0254 * 3.6;
4728 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4732 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4736 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4738 numsize_x = numsize_y = cvar("cl_showspeed_size");
4739 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4741 drawfont = hud_bigfont;
4742 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
4744 if (cvar("cl_showspeed_z") == 1) {
4745 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4746 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
4749 drawfont = hud_font;
4752 vector acc_prevspeed;
4756 void HUD_ShowAcceleration(void)
4758 float acceleration, sz, scale, alpha, f;
4759 vector pos, top, rgb;
4760 top_x = vid_conwidth/2;
4763 f = time - acc_prevtime;
4764 if(cvar("cl_showacceleration_z"))
4765 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4767 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4768 acc_prevspeed = pmove_vel;
4769 acc_prevtime = time;
4771 f = bound(0, f * 10, 1);
4772 acc_avg = acc_avg * (1 - f) + acceleration * f;
4773 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4775 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4777 sz = cvar("cl_showacceleration_size");
4778 scale = cvar("cl_showacceleration_scale");
4779 alpha = cvar("cl_showacceleration_alpha");
4780 if (cvar("cl_showacceleration_color_custom"))
4781 rgb = stov(cvar_string("cl_showacceleration_color"));
4784 if (acceleration < 0) {
4785 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4786 } else if (acceleration > 0) {
4787 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4791 if (acceleration > 0)
4792 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
4793 else if (acceleration < 0)
4794 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);
4797 void HUD_Reset (void)
4799 // reset gametype specific icons
4800 if(gametype == GAME_KEYHUNT)
4802 else if(gametype == GAME_CTF)
4803 HUD_Mod_CTF_Reset();
4806 #define HUD_DrawPanel(id)\
4808 case (HUD_PANEL_RADAR):\
4809 HUD_Radar(); break;\
4810 case (HUD_PANEL_WEAPONS):\
4811 HUD_Weapons(); break;\
4812 case (HUD_PANEL_AMMO):\
4814 case (HUD_PANEL_POWERUPS):\
4815 HUD_Powerups(); break;\
4816 case (HUD_PANEL_HEALTHARMOR):\
4817 HUD_HealthArmor(); break;\
4818 case (HUD_PANEL_NOTIFY):\
4819 HUD_Notify(); break;\
4820 case (HUD_PANEL_TIMER):\
4821 HUD_Timer(); break;\
4822 case (HUD_PANEL_SCORE):\
4823 HUD_Score(); break;\
4824 case (HUD_PANEL_RACETIMER):\
4825 HUD_RaceTimer(); break;\
4826 case (HUD_PANEL_VOTE):\
4827 HUD_VoteWindow(); break;\
4828 case (HUD_PANEL_MODICONS):\
4829 HUD_ModIcons(); break;\
4830 case (HUD_PANEL_PRESSEDKEYS):\
4831 HUD_DrawPressedKeys(); break;\
4832 case (HUD_PANEL_CHAT):\
4834 case (HUD_PANEL_ENGINEINFO):\
4835 HUD_EngineInfo(); break;\
4836 case (HUD_PANEL_INFOMESSAGES):\
4837 HUD_InfoMessages(); break;\
4840 void HUD_Main (void)
4842 hud_skin_path = strcat("gfx/hud/", autocvar_hud_skin);
4844 if(disable_menu_alphacheck == 1)
4845 menu_fade_alpha = 1;
4847 menu_fade_alpha = (1 - autocvar__menu_alpha);
4849 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4850 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4852 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4853 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4857 // HUD configure visible grid
4858 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4862 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2); ++i)
4864 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);
4867 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2); ++i)
4869 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);
4875 if((teamplay) && autocvar_hud_dock_color_team) {
4876 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4877 color = colormapPaletteColor(mod(f, 16), 1) * autocvar_hud_dock_color_team;
4879 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && autocvar_hud_dock_color_team) {
4880 color = '1 0 0' * autocvar_hud_dock_color_team;
4882 else if(autocvar_hud_dock_color == "shirt") {
4883 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4884 color = colormapPaletteColor(floor(f / 16), 0);
4886 else if(autocvar_hud_dock_color == "pants") {
4887 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4888 color = colormapPaletteColor(mod(f, 16), 1);
4891 color = stov(autocvar_hud_dock_color);
4894 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4897 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4898 if(precache_pic(pic) == "") {
4899 pic = "gfx/hud/default/dock";
4901 drawpic('0 0 0', pic, eX * vid_conwidth + eY * vid_conheight, color, autocvar_hud_dock_alpha * menu_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
4904 // cache the panel order into the panel_order array
4905 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4906 if(hud_panelorder_prev)
4907 strunzone(hud_panelorder_prev);
4908 hud_panelorder_prev = strzone(autocvar__hud_panelorder);
4909 tokenize_console(autocvar__hud_panelorder);
4910 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4911 panel_order[i] = stof(argv(i));
4914 // draw panels in order specified by panel_order array
4915 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
4916 if(i != HUD_PANEL_CHAT || !autocvar__con_chat_maximized) // don't draw maximized chat panel twice!
4917 HUD_DrawPanel(panel_order[i]);
4920 // draw chat panel on top if it is maximized
4921 if(autocvar__con_chat_maximized)
4922 HUD_DrawPanel(HUD_PANEL_CHAT);
4924 // TODO hud_'ify these
4925 if (cvar("cl_showspeed"))
4927 if (cvar("cl_showacceleration"))
4928 HUD_ShowAcceleration();
4930 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)
4931 localcmd("cmd selectteam auto; cmd join\n");
4933 hud_configure_prev = autocvar__hud_configure;
4935 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again
4936 disable_menu_alphacheck = 0;