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 // drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
88 #define drawpic_aspect(pos,pic,mySize,color,alpha,drawflag)\
91 imgsize = drawgetimagesize(pic);\
92 imgaspect = imgsize_x/imgsize_y;\
96 if(aspect > imgaspect) {\
97 sz_x = sz_y * imgaspect;\
98 drawpic(pos + eX * (oldsz_x - sz_x) * 0.5, pic, sz, color, alpha, drawflag);\
100 sz_y = sz_x / imgaspect;\
101 drawpic(pos + eY * (oldsz_y - sz_y) * 0.5, pic, sz, color, alpha, drawflag);\
105 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
106 #define drawpic_aspect_skin(pos,pic,sz,color,alpha,drawflag)\
108 picpath = strcat(hud_skin_path, "/", pic);\
109 if(precache_pic(picpath) == "") {\
110 picpath = strcat("gfx/hud/default/", pic);\
112 drawpic_aspect(pos, picpath, sz, color, alpha, drawflag);\
115 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
116 #define drawpic_skin(pos,pic,sz,color,alpha,drawflag)\
118 picpath = strcat(hud_skin_path, "/", pic);\
119 if(precache_pic(picpath) == "") {\
120 picpath = strcat("gfx/hud/default/", pic);\
122 drawpic(pos, picpath, sz, color, alpha, drawflag);\
126 void drawpic_aspect_skin_expanding(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
128 //drawpic_aspect_expanding(pos, strcat("gfx/hud/", autocvar_hud_skin, "/", pic), sz, rgb, alpha, flag, fadelerp);
131 void drawpic_aspect_skin_expanding_two(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
133 //drawpic_aspect_expanding_two(pos, strcat("gfx/hud/", autocvar_hud_skin, "/", pic), sz, rgb, alpha, flag, fadelerp);
136 vector HUD_Get_Num_Color (float x, float maxvalue)
144 else if(x > maxvalue * 0.75) {
145 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
146 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
149 else if(x > maxvalue * 0.5) {
150 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
151 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
152 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
154 else if(x > maxvalue * 0.25) {
157 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
159 else if(x > maxvalue * 0.1) {
161 color_y = (x-20)*90/27/100; // green value between 0 -> 1
162 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
172 float stringwidth_colors(string s, vector theSize)
174 return stringwidth(s, TRUE, theSize);
177 float stringwidth_nocolors(string s, vector theSize)
179 return stringwidth(s, FALSE, theSize);
182 #define CENTERPRINT_MAX_LINES 30
183 string centerprint_messages[CENTERPRINT_MAX_LINES];
184 float centerprint_width[CENTERPRINT_MAX_LINES];
185 vector centerprint_start;
186 float centerprint_expire;
187 float centerprint_num;
188 float centerprint_offset_hint;
189 vector centerprint_fontsize;
191 void centerprint(string strMessage)
193 float i, j, n, hcount;
196 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
198 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
200 if(cvar("scr_centertime") <= 0)
206 // strip trailing newlines
207 j = strlen(strMessage) - 1;
208 while(substring(strMessage, j, 1) == "\n" && j >= 0)
210 strMessage = substring(strMessage, 0, j + 1);
215 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
217 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
219 strMessage = substring(strMessage, j, strlen(strMessage) - j);
220 centerprint_offset_hint = j;
225 // if we get here, we have a message. Initialize its height.
228 n = tokenizebyseparator(strMessage, "\n");
230 for(j = 0; j < n; ++j)
232 getWrappedLine_remaining = argv(j);
233 while(getWrappedLine_remaining)
235 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
236 if(centerprint_messages[i])
237 strunzone(centerprint_messages[i]);
238 centerprint_messages[i] = strzone(s);
239 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
242 // half height for empty lines looks better
248 if(i >= CENTERPRINT_MAX_LINES)
254 h = centerprint_fontsize_y*hcount;
256 havail = vid_conheight;
257 if(cvar("con_chatpos") < 0)
258 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
259 if(havail > vid_conheight - 70)
260 havail = vid_conheight - 70; // avoid overlapping HUD
262 centerprint_start_x = 0;
265 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
267 // here, the centerprint would cover the crosshair. REALLY BAD.
268 forbiddenmin = vid_conheight * 0.5 - h - 16;
269 forbiddenmax = vid_conheight * 0.5 + 16;
271 allowedmin = scoreboard_bottom;
272 allowedmax = havail - h;
273 preferred = (havail - h)/2;
276 // possible orderings (total: 4! / 4 = 6)
277 // allowedmin allowedmax forbiddenmin forbiddenmax
278 // forbiddenmin forbiddenmax allowedmin allowedmax
279 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
281 // forbidden doesn't matter in this case
282 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
284 // allowedmin forbiddenmin allowedmax forbiddenmax
285 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
287 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
289 // allowedmin forbiddenmin forbiddenmax allowedmax
290 else if(allowedmin < forbiddenmin)
292 // make sure the forbidden zone is not covered
293 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
294 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
296 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
298 // forbiddenmin allowedmin allowedmax forbiddenmax
299 else if(allowedmax < forbiddenmax)
301 // it's better to leave the allowed zone (overlap with scoreboard) than
302 // to cover the forbidden zone (crosshair)
303 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
304 centerprint_start_y = forbiddenmax;
306 centerprint_start_y = forbiddenmin;
308 // forbiddenmin allowedmin forbiddenmax allowedmax
311 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
314 centerprint_start_y =
317 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
325 centerprint_expire = time + cvar("scr_centertime");
328 void HUD_DrawCenterPrint (void)
335 //if(time > centerprint_expire)
338 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
339 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
340 //sz = 1.2 / (a + 0.2);
345 pos = centerprint_start;
346 for (i=0; i<centerprint_num; i = i + 1)
348 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
349 ts = centerprint_messages[i];
352 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
353 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
354 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
355 pos_y = pos_y + centerprint_fontsize_y;
358 // half height for empty lines looks better
359 pos_y = pos_y + centerprint_fontsize_y * 0.5;
363 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
365 position_x -= 2 / 3 * strlen(text) * scale_x;
366 drawstring(position, text, scale, rgb, alpha, flag);
369 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
371 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
372 drawstring(position, text, scale, rgb, alpha, flag);
375 // return the string of the given race place
376 string race_PlaceName(float pos) {
384 return strcat(ftos(pos), "th");
387 // return the string of the onscreen race timer
388 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
396 if(histime == 0) // goal hit
400 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
410 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
416 lapstr = strcat(" (-", ftos(lapdelta), "L)");
419 else if(lapdelta < 0)
421 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
425 else if(histime > 0) // anticipation
427 if(mytime >= histime)
428 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
430 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
437 cpname = "Start line";
439 cpname = "Finish line";
441 cpname = strcat("Intermediate ", ftos(cp));
443 cpname = "Finish line";
446 return strcat(col, cpname);
447 else if(hisname == "")
448 return strcat(col, cpname, " (", timestr, ")");
450 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
453 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
454 float race_CheckName(string net_name) {
456 for (i=RANKINGS_CNT-1;i>=0;--i)
457 if(grecordholder[i] == net_name)
469 void HUD_Panel_ExportCfg(string cfgname)
472 fh = fopen(strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg"), FILE_WRITE);
475 fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
476 fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
477 fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
478 fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
479 fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
480 fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
481 fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
482 fputs(fh, strcat("seta hud_fg_alpha \"", cvar_string("hud_fg_alpha"), "\"", "\n"));
485 fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
486 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
487 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
488 fputs(fh, strcat("seta hud_dock_alpha \"", cvar_string("hud_dock_alpha"), "\"", "\n"));
491 fputs(fh, strcat("seta hud_progressbar_alpha \"", cvar_string("hud_progressbar_alpha"), "\"", "\n"));
492 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
493 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
494 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
495 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
496 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
497 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
500 fputs(fh, strcat("seta _hud_panelorder \"", cvar_string("_hud_panelorder"), "\"", "\n"));
503 // common cvars for all panels
505 for (i = 0; i < HUD_PANEL_NUM; ++i)
509 fputs(fh, strcat("seta hud_", panel_name, " ", cvar_string(strcat("hud_", panel_name)), "\n"));
510 fputs(fh, strcat("seta hud_", panel_name, "_pos \"", cvar_string(strcat("hud_", panel_name, "_pos")), "\"", "\n"));
511 fputs(fh, strcat("seta hud_", panel_name, "_size \"", cvar_string(strcat("hud_", panel_name, "_size")), "\"", "\n"));
512 fputs(fh, strcat("seta hud_", panel_name, "_bg \"", cvar_string(strcat("hud_", panel_name, "_bg")), "\"", "\n"));
513 fputs(fh, strcat("seta hud_", panel_name, "_bg_color \"", cvar_string(strcat("hud_", panel_name, "_bg_color")), "\"", "\n"));
514 fputs(fh, strcat("seta hud_", panel_name, "_bg_color_team \"", cvar_string(strcat("hud_", panel_name, "_bg_color_team")), "\"", "\n"));
515 fputs(fh, strcat("seta hud_", panel_name, "_bg_alpha \"", cvar_string(strcat("hud_", panel_name, "_bg_alpha")), "\"", "\n"));
516 fputs(fh, strcat("seta hud_", panel_name, "_bg_border \"", cvar_string(strcat("hud_", panel_name, "_bg_border")), "\"", "\n"));
517 fputs(fh, strcat("seta hud_", panel_name, "_bg_padding \"", cvar_string(strcat("hud_", panel_name, "_bg_padding")), "\"", "\n"));
519 case HUD_PANEL_WEAPONICONS:
520 fputs(fh, strcat("seta hud_", panel_name, "_complainbubble \"", cvar_string(strcat("hud_", panel_name, "_complainbubble")), "\"", "\n"));
521 fputs(fh, strcat("seta hud_", panel_name, "_complainbubble_padding \"", cvar_string(strcat("hud_", panel_name, "_complainbubble_padding")), "\"", "\n"));
523 case HUD_PANEL_INVENTORY:
524 fputs(fh, strcat("seta hud_", panel_name, "_onlycurrent \"", cvar_string(strcat("hud_", panel_name, "_onlycurrent")), "\"", "\n"));
525 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
527 case HUD_PANEL_POWERUPS:
528 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\"", "\n"));
529 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
530 fputs(fh, strcat("seta hud_", panel_name, "_baralign \"", cvar_string(strcat("hud_", panel_name, "_baralign")), "\"", "\n"));
532 case HUD_PANEL_HEALTHARMOR:
533 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\n"));
534 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
535 fputs(fh, strcat("seta hud_", panel_name, "_baralign \"", cvar_string(strcat("hud_", panel_name, "_baralign")), "\"", "\n"));
537 case HUD_PANEL_NOTIFY:
538 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\"", "\n"));
539 fputs(fh, strcat("seta hud_", panel_name, "_print \"", cvar_string(strcat("hud_", panel_name, "_print")), "\"", "\n"));
541 case HUD_PANEL_RADAR:
542 fputs(fh, strcat("seta hud_", panel_name, "_foreground_alpha \"", cvar_string(strcat("hud_", panel_name, "_foreground_alpha")), "\"", "\n"));
545 fputs(fh, strcat("seta hud_", panel_name, "_alreadyvoted_alpha \"", cvar_string(strcat("hud_", panel_name, "_alreadyvoted_alpha")), "\"", "\n"));
551 print("^2Successfully exported to hud_", autocvar_hud_skin, "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
556 const float hlBorderSize = 4;
557 const string hlBorder = "gfx/hud/default/border_highlighted";
558 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
559 void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
561 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
562 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);
563 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);
564 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);
565 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);
568 // draw the background/borders
569 #define HUD_Panel_DrawBg(alpha)\
571 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, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));\
572 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
573 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);
575 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
582 pic = strcat(hud_skin_path, "/statusbar_vertical");
583 if(precache_pic(pic) == "") {
584 pic = "gfx/hud/default/statusbar_vertical";
586 drawsubpic(pos, eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, pic, '0 0 0', '1 0.25 0', color, alpha, drawflag);
587 if(mySize_y/mySize_x > 2)
588 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);
589 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);
591 pic = strcat(hud_skin_path, "/statusbar");
592 if(precache_pic(pic) == "") {
593 pic = "gfx/hud/default/statusbar";
595 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
596 if(mySize_x/mySize_y > 2)
597 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);
598 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);
602 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
608 pic = strcat(hud_skin_path, "/num_leading");
609 if(precache_pic(pic) == "") {
610 pic = "gfx/hud/default/num_leading";
613 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
614 if(mySize_x/mySize_y > 2)
615 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);
616 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);
619 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
620 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
631 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
632 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
634 for (i = 0; i < HUD_PANEL_NUM; ++i) {
635 if(i == highlightedPanel || !panel_enabled)
638 HUD_Panel_UpdatePosSizeForId(i)
640 panel_pos -= '1 1 0' * panel_bg_border;
641 panel_size += '2 2 0' * panel_bg_border;
643 if(myPos_y + mySize_y < panel_pos_y)
645 if(myPos_y > panel_pos_y + panel_size_y)
648 if(myPos_x + mySize_x < panel_pos_x)
650 if(myPos_x > panel_pos_x + panel_size_x)
653 // OK, there IS a collision.
655 myCenter_x = myPos_x + 0.5 * mySize_x;
656 myCenter_y = myPos_y + 0.5 * mySize_y;
658 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
659 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
661 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
663 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
664 myTarget_x = panel_pos_x - mySize_x;
665 else // push it upwards
666 myTarget_y = panel_pos_y - mySize_y;
668 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
670 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
671 myTarget_x = panel_pos_x + panel_size_x;
672 else // push it upwards
673 myTarget_y = panel_pos_y - mySize_y;
675 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
677 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
678 myTarget_x = panel_pos_x - mySize_x;
679 else // push it downwards
680 myTarget_y = panel_pos_y + panel_size_y;
682 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
684 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
685 myTarget_x = panel_pos_x + panel_size_x;
686 else // push it downwards
687 myTarget_y = panel_pos_y + panel_size_y;
689 if(cvar("hud_configure_checkcollisions_debug"))
690 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
696 void HUD_Panel_SetPos(vector pos)
698 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
702 if(cvar("hud_configure_checkcollisions_debug"))
703 drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
705 if(autocvar_hud_configure_grid)
707 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;
708 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;
711 if(hud_configure_checkcollisions)
712 pos = HUD_Panel_CheckMove(pos, mySize);
714 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
715 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
718 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
720 HUD_Panel_GetName(highlightedPanel);
721 cvar_set(strcat("hud_", panel_name, "_pos"), s);
724 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
725 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
735 ratio = mySize_x/mySize_y;
737 for (i = 0; i < HUD_PANEL_NUM; ++i) {
738 if(i == highlightedPanel || !panel_enabled)
741 HUD_Panel_UpdatePosSizeForId(i)
743 panel_pos -= '1 1 0' * panel_bg_border;
744 panel_size += '2 2 0' * panel_bg_border;
746 targEndPos = panel_pos + panel_size;
748 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
749 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
752 if (resizeCorner == 1)
754 // check if this panel is on our way
755 if (resizeorigin_x <= panel_pos_x)
757 if (resizeorigin_y <= panel_pos_y)
759 if (targEndPos_x <= resizeorigin_x - mySize_x)
761 if (targEndPos_y <= resizeorigin_y - mySize_y)
764 // there is a collision:
765 // detect which side of the panel we are facing is actually limiting the resizing
766 // (which side the resize direction finds for first) and reduce the size up to there
768 // dist is the distance between resizeorigin and the "analogous" point of the panel
769 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
770 dist_x = resizeorigin_x - targEndPos_x;
771 dist_y = resizeorigin_y - targEndPos_y;
772 if (dist_y <= 0 || dist_x / dist_y > ratio)
773 mySize_x = min(mySize_x, dist_x);
775 mySize_y = min(mySize_y, dist_y);
777 else if (resizeCorner == 2)
779 if (resizeorigin_x >= targEndPos_x)
781 if (resizeorigin_y <= panel_pos_y)
783 if (panel_pos_x >= resizeorigin_x + mySize_x)
785 if (targEndPos_y <= resizeorigin_y - mySize_y)
788 dist_x = panel_pos_x - resizeorigin_x;
789 dist_y = resizeorigin_y - targEndPos_y;
790 if (dist_y <= 0 || dist_x / dist_y > ratio)
791 mySize_x = min(mySize_x, dist_x);
793 mySize_y = min(mySize_y, dist_y);
795 else if (resizeCorner == 3)
797 if (resizeorigin_x <= panel_pos_x)
799 if (resizeorigin_y >= targEndPos_y)
801 if (targEndPos_x <= resizeorigin_x - mySize_x)
803 if (panel_pos_y >= resizeorigin_y + mySize_y)
806 dist_x = resizeorigin_x - targEndPos_x;
807 dist_y = panel_pos_y - resizeorigin_y;
808 if (dist_y <= 0 || dist_x / dist_y > ratio)
809 mySize_x = min(mySize_x, dist_x);
811 mySize_y = min(mySize_y, dist_y);
813 else if (resizeCorner == 4)
815 if (resizeorigin_x >= targEndPos_x)
817 if (resizeorigin_y >= targEndPos_y)
819 if (panel_pos_x >= resizeorigin_x + mySize_x)
821 if (panel_pos_y >= resizeorigin_y + mySize_y)
824 dist_x = panel_pos_x - resizeorigin_x;
825 dist_y = panel_pos_y - resizeorigin_y;
826 if (dist_y <= 0 || dist_x / dist_y > ratio)
827 mySize_x = min(mySize_x, dist_x);
829 mySize_y = min(mySize_y, dist_y);
831 if(cvar("hud_configure_checkcollisions_debug"))
832 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
838 void HUD_Panel_SetPosSize(vector mySize)
840 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
842 resizeorigin = panel_click_resizeorigin;
845 // minimum panel size cap
846 mySize_x = max(0.025 * vid_conwidth, mySize_x);
847 mySize_y = max(0.025 * vid_conheight, mySize_y);
849 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.
851 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
852 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
855 // collision testing|
856 // -----------------+
858 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
859 if(resizeCorner == 1) {
860 myPos_x = resizeorigin_x - mySize_x;
861 myPos_y = resizeorigin_y - mySize_y;
862 } else if(resizeCorner == 2) {
863 myPos_x = resizeorigin_x;
864 myPos_y = resizeorigin_y - mySize_y;
865 } else if(resizeCorner == 3) {
866 myPos_x = resizeorigin_x - mySize_x;
867 myPos_y = resizeorigin_y;
868 } else { // resizeCorner == 4
869 myPos_x = resizeorigin_x;
870 myPos_y = resizeorigin_y;
873 // left/top screen edges
875 mySize_x = mySize_x + myPos_x;
877 mySize_y = mySize_y + myPos_y;
879 // bottom/right screen edges
880 if(myPos_x + mySize_x > vid_conwidth)
881 mySize_x = vid_conwidth - myPos_x;
882 if(myPos_y + mySize_y > vid_conheight)
883 mySize_y = vid_conheight - myPos_y;
885 if(cvar("hud_configure_checkcollisions_debug"))
886 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
888 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
889 if(autocvar_hud_configure_grid)
891 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;
892 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;
895 if(hud_configure_checkcollisions)
896 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
898 // 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)
899 mySize_x = max(0.025 * vid_conwidth, mySize_x);
900 mySize_y = max(0.025 * vid_conheight, mySize_y);
902 // do another pos check, as size might have changed by now
903 if(resizeCorner == 1) {
904 myPos_x = resizeorigin_x - mySize_x;
905 myPos_y = resizeorigin_y - mySize_y;
906 } else if(resizeCorner == 2) {
907 myPos_x = resizeorigin_x;
908 myPos_y = resizeorigin_y - mySize_y;
909 } else if(resizeCorner == 3) {
910 myPos_x = resizeorigin_x - mySize_x;
911 myPos_y = resizeorigin_y;
912 } else { // resizeCorner == 4
913 myPos_x = resizeorigin_x;
914 myPos_y = resizeorigin_y;
917 if(cvar("hud_configure_checkcollisions_debug"))
918 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
920 HUD_Panel_GetName(highlightedPanel);
922 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
923 cvar_set(strcat("hud_", panel_name, "_size"), s);
925 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
926 cvar_set(strcat("hud_", panel_name, "_pos"), s);
930 float prevMouseClicked; // previous state
931 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
932 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
935 float menu_enabled_time;
936 float pressed_key_time;
937 void HUD_Panel_Arrow_Action(float nPrimary)
939 if (highlightedPanel_prev == -1 || mouseClicked)
942 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
945 if(autocvar_hud_configure_grid)
947 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
949 if (hudShiftState & S_SHIFT)
950 step = bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
952 step = 2 * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
956 if (hudShiftState & S_SHIFT)
957 step = bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
959 step = 2 * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
964 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
965 step = vid_conheight;
968 if (hudShiftState & S_SHIFT)
969 step = (step / 256); // more precision
971 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
974 highlightedPanel = highlightedPanel_prev;
976 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
978 if (hudShiftState & S_ALT) // resize
980 highlightedAction = 1;
981 if(nPrimary == K_UPARROW)
983 else if(nPrimary == K_RIGHTARROW)
985 else if(nPrimary == K_LEFTARROW)
987 else // if(nPrimary == K_DOWNARROW)
990 // ctrl+arrow reduces the size, instead of increasing it
991 // Note that ctrl disables collisions check too, but it's fine
992 // since we don't collide with anything reducing the size
993 if (hudShiftState & S_CTRL) {
995 resizeCorner = 5 - resizeCorner;
1000 panel_click_resizeorigin = panel_pos;
1001 if(resizeCorner == 1) {
1002 panel_click_resizeorigin += mySize;
1004 } else if(resizeCorner == 2) {
1005 panel_click_resizeorigin_y += mySize_y;
1007 } else if(resizeCorner == 3) {
1008 panel_click_resizeorigin_x += mySize_x;
1010 } else { // resizeCorner == 4
1013 HUD_Panel_SetPosSize(mySize);
1017 highlightedAction = 2;
1020 if(nPrimary == K_UPARROW)
1022 else if(nPrimary == K_DOWNARROW)
1024 else if(nPrimary == K_LEFTARROW)
1026 else // if(nPrimary == K_RIGHTARROW)
1029 HUD_Panel_SetPos(pos);
1033 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1035 if(!autocvar__hud_configure)
1038 // allow console bind to work
1041 con_keys = findkeysforcommand("toggleconsole");
1042 keys = tokenize(con_keys);
1044 float hit_con_bind, i;
1045 for (i = 0; i < keys; ++i)
1047 if(nPrimary == stof(argv(i)))
1051 if(bInputType == 0) {
1052 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1053 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1054 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1056 else if(bInputType == 1) {
1057 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1058 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1059 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1062 if(nPrimary == K_MOUSE1)
1064 if(bInputType == 0) { // key pressed
1068 else if(bInputType == 1) {// key released
1073 else if(nPrimary == K_ESCAPE)
1075 if (bInputType == 1)
1077 disable_menu_alphacheck = 1;
1079 menu_enabled_time = time;
1080 localcmd("menu_showhudexit\n");
1082 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1084 if (bInputType == 1)
1086 pressed_key_time = 0;
1089 else if (pressed_key_time == 0)
1090 pressed_key_time = time;
1092 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1094 else if(hit_con_bind)
1097 return true; // Suppress ALL other input
1100 float HUD_Panel_HighlightCheck()
1106 while(j <= HUD_PANEL_NUM)
1111 HUD_Panel_UpdatePosSizeForId(i)
1113 panelPos = panel_pos;
1114 panelSize = panel_size;
1115 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1118 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1122 // resize from topleft border
1123 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)
1127 // resize from topright border
1128 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)
1132 // resize from bottomleft border
1133 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)
1137 // resize from bottomright border
1138 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)
1146 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1147 void HUD_Panel_FirstInDrawQ(float id)
1150 var float place = -1;
1151 // find out where in the array our current id is, save into place
1152 for(i = 0; i < HUD_PANEL_NUM; ++i)
1154 if(panel_order[i] == id)
1160 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1162 place = HUD_PANEL_NUM - 1;
1164 // move all ids up by one step in the array until "place"
1165 for(i = place; i > 0; --i)
1167 panel_order[i] = panel_order[i-1];
1169 // now save the new top id
1170 panel_order[0] = id;
1172 // let's save them into the cvar by some strcat trickery
1174 for(i = 0; i < HUD_PANEL_NUM; ++i)
1176 s = strcat(s, ftos(panel_order[i]), " ");
1178 cvar_set("_hud_panelorder", s);
1179 if(hud_panelorder_prev)
1180 strunzone(hud_panelorder_prev);
1181 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1184 void HUD_Panel_Highlight()
1190 while(j <= HUD_PANEL_NUM)
1195 HUD_Panel_UpdatePosSizeForId(i)
1197 panelPos = panel_pos;
1198 panelSize = panel_size;
1199 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1202 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1204 highlightedPanel = i;
1205 HUD_Panel_FirstInDrawQ(i);
1206 highlightedAction = 1;
1207 panel_click_distance = mousepos - panelPos;
1210 // resize from topleft border
1211 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)
1213 highlightedPanel = i;
1214 HUD_Panel_FirstInDrawQ(i);
1215 highlightedAction = 2;
1217 panel_click_distance = mousepos - panelPos;
1218 panel_click_resizeorigin = panelPos + panelSize;
1221 // resize from topright border
1222 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)
1224 highlightedPanel = i;
1225 HUD_Panel_FirstInDrawQ(i);
1226 highlightedAction = 2;
1228 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1229 panel_click_distance_y = mousepos_y - panelPos_y;
1230 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1233 // resize from bottomleft border
1234 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)
1236 highlightedPanel = i;
1237 HUD_Panel_FirstInDrawQ(i);
1238 highlightedAction = 2;
1240 panel_click_distance_x = mousepos_x - panelPos_x;
1241 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1242 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1245 // resize from bottomright border
1246 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)
1248 highlightedPanel = i;
1249 HUD_Panel_FirstInDrawQ(i);
1250 highlightedAction = 2;
1252 panel_click_distance = panelSize - mousepos + panelPos;
1253 panel_click_resizeorigin = panelPos;
1258 highlightedPanel_prev = -1;
1263 float highlightcheck;
1264 void HUD_Panel_Mouse()
1266 // 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
1267 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1268 disable_menu_alphacheck = 0;
1269 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1273 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1274 print("Highlighted: ", ftos(highlightedPanel), "\n");
1275 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1278 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1279 highlightedPanel = -1;
1280 highlightedAction = 0;
1282 if(highlightedPanel != -1)
1283 highlightedPanel_prev = highlightedPanel;
1285 mousepos = mousepos + getmousepos();
1287 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1288 mousepos_y = bound(0, mousepos_y, vid_conheight);
1292 if(prevMouseClicked == 0)
1293 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1295 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1297 if(highlightedAction == 1)
1298 HUD_Panel_SetPos(mousepos - panel_click_distance);
1299 else if(highlightedAction == 2)
1302 if(resizeCorner == 1) {
1303 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1304 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1305 } else if(resizeCorner == 2) {
1306 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1307 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1308 } else if(resizeCorner == 3) {
1309 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1310 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1311 } else { // resizeCorner == 4
1312 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1313 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1315 HUD_Panel_SetPosSize(mySize);
1318 // doubleclick check
1319 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1321 mouseClicked = 0; // to prevent spam, I guess.
1322 disable_menu_alphacheck = 2;
1324 menu_enabled_time = time;
1325 HUD_Panel_GetName(highlightedPanel)
1326 localcmd("menu_showhudoptions ", panel_name, "\n");
1329 if(prevMouseClicked == 0)
1331 prevMouseClickedTime = time;
1332 prevMouseClickedPos = mousepos;
1337 highlightcheck = HUD_Panel_HighlightCheck();
1339 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1342 cursorsize = '32 32 0';
1344 if(highlightcheck == 0)
1345 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1346 else if(highlightcheck == 1)
1347 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1348 else if(highlightcheck == 2)
1349 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1351 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1353 prevMouseClicked = mouseClicked;
1356 // Weapon icons (#0)
1358 float weaponspace[10];
1359 #define HUD_WeaponIcons_Clear()\
1361 for(idx = 0; idx < 10; ++idx)\
1362 weaponspace[idx] = 0;
1364 entity weaponorder[WEP_MAXCOUNT];
1365 void weaponorder_swap(float i, float j, entity pass)
1369 weaponorder[i] = weaponorder[j];
1373 string weaponorder_cmp_str_save;
1374 string weaponorder_cmp_str;
1375 float weaponorder_cmp(float i, float j, entity pass)
1378 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1379 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1380 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)
1383 void HUD_WeaponIcons(void)
1385 if(!autocvar_hud_weaponicons && !autocvar__hud_configure)
1388 float id = HUD_PANEL_WEAPONICONS;
1389 HUD_Panel_UpdateCvarsForId(id);
1390 float alpha, stat_weapons; // "constants"
1392 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1395 mySize = panel_size;
1397 stat_weapons = getstati(STAT_WEAPONS);
1399 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1401 self = get_weaponinfo(i);
1402 if(self.impulse >= 0)
1406 // TODO make this configurable
1407 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1409 if(weaponorder_cmp_str != weaponorder_cmp_str_save)
1411 if(weaponorder_cmp_str_save)
1412 strunzone(weaponorder_cmp_str_save);
1413 weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
1415 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1417 self = get_weaponinfo(i);
1418 if(self.impulse >= 0)
1420 weaponorder[weapon_cnt] = self;
1424 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1427 HUD_Panel_DrawBg(1);
1428 if(panel_bg_padding)
1430 pos += '1 1 0' * panel_bg_padding;
1431 mySize -= '2 2 0' * panel_bg_padding;
1435 weapon_stats = getstati(STAT_DAMAGE_HITS);
1436 weapon_number = weapon_stats & 63;
1437 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1439 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1440 weapon_number = weapon_stats & 63;
1441 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1443 if(cvar_or("hud_weaponicons_fade", 1))
1445 fade = 3.2 - 2 * (time - weapontime);
1446 fade = bound(0.7, fade, 1);
1451 HUD_WeaponIcons_Clear();
1453 float rows, columns;
1454 rows = mySize_y/mySize_x;
1455 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1456 // ^^^ weapon icon aspect goes here
1458 columns = ceil(WEP_COUNT/rows);
1463 when = autocvar_hud_weaponicons_complainbubble_time;
1465 fadetime = autocvar_hud_weaponicons_complainbubble_fadetime;
1468 for(i = 0; i < weapon_cnt; ++i)
1470 self = weaponorder[i];
1471 weapid = self.impulse;
1473 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1475 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1476 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1478 // draw background behind currently selected weapon
1479 if(self.weapon == activeweapon)
1480 drawpic_aspect_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), "weapon_current_bg", eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1482 // draw the weapon accuracy on the HUD
1483 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1486 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1488 // yellow_accuracy = value at which accuracy becomes yellow
1489 if(weapon_stats >= 100) {
1493 else if(weapon_stats > autocvar_hud_weaponicons_accuracy_yellow) {
1494 color_x = 1 - (weapon_stats-autocvar_hud_weaponicons_accuracy_yellow)/(100-autocvar_hud_weaponicons_accuracy_yellow); // red value between 1 -> 0
1498 color_y = weapon_stats/autocvar_hud_weaponicons_accuracy_yellow; // green value between 0 -> 1
1502 drawpic_aspect_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), "weapon_accuracy", eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), color, panel_fg_alpha, DRAWFLAG_NORMAL);
1505 // draw the weapon icon
1506 if((self.impulse >= 0) && (stat_weapons & self.weapons))
1508 drawpic_aspect_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), strcat("weapon", self.netname), eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1510 if(autocvar_hud_weaponicons_number == 1) // weapon number
1511 drawstring(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), ftos(weapid), '1 1 0' * 0.5 * mySize_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1512 else if(autocvar_hud_weaponicons_number == 2) // bind
1513 drawstring(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * mySize_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1516 // draw a "ghost weapon icon" if you don't have the weapon
1519 drawpic_aspect_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), strcat("weapon", self.netname), eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
1522 // draw the complain message
1523 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_weaponicons_complainbubble)
1527 if(complain_weapon_time + when > time)
1530 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1534 if(complain_weapon_time + when > time)
1541 if(complain_weapon_type == 0) {
1545 else if(complain_weapon_type == 1) {
1553 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);
1554 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, mySize_y*(1/rows), '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
1570 float GetAmmoStat(float i)
1574 case 0: return STAT_SHELLS;
1575 case 1: return STAT_NAILS;
1576 case 2: return STAT_ROCKETS;
1577 case 3: return STAT_CELLS;
1578 case 4: return STAT_FUEL;
1583 float GetAmmoItemCode(float i)
1587 case 0: return IT_SHELLS;
1588 case 1: return IT_NAILS;
1589 case 2: return IT_ROCKETS;
1590 case 3: return IT_CELLS;
1591 case 4: return IT_FUEL;
1596 string GetAmmoPicture(float i)
1600 case 0: return "ammo_shells";
1601 case 1: return "ammo_bullets";
1602 case 2: return "ammo_rockets";
1603 case 3: return "ammo_cells";
1604 case 4: return "ammo_fuel";
1609 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1612 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1613 if(autocvar__hud_configure)
1623 if(currently_selected)
1628 vector newSize, newPos;
1629 if(mySize_x/mySize_y > 3)
1631 newSize_x = 3 * mySize_y;
1632 newSize_y = mySize_y;
1634 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1639 newSize_y = 1/3 * mySize_x;
1640 newSize_x = mySize_x;
1642 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1646 vector picpos, numpos;
1647 if(autocvar_hud_inventory_iconalign)
1650 picpos = newPos + eX * 2 * newSize_y;
1654 numpos = newPos + eX * newSize_y;
1658 if (currently_selected)
1659 drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1661 drawfont = hud_bigfont;
1662 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1663 drawfont = hud_font;
1664 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1667 void HUD_Inventory(void)
1669 if(!autocvar_hud_inventory && !autocvar__hud_configure)
1672 float id = HUD_PANEL_INVENTORY;
1673 HUD_Panel_UpdateCvarsForId(id);
1674 float i, currently_selected;
1678 mySize = panel_size;
1680 HUD_Panel_DrawBg(1);
1681 if(panel_bg_padding)
1683 pos += '1 1 0' * panel_bg_padding;
1684 mySize -= '2 2 0' * panel_bg_padding;
1687 float rows, columns;
1688 rows = mySize_y/mySize_x;
1689 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1690 // ^^^ ammo item aspect goes here
1692 columns = ceil(AMMO_COUNT/rows);
1696 for (i = 0; i < AMMO_COUNT; ++i) {
1697 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1698 if(autocvar_hud_inventory_onlycurrent) {
1699 if(autocvar__hud_configure)
1701 if (currently_selected || autocvar__hud_configure)
1703 DrawAmmoItem(pos, mySize, i, currently_selected);
1707 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);
1712 column = column + 1;
1718 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color)
1720 vector newSize, newPos;
1721 if(mySize_x/mySize_y > 3)
1723 newSize_x = 3 * mySize_y;
1724 newSize_y = mySize_y;
1726 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1731 newSize_y = 1/3 * mySize_x;
1732 newSize_x = mySize_x;
1734 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1738 vector picpos, numpos;
1741 if(iconalign == 1 || iconalign == 3) // right align
1744 picpos = newPos + eX * 2 * newSize_y;
1748 numpos = newPos + eX * newSize_y;
1754 if(iconalign == 0 || iconalign == 3) // left align
1756 numpos = newPos + eX * newSize_y;
1762 picpos = newPos + eX * 2 * newSize_y;
1766 drawfont = hud_bigfont;
1767 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, newSize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1768 drawfont = hud_font;
1769 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1774 void HUD_Powerups(void) {
1775 if(!autocvar_hud_powerups && !autocvar__hud_configure)
1778 float id = HUD_PANEL_POWERUPS;
1779 HUD_Panel_UpdateCvarsForId(id);
1781 stat_items = getstati(STAT_ITEMS);
1783 if(!autocvar__hud_configure)
1785 if not(stat_items & IT_STRENGTH)
1786 if not(stat_items & IT_INVINCIBLE)
1789 if (getstati(STAT_HEALTH) <= 0)
1795 mySize = panel_size;
1797 HUD_Panel_DrawBg(1);
1798 if(panel_bg_padding)
1800 pos += '1 1 0' * panel_bg_padding;
1801 mySize -= '2 2 0' * panel_bg_padding;
1804 float strength_time, shield_time;
1806 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1807 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1809 if(autocvar__hud_configure)
1815 vector barpos, barsize;
1819 string leftname, rightname;
1820 float leftcnt, rightcnt;
1821 float leftexact, rightexact;
1822 float leftalpha, rightalpha;
1823 if (autocvar_hud_powerups_flip) {
1824 leftname = "strength";
1825 leftcnt = ceil(strength_time);
1826 leftexact = strength_time;
1828 rightname = "shield";
1829 rightcnt = ceil(shield_time);
1830 rightexact = shield_time;
1832 leftname = "shield";
1833 leftcnt = ceil(shield_time);
1834 leftexact = shield_time;
1836 rightname = "strength";
1837 rightcnt = ceil(strength_time);
1838 rightexact = strength_time;
1840 leftalpha = bound(0, leftexact, 1);
1841 rightalpha = bound(0, rightexact, 1);
1843 drawfont = hud_bigfont;
1844 if (mySize_x/mySize_y > 4)
1848 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1849 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1850 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1851 } else { // left align
1853 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1856 HUD_Panel_GetProgressBarColor(leftname)
1857 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1858 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1');
1861 // drawpic_aspect_skin_expanding_two(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_ADDITIVE, bound(0, (leftcnt - leftexact) / 0.5, 1));
1863 // drawpic_aspect_skin(picpos, leftname, eX * (1/6) * mySize_x + eY * mySize_y, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1868 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1869 barpos = pos + eX * 0.5 * mySize_x;
1870 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1871 } else { // right align
1872 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1873 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1876 HUD_Panel_GetProgressBarColor(rightname)
1877 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1878 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');
1881 else if (mySize_x/mySize_y > 1.5)
1885 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1886 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1887 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1888 } else { // left align
1890 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1893 HUD_Panel_GetProgressBarColor(leftname)
1894 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1895 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1');
1900 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1901 barpos = pos + eY * 0.5 * mySize_y;
1902 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1903 } else { // right align
1904 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1905 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1908 HUD_Panel_GetProgressBarColor(rightname)
1909 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1910 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');
1917 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // down align
1918 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1919 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1920 } else { // up align
1922 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1925 if(autocvar_hud_powerups_iconalign == 1 || autocvar_hud_powerups_iconalign == 3) { // down align
1926 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
1927 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
1928 } else { // up align
1929 picpos = pos + eX * 0.05 * mySize_x;
1930 numpos = pos + eY * 0.4 * mySize_x;
1933 HUD_Panel_GetProgressBarColor(leftname)
1934 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1936 //drawpic_aspect_skin_expanding_two(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_ADDITIVE, bound(0, (leftcnt - leftexact) / 0.5, 1));
1938 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1939 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1944 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // up align
1945 barpos = pos + eX * 0.5 * mySize_x;
1946 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1947 } else { // down align
1948 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1949 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1952 if(autocvar_hud_powerups_iconalign == 0 || autocvar_hud_powerups_iconalign == 3) { // up align
1953 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1954 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1955 } else { // down align
1956 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
1957 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
1960 HUD_Panel_GetProgressBarColor(rightname)
1961 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1963 // drawpic_aspect_skin_expanding_two(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_ADDITIVE, bound(0, (rightcnt - rightexact) / 0.5, 1));
1965 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1966 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1969 drawfont = hud_font;
1972 // Health/armor (#3)
1974 void HUD_HealthArmor(void)
1976 if(!autocvar_hud_healtharmor && !autocvar__hud_configure)
1979 float id = HUD_PANEL_HEALTHARMOR;
1980 HUD_Panel_UpdateCvarsForId(id);
1983 mySize = panel_size;
1985 HUD_Panel_DrawBg(1);
1986 if(panel_bg_padding)
1988 pos += '1 1 0' * panel_bg_padding;
1989 mySize -= '2 2 0' * panel_bg_padding;
1992 float armor, health;
1993 armor = getstati(STAT_ARMOR);
1994 health = getstati(STAT_HEALTH);
1997 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
1999 if(autocvar__hud_configure)
2009 vector barpos, barsize;
2013 drawfont = hud_bigfont;
2014 if(autocvar_hud_healtharmor == 2) // combined health and armor display
2017 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2022 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2023 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2024 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2025 } else { // left align
2027 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2031 if(v_z) // NOT fully armored
2033 biggercount = "health";
2034 HUD_Panel_GetProgressBarColor("health")
2035 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2037 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);
2041 biggercount = "armor";
2042 HUD_Panel_GetProgressBarColor("armor")
2043 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2045 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);
2047 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200));
2052 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2053 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2054 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2057 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2059 HUD_Panel_GetProgressBarColor("fuel")
2060 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2065 string leftname, rightname;
2066 float leftcnt, rightcnt;
2067 float leftactive, rightactive;
2068 float leftalpha, rightalpha;
2069 if (autocvar_hud_healtharmor_flip) { // old style layout with armor left/top of health
2074 leftalpha = min((armor+10)/55, 1);
2076 rightname = "health";
2081 leftname = "health";
2086 rightname = "armor";
2090 rightalpha = min((armor+10)/55, 1);
2093 if (mySize_x/mySize_y > 4)
2097 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2098 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2099 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2100 } else { // left align
2102 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2105 HUD_Panel_GetProgressBarColor(leftname)
2106 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2107 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2112 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2113 barpos = pos + eX * 0.5 * mySize_x;
2114 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2115 } else { // right align
2116 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2117 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2120 HUD_Panel_GetProgressBarColor(rightname)
2121 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2122 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));
2127 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2128 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2129 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2132 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2134 HUD_Panel_GetProgressBarColor("fuel")
2135 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2138 else if (mySize_x/mySize_y > 1.5)
2142 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2143 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2144 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2145 } else { // left align
2147 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2150 HUD_Panel_GetProgressBarColor(leftname)
2151 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2152 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2157 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2158 barpos = pos + eY * 0.5 * mySize_y;
2159 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2160 } else { // right align
2161 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2162 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2165 HUD_Panel_GetProgressBarColor(rightname)
2166 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2167 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));
2172 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2173 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2174 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2177 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2179 HUD_Panel_GetProgressBarColor("fuel")
2180 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2187 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // down align
2188 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2189 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2190 } else { // up align
2192 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2195 if(autocvar_hud_healtharmor_iconalign == 1 || autocvar_hud_healtharmor_iconalign == 3) { // down align
2196 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2197 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2198 } else { // up align
2199 picpos = pos + eX * 0.05 * mySize_x;
2200 numpos = pos + eY * 0.4 * mySize_x;
2203 HUD_Panel_GetProgressBarColor(leftname)
2204 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2205 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2206 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, 0.25 * mySize_x, HUD_Get_Num_Color(leftcnt, 200), panel_fg_alpha, DRAWFLAG_NORMAL);
2211 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // up align
2212 barpos = pos + eX * 0.5 * mySize_x;
2213 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2214 } else { // down align
2215 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2216 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2219 if(autocvar_hud_healtharmor_iconalign == 0 || autocvar_hud_healtharmor_iconalign == 3) { // up align
2220 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2221 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2222 } else { // down align
2223 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2224 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2227 HUD_Panel_GetProgressBarColor(rightname)
2228 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2229 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2230 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, 0.25 * mySize_x, HUD_Get_Num_Color(rightcnt, 200), panel_fg_alpha, DRAWFLAG_NORMAL);
2235 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2237 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2239 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2240 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2242 HUD_Panel_GetProgressBarColor("fuel")
2243 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2247 drawfont = hud_font;
2250 // Notification area (#4)
2253 string Weapon_SuicideMessage(float deathtype)
2255 w_deathtype = deathtype;
2256 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2257 return w_deathtypestring;
2260 string Weapon_KillMessage(float deathtype)
2262 w_deathtype = deathtype;
2263 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2264 return w_deathtypestring;
2267 float killnotify_times[10];
2268 float killnotify_deathtype[10];
2269 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2270 string killnotify_attackers[10];
2271 string killnotify_victims[10];
2272 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2275 for (i = 9; i > 0; --i) {
2276 killnotify_times[i] = killnotify_times[i-1];
2277 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2278 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2279 if(killnotify_attackers[i])
2280 strunzone(killnotify_attackers[i]);
2281 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2282 if(killnotify_victims[i])
2283 strunzone(killnotify_victims[i]);
2284 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2286 killnotify_times[0] = time;
2287 killnotify_deathtype[0] = wpn;
2288 killnotify_actiontype[0] = actiontype;
2289 if(killnotify_attackers[0])
2290 strunzone(killnotify_attackers[0]);
2291 killnotify_attackers[0] = strzone(attacker);
2292 if(killnotify_victims[0])
2293 strunzone(killnotify_victims[0]);
2294 killnotify_victims[0] = strzone(victim);
2297 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2300 float alsoprint, gentle;
2301 alsoprint = (autocvar_hud_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2302 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2304 if(msg == MSG_SUICIDE) {
2306 w = DEATH_WEAPONOF(type);
2308 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2310 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2311 } else if (type == DEATH_KILL) {
2312 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2314 print ("^1",s1, "^1 couldn't take it anymore\n");
2315 } else if (type == DEATH_ROT) {
2316 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2318 print ("^1",s1, "^1 died\n");
2319 } else if (type == DEATH_NOAMMO) {
2320 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2322 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2323 } else if (type == DEATH_CAMP) {
2324 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2326 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2327 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2328 HUD_KillNotify_Push(s1, "", 0, type);
2330 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2331 } else if (type == DEATH_CHEAT) {
2332 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2334 print ("^1",s1, "^1 unfairly eliminated themself\n");
2335 } else if (type == DEATH_FIRE) {
2336 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2338 print ("^1",s1, "^1 burned to death\n");
2339 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2340 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2342 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2345 if (stof(s2) > 2) // killcount > 2
2346 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2347 } else if(msg == MSG_KILL) {
2348 w = DEATH_WEAPONOF(type);
2350 HUD_KillNotify_Push(s2, s1, 1, w);
2352 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2354 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2355 HUD_KillNotify_Push(s1, s2, 1, type);
2359 print ("^1", s1, "^1 took action against a team mate\n");
2361 print ("^1", s1, "^1 mows down a team mate\n");
2364 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2366 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2368 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2370 else if (stof(s2) > 2) {
2372 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2374 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2377 else if(type == KILL_FIRST_BLOOD)
2378 print("^1",s1, "^1 drew first blood", "\n");
2380 else if (type == DEATH_TELEFRAG)
2381 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2382 else if (type == DEATH_DROWN) {
2383 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2385 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2387 else if (type == DEATH_SLIME) {
2388 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2390 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2392 else if (type == DEATH_LAVA) {
2393 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2395 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2397 else if (type == DEATH_FALL) {
2398 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2400 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2402 else if (type == DEATH_SHOOTING_STAR) {
2403 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2405 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2407 else if (type == DEATH_SWAMP) {
2408 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2410 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2412 else if (type == DEATH_HURTTRIGGER)
2414 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2416 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2417 } else if(type == DEATH_SBCRUSH) {
2418 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2420 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2421 } else if(type == DEATH_SBMINIGUN) {
2422 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2424 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2425 } else if(type == DEATH_SBROCKET) {
2426 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2428 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2429 } else if(type == DEATH_SBBLOWUP) {
2430 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2432 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2433 } else if(type == DEATH_WAKIGUN) {
2434 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2436 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2437 } else if(type == DEATH_WAKIROCKET) {
2438 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2440 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2441 } else if(type == DEATH_WAKIBLOWUP) {
2442 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2444 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2445 } else if(type == DEATH_TURRET) {
2446 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2448 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2449 } else if(type == DEATH_TOUCHEXPLODE) {
2450 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2452 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2453 } else if(type == DEATH_CHEAT) {
2454 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2456 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2457 } else if (type == DEATH_FIRE) {
2458 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2460 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2461 } else if (type == DEATH_CUSTOM) {
2462 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2464 print ("^1",s1, "^1 ", s2, "\n");
2466 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2468 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2470 } else if(msg == MSG_SPREE) {
2471 if(type == KILL_END_SPREE) {
2473 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2475 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2476 } else if(type == KILL_SPREE) {
2478 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2480 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2481 } else if(type == KILL_SPREE_3) {
2483 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2485 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2486 } else if(type == KILL_SPREE_5) {
2488 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2490 print (s1,"^7 unleashes ^1RAGE\n");
2491 } else if(type == KILL_SPREE_10) {
2493 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2495 print (s1,"^7 starts the ^1MASSACRE!\n");
2496 } else if(type == KILL_SPREE_15) {
2498 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2500 print (s1,"^7 executes ^1MAYHEM!\n");
2501 } else if(type == KILL_SPREE_20) {
2503 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2505 print (s1,"^7 is a ^1BERSERKER!\n");
2506 } else if(type == KILL_SPREE_25) {
2508 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2510 print (s1,"^7 inflicts ^1CARNAGE!\n");
2511 } else if(type == KILL_SPREE_30) {
2513 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2515 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2517 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2518 if (type == DEATH_DROWN) {
2519 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2523 print ("^1",s1, "^1 was in the water for too long\n");
2525 print ("^1",s1, "^1 drowned\n");
2527 } else if (type == DEATH_SLIME) {
2528 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2530 print ("^1",s1, "^1 was slimed\n");
2531 } else if (type == DEATH_LAVA) {
2532 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2536 print ("^1",s1, "^1 found a hot place\n");
2538 print ("^1",s1, "^1 turned into hot slag\n");
2540 } else if (type == DEATH_FALL) {
2541 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2545 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2547 print ("^1",s1, "^1 hit the ground with a crunch\n");
2549 } else if (type == DEATH_SHOOTING_STAR) {
2550 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2552 print ("^1",s1, "^1 became a shooting star\n");
2553 } else if (type == DEATH_SWAMP) {
2554 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2558 print ("^1",s1, "^1 discovered a swamp\n");
2560 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2562 } else if(type == DEATH_TURRET) {
2563 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2565 print ("^1",s1, "^1 was mowed down by a turret \n");
2566 } else if (type == DEATH_CUSTOM) {
2567 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2569 print ("^1",s1, "^1 ", s2, "\n");
2570 } else if (type == DEATH_HURTTRIGGER) {
2571 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2573 print ("^1",s1, "^1 was in the wrong place\n");
2574 } else if(type == DEATH_TOUCHEXPLODE) {
2575 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2577 print ("^1",s1, "^1 died in an accident\n");
2578 } else if(type == DEATH_CHEAT) {
2579 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2581 print ("^1",s1, "^1 was unfairly eliminated\n");
2582 } else if(type == DEATH_FIRE) {
2583 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2587 print ("^1",s1, "^1 felt a little hot\n");
2589 print ("^1",s1, "^1 burnt to death\n");
2592 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2596 print ("^1",s1, "^1 needs a restart\n");
2598 print ("^1",s1, "^1 died\n");
2601 } else if(msg == MSG_KILL_ACTION_SPREE) {
2603 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2605 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2606 } else if(msg == MSG_INFO) {
2607 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2608 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2609 print(s1, "^7 got the ", s2, "\n");
2610 } else if(type == INFO_LOSTFLAG) {
2611 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2612 print(s1, "^7 lost the ", s2, "\n");
2613 } else if(type == INFO_PICKUPFLAG) {
2614 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2615 print(s1, "^7 picked up the ", s2, "\n");
2616 } else if(type == INFO_RETURNFLAG) {
2617 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2618 print(s1, "^7 returned the ", s2, "\n");
2623 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2625 void HUD_Centerprint(string s1, string s2, float type, float msg)
2628 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2629 if(msg == MSG_SUICIDE) {
2630 if (type == DEATH_TEAMCHANGE) {
2631 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2632 } else if (type == DEATH_AUTOTEAMCHANGE) {
2633 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2634 } else if (type == DEATH_CAMP) {
2636 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2638 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2639 } else if (type == DEATH_NOAMMO) {
2641 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2643 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2644 } else if (type == DEATH_ROT) {
2646 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2648 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2649 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2651 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2653 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2654 } else if (type == DEATH_QUIET) {
2656 } else if (type == DEATH_KILL) {
2658 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2660 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2662 } else if(msg == MSG_KILL) {
2663 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2665 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2667 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2669 } else if (type == KILL_FIRST_BLOOD) {
2671 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2673 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2675 } else if (type == KILL_FIRST_VICTIM) {
2677 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2679 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2681 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2683 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2685 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2687 } else if (type == KILL_TYPEFRAGGED) {
2689 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2691 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2693 } else if (type == KILL_FRAG) {
2695 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2697 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2699 } else if (type == KILL_FRAGGED) {
2701 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2703 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2706 } else if(msg == MSG_KILL_ACTION) {
2707 // TODO: invent more centerprints here?
2708 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2712 void HUD_Notify (void)
2714 if(!autocvar_hud_notify && !autocvar__hud_configure)
2717 float id = HUD_PANEL_NOTIFY;
2718 HUD_Panel_UpdateCvarsForId(id);
2721 mySize = panel_size;
2723 HUD_Panel_DrawBg(1);
2724 if(panel_bg_padding)
2726 pos += '1 1 0' * panel_bg_padding;
2727 mySize -= '2 2 0' * panel_bg_padding;
2730 float entries, height;
2731 entries = bound(1, floor(10 * mySize_y/mySize_x), 10);
2732 height = mySize_y/entries;
2735 fontsize = '0.5 0.5 0' * height;
2739 when = autocvar_hud_notify_time;
2741 fadetime = autocvar_hud_notify_fadetime;
2746 vector pos_attacker, pos_victim;
2748 float width_attacker;
2749 string attacker, victim;
2752 for(j = 0; j < entries; ++j)
2755 if(autocvar_hud_notify_flip)
2757 else // rather nasty hack for ordering items from the bottom up
2758 i = entries - j - 1;
2762 if(killnotify_times[j] + when > time)
2765 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2769 if(killnotify_times[j] + when > time)
2775 // TODO: maybe print in team colors?
2778 if(killnotify_actiontype[j] == 0 && !autocvar__hud_configure)
2780 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2781 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
2782 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2784 if(killnotify_deathtype[j] == DEATH_GENERIC)
2789 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2791 s = "notify_outofammo";
2794 else if(killnotify_deathtype[j] == DEATH_KILL)
2796 s = "notify_selfkill";
2799 else if(killnotify_deathtype[j] == DEATH_CAMP)
2801 s = "notify_camping";
2804 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2806 s = "notify_teamkill";
2809 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2811 s = "notify_teamkill";
2814 else if(killnotify_deathtype[j] == DEATH_DROWN)
2819 else if(killnotify_deathtype[j] == DEATH_SLIME)
2824 else if(killnotify_deathtype[j] == DEATH_LAVA)
2829 else if(killnotify_deathtype[j] == DEATH_FALL)
2834 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2839 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2844 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2846 if(killnotify_victims[j] == "^1RED^7 flag")
2848 s = "flag_red_carrying";
2853 s = "flag_blue_carrying";
2857 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2859 if(killnotify_victims[j] == "^1RED^7 flag")
2861 s = "flag_red_taken";
2866 s = "flag_blue_taken";
2870 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2872 if(killnotify_victims[j] == "^1RED^7 flag")
2874 s = "flag_red_lost";
2879 s = "flag_blue_lost";
2885 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, color, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2886 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2889 // X [did action to] Y
2892 if(autocvar__hud_configure)
2894 attacker = textShortenToWidth("Player1", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2895 victim = textShortenToWidth("Player2", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2896 a = bound(0, (when - j) / 4, 1);
2900 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2901 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2903 width_attacker = stringwidth(attacker, TRUE, fontsize);
2904 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
2905 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
2906 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2908 if(autocvar__hud_configure) // example actions for config mode
2910 s = "weaponelectro";
2913 else if(WEP_VALID(killnotify_deathtype[j]))
2915 self = get_weaponinfo(killnotify_deathtype[j]);
2916 s = strcat("weapon", self.netname);
2919 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2921 s = "notify_teamkill";
2924 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2926 s = "notify_teamkill";
2929 else if(killnotify_deathtype[j] == DEATH_DROWN)
2934 else if(killnotify_deathtype[j] == DEATH_SLIME)
2939 else if(killnotify_deathtype[j] == DEATH_LAVA)
2944 else if(killnotify_deathtype[j] == DEATH_FALL)
2949 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2951 s = "notify_shootingstar";
2954 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2961 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, color, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2962 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2963 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2972 string seconds_tostring(float sec)
2975 minutes = floor(sec / 60);
2977 sec -= minutes * 60;
2980 s = ftos(100 + sec);
2982 return strcat(ftos(minutes), ":", substring(s, 1, 3));
2985 void HUD_Timer(void)
2987 if(!autocvar_hud_timer && !autocvar__hud_configure)
2990 float id = HUD_PANEL_TIMER;
2991 HUD_Panel_UpdateCvarsForId(id);
2994 mySize = panel_size;
2996 HUD_Panel_DrawBg(1);
2997 if(panel_bg_padding)
2999 pos += '1 1 0' * panel_bg_padding;
3000 mySize -= '2 2 0' * panel_bg_padding;
3004 float timelimit, elapsedTime, timeleft, minutesLeft;
3006 timelimit = getstatf(STAT_TIMELIMIT);
3008 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3009 timeleft = ceil(timeleft);
3011 minutesLeft = floor(timeleft / 60);
3014 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3015 timer_color = '1 1 1'; //white
3016 else if(minutesLeft >= 1)
3017 timer_color = '1 1 0'; //yellow
3019 timer_color = '1 0 0'; //red
3021 if (autocvar_hud_timer_increment || timelimit == 0 || warmup_stage) {
3022 if (time < getstatf(STAT_GAMESTARTTIME)) {
3023 //while restart is still active, show 00:00
3024 timer = seconds_tostring(0);
3026 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3027 timer = seconds_tostring(elapsedTime);
3030 timer = seconds_tostring(timeleft);
3033 drawfont = hud_bigfont;
3034 drawstring_aspect(pos, timer, mySize, mySize_y, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3035 drawfont = hud_font;
3040 void HUD_Radar(void)
3042 if (!(autocvar_hud_radar != 0 && (autocvar_hud_radar == 2 || teamplay || autocvar__hud_configure)))
3045 float id = HUD_PANEL_RADAR;
3046 HUD_Panel_UpdateCvarsForId(id);
3049 mySize = panel_size;
3051 HUD_Panel_DrawBg(1);
3052 if(panel_bg_padding)
3054 pos += '1 1 0' * panel_bg_padding;
3055 mySize -= '2 2 0' * panel_bg_padding;
3058 local float color1, color2; // color already declared as a global in hud.qc
3061 float scale2d, normalsize, bigsize;
3064 teamradar_origin2d = pos + 0.5 * mySize;
3065 teamradar_size2d = mySize;
3067 if(minimapname == "")
3070 teamradar_loadcvars();
3072 switch(hud_radar_zoommode)
3076 f = current_zoomfraction;
3079 f = 1 - current_zoomfraction;
3089 switch(hud_radar_rotation)
3092 teamradar_angle = view_angles_y - 90;
3095 teamradar_angle = 90 * hud_radar_rotation;
3099 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3100 teamradar_size2d = mySize;
3102 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3104 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3105 if(hud_radar_rotation == 0)
3107 // max-min distance must fit the radar in any rotation
3108 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3112 vector c0, c1, c2, c3, span;
3113 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3114 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3115 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3116 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3118 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3119 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3121 // max-min distance must fit the radar in x=x, y=y
3123 teamradar_size2d_x * scale2d / (1.05 * span_x),
3124 teamradar_size2d_y * scale2d / (1.05 * span_y)
3128 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3129 if(bigsize > normalsize)
3130 normalsize = bigsize;
3134 + (1 - f) * normalsize;
3135 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3136 f * (mi_min + mi_max) * 0.5
3137 + (1 - f) * view_origin);
3139 color1 = GetPlayerColor(player_localentnum-1);
3140 rgb = GetTeamRGB(color1);
3149 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3151 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3152 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3153 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3154 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3155 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3157 color2 = GetPlayerColor(tm.sv_entnum);
3158 //if(color == COLOR_SPECTATOR || color == color2)
3159 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3161 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3163 drawresetcliparea();
3168 void HUD_Score(void)
3170 if(!autocvar_hud_score && !autocvar__hud_configure)
3173 float id = HUD_PANEL_SCORE;
3174 HUD_Panel_UpdateCvarsForId(id);
3177 mySize = panel_size;
3179 HUD_Panel_DrawBg(1);
3180 if(panel_bg_padding)
3182 pos += '1 1 0' * panel_bg_padding;
3183 mySize -= '2 2 0' * panel_bg_padding;
3186 float score, distribution, leader;
3188 vector distribution_color;
3190 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3192 // TODO... this (race part) still uses constant coordinates :/
3193 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3194 /*pl = players.sort_next;
3197 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3198 if(pl.scores[ps_primary] == 0)
3201 score = me.(scores[ps_primary]);
3203 float racemin, racesec, racemsec;
3204 float distsec, distmsec, minusplus;
3206 racemin = floor(score/(60 * TIME_FACTOR));
3207 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
3208 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
3210 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3211 // distribution display
3212 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3214 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
3215 distmsec = fabs(distribution);
3217 distsec = floor(fabs(distribution)/TIME_FACTOR);
3218 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
3219 if (distribution < 0)
3223 if (distribution <= 0) {
3224 distribution_color = eY;
3225 minusplus = 1; // minusplus 1: always prefix with minus sign
3228 distribution_color = eX;
3229 minusplus = 2; // minusplus 1: always prefix with plus sign
3231 //HUD_DrawXNum(bottomright - '0 48 0' - '16 0 0' * TIME_DECIMALS, distmsec, -TIME_DECIMALS, 0, 16, distribution_color, 0, 0, panel_fg_alpha, DRAWFLAG_NORMAL);
3232 //HUD_DrawXNum(bottomright - '68 48 0' - '16 0 0' * TIME_DECIMALS, distsec, 4, minusplus, 16, distribution_color, 0, 0, panel_fg_alpha, DRAWFLAG_NORMAL);
3233 drawpic_aspect_skin(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "num_dot", '16 16 0', distribution_color, panel_fg_alpha, DRAWFLAG_ADDITIVE);
3235 // race record display
3236 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
3237 drawpic_aspect_skin(bottomright - '0 32 0' - '32 0 0' * (4 + TIME_DECIMALS), "num_leading_4", '0 28 0' + '32 0 0' * (4 + TIME_DECIMALS), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3239 //HUD_DrawXNum(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0', racemsec, -TIME_DECIMALS, 0, 30, '1 1 1', 0, 0, panel_fg_alpha, DRAWFLAG_NORMAL);
3240 //HUD_DrawXNum(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '66 0 0', racesec, -2, 0, 30, '1 1 1', 0, 0, panel_fg_alpha, DRAWFLAG_NORMAL);
3241 drawpic_aspect_skin(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '18 0 0', "num_dot", '30 30 0', '1 1 1', panel_fg_alpha, DRAWFLAG_ADDITIVE);
3243 //HUD_DrawXNum(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '132 0 0', racemin, -2, 0, 30, '1 1 1', 0, 0, panel_fg_alpha, DRAWFLAG_NORMAL);
3244 drawpic_aspect_skin(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '84 0 0', "num_colon", '30 30 0', '1 1 1', panel_fg_alpha, DRAWFLAG_ADDITIVE);
3246 } else if (!teamplay) { // non-teamgames
3247 // me vector := [team/connected frags id]
3248 pl = players.sort_next;
3252 if(autocvar__hud_configure)
3255 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3259 score = me.(scores[ps_primary]);
3260 if(autocvar__hud_configure)
3263 if(distribution >= 5) {
3264 distribution_color = eY;
3266 } else if(distribution >= 0) {
3267 distribution_color = '1 1 1';
3269 } else if(distribution >= -5)
3270 distribution_color = '1 1 0';
3272 distribution_color = eX;
3274 score_len = strlen(ftos(score));
3276 drawstring_aspect(pos + eX * 0.75 * mySize_x, ftos(distribution), eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3278 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3279 drawfont = hud_bigfont;
3280 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3281 drawfont = hud_font;
3282 } else { // teamgames
3283 float max_fragcount;
3284 max_fragcount = -99;
3287 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3288 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !autocvar__hud_configure)) // no players? don't display
3290 score = tm.(teamscores[ts_primary]);
3291 if(autocvar__hud_configure)
3295 score_len = strlen(ftos(score));
3297 if (score > max_fragcount)
3298 max_fragcount = score;
3300 if(tm.team == myteam) {
3301 if (max_fragcount == score)
3304 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3305 drawfont = hud_bigfont;
3306 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3307 drawfont = hud_font;
3309 if (max_fragcount == score)
3312 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);
3313 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, (1/3) * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3322 void HUD_RaceTimer (void) {
3323 if(!autocvar_hud_racetimer && !(gametype == GAME_RACE || gametype == GAME_CTS) && !autocvar__hud_configure)
3326 float id = HUD_PANEL_RACETIMER;
3327 HUD_Panel_UpdateCvarsForId(id);
3330 mySize = panel_size;
3332 HUD_Panel_DrawBg(1);
3333 if(panel_bg_padding)
3335 pos += '1 1 0' * panel_bg_padding;
3336 mySize -= '2 2 0' * panel_bg_padding;
3339 // always force 4:1 aspect
3341 if(mySize_x/mySize_y > 4)
3343 newSize_x = 4 * mySize_y;
3344 newSize_y = mySize_y;
3346 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3350 newSize_y = 1/4 * mySize_x;
3351 newSize_x = mySize_x;
3353 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3357 drawfont = hud_bigfont;
3359 string s, forcetime;
3361 if(autocvar__hud_configure)
3364 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);
3365 s = "^1Intermediate 1 (+15.42)";
3366 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);
3367 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3368 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);
3370 else if(race_checkpointtime)
3372 a = bound(0, 2 - (time - race_checkpointtime), 1);
3375 if(a > 0) // just hit a checkpoint?
3377 if(race_checkpoint != 254)
3379 if(race_time && race_previousbesttime)
3380 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3382 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3384 forcetime = TIME_ENCODED_TOSTRING(race_time);
3389 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3391 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3392 if(a > 0) // next one?
3394 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3399 if(s != "" && a > 0)
3401 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3402 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3403 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);
3406 if(race_penaltytime)
3408 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3411 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3412 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3413 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3414 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);
3420 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3421 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', panel_fg_alpha, 0, a);
3422 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);
3427 if(race_laptime && race_checkpoint != 255)
3429 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3430 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3431 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);
3436 if(race_mycheckpointtime)
3438 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3439 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3440 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3441 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3442 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);
3444 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3446 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3447 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3448 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3449 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3450 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);
3453 if(race_penaltytime && !race_penaltyaccumulator)
3455 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3456 a = bound(0, (1 + t - time), 1);
3460 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3462 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3463 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3464 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3465 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);
3470 drawfont = hud_font;
3475 float vote_yescount;
3478 float vote_highlighted; // currently selected vote
3480 float vote_active; // is there an active vote?
3481 float vote_prev; // previous state of vote_active to check for a change
3483 float vote_change; // "time" when vote_active changed
3485 void HUD_VoteWindow(void)
3487 if(!autocvar_hud_vote && !autocvar__hud_configure)
3490 float id = HUD_PANEL_VOTE;
3491 HUD_Panel_UpdateCvarsForId(id);
3494 mySize = panel_size;
3498 if(vote_active != vote_prev) {
3500 vote_prev = vote_active;
3503 if(vote_active || autocvar__hud_configure)
3504 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3506 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3508 if(autocvar__hud_configure)
3518 a = vote_alpha * bound(autocvar_hud_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3520 HUD_Panel_DrawBg(a);
3521 if(panel_bg_padding)
3523 pos += '1 1 0' * panel_bg_padding;
3524 mySize -= '2 2 0' * panel_bg_padding;
3527 // always force 3:1 aspect
3529 if(mySize_x/mySize_y > 3)
3531 newSize_x = 3 * mySize_y;
3532 newSize_y = mySize_y;
3534 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3538 newSize_y = 1/3 * mySize_x;
3539 newSize_x = mySize_x;
3541 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3545 s = "A vote has been called for:";
3546 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, mySize_y*(2/8), '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3547 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1.75/8), stringwidth_colors);
3548 if(autocvar__hud_configure)
3549 s = "Configure the HUD";
3550 drawstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, mySize_y*(1.75/8), '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3552 // print the yes/no counts
3553 s = strcat("Yes (", getcommandkey("not bound", "vyes"), "): ", ftos(vote_yescount));
3554 drawstring_aspect(pos + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, mySize_y*(1.5/8) , '0 1 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3555 s = strcat("No (", getcommandkey("not bound", "vno"), "): ", ftos(vote_nocount));
3556 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, mySize_y*(1.5/8) , '1 0 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3558 // draw the progress bar backgrounds
3559 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);
3561 // draw the highlights
3562 if(vote_highlighted == 1) {
3563 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3564 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);
3566 else if(vote_highlighted == 2) {
3567 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3568 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);
3571 // draw the progress bars
3572 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3573 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);
3575 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3576 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);
3578 drawresetcliparea();
3581 vote_highlighted = 0;
3585 // Mod icons panel (#10)
3588 float mod_active; // is there any active mod icon?
3590 // CTF HUD modicon section
3591 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3592 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3593 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3595 void HUD_Mod_CTF_Reset(void)
3597 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3600 void HUD_Mod_CTF(vector pos, vector mySize)
3602 vector redflag_pos, blueflag_pos;
3604 float f; // every function should have that
3606 float redflag, blueflag; // current status
3607 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3610 stat_items = getstati(STAT_ITEMS);
3611 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3612 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3614 if(redflag || blueflag)
3619 if(autocvar__hud_configure)
3625 // when status CHANGES, set old status into prevstatus and current status into status
3626 if (redflag != redflag_prevframe)
3628 redflag_statuschange_time = time;
3629 redflag_prevstatus = redflag_prevframe;
3630 redflag_prevframe = redflag;
3633 if (blueflag != blueflag_prevframe)
3635 blueflag_statuschange_time = time;
3636 blueflag_prevstatus = blueflag_prevframe;
3637 blueflag_prevframe = blueflag;
3640 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3641 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3643 float BLINK_FACTOR = 0.15;
3644 float BLINK_BASE = 0.85;
3646 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3648 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3650 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3652 string red_icon, red_icon_prevstatus;
3653 float red_alpha, red_alpha_prevstatus;
3654 red_alpha = red_alpha_prevstatus = 1;
3656 case 1: red_icon = "flag_red_taken"; break;
3657 case 2: red_icon = "flag_red_lost"; break;
3658 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3660 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3661 red_icon = "flag_red_shielded";
3663 red_icon = string_null;
3666 switch(redflag_prevstatus) {
3667 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3668 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3669 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3672 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3673 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3674 red_icon_prevstatus = "flag_red_shielded";
3676 red_icon_prevstatus = string_null;
3680 string blue_icon, blue_icon_prevstatus;
3681 float blue_alpha, blue_alpha_prevstatus;
3682 blue_alpha = blue_alpha_prevstatus = 1;
3684 case 1: blue_icon = "flag_blue_taken"; break;
3685 case 2: blue_icon = "flag_blue_lost"; break;
3686 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3688 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3689 blue_icon = "flag_blue_shielded";
3691 blue_icon = string_null;
3694 switch(blueflag_prevstatus) {
3695 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3696 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3697 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3700 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3701 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3702 blue_icon_prevstatus = "flag_blue_shielded";
3704 blue_icon_prevstatus = string_null;
3708 if(mySize_x > mySize_y) {
3709 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3711 blueflag_pos = pos + eX * 0.5 * mySize_x;
3714 redflag_pos = pos + eX * 0.5 * mySize_x;
3716 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3718 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3720 blueflag_pos = pos + eY * 0.5 * mySize_y;
3723 redflag_pos = pos + eY * 0.5 * mySize_y;
3725 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3728 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3729 if(red_icon_prevstatus && f < 1)
3730 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3732 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3734 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3735 if(blue_icon_prevstatus && f < 1)
3736 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3738 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3741 // Keyhunt HUD modicon section
3742 float kh_runheretime;
3744 void HUD_Mod_KH_Reset(void)
3749 void HUD_Mod_KH(vector pos, vector mySize)
3751 mod_active = 1; // keyhunt should never hide the mod icons panel
3755 vector p, pa, kh_size, kh_asize;
3757 kh_keys = getstati(STAT_KH_KEYS);
3760 if(mySize_x > mySize_y)
3762 p_y = pos_y + 0.25 * mySize_y;
3763 pa = p - eY * 0.25 * mySize_y;
3765 kh_size_x = mySize_x * 0.25;
3766 kh_size_y = 0.75 * mySize_y;
3767 kh_asize_x = mySize_x * 0.25;
3768 kh_asize_y = mySize_y * 0.25;
3772 p_y = pos_y + 0.125 * mySize_y;
3773 pa = p - eY * 0.125 * mySize_y;
3775 kh_size_x = mySize_x * 0.5;
3776 kh_size_y = 0.375 * mySize_y;
3777 kh_asize_x = mySize_x * 0.5;
3778 kh_asize_y = mySize_y * 0.125;
3785 for(i = 0; i < 4; ++i)
3787 key = floor(kh_keys / pow(32, i)) & 31;
3789 if(keyteam == 30 && keycount <= 4)
3791 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3795 // this yields 8 exactly if "RUN HERE" shows
3800 kh_runheretime = time;
3801 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3806 for(i = 0; i < 4; ++i)
3808 key = floor(kh_keys / pow(32, i)) & 31;
3821 default: // owned or dropped
3826 a = a * panel_fg_alpha;
3827 aa = aa * panel_fg_alpha;
3833 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3836 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3839 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3842 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3847 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3850 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3853 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3856 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3859 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3863 if(mySize_x > mySize_y)
3865 p_x += 0.25 * mySize_x;
3866 pa_x += 0.25 * mySize_x;
3872 p_y = pos_y + 0.625 * mySize_y;
3873 pa_y = pos_y + 0.5 * mySize_y;
3879 p_x += 0.5 * mySize_x;
3880 pa_x += 0.5 * mySize_x;
3886 // Nexball HUD mod icon
3887 void HUD_Mod_NexBall(vector pos, vector mySize)
3889 float stat_items, nb_pb_starttime, dt, p;
3891 stat_items = getstati(STAT_ITEMS);
3892 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3894 if (stat_items & IT_KEY1)
3899 //Manage the progress bar if any
3900 if (nb_pb_starttime > 0)
3902 dt = mod(time - nb_pb_starttime, nb_pb_period);
3903 // one period of positive triangle
3904 p = 2 * dt / nb_pb_period;
3911 if(mySize_x > mySize_y)
3913 barsize = eX * p * mySize_x + eY * mySize_y;
3918 barsize = eX * mySize_x + eY * p * mySize_y;
3921 HUD_Panel_GetProgressBarColor("nexball")
3922 HUD_Panel_DrawProgressBar(pos, vertical, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3925 if (stat_items & IT_KEY1)
3926 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3929 // Race/CTS HUD mod icons
3930 float crecordtime_prev; // last remembered crecordtime
3931 float crecordtime_change_time; // time when crecordtime last changed
3932 float srecordtime_prev; // last remembered srecordtime
3933 float srecordtime_change_time; // time when srecordtime last changed
3935 float race_status_time;
3936 float race_status_prev;
3937 string race_status_name_prev;
3938 void HUD_Mod_Race(vector pos, vector mySize)
3940 mod_active = 1; // race should never hide the mod icons panel
3942 me = playerslots[player_localentnum - 1];
3944 float f; // yet another function has this
3945 score = me.(scores[ps_primary]);
3947 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3948 return; // no records in the actual race
3950 drawfont = hud_bigfont;
3952 // clientside personal record
3954 if(gametype == GAME_CTS)
3958 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3960 if(score && (score < t || !t)) {
3961 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3962 if(cvar("cl_autodemo_delete_keeprecords"))
3964 f = cvar("cl_autodemo_delete");
3966 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3970 if(t != crecordtime_prev) {
3971 crecordtime_prev = t;
3972 crecordtime_change_time = time;
3974 f = time - crecordtime_change_time;
3977 drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3978 drawstring_aspect(pos + eY * 0.25 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3980 drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3981 drawstring_aspect(pos + eY * 0.25 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3982 //drawstring_expanding(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
3983 //drawstring_expanding(pos + eY * 0.2 * mySize_y, TIME_ENCODED_TOSTRING(t), '1 1 0' * 0.2 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
3987 t = race_server_record;
3988 if(t != srecordtime_prev) {
3989 srecordtime_prev = t;
3990 srecordtime_change_time = time;
3992 f = time - srecordtime_change_time;
3995 drawstring_aspect(pos + eY * 0.5 * mySize_y, "Server best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3996 drawstring_aspect(pos + eY * 0.75 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3998 drawstring_aspect(pos + eY * 0.5 * mySize_y, "Server best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3999 drawstring_aspect(pos + eY * 0.75 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4000 //drawstring_expanding(pos + eY * 0.5 * mySize_y, "Server best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4001 //drawstring_expanding(pos + eY * 0.5 * mySize_y + eY * 0.2 * mySize_y, TIME_ENCODED_TOSTRING(t),'1 1 0' * 0.2 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4004 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4005 race_status_time = time + 5;
4006 race_status_prev = race_status;
4007 if (race_status_name_prev)
4008 strunzone(race_status_name_prev);
4009 race_status_name_prev = strzone(race_status_name);
4012 pos_x += mySize_x/2;
4015 a = bound(0, race_status_time - time, 1);
4018 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4022 rank = race_CheckName(race_status_name);
4024 rankname = race_PlaceName(rank);
4027 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4029 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4031 if(race_status == 0)
4032 drawpic_aspect_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4033 else if(race_status == 1) {
4034 drawpic_aspect_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4035 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4036 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4037 } else if(race_status == 2) {
4038 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4039 drawpic_aspect_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4041 drawpic_aspect_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4042 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4043 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4044 } else if(race_status == 3) {
4045 drawpic_aspect_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4046 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4047 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4050 if (race_status_time - time <= 0) {
4051 race_status_prev = -1;
4053 if(race_status_name)
4054 strunzone(race_status_name);
4055 race_status_name = string_null;
4056 if(race_status_name_prev)
4057 strunzone(race_status_name_prev);
4058 race_status_name_prev = string_null;
4060 drawfont = hud_font;
4063 float mod_prev; // previous state of mod_active to check for a change
4065 float mod_change; // "time" when mod_active changed
4067 void HUD_ModIcons(void)
4069 if(!autocvar_hud_modicons && !autocvar__hud_configure)
4072 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !autocvar__hud_configure)
4075 float id = HUD_PANEL_MODICONS;
4076 HUD_Panel_UpdateCvarsForId(id);
4079 mySize = panel_size;
4081 if(mod_active != mod_prev) {
4083 mod_prev = mod_active;
4086 if(mod_active || autocvar__hud_configure)
4087 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4089 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4092 HUD_Panel_DrawBg(mod_alpha);
4094 if(panel_bg_padding)
4096 pos += '1 1 0' * panel_bg_padding;
4097 mySize -= '2 2 0' * panel_bg_padding;
4100 // these MUST be ran in order to update mod_active
4101 if(gametype == GAME_KEYHUNT)
4102 HUD_Mod_KH(pos, mySize);
4103 else if(gametype == GAME_CTF || autocvar__hud_configure)
4104 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4105 else if(gametype == GAME_NEXBALL)
4106 HUD_Mod_NexBall(pos, mySize);
4107 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4108 HUD_Mod_Race(pos, mySize);
4111 // Draw pressed keys (#11)
4113 void HUD_DrawPressedKeys(void)
4115 if(!autocvar_hud_pressedkeys && !autocvar__hud_configure)
4118 if(!(spectatee_status > 0 || autocvar_hud_pressedkeys >= 2 || autocvar__hud_configure))
4121 float id = HUD_PANEL_PRESSEDKEYS;
4122 HUD_Panel_UpdateCvarsForId(id);
4125 mySize = panel_size;
4127 HUD_Panel_DrawBg(1);
4128 if(panel_bg_padding)
4130 pos += '1 1 0' * panel_bg_padding;
4131 mySize -= '2 2 0' * panel_bg_padding;
4134 // always force 2:1 aspect
4136 if(mySize_x/mySize_y > 2)
4138 newSize_x = 2 * mySize_y;
4139 newSize_y = mySize_y;
4141 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4145 newSize_y = 1/2 * mySize_x;
4146 newSize_x = mySize_x;
4148 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4153 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4156 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4157 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4158 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);
4159 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);
4160 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);
4161 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);
4162 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);
4165 // Handle chat as a panel (#12)
4169 if(!autocvar_hud_chat && !autocvar__hud_configure)
4171 cvar_set("con_chatrect", "0");
4175 float id = HUD_PANEL_CHAT;
4176 HUD_Panel_UpdateCvarsForId(id);
4179 mySize = panel_size;
4181 HUD_Panel_DrawBg(1);
4182 if(panel_bg_padding)
4184 pos += '1 1 0' * panel_bg_padding;
4185 mySize -= '2 2 0' * panel_bg_padding;
4188 cvar_set("con_chatrect", "1");
4190 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4191 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4193 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4194 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4196 if(autocvar__hud_configure)
4199 chatsize = cvar("con_chatsize");
4200 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4202 for(i = 0; i < cvar("con_chat"); ++i)
4204 if(i == cvar("con_chat") - 1)
4207 a = panel_fg_alpha * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4208 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);
4213 // Engine info panel (#13)
4220 float frametimeavg1; // 1 frame ago
4221 float frametimeavg2; // 2 frames ago
4222 void HUD_EngineInfo(void)
4224 if(!autocvar_hud_engineinfo && !autocvar__hud_configure)
4227 float id = HUD_PANEL_ENGINEINFO;
4228 HUD_Panel_UpdateCvarsForId(id);
4231 mySize = panel_size;
4233 HUD_Panel_DrawBg(1);
4234 if(panel_bg_padding)
4236 pos += '1 1 0' * panel_bg_padding;
4237 mySize -= '2 2 0' * panel_bg_padding;
4240 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4242 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4243 frametimeavg2 = frametimeavg1;
4244 frametimeavg1 = frametimeavg;
4247 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4248 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.
4250 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
4251 prevfps = (1/frametime);
4252 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"
4258 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4260 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4262 prevfps_time = time;
4267 color = HUD_Get_Num_Color (prevfps, 100);
4268 drawfont = hud_bigfont;
4269 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), mySize, mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4270 drawfont = hud_font;
4273 // Info messages panel (#14)
4275 void HUD_InfoMessages(void)
4277 if(!autocvar_hud_infomessages && !autocvar__hud_configure)
4280 float id = HUD_PANEL_INFOMESSAGES;
4281 HUD_Panel_UpdateCvarsForId(id);
4284 mySize = panel_size;
4286 HUD_Panel_DrawBg(1);
4287 if(panel_bg_padding)
4289 pos += '1 1 0' * panel_bg_padding;
4290 mySize -= '2 2 0' * panel_bg_padding;
4293 // always force 6:1 aspect
4295 if(mySize_x/mySize_y > 6)
4297 newSize_x = 6 * mySize_y;
4298 newSize_y = mySize_y;
4300 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4304 newSize_y = 1/6 * mySize_x;
4305 newSize_x = mySize_x;
4307 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4316 fontsize = '0.25 0.25 0' * mySize_y;
4319 if(!autocvar__hud_configure)
4321 if(spectatee_status && !intermission)
4323 //drawfont = hud_bigfont;
4324 if(spectatee_status == -1)
4327 s = GetPlayerName(spectatee_status - 1);
4329 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
4330 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, panel_fg_alpha, DRAWFLAG_NORMAL);
4331 //drawfont = hud_font;
4333 // spectator text in the upper right corner
4334 if(spectatee_status == -1)
4335 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
4337 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
4338 if(autocvar_hud_infomessages_flip)
4339 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4340 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4341 o += eY * fontsize_y;
4343 if(spectatee_status == -1)
4344 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
4346 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
4347 if(autocvar_hud_infomessages_flip)
4348 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4349 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4350 o += eY * fontsize_y;
4352 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
4353 if(autocvar_hud_infomessages_flip)
4354 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4355 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4356 o += eY * fontsize_y;
4358 if(gametype == GAME_ARENA)
4359 s = "^1Wait for your turn to join";
4360 else if(gametype == GAME_LMS)
4363 sk = playerslots[player_localentnum - 1];
4364 if(sk.(scores[ps_primary]) >= 666)
4365 s = "^1Match has already begun";
4366 else if(sk.(scores[ps_primary]) > 0)
4367 s = "^1You have no more lives left";
4369 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4372 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4373 if(autocvar_hud_infomessages_flip)
4374 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4375 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4376 o += eY * fontsize_y;
4378 //show restart countdown:
4379 if (time < getstatf(STAT_GAMESTARTTIME)) {
4381 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4382 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4383 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
4384 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4385 o += eY * fontsize_y;
4388 if(warmup_stage && !intermission)
4390 s = "^2Currently in ^1warmup^2 stage!";
4391 if(autocvar_hud_infomessages_flip)
4392 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4393 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4394 o += eY * fontsize_y;
4398 if(mod(time, 1) >= 0.5)
4403 if(ready_waiting && !intermission && !spectatee_status)
4405 if(ready_waiting_for_me)
4408 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
4410 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
4415 s = strcat("^2Waiting for others to ready up to end warmup...");
4417 s = strcat("^2Waiting for others to ready up...");
4419 if(autocvar_hud_infomessages_flip)
4420 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4421 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4422 o += eY * fontsize_y;
4424 else if(warmup_stage && !intermission && !spectatee_status)
4426 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
4427 if(autocvar_hud_infomessages_flip)
4428 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4429 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4430 o += eY * fontsize_y;
4433 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4435 float ts_min, ts_max;
4436 tm = teams.sort_next;
4439 for(; tm.sort_next; tm = tm.sort_next)
4441 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4443 if(!ts_min) ts_min = tm.team_size;
4444 else ts_min = min(ts_min, tm.team_size);
4445 if(!ts_max) ts_max = tm.team_size;
4446 else ts_max = max(ts_max, tm.team_size);
4448 if ((ts_max - ts_min) > 1)
4450 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
4451 tm = GetTeam(myteam, false);
4453 if (tm.team != COLOR_SPECTATOR)
4454 if (tm.team_size == ts_max)
4455 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
4457 if(autocvar_hud_infomessages_flip)
4458 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4459 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4460 o += eY * fontsize_y;
4467 s = "^7Press ^3ESC ^7to show HUD options.";
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 = "^3Doubleclick ^7a panel for panel-specific options.";
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;
4477 s = "^3CTRL ^7to disable collision testing, ^3SHIFT ^7and";
4478 if(autocvar_hud_infomessages_flip)
4479 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4480 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4481 o += eY * fontsize_y;
4482 s = "^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.";
4483 if(autocvar_hud_infomessages_flip)
4484 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4485 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4486 o += eY * fontsize_y;
4496 void HUD_ShowSpeed(void)
4499 float pos, conversion_factor;
4500 string speed, zspeed, unit;
4502 switch(cvar("cl_showspeed_unit"))
4507 conversion_factor = 1.0;
4511 conversion_factor = 1.0;
4515 conversion_factor = 0.0254;
4519 conversion_factor = 0.0254 * 3.6;
4523 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4527 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4531 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4533 numsize_x = numsize_y = cvar("cl_showspeed_size");
4534 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4536 drawfont = hud_bigfont;
4537 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4539 if (cvar("cl_showspeed_z") == 1) {
4540 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4541 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4544 drawfont = hud_font;
4547 vector acc_prevspeed;
4551 void HUD_ShowAcceleration(void)
4553 float acceleration, sz, scale, alpha, f;
4554 vector pos, top, rgb;
4555 top_x = vid_conwidth/2;
4558 f = time - acc_prevtime;
4559 if(cvar("cl_showacceleration_z"))
4560 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4562 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4563 acc_prevspeed = pmove_vel;
4564 acc_prevtime = time;
4566 f = bound(0, f * 10, 1);
4567 acc_avg = acc_avg * (1 - f) + acceleration * f;
4568 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4570 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4572 sz = cvar("cl_showacceleration_size");
4573 scale = cvar("cl_showacceleration_scale");
4574 alpha = cvar("cl_showacceleration_alpha");
4575 if (cvar("cl_showacceleration_color_custom"))
4576 rgb = stov(cvar_string("cl_showacceleration_color"));
4579 if (acceleration < 0) {
4580 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4581 } else if (acceleration > 0) {
4582 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4586 if (acceleration > 0)
4587 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4588 else if (acceleration < 0)
4589 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4592 void HUD_Reset (void)
4594 // reset gametype specific icons
4595 if(gametype == GAME_KEYHUNT)
4597 else if(gametype == GAME_CTF)
4598 HUD_Mod_CTF_Reset();
4601 #define HUD_DrawPanel(id)\
4603 case (HUD_PANEL_RADAR):\
4604 HUD_Radar(); break;\
4605 case (HUD_PANEL_WEAPONICONS):\
4606 HUD_WeaponIcons(); break;\
4607 case (HUD_PANEL_INVENTORY):\
4608 HUD_Inventory(); break;\
4609 case (HUD_PANEL_POWERUPS):\
4610 HUD_Powerups(); break;\
4611 case (HUD_PANEL_HEALTHARMOR):\
4612 HUD_HealthArmor(); break;\
4613 case (HUD_PANEL_NOTIFY):\
4614 HUD_Notify(); break;\
4615 case (HUD_PANEL_TIMER):\
4616 HUD_Timer(); break;\
4617 case (HUD_PANEL_SCORE):\
4618 HUD_Score(); break;\
4619 case (HUD_PANEL_RACETIMER):\
4620 HUD_RaceTimer(); break;\
4621 case (HUD_PANEL_VOTE):\
4622 HUD_VoteWindow(); break;\
4623 case (HUD_PANEL_MODICONS):\
4624 HUD_ModIcons(); break;\
4625 case (HUD_PANEL_PRESSEDKEYS):\
4626 HUD_DrawPressedKeys(); break;\
4627 case (HUD_PANEL_CHAT):\
4629 case (HUD_PANEL_ENGINEINFO):\
4630 HUD_EngineInfo(); break;\
4631 case (HUD_PANEL_INFOMESSAGES):\
4632 HUD_InfoMessages(); break;\
4635 void HUD_Main (void)
4637 hud_skin_path = strcat("gfx/hud/", autocvar_hud_skin);
4639 if(disable_menu_alphacheck == 1)
4640 menu_fade_alpha = 1;
4642 menu_fade_alpha = (1 - autocvar__menu_alpha);
4643 hud_fg_alpha = cvar("hud_fg_alpha");
4645 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4646 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4647 hud_color_bg_team = cvar("hud_color_bg_team");
4649 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4650 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4654 // HUD configure visible grid
4655 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4659 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2); ++i)
4661 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);
4664 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2); ++i)
4666 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);
4672 if(teamplay && autocvar_hud_dock_color_team) {
4673 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4674 color = colormapPaletteColor(mod(f, 16), 1) * autocvar_hud_dock_color_team;
4676 else if(autocvar_hud_dock_color == "shirt") {
4677 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4678 color = colormapPaletteColor(floor(f / 16), 0);
4680 else if(autocvar_hud_dock_color == "pants") {
4681 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4682 color = colormapPaletteColor(mod(f, 16), 1);
4685 color = stov(autocvar_hud_dock_color);
4688 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4691 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4692 if(precache_pic(pic) == "") {
4693 pic = "gfx/hud/default/dock";
4695 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...
4698 // cache the panel order into the panel_order array
4699 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4700 if(hud_panelorder_prev)
4701 strunzone(hud_panelorder_prev);
4702 hud_panelorder_prev = strzone(autocvar__hud_panelorder);
4703 tokenize_console(autocvar__hud_panelorder);
4704 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4705 panel_order[i] = stof(argv(i));
4708 // draw panels in order specified by panel_order array
4709 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
4710 HUD_DrawPanel(panel_order[i]);
4713 // TODO hud_'ify these
4714 if (cvar("cl_showspeed"))
4716 if (cvar("cl_showacceleration"))
4717 HUD_ShowAcceleration();
4719 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)
4720 localcmd("cmd selectteam auto; cmd join\n");
4722 hud_configure_prev = autocvar__hud_configure;
4724 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again
4725 disable_menu_alphacheck = 0;