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"));
470 fputs(fh, strcat("seta hud_", panel_name, "_ammo_color \"", cvar_string(strcat("hud_", panel_name, "_ammo_color")), "\"", "\n"));
471 fputs(fh, strcat("seta hud_", panel_name, "_ammo_alpha \"", cvar_string(strcat("hud_", panel_name, "_ammo_alpha")), "\"", "\n"));
473 case HUD_PANEL_INVENTORY:
474 fputs(fh, strcat("seta hud_", panel_name, "_onlycurrent \"", cvar_string(strcat("hud_", panel_name, "_onlycurrent")), "\"", "\n"));
475 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
477 case HUD_PANEL_POWERUPS:
478 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\"", "\n"));
479 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
480 fputs(fh, strcat("seta hud_", panel_name, "_baralign \"", cvar_string(strcat("hud_", panel_name, "_baralign")), "\"", "\n"));
482 case HUD_PANEL_HEALTHARMOR:
483 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\n"));
484 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
485 fputs(fh, strcat("seta hud_", panel_name, "_baralign \"", cvar_string(strcat("hud_", panel_name, "_baralign")), "\"", "\n"));
487 case HUD_PANEL_NOTIFY:
488 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\"", "\n"));
489 fputs(fh, strcat("seta hud_", panel_name, "_print \"", cvar_string(strcat("hud_", panel_name, "_print")), "\"", "\n"));
491 case HUD_PANEL_RADAR:
492 fputs(fh, strcat("seta hud_", panel_name, "_foreground_alpha \"", cvar_string(strcat("hud_", panel_name, "_foreground_alpha")), "\"", "\n"));
495 fputs(fh, strcat("seta hud_", panel_name, "_alreadyvoted_alpha \"", cvar_string(strcat("hud_", panel_name, "_alreadyvoted_alpha")), "\"", "\n"));
501 print("^2Successfully exported to hud_", autocvar_hud_skin, "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
506 const float hlBorderSize = 4;
507 const string hlBorder = "gfx/hud/default/border_highlighted";
508 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
509 void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
511 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
512 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);
513 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);
514 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);
515 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);
518 // draw the background/borders
519 #define HUD_Panel_DrawBg(alpha)\
521 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));\
522 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
523 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);
525 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
532 pic = strcat(hud_skin_path, "/statusbar_vertical");
533 if(precache_pic(pic) == "") {
534 pic = "gfx/hud/default/statusbar_vertical";
536 drawsubpic(pos, eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, pic, '0 0 0', '1 0.25 0', color, alpha, drawflag);
537 if(mySize_y/mySize_x > 2)
538 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);
539 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);
541 pic = strcat(hud_skin_path, "/statusbar");
542 if(precache_pic(pic) == "") {
543 pic = "gfx/hud/default/statusbar";
545 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
546 if(mySize_x/mySize_y > 2)
547 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);
548 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);
552 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
558 pic = strcat(hud_skin_path, "/num_leading");
559 if(precache_pic(pic) == "") {
560 pic = "gfx/hud/default/num_leading";
563 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
564 if(mySize_x/mySize_y > 2)
565 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);
566 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);
569 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
570 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
581 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
582 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
584 for (i = 0; i < HUD_PANEL_NUM; ++i) {
585 if(i == highlightedPanel || !panel_enabled)
588 HUD_Panel_UpdatePosSizeForId(i)
590 panel_pos -= '1 1 0' * panel_bg_border;
591 panel_size += '2 2 0' * panel_bg_border;
593 if(myPos_y + mySize_y < panel_pos_y)
595 if(myPos_y > panel_pos_y + panel_size_y)
598 if(myPos_x + mySize_x < panel_pos_x)
600 if(myPos_x > panel_pos_x + panel_size_x)
603 // OK, there IS a collision.
605 myCenter_x = myPos_x + 0.5 * mySize_x;
606 myCenter_y = myPos_y + 0.5 * mySize_y;
608 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
609 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
611 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
613 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
614 myTarget_x = panel_pos_x - mySize_x;
615 else // push it upwards
616 myTarget_y = panel_pos_y - mySize_y;
618 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
620 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
621 myTarget_x = panel_pos_x + panel_size_x;
622 else // push it upwards
623 myTarget_y = panel_pos_y - mySize_y;
625 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
627 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
628 myTarget_x = panel_pos_x - mySize_x;
629 else // push it downwards
630 myTarget_y = panel_pos_y + panel_size_y;
632 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
634 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
635 myTarget_x = panel_pos_x + panel_size_x;
636 else // push it downwards
637 myTarget_y = panel_pos_y + panel_size_y;
639 if(cvar("hud_configure_checkcollisions_debug"))
640 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
646 void HUD_Panel_SetPos(vector pos)
648 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
652 if(cvar("hud_configure_checkcollisions_debug"))
653 drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
655 if(autocvar_hud_configure_grid)
657 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;
658 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;
661 if(hud_configure_checkcollisions)
662 pos = HUD_Panel_CheckMove(pos, mySize);
664 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
665 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
668 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
670 HUD_Panel_GetName(highlightedPanel);
671 cvar_set(strcat("hud_", panel_name, "_pos"), s);
674 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
675 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
685 ratio = mySize_x/mySize_y;
687 for (i = 0; i < HUD_PANEL_NUM; ++i) {
688 if(i == highlightedPanel || !panel_enabled)
691 HUD_Panel_UpdatePosSizeForId(i)
693 panel_pos -= '1 1 0' * panel_bg_border;
694 panel_size += '2 2 0' * panel_bg_border;
696 targEndPos = panel_pos + panel_size;
698 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
699 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
702 if (resizeCorner == 1)
704 // check if this panel is on our way
705 if (resizeorigin_x <= panel_pos_x)
707 if (resizeorigin_y <= panel_pos_y)
709 if (targEndPos_x <= resizeorigin_x - mySize_x)
711 if (targEndPos_y <= resizeorigin_y - mySize_y)
714 // there is a collision:
715 // detect which side of the panel we are facing is actually limiting the resizing
716 // (which side the resize direction finds for first) and reduce the size up to there
718 // dist is the distance between resizeorigin and the "analogous" point of the panel
719 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
720 dist_x = resizeorigin_x - targEndPos_x;
721 dist_y = resizeorigin_y - targEndPos_y;
722 if (dist_y <= 0 || dist_x / dist_y > ratio)
723 mySize_x = min(mySize_x, dist_x);
725 mySize_y = min(mySize_y, dist_y);
727 else if (resizeCorner == 2)
729 if (resizeorigin_x >= targEndPos_x)
731 if (resizeorigin_y <= panel_pos_y)
733 if (panel_pos_x >= resizeorigin_x + mySize_x)
735 if (targEndPos_y <= resizeorigin_y - mySize_y)
738 dist_x = panel_pos_x - resizeorigin_x;
739 dist_y = resizeorigin_y - targEndPos_y;
740 if (dist_y <= 0 || dist_x / dist_y > ratio)
741 mySize_x = min(mySize_x, dist_x);
743 mySize_y = min(mySize_y, dist_y);
745 else if (resizeCorner == 3)
747 if (resizeorigin_x <= panel_pos_x)
749 if (resizeorigin_y >= targEndPos_y)
751 if (targEndPos_x <= resizeorigin_x - mySize_x)
753 if (panel_pos_y >= resizeorigin_y + mySize_y)
756 dist_x = resizeorigin_x - targEndPos_x;
757 dist_y = panel_pos_y - resizeorigin_y;
758 if (dist_y <= 0 || dist_x / dist_y > ratio)
759 mySize_x = min(mySize_x, dist_x);
761 mySize_y = min(mySize_y, dist_y);
763 else if (resizeCorner == 4)
765 if (resizeorigin_x >= targEndPos_x)
767 if (resizeorigin_y >= targEndPos_y)
769 if (panel_pos_x >= resizeorigin_x + mySize_x)
771 if (panel_pos_y >= resizeorigin_y + mySize_y)
774 dist_x = panel_pos_x - resizeorigin_x;
775 dist_y = panel_pos_y - resizeorigin_y;
776 if (dist_y <= 0 || dist_x / dist_y > ratio)
777 mySize_x = min(mySize_x, dist_x);
779 mySize_y = min(mySize_y, dist_y);
781 if(cvar("hud_configure_checkcollisions_debug"))
782 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
788 void HUD_Panel_SetPosSize(vector mySize)
790 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
792 resizeorigin = panel_click_resizeorigin;
795 // minimum panel size cap
796 mySize_x = max(0.025 * vid_conwidth, mySize_x);
797 mySize_y = max(0.025 * vid_conheight, mySize_y);
799 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.
801 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
802 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
805 // collision testing|
806 // -----------------+
808 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
809 if(resizeCorner == 1) {
810 myPos_x = resizeorigin_x - mySize_x;
811 myPos_y = resizeorigin_y - mySize_y;
812 } else if(resizeCorner == 2) {
813 myPos_x = resizeorigin_x;
814 myPos_y = resizeorigin_y - mySize_y;
815 } else if(resizeCorner == 3) {
816 myPos_x = resizeorigin_x - mySize_x;
817 myPos_y = resizeorigin_y;
818 } else { // resizeCorner == 4
819 myPos_x = resizeorigin_x;
820 myPos_y = resizeorigin_y;
823 // left/top screen edges
825 mySize_x = mySize_x + myPos_x;
827 mySize_y = mySize_y + myPos_y;
829 // bottom/right screen edges
830 if(myPos_x + mySize_x > vid_conwidth)
831 mySize_x = vid_conwidth - myPos_x;
832 if(myPos_y + mySize_y > vid_conheight)
833 mySize_y = vid_conheight - myPos_y;
835 if(cvar("hud_configure_checkcollisions_debug"))
836 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
838 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
839 if(autocvar_hud_configure_grid)
841 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;
842 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;
845 if(hud_configure_checkcollisions)
846 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
848 // 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)
849 mySize_x = max(0.025 * vid_conwidth, mySize_x);
850 mySize_y = max(0.025 * vid_conheight, mySize_y);
852 // do another pos check, as size might have changed by now
853 if(resizeCorner == 1) {
854 myPos_x = resizeorigin_x - mySize_x;
855 myPos_y = resizeorigin_y - mySize_y;
856 } else if(resizeCorner == 2) {
857 myPos_x = resizeorigin_x;
858 myPos_y = resizeorigin_y - mySize_y;
859 } else if(resizeCorner == 3) {
860 myPos_x = resizeorigin_x - mySize_x;
861 myPos_y = resizeorigin_y;
862 } else { // resizeCorner == 4
863 myPos_x = resizeorigin_x;
864 myPos_y = resizeorigin_y;
867 if(cvar("hud_configure_checkcollisions_debug"))
868 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
870 HUD_Panel_GetName(highlightedPanel);
872 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
873 cvar_set(strcat("hud_", panel_name, "_size"), s);
875 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
876 cvar_set(strcat("hud_", panel_name, "_pos"), s);
880 float prevMouseClicked; // previous state
881 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
882 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
885 float menu_enabled_time;
886 float pressed_key_time;
887 void HUD_Panel_Arrow_Action(float nPrimary)
889 if (highlightedPanel_prev == -1 || mouseClicked)
892 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
895 if(autocvar_hud_configure_grid)
897 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
899 if (hudShiftState & S_SHIFT)
900 step = bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
902 step = 2 * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
906 if (hudShiftState & S_SHIFT)
907 step = bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
909 step = 2 * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
914 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
915 step = vid_conheight;
918 if (hudShiftState & S_SHIFT)
919 step = (step / 256); // more precision
921 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
924 highlightedPanel = highlightedPanel_prev;
926 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
928 if (hudShiftState & S_ALT) // resize
930 highlightedAction = 1;
931 if(nPrimary == K_UPARROW)
933 else if(nPrimary == K_RIGHTARROW)
935 else if(nPrimary == K_LEFTARROW)
937 else // if(nPrimary == K_DOWNARROW)
940 // ctrl+arrow reduces the size, instead of increasing it
941 // Note that ctrl disables collisions check too, but it's fine
942 // since we don't collide with anything reducing the size
943 if (hudShiftState & S_CTRL) {
945 resizeCorner = 5 - resizeCorner;
950 panel_click_resizeorigin = panel_pos;
951 if(resizeCorner == 1) {
952 panel_click_resizeorigin += mySize;
954 } else if(resizeCorner == 2) {
955 panel_click_resizeorigin_y += mySize_y;
957 } else if(resizeCorner == 3) {
958 panel_click_resizeorigin_x += mySize_x;
960 } else { // resizeCorner == 4
963 HUD_Panel_SetPosSize(mySize);
967 highlightedAction = 2;
970 if(nPrimary == K_UPARROW)
972 else if(nPrimary == K_DOWNARROW)
974 else if(nPrimary == K_LEFTARROW)
976 else // if(nPrimary == K_RIGHTARROW)
979 HUD_Panel_SetPos(pos);
983 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
985 if(!autocvar__hud_configure)
988 // allow console bind to work
991 con_keys = findkeysforcommand("toggleconsole");
992 keys = tokenize(con_keys);
994 float hit_con_bind, i;
995 for (i = 0; i < keys; ++i)
997 if(nPrimary == stof(argv(i)))
1001 if(bInputType == 0) {
1002 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1003 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1004 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1006 else if(bInputType == 1) {
1007 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1008 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1009 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1012 if(nPrimary == K_MOUSE1)
1014 if(bInputType == 0) { // key pressed
1018 else if(bInputType == 1) {// key released
1023 else if(nPrimary == K_ESCAPE)
1025 if (bInputType == 1)
1027 disable_menu_alphacheck = 1;
1029 menu_enabled_time = time;
1030 localcmd("menu_showhudexit\n");
1032 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1034 if (bInputType == 1)
1036 pressed_key_time = 0;
1039 else if (pressed_key_time == 0)
1040 pressed_key_time = time;
1042 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1044 else if(hit_con_bind)
1047 return true; // Suppress ALL other input
1050 float HUD_Panel_HighlightCheck()
1056 while(j <= HUD_PANEL_NUM)
1061 HUD_Panel_UpdatePosSizeForId(i)
1063 panelPos = panel_pos;
1064 panelSize = panel_size;
1065 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1068 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1072 // resize from topleft border
1073 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)
1077 // resize from topright border
1078 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)
1082 // resize from bottomleft border
1083 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)
1087 // resize from bottomright border
1088 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)
1096 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1097 void HUD_Panel_FirstInDrawQ(float id)
1100 var float place = -1;
1101 // find out where in the array our current id is, save into place
1102 for(i = 0; i < HUD_PANEL_NUM; ++i)
1104 if(panel_order[i] == id)
1110 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1112 place = HUD_PANEL_NUM - 1;
1114 // move all ids up by one step in the array until "place"
1115 for(i = place; i > 0; --i)
1117 panel_order[i] = panel_order[i-1];
1119 // now save the new top id
1120 panel_order[0] = id;
1122 // let's save them into the cvar by some strcat trickery
1124 for(i = 0; i < HUD_PANEL_NUM; ++i)
1126 s = strcat(s, ftos(panel_order[i]), " ");
1128 cvar_set("_hud_panelorder", s);
1129 if(hud_panelorder_prev)
1130 strunzone(hud_panelorder_prev);
1131 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1134 void HUD_Panel_Highlight()
1140 while(j <= HUD_PANEL_NUM)
1145 HUD_Panel_UpdatePosSizeForId(i)
1147 panelPos = panel_pos;
1148 panelSize = panel_size;
1149 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1152 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1154 highlightedPanel = i;
1155 HUD_Panel_FirstInDrawQ(i);
1156 highlightedAction = 1;
1157 panel_click_distance = mousepos - panelPos;
1160 // resize from topleft border
1161 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)
1163 highlightedPanel = i;
1164 HUD_Panel_FirstInDrawQ(i);
1165 highlightedAction = 2;
1167 panel_click_distance = mousepos - panelPos;
1168 panel_click_resizeorigin = panelPos + panelSize;
1171 // resize from topright border
1172 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)
1174 highlightedPanel = i;
1175 HUD_Panel_FirstInDrawQ(i);
1176 highlightedAction = 2;
1178 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1179 panel_click_distance_y = mousepos_y - panelPos_y;
1180 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1183 // resize from bottomleft border
1184 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)
1186 highlightedPanel = i;
1187 HUD_Panel_FirstInDrawQ(i);
1188 highlightedAction = 2;
1190 panel_click_distance_x = mousepos_x - panelPos_x;
1191 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1192 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1195 // resize from bottomright border
1196 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)
1198 highlightedPanel = i;
1199 HUD_Panel_FirstInDrawQ(i);
1200 highlightedAction = 2;
1202 panel_click_distance = panelSize - mousepos + panelPos;
1203 panel_click_resizeorigin = panelPos;
1208 highlightedPanel_prev = -1;
1213 float highlightcheck;
1214 void HUD_Panel_Mouse()
1216 // 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
1217 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1218 disable_menu_alphacheck = 0;
1219 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1223 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1224 print("Highlighted: ", ftos(highlightedPanel), "\n");
1225 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1228 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1229 highlightedPanel = -1;
1230 highlightedAction = 0;
1232 if(highlightedPanel != -1)
1233 highlightedPanel_prev = highlightedPanel;
1235 mousepos = mousepos + getmousepos();
1237 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1238 mousepos_y = bound(0, mousepos_y, vid_conheight);
1242 if(prevMouseClicked == 0)
1243 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1245 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1247 if(highlightedAction == 1)
1248 HUD_Panel_SetPos(mousepos - panel_click_distance);
1249 else if(highlightedAction == 2)
1252 if(resizeCorner == 1) {
1253 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1254 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1255 } else if(resizeCorner == 2) {
1256 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1257 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1258 } else if(resizeCorner == 3) {
1259 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1260 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1261 } else { // resizeCorner == 4
1262 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1263 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1265 HUD_Panel_SetPosSize(mySize);
1268 // doubleclick check
1269 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1271 mouseClicked = 0; // to prevent spam, I guess.
1272 disable_menu_alphacheck = 2;
1274 menu_enabled_time = time;
1275 HUD_Panel_GetName(highlightedPanel)
1276 localcmd("menu_showhudoptions ", panel_name, "\n");
1279 if(prevMouseClicked == 0)
1281 prevMouseClickedTime = time;
1282 prevMouseClickedPos = mousepos;
1287 highlightcheck = HUD_Panel_HighlightCheck();
1289 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1292 cursorsize = '32 32 0';
1294 if(highlightcheck == 0)
1295 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1296 else if(highlightcheck == 1)
1297 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1298 else if(highlightcheck == 2)
1299 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1301 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1303 prevMouseClicked = mouseClicked;
1306 // Weapon icons (#0)
1308 float weaponspace[10];
1309 #define HUD_WeaponIcons_Clear()\
1311 for(idx = 0; idx < 10; ++idx)\
1312 weaponspace[idx] = 0;
1314 entity weaponorder[WEP_MAXCOUNT];
1315 void weaponorder_swap(float i, float j, entity pass)
1319 weaponorder[i] = weaponorder[j];
1323 string weaponorder_cmp_str_save;
1324 string weaponorder_cmp_str;
1325 float weaponorder_cmp(float i, float j, entity pass)
1328 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1329 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1330 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)
1333 float GetAmmoStat(float i)
1337 case 0: return STAT_SHELLS;
1338 case 1: return STAT_NAILS;
1339 case 2: return STAT_ROCKETS;
1340 case 3: return STAT_CELLS;
1341 case 4: return STAT_FUEL;
1346 float GetAmmoTypeForWep(float i)
1350 case WEP_SHOTGUN: return 0;
1351 case WEP_UZI: return 1;
1352 case WEP_CAMPINGRIFLE: return 1;
1353 case WEP_GRENADE_LAUNCHER: return 2;
1354 case WEP_ELECTRO: return 3;
1355 case WEP_CRYLINK: return 3;
1356 case WEP_HLAC: return 3;
1357 case WEP_MINSTANEX: return 3;
1358 case WEP_NEX: return 3;
1359 case WEP_HAGAR: return 2;
1360 case WEP_ROCKET_LAUNCHER: return 2;
1361 case WEP_SEEKER: return 2;
1362 case WEP_FIREBALL: return 4;
1363 case WEP_HOOK: return 3;
1368 void HUD_WeaponIcons(void)
1370 if(!autocvar_hud_weaponicons && !autocvar__hud_configure)
1373 float id = HUD_PANEL_WEAPONICONS;
1374 HUD_Panel_UpdateCvarsForId(id);
1375 float alpha, stat_weapons; // "constants"
1377 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1380 mySize = panel_size;
1382 stat_weapons = getstati(STAT_WEAPONS);
1384 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1386 self = get_weaponinfo(i);
1387 if(self.impulse >= 0)
1391 // TODO make this configurable
1392 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1394 if(weaponorder_cmp_str != weaponorder_cmp_str_save)
1396 if(weaponorder_cmp_str_save)
1397 strunzone(weaponorder_cmp_str_save);
1398 weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
1400 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1402 self = get_weaponinfo(i);
1403 if(self.impulse >= 0)
1405 weaponorder[weapon_cnt] = self;
1409 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1412 HUD_Panel_DrawBg(1);
1413 if(panel_bg_padding)
1415 pos += '1 1 0' * panel_bg_padding;
1416 mySize -= '2 2 0' * panel_bg_padding;
1420 weapon_stats = getstati(STAT_DAMAGE_HITS);
1421 weapon_number = weapon_stats & 63;
1422 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1424 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1425 weapon_number = weapon_stats & 63;
1426 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1428 if(cvar_or("hud_weaponicons_fade", 1))
1430 fade = 3.2 - 2 * (time - weapontime);
1431 fade = bound(0.7, fade, 1);
1436 HUD_WeaponIcons_Clear();
1438 float rows, columns;
1439 rows = mySize_y/mySize_x;
1440 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1441 // ^^^ weapon icon aspect goes here
1443 columns = ceil(WEP_COUNT/rows);
1446 float a, type, fullammo;
1448 when = autocvar_hud_weaponicons_complainbubble_time;
1450 fadetime = autocvar_hud_weaponicons_complainbubble_fadetime;
1455 for(i = 0; i < weapon_cnt; ++i)
1457 wpnpos = pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows);
1458 wpnsize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
1460 self = weaponorder[i];
1461 weapid = self.impulse;
1463 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1465 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1466 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1468 // draw background behind currently selected weapon
1469 if(self.weapon == activeweapon)
1470 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1472 // draw the weapon accuracy
1473 if(autocvar_hud_weaponicons_accuracy && !(gametype == GAME_RACE || gametype == GAME_CTS))
1476 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1478 // yellow_accuracy = value at which accuracy becomes yellow
1479 if(weapon_stats >= 100) {
1483 else if(weapon_stats > autocvar_hud_weaponicons_accuracy_yellow) {
1484 color_x = 1 - (weapon_stats-autocvar_hud_weaponicons_accuracy_yellow)/(100-autocvar_hud_weaponicons_accuracy_yellow); // red value between 1 -> 0
1488 color_y = weapon_stats/autocvar_hud_weaponicons_accuracy_yellow; // green value between 0 -> 1
1493 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1496 // draw the weapon icon
1497 if((self.impulse >= 0) && (stat_weapons & self.weapons))
1499 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1501 if(autocvar_hud_weaponicons_number == 1) // weapon number
1502 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * mySize_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1503 else if(autocvar_hud_weaponicons_number == 2) // bind
1504 drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * mySize_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1506 // draw ammo status bar
1507 if(autocvar_hud_weaponicons_ammo && weapid != WEP_TUBA && weapid != WEP_LASER && weapid != WEP_PORTO)
1510 type = GetAmmoTypeForWep(weapid);
1512 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
1517 case 0: fullammo = autocvar_hud_weaponicons_ammo_full_shells; break;
1518 case 1: fullammo = autocvar_hud_weaponicons_ammo_full_nails; break;
1519 case 2: fullammo = autocvar_hud_weaponicons_ammo_full_rockets; break;
1520 case 3: fullammo = autocvar_hud_weaponicons_ammo_full_cells; break;
1521 case 4: fullammo = autocvar_hud_weaponicons_ammo_full_fuel; break;
1522 default: fullammo = 60;
1527 if(wpnsize_x/wpnsize_y > 2)
1529 barsize_x = 2 * wpnsize_y;
1530 barsize_y = wpnsize_y;
1532 barpos_x = wpnpos_x + (wpnsize_x - barsize_x) / 2;
1533 barpos_y = wpnpos_y;
1537 barsize_y = 1/2 * wpnsize_x;
1538 barsize_x = wpnsize_x;
1540 barpos_y = wpnpos_y + (wpnsize_y - barsize_y) / 2;
1541 barpos_x = wpnpos_x;
1547 barsize_x * bound(0, a/fullammo, 1),
1548 barsize_y); // use 2x more full ammo for uzi
1549 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, autocvar_hud_weaponicons_ammo_color, panel_fg_alpha * autocvar_hud_weaponicons_ammo_alpha, DRAWFLAG_NORMAL);
1550 drawresetcliparea();
1555 // draw a "ghost weapon icon" if you don't have the weapon
1558 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
1561 // draw the complain message
1562 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_weaponicons_complainbubble)
1566 if(complain_weapon_time + when > time)
1569 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1573 if(complain_weapon_time + when > time)
1580 if(complain_weapon_type == 0) {
1584 else if(complain_weapon_type == 1) {
1592 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);
1593 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);
1609 float GetAmmoItemCode(float i)
1613 case 0: return IT_SHELLS;
1614 case 1: return IT_NAILS;
1615 case 2: return IT_ROCKETS;
1616 case 3: return IT_CELLS;
1617 case 4: return IT_FUEL;
1622 string GetAmmoPicture(float i)
1626 case 0: return "ammo_shells";
1627 case 1: return "ammo_bullets";
1628 case 2: return "ammo_rockets";
1629 case 3: return "ammo_cells";
1630 case 4: return "ammo_fuel";
1635 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1638 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1639 if(autocvar__hud_configure)
1649 if(currently_selected)
1654 vector newSize, newPos;
1655 if(mySize_x/mySize_y > 3)
1657 newSize_x = 3 * mySize_y;
1658 newSize_y = mySize_y;
1660 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1665 newSize_y = 1/3 * mySize_x;
1666 newSize_x = mySize_x;
1668 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1672 vector picpos, numpos;
1673 if(autocvar_hud_inventory_iconalign)
1676 picpos = newPos + eX * 2 * newSize_y;
1680 numpos = newPos + eX * newSize_y;
1684 if (currently_selected)
1685 drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1687 drawfont = hud_bigfont;
1688 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1689 drawfont = hud_font;
1690 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1693 void HUD_Inventory(void)
1695 if(!autocvar_hud_inventory && !autocvar__hud_configure)
1698 float id = HUD_PANEL_INVENTORY;
1699 HUD_Panel_UpdateCvarsForId(id);
1700 float i, currently_selected;
1704 mySize = panel_size;
1706 HUD_Panel_DrawBg(1);
1707 if(panel_bg_padding)
1709 pos += '1 1 0' * panel_bg_padding;
1710 mySize -= '2 2 0' * panel_bg_padding;
1713 float rows, columns;
1714 rows = mySize_y/mySize_x;
1715 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1716 // ^^^ ammo item aspect goes here
1718 columns = ceil(AMMO_COUNT/rows);
1722 for (i = 0; i < AMMO_COUNT; ++i) {
1723 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1724 if(autocvar_hud_inventory_onlycurrent) {
1725 if(autocvar__hud_configure)
1727 if (currently_selected || autocvar__hud_configure)
1729 DrawAmmoItem(pos, mySize, i, currently_selected);
1733 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);
1738 column = column + 1;
1744 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float alpha)
1746 vector newSize, newPos;
1747 if(mySize_x/mySize_y > 3)
1749 newSize_x = 3 * mySize_y;
1750 newSize_y = mySize_y;
1752 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1757 newSize_y = 1/3 * mySize_x;
1758 newSize_x = mySize_x;
1760 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1764 vector picpos, numpos;
1767 if(iconalign == 1 || iconalign == 3) // right align
1770 picpos = newPos + eX * 2 * newSize_y;
1774 numpos = newPos + eX * newSize_y;
1780 if(iconalign == 0 || iconalign == 3) // left align
1782 numpos = newPos + eX * newSize_y;
1788 picpos = newPos + eX * 2 * newSize_y;
1792 drawfont = hud_bigfont;
1793 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1794 drawfont = hud_font;
1795 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1798 void DrawNumIcon_expanding(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float fadelerp)
1801 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
1803 DrawNumIcon(iconalign, myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, left, color, (1 - fadelerp));
1808 void HUD_Powerups(void) {
1809 if(!autocvar_hud_powerups && !autocvar__hud_configure)
1812 float id = HUD_PANEL_POWERUPS;
1813 HUD_Panel_UpdateCvarsForId(id);
1815 stat_items = getstati(STAT_ITEMS);
1817 if(!autocvar__hud_configure)
1819 if not(stat_items & IT_STRENGTH)
1820 if not(stat_items & IT_INVINCIBLE)
1823 if (getstati(STAT_HEALTH) <= 0)
1829 mySize = panel_size;
1831 float strength_time, shield_time;
1833 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1834 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1836 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
1837 if(panel_bg_padding)
1839 pos += '1 1 0' * panel_bg_padding;
1840 mySize -= '2 2 0' * panel_bg_padding;
1843 if(autocvar__hud_configure)
1849 vector barpos, barsize;
1853 string leftname, rightname;
1854 float leftcnt, rightcnt;
1855 float leftexact, rightexact;
1856 if (autocvar_hud_powerups_flip) {
1857 leftname = "strength";
1858 leftcnt = ceil(strength_time);
1859 leftexact = strength_time;
1861 rightname = "shield";
1862 rightcnt = ceil(shield_time);
1863 rightexact = shield_time;
1865 leftname = "shield";
1866 leftcnt = ceil(shield_time);
1867 leftexact = shield_time;
1869 rightname = "strength";
1870 rightcnt = ceil(strength_time);
1871 rightexact = strength_time;
1874 drawfont = hud_bigfont;
1875 if (mySize_x/mySize_y > 4)
1879 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1880 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1881 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1882 } else { // left align
1884 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1887 HUD_Panel_GetProgressBarColor(leftname)
1888 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);
1890 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
1892 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));
1897 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1898 barpos = pos + eX * 0.5 * mySize_x;
1899 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1900 } else { // right align
1901 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1902 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1905 HUD_Panel_GetProgressBarColor(rightname)
1906 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);
1908 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);
1910 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));
1913 else if (mySize_x/mySize_y > 1.5)
1917 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1918 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1919 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1920 } else { // left align
1922 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1925 HUD_Panel_GetProgressBarColor(leftname)
1926 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);
1928 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
1930 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));
1935 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1936 barpos = pos + eY * 0.5 * mySize_y;
1937 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1938 } else { // right align
1939 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1940 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1943 HUD_Panel_GetProgressBarColor(rightname)
1944 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);
1946 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);
1948 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));
1955 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // down align
1956 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1957 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1958 } else { // up align
1960 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1963 if(autocvar_hud_powerups_iconalign == 1 || autocvar_hud_powerups_iconalign == 3) { // down align
1964 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
1965 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
1966 } else { // up align
1967 picpos = pos + eX * 0.05 * mySize_x;
1968 numpos = pos + eY * 0.4 * mySize_x;
1971 HUD_Panel_GetProgressBarColor(leftname)
1972 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);
1974 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));
1976 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1977 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1982 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // up align
1983 barpos = pos + eX * 0.5 * mySize_x;
1984 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1985 } else { // down align
1986 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1987 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1990 if(autocvar_hud_powerups_iconalign == 0 || autocvar_hud_powerups_iconalign == 3) { // up align
1991 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1992 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1993 } else { // down align
1994 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
1995 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
1998 HUD_Panel_GetProgressBarColor(rightname)
1999 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);
2001 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));
2003 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2004 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2007 drawfont = hud_font;
2010 // Health/armor (#3)
2012 void HUD_HealthArmor(void)
2014 if(!autocvar_hud_healtharmor && !autocvar__hud_configure)
2017 float id = HUD_PANEL_HEALTHARMOR;
2018 HUD_Panel_UpdateCvarsForId(id);
2021 mySize = panel_size;
2023 HUD_Panel_DrawBg(1);
2024 if(panel_bg_padding)
2026 pos += '1 1 0' * panel_bg_padding;
2027 mySize -= '2 2 0' * panel_bg_padding;
2030 float armor, health;
2031 armor = getstati(STAT_ARMOR);
2032 health = getstati(STAT_HEALTH);
2035 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
2037 if(autocvar__hud_configure)
2047 vector barpos, barsize;
2051 drawfont = hud_bigfont;
2052 if(autocvar_hud_healtharmor == 2) // combined health and armor display
2055 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2060 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2061 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2062 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2063 } else { // left align
2065 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2069 if(v_z) // NOT fully armored
2071 biggercount = "health";
2072 HUD_Panel_GetProgressBarColor("health")
2073 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2075 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);
2079 biggercount = "armor";
2080 HUD_Panel_GetProgressBarColor("armor")
2081 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2083 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);
2085 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200), 1);
2090 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2091 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2092 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2095 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2097 HUD_Panel_GetProgressBarColor("fuel")
2098 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2103 string leftname, rightname;
2104 float leftcnt, rightcnt;
2105 float leftactive, rightactive;
2106 float leftalpha, rightalpha;
2107 if (autocvar_hud_healtharmor_flip) { // old style layout with armor left/top of health
2112 leftalpha = min((armor+10)/55, 1);
2114 rightname = "health";
2119 leftname = "health";
2124 rightname = "armor";
2128 rightalpha = min((armor+10)/55, 1);
2131 if (mySize_x/mySize_y > 4)
2135 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2136 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2137 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2138 } else { // left align
2140 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2143 HUD_Panel_GetProgressBarColor(leftname)
2144 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2145 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
2150 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2151 barpos = pos + eX * 0.5 * mySize_x;
2152 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2153 } else { // right align
2154 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2155 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2158 HUD_Panel_GetProgressBarColor(rightname)
2159 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2160 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);
2165 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2166 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2167 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2170 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2172 HUD_Panel_GetProgressBarColor("fuel")
2173 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2176 else if (mySize_x/mySize_y > 1.5)
2180 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2181 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2182 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2183 } else { // left align
2185 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2188 HUD_Panel_GetProgressBarColor(leftname)
2189 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2190 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
2195 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2196 barpos = pos + eY * 0.5 * mySize_y;
2197 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2198 } else { // right align
2199 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2200 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2203 HUD_Panel_GetProgressBarColor(rightname)
2204 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2205 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);
2210 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2211 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2212 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2215 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2217 HUD_Panel_GetProgressBarColor("fuel")
2218 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2225 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // down align
2226 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2227 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2228 } else { // up align
2230 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2233 if(autocvar_hud_healtharmor_iconalign == 1 || autocvar_hud_healtharmor_iconalign == 3) { // down align
2234 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2235 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2236 } else { // up align
2237 picpos = pos + eX * 0.05 * mySize_x;
2238 numpos = pos + eY * 0.4 * mySize_x;
2241 HUD_Panel_GetProgressBarColor(leftname)
2242 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2243 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2244 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);
2249 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // up align
2250 barpos = pos + eX * 0.5 * mySize_x;
2251 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2252 } else { // down align
2253 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2254 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2257 if(autocvar_hud_healtharmor_iconalign == 0 || autocvar_hud_healtharmor_iconalign == 3) { // up align
2258 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2259 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2260 } else { // down align
2261 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2262 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2265 HUD_Panel_GetProgressBarColor(rightname)
2266 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2267 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2268 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);
2273 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2275 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2277 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2278 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2280 HUD_Panel_GetProgressBarColor("fuel")
2281 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2285 drawfont = hud_font;
2288 // Notification area (#4)
2291 string Weapon_SuicideMessage(float deathtype)
2293 w_deathtype = deathtype;
2294 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2295 return w_deathtypestring;
2298 string Weapon_KillMessage(float deathtype)
2300 w_deathtype = deathtype;
2301 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2302 return w_deathtypestring;
2305 float killnotify_times[10];
2306 float killnotify_deathtype[10];
2307 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2308 string killnotify_attackers[10];
2309 string killnotify_victims[10];
2310 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2313 for (i = 9; i > 0; --i) {
2314 killnotify_times[i] = killnotify_times[i-1];
2315 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2316 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2317 if(killnotify_attackers[i])
2318 strunzone(killnotify_attackers[i]);
2319 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2320 if(killnotify_victims[i])
2321 strunzone(killnotify_victims[i]);
2322 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2324 killnotify_times[0] = time;
2325 killnotify_deathtype[0] = wpn;
2326 killnotify_actiontype[0] = actiontype;
2327 if(killnotify_attackers[0])
2328 strunzone(killnotify_attackers[0]);
2329 killnotify_attackers[0] = strzone(attacker);
2330 if(killnotify_victims[0])
2331 strunzone(killnotify_victims[0]);
2332 killnotify_victims[0] = strzone(victim);
2335 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2338 float alsoprint, gentle;
2339 alsoprint = (autocvar_hud_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2340 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2342 if(msg == MSG_SUICIDE) {
2343 w = DEATH_WEAPONOF(type);
2345 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2347 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2348 } else if (type == DEATH_KILL) {
2349 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2351 print ("^1",s1, "^1 couldn't take it anymore\n");
2352 } else if (type == DEATH_ROT) {
2353 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2355 print ("^1",s1, "^1 died\n");
2356 } else if (type == DEATH_NOAMMO) {
2357 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2359 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2360 } else if (type == DEATH_CAMP) {
2361 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2363 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2364 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2365 HUD_KillNotify_Push(s1, "", 0, type);
2367 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2368 } else if (type == DEATH_CHEAT) {
2369 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2371 print ("^1",s1, "^1 unfairly eliminated themself\n");
2372 } else if (type == DEATH_FIRE) {
2373 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2375 print ("^1",s1, "^1 burned to death\n");
2376 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2377 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2379 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2382 if (stof(s2) > 2) // killcount > 2
2383 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2384 } else if(msg == MSG_KILL) {
2385 w = DEATH_WEAPONOF(type);
2387 HUD_KillNotify_Push(s2, s1, 1, w);
2389 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2391 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2392 HUD_KillNotify_Push(s1, s2, 1, type);
2396 print ("^1", s1, "^1 took action against a team mate\n");
2398 print ("^1", s1, "^1 mows down a team mate\n");
2401 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2403 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2405 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2407 else if (stof(s2) > 2) {
2409 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2411 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2414 else if(type == KILL_FIRST_BLOOD)
2415 print("^1",s1, "^1 drew first blood", "\n");
2417 else if (type == DEATH_TELEFRAG)
2418 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2419 else if (type == DEATH_DROWN) {
2420 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2422 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2424 else if (type == DEATH_SLIME) {
2425 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2427 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2429 else if (type == DEATH_LAVA) {
2430 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2432 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2434 else if (type == DEATH_FALL) {
2435 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2437 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2439 else if (type == DEATH_SHOOTING_STAR) {
2440 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2442 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2444 else if (type == DEATH_SWAMP) {
2445 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2447 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2449 else if (type == DEATH_HURTTRIGGER)
2451 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2453 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2454 } else if(type == DEATH_SBCRUSH) {
2455 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2457 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2458 } else if(type == DEATH_SBMINIGUN) {
2459 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2461 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2462 } else if(type == DEATH_SBROCKET) {
2463 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2465 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2466 } else if(type == DEATH_SBBLOWUP) {
2467 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2469 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2470 } else if(type == DEATH_WAKIGUN) {
2471 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2473 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2474 } else if(type == DEATH_WAKIROCKET) {
2475 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2477 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2478 } else if(type == DEATH_WAKIBLOWUP) {
2479 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2481 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2482 } else if(type == DEATH_TURRET) {
2483 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2485 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2486 } else if(type == DEATH_TOUCHEXPLODE) {
2487 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2489 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2490 } else if(type == DEATH_CHEAT) {
2491 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2493 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2494 } else if (type == DEATH_FIRE) {
2495 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2497 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2498 } else if (type == DEATH_CUSTOM) {
2499 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2501 print ("^1",s1, "^1 ", s2, "\n");
2503 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2505 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2507 } else if(msg == MSG_SPREE) {
2508 if(type == KILL_END_SPREE) {
2510 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2512 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2513 } else if(type == KILL_SPREE) {
2515 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2517 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2518 } else if(type == KILL_SPREE_3) {
2520 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2522 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2523 } else if(type == KILL_SPREE_5) {
2525 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2527 print (s1,"^7 unleashes ^1RAGE\n");
2528 } else if(type == KILL_SPREE_10) {
2530 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2532 print (s1,"^7 starts the ^1MASSACRE!\n");
2533 } else if(type == KILL_SPREE_15) {
2535 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2537 print (s1,"^7 executes ^1MAYHEM!\n");
2538 } else if(type == KILL_SPREE_20) {
2540 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2542 print (s1,"^7 is a ^1BERSERKER!\n");
2543 } else if(type == KILL_SPREE_25) {
2545 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2547 print (s1,"^7 inflicts ^1CARNAGE!\n");
2548 } else if(type == KILL_SPREE_30) {
2550 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2552 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2554 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2555 if (type == DEATH_DROWN) {
2556 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2560 print ("^1",s1, "^1 was in the water for too long\n");
2562 print ("^1",s1, "^1 drowned\n");
2564 } else if (type == DEATH_SLIME) {
2565 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2567 print ("^1",s1, "^1 was slimed\n");
2568 } else if (type == DEATH_LAVA) {
2569 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2573 print ("^1",s1, "^1 found a hot place\n");
2575 print ("^1",s1, "^1 turned into hot slag\n");
2577 } else if (type == DEATH_FALL) {
2578 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2582 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2584 print ("^1",s1, "^1 hit the ground with a crunch\n");
2586 } else if (type == DEATH_SHOOTING_STAR) {
2587 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2589 print ("^1",s1, "^1 became a shooting star\n");
2590 } else if (type == DEATH_SWAMP) {
2591 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2595 print ("^1",s1, "^1 discovered a swamp\n");
2597 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2599 } else if(type == DEATH_TURRET) {
2600 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2602 print ("^1",s1, "^1 was mowed down by a turret \n");
2603 } else if (type == DEATH_CUSTOM) {
2604 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2606 print ("^1",s1, "^1 ", s2, "\n");
2607 } else if (type == DEATH_HURTTRIGGER) {
2608 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2610 print ("^1",s1, "^1 was in the wrong place\n");
2611 } else if(type == DEATH_TOUCHEXPLODE) {
2612 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2614 print ("^1",s1, "^1 died in an accident\n");
2615 } else if(type == DEATH_CHEAT) {
2616 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2618 print ("^1",s1, "^1 was unfairly eliminated\n");
2619 } else if(type == DEATH_FIRE) {
2620 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2624 print ("^1",s1, "^1 felt a little hot\n");
2626 print ("^1",s1, "^1 burnt to death\n");
2629 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2633 print ("^1",s1, "^1 needs a restart\n");
2635 print ("^1",s1, "^1 died\n");
2638 } else if(msg == MSG_KILL_ACTION_SPREE) {
2640 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2642 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2643 } else if(msg == MSG_INFO) {
2644 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2645 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2646 print(s1, "^7 got the ", s2, "\n");
2647 } else if(type == INFO_LOSTFLAG) {
2648 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2649 print(s1, "^7 lost the ", s2, "\n");
2650 } else if(type == INFO_PICKUPFLAG) {
2651 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2652 print(s1, "^7 picked up the ", s2, "\n");
2653 } else if(type == INFO_RETURNFLAG) {
2654 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2655 print(s1, "^7 returned the ", s2, "\n");
2656 } else if(type == INFO_CAPTUREFLAG) {
2657 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
2658 print(s1, "^7 captured the ", s2, s3, "\n");
2663 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2665 void HUD_Centerprint(string s1, string s2, float type, float msg)
2668 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2669 if(msg == MSG_SUICIDE) {
2670 if (type == DEATH_TEAMCHANGE) {
2671 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2672 } else if (type == DEATH_AUTOTEAMCHANGE) {
2673 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2674 } else if (type == DEATH_CAMP) {
2676 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2678 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2679 } else if (type == DEATH_NOAMMO) {
2681 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2683 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2684 } else if (type == DEATH_ROT) {
2686 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2688 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2689 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2691 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2693 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2694 } else if (type == DEATH_QUIET) {
2696 } else if (type == DEATH_KILL) {
2698 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2700 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2702 } else if(msg == MSG_KILL) {
2703 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2705 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2707 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2709 } else if (type == KILL_FIRST_BLOOD) {
2711 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2713 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2715 } else if (type == KILL_FIRST_VICTIM) {
2717 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2719 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2721 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2723 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2725 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2727 } else if (type == KILL_TYPEFRAGGED) {
2729 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2731 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2733 } else if (type == KILL_FRAG) {
2735 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2737 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2739 } else if (type == KILL_FRAGGED) {
2741 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2743 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2746 } else if(msg == MSG_KILL_ACTION) {
2747 // TODO: invent more centerprints here?
2748 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2752 void HUD_Notify (void)
2754 if(!autocvar_hud_notify && !autocvar__hud_configure)
2757 float id = HUD_PANEL_NOTIFY;
2758 HUD_Panel_UpdateCvarsForId(id);
2761 mySize = panel_size;
2763 HUD_Panel_DrawBg(1);
2764 if(panel_bg_padding)
2766 pos += '1 1 0' * panel_bg_padding;
2767 mySize -= '2 2 0' * panel_bg_padding;
2770 float entries, height;
2771 entries = bound(1, floor(10 * mySize_y/mySize_x), 10);
2772 height = mySize_y/entries;
2775 fontsize = '0.5 0.5 0' * height;
2779 when = autocvar_hud_notify_time;
2781 fadetime = autocvar_hud_notify_fadetime;
2785 vector pos_attacker, pos_victim;
2787 float width_attacker;
2788 string attacker, victim;
2791 for(j = 0; j < entries; ++j)
2794 if(autocvar_hud_notify_flip)
2796 else // rather nasty hack for ordering items from the bottom up
2797 i = entries - j - 1;
2801 if(killnotify_times[j] + when > time)
2804 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2808 if(killnotify_times[j] + when > time)
2814 // TODO: maybe print in team colors?
2817 if(killnotify_actiontype[j] == 0 && !autocvar__hud_configure)
2819 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2820 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
2821 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2823 if(killnotify_deathtype[j] == DEATH_GENERIC)
2827 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2829 s = "notify_outofammo";
2831 else if(killnotify_deathtype[j] == DEATH_KILL)
2833 s = "notify_selfkill";
2835 else if(killnotify_deathtype[j] == DEATH_CAMP)
2837 s = "notify_camping";
2839 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2841 s = "notify_teamkill_red";
2843 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2845 s = "notify_teamkill_blue";
2847 else if(killnotify_deathtype[j] == DEATH_DROWN)
2851 else if(killnotify_deathtype[j] == DEATH_SLIME)
2855 else if(killnotify_deathtype[j] == DEATH_LAVA)
2859 else if(killnotify_deathtype[j] == DEATH_FALL)
2863 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2865 s = "notify_shootingstar";
2867 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2871 // TODO: ctf icons...
2872 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2874 if(killnotify_victims[j] == "^1RED^7 flag")
2876 s = "notify_red_taken";
2880 s = "notify_blue_taken";
2883 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2885 if(killnotify_victims[j] == "^1RED^7 flag")
2887 s = "notify_red_returned";
2891 s = "notify_blue_returned";
2894 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2896 if(killnotify_victims[j] == "^1RED^7 flag")
2898 s = "notify_red_lost";
2902 s = "notify_blue_lost";
2905 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
2907 if(killnotify_victims[j] == "^1RED^7 flag")
2909 s = "notify_red_captured";
2913 s = "notify_blue_captured";
2918 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2919 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2922 // X [did action to] Y
2925 if(autocvar__hud_configure)
2927 attacker = textShortenToWidth("Player1", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2928 victim = textShortenToWidth("Player2", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2929 a = bound(0, (when - j) / 4, 1);
2933 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2934 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2936 width_attacker = stringwidth(attacker, TRUE, fontsize);
2937 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
2938 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
2939 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2941 if(autocvar__hud_configure) // example actions for config mode
2943 s = "weaponelectro";
2945 else if(WEP_VALID(killnotify_deathtype[j]))
2947 self = get_weaponinfo(killnotify_deathtype[j]);
2948 s = strcat("weapon", self.netname);
2950 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2952 s = "notify_teamkill_red";
2954 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2956 s = "notify_teamkill_red";
2958 else if(killnotify_deathtype[j] == DEATH_DROWN)
2962 else if(killnotify_deathtype[j] == DEATH_SLIME)
2966 else if(killnotify_deathtype[j] == DEATH_LAVA)
2970 else if(killnotify_deathtype[j] == DEATH_FALL)
2974 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2976 s = "notify_shootingstar";
2978 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2984 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2985 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2986 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2995 string seconds_tostring(float sec)
2998 minutes = floor(sec / 60);
3000 sec -= minutes * 60;
3003 s = ftos(100 + sec);
3005 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3008 void HUD_Timer(void)
3010 if(!autocvar_hud_timer && !autocvar__hud_configure)
3013 float id = HUD_PANEL_TIMER;
3014 HUD_Panel_UpdateCvarsForId(id);
3017 mySize = panel_size;
3019 HUD_Panel_DrawBg(1);
3020 if(panel_bg_padding)
3022 pos += '1 1 0' * panel_bg_padding;
3023 mySize -= '2 2 0' * panel_bg_padding;
3027 float timelimit, elapsedTime, timeleft, minutesLeft;
3029 timelimit = getstatf(STAT_TIMELIMIT);
3031 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3032 timeleft = ceil(timeleft);
3034 minutesLeft = floor(timeleft / 60);
3037 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3038 timer_color = '1 1 1'; //white
3039 else if(minutesLeft >= 1)
3040 timer_color = '1 1 0'; //yellow
3042 timer_color = '1 0 0'; //red
3044 if (autocvar_hud_timer_increment || timelimit == 0 || warmup_stage) {
3045 if (time < getstatf(STAT_GAMESTARTTIME)) {
3046 //while restart is still active, show 00:00
3047 timer = seconds_tostring(0);
3049 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3050 timer = seconds_tostring(elapsedTime);
3053 timer = seconds_tostring(timeleft);
3056 drawfont = hud_bigfont;
3057 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3058 drawfont = hud_font;
3063 void HUD_Radar(void)
3065 if ((autocvar_hud_radar == 0 || (autocvar_hud_radar != 2 && !teamplay)) && !autocvar__hud_configure)
3068 float id = HUD_PANEL_RADAR;
3069 HUD_Panel_UpdateCvarsForId(id);
3072 mySize = panel_size;
3074 HUD_Panel_DrawBg(1);
3075 if(panel_bg_padding)
3077 pos += '1 1 0' * panel_bg_padding;
3078 mySize -= '2 2 0' * panel_bg_padding;
3081 local float color1, color2; // color already declared as a global in hud.qc
3084 float scale2d, normalsize, bigsize;
3087 teamradar_origin2d = pos + 0.5 * mySize;
3088 teamradar_size2d = mySize;
3090 if(minimapname == "")
3093 teamradar_loadcvars();
3095 switch(hud_radar_zoommode)
3099 f = current_zoomfraction;
3102 f = 1 - current_zoomfraction;
3112 switch(hud_radar_rotation)
3115 teamradar_angle = view_angles_y - 90;
3118 teamradar_angle = 90 * hud_radar_rotation;
3122 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3123 teamradar_size2d = mySize;
3125 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3127 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3128 if(hud_radar_rotation == 0)
3130 // max-min distance must fit the radar in any rotation
3131 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3135 vector c0, c1, c2, c3, span;
3136 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3137 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3138 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3139 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3141 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3142 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3144 // max-min distance must fit the radar in x=x, y=y
3146 teamradar_size2d_x * scale2d / (1.05 * span_x),
3147 teamradar_size2d_y * scale2d / (1.05 * span_y)
3151 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3152 if(bigsize > normalsize)
3153 normalsize = bigsize;
3157 + (1 - f) * normalsize;
3158 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3159 f * (mi_min + mi_max) * 0.5
3160 + (1 - f) * view_origin);
3162 color1 = GetPlayerColor(player_localentnum-1);
3163 rgb = GetTeamRGB(color1);
3172 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3174 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3175 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3176 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3177 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3178 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3180 color2 = GetPlayerColor(tm.sv_entnum);
3181 //if(color == COLOR_SPECTATOR || color == color2)
3182 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3184 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3186 drawresetcliparea();
3191 void HUD_Score(void)
3193 if(!autocvar_hud_score && !autocvar__hud_configure)
3196 float id = HUD_PANEL_SCORE;
3197 HUD_Panel_UpdateCvarsForId(id);
3200 mySize = panel_size;
3202 HUD_Panel_DrawBg(1);
3203 if(panel_bg_padding)
3205 pos += '1 1 0' * panel_bg_padding;
3206 mySize -= '2 2 0' * panel_bg_padding;
3209 float score, distribution, leader;
3210 vector distribution_color;
3212 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3214 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3215 string timer, distrtimer;
3217 pl = players.sort_next;
3220 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3221 if(pl.scores[ps_primary] == 0)
3224 score = me.(scores[ps_primary]);
3225 timer = seconds_tostring(score/TIME_FACTOR);
3226 timer = strcat(timer, ":", ftos_decimals(mod(score, TIME_FACTOR), log(TIME_FACTOR)));
3228 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3229 // distribution display
3230 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3232 distrtimer = seconds_tostring(distribution/TIME_FACTOR);
3233 distrtimer = strcat(timer, ":", ftos_decimals(mod(distribution, TIME_FACTOR), log(TIME_FACTOR)));
3235 if (distribution <= 0) {
3236 distribution_color = '0 1 0';
3239 distribution_color = '1 0 0';
3241 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);
3243 // race record display
3244 if (distribution <= 0)
3245 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3246 drawfont = hud_bigfont;
3247 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3248 drawfont = hud_font;
3249 } else if (!teamplay) { // non-teamgames
3250 // me vector := [team/connected frags id]
3251 pl = players.sort_next;
3255 if(autocvar__hud_configure)
3258 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3262 score = me.(scores[ps_primary]);
3263 if(autocvar__hud_configure)
3266 if(distribution >= 5) {
3267 distribution_color = eY;
3269 } else if(distribution >= 0) {
3270 distribution_color = '1 1 1';
3272 } else if(distribution >= -5)
3273 distribution_color = '1 1 0';
3275 distribution_color = eX;
3277 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);
3279 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3280 drawfont = hud_bigfont;
3281 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3282 drawfont = hud_font;
3283 } else { // teamgames
3284 float max_fragcount;
3285 max_fragcount = -99;
3288 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3289 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !autocvar__hud_configure)) // no players? don't display
3291 score = tm.(teamscores[ts_primary]);
3292 if(autocvar__hud_configure)
3296 if (score > max_fragcount)
3297 max_fragcount = score;
3299 if(tm.team == myteam) {
3300 if (max_fragcount == score)
3303 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3304 drawfont = hud_bigfont;
3305 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3306 drawfont = hud_font;
3308 if (max_fragcount == score)
3311 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);
3312 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);
3321 void HUD_RaceTimer (void) {
3322 if(!autocvar_hud_racetimer && !(gametype == GAME_RACE || gametype == GAME_CTS) && !autocvar__hud_configure)
3325 float id = HUD_PANEL_RACETIMER;
3326 HUD_Panel_UpdateCvarsForId(id);
3329 mySize = panel_size;
3331 HUD_Panel_DrawBg(1);
3332 if(panel_bg_padding)
3334 pos += '1 1 0' * panel_bg_padding;
3335 mySize -= '2 2 0' * panel_bg_padding;
3338 // always force 4:1 aspect
3340 if(mySize_x/mySize_y > 4)
3342 newSize_x = 4 * mySize_y;
3343 newSize_y = mySize_y;
3345 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3349 newSize_y = 1/4 * mySize_x;
3350 newSize_x = mySize_x;
3352 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3356 drawfont = hud_bigfont;
3358 string s, forcetime;
3360 if(autocvar__hud_configure)
3363 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);
3364 s = "^1Intermediate 1 (+15.42)";
3365 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);
3366 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3367 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);
3369 else if(race_checkpointtime)
3371 a = bound(0, 2 - (time - race_checkpointtime), 1);
3374 if(a > 0) // just hit a checkpoint?
3376 if(race_checkpoint != 254)
3378 if(race_time && race_previousbesttime)
3379 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3381 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3383 forcetime = TIME_ENCODED_TOSTRING(race_time);
3388 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3390 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3391 if(a > 0) // next one?
3393 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3398 if(s != "" && a > 0)
3400 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);
3403 if(race_penaltytime)
3405 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3408 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3409 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);
3415 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3416 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);
3421 if(race_laptime && race_checkpoint != 255)
3423 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3424 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);
3429 if(race_mycheckpointtime)
3431 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3432 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3433 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);
3435 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3437 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3438 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3439 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);
3442 if(race_penaltytime && !race_penaltyaccumulator)
3444 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3445 a = bound(0, (1 + t - time), 1);
3449 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3451 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3452 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);
3457 drawfont = hud_font;
3462 float vote_yescount;
3465 float vote_highlighted; // currently selected vote
3467 float vote_active; // is there an active vote?
3468 float vote_prev; // previous state of vote_active to check for a change
3470 float vote_change; // "time" when vote_active changed
3472 void HUD_VoteWindow(void)
3474 if(!autocvar_hud_vote && !autocvar__hud_configure)
3477 float id = HUD_PANEL_VOTE;
3478 HUD_Panel_UpdateCvarsForId(id);
3481 mySize = panel_size;
3485 if(vote_active != vote_prev) {
3487 vote_prev = vote_active;
3490 if(vote_active || autocvar__hud_configure)
3491 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3493 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3495 if(autocvar__hud_configure)
3505 a = vote_alpha * bound(autocvar_hud_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3507 HUD_Panel_DrawBg(a);
3508 if(panel_bg_padding)
3510 pos += '1 1 0' * panel_bg_padding;
3511 mySize -= '2 2 0' * panel_bg_padding;
3514 // always force 3:1 aspect
3516 if(mySize_x/mySize_y > 3)
3518 newSize_x = 3 * mySize_y;
3519 newSize_y = mySize_y;
3521 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3525 newSize_y = 1/3 * mySize_x;
3526 newSize_x = mySize_x;
3528 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3532 s = "A vote has been called for:";
3533 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3534 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1.75/8), stringwidth_colors);
3535 if(autocvar__hud_configure)
3536 s = "^1Configure the HUD";
3537 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3539 // print the yes/no counts
3540 s = strcat("Yes (", getcommandkey("not bound", "vyes"), "): ", ftos(vote_yescount));
3541 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);
3542 s = strcat("No (", getcommandkey("not bound", "vno"), "): ", ftos(vote_nocount));
3543 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);
3545 // draw the progress bar backgrounds
3546 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);
3548 // draw the highlights
3549 if(vote_highlighted == 1) {
3550 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3551 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);
3553 else if(vote_highlighted == 2) {
3554 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3555 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);
3558 // draw the progress bars
3559 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3560 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);
3562 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3563 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);
3565 drawresetcliparea();
3568 vote_highlighted = 0;
3572 // Mod icons panel (#10)
3575 float mod_active; // is there any active mod icon?
3577 // CTF HUD modicon section
3578 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3579 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3580 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3582 void HUD_Mod_CTF_Reset(void)
3584 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3587 void HUD_Mod_CTF(vector pos, vector mySize)
3589 vector redflag_pos, blueflag_pos;
3591 float f; // every function should have that
3593 float redflag, blueflag; // current status
3594 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3597 stat_items = getstati(STAT_ITEMS);
3598 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3599 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3601 if(redflag || blueflag)
3606 if(autocvar__hud_configure)
3612 // when status CHANGES, set old status into prevstatus and current status into status
3613 if (redflag != redflag_prevframe)
3615 redflag_statuschange_time = time;
3616 redflag_prevstatus = redflag_prevframe;
3617 redflag_prevframe = redflag;
3620 if (blueflag != blueflag_prevframe)
3622 blueflag_statuschange_time = time;
3623 blueflag_prevstatus = blueflag_prevframe;
3624 blueflag_prevframe = blueflag;
3627 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3628 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3630 float BLINK_FACTOR = 0.15;
3631 float BLINK_BASE = 0.85;
3633 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3635 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3637 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3639 string red_icon, red_icon_prevstatus;
3640 float red_alpha, red_alpha_prevstatus;
3641 red_alpha = red_alpha_prevstatus = 1;
3643 case 1: red_icon = "flag_red_taken"; break;
3644 case 2: red_icon = "flag_red_lost"; break;
3645 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3647 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3648 red_icon = "flag_red_shielded";
3650 red_icon = string_null;
3653 switch(redflag_prevstatus) {
3654 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3655 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3656 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3659 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3660 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3661 red_icon_prevstatus = "flag_red_shielded";
3663 red_icon_prevstatus = string_null;
3667 string blue_icon, blue_icon_prevstatus;
3668 float blue_alpha, blue_alpha_prevstatus;
3669 blue_alpha = blue_alpha_prevstatus = 1;
3671 case 1: blue_icon = "flag_blue_taken"; break;
3672 case 2: blue_icon = "flag_blue_lost"; break;
3673 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3675 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3676 blue_icon = "flag_blue_shielded";
3678 blue_icon = string_null;
3681 switch(blueflag_prevstatus) {
3682 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3683 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3684 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3687 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3688 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3689 blue_icon_prevstatus = "flag_blue_shielded";
3691 blue_icon_prevstatus = string_null;
3695 if(mySize_x > mySize_y) {
3696 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3698 blueflag_pos = pos + eX * 0.5 * mySize_x;
3701 redflag_pos = pos + eX * 0.5 * mySize_x;
3703 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3705 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3707 blueflag_pos = pos + eY * 0.5 * mySize_y;
3710 redflag_pos = pos + eY * 0.5 * mySize_y;
3712 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3715 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3716 if(red_icon_prevstatus && f < 1)
3717 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3719 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3721 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3722 if(blue_icon_prevstatus && f < 1)
3723 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3725 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3728 // Keyhunt HUD modicon section
3729 float kh_runheretime;
3731 void HUD_Mod_KH_Reset(void)
3736 void HUD_Mod_KH(vector pos, vector mySize)
3738 mod_active = 1; // keyhunt should never hide the mod icons panel
3742 vector p, pa, kh_size, kh_asize;
3744 kh_keys = getstati(STAT_KH_KEYS);
3747 if(mySize_x > mySize_y)
3749 p_y = pos_y + 0.25 * mySize_y;
3750 pa = p - eY * 0.25 * mySize_y;
3752 kh_size_x = mySize_x * 0.25;
3753 kh_size_y = 0.75 * mySize_y;
3754 kh_asize_x = mySize_x * 0.25;
3755 kh_asize_y = mySize_y * 0.25;
3759 p_y = pos_y + 0.125 * mySize_y;
3760 pa = p - eY * 0.125 * mySize_y;
3762 kh_size_x = mySize_x * 0.5;
3763 kh_size_y = 0.375 * mySize_y;
3764 kh_asize_x = mySize_x * 0.5;
3765 kh_asize_y = mySize_y * 0.125;
3772 for(i = 0; i < 4; ++i)
3774 key = floor(kh_keys / pow(32, i)) & 31;
3776 if(keyteam == 30 && keycount <= 4)
3778 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3782 // this yields 8 exactly if "RUN HERE" shows
3787 kh_runheretime = time;
3788 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3793 for(i = 0; i < 4; ++i)
3795 key = floor(kh_keys / pow(32, i)) & 31;
3808 default: // owned or dropped
3813 a = a * panel_fg_alpha;
3814 aa = aa * panel_fg_alpha;
3820 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3823 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3826 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3829 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3834 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3837 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3840 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3843 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3846 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3850 if(mySize_x > mySize_y)
3852 p_x += 0.25 * mySize_x;
3853 pa_x += 0.25 * mySize_x;
3859 p_y = pos_y + 0.625 * mySize_y;
3860 pa_y = pos_y + 0.5 * mySize_y;
3866 p_x += 0.5 * mySize_x;
3867 pa_x += 0.5 * mySize_x;
3873 // Nexball HUD mod icon
3874 void HUD_Mod_NexBall(vector pos, vector mySize)
3876 float stat_items, nb_pb_starttime, dt, p;
3878 stat_items = getstati(STAT_ITEMS);
3879 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3881 if (stat_items & IT_KEY1)
3886 //Manage the progress bar if any
3887 if (nb_pb_starttime > 0)
3889 dt = mod(time - nb_pb_starttime, nb_pb_period);
3890 // one period of positive triangle
3891 p = 2 * dt / nb_pb_period;
3898 if(mySize_x > mySize_y)
3900 barsize = eX * p * mySize_x + eY * mySize_y;
3905 barsize = eX * mySize_x + eY * p * mySize_y;
3908 HUD_Panel_GetProgressBarColor("nexball")
3909 HUD_Panel_DrawProgressBar(pos, vertical, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3912 if (stat_items & IT_KEY1)
3913 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3916 // Race/CTS HUD mod icons
3917 float crecordtime_prev; // last remembered crecordtime
3918 float crecordtime_change_time; // time when crecordtime last changed
3919 float srecordtime_prev; // last remembered srecordtime
3920 float srecordtime_change_time; // time when srecordtime last changed
3922 float race_status_time;
3923 float race_status_prev;
3924 string race_status_name_prev;
3925 void HUD_Mod_Race(vector pos, vector mySize)
3927 mod_active = 1; // race should never hide the mod icons panel
3929 me = playerslots[player_localentnum - 1];
3931 float f; // yet another function has this
3932 score = me.(scores[ps_primary]);
3934 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3935 return; // no records in the actual race
3937 drawfont = hud_bigfont;
3939 // clientside personal record
3941 if(gametype == GAME_CTS)
3945 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3947 if(score && (score < t || !t)) {
3948 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3949 if(cvar("cl_autodemo_delete_keeprecords"))
3951 f = cvar("cl_autodemo_delete");
3953 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3957 if(t != crecordtime_prev) {
3958 crecordtime_prev = t;
3959 crecordtime_change_time = time;
3961 f = time - crecordtime_change_time;
3964 drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3965 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);
3967 drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3968 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);
3969 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);
3970 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);
3974 t = race_server_record;
3975 if(t != srecordtime_prev) {
3976 srecordtime_prev = t;
3977 srecordtime_change_time = time;
3979 f = time - srecordtime_change_time;
3982 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);
3983 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);
3985 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);
3986 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);
3987 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);
3988 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);
3991 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
3992 race_status_time = time + 5;
3993 race_status_prev = race_status;
3994 if (race_status_name_prev)
3995 strunzone(race_status_name_prev);
3996 race_status_name_prev = strzone(race_status_name);
3999 pos_x += mySize_x/2;
4002 a = bound(0, race_status_time - time, 1);
4005 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4009 rank = race_CheckName(race_status_name);
4011 rankname = race_PlaceName(rank);
4014 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4016 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4018 if(race_status == 0)
4019 drawpic_aspect_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4020 else if(race_status == 1) {
4021 drawpic_aspect_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4022 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4023 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4024 } else if(race_status == 2) {
4025 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4026 drawpic_aspect_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4028 drawpic_aspect_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4029 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4030 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4031 } else if(race_status == 3) {
4032 drawpic_aspect_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4033 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4034 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4037 if (race_status_time - time <= 0) {
4038 race_status_prev = -1;
4040 if(race_status_name)
4041 strunzone(race_status_name);
4042 race_status_name = string_null;
4043 if(race_status_name_prev)
4044 strunzone(race_status_name_prev);
4045 race_status_name_prev = string_null;
4047 drawfont = hud_font;
4050 float mod_prev; // previous state of mod_active to check for a change
4052 float mod_change; // "time" when mod_active changed
4054 void HUD_ModIcons(void)
4056 if(!autocvar_hud_modicons && !autocvar__hud_configure)
4059 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !autocvar__hud_configure)
4062 float id = HUD_PANEL_MODICONS;
4063 HUD_Panel_UpdateCvarsForId(id);
4066 mySize = panel_size;
4068 if(mod_active != mod_prev) {
4070 mod_prev = mod_active;
4073 if(mod_active || autocvar__hud_configure)
4074 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4076 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4079 HUD_Panel_DrawBg(mod_alpha);
4081 if(panel_bg_padding)
4083 pos += '1 1 0' * panel_bg_padding;
4084 mySize -= '2 2 0' * panel_bg_padding;
4087 // these MUST be ran in order to update mod_active
4088 if(gametype == GAME_KEYHUNT)
4089 HUD_Mod_KH(pos, mySize);
4090 else if(gametype == GAME_CTF || autocvar__hud_configure)
4091 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4092 else if(gametype == GAME_NEXBALL)
4093 HUD_Mod_NexBall(pos, mySize);
4094 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4095 HUD_Mod_Race(pos, mySize);
4098 // Draw pressed keys (#11)
4100 void HUD_DrawPressedKeys(void)
4102 if(!autocvar_hud_pressedkeys && !autocvar__hud_configure)
4105 if(!(spectatee_status > 0 || autocvar_hud_pressedkeys >= 2 || autocvar__hud_configure))
4108 float id = HUD_PANEL_PRESSEDKEYS;
4109 HUD_Panel_UpdateCvarsForId(id);
4112 mySize = panel_size;
4114 HUD_Panel_DrawBg(1);
4115 if(panel_bg_padding)
4117 pos += '1 1 0' * panel_bg_padding;
4118 mySize -= '2 2 0' * panel_bg_padding;
4121 // force custom aspect
4122 if(autocvar_hud_pressedkeys_aspect)
4125 if(mySize_x/mySize_y > autocvar_hud_pressedkeys_aspect)
4127 newSize_x = autocvar_hud_pressedkeys_aspect * mySize_y;
4128 newSize_y = mySize_y;
4130 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4134 newSize_y = 1/autocvar_hud_pressedkeys_aspect * mySize_x;
4135 newSize_x = mySize_x;
4137 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4143 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4146 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4147 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4148 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);
4149 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);
4150 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);
4151 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);
4152 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);
4155 // Handle chat as a panel (#12)
4159 if(!autocvar_hud_chat && !autocvar__hud_configure)
4161 cvar_set("con_chatrect", "0");
4165 float id = HUD_PANEL_CHAT;
4166 HUD_Panel_UpdateCvarsForId(id);
4169 mySize = panel_size;
4171 HUD_Panel_DrawBg(1);
4172 if(panel_bg_padding)
4174 pos += '1 1 0' * panel_bg_padding;
4175 mySize -= '2 2 0' * panel_bg_padding;
4178 cvar_set("con_chatrect", "1");
4180 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4181 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4183 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4184 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4186 if(autocvar__hud_configure)
4189 chatsize = cvar("con_chatsize");
4190 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4192 for(i = 0; i < cvar("con_chat"); ++i)
4194 if(i == cvar("con_chat") - 1)
4197 a = panel_fg_alpha * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4198 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);
4203 // Engine info panel (#13)
4210 float frametimeavg1; // 1 frame ago
4211 float frametimeavg2; // 2 frames ago
4212 void HUD_EngineInfo(void)
4214 if(!autocvar_hud_engineinfo && !autocvar__hud_configure)
4217 float id = HUD_PANEL_ENGINEINFO;
4218 HUD_Panel_UpdateCvarsForId(id);
4221 mySize = panel_size;
4223 HUD_Panel_DrawBg(1);
4224 if(panel_bg_padding)
4226 pos += '1 1 0' * panel_bg_padding;
4227 mySize -= '2 2 0' * panel_bg_padding;
4230 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4232 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4233 frametimeavg2 = frametimeavg1;
4234 frametimeavg1 = frametimeavg;
4237 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4238 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.
4240 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
4241 prevfps = (1/frametime);
4242 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"
4248 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4250 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4252 prevfps_time = time;
4257 color = HUD_Get_Num_Color (prevfps, 100);
4258 drawfont = hud_bigfont;
4259 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4260 drawfont = hud_font;
4263 // Info messages panel (#14)
4265 void HUD_InfoMessages(void)
4267 if(!autocvar_hud_infomessages && !autocvar__hud_configure)
4270 float id = HUD_PANEL_INFOMESSAGES;
4271 HUD_Panel_UpdateCvarsForId(id);
4274 mySize = panel_size;
4276 HUD_Panel_DrawBg(1);
4277 if(panel_bg_padding)
4279 pos += '1 1 0' * panel_bg_padding;
4280 mySize -= '2 2 0' * panel_bg_padding;
4283 // always force 6:1 aspect
4285 if(mySize_x/mySize_y > 6)
4287 newSize_x = 6 * mySize_y;
4288 newSize_y = mySize_y;
4290 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4294 newSize_y = 1/6 * mySize_x;
4295 newSize_x = mySize_x;
4297 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4306 fontsize = '0.25 0.25 0' * mySize_y;
4309 if(!autocvar__hud_configure)
4311 if(spectatee_status && !intermission)
4313 //drawfont = hud_bigfont;
4314 if(spectatee_status == -1)
4317 s = GetPlayerName(spectatee_status - 1);
4319 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
4320 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, panel_fg_alpha, DRAWFLAG_NORMAL);
4321 //drawfont = hud_font;
4323 // spectator text in the upper right corner
4324 if(spectatee_status == -1)
4325 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
4327 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
4328 if(autocvar_hud_infomessages_flip)
4329 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4330 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4331 o += eY * fontsize_y;
4333 if(spectatee_status == -1)
4334 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
4336 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
4337 if(autocvar_hud_infomessages_flip)
4338 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4339 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4340 o += eY * fontsize_y;
4342 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
4343 if(autocvar_hud_infomessages_flip)
4344 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4345 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4346 o += eY * fontsize_y;
4348 if(gametype == GAME_ARENA)
4349 s = "^1Wait for your turn to join";
4350 else if(gametype == GAME_LMS)
4353 sk = playerslots[player_localentnum - 1];
4354 if(sk.(scores[ps_primary]) >= 666)
4355 s = "^1Match has already begun";
4356 else if(sk.(scores[ps_primary]) > 0)
4357 s = "^1You have no more lives left";
4359 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4362 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4363 if(autocvar_hud_infomessages_flip)
4364 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4365 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4366 o += eY * fontsize_y;
4368 //show restart countdown:
4369 if (time < getstatf(STAT_GAMESTARTTIME)) {
4371 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4372 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4373 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
4374 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4375 o += eY * fontsize_y;
4378 if(warmup_stage && !intermission)
4380 s = "^2Currently in ^1warmup^2 stage!";
4381 if(autocvar_hud_infomessages_flip)
4382 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4383 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4384 o += eY * fontsize_y;
4388 if(mod(time, 1) >= 0.5)
4393 if(ready_waiting && !intermission && !spectatee_status)
4395 if(ready_waiting_for_me)
4398 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
4400 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
4405 s = strcat("^2Waiting for others to ready up to end warmup...");
4407 s = strcat("^2Waiting for others to ready up...");
4409 if(autocvar_hud_infomessages_flip)
4410 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4411 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4412 o += eY * fontsize_y;
4414 else if(warmup_stage && !intermission && !spectatee_status)
4416 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
4417 if(autocvar_hud_infomessages_flip)
4418 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4419 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4420 o += eY * fontsize_y;
4423 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4425 float ts_min, ts_max;
4426 tm = teams.sort_next;
4429 for(; tm.sort_next; tm = tm.sort_next)
4431 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4433 if(!ts_min) ts_min = tm.team_size;
4434 else ts_min = min(ts_min, tm.team_size);
4435 if(!ts_max) ts_max = tm.team_size;
4436 else ts_max = max(ts_max, tm.team_size);
4438 if ((ts_max - ts_min) > 1)
4440 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
4441 tm = GetTeam(myteam, false);
4443 if (tm.team != COLOR_SPECTATOR)
4444 if (tm.team_size == ts_max)
4445 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
4447 if(autocvar_hud_infomessages_flip)
4448 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4449 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4450 o += eY * fontsize_y;
4457 s = "^7Press ^3ESC ^7to show HUD options.";
4458 if(autocvar_hud_infomessages_flip)
4459 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4460 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4461 o += eY * fontsize_y;
4462 s = "^3Doubleclick ^7a panel for panel-specific options.";
4463 if(autocvar_hud_infomessages_flip)
4464 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4465 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4466 o += eY * fontsize_y;
4467 s = "^3CTRL ^7to disable collision testing, ^3SHIFT ^7and";
4468 if(autocvar_hud_infomessages_flip)
4469 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4470 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4471 o += eY * fontsize_y;
4472 s = "^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.";
4473 if(autocvar_hud_infomessages_flip)
4474 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4475 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4476 o += eY * fontsize_y;
4486 void HUD_ShowSpeed(void)
4489 float pos, conversion_factor;
4490 string speed, zspeed, unit;
4492 switch(cvar("cl_showspeed_unit"))
4497 conversion_factor = 1.0;
4501 conversion_factor = 1.0;
4505 conversion_factor = 0.0254;
4509 conversion_factor = 0.0254 * 3.6;
4513 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4517 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4521 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4523 numsize_x = numsize_y = cvar("cl_showspeed_size");
4524 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4526 drawfont = hud_bigfont;
4527 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4529 if (cvar("cl_showspeed_z") == 1) {
4530 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4531 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4534 drawfont = hud_font;
4537 vector acc_prevspeed;
4541 void HUD_ShowAcceleration(void)
4543 float acceleration, sz, scale, alpha, f;
4544 vector pos, top, rgb;
4545 top_x = vid_conwidth/2;
4548 f = time - acc_prevtime;
4549 if(cvar("cl_showacceleration_z"))
4550 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4552 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4553 acc_prevspeed = pmove_vel;
4554 acc_prevtime = time;
4556 f = bound(0, f * 10, 1);
4557 acc_avg = acc_avg * (1 - f) + acceleration * f;
4558 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4560 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4562 sz = cvar("cl_showacceleration_size");
4563 scale = cvar("cl_showacceleration_scale");
4564 alpha = cvar("cl_showacceleration_alpha");
4565 if (cvar("cl_showacceleration_color_custom"))
4566 rgb = stov(cvar_string("cl_showacceleration_color"));
4569 if (acceleration < 0) {
4570 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4571 } else if (acceleration > 0) {
4572 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4576 if (acceleration > 0)
4577 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4578 else if (acceleration < 0)
4579 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4582 void HUD_Reset (void)
4584 // reset gametype specific icons
4585 if(gametype == GAME_KEYHUNT)
4587 else if(gametype == GAME_CTF)
4588 HUD_Mod_CTF_Reset();
4591 #define HUD_DrawPanel(id)\
4593 case (HUD_PANEL_RADAR):\
4594 HUD_Radar(); break;\
4595 case (HUD_PANEL_WEAPONICONS):\
4596 HUD_WeaponIcons(); break;\
4597 case (HUD_PANEL_INVENTORY):\
4598 HUD_Inventory(); break;\
4599 case (HUD_PANEL_POWERUPS):\
4600 HUD_Powerups(); break;\
4601 case (HUD_PANEL_HEALTHARMOR):\
4602 HUD_HealthArmor(); break;\
4603 case (HUD_PANEL_NOTIFY):\
4604 HUD_Notify(); break;\
4605 case (HUD_PANEL_TIMER):\
4606 HUD_Timer(); break;\
4607 case (HUD_PANEL_SCORE):\
4608 HUD_Score(); break;\
4609 case (HUD_PANEL_RACETIMER):\
4610 HUD_RaceTimer(); break;\
4611 case (HUD_PANEL_VOTE):\
4612 HUD_VoteWindow(); break;\
4613 case (HUD_PANEL_MODICONS):\
4614 HUD_ModIcons(); break;\
4615 case (HUD_PANEL_PRESSEDKEYS):\
4616 HUD_DrawPressedKeys(); break;\
4617 case (HUD_PANEL_CHAT):\
4619 case (HUD_PANEL_ENGINEINFO):\
4620 HUD_EngineInfo(); break;\
4621 case (HUD_PANEL_INFOMESSAGES):\
4622 HUD_InfoMessages(); break;\
4625 void HUD_Main (void)
4627 hud_skin_path = strcat("gfx/hud/", autocvar_hud_skin);
4629 if(disable_menu_alphacheck == 1)
4630 menu_fade_alpha = 1;
4632 menu_fade_alpha = (1 - autocvar__menu_alpha);
4633 hud_fg_alpha = cvar("hud_fg_alpha");
4635 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4636 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4637 hud_color_bg_team = cvar("hud_color_bg_team");
4639 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4640 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4644 // HUD configure visible grid
4645 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4649 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2); ++i)
4651 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);
4654 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2); ++i)
4656 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);
4662 if(teamplay && autocvar_hud_dock_color_team) {
4663 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4664 color = colormapPaletteColor(mod(f, 16), 1) * autocvar_hud_dock_color_team;
4666 else if(autocvar_hud_dock_color == "shirt") {
4667 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4668 color = colormapPaletteColor(floor(f / 16), 0);
4670 else if(autocvar_hud_dock_color == "pants") {
4671 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4672 color = colormapPaletteColor(mod(f, 16), 1);
4675 color = stov(autocvar_hud_dock_color);
4678 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4681 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4682 if(precache_pic(pic) == "") {
4683 pic = "gfx/hud/default/dock";
4685 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...
4688 // cache the panel order into the panel_order array
4689 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4690 if(hud_panelorder_prev)
4691 strunzone(hud_panelorder_prev);
4692 hud_panelorder_prev = strzone(autocvar__hud_panelorder);
4693 tokenize_console(autocvar__hud_panelorder);
4694 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4695 panel_order[i] = stof(argv(i));
4698 // draw panels in order specified by panel_order array
4699 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
4700 HUD_DrawPanel(panel_order[i]);
4703 // TODO hud_'ify these
4704 if (cvar("cl_showspeed"))
4706 if (cvar("cl_showacceleration"))
4707 HUD_ShowAcceleration();
4709 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)
4710 localcmd("cmd selectteam auto; cmd join\n");
4712 hud_configure_prev = autocvar__hud_configure;
4714 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again
4715 disable_menu_alphacheck = 0;