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_bg \"", cvar_string("hud_bg"), "\"", "\n"));
425 fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
426 fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
427 fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
428 fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
429 fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
430 fputs(fh, strcat("seta hud_fg_alpha \"", cvar_string("hud_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 // common cvars for all panels
453 for (i = 0; i < HUD_PANEL_NUM; ++i)
457 fputs(fh, strcat("seta hud_", panel_name, " ", cvar_string(strcat("hud_", panel_name)), "\n"));
458 fputs(fh, strcat("seta hud_", panel_name, "_pos \"", cvar_string(strcat("hud_", panel_name, "_pos")), "\"", "\n"));
459 fputs(fh, strcat("seta hud_", panel_name, "_size \"", cvar_string(strcat("hud_", panel_name, "_size")), "\"", "\n"));
460 fputs(fh, strcat("seta hud_", panel_name, "_bg \"", cvar_string(strcat("hud_", panel_name, "_bg")), "\"", "\n"));
461 fputs(fh, strcat("seta hud_", panel_name, "_bg_color \"", cvar_string(strcat("hud_", panel_name, "_bg_color")), "\"", "\n"));
462 fputs(fh, strcat("seta hud_", panel_name, "_bg_color_team \"", cvar_string(strcat("hud_", panel_name, "_bg_color_team")), "\"", "\n"));
463 fputs(fh, strcat("seta hud_", panel_name, "_bg_alpha \"", cvar_string(strcat("hud_", panel_name, "_bg_alpha")), "\"", "\n"));
464 fputs(fh, strcat("seta hud_", panel_name, "_bg_border \"", cvar_string(strcat("hud_", panel_name, "_bg_border")), "\"", "\n"));
465 fputs(fh, strcat("seta hud_", panel_name, "_bg_padding \"", cvar_string(strcat("hud_", panel_name, "_bg_padding")), "\"", "\n"));
467 case HUD_PANEL_WEAPONICONS:
468 fputs(fh, strcat("seta hud_", panel_name, "_complainbubble \"", cvar_string(strcat("hud_", panel_name, "_complainbubble")), "\"", "\n"));
469 fputs(fh, strcat("seta hud_", panel_name, "_complainbubble_padding \"", cvar_string(strcat("hud_", panel_name, "_complainbubble_padding")), "\"", "\n"));
471 case HUD_PANEL_INVENTORY:
472 fputs(fh, strcat("seta hud_", panel_name, "_onlycurrent \"", cvar_string(strcat("hud_", panel_name, "_onlycurrent")), "\"", "\n"));
473 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
475 case HUD_PANEL_POWERUPS:
476 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\"", "\n"));
477 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
478 fputs(fh, strcat("seta hud_", panel_name, "_baralign \"", cvar_string(strcat("hud_", panel_name, "_baralign")), "\"", "\n"));
480 case HUD_PANEL_HEALTHARMOR:
481 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\n"));
482 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
483 fputs(fh, strcat("seta hud_", panel_name, "_baralign \"", cvar_string(strcat("hud_", panel_name, "_baralign")), "\"", "\n"));
485 case HUD_PANEL_NOTIFY:
486 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\"", "\n"));
487 fputs(fh, strcat("seta hud_", panel_name, "_print \"", cvar_string(strcat("hud_", panel_name, "_print")), "\"", "\n"));
489 case HUD_PANEL_RADAR:
490 fputs(fh, strcat("seta hud_", panel_name, "_foreground_alpha \"", cvar_string(strcat("hud_", panel_name, "_foreground_alpha")), "\"", "\n"));
493 fputs(fh, strcat("seta hud_", panel_name, "_alreadyvoted_alpha \"", cvar_string(strcat("hud_", panel_name, "_alreadyvoted_alpha")), "\"", "\n"));
499 print("^2Successfully exported to hud_", autocvar_hud_skin, "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
504 const float hlBorderSize = 4;
505 const string hlBorder = "gfx/hud/default/border_highlighted";
506 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
507 void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
509 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
510 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);
511 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);
512 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);
513 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);
516 // draw the background/borders
517 #define HUD_Panel_DrawBg(alpha)\
519 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));\
520 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
521 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);
523 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
530 pic = strcat(hud_skin_path, "/statusbar_vertical");
531 if(precache_pic(pic) == "") {
532 pic = "gfx/hud/default/statusbar_vertical";
534 drawsubpic(pos, eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, pic, '0 0 0', '1 0.25 0', color, alpha, drawflag);
535 if(mySize_y/mySize_x > 2)
536 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);
537 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);
539 pic = strcat(hud_skin_path, "/statusbar");
540 if(precache_pic(pic) == "") {
541 pic = "gfx/hud/default/statusbar";
543 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
544 if(mySize_x/mySize_y > 2)
545 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);
546 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);
550 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
556 pic = strcat(hud_skin_path, "/num_leading");
557 if(precache_pic(pic) == "") {
558 pic = "gfx/hud/default/num_leading";
561 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
562 if(mySize_x/mySize_y > 2)
563 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);
564 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 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
568 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
579 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
580 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
582 for (i = 0; i < HUD_PANEL_NUM; ++i) {
583 if(i == highlightedPanel || !panel_enabled)
586 HUD_Panel_UpdatePosSizeForId(i)
588 panel_pos -= '1 1 0' * panel_bg_border;
589 panel_size += '2 2 0' * panel_bg_border;
591 if(myPos_y + mySize_y < panel_pos_y)
593 if(myPos_y > panel_pos_y + panel_size_y)
596 if(myPos_x + mySize_x < panel_pos_x)
598 if(myPos_x > panel_pos_x + panel_size_x)
601 // OK, there IS a collision.
603 myCenter_x = myPos_x + 0.5 * mySize_x;
604 myCenter_y = myPos_y + 0.5 * mySize_y;
606 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
607 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
609 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
611 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
612 myTarget_x = panel_pos_x - mySize_x;
613 else // push it upwards
614 myTarget_y = panel_pos_y - mySize_y;
616 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
618 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
619 myTarget_x = panel_pos_x + panel_size_x;
620 else // push it upwards
621 myTarget_y = panel_pos_y - mySize_y;
623 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
625 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
626 myTarget_x = panel_pos_x - mySize_x;
627 else // push it downwards
628 myTarget_y = panel_pos_y + panel_size_y;
630 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
632 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
633 myTarget_x = panel_pos_x + panel_size_x;
634 else // push it downwards
635 myTarget_y = panel_pos_y + panel_size_y;
637 if(cvar("hud_configure_checkcollisions_debug"))
638 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
644 void HUD_Panel_SetPos(vector pos)
646 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
650 if(cvar("hud_configure_checkcollisions_debug"))
651 drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
653 if(autocvar_hud_configure_grid)
655 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;
656 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;
659 if(hud_configure_checkcollisions)
660 pos = HUD_Panel_CheckMove(pos, mySize);
662 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
663 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
666 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
668 HUD_Panel_GetName(highlightedPanel);
669 cvar_set(strcat("hud_", panel_name, "_pos"), s);
672 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
673 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
683 ratio = mySize_x/mySize_y;
685 for (i = 0; i < HUD_PANEL_NUM; ++i) {
686 if(i == highlightedPanel || !panel_enabled)
689 HUD_Panel_UpdatePosSizeForId(i)
691 panel_pos -= '1 1 0' * panel_bg_border;
692 panel_size += '2 2 0' * panel_bg_border;
694 targEndPos = panel_pos + panel_size;
696 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
697 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
700 if (resizeCorner == 1)
702 // check if this panel is on our way
703 if (resizeorigin_x <= panel_pos_x)
705 if (resizeorigin_y <= panel_pos_y)
707 if (targEndPos_x <= resizeorigin_x - mySize_x)
709 if (targEndPos_y <= resizeorigin_y - mySize_y)
712 // there is a collision:
713 // detect which side of the panel we are facing is actually limiting the resizing
714 // (which side the resize direction finds for first) and reduce the size up to there
716 // dist is the distance between resizeorigin and the "analogous" point of the panel
717 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
718 dist_x = resizeorigin_x - targEndPos_x;
719 dist_y = resizeorigin_y - targEndPos_y;
720 if (dist_y <= 0 || dist_x / dist_y > ratio)
721 mySize_x = min(mySize_x, dist_x);
723 mySize_y = min(mySize_y, dist_y);
725 else if (resizeCorner == 2)
727 if (resizeorigin_x >= targEndPos_x)
729 if (resizeorigin_y <= panel_pos_y)
731 if (panel_pos_x >= resizeorigin_x + mySize_x)
733 if (targEndPos_y <= resizeorigin_y - mySize_y)
736 dist_x = panel_pos_x - resizeorigin_x;
737 dist_y = resizeorigin_y - targEndPos_y;
738 if (dist_y <= 0 || dist_x / dist_y > ratio)
739 mySize_x = min(mySize_x, dist_x);
741 mySize_y = min(mySize_y, dist_y);
743 else if (resizeCorner == 3)
745 if (resizeorigin_x <= panel_pos_x)
747 if (resizeorigin_y >= targEndPos_y)
749 if (targEndPos_x <= resizeorigin_x - mySize_x)
751 if (panel_pos_y >= resizeorigin_y + mySize_y)
754 dist_x = resizeorigin_x - targEndPos_x;
755 dist_y = panel_pos_y - resizeorigin_y;
756 if (dist_y <= 0 || dist_x / dist_y > ratio)
757 mySize_x = min(mySize_x, dist_x);
759 mySize_y = min(mySize_y, dist_y);
761 else if (resizeCorner == 4)
763 if (resizeorigin_x >= targEndPos_x)
765 if (resizeorigin_y >= targEndPos_y)
767 if (panel_pos_x >= resizeorigin_x + mySize_x)
769 if (panel_pos_y >= resizeorigin_y + mySize_y)
772 dist_x = panel_pos_x - resizeorigin_x;
773 dist_y = panel_pos_y - resizeorigin_y;
774 if (dist_y <= 0 || dist_x / dist_y > ratio)
775 mySize_x = min(mySize_x, dist_x);
777 mySize_y = min(mySize_y, dist_y);
779 if(cvar("hud_configure_checkcollisions_debug"))
780 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
786 void HUD_Panel_SetPosSize(vector mySize)
788 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
790 resizeorigin = panel_click_resizeorigin;
793 // minimum panel size cap
794 mySize_x = max(0.025 * vid_conwidth, mySize_x);
795 mySize_y = max(0.025 * vid_conheight, mySize_y);
797 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.
799 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
800 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
803 // collision testing|
804 // -----------------+
806 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
807 if(resizeCorner == 1) {
808 myPos_x = resizeorigin_x - mySize_x;
809 myPos_y = resizeorigin_y - mySize_y;
810 } else if(resizeCorner == 2) {
811 myPos_x = resizeorigin_x;
812 myPos_y = resizeorigin_y - mySize_y;
813 } else if(resizeCorner == 3) {
814 myPos_x = resizeorigin_x - mySize_x;
815 myPos_y = resizeorigin_y;
816 } else { // resizeCorner == 4
817 myPos_x = resizeorigin_x;
818 myPos_y = resizeorigin_y;
821 // left/top screen edges
823 mySize_x = mySize_x + myPos_x;
825 mySize_y = mySize_y + myPos_y;
827 // bottom/right screen edges
828 if(myPos_x + mySize_x > vid_conwidth)
829 mySize_x = vid_conwidth - myPos_x;
830 if(myPos_y + mySize_y > vid_conheight)
831 mySize_y = vid_conheight - myPos_y;
833 if(cvar("hud_configure_checkcollisions_debug"))
834 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
836 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
837 if(autocvar_hud_configure_grid)
839 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;
840 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;
843 if(hud_configure_checkcollisions)
844 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
846 // 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)
847 mySize_x = max(0.025 * vid_conwidth, mySize_x);
848 mySize_y = max(0.025 * vid_conheight, mySize_y);
850 // do another pos check, as size might have changed by now
851 if(resizeCorner == 1) {
852 myPos_x = resizeorigin_x - mySize_x;
853 myPos_y = resizeorigin_y - mySize_y;
854 } else if(resizeCorner == 2) {
855 myPos_x = resizeorigin_x;
856 myPos_y = resizeorigin_y - mySize_y;
857 } else if(resizeCorner == 3) {
858 myPos_x = resizeorigin_x - mySize_x;
859 myPos_y = resizeorigin_y;
860 } else { // resizeCorner == 4
861 myPos_x = resizeorigin_x;
862 myPos_y = resizeorigin_y;
865 if(cvar("hud_configure_checkcollisions_debug"))
866 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
868 HUD_Panel_GetName(highlightedPanel);
870 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
871 cvar_set(strcat("hud_", panel_name, "_size"), s);
873 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
874 cvar_set(strcat("hud_", panel_name, "_pos"), s);
878 float prevMouseClicked; // previous state
879 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
880 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
883 float menu_enabled_time;
884 float pressed_key_time;
885 void HUD_Panel_Arrow_Action(float nPrimary)
887 if (highlightedPanel_prev == -1 || mouseClicked)
890 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
893 if(autocvar_hud_configure_grid)
895 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
897 if (hudShiftState & S_SHIFT)
898 step = bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
900 step = 2 * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
904 if (hudShiftState & S_SHIFT)
905 step = bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
907 step = 2 * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
912 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
913 step = vid_conheight;
916 if (hudShiftState & S_SHIFT)
917 step = (step / 256); // more precision
919 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
922 highlightedPanel = highlightedPanel_prev;
924 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
926 if (hudShiftState & S_ALT) // resize
928 highlightedAction = 1;
929 if(nPrimary == K_UPARROW)
931 else if(nPrimary == K_RIGHTARROW)
933 else if(nPrimary == K_LEFTARROW)
935 else // if(nPrimary == K_DOWNARROW)
938 // ctrl+arrow reduces the size, instead of increasing it
939 // Note that ctrl disables collisions check too, but it's fine
940 // since we don't collide with anything reducing the size
941 if (hudShiftState & S_CTRL) {
943 resizeCorner = 5 - resizeCorner;
948 panel_click_resizeorigin = panel_pos;
949 if(resizeCorner == 1) {
950 panel_click_resizeorigin += mySize;
952 } else if(resizeCorner == 2) {
953 panel_click_resizeorigin_y += mySize_y;
955 } else if(resizeCorner == 3) {
956 panel_click_resizeorigin_x += mySize_x;
958 } else { // resizeCorner == 4
961 HUD_Panel_SetPosSize(mySize);
965 highlightedAction = 2;
968 if(nPrimary == K_UPARROW)
970 else if(nPrimary == K_DOWNARROW)
972 else if(nPrimary == K_LEFTARROW)
974 else // if(nPrimary == K_RIGHTARROW)
977 HUD_Panel_SetPos(pos);
981 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
983 if(!autocvar__hud_configure)
986 // allow console bind to work
989 con_keys = findkeysforcommand("toggleconsole");
990 keys = tokenize(con_keys);
992 float hit_con_bind, i;
993 for (i = 0; i < keys; ++i)
995 if(nPrimary == stof(argv(i)))
999 if(bInputType == 0) {
1000 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1001 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1002 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1004 else if(bInputType == 1) {
1005 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1006 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1007 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1010 if(nPrimary == K_MOUSE1)
1012 if(bInputType == 0) { // key pressed
1016 else if(bInputType == 1) {// key released
1021 else if(nPrimary == K_ESCAPE)
1023 if (bInputType == 1)
1025 disable_menu_alphacheck = 1;
1027 menu_enabled_time = time;
1028 localcmd("menu_showhudexit\n");
1030 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1032 if (bInputType == 1)
1034 pressed_key_time = 0;
1037 else if (pressed_key_time == 0)
1038 pressed_key_time = time;
1040 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1042 else if(hit_con_bind)
1045 return true; // Suppress ALL other input
1048 float HUD_Panel_HighlightCheck()
1054 while(j <= HUD_PANEL_NUM)
1059 HUD_Panel_UpdatePosSizeForId(i)
1061 panelPos = panel_pos;
1062 panelSize = panel_size;
1063 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1066 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1070 // resize from topleft border
1071 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)
1075 // resize from topright border
1076 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)
1080 // resize from bottomleft border
1081 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)
1085 // resize from bottomright border
1086 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)
1094 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1095 void HUD_Panel_FirstInDrawQ(float id)
1098 var float place = -1;
1099 // find out where in the array our current id is, save into place
1100 for(i = 0; i < HUD_PANEL_NUM; ++i)
1102 if(panel_order[i] == id)
1108 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1110 place = HUD_PANEL_NUM - 1;
1112 // move all ids up by one step in the array until "place"
1113 for(i = place; i > 0; --i)
1115 panel_order[i] = panel_order[i-1];
1117 // now save the new top id
1118 panel_order[0] = id;
1120 // let's save them into the cvar by some strcat trickery
1122 for(i = 0; i < HUD_PANEL_NUM; ++i)
1124 s = strcat(s, ftos(panel_order[i]), " ");
1126 cvar_set("_hud_panelorder", s);
1127 if(hud_panelorder_prev)
1128 strunzone(hud_panelorder_prev);
1129 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1132 void HUD_Panel_Highlight()
1138 while(j <= HUD_PANEL_NUM)
1143 HUD_Panel_UpdatePosSizeForId(i)
1145 panelPos = panel_pos;
1146 panelSize = panel_size;
1147 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1150 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1152 highlightedPanel = i;
1153 HUD_Panel_FirstInDrawQ(i);
1154 highlightedAction = 1;
1155 panel_click_distance = mousepos - panelPos;
1158 // resize from topleft border
1159 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)
1161 highlightedPanel = i;
1162 HUD_Panel_FirstInDrawQ(i);
1163 highlightedAction = 2;
1165 panel_click_distance = mousepos - panelPos;
1166 panel_click_resizeorigin = panelPos + panelSize;
1169 // resize from topright border
1170 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)
1172 highlightedPanel = i;
1173 HUD_Panel_FirstInDrawQ(i);
1174 highlightedAction = 2;
1176 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1177 panel_click_distance_y = mousepos_y - panelPos_y;
1178 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1181 // resize from bottomleft border
1182 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)
1184 highlightedPanel = i;
1185 HUD_Panel_FirstInDrawQ(i);
1186 highlightedAction = 2;
1188 panel_click_distance_x = mousepos_x - panelPos_x;
1189 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1190 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1193 // resize from bottomright border
1194 else if(mousepos_x >= panelPos_x + 0.5 * panelSize_x && mousepos_y >= panelPos_y + 0.5 * panelSize_y && mousepos_x <= panelPos_x + panelSize_x + border && mousepos_y <= panelPos_y + panelSize_y + border)
1196 highlightedPanel = i;
1197 HUD_Panel_FirstInDrawQ(i);
1198 highlightedAction = 2;
1200 panel_click_distance = panelSize - mousepos + panelPos;
1201 panel_click_resizeorigin = panelPos;
1206 highlightedPanel_prev = -1;
1211 float highlightcheck;
1212 void HUD_Panel_Mouse()
1214 // 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
1215 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1216 disable_menu_alphacheck = 0;
1217 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1221 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1222 print("Highlighted: ", ftos(highlightedPanel), "\n");
1223 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1226 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1227 highlightedPanel = -1;
1228 highlightedAction = 0;
1230 if(highlightedPanel != -1)
1231 highlightedPanel_prev = highlightedPanel;
1233 mousepos = mousepos + getmousepos();
1235 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1236 mousepos_y = bound(0, mousepos_y, vid_conheight);
1240 if(prevMouseClicked == 0)
1241 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1243 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1245 if(highlightedAction == 1)
1246 HUD_Panel_SetPos(mousepos - panel_click_distance);
1247 else if(highlightedAction == 2)
1250 if(resizeCorner == 1) {
1251 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1252 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1253 } else if(resizeCorner == 2) {
1254 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1255 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1256 } else if(resizeCorner == 3) {
1257 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1258 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1259 } else { // resizeCorner == 4
1260 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1261 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1263 HUD_Panel_SetPosSize(mySize);
1266 // doubleclick check
1267 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1269 mouseClicked = 0; // to prevent spam, I guess.
1270 disable_menu_alphacheck = 2;
1272 menu_enabled_time = time;
1273 HUD_Panel_GetName(highlightedPanel)
1274 localcmd("menu_showhudoptions ", panel_name, "\n");
1277 if(prevMouseClicked == 0)
1279 prevMouseClickedTime = time;
1280 prevMouseClickedPos = mousepos;
1285 highlightcheck = HUD_Panel_HighlightCheck();
1287 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1290 cursorsize = '32 32 0';
1292 if(highlightcheck == 0)
1293 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1294 else if(highlightcheck == 1)
1295 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1296 else if(highlightcheck == 2)
1297 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1299 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1301 prevMouseClicked = mouseClicked;
1304 // Weapon icons (#0)
1306 float weaponspace[10];
1307 #define HUD_WeaponIcons_Clear()\
1309 for(idx = 0; idx < 10; ++idx)\
1310 weaponspace[idx] = 0;
1312 entity weaponorder[WEP_MAXCOUNT];
1313 void weaponorder_swap(float i, float j, entity pass)
1317 weaponorder[i] = weaponorder[j];
1321 string weaponorder_cmp_str_save;
1322 string weaponorder_cmp_str;
1323 float weaponorder_cmp(float i, float j, entity pass)
1326 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1327 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1328 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)
1331 void HUD_WeaponIcons(void)
1333 if(!autocvar_hud_weaponicons && !autocvar__hud_configure)
1336 float id = HUD_PANEL_WEAPONICONS;
1337 HUD_Panel_UpdateCvarsForId(id);
1338 float alpha, stat_weapons; // "constants"
1340 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1343 mySize = panel_size;
1345 stat_weapons = getstati(STAT_WEAPONS);
1347 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1349 self = get_weaponinfo(i);
1350 if(self.impulse >= 0)
1354 // TODO make this configurable
1355 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1357 if(weaponorder_cmp_str != weaponorder_cmp_str_save)
1359 if(weaponorder_cmp_str_save)
1360 strunzone(weaponorder_cmp_str_save);
1361 weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
1363 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1365 self = get_weaponinfo(i);
1366 if(self.impulse >= 0)
1368 weaponorder[weapon_cnt] = self;
1372 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1375 HUD_Panel_DrawBg(1);
1376 if(panel_bg_padding)
1378 pos += '1 1 0' * panel_bg_padding;
1379 mySize -= '2 2 0' * panel_bg_padding;
1383 weapon_stats = getstati(STAT_DAMAGE_HITS);
1384 weapon_number = weapon_stats & 63;
1385 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1387 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1388 weapon_number = weapon_stats & 63;
1389 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1391 if(cvar_or("hud_weaponicons_fade", 1))
1393 fade = 3.2 - 2 * (time - weapontime);
1394 fade = bound(0.7, fade, 1);
1399 HUD_WeaponIcons_Clear();
1401 float rows, columns;
1402 rows = mySize_y/mySize_x;
1403 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1404 // ^^^ weapon icon aspect goes here
1406 columns = ceil(WEP_COUNT/rows);
1411 when = autocvar_hud_weaponicons_complainbubble_time;
1413 fadetime = autocvar_hud_weaponicons_complainbubble_fadetime;
1416 for(i = 0; i < weapon_cnt; ++i)
1418 self = weaponorder[i];
1419 weapid = self.impulse;
1421 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1423 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1424 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1426 // draw background behind currently selected weapon
1427 if(self.weapon == activeweapon)
1428 drawpic_aspect_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), "weapon_current_bg", eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1430 // draw the weapon accuracy on the HUD
1431 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1434 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1436 // yellow_accuracy = value at which accuracy becomes yellow
1437 if(weapon_stats >= 100) {
1441 else if(weapon_stats > autocvar_hud_weaponicons_accuracy_yellow) {
1442 color_x = 1 - (weapon_stats-autocvar_hud_weaponicons_accuracy_yellow)/(100-autocvar_hud_weaponicons_accuracy_yellow); // red value between 1 -> 0
1446 color_y = weapon_stats/autocvar_hud_weaponicons_accuracy_yellow; // green value between 0 -> 1
1450 drawpic_aspect_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), "weapon_accuracy", eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), color, panel_fg_alpha, DRAWFLAG_NORMAL);
1453 // draw the weapon icon
1454 if((self.impulse >= 0) && (stat_weapons & self.weapons))
1456 drawpic_aspect_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), strcat("weapon", self.netname), eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1458 if(autocvar_hud_weaponicons_number == 1) // weapon number
1459 drawstring(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), ftos(weapid), '1 1 0' * 0.5 * mySize_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1460 else if(autocvar_hud_weaponicons_number == 2) // bind
1461 drawstring(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * mySize_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1464 // draw a "ghost weapon icon" if you don't have the weapon
1467 drawpic_aspect_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), strcat("weapon", self.netname), eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
1470 // draw the complain message
1471 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_weaponicons_complainbubble)
1475 if(complain_weapon_time + when > time)
1478 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1482 if(complain_weapon_time + when > time)
1489 if(complain_weapon_type == 0) {
1493 else if(complain_weapon_type == 1) {
1501 drawpic_aspect_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows) + '1 1 0' * autocvar_hud_weaponicons_complainbubble_padding, "weapon_complainbubble", eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows) - '2 2 0' * autocvar_hud_weaponicons_complainbubble_padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
1502 drawstring_aspect(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows) + '1 1 0' * autocvar_hud_weaponicons_complainbubble_padding, s, eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows) - '2 2 0' * autocvar_hud_weaponicons_complainbubble_padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
1518 float GetAmmoStat(float i)
1522 case 0: return STAT_SHELLS;
1523 case 1: return STAT_NAILS;
1524 case 2: return STAT_ROCKETS;
1525 case 3: return STAT_CELLS;
1526 case 4: return STAT_FUEL;
1531 float GetAmmoItemCode(float i)
1535 case 0: return IT_SHELLS;
1536 case 1: return IT_NAILS;
1537 case 2: return IT_ROCKETS;
1538 case 3: return IT_CELLS;
1539 case 4: return IT_FUEL;
1544 string GetAmmoPicture(float i)
1548 case 0: return "ammo_shells";
1549 case 1: return "ammo_bullets";
1550 case 2: return "ammo_rockets";
1551 case 3: return "ammo_cells";
1552 case 4: return "ammo_fuel";
1557 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1560 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1561 if(autocvar__hud_configure)
1571 if(currently_selected)
1576 vector newSize, newPos;
1577 if(mySize_x/mySize_y > 3)
1579 newSize_x = 3 * mySize_y;
1580 newSize_y = mySize_y;
1582 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1587 newSize_y = 1/3 * mySize_x;
1588 newSize_x = mySize_x;
1590 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1594 vector picpos, numpos;
1595 if(autocvar_hud_inventory_iconalign)
1598 picpos = newPos + eX * 2 * newSize_y;
1602 numpos = newPos + eX * newSize_y;
1606 if (currently_selected)
1607 drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1609 drawfont = hud_bigfont;
1610 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1611 drawfont = hud_font;
1612 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1615 void HUD_Inventory(void)
1617 if(!autocvar_hud_inventory && !autocvar__hud_configure)
1620 float id = HUD_PANEL_INVENTORY;
1621 HUD_Panel_UpdateCvarsForId(id);
1622 float i, currently_selected;
1626 mySize = panel_size;
1628 HUD_Panel_DrawBg(1);
1629 if(panel_bg_padding)
1631 pos += '1 1 0' * panel_bg_padding;
1632 mySize -= '2 2 0' * panel_bg_padding;
1635 float rows, columns;
1636 rows = mySize_y/mySize_x;
1637 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1638 // ^^^ ammo item aspect goes here
1640 columns = ceil(AMMO_COUNT/rows);
1644 for (i = 0; i < AMMO_COUNT; ++i) {
1645 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1646 if(autocvar_hud_inventory_onlycurrent) {
1647 if(autocvar__hud_configure)
1649 if (currently_selected || autocvar__hud_configure)
1651 DrawAmmoItem(pos, mySize, i, currently_selected);
1655 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);
1660 column = column + 1;
1666 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float alpha)
1668 vector newSize, newPos;
1669 if(mySize_x/mySize_y > 3)
1671 newSize_x = 3 * mySize_y;
1672 newSize_y = mySize_y;
1674 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1679 newSize_y = 1/3 * mySize_x;
1680 newSize_x = mySize_x;
1682 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1686 vector picpos, numpos;
1689 if(iconalign == 1 || iconalign == 3) // right align
1692 picpos = newPos + eX * 2 * newSize_y;
1696 numpos = newPos + eX * newSize_y;
1702 if(iconalign == 0 || iconalign == 3) // left align
1704 numpos = newPos + eX * newSize_y;
1710 picpos = newPos + eX * 2 * newSize_y;
1714 drawfont = hud_bigfont;
1715 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1716 drawfont = hud_font;
1717 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1720 void DrawNumIcon_expanding(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float fadelerp)
1723 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
1725 DrawNumIcon(iconalign, myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, left, color, (1 - fadelerp));
1730 void HUD_Powerups(void) {
1731 if(!autocvar_hud_powerups && !autocvar__hud_configure)
1734 float id = HUD_PANEL_POWERUPS;
1735 HUD_Panel_UpdateCvarsForId(id);
1737 stat_items = getstati(STAT_ITEMS);
1739 if(!autocvar__hud_configure)
1741 if not(stat_items & IT_STRENGTH)
1742 if not(stat_items & IT_INVINCIBLE)
1745 if (getstati(STAT_HEALTH) <= 0)
1751 mySize = panel_size;
1753 float strength_time, shield_time;
1755 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1756 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1758 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
1759 if(panel_bg_padding)
1761 pos += '1 1 0' * panel_bg_padding;
1762 mySize -= '2 2 0' * panel_bg_padding;
1765 if(autocvar__hud_configure)
1771 vector barpos, barsize;
1775 string leftname, rightname;
1776 float leftcnt, rightcnt;
1777 float leftexact, rightexact;
1778 if (autocvar_hud_powerups_flip) {
1779 leftname = "strength";
1780 leftcnt = ceil(strength_time);
1781 leftexact = strength_time;
1783 rightname = "shield";
1784 rightcnt = ceil(shield_time);
1785 rightexact = shield_time;
1787 leftname = "shield";
1788 leftcnt = ceil(shield_time);
1789 leftexact = shield_time;
1791 rightname = "strength";
1792 rightcnt = ceil(strength_time);
1793 rightexact = strength_time;
1796 drawfont = hud_bigfont;
1797 if (mySize_x/mySize_y > 4)
1801 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1802 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1803 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1804 } else { // left align
1806 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1809 HUD_Panel_GetProgressBarColor(leftname)
1810 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);
1812 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
1814 DrawNumIcon_expanding(autocvar_hud_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
1819 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1820 barpos = pos + eX * 0.5 * mySize_x;
1821 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1822 } else { // right align
1823 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1824 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1827 HUD_Panel_GetProgressBarColor(rightname)
1828 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);
1830 DrawNumIcon(autocvar_hud_powerups_iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
1832 DrawNumIcon_expanding(autocvar_hud_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));
1835 else if (mySize_x/mySize_y > 1.5)
1839 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1840 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1841 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1842 } else { // left align
1844 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1847 HUD_Panel_GetProgressBarColor(leftname)
1848 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);
1850 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
1852 DrawNumIcon_expanding(autocvar_hud_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
1857 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1858 barpos = pos + eY * 0.5 * mySize_y;
1859 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1860 } else { // right align
1861 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1862 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1865 HUD_Panel_GetProgressBarColor(rightname)
1866 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);
1868 DrawNumIcon(autocvar_hud_powerups_iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
1870 DrawNumIcon_expanding(autocvar_hud_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));
1877 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // down align
1878 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1879 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1880 } else { // up align
1882 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1885 if(autocvar_hud_powerups_iconalign == 1 || autocvar_hud_powerups_iconalign == 3) { // down align
1886 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
1887 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
1888 } else { // up align
1889 picpos = pos + eX * 0.05 * mySize_x;
1890 numpos = pos + eY * 0.4 * mySize_x;
1893 HUD_Panel_GetProgressBarColor(leftname)
1894 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);
1896 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));
1898 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1899 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1904 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // up align
1905 barpos = pos + eX * 0.5 * mySize_x;
1906 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1907 } else { // down align
1908 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1909 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1912 if(autocvar_hud_powerups_iconalign == 0 || autocvar_hud_powerups_iconalign == 3) { // up align
1913 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1914 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1915 } else { // down align
1916 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
1917 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
1920 HUD_Panel_GetProgressBarColor(rightname)
1921 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);
1923 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));
1925 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1926 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1929 drawfont = hud_font;
1932 // Health/armor (#3)
1934 void HUD_HealthArmor(void)
1936 if(!autocvar_hud_healtharmor && !autocvar__hud_configure)
1939 float id = HUD_PANEL_HEALTHARMOR;
1940 HUD_Panel_UpdateCvarsForId(id);
1943 mySize = panel_size;
1945 HUD_Panel_DrawBg(1);
1946 if(panel_bg_padding)
1948 pos += '1 1 0' * panel_bg_padding;
1949 mySize -= '2 2 0' * panel_bg_padding;
1952 float armor, health;
1953 armor = getstati(STAT_ARMOR);
1954 health = getstati(STAT_HEALTH);
1957 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
1959 if(autocvar__hud_configure)
1969 vector barpos, barsize;
1973 drawfont = hud_bigfont;
1974 if(autocvar_hud_healtharmor == 2) // combined health and armor display
1977 v = healtharmor_maxdamage(health, armor, armorblockpercent);
1982 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
1983 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
1984 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
1985 } else { // left align
1987 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
1991 if(v_z) // NOT fully armored
1993 biggercount = "health";
1994 HUD_Panel_GetProgressBarColor("health")
1995 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1997 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);
2001 biggercount = "armor";
2002 HUD_Panel_GetProgressBarColor("armor")
2003 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2005 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);
2007 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200), 1);
2012 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2013 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2014 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2017 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2019 HUD_Panel_GetProgressBarColor("fuel")
2020 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2025 string leftname, rightname;
2026 float leftcnt, rightcnt;
2027 float leftactive, rightactive;
2028 float leftalpha, rightalpha;
2029 if (autocvar_hud_healtharmor_flip) { // old style layout with armor left/top of health
2034 leftalpha = min((armor+10)/55, 1);
2036 rightname = "health";
2041 leftname = "health";
2046 rightname = "armor";
2050 rightalpha = min((armor+10)/55, 1);
2053 if (mySize_x/mySize_y > 4)
2057 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2058 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2059 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2060 } else { // left align
2062 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2065 HUD_Panel_GetProgressBarColor(leftname)
2066 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2067 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
2072 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2073 barpos = pos + eX * 0.5 * mySize_x;
2074 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2075 } else { // right align
2076 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2077 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2080 HUD_Panel_GetProgressBarColor(rightname)
2081 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2082 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(leftcnt, 200), 1);
2087 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2088 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2089 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2092 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2094 HUD_Panel_GetProgressBarColor("fuel")
2095 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2098 else if (mySize_x/mySize_y > 1.5)
2102 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2103 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2104 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2105 } else { // left align
2107 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2110 HUD_Panel_GetProgressBarColor(leftname)
2111 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2112 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
2117 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2118 barpos = pos + eY * 0.5 * mySize_y;
2119 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2120 } else { // right align
2121 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2122 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2125 HUD_Panel_GetProgressBarColor(rightname)
2126 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2127 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(leftcnt, 200), 1);
2132 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2133 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2134 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2137 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2139 HUD_Panel_GetProgressBarColor("fuel")
2140 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2147 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // down align
2148 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2149 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2150 } else { // up align
2152 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2155 if(autocvar_hud_healtharmor_iconalign == 1 || autocvar_hud_healtharmor_iconalign == 3) { // down align
2156 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2157 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2158 } else { // up align
2159 picpos = pos + eX * 0.05 * mySize_x;
2160 numpos = pos + eY * 0.4 * mySize_x;
2163 HUD_Panel_GetProgressBarColor(leftname)
2164 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2165 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2166 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);
2171 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // up align
2172 barpos = pos + eX * 0.5 * mySize_x;
2173 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2174 } else { // down align
2175 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2176 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2179 if(autocvar_hud_healtharmor_iconalign == 0 || autocvar_hud_healtharmor_iconalign == 3) { // up align
2180 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2181 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2182 } else { // down align
2183 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2184 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2187 HUD_Panel_GetProgressBarColor(rightname)
2188 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2189 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2190 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);
2195 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2197 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2199 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2200 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2202 HUD_Panel_GetProgressBarColor("fuel")
2203 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2207 drawfont = hud_font;
2210 // Notification area (#4)
2213 string Weapon_SuicideMessage(float deathtype)
2215 w_deathtype = deathtype;
2216 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2217 return w_deathtypestring;
2220 string Weapon_KillMessage(float deathtype)
2222 w_deathtype = deathtype;
2223 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2224 return w_deathtypestring;
2227 float killnotify_times[10];
2228 float killnotify_deathtype[10];
2229 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2230 string killnotify_attackers[10];
2231 string killnotify_victims[10];
2232 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2235 for (i = 9; i > 0; --i) {
2236 killnotify_times[i] = killnotify_times[i-1];
2237 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2238 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2239 if(killnotify_attackers[i])
2240 strunzone(killnotify_attackers[i]);
2241 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2242 if(killnotify_victims[i])
2243 strunzone(killnotify_victims[i]);
2244 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2246 killnotify_times[0] = time;
2247 killnotify_deathtype[0] = wpn;
2248 killnotify_actiontype[0] = actiontype;
2249 if(killnotify_attackers[0])
2250 strunzone(killnotify_attackers[0]);
2251 killnotify_attackers[0] = strzone(attacker);
2252 if(killnotify_victims[0])
2253 strunzone(killnotify_victims[0]);
2254 killnotify_victims[0] = strzone(victim);
2257 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2260 float alsoprint, gentle;
2261 alsoprint = (autocvar_hud_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2262 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2264 if(msg == MSG_SUICIDE) {
2265 w = DEATH_WEAPONOF(type);
2267 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2269 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2270 } else if (type == DEATH_KILL) {
2271 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2273 print ("^1",s1, "^1 couldn't take it anymore\n");
2274 } else if (type == DEATH_ROT) {
2275 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2277 print ("^1",s1, "^1 died\n");
2278 } else if (type == DEATH_NOAMMO) {
2279 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2281 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2282 } else if (type == DEATH_CAMP) {
2283 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2285 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2286 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2287 HUD_KillNotify_Push(s1, "", 0, type);
2289 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2290 } else if (type == DEATH_CHEAT) {
2291 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2293 print ("^1",s1, "^1 unfairly eliminated themself\n");
2294 } else if (type == DEATH_FIRE) {
2295 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2297 print ("^1",s1, "^1 burned to death\n");
2298 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2299 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2301 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2304 if (stof(s2) > 2) // killcount > 2
2305 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2306 } else if(msg == MSG_KILL) {
2307 w = DEATH_WEAPONOF(type);
2309 HUD_KillNotify_Push(s2, s1, 1, w);
2311 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2313 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2314 HUD_KillNotify_Push(s1, s2, 1, type);
2318 print ("^1", s1, "^1 took action against a team mate\n");
2320 print ("^1", s1, "^1 mows down a team mate\n");
2323 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2325 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2327 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2329 else if (stof(s2) > 2) {
2331 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2333 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2336 else if(type == KILL_FIRST_BLOOD)
2337 print("^1",s1, "^1 drew first blood", "\n");
2339 else if (type == DEATH_TELEFRAG)
2340 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2341 else if (type == DEATH_DROWN) {
2342 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2344 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2346 else if (type == DEATH_SLIME) {
2347 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2349 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2351 else if (type == DEATH_LAVA) {
2352 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2354 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2356 else if (type == DEATH_FALL) {
2357 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2359 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2361 else if (type == DEATH_SHOOTING_STAR) {
2362 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2364 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2366 else if (type == DEATH_SWAMP) {
2367 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2369 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2371 else if (type == DEATH_HURTTRIGGER)
2373 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2375 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2376 } else if(type == DEATH_SBCRUSH) {
2377 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2379 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2380 } else if(type == DEATH_SBMINIGUN) {
2381 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2383 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2384 } else if(type == DEATH_SBROCKET) {
2385 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2387 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2388 } else if(type == DEATH_SBBLOWUP) {
2389 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2391 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2392 } else if(type == DEATH_WAKIGUN) {
2393 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2395 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2396 } else if(type == DEATH_WAKIROCKET) {
2397 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2399 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2400 } else if(type == DEATH_WAKIBLOWUP) {
2401 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2403 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2404 } else if(type == DEATH_TURRET) {
2405 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2407 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2408 } else if(type == DEATH_TOUCHEXPLODE) {
2409 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2411 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2412 } else if(type == DEATH_CHEAT) {
2413 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2415 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2416 } else if (type == DEATH_FIRE) {
2417 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2419 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2420 } else if (type == DEATH_CUSTOM) {
2421 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2423 print ("^1",s1, "^1 ", s2, "\n");
2425 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2427 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2429 } else if(msg == MSG_SPREE) {
2430 if(type == KILL_END_SPREE) {
2432 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2434 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2435 } else if(type == KILL_SPREE) {
2437 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2439 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2440 } else if(type == KILL_SPREE_3) {
2442 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2444 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2445 } else if(type == KILL_SPREE_5) {
2447 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2449 print (s1,"^7 unleashes ^1RAGE\n");
2450 } else if(type == KILL_SPREE_10) {
2452 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2454 print (s1,"^7 starts the ^1MASSACRE!\n");
2455 } else if(type == KILL_SPREE_15) {
2457 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2459 print (s1,"^7 executes ^1MAYHEM!\n");
2460 } else if(type == KILL_SPREE_20) {
2462 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2464 print (s1,"^7 is a ^1BERSERKER!\n");
2465 } else if(type == KILL_SPREE_25) {
2467 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2469 print (s1,"^7 inflicts ^1CARNAGE!\n");
2470 } else if(type == KILL_SPREE_30) {
2472 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2474 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2476 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2477 if (type == DEATH_DROWN) {
2478 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2482 print ("^1",s1, "^1 was in the water for too long\n");
2484 print ("^1",s1, "^1 drowned\n");
2486 } else if (type == DEATH_SLIME) {
2487 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2489 print ("^1",s1, "^1 was slimed\n");
2490 } else if (type == DEATH_LAVA) {
2491 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2495 print ("^1",s1, "^1 found a hot place\n");
2497 print ("^1",s1, "^1 turned into hot slag\n");
2499 } else if (type == DEATH_FALL) {
2500 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2504 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2506 print ("^1",s1, "^1 hit the ground with a crunch\n");
2508 } else if (type == DEATH_SHOOTING_STAR) {
2509 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2511 print ("^1",s1, "^1 became a shooting star\n");
2512 } else if (type == DEATH_SWAMP) {
2513 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2517 print ("^1",s1, "^1 discovered a swamp\n");
2519 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2521 } else if(type == DEATH_TURRET) {
2522 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2524 print ("^1",s1, "^1 was mowed down by a turret \n");
2525 } else if (type == DEATH_CUSTOM) {
2526 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2528 print ("^1",s1, "^1 ", s2, "\n");
2529 } else if (type == DEATH_HURTTRIGGER) {
2530 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2532 print ("^1",s1, "^1 was in the wrong place\n");
2533 } else if(type == DEATH_TOUCHEXPLODE) {
2534 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2536 print ("^1",s1, "^1 died in an accident\n");
2537 } else if(type == DEATH_CHEAT) {
2538 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2540 print ("^1",s1, "^1 was unfairly eliminated\n");
2541 } else if(type == DEATH_FIRE) {
2542 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2546 print ("^1",s1, "^1 felt a little hot\n");
2548 print ("^1",s1, "^1 burnt to death\n");
2551 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2555 print ("^1",s1, "^1 needs a restart\n");
2557 print ("^1",s1, "^1 died\n");
2560 } else if(msg == MSG_KILL_ACTION_SPREE) {
2562 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2564 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2565 } else if(msg == MSG_INFO) {
2566 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2567 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2568 print(s1, "^7 got the ", s2, "\n");
2569 } else if(type == INFO_LOSTFLAG) {
2570 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2571 print(s1, "^7 lost the ", s2, "\n");
2572 } else if(type == INFO_PICKUPFLAG) {
2573 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2574 print(s1, "^7 picked up the ", s2, "\n");
2575 } else if(type == INFO_RETURNFLAG) {
2576 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2577 print(s1, "^7 returned the ", s2, "\n");
2582 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2584 void HUD_Centerprint(string s1, string s2, float type, float msg)
2587 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2588 if(msg == MSG_SUICIDE) {
2589 if (type == DEATH_TEAMCHANGE) {
2590 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2591 } else if (type == DEATH_AUTOTEAMCHANGE) {
2592 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2593 } else if (type == DEATH_CAMP) {
2595 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2597 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2598 } else if (type == DEATH_NOAMMO) {
2600 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2602 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2603 } else if (type == DEATH_ROT) {
2605 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2607 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2608 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2610 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2612 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2613 } else if (type == DEATH_QUIET) {
2615 } else if (type == DEATH_KILL) {
2617 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2619 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2621 } else if(msg == MSG_KILL) {
2622 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2624 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2626 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2628 } else if (type == KILL_FIRST_BLOOD) {
2630 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2632 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2634 } else if (type == KILL_FIRST_VICTIM) {
2636 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2638 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2640 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2642 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2644 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2646 } else if (type == KILL_TYPEFRAGGED) {
2648 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2650 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2652 } else if (type == KILL_FRAG) {
2654 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2656 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2658 } else if (type == KILL_FRAGGED) {
2660 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2662 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2665 } else if(msg == MSG_KILL_ACTION) {
2666 // TODO: invent more centerprints here?
2667 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2671 void HUD_Notify (void)
2673 if(!autocvar_hud_notify && !autocvar__hud_configure)
2676 float id = HUD_PANEL_NOTIFY;
2677 HUD_Panel_UpdateCvarsForId(id);
2680 mySize = panel_size;
2682 HUD_Panel_DrawBg(1);
2683 if(panel_bg_padding)
2685 pos += '1 1 0' * panel_bg_padding;
2686 mySize -= '2 2 0' * panel_bg_padding;
2689 float entries, height;
2690 entries = bound(1, floor(10 * mySize_y/mySize_x), 10);
2691 height = mySize_y/entries;
2694 fontsize = '0.5 0.5 0' * height;
2698 when = autocvar_hud_notify_time;
2700 fadetime = autocvar_hud_notify_fadetime;
2705 vector pos_attacker, pos_victim;
2707 float width_attacker;
2708 string attacker, victim;
2711 for(j = 0; j < entries; ++j)
2714 if(autocvar_hud_notify_flip)
2716 else // rather nasty hack for ordering items from the bottom up
2717 i = entries - j - 1;
2721 if(killnotify_times[j] + when > time)
2724 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2728 if(killnotify_times[j] + when > time)
2734 // TODO: maybe print in team colors?
2737 if(killnotify_actiontype[j] == 0 && !autocvar__hud_configure)
2739 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2740 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
2741 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2743 if(killnotify_deathtype[j] == DEATH_GENERIC)
2748 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2750 s = "notify_outofammo";
2753 else if(killnotify_deathtype[j] == DEATH_KILL)
2755 s = "notify_selfkill";
2758 else if(killnotify_deathtype[j] == DEATH_CAMP)
2760 s = "notify_camping";
2763 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2765 s = "notify_teamkill";
2768 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2770 s = "notify_teamkill";
2773 else if(killnotify_deathtype[j] == DEATH_DROWN)
2778 else if(killnotify_deathtype[j] == DEATH_SLIME)
2783 else if(killnotify_deathtype[j] == DEATH_LAVA)
2788 else if(killnotify_deathtype[j] == DEATH_FALL)
2793 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2798 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2803 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2805 if(killnotify_victims[j] == "^1RED^7 flag")
2807 s = "flag_red_carrying";
2812 s = "flag_blue_carrying";
2816 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2818 if(killnotify_victims[j] == "^1RED^7 flag")
2820 s = "flag_red_taken";
2825 s = "flag_blue_taken";
2829 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2831 if(killnotify_victims[j] == "^1RED^7 flag")
2833 s = "flag_red_lost";
2838 s = "flag_blue_lost";
2844 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, color, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2845 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2848 // X [did action to] Y
2851 if(autocvar__hud_configure)
2853 attacker = textShortenToWidth("Player1", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2854 victim = textShortenToWidth("Player2", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2855 a = bound(0, (when - j) / 4, 1);
2859 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2860 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2862 width_attacker = stringwidth(attacker, TRUE, fontsize);
2863 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
2864 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
2865 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2867 if(autocvar__hud_configure) // example actions for config mode
2869 s = "weaponelectro";
2872 else if(WEP_VALID(killnotify_deathtype[j]))
2874 self = get_weaponinfo(killnotify_deathtype[j]);
2875 s = strcat("weapon", self.netname);
2878 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2880 s = "notify_teamkill";
2883 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2885 s = "notify_teamkill";
2888 else if(killnotify_deathtype[j] == DEATH_DROWN)
2893 else if(killnotify_deathtype[j] == DEATH_SLIME)
2898 else if(killnotify_deathtype[j] == DEATH_LAVA)
2903 else if(killnotify_deathtype[j] == DEATH_FALL)
2908 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2910 s = "notify_shootingstar";
2913 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2920 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, color, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2921 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2922 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2931 string seconds_tostring(float sec)
2934 minutes = floor(sec / 60);
2936 sec -= minutes * 60;
2939 s = ftos(100 + sec);
2941 return strcat(ftos(minutes), ":", substring(s, 1, 3));
2944 void HUD_Timer(void)
2946 if(!autocvar_hud_timer && !autocvar__hud_configure)
2949 float id = HUD_PANEL_TIMER;
2950 HUD_Panel_UpdateCvarsForId(id);
2953 mySize = panel_size;
2955 HUD_Panel_DrawBg(1);
2956 if(panel_bg_padding)
2958 pos += '1 1 0' * panel_bg_padding;
2959 mySize -= '2 2 0' * panel_bg_padding;
2963 float timelimit, elapsedTime, timeleft, minutesLeft;
2965 timelimit = getstatf(STAT_TIMELIMIT);
2967 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
2968 timeleft = ceil(timeleft);
2970 minutesLeft = floor(timeleft / 60);
2973 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
2974 timer_color = '1 1 1'; //white
2975 else if(minutesLeft >= 1)
2976 timer_color = '1 1 0'; //yellow
2978 timer_color = '1 0 0'; //red
2980 if (autocvar_hud_timer_increment || timelimit == 0 || warmup_stage) {
2981 if (time < getstatf(STAT_GAMESTARTTIME)) {
2982 //while restart is still active, show 00:00
2983 timer = seconds_tostring(0);
2985 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
2986 timer = seconds_tostring(elapsedTime);
2989 timer = seconds_tostring(timeleft);
2992 drawfont = hud_bigfont;
2993 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2994 drawfont = hud_font;
2999 void HUD_Radar(void)
3001 if (!(autocvar_hud_radar != 0 && (autocvar_hud_radar == 2 || teamplay || autocvar__hud_configure)))
3004 float id = HUD_PANEL_RADAR;
3005 HUD_Panel_UpdateCvarsForId(id);
3008 mySize = panel_size;
3010 HUD_Panel_DrawBg(1);
3011 if(panel_bg_padding)
3013 pos += '1 1 0' * panel_bg_padding;
3014 mySize -= '2 2 0' * panel_bg_padding;
3017 local float color1, color2; // color already declared as a global in hud.qc
3020 float scale2d, normalsize, bigsize;
3023 teamradar_origin2d = pos + 0.5 * mySize;
3024 teamradar_size2d = mySize;
3026 if(minimapname == "")
3029 teamradar_loadcvars();
3031 switch(hud_radar_zoommode)
3035 f = current_zoomfraction;
3038 f = 1 - current_zoomfraction;
3048 switch(hud_radar_rotation)
3051 teamradar_angle = view_angles_y - 90;
3054 teamradar_angle = 90 * hud_radar_rotation;
3058 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3059 teamradar_size2d = mySize;
3061 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3063 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3064 if(hud_radar_rotation == 0)
3066 // max-min distance must fit the radar in any rotation
3067 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3071 vector c0, c1, c2, c3, span;
3072 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3073 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3074 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3075 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3077 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3078 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3080 // max-min distance must fit the radar in x=x, y=y
3082 teamradar_size2d_x * scale2d / (1.05 * span_x),
3083 teamradar_size2d_y * scale2d / (1.05 * span_y)
3087 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3088 if(bigsize > normalsize)
3089 normalsize = bigsize;
3093 + (1 - f) * normalsize;
3094 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3095 f * (mi_min + mi_max) * 0.5
3096 + (1 - f) * view_origin);
3098 color1 = GetPlayerColor(player_localentnum-1);
3099 rgb = GetTeamRGB(color1);
3108 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3110 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3111 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3112 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3113 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3114 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3116 color2 = GetPlayerColor(tm.sv_entnum);
3117 //if(color == COLOR_SPECTATOR || color == color2)
3118 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3120 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3122 drawresetcliparea();
3127 void HUD_Score(void)
3129 if(!autocvar_hud_score && !autocvar__hud_configure)
3132 float id = HUD_PANEL_SCORE;
3133 HUD_Panel_UpdateCvarsForId(id);
3136 mySize = panel_size;
3138 HUD_Panel_DrawBg(1);
3139 if(panel_bg_padding)
3141 pos += '1 1 0' * panel_bg_padding;
3142 mySize -= '2 2 0' * panel_bg_padding;
3145 float score, distribution, leader;
3146 vector distribution_color;
3148 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3150 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3151 string timer, distrtimer;
3153 pl = players.sort_next;
3156 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3157 if(pl.scores[ps_primary] == 0)
3160 score = me.(scores[ps_primary]);
3161 timer = seconds_tostring(score/TIME_FACTOR);
3162 timer = strcat(timer, ":", ftos_decimals(mod(score, TIME_FACTOR), log(TIME_FACTOR)));
3164 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3165 // distribution display
3166 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3168 distrtimer = seconds_tostring(distribution/TIME_FACTOR);
3169 distrtimer = strcat(timer, ":", ftos_decimals(mod(distribution, TIME_FACTOR), log(TIME_FACTOR)));
3171 if (distribution <= 0) {
3172 distribution_color = '0 1 0';
3175 distribution_color = '1 0 0';
3177 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);
3179 // race record display
3180 if (distribution <= 0)
3181 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3182 drawfont = hud_bigfont;
3183 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3184 drawfont = hud_font;
3185 } else if (!teamplay) { // non-teamgames
3186 // me vector := [team/connected frags id]
3187 pl = players.sort_next;
3191 if(autocvar__hud_configure)
3194 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3198 score = me.(scores[ps_primary]);
3199 if(autocvar__hud_configure)
3202 if(distribution >= 5) {
3203 distribution_color = eY;
3205 } else if(distribution >= 0) {
3206 distribution_color = '1 1 1';
3208 } else if(distribution >= -5)
3209 distribution_color = '1 1 0';
3211 distribution_color = eX;
3213 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);
3215 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3216 drawfont = hud_bigfont;
3217 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3218 drawfont = hud_font;
3219 } else { // teamgames
3220 float max_fragcount;
3221 max_fragcount = -99;
3224 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3225 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !autocvar__hud_configure)) // no players? don't display
3227 score = tm.(teamscores[ts_primary]);
3228 if(autocvar__hud_configure)
3232 if (score > max_fragcount)
3233 max_fragcount = score;
3235 if(tm.team == myteam) {
3236 if (max_fragcount == score)
3239 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3240 drawfont = hud_bigfont;
3241 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3242 drawfont = hud_font;
3244 if (max_fragcount == score)
3247 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);
3248 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);
3257 void HUD_RaceTimer (void) {
3258 if(!autocvar_hud_racetimer && !(gametype == GAME_RACE || gametype == GAME_CTS) && !autocvar__hud_configure)
3261 float id = HUD_PANEL_RACETIMER;
3262 HUD_Panel_UpdateCvarsForId(id);
3265 mySize = panel_size;
3267 HUD_Panel_DrawBg(1);
3268 if(panel_bg_padding)
3270 pos += '1 1 0' * panel_bg_padding;
3271 mySize -= '2 2 0' * panel_bg_padding;
3274 // always force 4:1 aspect
3276 if(mySize_x/mySize_y > 4)
3278 newSize_x = 4 * mySize_y;
3279 newSize_y = mySize_y;
3281 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3285 newSize_y = 1/4 * mySize_x;
3286 newSize_x = mySize_x;
3288 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3292 drawfont = hud_bigfont;
3294 string s, forcetime;
3296 if(autocvar__hud_configure)
3299 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);
3300 s = "^1Intermediate 1 (+15.42)";
3301 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);
3302 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3303 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);
3305 else if(race_checkpointtime)
3307 a = bound(0, 2 - (time - race_checkpointtime), 1);
3310 if(a > 0) // just hit a checkpoint?
3312 if(race_checkpoint != 254)
3314 if(race_time && race_previousbesttime)
3315 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3317 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3319 forcetime = TIME_ENCODED_TOSTRING(race_time);
3324 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3326 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3327 if(a > 0) // next one?
3329 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3334 if(s != "" && a > 0)
3336 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);
3339 if(race_penaltytime)
3341 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3344 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3345 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);
3351 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3352 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);
3357 if(race_laptime && race_checkpoint != 255)
3359 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3360 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);
3365 if(race_mycheckpointtime)
3367 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3368 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3369 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);
3371 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3373 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3374 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3375 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);
3378 if(race_penaltytime && !race_penaltyaccumulator)
3380 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3381 a = bound(0, (1 + t - time), 1);
3385 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3387 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3388 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);
3393 drawfont = hud_font;
3398 float vote_yescount;
3401 float vote_highlighted; // currently selected vote
3403 float vote_active; // is there an active vote?
3404 float vote_prev; // previous state of vote_active to check for a change
3406 float vote_change; // "time" when vote_active changed
3408 void HUD_VoteWindow(void)
3410 if(!autocvar_hud_vote && !autocvar__hud_configure)
3413 float id = HUD_PANEL_VOTE;
3414 HUD_Panel_UpdateCvarsForId(id);
3417 mySize = panel_size;
3421 if(vote_active != vote_prev) {
3423 vote_prev = vote_active;
3426 if(vote_active || autocvar__hud_configure)
3427 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3429 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3431 if(autocvar__hud_configure)
3441 a = vote_alpha * bound(autocvar_hud_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3443 HUD_Panel_DrawBg(a);
3444 if(panel_bg_padding)
3446 pos += '1 1 0' * panel_bg_padding;
3447 mySize -= '2 2 0' * panel_bg_padding;
3450 // always force 3:1 aspect
3452 if(mySize_x/mySize_y > 3)
3454 newSize_x = 3 * mySize_y;
3455 newSize_y = mySize_y;
3457 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3461 newSize_y = 1/3 * mySize_x;
3462 newSize_x = mySize_x;
3464 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3468 s = "A vote has been called for:";
3469 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3470 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1.75/8), stringwidth_colors);
3471 if(autocvar__hud_configure)
3472 s = "^1Configure the HUD";
3473 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3475 // print the yes/no counts
3476 s = strcat("Yes (", getcommandkey("not bound", "vyes"), "): ", ftos(vote_yescount));
3477 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);
3478 s = strcat("No (", getcommandkey("not bound", "vno"), "): ", ftos(vote_nocount));
3479 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);
3481 // draw the progress bar backgrounds
3482 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);
3484 // draw the highlights
3485 if(vote_highlighted == 1) {
3486 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3487 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);
3489 else if(vote_highlighted == 2) {
3490 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3491 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);
3494 // draw the progress bars
3495 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3496 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);
3498 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3499 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);
3501 drawresetcliparea();
3504 vote_highlighted = 0;
3508 // Mod icons panel (#10)
3511 float mod_active; // is there any active mod icon?
3513 // CTF HUD modicon section
3514 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3515 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3516 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3518 void HUD_Mod_CTF_Reset(void)
3520 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3523 void HUD_Mod_CTF(vector pos, vector mySize)
3525 vector redflag_pos, blueflag_pos;
3527 float f; // every function should have that
3529 float redflag, blueflag; // current status
3530 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3533 stat_items = getstati(STAT_ITEMS);
3534 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3535 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3537 if(redflag || blueflag)
3542 if(autocvar__hud_configure)
3548 // when status CHANGES, set old status into prevstatus and current status into status
3549 if (redflag != redflag_prevframe)
3551 redflag_statuschange_time = time;
3552 redflag_prevstatus = redflag_prevframe;
3553 redflag_prevframe = redflag;
3556 if (blueflag != blueflag_prevframe)
3558 blueflag_statuschange_time = time;
3559 blueflag_prevstatus = blueflag_prevframe;
3560 blueflag_prevframe = blueflag;
3563 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3564 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3566 float BLINK_FACTOR = 0.15;
3567 float BLINK_BASE = 0.85;
3569 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3571 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3573 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3575 string red_icon, red_icon_prevstatus;
3576 float red_alpha, red_alpha_prevstatus;
3577 red_alpha = red_alpha_prevstatus = 1;
3579 case 1: red_icon = "flag_red_taken"; break;
3580 case 2: red_icon = "flag_red_lost"; break;
3581 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3583 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3584 red_icon = "flag_red_shielded";
3586 red_icon = string_null;
3589 switch(redflag_prevstatus) {
3590 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3591 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3592 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3595 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3596 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3597 red_icon_prevstatus = "flag_red_shielded";
3599 red_icon_prevstatus = string_null;
3603 string blue_icon, blue_icon_prevstatus;
3604 float blue_alpha, blue_alpha_prevstatus;
3605 blue_alpha = blue_alpha_prevstatus = 1;
3607 case 1: blue_icon = "flag_blue_taken"; break;
3608 case 2: blue_icon = "flag_blue_lost"; break;
3609 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3611 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3612 blue_icon = "flag_blue_shielded";
3614 blue_icon = string_null;
3617 switch(blueflag_prevstatus) {
3618 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3619 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3620 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3623 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3624 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3625 blue_icon_prevstatus = "flag_blue_shielded";
3627 blue_icon_prevstatus = string_null;
3631 if(mySize_x > mySize_y) {
3632 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3634 blueflag_pos = pos + eX * 0.5 * mySize_x;
3637 redflag_pos = pos + eX * 0.5 * mySize_x;
3639 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3641 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3643 blueflag_pos = pos + eY * 0.5 * mySize_y;
3646 redflag_pos = pos + eY * 0.5 * mySize_y;
3648 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3651 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3652 if(red_icon_prevstatus && f < 1)
3653 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3655 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3657 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3658 if(blue_icon_prevstatus && f < 1)
3659 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3661 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3664 // Keyhunt HUD modicon section
3665 float kh_runheretime;
3667 void HUD_Mod_KH_Reset(void)
3672 void HUD_Mod_KH(vector pos, vector mySize)
3674 mod_active = 1; // keyhunt should never hide the mod icons panel
3678 vector p, pa, kh_size, kh_asize;
3680 kh_keys = getstati(STAT_KH_KEYS);
3683 if(mySize_x > mySize_y)
3685 p_y = pos_y + 0.25 * mySize_y;
3686 pa = p - eY * 0.25 * mySize_y;
3688 kh_size_x = mySize_x * 0.25;
3689 kh_size_y = 0.75 * mySize_y;
3690 kh_asize_x = mySize_x * 0.25;
3691 kh_asize_y = mySize_y * 0.25;
3695 p_y = pos_y + 0.125 * mySize_y;
3696 pa = p - eY * 0.125 * mySize_y;
3698 kh_size_x = mySize_x * 0.5;
3699 kh_size_y = 0.375 * mySize_y;
3700 kh_asize_x = mySize_x * 0.5;
3701 kh_asize_y = mySize_y * 0.125;
3708 for(i = 0; i < 4; ++i)
3710 key = floor(kh_keys / pow(32, i)) & 31;
3712 if(keyteam == 30 && keycount <= 4)
3714 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3718 // this yields 8 exactly if "RUN HERE" shows
3723 kh_runheretime = time;
3724 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3729 for(i = 0; i < 4; ++i)
3731 key = floor(kh_keys / pow(32, i)) & 31;
3744 default: // owned or dropped
3749 a = a * panel_fg_alpha;
3750 aa = aa * panel_fg_alpha;
3756 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3759 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3762 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3765 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3770 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3773 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3776 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3779 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3782 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3786 if(mySize_x > mySize_y)
3788 p_x += 0.25 * mySize_x;
3789 pa_x += 0.25 * mySize_x;
3795 p_y = pos_y + 0.625 * mySize_y;
3796 pa_y = pos_y + 0.5 * mySize_y;
3802 p_x += 0.5 * mySize_x;
3803 pa_x += 0.5 * mySize_x;
3809 // Nexball HUD mod icon
3810 void HUD_Mod_NexBall(vector pos, vector mySize)
3812 float stat_items, nb_pb_starttime, dt, p;
3814 stat_items = getstati(STAT_ITEMS);
3815 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3817 if (stat_items & IT_KEY1)
3822 //Manage the progress bar if any
3823 if (nb_pb_starttime > 0)
3825 dt = mod(time - nb_pb_starttime, nb_pb_period);
3826 // one period of positive triangle
3827 p = 2 * dt / nb_pb_period;
3834 if(mySize_x > mySize_y)
3836 barsize = eX * p * mySize_x + eY * mySize_y;
3841 barsize = eX * mySize_x + eY * p * mySize_y;
3844 HUD_Panel_GetProgressBarColor("nexball")
3845 HUD_Panel_DrawProgressBar(pos, vertical, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3848 if (stat_items & IT_KEY1)
3849 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3852 // Race/CTS HUD mod icons
3853 float crecordtime_prev; // last remembered crecordtime
3854 float crecordtime_change_time; // time when crecordtime last changed
3855 float srecordtime_prev; // last remembered srecordtime
3856 float srecordtime_change_time; // time when srecordtime last changed
3858 float race_status_time;
3859 float race_status_prev;
3860 string race_status_name_prev;
3861 void HUD_Mod_Race(vector pos, vector mySize)
3863 mod_active = 1; // race should never hide the mod icons panel
3865 me = playerslots[player_localentnum - 1];
3867 float f; // yet another function has this
3868 score = me.(scores[ps_primary]);
3870 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3871 return; // no records in the actual race
3873 drawfont = hud_bigfont;
3875 // clientside personal record
3877 if(gametype == GAME_CTS)
3881 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3883 if(score && (score < t || !t)) {
3884 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3885 if(cvar("cl_autodemo_delete_keeprecords"))
3887 f = cvar("cl_autodemo_delete");
3889 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3893 if(t != crecordtime_prev) {
3894 crecordtime_prev = t;
3895 crecordtime_change_time = time;
3897 f = time - crecordtime_change_time;
3900 drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3901 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);
3903 drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3904 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);
3905 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);
3906 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);
3910 t = race_server_record;
3911 if(t != srecordtime_prev) {
3912 srecordtime_prev = t;
3913 srecordtime_change_time = time;
3915 f = time - srecordtime_change_time;
3918 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);
3919 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);
3921 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);
3922 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);
3923 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);
3924 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);
3927 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
3928 race_status_time = time + 5;
3929 race_status_prev = race_status;
3930 if (race_status_name_prev)
3931 strunzone(race_status_name_prev);
3932 race_status_name_prev = strzone(race_status_name);
3935 pos_x += mySize_x/2;
3938 a = bound(0, race_status_time - time, 1);
3941 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
3945 rank = race_CheckName(race_status_name);
3947 rankname = race_PlaceName(rank);
3950 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
3952 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
3954 if(race_status == 0)
3955 drawpic_aspect_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3956 else if(race_status == 1) {
3957 drawpic_aspect_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3958 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3959 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3960 } else if(race_status == 2) {
3961 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
3962 drawpic_aspect_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3964 drawpic_aspect_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3965 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3966 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3967 } else if(race_status == 3) {
3968 drawpic_aspect_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3969 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3970 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3973 if (race_status_time - time <= 0) {
3974 race_status_prev = -1;
3976 if(race_status_name)
3977 strunzone(race_status_name);
3978 race_status_name = string_null;
3979 if(race_status_name_prev)
3980 strunzone(race_status_name_prev);
3981 race_status_name_prev = string_null;
3983 drawfont = hud_font;
3986 float mod_prev; // previous state of mod_active to check for a change
3988 float mod_change; // "time" when mod_active changed
3990 void HUD_ModIcons(void)
3992 if(!autocvar_hud_modicons && !autocvar__hud_configure)
3995 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !autocvar__hud_configure)
3998 float id = HUD_PANEL_MODICONS;
3999 HUD_Panel_UpdateCvarsForId(id);
4002 mySize = panel_size;
4004 if(mod_active != mod_prev) {
4006 mod_prev = mod_active;
4009 if(mod_active || autocvar__hud_configure)
4010 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4012 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4015 HUD_Panel_DrawBg(mod_alpha);
4017 if(panel_bg_padding)
4019 pos += '1 1 0' * panel_bg_padding;
4020 mySize -= '2 2 0' * panel_bg_padding;
4023 // these MUST be ran in order to update mod_active
4024 if(gametype == GAME_KEYHUNT)
4025 HUD_Mod_KH(pos, mySize);
4026 else if(gametype == GAME_CTF || autocvar__hud_configure)
4027 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4028 else if(gametype == GAME_NEXBALL)
4029 HUD_Mod_NexBall(pos, mySize);
4030 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4031 HUD_Mod_Race(pos, mySize);
4034 // Draw pressed keys (#11)
4036 void HUD_DrawPressedKeys(void)
4038 if(!autocvar_hud_pressedkeys && !autocvar__hud_configure)
4041 if(!(spectatee_status > 0 || autocvar_hud_pressedkeys >= 2 || autocvar__hud_configure))
4044 float id = HUD_PANEL_PRESSEDKEYS;
4045 HUD_Panel_UpdateCvarsForId(id);
4048 mySize = panel_size;
4050 HUD_Panel_DrawBg(1);
4051 if(panel_bg_padding)
4053 pos += '1 1 0' * panel_bg_padding;
4054 mySize -= '2 2 0' * panel_bg_padding;
4057 // always force 2:1 aspect
4059 if(mySize_x/mySize_y > 2)
4061 newSize_x = 2 * mySize_y;
4062 newSize_y = mySize_y;
4064 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4068 newSize_y = 1/2 * mySize_x;
4069 newSize_x = mySize_x;
4071 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4076 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4079 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4080 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4081 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);
4082 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);
4083 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);
4084 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);
4085 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);
4088 // Handle chat as a panel (#12)
4092 if(!autocvar_hud_chat && !autocvar__hud_configure)
4094 cvar_set("con_chatrect", "0");
4098 float id = HUD_PANEL_CHAT;
4099 HUD_Panel_UpdateCvarsForId(id);
4102 mySize = panel_size;
4104 HUD_Panel_DrawBg(1);
4105 if(panel_bg_padding)
4107 pos += '1 1 0' * panel_bg_padding;
4108 mySize -= '2 2 0' * panel_bg_padding;
4111 cvar_set("con_chatrect", "1");
4113 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4114 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4116 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4117 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4119 if(autocvar__hud_configure)
4122 chatsize = cvar("con_chatsize");
4123 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4125 for(i = 0; i < cvar("con_chat"); ++i)
4127 if(i == cvar("con_chat") - 1)
4130 a = panel_fg_alpha * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4131 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);
4136 // Engine info panel (#13)
4143 float frametimeavg1; // 1 frame ago
4144 float frametimeavg2; // 2 frames ago
4145 void HUD_EngineInfo(void)
4147 if(!autocvar_hud_engineinfo && !autocvar__hud_configure)
4150 float id = HUD_PANEL_ENGINEINFO;
4151 HUD_Panel_UpdateCvarsForId(id);
4154 mySize = panel_size;
4156 HUD_Panel_DrawBg(1);
4157 if(panel_bg_padding)
4159 pos += '1 1 0' * panel_bg_padding;
4160 mySize -= '2 2 0' * panel_bg_padding;
4163 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4165 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4166 frametimeavg2 = frametimeavg1;
4167 frametimeavg1 = frametimeavg;
4170 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4171 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.
4173 if(fabs(prevfps - (1/frametimeavg)) > prevfps * cvar("hud_engineinfo_framecounter_exponentialmovingaverage_instantupdate_change_threshold")) // if there was a big jump in fps, just force prevfps at current (1/frametime) to make big updates instant
4174 prevfps = (1/frametime);
4175 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"
4181 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4183 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4185 prevfps_time = time;
4190 color = HUD_Get_Num_Color (prevfps, 100);
4191 drawfont = hud_bigfont;
4192 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4193 drawfont = hud_font;
4196 // Info messages panel (#14)
4198 void HUD_InfoMessages(void)
4200 if(!autocvar_hud_infomessages && !autocvar__hud_configure)
4203 float id = HUD_PANEL_INFOMESSAGES;
4204 HUD_Panel_UpdateCvarsForId(id);
4207 mySize = panel_size;
4209 HUD_Panel_DrawBg(1);
4210 if(panel_bg_padding)
4212 pos += '1 1 0' * panel_bg_padding;
4213 mySize -= '2 2 0' * panel_bg_padding;
4216 // always force 6:1 aspect
4218 if(mySize_x/mySize_y > 6)
4220 newSize_x = 6 * mySize_y;
4221 newSize_y = mySize_y;
4223 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4227 newSize_y = 1/6 * mySize_x;
4228 newSize_x = mySize_x;
4230 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4239 fontsize = '0.25 0.25 0' * mySize_y;
4242 if(!autocvar__hud_configure)
4244 if(spectatee_status && !intermission)
4246 //drawfont = hud_bigfont;
4247 if(spectatee_status == -1)
4250 s = GetPlayerName(spectatee_status - 1);
4252 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
4253 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, panel_fg_alpha, DRAWFLAG_NORMAL);
4254 //drawfont = hud_font;
4256 // spectator text in the upper right corner
4257 if(spectatee_status == -1)
4258 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
4260 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
4261 if(autocvar_hud_infomessages_flip)
4262 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4263 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4264 o += eY * fontsize_y;
4266 if(spectatee_status == -1)
4267 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
4269 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
4270 if(autocvar_hud_infomessages_flip)
4271 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4272 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4273 o += eY * fontsize_y;
4275 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
4276 if(autocvar_hud_infomessages_flip)
4277 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4278 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4279 o += eY * fontsize_y;
4281 if(gametype == GAME_ARENA)
4282 s = "^1Wait for your turn to join";
4283 else if(gametype == GAME_LMS)
4286 sk = playerslots[player_localentnum - 1];
4287 if(sk.(scores[ps_primary]) >= 666)
4288 s = "^1Match has already begun";
4289 else if(sk.(scores[ps_primary]) > 0)
4290 s = "^1You have no more lives left";
4292 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4295 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4296 if(autocvar_hud_infomessages_flip)
4297 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4298 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4299 o += eY * fontsize_y;
4301 //show restart countdown:
4302 if (time < getstatf(STAT_GAMESTARTTIME)) {
4304 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4305 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4306 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
4307 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4308 o += eY * fontsize_y;
4311 if(warmup_stage && !intermission)
4313 s = "^2Currently in ^1warmup^2 stage!";
4314 if(autocvar_hud_infomessages_flip)
4315 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4316 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4317 o += eY * fontsize_y;
4321 if(mod(time, 1) >= 0.5)
4326 if(ready_waiting && !intermission && !spectatee_status)
4328 if(ready_waiting_for_me)
4331 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
4333 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
4338 s = strcat("^2Waiting for others to ready up to end warmup...");
4340 s = strcat("^2Waiting for others to ready up...");
4342 if(autocvar_hud_infomessages_flip)
4343 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4344 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4345 o += eY * fontsize_y;
4347 else if(warmup_stage && !intermission && !spectatee_status)
4349 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
4350 if(autocvar_hud_infomessages_flip)
4351 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4352 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4353 o += eY * fontsize_y;
4356 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4358 float ts_min, ts_max;
4359 tm = teams.sort_next;
4362 for(; tm.sort_next; tm = tm.sort_next)
4364 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4366 if(!ts_min) ts_min = tm.team_size;
4367 else ts_min = min(ts_min, tm.team_size);
4368 if(!ts_max) ts_max = tm.team_size;
4369 else ts_max = max(ts_max, tm.team_size);
4371 if ((ts_max - ts_min) > 1)
4373 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
4374 tm = GetTeam(myteam, false);
4376 if (tm.team != COLOR_SPECTATOR)
4377 if (tm.team_size == ts_max)
4378 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
4380 if(autocvar_hud_infomessages_flip)
4381 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4382 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4383 o += eY * fontsize_y;
4390 s = "^7Press ^3ESC ^7to show HUD options.";
4391 if(autocvar_hud_infomessages_flip)
4392 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4393 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4394 o += eY * fontsize_y;
4395 s = "^3Doubleclick ^7a panel for panel-specific options.";
4396 if(autocvar_hud_infomessages_flip)
4397 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4398 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4399 o += eY * fontsize_y;
4400 s = "^3CTRL ^7to disable collision testing, ^3SHIFT ^7and";
4401 if(autocvar_hud_infomessages_flip)
4402 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4403 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4404 o += eY * fontsize_y;
4405 s = "^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.";
4406 if(autocvar_hud_infomessages_flip)
4407 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4408 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4409 o += eY * fontsize_y;
4419 void HUD_ShowSpeed(void)
4422 float pos, conversion_factor;
4423 string speed, zspeed, unit;
4425 switch(cvar("cl_showspeed_unit"))
4430 conversion_factor = 1.0;
4434 conversion_factor = 1.0;
4438 conversion_factor = 0.0254;
4442 conversion_factor = 0.0254 * 3.6;
4446 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4450 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4454 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4456 numsize_x = numsize_y = cvar("cl_showspeed_size");
4457 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4459 drawfont = hud_bigfont;
4460 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4462 if (cvar("cl_showspeed_z") == 1) {
4463 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4464 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4467 drawfont = hud_font;
4470 vector acc_prevspeed;
4474 void HUD_ShowAcceleration(void)
4476 float acceleration, sz, scale, alpha, f;
4477 vector pos, top, rgb;
4478 top_x = vid_conwidth/2;
4481 f = time - acc_prevtime;
4482 if(cvar("cl_showacceleration_z"))
4483 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4485 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4486 acc_prevspeed = pmove_vel;
4487 acc_prevtime = time;
4489 f = bound(0, f * 10, 1);
4490 acc_avg = acc_avg * (1 - f) + acceleration * f;
4491 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4493 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4495 sz = cvar("cl_showacceleration_size");
4496 scale = cvar("cl_showacceleration_scale");
4497 alpha = cvar("cl_showacceleration_alpha");
4498 if (cvar("cl_showacceleration_color_custom"))
4499 rgb = stov(cvar_string("cl_showacceleration_color"));
4502 if (acceleration < 0) {
4503 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4504 } else if (acceleration > 0) {
4505 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4509 if (acceleration > 0)
4510 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4511 else if (acceleration < 0)
4512 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4515 void HUD_Reset (void)
4517 // reset gametype specific icons
4518 if(gametype == GAME_KEYHUNT)
4520 else if(gametype == GAME_CTF)
4521 HUD_Mod_CTF_Reset();
4524 #define HUD_DrawPanel(id)\
4526 case (HUD_PANEL_RADAR):\
4527 HUD_Radar(); break;\
4528 case (HUD_PANEL_WEAPONICONS):\
4529 HUD_WeaponIcons(); break;\
4530 case (HUD_PANEL_INVENTORY):\
4531 HUD_Inventory(); break;\
4532 case (HUD_PANEL_POWERUPS):\
4533 HUD_Powerups(); break;\
4534 case (HUD_PANEL_HEALTHARMOR):\
4535 HUD_HealthArmor(); break;\
4536 case (HUD_PANEL_NOTIFY):\
4537 HUD_Notify(); break;\
4538 case (HUD_PANEL_TIMER):\
4539 HUD_Timer(); break;\
4540 case (HUD_PANEL_SCORE):\
4541 HUD_Score(); break;\
4542 case (HUD_PANEL_RACETIMER):\
4543 HUD_RaceTimer(); break;\
4544 case (HUD_PANEL_VOTE):\
4545 HUD_VoteWindow(); break;\
4546 case (HUD_PANEL_MODICONS):\
4547 HUD_ModIcons(); break;\
4548 case (HUD_PANEL_PRESSEDKEYS):\
4549 HUD_DrawPressedKeys(); break;\
4550 case (HUD_PANEL_CHAT):\
4552 case (HUD_PANEL_ENGINEINFO):\
4553 HUD_EngineInfo(); break;\
4554 case (HUD_PANEL_INFOMESSAGES):\
4555 HUD_InfoMessages(); break;\
4558 void HUD_Main (void)
4560 hud_skin_path = strcat("gfx/hud/", autocvar_hud_skin);
4562 if(disable_menu_alphacheck == 1)
4563 menu_fade_alpha = 1;
4565 menu_fade_alpha = (1 - autocvar__menu_alpha);
4566 hud_fg_alpha = cvar("hud_fg_alpha");
4568 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4569 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4570 hud_color_bg_team = cvar("hud_color_bg_team");
4572 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4573 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4577 // HUD configure visible grid
4578 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4582 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2); ++i)
4584 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);
4587 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2); ++i)
4589 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);
4595 if(teamplay && autocvar_hud_dock_color_team) {
4596 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4597 color = colormapPaletteColor(mod(f, 16), 1) * autocvar_hud_dock_color_team;
4599 else if(autocvar_hud_dock_color == "shirt") {
4600 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4601 color = colormapPaletteColor(floor(f / 16), 0);
4603 else if(autocvar_hud_dock_color == "pants") {
4604 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4605 color = colormapPaletteColor(mod(f, 16), 1);
4608 color = stov(autocvar_hud_dock_color);
4611 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4614 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4615 if(precache_pic(pic) == "") {
4616 pic = "gfx/hud/default/dock";
4618 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...
4621 // cache the panel order into the panel_order array
4622 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4623 if(hud_panelorder_prev)
4624 strunzone(hud_panelorder_prev);
4625 hud_panelorder_prev = strzone(autocvar__hud_panelorder);
4626 tokenize_console(autocvar__hud_panelorder);
4627 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4628 panel_order[i] = stof(argv(i));
4631 // draw panels in order specified by panel_order array
4632 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
4633 HUD_DrawPanel(panel_order[i]);
4636 // TODO hud_'ify these
4637 if (cvar("cl_showspeed"))
4639 if (cvar("cl_showacceleration"))
4640 HUD_ShowAcceleration();
4642 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)
4643 localcmd("cmd selectteam auto; cmd join\n");
4645 hud_configure_prev = autocvar__hud_configure;
4647 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again
4648 disable_menu_alphacheck = 0;