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 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
86 // TODO: make a default skin, and fallback to these!
88 // drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
91 #define drawpic_aspect(pos,pic,mySize,color,alpha,drawflag)\
93 imgsize = drawgetimagesize(pic);\
94 imgaspect = imgsize_x/imgsize_y;\
98 if(aspect > imgaspect) {\
99 sz_x = sz_y * imgaspect;\
100 drawpic(pos + eX * (oldsz_x - sz_x) * 0.5, pic, sz, color, alpha, drawflag);\
102 sz_y = sz_x / imgaspect;\
103 drawpic(pos + eY * (oldsz_y - sz_y) * 0.5, pic, sz, color, alpha, drawflag);\
106 #define drawpic_aspect_skin(pos,pic,sz,color,alpha,drawflag)\
107 do {drawpic_aspect(pos, strcat(hud_skin_path, "/", pic), sz, color, alpha, drawflag) } while(0)
110 void drawpic_aspect_skin_expanding(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
112 //drawpic_aspect_expanding(pos, strcat("gfx/hud/", autocvar_hud_skin, "/", pic), sz, rgb, alpha, flag, fadelerp);
115 void drawpic_aspect_skin_expanding_two(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
117 //drawpic_aspect_expanding_two(pos, strcat("gfx/hud/", autocvar_hud_skin, "/", pic), sz, rgb, alpha, flag, fadelerp);
120 vector HUD_Get_Num_Color (float x, float maxvalue)
128 else if(x > maxvalue * 0.75) {
129 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
130 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
133 else if(x > maxvalue * 0.5) {
134 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
135 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
136 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
138 else if(x > maxvalue * 0.25) {
141 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
143 else if(x > maxvalue * 0.1) {
145 color_y = (x-20)*90/27/100; // green value between 0 -> 1
146 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
156 float stringwidth_colors(string s, vector theSize)
158 return stringwidth(s, TRUE, theSize);
161 float stringwidth_nocolors(string s, vector theSize)
163 return stringwidth(s, FALSE, theSize);
166 #define CENTERPRINT_MAX_LINES 30
167 string centerprint_messages[CENTERPRINT_MAX_LINES];
168 float centerprint_width[CENTERPRINT_MAX_LINES];
169 vector centerprint_start;
170 float centerprint_expire;
171 float centerprint_num;
172 float centerprint_offset_hint;
173 vector centerprint_fontsize;
175 void centerprint(string strMessage)
177 float i, j, n, hcount;
180 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
182 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
184 if(cvar("scr_centertime") <= 0)
190 // strip trailing newlines
191 j = strlen(strMessage) - 1;
192 while(substring(strMessage, j, 1) == "\n" && j >= 0)
194 strMessage = substring(strMessage, 0, j + 1);
199 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
201 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
203 strMessage = substring(strMessage, j, strlen(strMessage) - j);
204 centerprint_offset_hint = j;
209 // if we get here, we have a message. Initialize its height.
212 n = tokenizebyseparator(strMessage, "\n");
214 for(j = 0; j < n; ++j)
216 getWrappedLine_remaining = argv(j);
217 while(getWrappedLine_remaining)
219 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
220 if(centerprint_messages[i])
221 strunzone(centerprint_messages[i]);
222 centerprint_messages[i] = strzone(s);
223 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
226 // half height for empty lines looks better
232 if(i >= CENTERPRINT_MAX_LINES)
238 h = centerprint_fontsize_y*hcount;
240 havail = vid_conheight;
241 if(cvar("con_chatpos") < 0)
242 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
243 if(havail > vid_conheight - 70)
244 havail = vid_conheight - 70; // avoid overlapping HUD
246 centerprint_start_x = 0;
249 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
251 // here, the centerprint would cover the crosshair. REALLY BAD.
252 forbiddenmin = vid_conheight * 0.5 - h - 16;
253 forbiddenmax = vid_conheight * 0.5 + 16;
255 allowedmin = scoreboard_bottom;
256 allowedmax = havail - h;
257 preferred = (havail - h)/2;
260 // possible orderings (total: 4! / 4 = 6)
261 // allowedmin allowedmax forbiddenmin forbiddenmax
262 // forbiddenmin forbiddenmax allowedmin allowedmax
263 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
265 // forbidden doesn't matter in this case
266 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
268 // allowedmin forbiddenmin allowedmax forbiddenmax
269 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
271 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
273 // allowedmin forbiddenmin forbiddenmax allowedmax
274 else if(allowedmin < forbiddenmin)
276 // make sure the forbidden zone is not covered
277 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
278 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
280 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
282 // forbiddenmin allowedmin allowedmax forbiddenmax
283 else if(allowedmax < forbiddenmax)
285 // it's better to leave the allowed zone (overlap with scoreboard) than
286 // to cover the forbidden zone (crosshair)
287 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
288 centerprint_start_y = forbiddenmax;
290 centerprint_start_y = forbiddenmin;
292 // forbiddenmin allowedmin forbiddenmax allowedmax
295 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
298 centerprint_start_y =
301 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
309 centerprint_expire = time + cvar("scr_centertime");
312 void HUD_DrawCenterPrint (void)
319 //if(time > centerprint_expire)
322 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
323 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
324 //sz = 1.2 / (a + 0.2);
329 pos = centerprint_start;
330 for (i=0; i<centerprint_num; i = i + 1)
332 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
333 ts = centerprint_messages[i];
336 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
337 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
338 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
339 pos_y = pos_y + centerprint_fontsize_y;
342 // half height for empty lines looks better
343 pos_y = pos_y + centerprint_fontsize_y * 0.5;
347 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
349 position_x -= 2 / 3 * strlen(text) * scale_x;
350 drawstring(position, text, scale, rgb, alpha, flag);
353 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
355 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
356 drawstring(position, text, scale, rgb, alpha, flag);
359 // return the string of the given race place
360 string race_PlaceName(float pos) {
368 return strcat(ftos(pos), "th");
371 // return the string of the onscreen race timer
372 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
380 if(histime == 0) // goal hit
384 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
394 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
400 lapstr = strcat(" (-", ftos(lapdelta), "L)");
403 else if(lapdelta < 0)
405 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
409 else if(histime > 0) // anticipation
411 if(mytime >= histime)
412 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
414 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
421 cpname = "Start line";
423 cpname = "Finish line";
425 cpname = strcat("Intermediate ", ftos(cp));
427 cpname = "Finish line";
430 return strcat(col, cpname);
431 else if(hisname == "")
432 return strcat(col, cpname, " (", timestr, ")");
434 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
437 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
438 float race_CheckName(string net_name) {
440 for (i=RANKINGS_CNT-1;i>=0;--i)
441 if(grecordholder[i] == net_name)
453 void HUD_Panel_ExportCfg(string cfgname)
456 fh = fopen(strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg"), FILE_WRITE);
459 fputs(fh, strcat("seta hud_skin \"", autocvar_hud_skin, "\"", "\n"));
460 fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
461 fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
462 fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
463 fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
464 fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
465 fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
466 fputs(fh, strcat("seta hud_fg_alpha \"", cvar_string("hud_fg_alpha"), "\"", "\n"));
469 fputs(fh, strcat("seta hud_dock \"", autocvar_hud_dock, "\"", "\n"));
470 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
471 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
472 fputs(fh, strcat("seta hud_dock_alpha \"", ftos(autocvar_hud_dock_alpha), "\"", "\n"));
475 fputs(fh, strcat("seta hud_progressbar_alpha ", ftos(autocvar_hud_progressbar_alpha), "\n"));
476 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
477 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
478 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
479 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
480 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
481 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
484 // common cvars for all panels
486 for (i = 0; i < HUD_PANEL_NUM; ++i)
489 HUD_Panel_UpdateCvarsForId(i)
491 fputs(fh, strcat("seta hud_", panel_name, " ", ftos(cvar(strcat("hud_", panel_name))), "\n"));
492 fputs(fh, strcat("seta hud_", panel_name, "_pos \"", cvar_string(strcat("hud_", panel_name, "_pos")), "\"", "\n"));
493 fputs(fh, strcat("seta hud_", panel_name, "_size \"", cvar_string(strcat("hud_", panel_name, "_size")), "\"", "\n"));
494 fputs(fh, strcat("seta hud_", panel_name, "_bg \"", cvar_string(strcat("hud_", panel_name, "_bg")), "\"", "\n"));
495 fputs(fh, strcat("seta hud_", panel_name, "_bg_color \"", cvar_string(strcat("hud_", panel_name, "_bg_color")), "\"", "\n"));
496 fputs(fh, strcat("seta hud_", panel_name, "_bg_color_team \"", cvar_string(strcat("hud_", panel_name, "_bg_color_team")), "\"", "\n"));
497 fputs(fh, strcat("seta hud_", panel_name, "_bg_alpha \"", cvar_string(strcat("hud_", panel_name, "_bg_alpha")), "\"", "\n"));
498 fputs(fh, strcat("seta hud_", panel_name, "_bg_border \"", cvar_string(strcat("hud_", panel_name, "_bg_border")), "\"", "\n"));
499 fputs(fh, strcat("seta hud_", panel_name, "_bg_padding \"", cvar_string(strcat("hud_", panel_name, "_bg_padding")), "\"", "\n"));
501 case HUD_PANEL_WEAPONICONS:
502 fputs(fh, strcat("seta hud_", panel_name, "_accuracy_yellow ", ftos(cvar(strcat("hud_", panel_name, "_accuracy_yellow"))), "\n"));
504 case HUD_PANEL_INVENTORY:
505 fputs(fh, strcat("seta hud_", panel_name, "_onlycurrent ", ftos(cvar(strcat("hud_", panel_name, "_onlycurrent"))), "\n"));
506 fputs(fh, strcat("seta hud_", panel_name, "_iconalign ", ftos(cvar(strcat("hud_", panel_name, "_iconalign"))), "\n"));
508 case HUD_PANEL_POWERUPS:
509 fputs(fh, strcat("seta hud_", panel_name, "_flip ", ftos(cvar(strcat("hud_", panel_name, "_flip"))), "\n"));
510 fputs(fh, strcat("seta hud_", panel_name, "_iconalign ", ftos(cvar(strcat("hud_", panel_name, "_iconalign"))), "\n"));
511 fputs(fh, strcat("seta hud_", panel_name, "_baralign ", ftos(cvar(strcat("hud_", panel_name, "_baralign"))), "\n"));
513 case HUD_PANEL_HEALTHARMOR:
514 fputs(fh, strcat("seta hud_", panel_name, "_flip ", ftos(cvar(strcat("hud_", panel_name, "_flip"))), "\n"));
515 fputs(fh, strcat("seta hud_", panel_name, "_iconalign ", ftos(cvar(strcat("hud_", panel_name, "_iconalign"))), "\n"));
516 fputs(fh, strcat("seta hud_", panel_name, "_baralign ", ftos(cvar(strcat("hud_", panel_name, "_baralign"))), "\n"));
518 case HUD_PANEL_NOTIFY:
519 fputs(fh, strcat("seta hud_", panel_name, "_flip ", ftos(cvar(strcat("hud_", panel_name, "_flip"))), "\n"));
520 fputs(fh, strcat("seta hud_", panel_name, "_info_top ", ftos(cvar(strcat("hud_", panel_name, "_info_top"))), "\n"));
522 case HUD_PANEL_RADAR:
523 fputs(fh, strcat("seta hud_", panel_name, "_foreground_alpha ", ftos(cvar(strcat("hud_", panel_name, "_foreground_alpha"))), "\n"));
526 fputs(fh, strcat("seta hud_", panel_name, "_alreadyvoted_alpha ", ftos(cvar(strcat("hud_", panel_name, "_alreadyvoted_alpha"))), "\n"));
532 print("^2Successfully exported to hud_", autocvar_hud_skin, "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
537 // return smoothly faded size of given panel when a dialog is active
538 vector HUD_Panel_GetMenuSize(float id)
543 mySize = eX * mySize_x * vid_conwidth + eY * mySize_y * vid_conheight;
545 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
547 vector menu_enable_maxsize, menu_enable_size;
548 menu_enable_maxsize = '0 0 0'; // shut up FTEQCC
549 menu_enable_maxsize_x = 0.3 * vid_conwidth;
550 menu_enable_maxsize_y = 0.18 * vid_conheight;
551 if(mySize_x > mySize_y)
553 if(mySize_y > menu_enable_maxsize_y)
555 menu_enable_size_y = menu_enable_maxsize_y;
556 menu_enable_size_x = mySize_x * (menu_enable_maxsize_y/mySize_y);
557 mySize = (1 - autocvar__menu_alpha) * mySize + (autocvar__menu_alpha) * menu_enable_size;
562 if(mySize_x > menu_enable_maxsize_x)
564 menu_enable_size_x = menu_enable_maxsize_x;
565 menu_enable_size_y = mySize_y * (menu_enable_maxsize_x/mySize_x);
566 mySize = (1 - autocvar__menu_alpha) * mySize + (autocvar__menu_alpha) * menu_enable_size;
573 // return smoothly faded pos of given panel when a dialog is active
574 vector HUD_Panel_GetMenuPos(float id)
579 pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
581 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
583 vector mySize, menu_enable_panelpos;
584 mySize = HUD_Panel_GetMenuSize(id);
585 if(mySize_x > mySize_y)
586 menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * mySize_x + eY * 0.82 * vid_conheight;
588 menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * mySize_y + eX * 0.7 * vid_conwidth;
589 pos = (1 - autocvar__menu_alpha) * pos + (autocvar__menu_alpha) * menu_enable_panelpos;
594 // draw the background/borders
595 #define HUD_Panel_DrawBg(alpha)\
597 draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, strcat(hud_skin_path, "/", 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));\
598 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
599 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '1 1 0' * 2 * panel_bg_border, '1 1 1', .1 * (1 - autocvar__menu_alpha), DRAWFLAG_ADDITIVE);
601 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
607 pic = strcat(hud_skin_path, "/");
609 drawsubpic(pos, eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, strcat(pic, "statusbar_vertical"), '0 0 0', '1 0.25 0', color, alpha, drawflag);
610 if(mySize_y/mySize_x > 2)
611 drawsubpic(pos + eY * mySize_x, eY * (mySize_y - 2 * mySize_x) + eX * mySize_x, strcat(pic, "statusbar_vertical"), '0 0.25 0', '1 0.5 0', color, alpha, drawflag);
612 drawsubpic(pos + eY * mySize_y - eY * min(mySize_y * 0.5, mySize_x), eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, strcat(pic, "statusbar_vertical"), '0 0.75 0', '1 0.25 0', color, alpha, drawflag);
614 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, strcat(pic, "statusbar"), '0 0 0', '0.25 1 0', color, alpha, drawflag);
615 if(mySize_x/mySize_y > 2)
616 drawsubpic(pos + eX * mySize_y, eX * (mySize_x - 2 * mySize_y) + eY * mySize_y, strcat(pic, "statusbar"), '0.25 0 0', '0.5 1 0', color, alpha, drawflag);
617 drawsubpic(pos + eX * mySize_x - eX * min(mySize_x * 0.5, mySize_y), eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, strcat(pic, "statusbar"), '0.75 0 0', '0.25 1 0', color, alpha, drawflag);
621 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
622 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
633 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
634 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
636 for (i = 0; i < HUD_PANEL_NUM; ++i) {
637 if(i == highlightedPanel || !panel_enabled)
640 HUD_Panel_UpdatePosSizeForId(i)
642 panel_pos -= '1 1 0' * panel_bg_border;
643 panel_size += '2 2 0' * panel_bg_border;
645 if(myPos_y + mySize_y < panel_pos_y)
647 if(myPos_y > panel_pos_y + panel_size_y)
650 if(myPos_x + mySize_x < panel_pos_x)
652 if(myPos_x > panel_pos_x + panel_size_x)
655 // OK, there IS a collision.
657 myCenter_x = myPos_x + 0.5 * mySize_x;
658 myCenter_y = myPos_y + 0.5 * mySize_y;
660 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
661 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
663 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
665 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
666 myTarget_x = panel_pos_x - mySize_x;
667 else // push it upwards
668 myTarget_y = panel_pos_y - mySize_y;
670 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
672 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
673 myTarget_x = panel_pos_x + panel_size_x;
674 else // push it upwards
675 myTarget_y = panel_pos_y - mySize_y;
677 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
679 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
680 myTarget_x = panel_pos_x - mySize_x;
681 else // push it downwards
682 myTarget_y = panel_pos_y + panel_size_y;
684 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
686 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
687 myTarget_x = panel_pos_x + panel_size_x;
688 else // push it downwards
689 myTarget_y = panel_pos_y + panel_size_y;
691 if(cvar("hud_configure_checkcollisions_debug"))
692 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
698 void HUD_Panel_SetPos(vector pos)
700 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
704 if(cvar("hud_configure_checkcollisions_debug"))
705 drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
707 if(autocvar_hud_configure_grid)
709 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;
710 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;
713 if(hud_configure_checkcollisions)
714 pos = HUD_Panel_CheckMove(pos, mySize);
716 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
717 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
720 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
722 HUD_Panel_GetName(highlightedPanel);
723 cvar_set(strcat("hud_", panel_name, "_pos"), s);
726 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
727 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
737 ratio = mySize_x/mySize_y;
739 for (i = 0; i < HUD_PANEL_NUM; ++i) {
740 if(i == highlightedPanel || !panel_enabled)
743 HUD_Panel_UpdatePosSizeForId(i)
745 panel_pos -= '1 1 0' * panel_bg_border;
746 panel_size += '2 2 0' * panel_bg_border;
748 targEndPos = panel_pos + panel_size;
750 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
751 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
754 if (resizeCorner == 1)
756 // check if this panel is on our way
757 if (resizeorigin_x <= panel_pos_x)
759 if (resizeorigin_y <= panel_pos_y)
761 if (targEndPos_x <= resizeorigin_x - mySize_x)
763 if (targEndPos_y <= resizeorigin_y - mySize_y)
766 // there is a collision:
767 // detect which side of the panel we are facing is actually limiting the resizing
768 // (which side the resize direction finds for first) and reduce the size up to there
770 // dist is the distance between resizeorigin and the "analogous" point of the panel
771 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
772 dist_x = resizeorigin_x - targEndPos_x;
773 dist_y = resizeorigin_y - targEndPos_y;
774 if (dist_y <= 0 || dist_x / dist_y > ratio)
775 mySize_x = min(mySize_x, dist_x);
777 mySize_y = min(mySize_y, dist_y);
779 else if (resizeCorner == 2)
781 if (resizeorigin_x >= targEndPos_x)
783 if (resizeorigin_y <= panel_pos_y)
785 if (panel_pos_x >= resizeorigin_x + mySize_x)
787 if (targEndPos_y <= resizeorigin_y - mySize_y)
790 dist_x = panel_pos_x - resizeorigin_x;
791 dist_y = resizeorigin_y - targEndPos_y;
792 if (dist_y <= 0 || dist_x / dist_y > ratio)
793 mySize_x = min(mySize_x, dist_x);
795 mySize_y = min(mySize_y, dist_y);
797 else if (resizeCorner == 3)
799 if (resizeorigin_x <= panel_pos_x)
801 if (resizeorigin_y >= targEndPos_y)
803 if (targEndPos_x <= resizeorigin_x - mySize_x)
805 if (panel_pos_y >= resizeorigin_y + mySize_y)
808 dist_x = resizeorigin_x - targEndPos_x;
809 dist_y = panel_pos_y - resizeorigin_y;
810 if (dist_y <= 0 || dist_x / dist_y > ratio)
811 mySize_x = min(mySize_x, dist_x);
813 mySize_y = min(mySize_y, dist_y);
815 else if (resizeCorner == 4)
817 if (resizeorigin_x >= targEndPos_x)
819 if (resizeorigin_y >= targEndPos_y)
821 if (panel_pos_x >= resizeorigin_x + mySize_x)
823 if (panel_pos_y >= resizeorigin_y + mySize_y)
826 dist_x = panel_pos_x - resizeorigin_x;
827 dist_y = panel_pos_y - resizeorigin_y;
828 if (dist_y <= 0 || dist_x / dist_y > ratio)
829 mySize_x = min(mySize_x, dist_x);
831 mySize_y = min(mySize_y, dist_y);
833 if(cvar("hud_configure_checkcollisions_debug"))
834 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
840 void HUD_Panel_SetPosSize(vector mySize)
842 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
844 resizeorigin = panel_click_resizeorigin;
847 // minimum panel size cap
848 mySize_x = max(0.025 * vid_conwidth, mySize_x);
849 mySize_y = max(0.025 * vid_conheight, mySize_y);
851 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.
853 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
854 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
857 // collision testing|
858 // -----------------+
860 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
861 if(resizeCorner == 1) {
862 myPos_x = resizeorigin_x - mySize_x;
863 myPos_y = resizeorigin_y - mySize_y;
864 } else if(resizeCorner == 2) {
865 myPos_x = resizeorigin_x;
866 myPos_y = resizeorigin_y - mySize_y;
867 } else if(resizeCorner == 3) {
868 myPos_x = resizeorigin_x - mySize_x;
869 myPos_y = resizeorigin_y;
870 } else { // resizeCorner == 4
871 myPos_x = resizeorigin_x;
872 myPos_y = resizeorigin_y;
875 // left/top screen edges
877 mySize_x = mySize_x + myPos_x;
879 mySize_y = mySize_y + myPos_y;
881 // bottom/right screen edges
882 if(myPos_x + mySize_x > vid_conwidth)
883 mySize_x = vid_conwidth - myPos_x;
884 if(myPos_y + mySize_y > vid_conheight)
885 mySize_y = vid_conheight - myPos_y;
887 if(cvar("hud_configure_checkcollisions_debug"))
888 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
890 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
891 if(autocvar_hud_configure_grid)
893 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;
894 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;
897 if(hud_configure_checkcollisions)
898 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
900 // 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)
901 mySize_x = max(0.025 * vid_conwidth, mySize_x);
902 mySize_y = max(0.025 * vid_conheight, mySize_y);
904 // do another pos check, as size might have changed by now
905 if(resizeCorner == 1) {
906 myPos_x = resizeorigin_x - mySize_x;
907 myPos_y = resizeorigin_y - mySize_y;
908 } else if(resizeCorner == 2) {
909 myPos_x = resizeorigin_x;
910 myPos_y = resizeorigin_y - mySize_y;
911 } else if(resizeCorner == 3) {
912 myPos_x = resizeorigin_x - mySize_x;
913 myPos_y = resizeorigin_y;
914 } else { // resizeCorner == 4
915 myPos_x = resizeorigin_x;
916 myPos_y = resizeorigin_y;
919 if(cvar("hud_configure_checkcollisions_debug"))
920 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
922 HUD_Panel_GetName(highlightedPanel);
924 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
925 cvar_set(strcat("hud_", panel_name, "_size"), s);
927 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
928 cvar_set(strcat("hud_", panel_name, "_pos"), s);
932 float prevMouseClicked; // previous state
933 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
934 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
937 float menu_enabled_time;
938 float pressed_key_time;
939 void HUD_Panel_Arrow_Action(float nPrimary)
941 if (highlightedPanel_prev == -1 || mouseClicked)
944 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
947 if(autocvar_hud_configure_grid)
949 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
951 if (hudShiftState & S_SHIFT)
952 step = bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
954 step = 2 * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
958 if (hudShiftState & S_SHIFT)
959 step = bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
961 step = 2 * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
966 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
967 step = vid_conheight;
970 if (hudShiftState & S_SHIFT)
971 step = (step / 256); // more precision
973 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
976 highlightedPanel = highlightedPanel_prev;
978 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
980 if (hudShiftState & S_ALT) // resize
982 highlightedAction = 1;
983 if(nPrimary == K_UPARROW)
985 else if(nPrimary == K_RIGHTARROW)
987 else if(nPrimary == K_LEFTARROW)
989 else // if(nPrimary == K_DOWNARROW)
992 // ctrl+arrow reduces the size, instead of increasing it
993 // Note that ctrl disables collisions check too, but it's fine
994 // since we don't collide with anything reducing the size
995 if (hudShiftState & S_CTRL) {
997 resizeCorner = 5 - resizeCorner;
1001 mySize = panel_size;
1002 panel_click_resizeorigin = panel_pos;
1003 if(resizeCorner == 1) {
1004 panel_click_resizeorigin += mySize;
1006 } else if(resizeCorner == 2) {
1007 panel_click_resizeorigin_y += mySize_y;
1009 } else if(resizeCorner == 3) {
1010 panel_click_resizeorigin_x += mySize_x;
1012 } else { // resizeCorner == 4
1015 HUD_Panel_SetPosSize(mySize);
1019 highlightedAction = 2;
1022 if(nPrimary == K_UPARROW)
1024 else if(nPrimary == K_DOWNARROW)
1026 else if(nPrimary == K_LEFTARROW)
1028 else // if(nPrimary == K_RIGHTARROW)
1031 HUD_Panel_SetPos(pos);
1035 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1037 if(!autocvar__hud_configure)
1040 // allow console bind to work
1043 con_keys = findkeysforcommand("toggleconsole");
1044 keys = tokenize(con_keys);
1046 float hit_con_bind, i;
1047 for (i = 0; i < keys; ++i)
1049 if(nPrimary == stof(argv(i)))
1053 if(bInputType == 0) {
1054 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1055 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1056 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1058 else if(bInputType == 1) {
1059 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1060 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1061 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1064 if(nPrimary == K_MOUSE1)
1066 if(bInputType == 0) { // key pressed
1070 else if(bInputType == 1) {// key released
1075 else if(nPrimary == K_ESCAPE)
1077 if (bInputType == 1)
1079 disable_menu_alphacheck = 1;
1081 menu_enabled_time = time;
1082 localcmd("menu_showhudexit\n");
1084 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1086 if (bInputType == 1)
1088 pressed_key_time = 0;
1091 else if (pressed_key_time == 0)
1092 pressed_key_time = time;
1094 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1096 else if(hit_con_bind)
1099 return true; // Suppress ALL other input
1102 float HUD_Panel_HighlightCheck()
1108 for(i = 0; i < HUD_PANEL_NUM; ++i)
1110 HUD_Panel_UpdatePosSizeForId(i)
1112 panelPos = panel_pos;
1113 panelSize = panel_size;
1114 border = 10; // FORCED border so a small border size doesn't mean you can't resize
1117 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1121 // resize from topleft border
1122 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)
1126 // resize from topright border
1127 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)
1131 // resize from bottomleft border
1132 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)
1136 // resize from bottomright border
1137 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)
1145 void HUD_Panel_Highlight()
1151 for(i = 0; i < HUD_PANEL_NUM; ++i)
1153 HUD_Panel_UpdatePosSizeForId(i)
1155 panelPos = panel_pos;
1156 panelSize = panel_size;
1157 border = 10; // FORCED border so a small border size doesn't mean you can't resize
1160 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1162 highlightedPanel = i;
1163 highlightedAction = 1;
1164 panel_click_distance = mousepos - panelPos;
1167 // resize from topleft border
1168 else if(mousepos_x >= panelPos_x - border && mousepos_y >= panelPos_y - border && mousepos_x <= panelPos_x + 0.5 * panelSize_x && mousepos_y <= panelPos_y + 0.5 * panelSize_y)
1170 highlightedPanel = i;
1171 highlightedAction = 2;
1173 panel_click_distance = mousepos - panelPos;
1174 panel_click_resizeorigin = panelPos + panelSize;
1177 // resize from topright border
1178 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)
1180 highlightedPanel = i;
1181 highlightedAction = 2;
1183 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1184 panel_click_distance_y = mousepos_y - panelPos_y;
1185 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1188 // resize from bottomleft border
1189 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)
1191 highlightedPanel = i;
1192 highlightedAction = 2;
1194 panel_click_distance_x = mousepos_x - panelPos_x;
1195 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1196 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1199 // resize from bottomright border
1200 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)
1202 highlightedPanel = i;
1203 highlightedAction = 2;
1205 panel_click_distance = panelSize - mousepos + panelPos;
1206 panel_click_resizeorigin = panelPos;
1212 float highlightcheck;
1213 void HUD_Panel_Mouse()
1215 // 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
1216 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1217 disable_menu_alphacheck = 0;
1218 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1222 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1223 print("Highlighted: ", ftos(highlightedPanel), "\n");
1224 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1227 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1228 highlightedPanel_prev = highlightedPanel;
1229 highlightedPanel = -1;
1230 highlightedAction = 0;
1233 mousepos = mousepos + getmousepos();
1235 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1236 mousepos_y = bound(0, mousepos_y, vid_conheight);
1240 if(prevMouseClicked == 0)
1241 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1243 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1245 if(highlightedAction == 1)
1246 HUD_Panel_SetPos(mousepos - panel_click_distance);
1247 else if(highlightedAction == 2)
1250 if(resizeCorner == 1) {
1251 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1252 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1253 } else if(resizeCorner == 2) {
1254 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1255 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1256 } else if(resizeCorner == 3) {
1257 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1258 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1259 } else { // resizeCorner == 4
1260 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1261 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1263 HUD_Panel_SetPosSize(mySize);
1266 // doubleclick check
1267 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1269 mouseClicked = 0; // to prevent spam, I guess.
1270 disable_menu_alphacheck = 2;
1272 menu_enabled_time = time;
1273 HUD_Panel_GetName(highlightedPanel)
1274 localcmd("menu_showhudoptions ", panel_name, "\n");
1277 if(prevMouseClicked == 0)
1279 prevMouseClickedTime = time;
1280 prevMouseClickedPos = mousepos;
1285 highlightcheck = HUD_Panel_HighlightCheck();
1287 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1290 cursorsize = '32 32 0';
1292 if(highlightcheck == 0)
1293 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1294 else if(highlightcheck == 1)
1295 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1296 else if(highlightcheck == 2)
1297 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1299 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1301 prevMouseClicked = mouseClicked;
1304 // Weapon icons (#0)
1306 float weaponspace[10];
1307 #define HUD_WeaponIcons_Clear()\
1309 for(idx = 0; idx < 10; ++idx)\
1310 weaponspace[idx] = 0;
1312 entity weaponorder[WEP_MAXCOUNT];
1313 void weaponorder_swap(float i, float j, entity pass)
1317 weaponorder[i] = weaponorder[j];
1321 string weaponorder_cmp_str_save;
1322 string weaponorder_cmp_str;
1323 float weaponorder_cmp(float i, float j, entity pass)
1326 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1327 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1328 return aj - ai; // the string is in REVERSE order (higher prio at the right is what we want, but higher prio first is the string)
1331 void HUD_WeaponIcons(void)
1333 float id = HUD_PANEL_WEAPONICONS;
1334 HUD_Panel_UpdateCvarsForId(id);
1335 float alpha, stat_weapons; // "constants"
1337 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1340 mySize = panel_size;
1342 stat_weapons = getstati(STAT_WEAPONS);
1344 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1346 self = get_weaponinfo(i);
1347 if(self.impulse >= 0)
1351 // TODO make this configurable
1352 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1354 if(weaponorder_cmp_str != weaponorder_cmp_str_save)
1356 if(weaponorder_cmp_str_save)
1357 strunzone(weaponorder_cmp_str_save);
1358 weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
1360 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1362 self = get_weaponinfo(i);
1363 if(self.impulse >= 0)
1365 weaponorder[weapon_cnt] = self;
1369 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1372 HUD_Panel_DrawBg(1);
1373 if(panel_bg_padding)
1375 pos += '1 1 0' * panel_bg_padding;
1376 mySize -= '2 2 0' * panel_bg_padding;
1380 weapon_stats = getstati(STAT_DAMAGE_HITS);
1381 weapon_number = weapon_stats & 63;
1382 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1384 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1385 weapon_number = weapon_stats & 63;
1386 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1388 if(cvar_or("hud_weaponicons_fade", 1))
1390 fade = 3.2 - 2 * (time - weapontime);
1391 fade = bound(0.7, fade, 1);
1396 HUD_WeaponIcons_Clear();
1398 float rows, columns;
1399 rows = mySize_y/mySize_x;
1400 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1401 // ^^^ weapon icon aspect goes here
1403 columns = ceil(WEP_COUNT/rows);
1408 when = autocvar_hud_weaponicons_complainbubble_time;
1410 fadetime = autocvar_hud_weaponicons_complainbubble_fadetime;
1413 for(i = 0; i < weapon_cnt; ++i)
1415 self = weaponorder[i];
1416 weapid = self.impulse;
1418 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1420 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1421 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1423 // draw background behind currently selected weapon
1424 if(self.weapon == activeweapon)
1425 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);
1427 // draw the weapon accuracy on the HUD
1428 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1431 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1433 // yellow_accuracy = value at which accuracy becomes yellow
1434 if(weapon_stats >= 100) {
1438 else if(weapon_stats > autocvar_hud_weaponicons_accuracy_yellow) {
1439 color_x = 1 - (weapon_stats-autocvar_hud_weaponicons_accuracy_yellow)/(100-autocvar_hud_weaponicons_accuracy_yellow); // red value between 1 -> 0
1443 color_y = weapon_stats/autocvar_hud_weaponicons_accuracy_yellow; // green value between 0 -> 1
1447 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);
1450 // draw the weapon icon
1451 if((self.impulse >= 0) && (stat_weapons & self.weapons))
1453 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);
1455 if(cvar_or("hud_weaponicons_number", 1))
1456 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);
1458 // draw a "ghost weapon icon" if you don't have the weapon
1461 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);
1464 // draw the complain message
1465 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_weaponicons_complainbubble)
1469 if(complain_weapon_time + when > time)
1472 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1476 if(complain_weapon_time + when > time)
1482 vector complain_bubble_size = '100 50 0' * bound(0.25, autocvar_hud_weaponicons_complainbubble_size, 2);
1483 drawpic_aspect_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows) - complain_bubble_size + 0.5 * (eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows)), "weapon_complainbubble", complain_bubble_size, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
1486 if(complain_weapon_type == 0) {
1487 s = "Out of ammo for the";
1490 else if(complain_weapon_type == 1) {
1491 s = "You don't have the";
1495 s = "Map doesn't have the";
1498 drawstring_aspect(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows) - complain_bubble_size + eX * 0.05 * complain_bubble_size_x + eY * (1/6) * complain_bubble_size_y + 0.5 * (eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows)), s, eX * 0.9 * complain_bubble_size_x + eY * 0.2 * complain_bubble_size_y, 0.2 * complain_bubble_size_y, color, panel_fg_alpha * a, DRAWFLAG_NORMAL);
1499 drawstring_aspect(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows) - complain_bubble_size + eX * 0.05 * complain_bubble_size_x + eY * (11/30) * complain_bubble_size_y + 0.5 * (eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows)), complain_weapon_name, eX * 0.9 * complain_bubble_size_x + eY * 0.25 * complain_bubble_size_y, 0.25 * complain_bubble_size_y, '1 0 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
1515 float GetAmmoStat(float i)
1519 case 0: return STAT_SHELLS;
1520 case 1: return STAT_NAILS;
1521 case 2: return STAT_ROCKETS;
1522 case 3: return STAT_CELLS;
1523 case 4: return STAT_FUEL;
1528 float GetAmmoItemCode(float i)
1532 case 0: return IT_SHELLS;
1533 case 1: return IT_NAILS;
1534 case 2: return IT_ROCKETS;
1535 case 3: return IT_CELLS;
1536 case 4: return IT_FUEL;
1541 string GetAmmoPicture(float i)
1545 case 0: return "ammo_shells";
1546 case 1: return "ammo_bullets";
1547 case 2: return "ammo_rockets";
1548 case 3: return "ammo_cells";
1549 case 4: return "ammo_fuel";
1554 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1557 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1558 if(autocvar__hud_configure)
1568 if(currently_selected)
1573 vector newSize, newPos;
1574 if(mySize_x/mySize_y > 3)
1576 newSize_x = 3 * mySize_y;
1577 newSize_y = mySize_y;
1579 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1584 newSize_y = 1/3 * mySize_x;
1585 newSize_x = mySize_x;
1587 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1591 vector picpos, numpos;
1592 if(autocvar_hud_inventory_iconalign)
1595 picpos = newPos + eX * 2 * newSize_y;
1599 numpos = newPos + eX * newSize_y;
1603 if (currently_selected)
1604 drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1606 drawfont = hud_bigfont;
1607 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1608 drawfont = hud_font;
1609 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1612 void HUD_Inventory(void)
1614 float id = HUD_PANEL_INVENTORY;
1615 HUD_Panel_UpdateCvarsForId(id);
1616 float i, currently_selected;
1620 mySize = panel_size;
1622 HUD_Panel_DrawBg(1);
1623 if(panel_bg_padding)
1625 pos += '1 1 0' * panel_bg_padding;
1626 mySize -= '2 2 0' * panel_bg_padding;
1629 float rows, columns;
1630 rows = mySize_y/mySize_x;
1631 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1632 // ^^^ ammo item aspect goes here
1634 columns = ceil(AMMO_COUNT/rows);
1638 for (i = 0; i < AMMO_COUNT; ++i) {
1639 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1640 if(autocvar_hud_inventory_onlycurrent) {
1641 if(autocvar__hud_configure)
1643 if (currently_selected || autocvar__hud_configure)
1644 DrawAmmoItem(pos, mySize, i, currently_selected);
1647 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);
1652 column = column + 1;
1658 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color)
1660 vector newSize, newPos;
1661 if(mySize_x/mySize_y > 3)
1663 newSize_x = 3 * mySize_y;
1664 newSize_y = mySize_y;
1666 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1671 newSize_y = 1/3 * mySize_x;
1672 newSize_x = mySize_x;
1674 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1678 vector picpos, numpos;
1681 if(iconalign == 1 || iconalign == 3) // right align
1684 picpos = newPos + eX * 2 * newSize_y;
1688 numpos = newPos + eX * newSize_y;
1694 if(iconalign == 0 || iconalign == 3) // left align
1696 numpos = newPos + eX * newSize_y;
1702 picpos = newPos + eX * 2 * newSize_y;
1706 drawfont = hud_bigfont;
1707 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, newSize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1708 drawfont = hud_font;
1709 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1714 void HUD_Powerups(void) {
1715 float id = HUD_PANEL_POWERUPS;
1716 HUD_Panel_UpdateCvarsForId(id);
1718 stat_items = getstati(STAT_ITEMS);
1720 if(!autocvar__hud_configure)
1722 if not(stat_items & IT_STRENGTH)
1723 if not(stat_items & IT_INVINCIBLE)
1726 if (getstati(STAT_HEALTH) <= 0)
1732 mySize = panel_size;
1734 HUD_Panel_DrawBg(1);
1735 if(panel_bg_padding)
1737 pos += '1 1 0' * panel_bg_padding;
1738 mySize -= '2 2 0' * panel_bg_padding;
1741 float strength_time, shield_time;
1743 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1744 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1746 if(autocvar__hud_configure)
1752 vector barpos, barsize;
1756 string leftname, rightname;
1757 float leftcnt, rightcnt;
1758 float leftexact, rightexact;
1759 float leftalpha, rightalpha;
1760 if (autocvar_hud_powerups_flip) {
1761 leftname = "strength";
1762 leftcnt = ceil(strength_time);
1763 leftexact = strength_time;
1765 rightname = "shield";
1766 rightcnt = ceil(shield_time);
1767 rightexact = shield_time;
1769 leftname = "shield";
1770 leftcnt = ceil(shield_time);
1771 leftexact = shield_time;
1773 rightname = "strength";
1774 rightcnt = ceil(strength_time);
1775 rightexact = strength_time;
1777 leftalpha = bound(0, leftexact, 1);
1778 rightalpha = bound(0, rightexact, 1);
1780 drawfont = hud_bigfont;
1781 if (mySize_x/mySize_y > 4)
1785 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1786 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1787 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1788 } else { // left align
1790 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1793 HUD_Panel_GetProgressBarColor(leftname)
1794 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1795 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1');
1798 // 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));
1800 // drawpic_aspect_skin(picpos, leftname, eX * (1/6) * mySize_x + eY * mySize_y, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1805 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1806 barpos = pos + eX * 0.5 * mySize_x;
1807 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1808 } else { // right align
1809 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1810 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1813 HUD_Panel_GetProgressBarColor(rightname)
1814 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1815 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');
1818 else if (mySize_x/mySize_y > 1.5)
1822 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1823 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1824 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1825 } else { // left align
1827 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1830 HUD_Panel_GetProgressBarColor(leftname)
1831 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1832 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1');
1837 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1838 barpos = pos + eY * 0.5 * mySize_y;
1839 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1840 } else { // right align
1841 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1842 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1845 HUD_Panel_GetProgressBarColor(rightname)
1846 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1847 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');
1854 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // down align
1855 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1856 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1857 } else { // up align
1859 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1862 if(autocvar_hud_powerups_iconalign == 1 || autocvar_hud_powerups_iconalign == 3) { // down align
1863 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
1864 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
1865 } else { // up align
1866 picpos = pos + eX * 0.05 * mySize_x;
1867 numpos = pos + eY * 0.4 * mySize_x;
1870 HUD_Panel_GetProgressBarColor(leftname)
1871 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1873 //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));
1875 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1876 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);
1881 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // up align
1882 barpos = pos + eX * 0.5 * mySize_x;
1883 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1884 } else { // down align
1885 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1886 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1889 if(autocvar_hud_powerups_iconalign == 0 || autocvar_hud_powerups_iconalign == 3) { // up align
1890 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1891 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1892 } else { // down align
1893 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
1894 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
1897 HUD_Panel_GetProgressBarColor(rightname)
1898 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1900 // 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));
1902 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1903 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);
1906 drawfont = hud_font;
1909 // Health/armor (#3)
1911 void HUD_HealthArmor(void)
1913 float id = HUD_PANEL_HEALTHARMOR;
1914 HUD_Panel_UpdateCvarsForId(id);
1917 mySize = panel_size;
1919 HUD_Panel_DrawBg(1);
1920 if(panel_bg_padding)
1922 pos += '1 1 0' * panel_bg_padding;
1923 mySize -= '2 2 0' * panel_bg_padding;
1926 float armor, health;
1927 armor = getstati(STAT_ARMOR);
1928 health = getstati(STAT_HEALTH);
1931 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
1933 if(autocvar__hud_configure)
1943 vector barpos, barsize;
1947 drawfont = hud_bigfont;
1948 if(autocvar_hud_healtharmor == 2) // combined health and armor display
1951 v = healtharmor_maxdamage(health, armor, armorblockpercent);
1956 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
1957 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
1958 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
1959 } else { // left align
1961 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
1965 if(v_z) // NOT fully armored
1967 biggercount = "health";
1968 HUD_Panel_GetProgressBarColor("health")
1969 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1971 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);
1975 biggercount = "armor";
1976 HUD_Panel_GetProgressBarColor("armor")
1977 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1979 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);
1981 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200));
1986 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
1987 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
1988 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
1991 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
1993 HUD_Panel_GetProgressBarColor("fuel")
1994 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
1999 string leftname, rightname;
2000 float leftcnt, rightcnt;
2001 float leftactive, rightactive;
2002 float leftalpha, rightalpha;
2003 if (autocvar_hud_healtharmor_flip) { // old style layout with armor left/top of health
2008 leftalpha = min((armor+10)/55, 1);
2010 rightname = "health";
2015 leftname = "health";
2020 rightname = "armor";
2024 rightalpha = min((armor+10)/55, 1);
2027 if (mySize_x/mySize_y > 4)
2031 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2032 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2033 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2034 } else { // left align
2036 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2039 HUD_Panel_GetProgressBarColor(leftname)
2040 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2041 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2046 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2047 barpos = pos + eX * 0.5 * mySize_x;
2048 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2049 } else { // right align
2050 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2051 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2054 HUD_Panel_GetProgressBarColor(rightname)
2055 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2056 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));
2061 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2062 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2063 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2066 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2068 HUD_Panel_GetProgressBarColor("fuel")
2069 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2072 else if (mySize_x/mySize_y > 1.5)
2076 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2077 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2078 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2079 } else { // left align
2081 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2084 HUD_Panel_GetProgressBarColor(leftname)
2085 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2086 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2091 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2092 barpos = pos + eY * 0.5 * mySize_y;
2093 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2094 } else { // right align
2095 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2096 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2099 HUD_Panel_GetProgressBarColor(rightname)
2100 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2101 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));
2106 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2107 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2108 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2111 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2113 HUD_Panel_GetProgressBarColor("fuel")
2114 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2121 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // down align
2122 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2123 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2124 } else { // up align
2126 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2129 if(autocvar_hud_healtharmor_iconalign == 1 || autocvar_hud_healtharmor_iconalign == 3) { // down align
2130 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2131 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2132 } else { // up align
2133 picpos = pos + eX * 0.05 * mySize_x;
2134 numpos = pos + eY * 0.4 * mySize_x;
2137 HUD_Panel_GetProgressBarColor(leftname)
2138 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2139 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2140 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);
2145 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // up align
2146 barpos = pos + eX * 0.5 * mySize_x;
2147 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2148 } else { // down align
2149 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2150 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2153 if(autocvar_hud_healtharmor_iconalign == 0 || autocvar_hud_healtharmor_iconalign == 3) { // up align
2154 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2155 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2156 } else { // down align
2157 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2158 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2161 HUD_Panel_GetProgressBarColor(rightname)
2162 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2163 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2164 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);
2169 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2171 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2173 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2174 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2176 HUD_Panel_GetProgressBarColor("fuel")
2177 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2181 drawfont = hud_font;
2185 // Notification area (#4)
2188 string Weapon_SuicideMessage(float deathtype)
2190 w_deathtype = deathtype;
2191 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2192 return w_deathtypestring;
2195 string Weapon_KillMessage(float deathtype)
2197 w_deathtype = deathtype;
2198 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2199 return w_deathtypestring;
2202 float killnotify_times[10];
2203 float killnotify_deathtype[10];
2204 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2205 string killnotify_attackers[10];
2206 string killnotify_victims[10];
2207 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2210 for (i = 9; i > 0; --i) {
2211 killnotify_times[i] = killnotify_times[i-1];
2212 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2213 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2214 if(killnotify_attackers[i])
2215 strunzone(killnotify_attackers[i]);
2216 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2217 if(killnotify_victims[i])
2218 strunzone(killnotify_victims[i]);
2219 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2221 killnotify_times[0] = time;
2222 killnotify_deathtype[0] = wpn;
2223 killnotify_actiontype[0] = actiontype;
2224 if(killnotify_attackers[0])
2225 strunzone(killnotify_attackers[0]);
2226 killnotify_attackers[0] = strzone(attacker);
2227 if(killnotify_victims[0])
2228 strunzone(killnotify_victims[0]);
2229 killnotify_victims[0] = strzone(victim);
2232 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2236 alsoprint = (autocvar_hud_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2238 if(msg == MSG_SUICIDE) {
2240 w = DEATH_WEAPONOF(type);
2242 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2244 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2245 } else if (type == DEATH_KILL) {
2246 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2248 print ("^1",s1, "^1 couldn't take it anymore\n");
2249 } else if (type == DEATH_ROT) {
2250 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2252 print ("^1",s1, "^1 died\n");
2253 } else if (type == DEATH_NOAMMO) {
2254 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2256 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2257 } else if (type == DEATH_CAMP) {
2258 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2260 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2261 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2262 HUD_KillNotify_Push(s1, "", 0, type);
2264 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2265 } else if (type == DEATH_CHEAT) {
2266 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2268 print ("^1",s1, "^1 unfairly eliminated themself\n");
2269 } else if (type == DEATH_FIRE) {
2270 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2272 print ("^1",s1, "^1 burned to death\n");
2273 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2274 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2276 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2279 if (stof(s2) > 2) // killcount > 2
2280 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2281 } else if(msg == MSG_KILL) {
2282 w = DEATH_WEAPONOF(type);
2284 HUD_KillNotify_Push(s2, s1, 1, w);
2286 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2288 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2289 HUD_KillNotify_Push(s1, s2, 1, type);
2292 if(cvar("cl_gentle")) {
2293 print ("^1", s1, "^1 took action against a team mate\n");
2295 print ("^1", s1, "^1 mows down a team mate\n");
2298 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2299 if(cvar("cl_gentle"))
2300 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2302 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2304 else if (stof(s2) > 2) {
2305 if(cvar("cl_gentle"))
2306 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2308 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2311 else if(type == KILL_FIRST_BLOOD)
2312 print("^1",s1, "^1 drew first blood", "\n");
2314 else if (type == DEATH_TELEFRAG)
2315 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2316 else if (type == DEATH_DROWN) {
2317 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2319 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2321 else if (type == DEATH_SLIME) {
2322 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2324 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2326 else if (type == DEATH_LAVA) {
2327 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2329 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2331 else if (type == DEATH_FALL) {
2332 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2334 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2336 else if (type == DEATH_SHOOTING_STAR) {
2337 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2339 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2341 else if (type == DEATH_SWAMP) {
2342 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2344 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2346 else if (type == DEATH_HURTTRIGGER)
2348 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2350 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2351 } else if(type == DEATH_SBCRUSH) {
2352 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2354 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2355 } else if(type == DEATH_SBMINIGUN) {
2356 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2358 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2359 } else if(type == DEATH_SBROCKET) {
2360 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2362 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2363 } else if(type == DEATH_SBBLOWUP) {
2364 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2366 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2367 } else if(type == DEATH_WAKIGUN) {
2368 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2370 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2371 } else if(type == DEATH_WAKIROCKET) {
2372 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2374 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2375 } else if(type == DEATH_WAKIBLOWUP) {
2376 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2378 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2379 } else if(type == DEATH_TURRET) {
2380 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2382 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2383 } else if(type == DEATH_TOUCHEXPLODE) {
2384 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2386 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2387 } else if(type == DEATH_CHEAT) {
2388 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2390 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2391 } else if (type == DEATH_FIRE) {
2392 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2394 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2395 } else if (type == DEATH_CUSTOM) {
2396 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2398 print ("^1",s1, "^1 ", s2, "\n");
2400 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2402 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2404 } else if(msg == MSG_SPREE) {
2405 if(type == KILL_END_SPREE) {
2406 if(cvar("cl_gentle"))
2407 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2409 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2410 } else if(type == KILL_SPREE) {
2411 if(cvar("cl_gentle"))
2412 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2414 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2415 } else if(type == KILL_SPREE_3) {
2416 if(cvar("cl_gentle"))
2417 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2419 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2420 } else if(type == KILL_SPREE_5) {
2421 if(cvar("cl_gentle"))
2422 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2424 print (s1,"^7 unleashes ^1RAGE\n");
2425 } else if(type == KILL_SPREE_10) {
2426 if(cvar("cl_gentle"))
2427 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2429 print (s1,"^7 starts the ^1MASSACRE!\n");
2430 } else if(type == KILL_SPREE_15) {
2431 if(cvar("cl_gentle"))
2432 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2434 print (s1,"^7 executes ^1MAYHEM!\n");
2435 } else if(type == KILL_SPREE_20) {
2436 if(cvar("cl_gentle"))
2437 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2439 print (s1,"^7 is a ^1BERSERKER!\n");
2440 } else if(type == KILL_SPREE_25) {
2441 if(cvar("cl_gentle"))
2442 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2444 print (s1,"^7 inflicts ^1CARNAGE!\n");
2445 } else if(type == KILL_SPREE_30) {
2446 if(cvar("cl_gentle"))
2447 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2449 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2451 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2452 if (type == DEATH_DROWN) {
2453 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2456 if(cvar("cl_gentle"))
2457 print ("^1",s1, "^1 was in the water for too long\n");
2459 print ("^1",s1, "^1 drowned\n");
2461 } else if (type == DEATH_SLIME) {
2462 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2464 print ("^1",s1, "^1 was slimed\n");
2465 } else if (type == DEATH_LAVA) {
2466 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2469 if(cvar("cl_gentle"))
2470 print ("^1",s1, "^1 found a hot place\n");
2472 print ("^1",s1, "^1 turned into hot slag\n");
2474 } else if (type == DEATH_FALL) {
2475 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2478 if(cvar("cl_gentle"))
2479 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2481 print ("^1",s1, "^1 hit the ground with a crunch\n");
2483 } else if (type == DEATH_SHOOTING_STAR) {
2484 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2486 print ("^1",s1, "^1 became a shooting star\n");
2487 } else if (type == DEATH_SWAMP) {
2488 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2491 if(cvar("cl_gentle"))
2492 print ("^1",s1, "^1 discovered a swamp\n");
2494 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2496 } else if(type == DEATH_TURRET) {
2497 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2499 print ("^1",s1, "^1 was mowed down by a turret \n");
2500 } else if (type == DEATH_CUSTOM) {
2501 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2503 print ("^1",s1, "^1 ", s2, "\n");
2504 } else if (type == DEATH_HURTTRIGGER) {
2505 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2507 print ("^1",s1, "^1 was in the wrong place\n");
2508 } else if(type == DEATH_TOUCHEXPLODE) {
2509 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2511 print ("^1",s1, "^1 died in an accident\n");
2512 } else if(type == DEATH_CHEAT) {
2513 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2515 print ("^1",s1, "^1 was unfairly eliminated\n");
2516 } else if(type == DEATH_FIRE) {
2517 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2520 if(cvar("cl_gentle"))
2521 print ("^1",s1, "^1 felt a little hot\n");
2523 print ("^1",s1, "^1 burnt to death\n");
2526 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2529 if(cvar("cl_gentle"))
2530 print ("^1",s1, "^1 needs a restart\n");
2532 print ("^1",s1, "^1 died\n");
2535 } else if(msg == MSG_KILL_ACTION_SPREE) {
2536 if(cvar("cl_gentle"))
2537 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2539 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2540 } else if(msg == MSG_INFO) {
2541 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2542 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2543 print(s1, "^7 got the ", s2, "\n");
2544 } else if(type == INFO_LOSTFLAG) {
2545 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2546 print(s1, "^7 lost the ", s2, "\n");
2547 } else if(type == INFO_PICKUPFLAG) {
2548 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2549 print(s1, "^7 picked up the ", s2, "\n");
2550 } else if(type == INFO_RETURNFLAG) {
2551 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2552 print(s1, "^7 returned the ", s2, "\n");
2557 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2559 void HUD_Centerprint(string s1, string s2, float type, float msg)
2561 if(msg == MSG_SUICIDE) {
2562 if (type == DEATH_TEAMCHANGE) {
2563 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2564 } else if (type == DEATH_AUTOTEAMCHANGE) {
2565 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2566 } else if (type == DEATH_CAMP) {
2567 if(cvar("cl_gentle"))
2568 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2570 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2571 } else if (type == DEATH_NOAMMO) {
2572 if(cvar("cl_gentle"))
2573 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2575 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2576 } else if (type == DEATH_ROT) {
2577 if(cvar("cl_gentle"))
2578 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2580 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2581 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2582 if(cvar("cl_gentle"))
2583 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2585 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2586 } else if (type == DEATH_QUIET) {
2588 } else if (type == DEATH_KILL) {
2589 if(cvar("cl_gentle"))
2590 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2592 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2594 } else if(msg == MSG_KILL) {
2595 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2596 if(cvar("cl_gentle")) {
2597 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2599 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2601 } else if (type == KILL_FIRST_BLOOD) {
2602 if(cvar("cl_gentle")) {
2603 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2605 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2607 } else if (type == KILL_FIRST_VICTIM) {
2608 if(cvar("cl_gentle")) {
2609 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2611 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2613 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2614 if(cvar("cl_gentle")) {
2615 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2617 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2619 } else if (type == KILL_TYPEFRAGGED) {
2620 if(cvar("cl_gentle")) {
2621 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2623 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2625 } else if (type == KILL_FRAG) {
2626 if(cvar("cl_gentle")) {
2627 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2629 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2631 } else if (type == KILL_FRAGGED) {
2632 if(cvar("cl_gentle")) {
2633 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2635 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2638 } else if(msg == MSG_KILL_ACTION) {
2639 // TODO: invent more centerprints here?
2640 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2644 void HUD_Notify (void)
2646 float id = HUD_PANEL_NOTIFY;
2647 HUD_Panel_UpdateCvarsForId(id);
2650 mySize = panel_size;
2652 HUD_Panel_DrawBg(1);
2653 if(panel_bg_padding)
2655 pos += '1 1 0' * panel_bg_padding;
2656 mySize -= '2 2 0' * panel_bg_padding;
2659 float entries, height;
2660 entries = bound(1, floor(14 * mySize_y/mySize_x), 12);
2661 height = mySize_y/entries;
2662 entries -= 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2665 fontsize = '0.5 0.5 0' * height;
2669 when = autocvar_hud_notify_time;
2671 fadetime = autocvar_hud_notify_fadetime;
2675 vector pos_attacker, pos_victim;
2677 float width_attacker, width_victim;
2678 string attacker, victim;
2681 for(j = 0; j < entries; ++j)
2683 if(autocvar_hud_notify_flip)
2685 else // rather nasty hack for ordering items from the bottom up
2686 i = entries - j - 1;
2687 if(autocvar_hud_notify_info_top)
2688 i += 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2692 if(killnotify_times[j] + when > time)
2695 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2699 if(killnotify_times[j] + when > time)
2705 // TODO: maybe print in team colors?
2706 // TODO: maybe this could be cleaned up somehow...
2707 // TODO: less copypaste code below
2710 if(killnotify_actiontype[j] == 0 && !autocvar__hud_configure)
2712 attacker = textShortenToWidth(killnotify_attackers[j], mySize_x - 2 * height, fontsize, stringwidth_colors);
2714 width_attacker = stringwidth(attacker, TRUE, fontsize);
2715 pos_attacker = pos + eX * 0.5 * (mySize_x - width_attacker + 2 * height) + eY * 0.5 * fontsize_y + eY * i * height;
2717 weap_pos = pos + eX * 0.5 * (mySize_x - width_attacker) - eX * height + eY * i * height;
2718 if(killnotify_deathtype[j] == DEATH_GENERIC)
2720 drawpic_aspect_skin(weap_pos, "notify_death", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2721 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2723 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2725 drawpic_aspect_skin(weap_pos, "notify_outofammo", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2726 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2728 else if(killnotify_deathtype[j] == DEATH_KILL)
2730 drawpic_aspect_skin(weap_pos, "notify_selfkill", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2731 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2733 else if(killnotify_deathtype[j] == DEATH_CAMP)
2735 drawpic_aspect_skin(weap_pos, "notify_camping", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2736 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2738 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2740 drawpic_aspect_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2741 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2743 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2745 drawpic_aspect_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2746 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2748 else if(killnotify_deathtype[j] == DEATH_DROWN)
2750 drawpic_aspect_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2751 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2753 else if(killnotify_deathtype[j] == DEATH_SLIME)
2755 drawpic_aspect_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2756 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2758 else if(killnotify_deathtype[j] == DEATH_LAVA)
2760 drawpic_aspect_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2761 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2763 else if(killnotify_deathtype[j] == DEATH_FALL)
2765 drawpic_aspect_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2766 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2768 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2770 drawpic_aspect_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2771 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2773 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2775 drawpic_aspect_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2776 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2778 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2780 if(killnotify_victims[j] == "^1RED^7 flag")
2784 drawpic_aspect_skin(weap_pos, strcat("flag_", s, "_carrying"), '1 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2785 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2787 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2789 if(killnotify_victims[j] == "^1RED^7 flag")
2793 drawpic_aspect_skin(weap_pos, strcat("flag_", s, "_taken"), '1 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2794 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2796 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2798 if(killnotify_victims[j] == "^1RED^7 flag")
2802 drawpic_aspect_skin(weap_pos, strcat("flag_", s, "_lost"), '1 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2803 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2806 // X [did action to] Y
2809 if(autocvar__hud_configure)
2811 attacker = textShortenToWidth("Player1", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2812 victim = textShortenToWidth("Player2", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2813 a = bound(0, (when - j) / 4, 1);
2817 attacker = textShortenToWidth(killnotify_attackers[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2818 victim = textShortenToWidth(killnotify_victims[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2820 width_attacker = stringwidth(attacker, TRUE, fontsize);
2821 width_victim = stringwidth(victim, TRUE, fontsize);
2822 pos_attacker = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_attacker) + eY * 0.5 * fontsize_y + eY * i * height;
2823 pos_victim = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_victim) + eY * 0.5 * fontsize_y + eX * 0.5 * mySize_x + eX * height + eY * i * height;
2824 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2826 if(autocvar__hud_configure) // example actions for config mode
2828 drawpic_aspect_skin(weap_pos, strcat("weapon", "electro"), '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2829 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2830 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2832 else if(WEP_VALID(killnotify_deathtype[j]))
2834 self = get_weaponinfo(killnotify_deathtype[j]);
2835 drawpic_aspect_skin(weap_pos, strcat("weapon", self.netname), '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2836 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2837 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2839 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2841 drawpic_aspect_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2842 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2843 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2845 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2847 drawpic_aspect_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2848 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2849 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2851 else if(killnotify_deathtype[j] == DEATH_DROWN)
2853 drawpic_aspect_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2854 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2855 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2857 else if(killnotify_deathtype[j] == DEATH_SLIME)
2859 drawpic_aspect_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2860 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2861 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2863 else if(killnotify_deathtype[j] == DEATH_LAVA)
2865 drawpic_aspect_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2866 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2867 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2869 else if(killnotify_deathtype[j] == DEATH_FALL)
2871 drawpic_aspect_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2872 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2873 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2875 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2877 drawpic_aspect_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2878 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2879 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2881 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2883 drawpic_aspect_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2884 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2885 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2891 // TODO: separate panel for these?
2897 if(autocvar_hud_notify_info_top)
2900 o = pos + eY * mySize_y - eY * 2 * height;
2902 if(spectatee_status && !intermission)
2904 //drawfont = hud_bigfont;
2905 if(spectatee_status == -1)
2908 s = GetPlayerName(spectatee_status - 1);
2910 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
2911 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, panel_fg_alpha, DRAWFLAG_NORMAL);
2912 //drawfont = hud_font;
2914 // spectator text in the upper right corner
2915 if(spectatee_status == -1)
2916 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
2918 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
2919 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2920 o += eY * fontsize_y;
2922 if(spectatee_status == -1)
2923 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
2925 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
2926 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2927 o += eY * fontsize_y;
2929 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
2930 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2931 o += eY * fontsize_y;
2933 if(gametype == GAME_ARENA)
2934 s = "^1Wait for your turn to join";
2935 else if(gametype == GAME_LMS)
2938 sk = playerslots[player_localentnum - 1];
2939 if(sk.(scores[ps_primary]) >= 666)
2940 s = "^1Match has already begun";
2941 else if(sk.(scores[ps_primary]) > 0)
2942 s = "^1You have no more lives left";
2944 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
2947 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
2948 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2949 o += eY * fontsize_y;
2951 //show restart countdown:
2952 if (time < getstatf(STAT_GAMESTARTTIME)) {
2954 //we need to ceil, otherwise the countdown would be off by .5 when using round()
2955 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
2956 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
2957 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2958 o += eY * fontsize_y;
2961 if(warmup_stage && !intermission)
2963 s = "^2Currently in ^1warmup^2 stage!";
2964 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2965 o += eY * fontsize_y;
2969 if(mod(time, 1) >= 0.5)
2974 if(ready_waiting && !intermission && !spectatee_status)
2976 if(ready_waiting_for_me)
2979 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
2981 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
2986 s = strcat("^2Waiting for others to ready up to end warmup...");
2988 s = strcat("^2Waiting for others to ready up...");
2990 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2991 o += eY * fontsize_y;
2993 else if(warmup_stage && !intermission && !spectatee_status)
2995 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
2996 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2997 o += eY * fontsize_y;
3000 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
3002 float ts_min, ts_max;
3003 tm = teams.sort_next;
3006 for(; tm.sort_next; tm = tm.sort_next)
3008 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
3010 if(!ts_min) ts_min = tm.team_size;
3011 else ts_min = min(ts_min, tm.team_size);
3012 if(!ts_max) ts_max = tm.team_size;
3013 else ts_max = max(ts_max, tm.team_size);
3015 if ((ts_max - ts_min) > 1)
3017 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
3018 tm = GetTeam(myteam, false);
3020 if (tm.team != COLOR_SPECTATOR)
3021 if (tm.team_size == ts_max)
3022 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
3024 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3025 o += eY * fontsize_y;
3029 if(autocvar__hud_configure)
3031 s = "^7Press ^3ESC ^7to show HUD options.";
3032 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3033 o += eY * fontsize_y;
3034 s = "^3Doubleclick a panel for panel-specific options.";
3035 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3036 o += eY * fontsize_y;
3042 string seconds_tostring(float sec)
3045 minutes = floor(sec / 60);
3047 sec -= minutes * 60;
3050 s = ftos(100 + sec);
3052 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3055 void HUD_Timer(void)
3057 float id = HUD_PANEL_TIMER;
3058 HUD_Panel_UpdateCvarsForId(id);
3061 mySize = panel_size;
3063 HUD_Panel_DrawBg(1);
3064 if(panel_bg_padding)
3066 pos += '1 1 0' * panel_bg_padding;
3067 mySize -= '2 2 0' * panel_bg_padding;
3071 float timelimit, elapsedTime, timeleft, minutesLeft;
3073 timelimit = getstatf(STAT_TIMELIMIT);
3075 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3076 timeleft = ceil(timeleft);
3078 minutesLeft = floor(timeleft / 60);
3081 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3082 timer_color = '1 1 1'; //white
3083 else if(minutesLeft >= 1)
3084 timer_color = '1 1 0'; //yellow
3086 timer_color = '1 0 0'; //red
3088 if (autocvar_hud_timer_increment || timelimit == 0 || warmup_stage) {
3089 if (time < getstatf(STAT_GAMESTARTTIME)) {
3090 //while restart is still active, show 00:00
3091 timer = seconds_tostring(0);
3093 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3094 timer = seconds_tostring(elapsedTime);
3097 timer = seconds_tostring(timeleft);
3100 drawfont = hud_bigfont;
3101 drawstring_aspect(pos, timer, mySize, mySize_y, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3102 drawfont = hud_font;
3107 void HUD_Radar(void)
3109 float id = HUD_PANEL_RADAR;
3110 HUD_Panel_UpdateCvarsForId(id);
3113 mySize = panel_size;
3115 HUD_Panel_DrawBg(1);
3116 if(panel_bg_padding)
3118 pos += '1 1 0' * panel_bg_padding;
3119 mySize -= '2 2 0' * panel_bg_padding;
3122 local float color1, color2; // color already declared as a global in hud.qc
3125 float scale2d, normalsize, bigsize;
3128 teamradar_origin2d = pos + 0.5 * mySize;
3129 teamradar_size2d = mySize;
3131 if(minimapname == "")
3134 teamradar_loadcvars();
3136 switch(hud_radar_zoommode)
3140 f = current_zoomfraction;
3143 f = 1 - current_zoomfraction;
3153 switch(hud_radar_rotation)
3156 teamradar_angle = view_angles_y - 90;
3159 teamradar_angle = 90 * hud_radar_rotation;
3163 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3164 teamradar_size2d = mySize;
3166 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3168 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3169 if(hud_radar_rotation == 0)
3171 // max-min distance must fit the radar in any rotation
3172 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3176 vector c0, c1, c2, c3, span;
3177 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3178 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3179 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3180 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3182 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3183 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3185 // max-min distance must fit the radar in x=x, y=y
3187 teamradar_size2d_x * scale2d / (1.05 * span_x),
3188 teamradar_size2d_y * scale2d / (1.05 * span_y)
3192 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3193 if(bigsize > normalsize)
3194 normalsize = bigsize;
3198 + (1 - f) * normalsize;
3199 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3200 f * (mi_min + mi_max) * 0.5
3201 + (1 - f) * view_origin);
3203 color1 = GetPlayerColor(player_localentnum-1);
3204 rgb = GetTeamRGB(color1);
3213 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3215 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3216 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3217 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3218 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3219 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3221 color2 = GetPlayerColor(tm.sv_entnum);
3222 //if(color == COLOR_SPECTATOR || color == color2)
3223 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3225 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3227 drawresetcliparea();
3232 void HUD_Score(void)
3234 float id = HUD_PANEL_SCORE;
3235 HUD_Panel_UpdateCvarsForId(id);
3238 mySize = panel_size;
3240 HUD_Panel_DrawBg(1);
3241 if(panel_bg_padding)
3243 pos += '1 1 0' * panel_bg_padding;
3244 mySize -= '2 2 0' * panel_bg_padding;
3247 float score, distribution, leader;
3249 vector distribution_color;
3251 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3253 // TODO... this (race part) still uses constant coordinates :/
3254 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3255 /*pl = players.sort_next;
3258 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3259 if(pl.scores[ps_primary] == 0)
3262 score = me.(scores[ps_primary]);
3264 float racemin, racesec, racemsec;
3265 float distsec, distmsec, minusplus;
3267 racemin = floor(score/(60 * TIME_FACTOR));
3268 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
3269 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
3271 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3272 // distribution display
3273 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3275 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
3276 distmsec = fabs(distribution);
3278 distsec = floor(fabs(distribution)/TIME_FACTOR);
3279 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
3280 if (distribution < 0)
3284 if (distribution <= 0) {
3285 distribution_color = eY;
3286 minusplus = 1; // minusplus 1: always prefix with minus sign
3289 distribution_color = eX;
3290 minusplus = 2; // minusplus 1: always prefix with plus sign
3292 //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);
3293 //HUD_DrawXNum(bottomright - '68 48 0' - '16 0 0' * TIME_DECIMALS, distsec, 4, minusplus, 16, distribution_color, 0, 0, panel_fg_alpha, DRAWFLAG_NORMAL);
3294 drawpic_aspect_skin(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "num_dot", '16 16 0', distribution_color, panel_fg_alpha, DRAWFLAG_ADDITIVE);
3296 // race record display
3297 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
3298 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);
3300 //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);
3301 //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);
3302 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);
3304 //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);
3305 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);
3307 } else if (!teamplay) { // non-teamgames
3308 // me vector := [team/connected frags id]
3309 pl = players.sort_next;
3313 if(autocvar__hud_configure)
3316 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3320 score = me.(scores[ps_primary]);
3321 if(autocvar__hud_configure)
3324 if(distribution >= 5) {
3325 distribution_color = eY;
3327 } else if(distribution >= 0) {
3328 distribution_color = '1 1 1';
3330 } else if(distribution >= -5)
3331 distribution_color = '1 1 0';
3333 distribution_color = eX;
3335 score_len = strlen(ftos(score));
3337 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);
3339 drawpic_aspect_skin(pos, strcat("num_leading_", ftos(score_len)), eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3340 drawfont = hud_bigfont;
3341 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3342 drawfont = hud_font;
3343 } else { // teamgames
3344 float max_fragcount;
3345 max_fragcount = -99;
3348 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3349 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !autocvar__hud_configure)) // no players? don't display
3351 score = tm.(teamscores[ts_primary]);
3352 if(autocvar__hud_configure)
3356 score_len = strlen(ftos(score));
3358 if (score > max_fragcount)
3359 max_fragcount = score;
3361 if(tm.team == myteam) {
3362 if (max_fragcount == score)
3365 drawpic_aspect_skin(pos, strcat("num_leading_", ftos(score_len)), eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3366 drawfont = hud_bigfont;
3367 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);
3368 drawfont = hud_font;
3370 if (max_fragcount == score)
3373 drawpic_aspect_skin(pos + eX * 0.75 * mySize_x + eY * (1/3) * teamnum * mySize_y, strcat("num_leading_", ftos(score_len)), eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3374 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);
3383 void HUD_RaceTimer (void) {
3384 float id = HUD_PANEL_RACETIMER;
3385 HUD_Panel_UpdateCvarsForId(id);
3388 mySize = panel_size;
3390 HUD_Panel_DrawBg(1);
3391 if(panel_bg_padding)
3393 pos += '1 1 0' * panel_bg_padding;
3394 mySize -= '2 2 0' * panel_bg_padding;
3397 // always force 2:1 aspect
3399 if(mySize_x/mySize_y > 2)
3401 newSize_x = 2 * mySize_y;
3402 newSize_y = mySize_y;
3404 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3408 newSize_y = 1/2 * mySize_x;
3409 newSize_x = mySize_x;
3411 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3415 drawfont = hud_bigfont;
3417 string s, forcetime;
3419 if(autocvar__hud_configure)
3422 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);
3423 s = "^1Intermediate 1 (+15.42)";
3424 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);
3425 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3426 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);
3428 else if(race_checkpointtime)
3430 a = bound(0, 2 - (time - race_checkpointtime), 1);
3433 if(a > 0) // just hit a checkpoint?
3435 if(race_checkpoint != 254)
3437 if(race_time && race_previousbesttime)
3438 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3440 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3442 forcetime = TIME_ENCODED_TOSTRING(race_time);
3447 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3449 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3450 if(a > 0) // next one?
3452 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3457 if(s != "" && a > 0)
3459 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3460 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3461 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);
3464 if(race_penaltytime)
3466 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3469 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3470 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3471 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3472 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);
3478 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3479 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', panel_fg_alpha, 0, a);
3480 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);
3485 if(race_laptime && race_checkpoint != 255)
3487 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3488 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3489 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);
3494 if(race_mycheckpointtime)
3496 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3497 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3498 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3499 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3500 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);
3502 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3504 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3505 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3506 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3507 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3508 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);
3511 if(race_penaltytime && !race_penaltyaccumulator)
3513 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3514 a = bound(0, (1 + t - time), 1);
3518 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3520 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3521 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3522 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3523 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);
3528 drawfont = hud_font;
3533 float vote_yescount;
3536 float vote_highlighted; // currently selected vote
3538 float vote_active; // is there an active vote?
3539 float vote_prev; // previous state of vote_active to check for a change
3541 float vote_change; // "time" when vote_active changed
3543 void HUD_VoteWindow(void)
3545 float id = HUD_PANEL_VOTE;
3546 HUD_Panel_UpdateCvarsForId(id);
3549 mySize = panel_size;
3553 if(vote_active != vote_prev) {
3555 vote_prev = vote_active;
3558 if(vote_active || autocvar__hud_configure)
3559 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3561 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3563 if(autocvar__hud_configure)
3573 a = vote_alpha * bound(autocvar_hud_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3575 HUD_Panel_DrawBg(1);
3576 if(panel_bg_padding)
3578 pos += '1 1 0' * panel_bg_padding;
3579 mySize -= '2 2 0' * panel_bg_padding;
3582 // always force 2:1 aspect
3584 if(mySize_x/mySize_y > 2)
3586 newSize_x = 2 * mySize_y;
3587 newSize_y = mySize_y;
3589 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3593 newSize_y = 1/2 * mySize_x;
3594 newSize_x = mySize_x;
3596 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3600 drawpic_aspect_skin(pos, "voteprogress_back", mySize, '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3602 s = "A vote has been called for: ";
3603 drawstring_aspect(pos + eY * (1/12) * mySize_y, s, eX * mySize_x + eY * (3/12) * mySize_y, mySize_y*(3/12), '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3604 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (3/12), stringwidth_colors); // TODO: broken?
3605 if(autocvar__hud_configure)
3606 s = "Configure the HUD";
3607 drawstring_aspect(pos + eY * (4/12) * mySize_y, s, eX * mySize_x + eY * (2/12) * mySize_y, mySize_y*(2/12), '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3609 // print the yes/no counts
3610 s = strcat("Yes: ", ftos(vote_yescount));
3611 drawstring(pos + '0 0.6 0' * mySize_y + '0.02 0 0' * mySize_x, s, '1 1 0' * mySize_y*(1/6) , eY, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3612 s = strcat("No: ", ftos(vote_nocount));
3613 drawstring(pos + '0 0.6 0' * mySize_y + '0.98 0 0' * mySize_x - eX * stringwidth(s, FALSE, '1 1 0' * mySize_y*(1/6)), s, '1 1 0' * mySize_y*(1/6), eX, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3615 // draw the progress bars
3616 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3617 drawpic_aspect_skin(pos, "voteprogress_prog", mySize, eY, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3619 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3620 drawpic_aspect_skin(pos, "voteprogress_prog", mySize, eX, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3622 // draw the highlights
3623 if(vote_highlighted == 1) {
3624 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3625 drawpic_aspect_skin(pos, "voteprogress_voted", mySize, eY, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3627 else if(vote_highlighted == 2) {
3628 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3629 drawpic_aspect_skin(pos, "voteprogress_voted", mySize, eX, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3632 drawresetcliparea();
3635 vote_highlighted = 0;
3639 // Mod icons panel (#10)
3642 float mod_active; // is there any active mod icon?
3644 // CTF HUD modicon section
3645 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3646 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3647 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3649 void HUD_Mod_CTF_Reset(void)
3651 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3654 void HUD_Mod_CTF(vector pos, vector mySize)
3656 vector redflag_pos, blueflag_pos;
3658 float f; // every function should have that
3660 float redflag, blueflag; // current status
3661 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3664 stat_items = getstati(STAT_ITEMS);
3665 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3666 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3668 if(redflag || blueflag)
3673 if(autocvar__hud_configure)
3679 // when status CHANGES, set old status into prevstatus and current status into status
3680 if (redflag != redflag_prevframe)
3682 redflag_statuschange_time = time;
3683 redflag_prevstatus = redflag_prevframe;
3684 redflag_prevframe = redflag;
3687 if (blueflag != blueflag_prevframe)
3689 blueflag_statuschange_time = time;
3690 blueflag_prevstatus = blueflag_prevframe;
3691 blueflag_prevframe = blueflag;
3694 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3695 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3697 float BLINK_FACTOR = 0.15;
3698 float BLINK_BASE = 0.85;
3700 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3702 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3704 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3706 string red_icon, red_icon_prevstatus;
3707 float red_alpha, red_alpha_prevstatus;
3708 red_alpha = red_alpha_prevstatus = 1;
3710 case 1: red_icon = "flag_red_taken"; break;
3711 case 2: red_icon = "flag_red_lost"; break;
3712 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3714 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3715 red_icon = "flag_red_shielded";
3717 red_icon = string_null;
3720 switch(redflag_prevstatus) {
3721 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3722 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3723 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3726 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3727 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3728 red_icon_prevstatus = "flag_red_shielded";
3730 red_icon_prevstatus = string_null;
3734 string blue_icon, blue_icon_prevstatus;
3735 float blue_alpha, blue_alpha_prevstatus;
3736 blue_alpha = blue_alpha_prevstatus = 1;
3738 case 1: blue_icon = "flag_blue_taken"; break;
3739 case 2: blue_icon = "flag_blue_lost"; break;
3740 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3742 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3743 blue_icon = "flag_blue_shielded";
3745 blue_icon = string_null;
3748 switch(blueflag_prevstatus) {
3749 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3750 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3751 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3754 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3755 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3756 blue_icon_prevstatus = "flag_blue_shielded";
3758 blue_icon_prevstatus = string_null;
3762 if(mySize_x > mySize_y) {
3763 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3765 blueflag_pos = pos + eX * 0.5 * mySize_x;
3768 redflag_pos = pos + eX * 0.5 * mySize_x;
3770 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3772 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3774 blueflag_pos = pos + eY * 0.5 * mySize_y;
3777 redflag_pos = pos + eY * 0.5 * mySize_y;
3779 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3782 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3783 if(red_icon_prevstatus && f < 1)
3784 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3786 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3788 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3789 if(blue_icon_prevstatus && f < 1)
3790 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3792 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3795 // Keyhunt HUD modicon section
3796 float kh_runheretime;
3798 void HUD_Mod_KH_Reset(void)
3803 void HUD_Mod_KH(vector pos, vector mySize)
3805 mod_active = 1; // keyhunt should never hide the mod icons panel
3809 vector p, pa, kh_size, kh_asize;
3811 kh_keys = getstati(STAT_KH_KEYS);
3814 if(mySize_x > mySize_y)
3816 p_y = pos_y + 0.25 * mySize_y;
3817 pa = p - eY * 0.25 * mySize_y;
3819 kh_size_x = mySize_x * 0.25;
3820 kh_size_y = 0.75 * mySize_y;
3821 kh_asize_x = mySize_x * 0.25;
3822 kh_asize_y = mySize_y * 0.25;
3826 p_y = pos_y + 0.125 * mySize_y;
3827 pa = p - eY * 0.125 * mySize_y;
3829 kh_size_x = mySize_x * 0.5;
3830 kh_size_y = 0.375 * mySize_y;
3831 kh_asize_x = mySize_x * 0.5;
3832 kh_asize_y = mySize_y * 0.125;
3839 for(i = 0; i < 4; ++i)
3841 key = floor(kh_keys / pow(32, i)) & 31;
3843 if(keyteam == 30 && keycount <= 4)
3845 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3849 // this yields 8 exactly if "RUN HERE" shows
3854 kh_runheretime = time;
3855 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3860 for(i = 0; i < 4; ++i)
3862 key = floor(kh_keys / pow(32, i)) & 31;
3875 default: // owned or dropped
3880 a = a * panel_fg_alpha;
3881 aa = aa * panel_fg_alpha;
3887 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3890 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3893 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3896 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3901 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3904 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3907 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3910 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3913 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3917 if(mySize_x > mySize_y)
3919 p_x += 0.25 * mySize_x;
3920 pa_x += 0.25 * mySize_x;
3926 p_y = pos_y + 0.625 * mySize_y;
3927 pa_y = pos_y + 0.5 * mySize_y;
3933 p_x += 0.5 * mySize_x;
3934 pa_x += 0.5 * mySize_x;
3940 // Nexball HUD mod icon
3941 void HUD_Mod_NexBall(vector pos, vector mySize)
3943 float stat_items, nb_pb_starttime, dt, p;
3945 stat_items = getstati(STAT_ITEMS);
3946 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3948 if (stat_items & IT_KEY1)
3953 //Manage the progress bar if any
3954 if (nb_pb_starttime > 0)
3956 dt = mod(time - nb_pb_starttime, nb_pb_period);
3957 // one period of positive triangle
3958 p = 2 * dt / nb_pb_period;
3965 if(mySize_x > mySize_y)
3967 barsize = eX * p * mySize_x + eY * mySize_y;
3972 barsize = eX * mySize_x + eY * p * mySize_y;
3975 HUD_Panel_GetProgressBarColor("nexball")
3976 HUD_Panel_DrawProgressBar(pos, vertical, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3979 if (stat_items & IT_KEY1)
3980 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3983 // Race/CTS HUD mod icons
3984 float crecordtime_prev; // last remembered crecordtime
3985 float crecordtime_change_time; // time when crecordtime last changed
3986 float srecordtime_prev; // last remembered srecordtime
3987 float srecordtime_change_time; // time when srecordtime last changed
3989 float race_status_time;
3990 float race_status_prev;
3991 string race_status_name_prev;
3992 void HUD_Mod_Race(vector pos, vector mySize)
3994 mod_active = 1; // race should never hide the mod icons panel
3996 me = playerslots[player_localentnum - 1];
3998 float f; // yet another function has this
3999 score = me.(scores[ps_primary]);
4001 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
4002 return; // no records in the actual race
4004 drawfont = hud_bigfont;
4006 // clientside personal record
4008 if(gametype == GAME_CTS)
4012 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4014 if(score && (score < t || !t)) {
4015 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4016 if(cvar("cl_autodemo_delete_keeprecords"))
4018 f = cvar("cl_autodemo_delete");
4020 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4024 if(t != crecordtime_prev) {
4025 crecordtime_prev = t;
4026 crecordtime_change_time = time;
4028 f = time - crecordtime_change_time;
4031 drawstring_aspect(pos, "Personal best ", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4032 drawstring(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);
4034 drawstring(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4035 drawstring(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);
4036 drawstring_expanding(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4037 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);
4041 t = race_server_record;
4042 if(t != srecordtime_prev) {
4043 srecordtime_prev = t;
4044 srecordtime_change_time = time;
4046 f = time - srecordtime_change_time;
4049 drawstring(pos + eY * 0.5 * mySize_y, "Server best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4050 drawstring(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);
4052 drawstring(pos + eY * 0.5 * mySize_y, "Server best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4053 drawstring(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);
4054 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);
4055 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);
4058 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4059 race_status_time = time + 5;
4060 race_status_prev = race_status;
4061 if (race_status_name_prev)
4062 strunzone(race_status_name_prev);
4063 race_status_name_prev = strzone(race_status_name);
4066 pos_x += mySize_x/2;
4069 a = bound(0, race_status_time - time, 1);
4072 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4076 rank = race_CheckName(race_status_name);
4078 rankname = race_PlaceName(rank);
4081 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4083 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4085 if(race_status == 0)
4086 drawpic_aspect_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4087 else if(race_status == 1) {
4088 drawpic_aspect_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4089 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4090 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4091 } else if(race_status == 2) {
4092 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4093 drawpic_aspect_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4095 drawpic_aspect_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4096 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4097 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4098 } else if(race_status == 3) {
4099 drawpic_aspect_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4100 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4101 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4104 if (race_status_time - time <= 0) {
4105 race_status_prev = -1;
4107 if(race_status_name)
4108 strunzone(race_status_name);
4109 race_status_name = string_null;
4110 if(race_status_name_prev)
4111 strunzone(race_status_name_prev);
4112 race_status_name_prev = string_null;
4114 drawfont = hud_font;
4117 float mod_prev; // previous state of mod_active to check for a change
4119 float mod_change; // "time" when mod_active changed
4121 void HUD_ModIcons(void)
4123 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !autocvar__hud_configure)
4126 float id = HUD_PANEL_MODICONS;
4127 HUD_Panel_UpdateCvarsForId(id);
4130 mySize = panel_size;
4132 if(mod_active != mod_prev) {
4134 mod_prev = mod_active;
4137 if(mod_active || autocvar__hud_configure)
4138 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4140 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4143 HUD_Panel_DrawBg(mod_alpha);
4145 if(panel_bg_padding)
4147 pos += '1 1 0' * panel_bg_padding;
4148 mySize -= '2 2 0' * panel_bg_padding;
4151 // these MUST be ran in order to update mod_active
4152 if(gametype == GAME_KEYHUNT)
4153 HUD_Mod_KH(pos, mySize);
4154 else if(gametype == GAME_CTF || autocvar__hud_configure)
4155 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4156 else if(gametype == GAME_NEXBALL)
4157 HUD_Mod_NexBall(pos, mySize);
4158 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4159 HUD_Mod_Race(pos, mySize);
4162 // Draw pressed keys (#11)
4164 void HUD_DrawPressedKeys(void)
4166 float id = HUD_PANEL_PRESSEDKEYS;
4167 HUD_Panel_UpdateCvarsForId(id);
4170 mySize = panel_size;
4172 HUD_Panel_DrawBg(1);
4173 if(panel_bg_padding)
4175 pos += '1 1 0' * panel_bg_padding;
4176 mySize -= '2 2 0' * panel_bg_padding;
4180 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4183 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4184 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4185 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);
4186 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);
4187 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);
4188 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);
4189 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);
4192 // Handle chat as a panel (#12)
4196 float id = HUD_PANEL_CHAT;
4197 HUD_Panel_UpdateCvarsForId(id);
4200 mySize = panel_size;
4202 HUD_Panel_DrawBg(1);
4203 if(panel_bg_padding)
4205 pos += '1 1 0' * panel_bg_padding;
4206 mySize -= '2 2 0' * panel_bg_padding;
4209 cvar_set("con_chatrect", "1");
4211 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4212 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4214 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4215 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4217 if(autocvar__hud_configure)
4220 chatsize = cvar("con_chatsize");
4221 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4223 for(i = 0; i < cvar("con_chat"); ++i)
4225 if(i == cvar("con_chat") - 1)
4228 a = panel_fg_alpha * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4229 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);
4234 // Engine info panel (#13)
4241 float frametimeavg1; // 1 frame ago
4242 float frametimeavg2; // 2 frames ago
4243 void HUD_EngineInfo(void)
4245 float id = HUD_PANEL_ENGINEINFO;
4246 HUD_Panel_UpdateCvarsForId(id);
4249 mySize = panel_size;
4251 HUD_Panel_DrawBg(1);
4252 if(panel_bg_padding)
4254 pos += '1 1 0' * panel_bg_padding;
4255 mySize -= '2 2 0' * panel_bg_padding;
4258 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4260 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4261 frametimeavg2 = frametimeavg1;
4262 frametimeavg1 = frametimeavg;
4265 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4266 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.
4268 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
4269 prevfps = (1/frametime);
4270 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"
4276 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4278 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4280 prevfps_time = time;
4285 color = HUD_Get_Num_Color (prevfps, 100);
4286 drawfont = hud_bigfont;
4287 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), mySize, mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4288 drawfont = hud_font;
4296 void HUD_ShowSpeed(void)
4299 float pos, conversion_factor;
4300 string speed, zspeed, unit;
4302 switch(cvar("cl_showspeed_unit"))
4307 conversion_factor = 1.0;
4311 conversion_factor = 1.0;
4315 conversion_factor = 0.0254;
4319 conversion_factor = 0.0254 * 3.6;
4323 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4327 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4331 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4333 numsize_x = numsize_y = cvar("cl_showspeed_size");
4334 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4336 drawfont = hud_bigfont;
4337 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4339 if (cvar("cl_showspeed_z") == 1) {
4340 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4341 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4344 drawfont = hud_font;
4347 vector acc_prevspeed;
4351 void HUD_ShowAcceleration(void)
4353 float acceleration, sz, scale, alpha, f;
4354 vector pos, top, rgb;
4355 top_x = vid_conwidth/2;
4358 f = time - acc_prevtime;
4359 if(cvar("cl_showacceleration_z"))
4360 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4362 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4363 acc_prevspeed = pmove_vel;
4364 acc_prevtime = time;
4366 f = bound(0, f * 10, 1);
4367 acc_avg = acc_avg * (1 - f) + acceleration * f;
4368 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4370 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4372 sz = cvar("cl_showacceleration_size");
4373 scale = cvar("cl_showacceleration_scale");
4374 alpha = cvar("cl_showacceleration_alpha");
4375 if (cvar("cl_showacceleration_color_custom"))
4376 rgb = stov(cvar_string("cl_showacceleration_color"));
4379 if (acceleration < 0) {
4380 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4381 } else if (acceleration > 0) {
4382 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4386 if (acceleration > 0)
4387 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4388 else if (acceleration < 0)
4389 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4392 void HUD_Reset (void)
4394 // reset gametype specific icons
4395 if(gametype == GAME_KEYHUNT)
4397 else if(gametype == GAME_CTF)
4398 HUD_Mod_CTF_Reset();
4401 void HUD_Main (void)
4403 // TODO: render order?
4404 hud_skin_path = strcat("gfx/hud/", autocvar_hud_skin);
4406 if(disable_menu_alphacheck == 1)
4407 menu_fade_alpha = 1;
4409 menu_fade_alpha = (1 - autocvar__menu_alpha);
4410 hud_fg_alpha = cvar("hud_fg_alpha");
4412 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4413 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4414 hud_color_bg_team = cvar("hud_color_bg_team");
4416 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4417 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4421 // HUD configure visible grid
4422 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4426 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2); ++i)
4428 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);
4431 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2); ++i)
4433 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);
4436 print("grid_xsize: ", ftos(autocvar_hud_configure_grid_xsize), "\n");
4440 if(teamplay && autocvar_hud_dock_color_team) {
4441 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4442 color = colormapPaletteColor(mod(f, 16), 1) * autocvar_hud_dock_color_team;
4444 else if(autocvar_hud_dock_color == "shirt") {
4445 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4446 color = colormapPaletteColor(floor(f / 16), 0);
4448 else if(autocvar_hud_dock_color == "pants") {
4449 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4450 color = colormapPaletteColor(mod(f, 16), 1);
4453 color = stov(autocvar_hud_dock_color);
4455 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4456 drawpic('0 0 0', strcat("gfx/hud/", autocvar_hud_skin, "/", autocvar_hud_dock), eX * vid_conwidth + eY * vid_conheight, color, autocvar_hud_dock_alpha * menu_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
4458 if(autocvar_hud_radar || autocvar__hud_configure)
4459 if(autocvar_hud_radar != 0 && (autocvar_hud_radar == 2 || teamplay))
4461 if(autocvar_hud_weaponicons || autocvar__hud_configure)
4463 if(autocvar_hud_inventory || autocvar__hud_configure)
4465 if(autocvar_hud_powerups || autocvar__hud_configure)
4467 if(autocvar_hud_healtharmor || autocvar__hud_configure)
4469 if(autocvar_hud_notify || autocvar__hud_configure)
4471 if(autocvar_hud_timer || autocvar__hud_configure)
4473 if(autocvar_hud_score || autocvar__hud_configure)
4475 if(autocvar_hud_racetimer || autocvar__hud_configure)
4476 if(gametype == GAME_RACE || gametype == GAME_CTS || autocvar__hud_configure)
4478 if(autocvar_hud_vote || autocvar__hud_configure)
4480 if(autocvar_hud_modicons || autocvar__hud_configure)
4482 if(autocvar_hud_pressedkeys || autocvar__hud_configure)
4483 if(spectatee_status > 0 || autocvar_hud_pressedkeys >= 2 || autocvar__hud_configure)
4484 HUD_DrawPressedKeys();
4485 if(autocvar_hud_chat || autocvar__hud_configure)
4488 cvar_set("con_chatrect", "0");
4489 if(autocvar_hud_engineinfo || autocvar__hud_configure)
4492 // TODO hud_'ify these
4493 if (cvar("cl_showspeed"))
4495 if (cvar("cl_showacceleration"))
4496 HUD_ShowAcceleration();
4498 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)
4499 localcmd("cmd selectteam auto; cmd join\n");
4501 hud_configure_prev = autocvar__hud_configure;
4503 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again
4504 disable_menu_alphacheck = 0;