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
89 void drawpic_aspect_skin(vector pos, string pic, vector sz, vector color, float alpha, float drawflag) {
90 pic = strcat(hud_skin_path, "/", pic);
93 imgsize = drawgetimagesize(pic);
95 imgaspect = imgsize_x/imgsize_y;
102 if(aspect > imgaspect) {
103 sz_x = sz_y * imgaspect;
104 drawpic(pos + eX * (oldsz_x - sz_x) * 0.5, pic, sz, color, alpha, drawflag);
106 sz_y = sz_x / imgaspect;
107 drawpic(pos + eY * (oldsz_y - sz_y) * 0.5, pic, sz, color, alpha, drawflag);
111 // drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
112 void drawpic_aspect(vector pos, string pic, vector sz, vector color, float alpha, float drawflag) {
114 imgsize = drawgetimagesize(pic);
116 imgaspect = imgsize_x/imgsize_y;
123 if(aspect > imgaspect) {
124 sz_x = sz_y * imgaspect;
125 drawpic(pos + eX * (oldsz_x - sz_x) * 0.5, pic, sz, color, alpha, drawflag);
127 sz_y = sz_x / imgaspect;
128 drawpic(pos + eY * (oldsz_y - sz_y) * 0.5, pic, sz, color, alpha, drawflag);
133 void drawpic_aspect_skin_expanding(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
135 //drawpic_aspect_expanding(pos, strcat("gfx/hud/", autocvar_hud_skin, "/", pic), sz, rgb, alpha, flag, fadelerp);
138 void drawpic_aspect_skin_expanding_two(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
140 //drawpic_aspect_expanding_two(pos, strcat("gfx/hud/", autocvar_hud_skin, "/", pic), sz, rgb, alpha, flag, fadelerp);
143 vector HUD_Get_Num_Color (float x, float maxvalue)
151 else if(x > maxvalue * 0.75) {
152 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
153 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
156 else if(x > maxvalue * 0.5) {
157 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
158 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
159 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
161 else if(x > maxvalue * 0.25) {
164 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
166 else if(x > maxvalue * 0.1) {
168 color_y = (x-20)*90/27/100; // green value between 0 -> 1
169 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
179 float stringwidth_colors(string s, vector theSize)
181 return stringwidth(s, TRUE, theSize);
184 float stringwidth_nocolors(string s, vector theSize)
186 return stringwidth(s, FALSE, theSize);
189 #define CENTERPRINT_MAX_LINES 30
190 string centerprint_messages[CENTERPRINT_MAX_LINES];
191 float centerprint_width[CENTERPRINT_MAX_LINES];
192 vector centerprint_start;
193 float centerprint_expire;
194 float centerprint_num;
195 float centerprint_offset_hint;
196 vector centerprint_fontsize;
198 void centerprint(string strMessage)
200 float i, j, n, hcount;
203 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
205 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
207 if(cvar("scr_centertime") <= 0)
213 // strip trailing newlines
214 j = strlen(strMessage) - 1;
215 while(substring(strMessage, j, 1) == "\n" && j >= 0)
217 strMessage = substring(strMessage, 0, j + 1);
222 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
224 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
226 strMessage = substring(strMessage, j, strlen(strMessage) - j);
227 centerprint_offset_hint = j;
232 // if we get here, we have a message. Initialize its height.
235 n = tokenizebyseparator(strMessage, "\n");
237 for(j = 0; j < n; ++j)
239 getWrappedLine_remaining = argv(j);
240 while(getWrappedLine_remaining)
242 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
243 if(centerprint_messages[i])
244 strunzone(centerprint_messages[i]);
245 centerprint_messages[i] = strzone(s);
246 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
249 // half height for empty lines looks better
255 if(i >= CENTERPRINT_MAX_LINES)
261 h = centerprint_fontsize_y*hcount;
263 havail = vid_conheight;
264 if(cvar("con_chatpos") < 0)
265 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
266 if(havail > vid_conheight - 70)
267 havail = vid_conheight - 70; // avoid overlapping HUD
269 centerprint_start_x = 0;
272 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
274 // here, the centerprint would cover the crosshair. REALLY BAD.
275 forbiddenmin = vid_conheight * 0.5 - h - 16;
276 forbiddenmax = vid_conheight * 0.5 + 16;
278 allowedmin = scoreboard_bottom;
279 allowedmax = havail - h;
280 preferred = (havail - h)/2;
283 // possible orderings (total: 4! / 4 = 6)
284 // allowedmin allowedmax forbiddenmin forbiddenmax
285 // forbiddenmin forbiddenmax allowedmin allowedmax
286 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
288 // forbidden doesn't matter in this case
289 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
291 // allowedmin forbiddenmin allowedmax forbiddenmax
292 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
294 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
296 // allowedmin forbiddenmin forbiddenmax allowedmax
297 else if(allowedmin < forbiddenmin)
299 // make sure the forbidden zone is not covered
300 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
301 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
303 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
305 // forbiddenmin allowedmin allowedmax forbiddenmax
306 else if(allowedmax < forbiddenmax)
308 // it's better to leave the allowed zone (overlap with scoreboard) than
309 // to cover the forbidden zone (crosshair)
310 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
311 centerprint_start_y = forbiddenmax;
313 centerprint_start_y = forbiddenmin;
315 // forbiddenmin allowedmin forbiddenmax allowedmax
318 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
321 centerprint_start_y =
324 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
332 centerprint_expire = time + cvar("scr_centertime");
335 void HUD_DrawCenterPrint (void)
342 //if(time > centerprint_expire)
345 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
346 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
347 //sz = 1.2 / (a + 0.2);
352 pos = centerprint_start;
353 for (i=0; i<centerprint_num; i = i + 1)
355 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
356 ts = centerprint_messages[i];
359 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
360 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
361 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
362 pos_y = pos_y + centerprint_fontsize_y;
365 // half height for empty lines looks better
366 pos_y = pos_y + centerprint_fontsize_y * 0.5;
370 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
372 position_x -= 2 / 3 * strlen(text) * scale_x;
373 drawstring(position, text, scale, rgb, alpha, flag);
376 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
378 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
379 drawstring(position, text, scale, rgb, alpha, flag);
382 // return the string of the given race place
383 string race_PlaceName(float pos) {
391 return strcat(ftos(pos), "th");
394 // return the string of the onscreen race timer
395 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
403 if(histime == 0) // goal hit
407 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
417 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
423 lapstr = strcat(" (-", ftos(lapdelta), "L)");
426 else if(lapdelta < 0)
428 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
432 else if(histime > 0) // anticipation
434 if(mytime >= histime)
435 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
437 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
444 cpname = "Start line";
446 cpname = "Finish line";
448 cpname = strcat("Intermediate ", ftos(cp));
450 cpname = "Finish line";
453 return strcat(col, cpname);
454 else if(hisname == "")
455 return strcat(col, cpname, " (", timestr, ")");
457 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
460 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
461 float race_CheckName(string net_name) {
463 for (i=RANKINGS_CNT-1;i>=0;--i)
464 if(grecordholder[i] == net_name)
476 void HUD_Panel_ExportCfg(string cfgname)
479 fh = fopen(strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg"), FILE_WRITE);
482 fputs(fh, strcat("seta hud_skin \"", autocvar_hud_skin, "\"", "\n"));
483 fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
484 fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
485 fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
486 fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
487 fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
488 fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
489 fputs(fh, strcat("seta hud_fg_alpha \"", cvar_string("hud_fg_alpha"), "\"", "\n"));
492 fputs(fh, strcat("seta hud_dock \"", autocvar_hud_dock, "\"", "\n"));
493 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
494 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
495 fputs(fh, strcat("seta hud_dock_alpha \"", ftos(autocvar_hud_dock_alpha), "\"", "\n"));
498 fputs(fh, strcat("seta hud_progressbar_alpha ", ftos(autocvar_hud_progressbar_alpha), "\n"));
499 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
500 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
501 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
502 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
503 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
504 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
507 // common cvars for all panels
509 for (i = 0; i < HUD_PANEL_NUM; ++i)
512 HUD_Panel_UpdateCvarsForId(i)
514 fputs(fh, strcat("seta hud_", panel_name, " ", ftos(cvar(strcat("hud_", panel_name))), "\n"));
515 fputs(fh, strcat("seta hud_", panel_name, "_pos \"", cvar_string(strcat("hud_", panel_name, "_pos")), "\"", "\n"));
516 fputs(fh, strcat("seta hud_", panel_name, "_size \"", cvar_string(strcat("hud_", panel_name, "_size")), "\"", "\n"));
517 fputs(fh, strcat("seta hud_", panel_name, "_bg \"", cvar_string(strcat("hud_", panel_name, "_bg")), "\"", "\n"));
518 fputs(fh, strcat("seta hud_", panel_name, "_bg_color \"", cvar_string(strcat("hud_", panel_name, "_bg_color")), "\"", "\n"));
519 fputs(fh, strcat("seta hud_", panel_name, "_bg_color_team \"", cvar_string(strcat("hud_", panel_name, "_bg_color_team")), "\"", "\n"));
520 fputs(fh, strcat("seta hud_", panel_name, "_bg_alpha \"", cvar_string(strcat("hud_", panel_name, "_bg_alpha")), "\"", "\n"));
521 fputs(fh, strcat("seta hud_", panel_name, "_bg_border \"", cvar_string(strcat("hud_", panel_name, "_bg_border")), "\"", "\n"));
522 fputs(fh, strcat("seta hud_", panel_name, "_bg_padding \"", cvar_string(strcat("hud_", panel_name, "_bg_padding")), "\"", "\n"));
524 case HUD_PANEL_WEAPONICONS:
525 fputs(fh, strcat("seta hud_", panel_name, "_accuracy_yellow ", ftos(cvar(strcat("hud_", panel_name, "_accuracy_yellow"))), "\n"));
527 case HUD_PANEL_INVENTORY:
528 fputs(fh, strcat("seta hud_", panel_name, "_onlycurrent ", ftos(cvar(strcat("hud_", panel_name, "_onlycurrent"))), "\n"));
529 fputs(fh, strcat("seta hud_", panel_name, "_iconalign ", ftos(cvar(strcat("hud_", panel_name, "_iconalign"))), "\n"));
531 case HUD_PANEL_POWERUPS:
532 fputs(fh, strcat("seta hud_", panel_name, "_flip ", ftos(cvar(strcat("hud_", panel_name, "_flip"))), "\n"));
533 fputs(fh, strcat("seta hud_", panel_name, "_iconalign ", ftos(cvar(strcat("hud_", panel_name, "_iconalign"))), "\n"));
534 fputs(fh, strcat("seta hud_", panel_name, "_baralign ", ftos(cvar(strcat("hud_", panel_name, "_baralign"))), "\n"));
536 case HUD_PANEL_HEALTHARMOR:
537 fputs(fh, strcat("seta hud_", panel_name, "_flip ", ftos(cvar(strcat("hud_", panel_name, "_flip"))), "\n"));
538 fputs(fh, strcat("seta hud_", panel_name, "_iconalign ", ftos(cvar(strcat("hud_", panel_name, "_iconalign"))), "\n"));
539 fputs(fh, strcat("seta hud_", panel_name, "_baralign ", ftos(cvar(strcat("hud_", panel_name, "_baralign"))), "\n"));
541 case HUD_PANEL_NOTIFY:
542 fputs(fh, strcat("seta hud_", panel_name, "_flip ", ftos(cvar(strcat("hud_", panel_name, "_flip"))), "\n"));
543 fputs(fh, strcat("seta hud_", panel_name, "_info_top ", ftos(cvar(strcat("hud_", panel_name, "_info_top"))), "\n"));
545 case HUD_PANEL_RADAR:
546 fputs(fh, strcat("seta hud_", panel_name, "_foreground_alpha ", ftos(cvar(strcat("hud_", panel_name, "_foreground_alpha"))), "\n"));
549 fputs(fh, strcat("seta hud_", panel_name, "_alreadyvoted_alpha ", ftos(cvar(strcat("hud_", panel_name, "_alreadyvoted_alpha"))), "\n"));
555 print("^2Successfully exported to hud_", autocvar_hud_skin, "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
560 // return smoothly faded size of given panel when a dialog is active
561 vector HUD_Panel_GetMenuSize(float id)
566 mySize = eX * mySize_x * vid_conwidth + eY * mySize_y * vid_conheight;
568 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
570 vector menu_enable_maxsize, menu_enable_size;
571 menu_enable_maxsize = '0 0 0'; // shut up FTEQCC
572 menu_enable_maxsize_x = 0.3 * vid_conwidth;
573 menu_enable_maxsize_y = 0.18 * vid_conheight;
574 if(mySize_x > mySize_y)
576 if(mySize_y > menu_enable_maxsize_y)
578 menu_enable_size_y = menu_enable_maxsize_y;
579 menu_enable_size_x = mySize_x * (menu_enable_maxsize_y/mySize_y);
580 mySize = (1 - autocvar__menu_alpha) * mySize + (autocvar__menu_alpha) * menu_enable_size;
585 if(mySize_x > menu_enable_maxsize_x)
587 menu_enable_size_x = menu_enable_maxsize_x;
588 menu_enable_size_y = mySize_y * (menu_enable_maxsize_x/mySize_x);
589 mySize = (1 - autocvar__menu_alpha) * mySize + (autocvar__menu_alpha) * menu_enable_size;
596 // return smoothly faded pos of given panel when a dialog is active
597 vector HUD_Panel_GetMenuPos(float id)
602 pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
604 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
606 vector mySize, menu_enable_panelpos;
607 mySize = HUD_Panel_GetMenuSize(id);
608 if(mySize_x > mySize_y)
609 menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * mySize_x + eY * 0.82 * vid_conheight;
611 menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * mySize_y + eX * 0.7 * vid_conwidth;
612 pos = (1 - autocvar__menu_alpha) * pos + (autocvar__menu_alpha) * menu_enable_panelpos;
617 // draw the background/borders
618 #define HUD_Panel_DrawBg(alpha)\
620 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));\
621 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
622 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);
624 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
630 pic = strcat(hud_skin_path, "/");
632 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);
633 if(mySize_y/mySize_x > 2)
634 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);
635 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);
637 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);
638 if(mySize_x/mySize_y > 2)
639 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);
640 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);
644 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
645 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
656 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
657 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
659 for (i = 0; i < HUD_PANEL_NUM; ++i) {
660 HUD_Panel_UpdatePosSizeForId(i)
662 if(i == highlightedPanel || !panel_enabled)
666 targSize = panel_size;
668 if(myPos_y + mySize_y < targPos_y)
670 if(myPos_y > targPos_y + targSize_y)
673 if(myPos_x + mySize_x < targPos_x)
675 if(myPos_x > targPos_x + targSize_x)
678 // OK, there IS a collision.
680 myCenter_x = myPos_x + 0.5 * mySize_x;
681 myCenter_y = myPos_y + 0.5 * mySize_y;
683 targCenter_x = targPos_x + 0.5 * targSize_x;
684 targCenter_y = targPos_y + 0.5 * targSize_y;
686 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
688 if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
689 myTarget_x = targPos_x - mySize_x;
690 else // push it upwards
691 myTarget_y = targPos_y - mySize_y;
693 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
695 if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
696 myTarget_x = targPos_x + targSize_x;
697 else // push it upwards
698 myTarget_y = targPos_y - mySize_y;
700 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
702 if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
703 myTarget_x = targPos_x - mySize_x;
704 else // push it downwards
705 myTarget_y = targPos_y + targSize_y;
707 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
709 if(targPos_x + targSize_x - myPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
710 myTarget_x = targPos_x + targSize_x;
711 else // push it downwards
712 myTarget_y = targPos_y + targSize_y;
719 void HUD_Panel_SetPos(vector pos)
721 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
725 if(hud_configure_checkcollisions)
726 pos = HUD_Panel_CheckMove(pos, mySize);
728 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
729 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
731 if(autocvar_hud_configure_grid)
733 pos_x = floor((pos_x/vid_conwidth)/bound(0.005, autocvar_hud_configure_grid_x, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_x, 0.2) * vid_conwidth;
734 pos_y = floor((pos_y/vid_conheight)/bound(0.005, autocvar_hud_configure_grid_y, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_y, 0.2) * vid_conheight;
738 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
740 HUD_Panel_GetName(highlightedPanel);
741 cvar_set(strcat("hud_", panel_name, "_pos"), s);
744 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
745 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
755 ratio = mySize_x/mySize_y;
757 for (i = 0; i < HUD_PANEL_NUM; ++i) {
758 HUD_Panel_UpdatePosSizeForId(i)
760 if(i == highlightedPanel || !panel_enabled)
764 targSize = panel_size;
765 targEndPos = targPos + targSize;
767 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
768 if(resizeorigin_x > targPos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > targPos_y && resizeorigin_y < targEndPos_y)
771 if (resizeCorner == 1)
773 // check if this panel is on our way
774 if (resizeorigin_x <= targPos_x)
776 if (resizeorigin_y <= targPos_y)
778 if (targEndPos_x <= resizeorigin_x - mySize_x)
780 if (targEndPos_y <= resizeorigin_y - mySize_y)
783 // there is a collision:
784 // detect which side of the panel we are facing is actually limiting the resizing
785 // (which side the resize direction finds for first) and reduce the size up to there
787 // dist is the distance between resizeorigin and the "analogous" point of the panel
788 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
789 dist_x = resizeorigin_x - targEndPos_x;
790 dist_y = resizeorigin_y - targEndPos_y;
791 if (dist_y < 0 || dist_x / dist_y > ratio)
792 mySize_x = min(mySize_x, dist_x);
794 mySize_y = min(mySize_y, dist_y);
796 else if (resizeCorner == 2)
798 if (resizeorigin_x >= targEndPos_x)
800 if (resizeorigin_y <= targPos_y)
802 if (targPos_x >= resizeorigin_x + mySize_x)
804 if (targEndPos_y <= resizeorigin_y - mySize_y)
807 dist_x = targPos_x - resizeorigin_x;
808 dist_y = resizeorigin_y - targEndPos_y;
809 if (dist_y < 0 || dist_x / dist_y > ratio)
810 mySize_x = min(mySize_x, dist_x);
812 mySize_y = min(mySize_y, dist_y);
814 else if (resizeCorner == 3)
816 if (resizeorigin_x <= targPos_x)
818 if (resizeorigin_y >= targEndPos_y)
820 if (targEndPos_x <= resizeorigin_x - mySize_x)
822 if (targPos_y >= resizeorigin_y + mySize_y)
825 dist_x = resizeorigin_x - targEndPos_x;
826 dist_y = targPos_y - resizeorigin_y;
827 if (dist_y < 0 || dist_x / dist_y > ratio)
828 mySize_x = min(mySize_x, dist_x);
830 mySize_y = min(mySize_y, dist_y);
832 else if (resizeCorner == 4)
834 if (resizeorigin_x >= targEndPos_x)
836 if (resizeorigin_y >= targEndPos_y)
838 if (targPos_x >= resizeorigin_x + mySize_x)
840 if (targPos_y >= resizeorigin_y + mySize_y)
843 dist_x = targPos_x - resizeorigin_x;
844 dist_y = targPos_y - resizeorigin_y;
845 if (dist_y < 0 || dist_x / dist_y > ratio)
846 mySize_x = min(mySize_x, dist_x);
848 mySize_y = min(mySize_y, dist_y);
850 if(cvar("hud_configure_checkcollisions_debug"))
851 drawfill(targPos, targSize, '1 1 0', .3, DRAWFLAG_NORMAL);
857 void HUD_Panel_SetPosSize(vector mySize)
859 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
861 resizeorigin = panel_click_resizeorigin;
864 // minimum panel size cap
865 mySize_x = max(0.025 * vid_conwidth, mySize_x);
866 mySize_y = max(0.025 * vid_conheight, mySize_y);
868 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.
870 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
871 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
874 // collision testing|
875 // -----------------+
877 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
878 if(resizeCorner == 1) {
879 myPos_x = resizeorigin_x - mySize_x;
880 myPos_y = resizeorigin_y - mySize_y;
881 } else if(resizeCorner == 2) {
882 myPos_x = resizeorigin_x;
883 myPos_y = resizeorigin_y - mySize_y;
884 } else if(resizeCorner == 3) {
885 myPos_x = resizeorigin_x - mySize_x;
886 myPos_y = resizeorigin_y;
887 } else { // resizeCorner == 4
888 myPos_x = resizeorigin_x;
889 myPos_y = resizeorigin_y;
892 // left/top screen edges
894 mySize_x = mySize_x + myPos_x;
896 mySize_y = mySize_y + myPos_y;
898 // bottom/right screen edges
899 if(myPos_x + mySize_x > vid_conwidth)
900 mySize_x = vid_conwidth - myPos_x;
901 if(myPos_y + mySize_y > vid_conheight)
902 mySize_y = vid_conheight - myPos_y;
904 if(cvar("hud_configure_checkcollisions_debug"))
905 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
907 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
908 if(autocvar_hud_configure_grid)
910 mySize_x = floor((mySize_x/vid_conwidth)/bound(0.005, autocvar_hud_configure_grid_x, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_x, 0.2) * vid_conwidth;
911 mySize_y = floor((mySize_y/vid_conheight)/bound(0.005, autocvar_hud_configure_grid_y, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_y, 0.2) * vid_conheight;
914 if(hud_configure_checkcollisions)
915 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
917 // 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)
918 mySize_x = max(0.025 * vid_conwidth, mySize_x);
919 mySize_y = max(0.025 * vid_conheight, mySize_y);
921 // do another pos check, as size might have changed by now
922 if(resizeCorner == 1) {
923 myPos_x = resizeorigin_x - mySize_x;
924 myPos_y = resizeorigin_y - mySize_y;
925 } else if(resizeCorner == 2) {
926 myPos_x = resizeorigin_x;
927 myPos_y = resizeorigin_y - mySize_y;
928 } else if(resizeCorner == 3) {
929 myPos_x = resizeorigin_x - mySize_x;
930 myPos_y = resizeorigin_y;
931 } else { // resizeCorner == 4
932 myPos_x = resizeorigin_x;
933 myPos_y = resizeorigin_y;
936 if(cvar("hud_configure_checkcollisions_debug"))
937 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
939 HUD_Panel_GetName(highlightedPanel);
941 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
942 cvar_set(strcat("hud_", panel_name, "_size"), s);
944 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
945 cvar_set(strcat("hud_", panel_name, "_pos"), s);
949 float prevMouseClicked; // previous state
950 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
951 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
954 float menu_enabled_time;
955 float pressed_key_time;
956 void HUD_Panel_Arrow_Action(float nPrimary)
958 if (highlightedPanel_prev == -1 || mouseClicked)
961 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
964 if(autocvar_hud_configure_grid)
966 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
968 if (hudShiftState & S_SHIFT)
969 step = bound(0.005, autocvar_hud_configure_grid_y, 0.2) * vid_conheight;
971 step = 2 * bound(0.005, autocvar_hud_configure_grid_y, 0.2) * vid_conheight;
975 if (hudShiftState & S_SHIFT)
976 step = bound(0.005, autocvar_hud_configure_grid_x, 0.2) * vid_conwidth;
978 step = 2 * bound(0.005, autocvar_hud_configure_grid_x, 0.2) * vid_conwidth;
983 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
984 step = vid_conheight;
987 if (hudShiftState & S_SHIFT)
988 step = (step / 256); // more precision
990 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
993 highlightedPanel = highlightedPanel_prev;
995 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
997 if (hudShiftState & S_ALT) // resize
999 highlightedAction = 1;
1000 if(nPrimary == K_UPARROW)
1002 else if(nPrimary == K_RIGHTARROW)
1004 else if(nPrimary == K_LEFTARROW)
1006 else // if(nPrimary == K_DOWNARROW)
1009 // ctrl+arrow reduces the size, instead of increasing it
1010 // Note that ctrl disables collisions check too, but it's fine
1011 // since we don't collide with anything reducing the size
1012 if (hudShiftState & S_CTRL) {
1014 resizeCorner = 5 - resizeCorner;
1018 mySize = panel_size;
1019 panel_click_resizeorigin = panel_pos;
1020 if(resizeCorner == 1) {
1021 panel_click_resizeorigin += mySize;
1023 } else if(resizeCorner == 2) {
1024 panel_click_resizeorigin_y += mySize_y;
1026 } else if(resizeCorner == 3) {
1027 panel_click_resizeorigin_x += mySize_x;
1029 } else { // resizeCorner == 4
1032 HUD_Panel_SetPosSize(mySize);
1036 highlightedAction = 2;
1039 if(nPrimary == K_UPARROW)
1041 else if(nPrimary == K_DOWNARROW)
1043 else if(nPrimary == K_LEFTARROW)
1045 else // if(nPrimary == K_RIGHTARROW)
1048 HUD_Panel_SetPos(pos);
1052 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1054 if(!autocvar__hud_configure)
1057 // allow console bind to work
1060 con_keys = findkeysforcommand("toggleconsole");
1061 keys = tokenize(con_keys);
1063 float hit_con_bind, i;
1064 for (i = 0; i < keys; ++i)
1066 if(nPrimary == stof(argv(i)))
1070 if(bInputType == 0) {
1071 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1072 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1073 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1075 else if(bInputType == 1) {
1076 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1077 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1078 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1081 if(nPrimary == K_MOUSE1)
1083 if(bInputType == 0) { // key pressed
1087 else if(bInputType == 1) {// key released
1092 else if(nPrimary == K_ESCAPE)
1094 if (bInputType == 1)
1096 disable_menu_alphacheck = 1;
1098 menu_enabled_time = time;
1099 localcmd("menu_showhudexit\n");
1101 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1103 if (bInputType == 1)
1105 pressed_key_time = 0;
1108 else if (pressed_key_time == 0)
1109 pressed_key_time = time;
1111 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1113 else if(hit_con_bind)
1116 return true; // Suppress ALL other input
1119 float HUD_Panel_HighlightCheck()
1125 for(i = 0; i < HUD_PANEL_NUM; ++i)
1127 HUD_Panel_UpdatePosSizeForId(i)
1129 panelPos = panel_pos;
1130 panelSize = panel_size;
1131 border = 10; // FORCED border so a small border size doesn't mean you can't resize
1134 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1138 // resize from topleft border
1139 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)
1143 // resize from topright border
1144 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)
1148 // resize from bottomleft border
1149 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)
1153 // resize from bottomright border
1154 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)
1162 void HUD_Panel_Highlight()
1168 for(i = 0; i < HUD_PANEL_NUM; ++i)
1170 HUD_Panel_UpdatePosSizeForId(i)
1172 panelPos = panel_pos;
1173 panelSize = panel_size;
1174 border = 10; // FORCED border so a small border size doesn't mean you can't resize
1177 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1179 highlightedPanel = i;
1180 highlightedAction = 1;
1181 panel_click_distance = mousepos - panelPos;
1184 // resize from topleft border
1185 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)
1187 highlightedPanel = i;
1188 highlightedAction = 2;
1190 panel_click_distance = mousepos - panelPos;
1191 panel_click_resizeorigin = panelPos + panelSize;
1194 // resize from topright border
1195 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)
1197 highlightedPanel = i;
1198 highlightedAction = 2;
1200 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1201 panel_click_distance_y = mousepos_y - panelPos_y;
1202 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1205 // resize from bottomleft border
1206 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)
1208 highlightedPanel = i;
1209 highlightedAction = 2;
1211 panel_click_distance_x = mousepos_x - panelPos_x;
1212 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1213 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1216 // resize from bottomright border
1217 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)
1219 highlightedPanel = i;
1220 highlightedAction = 2;
1222 panel_click_distance = panelSize - mousepos + panelPos;
1223 panel_click_resizeorigin = panelPos;
1229 float highlightcheck;
1230 void HUD_Panel_Mouse()
1232 // 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
1233 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1234 disable_menu_alphacheck = 0;
1235 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1239 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1240 print("Highlighted: ", ftos(highlightedPanel), "\n");
1241 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1244 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1245 highlightedPanel_prev = highlightedPanel;
1246 highlightedPanel = -1;
1247 highlightedAction = 0;
1250 mousepos = mousepos + getmousepos();
1252 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1253 mousepos_y = bound(0, mousepos_y, vid_conheight);
1257 if(prevMouseClicked == 0)
1258 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1260 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1262 if(highlightedAction == 1)
1263 HUD_Panel_SetPos(mousepos - panel_click_distance);
1264 else if(highlightedAction == 2)
1267 if(resizeCorner == 1) {
1268 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1269 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1270 } else if(resizeCorner == 2) {
1271 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1272 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1273 } else if(resizeCorner == 3) {
1274 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1275 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1276 } else { // resizeCorner == 4
1277 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1278 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1280 HUD_Panel_SetPosSize(mySize);
1283 // doubleclick check
1284 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1286 mouseClicked = 0; // to prevent spam, I guess.
1287 disable_menu_alphacheck = 2;
1289 menu_enabled_time = time;
1290 HUD_Panel_GetName(highlightedPanel)
1291 localcmd("menu_showhudoptions ", panel_name, "\n");
1294 if(prevMouseClicked == 0)
1296 prevMouseClickedTime = time;
1297 prevMouseClickedPos = mousepos;
1302 highlightcheck = HUD_Panel_HighlightCheck();
1304 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1307 cursorsize = '32 32 0';
1309 if(highlightcheck == 0)
1310 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1311 else if(highlightcheck == 1)
1312 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1313 else if(highlightcheck == 2)
1314 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1316 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1318 prevMouseClicked = mouseClicked;
1321 // Weapon icons (#0)
1323 float weaponspace[10];
1324 #define HUD_WeaponIcons_Clear()\
1326 for(idx = 0; idx < 10; ++idx)\
1327 weaponspace[idx] = 0;
1329 entity weaponorder[WEP_MAXCOUNT];
1330 void weaponorder_swap(float i, float j, entity pass)
1334 weaponorder[i] = weaponorder[j];
1338 string weaponorder_cmp_str_save;
1339 string weaponorder_cmp_str;
1340 float weaponorder_cmp(float i, float j, entity pass)
1343 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1344 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1345 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)
1348 void HUD_WeaponIcons(void)
1350 float id = HUD_PANEL_WEAPONICONS;
1351 HUD_Panel_UpdateCvarsForId(id);
1352 float alpha, stat_weapons; // "constants"
1354 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1357 mySize = panel_size;
1359 stat_weapons = getstati(STAT_WEAPONS);
1361 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1363 self = get_weaponinfo(i);
1364 if(self.impulse >= 0)
1368 // TODO make this configurable
1369 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1371 if(weaponorder_cmp_str != weaponorder_cmp_str_save)
1373 if(weaponorder_cmp_str_save)
1374 strunzone(weaponorder_cmp_str_save);
1375 weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
1377 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1379 self = get_weaponinfo(i);
1380 if(self.impulse >= 0)
1382 weaponorder[weapon_cnt] = self;
1386 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1389 HUD_Panel_DrawBg(id, pos, mySize, 0);
1390 if(panel_bg_padding)
1392 pos += '1 1 0' * panel_bg_padding;
1393 mySize -= '2 2 0' * panel_bg_padding;
1397 weapon_stats = getstati(STAT_DAMAGE_HITS);
1398 weapon_number = weapon_stats & 63;
1399 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1401 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1402 weapon_number = weapon_stats & 63;
1403 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1405 if(cvar_or("hud_weaponicons_fade", 1))
1407 fade = 3.2 - 2 * (time - weapontime);
1408 fade = bound(0.7, fade, 1);
1413 HUD_WeaponIcons_Clear();
1415 float rows, columns;
1416 rows = mySize_y/mySize_x;
1417 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1418 // ^^^ weapon icon aspect goes here
1420 columns = ceil(WEP_COUNT/rows);
1425 when = autocvar_hud_weaponicons_complainbubble_time;
1427 fadetime = autocvar_hud_weaponicons_complainbubble_fadetime;
1430 for(i = 0; i < weapon_cnt; ++i)
1432 self = weaponorder[i];
1433 weapid = self.impulse;
1435 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1437 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1438 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1440 // draw background behind currently selected weapon
1441 if(self.weapon == activeweapon)
1442 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);
1444 // draw the weapon accuracy on the HUD
1445 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1448 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1450 // yellow_accuracy = value at which accuracy becomes yellow
1451 if(weapon_stats >= 100) {
1455 else if(weapon_stats > autocvar_hud_weaponicons_accuracy_yellow) {
1456 color_x = 1 - (weapon_stats-autocvar_hud_weaponicons_accuracy_yellow)/(100-autocvar_hud_weaponicons_accuracy_yellow); // red value between 1 -> 0
1460 color_y = weapon_stats/autocvar_hud_weaponicons_accuracy_yellow; // green value between 0 -> 1
1464 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);
1467 // draw the weapon icon
1468 if((self.impulse >= 0) && (stat_weapons & self.weapons))
1470 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);
1472 if(cvar_or("hud_weaponicons_number", 1))
1473 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);
1475 // draw a "ghost weapon icon" if you don't have the weapon
1478 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);
1481 // draw the complain message
1482 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_weaponicons_complainbubble)
1486 if(complain_weapon_time + when > time)
1489 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1493 if(complain_weapon_time + when > time)
1499 vector complain_bubble_size = '100 50 0' * bound(0.25, autocvar_hud_weaponicons_complainbubble_size, 2);
1500 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);
1503 if(complain_weapon_type == 0) {
1504 s = "Out of ammo for the";
1507 else if(complain_weapon_type == 1) {
1508 s = "You don't have the";
1512 s = "Map doesn't have the";
1515 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);
1516 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);
1532 float GetAmmoStat(float i)
1536 case 0: return STAT_SHELLS;
1537 case 1: return STAT_NAILS;
1538 case 2: return STAT_ROCKETS;
1539 case 3: return STAT_CELLS;
1540 case 4: return STAT_FUEL;
1545 float GetAmmoItemCode(float i)
1549 case 0: return IT_SHELLS;
1550 case 1: return IT_NAILS;
1551 case 2: return IT_ROCKETS;
1552 case 3: return IT_CELLS;
1553 case 4: return IT_FUEL;
1558 string GetAmmoPicture(float i)
1562 case 0: return "ammo_shells";
1563 case 1: return "ammo_bullets";
1564 case 2: return "ammo_rockets";
1565 case 3: return "ammo_cells";
1566 case 4: return "ammo_fuel";
1571 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1574 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1575 if(autocvar__hud_configure)
1585 if(currently_selected)
1590 vector newSize, newPos;
1591 if(mySize_x/mySize_y > 3)
1593 newSize_x = 3 * mySize_y;
1594 newSize_y = mySize_y;
1596 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1601 newSize_y = 1/3 * mySize_x;
1602 newSize_x = mySize_x;
1604 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1608 vector picpos, numpos;
1609 if(autocvar_hud_inventory_iconalign)
1612 picpos = newPos + eX * 2 * newSize_y;
1616 numpos = newPos + eX * newSize_y;
1620 if (currently_selected)
1621 drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1623 drawfont = hud_bigfont;
1624 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1625 drawfont = hud_font;
1626 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1629 void HUD_Inventory(void)
1631 float id = HUD_PANEL_INVENTORY;
1632 HUD_Panel_UpdateCvarsForId(id);
1633 float i, currently_selected;
1637 mySize = panel_size;
1639 HUD_Panel_DrawBg(id, pos, mySize, 0);
1640 if(panel_bg_padding)
1642 pos += '1 1 0' * panel_bg_padding;
1643 mySize -= '2 2 0' * panel_bg_padding;
1646 float rows, columns;
1647 rows = mySize_y/mySize_x;
1648 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1649 // ^^^ ammo item aspect goes here
1651 columns = ceil(AMMO_COUNT/rows);
1655 for (i = 0; i < AMMO_COUNT; ++i) {
1656 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1657 if(autocvar_hud_inventory_onlycurrent) {
1658 if(autocvar__hud_configure)
1660 if (currently_selected || autocvar__hud_configure)
1661 DrawAmmoItem(pos, mySize, i, currently_selected);
1664 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);
1669 column = column + 1;
1675 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color)
1677 vector newSize, newPos;
1678 if(mySize_x/mySize_y > 3)
1680 newSize_x = 3 * mySize_y;
1681 newSize_y = mySize_y;
1683 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1688 newSize_y = 1/3 * mySize_x;
1689 newSize_x = mySize_x;
1691 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1695 vector picpos, numpos;
1698 if(iconalign == 1 || iconalign == 3) // right align
1701 picpos = newPos + eX * 2 * newSize_y;
1705 numpos = newPos + eX * newSize_y;
1711 if(iconalign == 0 || iconalign == 3) // left align
1713 numpos = newPos + eX * newSize_y;
1719 picpos = newPos + eX * 2 * newSize_y;
1723 drawfont = hud_bigfont;
1724 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, newSize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1725 drawfont = hud_font;
1726 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1731 void HUD_Powerups(void) {
1732 float id = HUD_PANEL_POWERUPS;
1733 HUD_Panel_UpdateCvarsForId(id);
1735 stat_items = getstati(STAT_ITEMS);
1737 if(!autocvar__hud_configure)
1739 if not(stat_items & IT_STRENGTH)
1740 if not(stat_items & IT_INVINCIBLE)
1743 if (getstati(STAT_HEALTH) <= 0)
1749 mySize = panel_size;
1751 HUD_Panel_DrawBg(id, pos, mySize, 0);
1752 if(panel_bg_padding)
1754 pos += '1 1 0' * panel_bg_padding;
1755 mySize -= '2 2 0' * panel_bg_padding;
1758 float strength_time, shield_time;
1760 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1761 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1763 if(autocvar__hud_configure)
1769 vector barpos, barsize;
1773 string leftname, rightname;
1774 float leftcnt, rightcnt;
1775 float leftexact, rightexact;
1776 float leftalpha, rightalpha;
1777 if (autocvar_hud_powerups_flip) {
1778 leftname = "strength";
1779 leftcnt = ceil(strength_time);
1780 leftexact = strength_time;
1782 rightname = "shield";
1783 rightcnt = ceil(shield_time);
1784 rightexact = shield_time;
1786 leftname = "shield";
1787 leftcnt = ceil(shield_time);
1788 leftexact = shield_time;
1790 rightname = "strength";
1791 rightcnt = ceil(strength_time);
1792 rightexact = strength_time;
1794 leftalpha = bound(0, leftexact, 1);
1795 rightalpha = bound(0, rightexact, 1);
1797 if (mySize_x/mySize_y > 4)
1801 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1802 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1803 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1804 } else { // left align
1806 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1809 HUD_Panel_GetProgressBarColor(leftname)
1810 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1811 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1');
1814 // 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));
1816 // drawpic_aspect_skin(picpos, leftname, eX * (1/6) * mySize_x + eY * mySize_y, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1821 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1822 barpos = pos + eX * 0.5 * mySize_x;
1823 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1824 } else { // right align
1825 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1826 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1829 HUD_Panel_GetProgressBarColor(rightname)
1830 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1831 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');
1834 else if (mySize_x/mySize_y > 1.5)
1838 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1839 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1840 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1841 } else { // left align
1843 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1846 HUD_Panel_GetProgressBarColor(leftname)
1847 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1848 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1');
1853 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1854 barpos = pos + eY * 0.5 * mySize_y;
1855 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1856 } else { // right align
1857 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1858 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1861 HUD_Panel_GetProgressBarColor(rightname)
1862 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1863 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');
1870 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // down align
1871 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1872 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1873 } else { // up align
1875 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1878 if(autocvar_hud_powerups_iconalign == 1 || autocvar_hud_powerups_iconalign == 3) { // down align
1879 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
1880 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
1881 } else { // up align
1882 picpos = pos + eX * 0.05 * mySize_x;
1883 numpos = pos + eY * 0.4 * mySize_x;
1886 HUD_Panel_GetProgressBarColor(leftname)
1887 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1889 //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));
1891 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1892 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);
1897 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // up align
1898 barpos = pos + eX * 0.5 * mySize_x;
1899 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1900 } else { // down align
1901 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1902 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1905 if(autocvar_hud_powerups_iconalign == 0 || autocvar_hud_powerups_iconalign == 3) { // up align
1906 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1907 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1908 } else { // down align
1909 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
1910 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
1913 HUD_Panel_GetProgressBarColor(rightname)
1914 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1916 // 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));
1918 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1919 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);
1924 // Health/armor (#3)
1926 void HUD_HealthArmor(void)
1928 float id = HUD_PANEL_HEALTHARMOR;
1929 HUD_Panel_UpdateCvarsForId(id);
1932 mySize = panel_size;
1934 HUD_Panel_DrawBg(id, pos, mySize, 0);
1935 if(panel_bg_padding)
1937 pos += '1 1 0' * panel_bg_padding;
1938 mySize -= '2 2 0' * panel_bg_padding;
1941 float armor, health;
1942 armor = getstati(STAT_ARMOR);
1943 health = getstati(STAT_HEALTH);
1946 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
1948 if(autocvar__hud_configure)
1958 vector barpos, barsize;
1962 if(autocvar_hud_healtharmor == 2) // combined health and armor display
1965 v = healtharmor_maxdamage(health, armor, armorblockpercent);
1970 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
1971 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
1972 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
1973 } else { // left align
1975 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
1979 if(v_z) // NOT fully armored
1981 biggercount = "health";
1982 HUD_Panel_GetProgressBarColor("health")
1983 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1985 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);
1989 biggercount = "armor";
1990 HUD_Panel_GetProgressBarColor("armor")
1991 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1993 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);
1995 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200));
2000 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2001 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2002 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2005 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2007 HUD_Panel_GetProgressBarColor("fuel")
2008 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2013 string leftname, rightname;
2014 float leftcnt, rightcnt;
2015 float leftactive, rightactive;
2016 float leftalpha, rightalpha;
2017 if (autocvar_hud_healtharmor_flip) { // old style layout with armor left/top of health
2022 leftalpha = min((armor+10)/55, 1);
2024 rightname = "health";
2029 leftname = "health";
2034 rightname = "armor";
2038 rightalpha = min((armor+10)/55, 1);
2041 if (mySize_x/mySize_y > 4)
2045 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2046 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2047 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2048 } else { // left align
2050 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2053 HUD_Panel_GetProgressBarColor(leftname)
2054 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2055 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2060 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2061 barpos = pos + eX * 0.5 * mySize_x;
2062 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2063 } else { // right align
2064 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2065 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2068 HUD_Panel_GetProgressBarColor(rightname)
2069 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2070 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));
2075 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2076 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2077 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2080 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2082 HUD_Panel_GetProgressBarColor("fuel")
2083 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2086 else if (mySize_x/mySize_y > 1.5)
2090 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2091 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2092 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2093 } else { // left align
2095 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2098 HUD_Panel_GetProgressBarColor(leftname)
2099 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2100 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2105 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2106 barpos = pos + eY * 0.5 * mySize_y;
2107 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2108 } else { // right align
2109 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2110 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2113 HUD_Panel_GetProgressBarColor(rightname)
2114 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2115 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));
2120 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2121 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2122 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2125 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2127 HUD_Panel_GetProgressBarColor("fuel")
2128 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2135 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // down align
2136 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2137 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2138 } else { // up align
2140 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2143 if(autocvar_hud_healtharmor_iconalign == 1 || autocvar_hud_healtharmor_iconalign == 3) { // down align
2144 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2145 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2146 } else { // up align
2147 picpos = pos + eX * 0.05 * mySize_x;
2148 numpos = pos + eY * 0.4 * mySize_x;
2151 HUD_Panel_GetProgressBarColor(leftname)
2152 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2153 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2154 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);
2159 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // up align
2160 barpos = pos + eX * 0.5 * mySize_x;
2161 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2162 } else { // down align
2163 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2164 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2167 if(autocvar_hud_healtharmor_iconalign == 0 || autocvar_hud_healtharmor_iconalign == 3) { // up align
2168 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2169 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2170 } else { // down align
2171 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2172 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2175 HUD_Panel_GetProgressBarColor(rightname)
2176 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2177 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2178 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);
2183 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2185 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2187 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2188 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2190 HUD_Panel_GetProgressBarColor("fuel")
2191 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2198 // Notification area (#4)
2201 string Weapon_SuicideMessage(float deathtype)
2203 w_deathtype = deathtype;
2204 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2205 return w_deathtypestring;
2208 string Weapon_KillMessage(float deathtype)
2210 w_deathtype = deathtype;
2211 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2212 return w_deathtypestring;
2215 float killnotify_times[10];
2216 float killnotify_deathtype[10];
2217 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2218 string killnotify_attackers[10];
2219 string killnotify_victims[10];
2220 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2223 for (i = 9; i > 0; --i) {
2224 killnotify_times[i] = killnotify_times[i-1];
2225 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2226 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2227 if(killnotify_attackers[i])
2228 strunzone(killnotify_attackers[i]);
2229 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2230 if(killnotify_victims[i])
2231 strunzone(killnotify_victims[i]);
2232 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2234 killnotify_times[0] = time;
2235 killnotify_deathtype[0] = wpn;
2236 killnotify_actiontype[0] = actiontype;
2237 if(killnotify_attackers[0])
2238 strunzone(killnotify_attackers[0]);
2239 killnotify_attackers[0] = strzone(attacker);
2240 if(killnotify_victims[0])
2241 strunzone(killnotify_victims[0]);
2242 killnotify_victims[0] = strzone(victim);
2245 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2249 alsoprint = (autocvar_hud_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2251 if(msg == MSG_SUICIDE) {
2253 w = DEATH_WEAPONOF(type);
2255 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2257 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2258 } else if (type == DEATH_KILL) {
2259 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2261 print ("^1",s1, "^1 couldn't take it anymore\n");
2262 } else if (type == DEATH_ROT) {
2263 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2265 print ("^1",s1, "^1 died\n");
2266 } else if (type == DEATH_NOAMMO) {
2267 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2269 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2270 } else if (type == DEATH_CAMP) {
2271 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2273 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2274 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2275 HUD_KillNotify_Push(s1, "", 0, type);
2277 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2278 } else if (type == DEATH_CHEAT) {
2279 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2281 print ("^1",s1, "^1 unfairly eliminated themself\n");
2282 } else if (type == DEATH_FIRE) {
2283 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2285 print ("^1",s1, "^1 burned to death\n");
2286 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2287 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2289 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2292 if (stof(s2) > 2) // killcount > 2
2293 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2294 } else if(msg == MSG_KILL) {
2295 w = DEATH_WEAPONOF(type);
2297 HUD_KillNotify_Push(s2, s1, 1, w);
2299 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2301 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2302 HUD_KillNotify_Push(s1, s2, 1, type);
2305 if(cvar("cl_gentle")) {
2306 print ("^1", s1, "^1 took action against a team mate\n");
2308 print ("^1", s1, "^1 mows down a team mate\n");
2311 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2312 if(cvar("cl_gentle"))
2313 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2315 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2317 else if (stof(s2) > 2) {
2318 if(cvar("cl_gentle"))
2319 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2321 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2324 else if(type == KILL_FIRST_BLOOD)
2325 print("^1",s1, "^1 drew first blood", "\n");
2327 else if (type == DEATH_TELEFRAG)
2328 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2329 else if (type == DEATH_DROWN) {
2330 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2332 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2334 else if (type == DEATH_SLIME) {
2335 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2337 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2339 else if (type == DEATH_LAVA) {
2340 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2342 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2344 else if (type == DEATH_FALL) {
2345 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2347 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2349 else if (type == DEATH_SHOOTING_STAR) {
2350 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2352 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2354 else if (type == DEATH_SWAMP) {
2355 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2357 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2359 else if (type == DEATH_HURTTRIGGER)
2361 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2363 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2364 } else if(type == DEATH_SBCRUSH) {
2365 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2367 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2368 } else if(type == DEATH_SBMINIGUN) {
2369 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2371 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2372 } else if(type == DEATH_SBROCKET) {
2373 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2375 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2376 } else if(type == DEATH_SBBLOWUP) {
2377 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2379 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2380 } else if(type == DEATH_WAKIGUN) {
2381 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2383 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2384 } else if(type == DEATH_WAKIROCKET) {
2385 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2387 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2388 } else if(type == DEATH_WAKIBLOWUP) {
2389 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2391 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2392 } else if(type == DEATH_TURRET) {
2393 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2395 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2396 } else if(type == DEATH_TOUCHEXPLODE) {
2397 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2399 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2400 } else if(type == DEATH_CHEAT) {
2401 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2403 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2404 } else if (type == DEATH_FIRE) {
2405 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2407 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2408 } else if (type == DEATH_CUSTOM) {
2409 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2411 print ("^1",s1, "^1 ", s2, "\n");
2413 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2415 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2417 } else if(msg == MSG_SPREE) {
2418 if(type == KILL_END_SPREE) {
2419 if(cvar("cl_gentle"))
2420 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2422 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2423 } else if(type == KILL_SPREE) {
2424 if(cvar("cl_gentle"))
2425 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2427 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2428 } else if(type == KILL_SPREE_3) {
2429 if(cvar("cl_gentle"))
2430 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2432 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2433 } else if(type == KILL_SPREE_5) {
2434 if(cvar("cl_gentle"))
2435 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2437 print (s1,"^7 unleashes ^1RAGE\n");
2438 } else if(type == KILL_SPREE_10) {
2439 if(cvar("cl_gentle"))
2440 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2442 print (s1,"^7 starts the ^1MASSACRE!\n");
2443 } else if(type == KILL_SPREE_15) {
2444 if(cvar("cl_gentle"))
2445 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2447 print (s1,"^7 executes ^1MAYHEM!\n");
2448 } else if(type == KILL_SPREE_20) {
2449 if(cvar("cl_gentle"))
2450 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2452 print (s1,"^7 is a ^1BERSERKER!\n");
2453 } else if(type == KILL_SPREE_25) {
2454 if(cvar("cl_gentle"))
2455 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2457 print (s1,"^7 inflicts ^1CARNAGE!\n");
2458 } else if(type == KILL_SPREE_30) {
2459 if(cvar("cl_gentle"))
2460 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2462 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2464 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2465 if (type == DEATH_DROWN) {
2466 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2469 if(cvar("cl_gentle"))
2470 print ("^1",s1, "^1 was in the water for too long\n");
2472 print ("^1",s1, "^1 drowned\n");
2474 } else if (type == DEATH_SLIME) {
2475 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2477 print ("^1",s1, "^1 was slimed\n");
2478 } else if (type == DEATH_LAVA) {
2479 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2482 if(cvar("cl_gentle"))
2483 print ("^1",s1, "^1 found a hot place\n");
2485 print ("^1",s1, "^1 turned into hot slag\n");
2487 } else if (type == DEATH_FALL) {
2488 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2491 if(cvar("cl_gentle"))
2492 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2494 print ("^1",s1, "^1 hit the ground with a crunch\n");
2496 } else if (type == DEATH_SHOOTING_STAR) {
2497 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2499 print ("^1",s1, "^1 became a shooting star\n");
2500 } else if (type == DEATH_SWAMP) {
2501 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2504 if(cvar("cl_gentle"))
2505 print ("^1",s1, "^1 discovered a swamp\n");
2507 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2509 } else if(type == DEATH_TURRET) {
2510 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2512 print ("^1",s1, "^1 was mowed down by a turret \n");
2513 } else if (type == DEATH_CUSTOM) {
2514 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2516 print ("^1",s1, "^1 ", s2, "\n");
2517 } else if (type == DEATH_HURTTRIGGER) {
2518 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2520 print ("^1",s1, "^1 was in the wrong place\n");
2521 } else if(type == DEATH_TOUCHEXPLODE) {
2522 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2524 print ("^1",s1, "^1 died in an accident\n");
2525 } else if(type == DEATH_CHEAT) {
2526 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2528 print ("^1",s1, "^1 was unfairly eliminated\n");
2529 } else if(type == DEATH_FIRE) {
2530 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2533 if(cvar("cl_gentle"))
2534 print ("^1",s1, "^1 felt a little hot\n");
2536 print ("^1",s1, "^1 burnt to death\n");
2539 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2542 if(cvar("cl_gentle"))
2543 print ("^1",s1, "^1 needs a restart\n");
2545 print ("^1",s1, "^1 died\n");
2548 } else if(msg == MSG_KILL_ACTION_SPREE) {
2549 if(cvar("cl_gentle"))
2550 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2552 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2553 } else if(msg == MSG_INFO) {
2554 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2555 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2556 print(s1, "^7 got the ", s2, "\n");
2557 } else if(type == INFO_LOSTFLAG) {
2558 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2559 print(s1, "^7 lost the ", s2, "\n");
2560 } else if(type == INFO_PICKUPFLAG) {
2561 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2562 print(s1, "^7 picked up the ", s2, "\n");
2563 } else if(type == INFO_RETURNFLAG) {
2564 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2565 print(s1, "^7 returned the ", s2, "\n");
2570 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2572 void HUD_Centerprint(string s1, string s2, float type, float msg)
2574 if(msg == MSG_SUICIDE) {
2575 if (type == DEATH_TEAMCHANGE) {
2576 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2577 } else if (type == DEATH_AUTOTEAMCHANGE) {
2578 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2579 } else if (type == DEATH_CAMP) {
2580 if(cvar("cl_gentle"))
2581 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2583 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2584 } else if (type == DEATH_NOAMMO) {
2585 if(cvar("cl_gentle"))
2586 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2588 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2589 } else if (type == DEATH_ROT) {
2590 if(cvar("cl_gentle"))
2591 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2593 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2594 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2595 if(cvar("cl_gentle"))
2596 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2598 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2599 } else if (type == DEATH_QUIET) {
2601 } else if (type == DEATH_KILL) {
2602 if(cvar("cl_gentle"))
2603 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2605 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2607 } else if(msg == MSG_KILL) {
2608 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2609 if(cvar("cl_gentle")) {
2610 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2612 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2614 } else if (type == KILL_FIRST_BLOOD) {
2615 if(cvar("cl_gentle")) {
2616 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2618 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2620 } else if (type == KILL_FIRST_VICTIM) {
2621 if(cvar("cl_gentle")) {
2622 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2624 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2626 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2627 if(cvar("cl_gentle")) {
2628 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2630 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2632 } else if (type == KILL_TYPEFRAGGED) {
2633 if(cvar("cl_gentle")) {
2634 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2636 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2638 } else if (type == KILL_FRAG) {
2639 if(cvar("cl_gentle")) {
2640 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2642 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2644 } else if (type == KILL_FRAGGED) {
2645 if(cvar("cl_gentle")) {
2646 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2648 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2651 } else if(msg == MSG_KILL_ACTION) {
2652 // TODO: invent more centerprints here?
2653 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2657 void HUD_Notify (void)
2659 float id = HUD_PANEL_NOTIFY;
2660 HUD_Panel_UpdateCvarsForId(id);
2663 mySize = panel_size;
2665 HUD_Panel_DrawBg(id, pos, mySize, 0);
2666 if(panel_bg_padding)
2668 pos += '1 1 0' * panel_bg_padding;
2669 mySize -= '2 2 0' * panel_bg_padding;
2672 float entries, height;
2673 entries = bound(1, floor(14 * mySize_y/mySize_x), 12);
2674 height = mySize_y/entries;
2675 entries -= 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2678 fontsize = '0.5 0.5 0' * height;
2682 when = autocvar_hud_notify_time;
2684 fadetime = autocvar_hud_notify_fadetime;
2688 vector pos_attacker, pos_victim;
2690 float width_attacker, width_victim;
2691 string attacker, victim;
2694 for(j = 0; j < entries; ++j)
2696 if(autocvar_hud_notify_flip)
2698 else // rather nasty hack for ordering items from the bottom up
2699 i = entries - j - 1;
2700 if(autocvar_hud_notify_info_top)
2701 i += 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2705 if(killnotify_times[j] + when > time)
2708 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2712 if(killnotify_times[j] + when > time)
2718 // TODO: maybe print in team colors?
2719 // TODO: maybe this could be cleaned up somehow...
2720 // TODO: less copypaste code below
2723 if(killnotify_actiontype[j] == 0 && !autocvar__hud_configure)
2725 attacker = textShortenToWidth(killnotify_attackers[j], mySize_x - 2 * height, fontsize, stringwidth_colors);
2727 width_attacker = stringwidth(attacker, TRUE, fontsize);
2728 pos_attacker = pos + eX * 0.5 * (mySize_x - width_attacker + 2 * height) + eY * 0.5 * fontsize_y + eY * i * height;
2730 weap_pos = pos + eX * 0.5 * (mySize_x - width_attacker) - eX * height + eY * i * height;
2731 if(killnotify_deathtype[j] == DEATH_GENERIC)
2733 drawpic_aspect_skin(weap_pos, "notify_death", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2734 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2736 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2738 drawpic_aspect_skin(weap_pos, "notify_outofammo", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2739 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2741 else if(killnotify_deathtype[j] == DEATH_KILL)
2743 drawpic_aspect_skin(weap_pos, "notify_selfkill", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2744 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2746 else if(killnotify_deathtype[j] == DEATH_CAMP)
2748 drawpic_aspect_skin(weap_pos, "notify_camping", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2749 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2751 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2753 drawpic_aspect_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2754 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2756 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2758 drawpic_aspect_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2759 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2761 else if(killnotify_deathtype[j] == DEATH_DROWN)
2763 drawpic_aspect_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2764 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2766 else if(killnotify_deathtype[j] == DEATH_SLIME)
2768 drawpic_aspect_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2769 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2771 else if(killnotify_deathtype[j] == DEATH_LAVA)
2773 drawpic_aspect_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2774 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2776 else if(killnotify_deathtype[j] == DEATH_FALL)
2778 drawpic_aspect_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2779 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2781 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2783 drawpic_aspect_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2784 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2786 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2788 drawpic_aspect_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2789 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2791 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2793 if(killnotify_victims[j] == "^1RED^7 flag")
2797 drawpic_aspect_skin(weap_pos, strcat("flag_", s, "_carrying"), '1 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2798 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2800 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2802 if(killnotify_victims[j] == "^1RED^7 flag")
2806 drawpic_aspect_skin(weap_pos, strcat("flag_", s, "_taken"), '1 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2807 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2809 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2811 if(killnotify_victims[j] == "^1RED^7 flag")
2815 drawpic_aspect_skin(weap_pos, strcat("flag_", s, "_lost"), '1 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2816 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2819 // X [did action to] Y
2822 if(autocvar__hud_configure)
2824 attacker = textShortenToWidth("Player1", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2825 victim = textShortenToWidth("Player2", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2826 a = bound(0, (when - j) / 4, 1);
2830 attacker = textShortenToWidth(killnotify_attackers[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2831 victim = textShortenToWidth(killnotify_victims[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2833 width_attacker = stringwidth(attacker, TRUE, fontsize);
2834 width_victim = stringwidth(victim, TRUE, fontsize);
2835 pos_attacker = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_attacker) + eY * 0.5 * fontsize_y + eY * i * height;
2836 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;
2837 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2839 if(autocvar__hud_configure) // example actions for config mode
2841 drawpic_aspect_skin(weap_pos, strcat("weapon", "electro"), '2 1 0' * height, '1 1 1', 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(WEP_VALID(killnotify_deathtype[j]))
2847 self = get_weaponinfo(killnotify_deathtype[j]);
2848 drawpic_aspect_skin(weap_pos, strcat("weapon", self.netname), '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2849 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2850 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2852 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2854 drawpic_aspect_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2855 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2856 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2858 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2860 drawpic_aspect_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2861 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2862 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2864 else if(killnotify_deathtype[j] == DEATH_DROWN)
2866 drawpic_aspect_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2867 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2868 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2870 else if(killnotify_deathtype[j] == DEATH_SLIME)
2872 drawpic_aspect_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2873 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2874 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2876 else if(killnotify_deathtype[j] == DEATH_LAVA)
2878 drawpic_aspect_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2879 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2880 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2882 else if(killnotify_deathtype[j] == DEATH_FALL)
2884 drawpic_aspect_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2885 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2886 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2888 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2890 drawpic_aspect_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2891 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2892 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2894 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2896 drawpic_aspect_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2897 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2898 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2904 // TODO: separate panel for these?
2910 if(autocvar_hud_notify_info_top)
2913 o = pos + eY * mySize_y - eY * 2 * height;
2915 if(spectatee_status && !intermission)
2917 //drawfont = hud_bigfont;
2918 if(spectatee_status == -1)
2921 s = GetPlayerName(spectatee_status - 1);
2923 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
2924 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, panel_fg_alpha, DRAWFLAG_NORMAL);
2925 //drawfont = hud_font;
2927 // spectator text in the upper right corner
2928 if(spectatee_status == -1)
2929 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
2931 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
2932 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2933 o += eY * fontsize_y;
2935 if(spectatee_status == -1)
2936 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
2938 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
2939 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2940 o += eY * fontsize_y;
2942 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
2943 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2944 o += eY * fontsize_y;
2946 if(gametype == GAME_ARENA)
2947 s = "^1Wait for your turn to join";
2948 else if(gametype == GAME_LMS)
2951 sk = playerslots[player_localentnum - 1];
2952 if(sk.(scores[ps_primary]) >= 666)
2953 s = "^1Match has already begun";
2954 else if(sk.(scores[ps_primary]) > 0)
2955 s = "^1You have no more lives left";
2957 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
2960 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
2961 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2962 o += eY * fontsize_y;
2964 //show restart countdown:
2965 if (time < getstatf(STAT_GAMESTARTTIME)) {
2967 //we need to ceil, otherwise the countdown would be off by .5 when using round()
2968 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
2969 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
2970 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2971 o += eY * fontsize_y;
2974 if(warmup_stage && !intermission)
2976 s = "^2Currently in ^1warmup^2 stage!";
2977 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2978 o += eY * fontsize_y;
2982 if(mod(time, 1) >= 0.5)
2987 if(ready_waiting && !intermission && !spectatee_status)
2989 if(ready_waiting_for_me)
2992 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
2994 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
2999 s = strcat("^2Waiting for others to ready up to end warmup...");
3001 s = strcat("^2Waiting for others to ready up...");
3003 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3004 o += eY * fontsize_y;
3006 else if(warmup_stage && !intermission && !spectatee_status)
3008 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
3009 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3010 o += eY * fontsize_y;
3013 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
3015 float ts_min, ts_max;
3016 tm = teams.sort_next;
3019 for(; tm.sort_next; tm = tm.sort_next)
3021 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
3023 if(!ts_min) ts_min = tm.team_size;
3024 else ts_min = min(ts_min, tm.team_size);
3025 if(!ts_max) ts_max = tm.team_size;
3026 else ts_max = max(ts_max, tm.team_size);
3028 if ((ts_max - ts_min) > 1)
3030 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
3031 tm = GetTeam(myteam, false);
3033 if (tm.team != COLOR_SPECTATOR)
3034 if (tm.team_size == ts_max)
3035 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
3037 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3038 o += eY * fontsize_y;
3042 if(autocvar__hud_configure)
3044 s = "^7Press ^3ESC ^7to show HUD options.";
3045 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3046 o += eY * fontsize_y;
3047 s = "^3Doubleclick a panel for panel-specific options.";
3048 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3049 o += eY * fontsize_y;
3055 string seconds_tostring(float sec)
3058 minutes = floor(sec / 60);
3060 sec -= minutes * 60;
3063 s = ftos(100 + sec);
3065 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3068 void HUD_Timer(void)
3070 float id = HUD_PANEL_TIMER;
3071 HUD_Panel_UpdateCvarsForId(id);
3074 mySize = panel_size;
3076 HUD_Panel_DrawBg(id, pos, mySize, 0);
3077 if(panel_bg_padding)
3079 pos += '1 1 0' * panel_bg_padding;
3080 mySize -= '2 2 0' * panel_bg_padding;
3084 float timelimit, elapsedTime, timeleft, minutesLeft;
3086 timelimit = getstatf(STAT_TIMELIMIT);
3088 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3089 timeleft = ceil(timeleft);
3091 minutesLeft = floor(timeleft / 60);
3094 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3095 timer_color = '1 1 1'; //white
3096 else if(minutesLeft >= 1)
3097 timer_color = '1 1 0'; //yellow
3099 timer_color = '1 0 0'; //red
3101 if (autocvar_hud_timer_increment || timelimit == 0 || warmup_stage) {
3102 if (time < getstatf(STAT_GAMESTARTTIME)) {
3103 //while restart is still active, show 00:00
3104 timer = seconds_tostring(0);
3106 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3107 timer = seconds_tostring(elapsedTime);
3110 timer = seconds_tostring(timeleft);
3113 drawfont = hud_bigfont;
3114 drawstring_aspect(pos, timer, mySize, mySize_y, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3115 drawfont = hud_font;
3120 void HUD_Radar(void)
3122 float id = HUD_PANEL_RADAR;
3123 HUD_Panel_UpdateCvarsForId(id);
3126 mySize = panel_size;
3128 HUD_Panel_DrawBg(id, pos, mySize, 0);
3129 if(panel_bg_padding)
3131 pos += '1 1 0' * panel_bg_padding;
3132 mySize -= '2 2 0' * panel_bg_padding;
3135 local float color1, color2; // color already declared as a global in hud.qc
3138 float scale2d, normalsize, bigsize;
3141 teamradar_origin2d = pos + 0.5 * mySize;
3142 teamradar_size2d = mySize;
3144 if(minimapname == "")
3147 teamradar_loadcvars();
3149 switch(hud_radar_zoommode)
3153 f = current_zoomfraction;
3156 f = 1 - current_zoomfraction;
3166 switch(hud_radar_rotation)
3169 teamradar_angle = view_angles_y - 90;
3172 teamradar_angle = 90 * hud_radar_rotation;
3176 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3177 teamradar_size2d = mySize;
3179 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3181 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3182 if(hud_radar_rotation == 0)
3184 // max-min distance must fit the radar in any rotation
3185 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3189 vector c0, c1, c2, c3, span;
3190 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3191 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3192 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3193 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3195 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3196 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3198 // max-min distance must fit the radar in x=x, y=y
3200 teamradar_size2d_x * scale2d / (1.05 * span_x),
3201 teamradar_size2d_y * scale2d / (1.05 * span_y)
3205 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3206 if(bigsize > normalsize)
3207 normalsize = bigsize;
3211 + (1 - f) * normalsize;
3212 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3213 f * (mi_min + mi_max) * 0.5
3214 + (1 - f) * view_origin);
3216 color1 = GetPlayerColor(player_localentnum-1);
3217 rgb = GetTeamRGB(color1);
3226 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3228 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3229 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3230 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3231 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3232 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3234 color2 = GetPlayerColor(tm.sv_entnum);
3235 //if(color == COLOR_SPECTATOR || color == color2)
3236 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3238 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3240 drawresetcliparea();
3245 void HUD_Score(void)
3247 float id = HUD_PANEL_SCORE;
3248 HUD_Panel_UpdateCvarsForId(id);
3251 mySize = panel_size;
3253 HUD_Panel_DrawBg(id, pos, mySize, 0);
3254 if(panel_bg_padding)
3256 pos += '1 1 0' * panel_bg_padding;
3257 mySize -= '2 2 0' * panel_bg_padding;
3260 float score, distribution, leader;
3262 vector distribution_color;
3264 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3266 // TODO... this (race part) still uses constant coordinates :/
3267 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3268 /*pl = players.sort_next;
3271 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3272 if(pl.scores[ps_primary] == 0)
3275 score = me.(scores[ps_primary]);
3277 float racemin, racesec, racemsec;
3278 float distsec, distmsec, minusplus;
3280 racemin = floor(score/(60 * TIME_FACTOR));
3281 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
3282 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
3284 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3285 // distribution display
3286 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3288 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
3289 distmsec = fabs(distribution);
3291 distsec = floor(fabs(distribution)/TIME_FACTOR);
3292 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
3293 if (distribution < 0)
3297 if (distribution <= 0) {
3298 distribution_color = eY;
3299 minusplus = 1; // minusplus 1: always prefix with minus sign
3302 distribution_color = eX;
3303 minusplus = 2; // minusplus 1: always prefix with plus sign
3305 //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);
3306 //HUD_DrawXNum(bottomright - '68 48 0' - '16 0 0' * TIME_DECIMALS, distsec, 4, minusplus, 16, distribution_color, 0, 0, panel_fg_alpha, DRAWFLAG_NORMAL);
3307 drawpic_aspect_skin(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "num_dot", '16 16 0', distribution_color, panel_fg_alpha, DRAWFLAG_ADDITIVE);
3309 // race record display
3310 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
3311 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);
3313 //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);
3314 //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);
3315 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);
3317 //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);
3318 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);
3320 } else if (!teamplay) { // non-teamgames
3321 // me vector := [team/connected frags id]
3322 pl = players.sort_next;
3326 if(autocvar__hud_configure)
3329 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3333 score = me.(scores[ps_primary]);
3334 if(autocvar__hud_configure)
3337 if(distribution >= 5) {
3338 distribution_color = eY;
3340 } else if(distribution >= 0) {
3341 distribution_color = '1 1 1';
3343 } else if(distribution >= -5)
3344 distribution_color = '1 1 0';
3346 distribution_color = eX;
3348 score_len = strlen(ftos(score));
3350 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);
3352 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);
3353 drawfont = hud_bigfont;
3354 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3355 drawfont = hud_font;
3356 } else { // teamgames
3357 float max_fragcount;
3358 max_fragcount = -99;
3361 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3362 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !autocvar__hud_configure)) // no players? don't display
3364 score = tm.(teamscores[ts_primary]);
3365 if(autocvar__hud_configure)
3369 score_len = strlen(ftos(score));
3371 if (score > max_fragcount)
3372 max_fragcount = score;
3374 if(tm.team == myteam) {
3375 if (max_fragcount == score)
3378 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);
3379 drawfont = hud_bigfont;
3380 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);
3381 drawfont = hud_font;
3383 if (max_fragcount == score)
3386 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);
3387 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);
3396 void HUD_RaceTimer (void) {
3397 float id = HUD_PANEL_RACETIMER;
3398 HUD_Panel_UpdateCvarsForId(id);
3401 mySize = panel_size;
3403 HUD_Panel_DrawBg(id, pos, mySize, 0);
3404 if(panel_bg_padding)
3406 pos += '1 1 0' * panel_bg_padding;
3407 mySize -= '2 2 0' * panel_bg_padding;
3410 // always force 2:1 aspect
3412 if(mySize_x/mySize_y > 2)
3414 newSize_x = 2 * mySize_y;
3415 newSize_y = mySize_y;
3417 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3421 newSize_y = 1/2 * mySize_x;
3422 newSize_x = mySize_x;
3424 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3428 drawfont = hud_bigfont;
3430 string s, forcetime;
3432 if(autocvar__hud_configure)
3435 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);
3436 s = "^1Intermediate 1 (+15.42)";
3437 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);
3438 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3439 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);
3441 else if(race_checkpointtime)
3443 a = bound(0, 2 - (time - race_checkpointtime), 1);
3446 if(a > 0) // just hit a checkpoint?
3448 if(race_checkpoint != 254)
3450 if(race_time && race_previousbesttime)
3451 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3453 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3455 forcetime = TIME_ENCODED_TOSTRING(race_time);
3460 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3462 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3463 if(a > 0) // next one?
3465 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3470 if(s != "" && a > 0)
3472 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3473 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3474 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);
3477 if(race_penaltytime)
3479 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3482 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3483 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3484 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3485 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);
3491 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3492 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', panel_fg_alpha, 0, a);
3493 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);
3498 if(race_laptime && race_checkpoint != 255)
3500 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3501 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3502 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);
3507 if(race_mycheckpointtime)
3509 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3510 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3511 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3512 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3513 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);
3515 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3517 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3518 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3519 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3520 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3521 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);
3524 if(race_penaltytime && !race_penaltyaccumulator)
3526 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3527 a = bound(0, (1 + t - time), 1);
3531 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3533 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3534 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3535 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3536 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);
3541 drawfont = hud_font;
3546 float vote_yescount;
3549 float vote_highlighted; // currently selected vote
3551 float vote_active; // is there an active vote?
3552 float vote_prev; // previous state of vote_active to check for a change
3554 float vote_change; // "time" when vote_active changed
3556 void HUD_VoteWindow(void)
3558 float id = HUD_PANEL_VOTE;
3559 HUD_Panel_UpdateCvarsForId(id);
3562 mySize = panel_size;
3566 if(vote_active != vote_prev) {
3568 vote_prev = vote_active;
3571 if(vote_active || autocvar__hud_configure)
3572 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3574 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3576 if(autocvar__hud_configure)
3586 a = vote_alpha * bound(autocvar_hud_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3588 HUD_Panel_DrawBg(id, pos, mySize, a);
3589 if(panel_bg_padding)
3591 pos += '1 1 0' * panel_bg_padding;
3592 mySize -= '2 2 0' * panel_bg_padding;
3595 // always force 2:1 aspect
3597 if(mySize_x/mySize_y > 2)
3599 newSize_x = 2 * mySize_y;
3600 newSize_y = mySize_y;
3602 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3606 newSize_y = 1/2 * mySize_x;
3607 newSize_x = mySize_x;
3609 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3613 drawpic_aspect_skin(pos, "voteprogress_back", mySize, '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3615 s = "A vote has been called for: ";
3616 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);
3617 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (3/12), stringwidth_colors); // TODO: broken?
3618 if(autocvar__hud_configure)
3619 s = "Configure the HUD";
3620 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);
3622 // print the yes/no counts
3623 s = strcat("Yes: ", ftos(vote_yescount));
3624 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);
3625 s = strcat("No: ", ftos(vote_nocount));
3626 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);
3628 // draw the progress bars
3629 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3630 drawpic_aspect_skin(pos, "voteprogress_prog", mySize, eY, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3632 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3633 drawpic_aspect_skin(pos, "voteprogress_prog", mySize, eX, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3635 // draw the highlights
3636 if(vote_highlighted == 1) {
3637 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3638 drawpic_aspect_skin(pos, "voteprogress_voted", mySize, eY, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3640 else if(vote_highlighted == 2) {
3641 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3642 drawpic_aspect_skin(pos, "voteprogress_voted", mySize, eX, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3645 drawresetcliparea();
3648 vote_highlighted = 0;
3652 // Mod icons panel (#10)
3655 float mod_active; // is there any active mod icon?
3657 // CTF HUD modicon section
3658 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3659 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3660 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3662 void HUD_Mod_CTF_Reset(void)
3664 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3667 void HUD_Mod_CTF(vector pos, vector mySize)
3669 vector redflag_pos, blueflag_pos;
3671 float f; // every function should have that
3673 float redflag, blueflag; // current status
3674 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3677 stat_items = getstati(STAT_ITEMS);
3678 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3679 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3681 if(redflag || blueflag)
3686 if(autocvar__hud_configure)
3692 // when status CHANGES, set old status into prevstatus and current status into status
3693 if (redflag != redflag_prevframe)
3695 redflag_statuschange_time = time;
3696 redflag_prevstatus = redflag_prevframe;
3697 redflag_prevframe = redflag;
3700 if (blueflag != blueflag_prevframe)
3702 blueflag_statuschange_time = time;
3703 blueflag_prevstatus = blueflag_prevframe;
3704 blueflag_prevframe = blueflag;
3707 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3708 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3710 float BLINK_FACTOR = 0.15;
3711 float BLINK_BASE = 0.85;
3713 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3715 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3717 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3719 string red_icon, red_icon_prevstatus;
3720 float red_alpha, red_alpha_prevstatus;
3721 red_alpha = red_alpha_prevstatus = 1;
3723 case 1: red_icon = "flag_red_taken"; break;
3724 case 2: red_icon = "flag_red_lost"; break;
3725 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3727 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3728 red_icon = "flag_red_shielded";
3730 red_icon = string_null;
3733 switch(redflag_prevstatus) {
3734 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3735 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3736 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3739 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3740 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3741 red_icon_prevstatus = "flag_red_shielded";
3743 red_icon_prevstatus = string_null;
3747 string blue_icon, blue_icon_prevstatus;
3748 float blue_alpha, blue_alpha_prevstatus;
3749 blue_alpha = blue_alpha_prevstatus = 1;
3751 case 1: blue_icon = "flag_blue_taken"; break;
3752 case 2: blue_icon = "flag_blue_lost"; break;
3753 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3755 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3756 blue_icon = "flag_blue_shielded";
3758 blue_icon = string_null;
3761 switch(blueflag_prevstatus) {
3762 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3763 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3764 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3767 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3768 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3769 blue_icon_prevstatus = "flag_blue_shielded";
3771 blue_icon_prevstatus = string_null;
3775 if(mySize_x > mySize_y) {
3776 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3778 blueflag_pos = pos + eX * 0.5 * mySize_x;
3781 redflag_pos = pos + eX * 0.5 * mySize_x;
3783 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3785 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3787 blueflag_pos = pos + eY * 0.5 * mySize_y;
3790 redflag_pos = pos + eY * 0.5 * mySize_y;
3792 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3795 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3796 if(red_icon_prevstatus && f < 1)
3797 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3799 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3801 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3802 if(blue_icon_prevstatus && f < 1)
3803 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3805 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3808 // Keyhunt HUD modicon section
3809 float kh_runheretime;
3811 void HUD_Mod_KH_Reset(void)
3816 void HUD_Mod_KH(vector pos, vector mySize)
3818 mod_active = 1; // keyhunt should never hide the mod icons panel
3822 vector p, pa, kh_size, kh_asize;
3824 kh_keys = getstati(STAT_KH_KEYS);
3827 if(mySize_x > mySize_y)
3829 p_y = pos_y + 0.25 * mySize_y;
3830 pa = p - eY * 0.25 * mySize_y;
3832 kh_size_x = mySize_x * 0.25;
3833 kh_size_y = 0.75 * mySize_y;
3834 kh_asize_x = mySize_x * 0.25;
3835 kh_asize_y = mySize_y * 0.25;
3839 p_y = pos_y + 0.125 * mySize_y;
3840 pa = p - eY * 0.125 * mySize_y;
3842 kh_size_x = mySize_x * 0.5;
3843 kh_size_y = 0.375 * mySize_y;
3844 kh_asize_x = mySize_x * 0.5;
3845 kh_asize_y = mySize_y * 0.125;
3852 for(i = 0; i < 4; ++i)
3854 key = floor(kh_keys / pow(32, i)) & 31;
3856 if(keyteam == 30 && keycount <= 4)
3858 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3862 // this yields 8 exactly if "RUN HERE" shows
3867 kh_runheretime = time;
3868 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3873 for(i = 0; i < 4; ++i)
3875 key = floor(kh_keys / pow(32, i)) & 31;
3888 default: // owned or dropped
3893 a = a * panel_fg_alpha;
3894 aa = aa * panel_fg_alpha;
3900 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3903 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3906 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3909 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3914 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3917 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3920 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3923 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3926 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3930 if(mySize_x > mySize_y)
3932 p_x += 0.25 * mySize_x;
3933 pa_x += 0.25 * mySize_x;
3939 p_y = pos_y + 0.625 * mySize_y;
3940 pa_y = pos_y + 0.5 * mySize_y;
3946 p_x += 0.5 * mySize_x;
3947 pa_x += 0.5 * mySize_x;
3953 // Nexball HUD mod icon
3954 void HUD_Mod_NexBall(vector pos, vector mySize)
3956 float stat_items, nb_pb_starttime, dt, p;
3958 stat_items = getstati(STAT_ITEMS);
3959 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3961 if (stat_items & IT_KEY1)
3966 //Manage the progress bar if any
3967 if (nb_pb_starttime > 0)
3969 dt = mod(time - nb_pb_starttime, nb_pb_period);
3970 // one period of positive triangle
3971 p = 2 * dt / nb_pb_period;
3978 if(mySize_x > mySize_y)
3980 barsize = eX * p * mySize_x + eY * mySize_y;
3985 barsize = eX * mySize_x + eY * p * mySize_y;
3988 HUD_Panel_GetProgressBarColor("nexball")
3989 HUD_Panel_DrawProgressBar(pos, vertical, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3992 if (stat_items & IT_KEY1)
3993 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3996 // Race/CTS HUD mod icons
3997 float crecordtime_prev; // last remembered crecordtime
3998 float crecordtime_change_time; // time when crecordtime last changed
3999 float srecordtime_prev; // last remembered srecordtime
4000 float srecordtime_change_time; // time when srecordtime last changed
4002 float race_status_time;
4003 float race_status_prev;
4004 string race_status_name_prev;
4005 void HUD_Mod_Race(vector pos, vector mySize)
4007 mod_active = 1; // race should never hide the mod icons panel
4009 me = playerslots[player_localentnum - 1];
4011 float f; // yet another function has this
4012 score = me.(scores[ps_primary]);
4014 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
4015 return; // no records in the actual race
4017 drawfont = hud_bigfont;
4019 // clientside personal record
4021 if(gametype == GAME_CTS)
4025 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4027 if(score && (score < t || !t)) {
4028 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4029 if(cvar("cl_autodemo_delete_keeprecords"))
4031 f = cvar("cl_autodemo_delete");
4033 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4037 if(t != crecordtime_prev) {
4038 crecordtime_prev = t;
4039 crecordtime_change_time = time;
4041 f = time - crecordtime_change_time;
4044 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);
4045 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);
4047 drawstring(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4048 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);
4049 drawstring_expanding(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4050 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);
4054 t = race_server_record;
4055 if(t != srecordtime_prev) {
4056 srecordtime_prev = t;
4057 srecordtime_change_time = time;
4059 f = time - srecordtime_change_time;
4062 drawstring(pos + eY * 0.5 * mySize_y, "Server best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4063 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);
4065 drawstring(pos + eY * 0.5 * mySize_y, "Server best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4066 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);
4067 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);
4068 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);
4071 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4072 race_status_time = time + 5;
4073 race_status_prev = race_status;
4074 if (race_status_name_prev)
4075 strunzone(race_status_name_prev);
4076 race_status_name_prev = strzone(race_status_name);
4079 pos_x += mySize_x/2;
4082 a = bound(0, race_status_time - time, 1);
4085 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4089 rank = race_CheckName(race_status_name);
4091 rankname = race_PlaceName(rank);
4094 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4096 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4098 if(race_status == 0)
4099 drawpic_aspect_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4100 else if(race_status == 1) {
4101 drawpic_aspect_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4102 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4103 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4104 } else if(race_status == 2) {
4105 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4106 drawpic_aspect_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4108 drawpic_aspect_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4109 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4110 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4111 } else if(race_status == 3) {
4112 drawpic_aspect_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4113 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4114 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4117 if (race_status_time - time <= 0) {
4118 race_status_prev = -1;
4120 if(race_status_name)
4121 strunzone(race_status_name);
4122 race_status_name = string_null;
4123 if(race_status_name_prev)
4124 strunzone(race_status_name_prev);
4125 race_status_name_prev = string_null;
4127 drawfont = hud_font;
4130 float mod_prev; // previous state of mod_active to check for a change
4132 float mod_change; // "time" when mod_active changed
4134 void HUD_ModIcons(void)
4136 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !autocvar__hud_configure)
4139 float id = HUD_PANEL_MODICONS;
4140 HUD_Panel_UpdateCvarsForId(id);
4143 mySize = panel_size;
4145 if(mod_active != mod_prev) {
4147 mod_prev = mod_active;
4150 if(mod_active || autocvar__hud_configure)
4151 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4153 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4156 HUD_Panel_DrawBg(id, pos, mySize, mod_alpha);
4158 if(panel_bg_padding)
4160 pos += '1 1 0' * panel_bg_padding;
4161 mySize -= '2 2 0' * panel_bg_padding;
4164 // these MUST be ran in order to update mod_active
4165 if(gametype == GAME_KEYHUNT)
4166 HUD_Mod_KH(pos, mySize);
4167 else if(gametype == GAME_CTF || autocvar__hud_configure)
4168 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4169 else if(gametype == GAME_NEXBALL)
4170 HUD_Mod_NexBall(pos, mySize);
4171 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4172 HUD_Mod_Race(pos, mySize);
4175 // Draw pressed keys (#11)
4177 void HUD_DrawPressedKeys(void)
4179 float id = HUD_PANEL_PRESSEDKEYS;
4180 HUD_Panel_UpdateCvarsForId(id);
4183 mySize = panel_size;
4185 HUD_Panel_DrawBg(id, pos, mySize, 0);
4186 if(panel_bg_padding)
4188 pos += '1 1 0' * panel_bg_padding;
4189 mySize -= '2 2 0' * panel_bg_padding;
4193 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4196 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4197 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4198 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);
4199 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);
4200 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);
4201 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);
4202 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);
4205 // Handle chat as a panel (#12)
4209 float id = HUD_PANEL_CHAT;
4210 HUD_Panel_UpdateCvarsForId(id);
4213 mySize = panel_size;
4215 HUD_Panel_DrawBg(id, pos, mySize, 0);
4216 if(panel_bg_padding)
4218 pos += '1 1 0' * panel_bg_padding;
4219 mySize -= '2 2 0' * panel_bg_padding;
4222 cvar_set("con_chatrect", "1");
4224 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4225 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4227 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4228 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4230 if(autocvar__hud_configure)
4233 chatsize = cvar("con_chatsize");
4234 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4236 for(i = 0; i < cvar("con_chat"); ++i)
4238 if(i == cvar("con_chat") - 1)
4241 a = panel_fg_alpha * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4242 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);
4247 // Engine info panel (#13)
4254 float frametimeavg1; // 1 frame ago
4255 float frametimeavg2; // 2 frames ago
4256 void HUD_EngineInfo(void)
4258 float id = HUD_PANEL_ENGINEINFO;
4259 HUD_Panel_UpdateCvarsForId(id);
4262 mySize = panel_size;
4264 HUD_Panel_DrawBg(id, pos, mySize, 0);
4265 if(panel_bg_padding)
4267 pos += '1 1 0' * panel_bg_padding;
4268 mySize -= '2 2 0' * panel_bg_padding;
4271 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4273 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4274 frametimeavg2 = frametimeavg1;
4275 frametimeavg1 = frametimeavg;
4278 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4279 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.
4281 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
4282 prevfps = (1/frametime);
4283 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"
4289 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4291 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4293 prevfps_time = time;
4298 color = HUD_Get_Num_Color (prevfps, 100);
4299 drawfont = hud_bigfont;
4300 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), mySize, mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4301 drawfont = hud_font;
4309 void HUD_ShowSpeed(void)
4312 float pos, conversion_factor;
4313 string speed, zspeed, unit;
4315 switch(cvar("cl_showspeed_unit"))
4320 conversion_factor = 1.0;
4324 conversion_factor = 1.0;
4328 conversion_factor = 0.0254;
4332 conversion_factor = 0.0254 * 3.6;
4336 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4340 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4344 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4346 numsize_x = numsize_y = cvar("cl_showspeed_size");
4347 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4349 drawfont = hud_bigfont;
4350 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4352 if (cvar("cl_showspeed_z") == 1) {
4353 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4354 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4357 drawfont = hud_font;
4360 vector acc_prevspeed;
4364 void HUD_ShowAcceleration(void)
4366 float acceleration, sz, scale, alpha, f;
4367 vector pos, top, rgb;
4368 top_x = vid_conwidth/2;
4371 f = time - acc_prevtime;
4372 if(cvar("cl_showacceleration_z"))
4373 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4375 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4376 acc_prevspeed = pmove_vel;
4377 acc_prevtime = time;
4379 f = bound(0, f * 10, 1);
4380 acc_avg = acc_avg * (1 - f) + acceleration * f;
4381 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4383 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4385 sz = cvar("cl_showacceleration_size");
4386 scale = cvar("cl_showacceleration_scale");
4387 alpha = cvar("cl_showacceleration_alpha");
4388 if (cvar("cl_showacceleration_color_custom"))
4389 rgb = stov(cvar_string("cl_showacceleration_color"));
4392 if (acceleration < 0) {
4393 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4394 } else if (acceleration > 0) {
4395 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4399 if (acceleration > 0)
4400 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4401 else if (acceleration < 0)
4402 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4405 void HUD_Reset (void)
4407 // reset gametype specific icons
4408 if(gametype == GAME_KEYHUNT)
4410 else if(gametype == GAME_CTF)
4411 HUD_Mod_CTF_Reset();
4414 void HUD_Main (void)
4416 // TODO: render order?
4417 hud_skin_path = strcat("gfx/hud/", autocvar_hud_skin);
4419 if(disable_menu_alphacheck == 1)
4420 menu_fade_alpha = 1;
4422 menu_fade_alpha = (1 - autocvar__menu_alpha);
4423 hud_fg_alpha = cvar("hud_fg_alpha");
4425 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4426 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4427 hud_color_bg_team = cvar("hud_color_bg_team");
4429 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4430 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4434 // HUD configure visible grid
4435 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4439 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_x, 0.2); ++i)
4441 drawfill(eX * i * vid_conwidth * bound(0.005, autocvar_hud_configure_grid_x, 0.2), eX + eY * vid_conheight, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4444 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_y, 0.2); ++i)
4446 drawfill(eY * i * vid_conheight * bound(0.005, autocvar_hud_configure_grid_y, 0.2), eY + eX * vid_conwidth, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4452 if(teamplay && autocvar_hud_dock_color_team) {
4453 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4454 color = colormapPaletteColor(mod(f, 16), 1) * autocvar_hud_dock_color_team;
4456 else if(autocvar_hud_dock_color == "shirt") {
4457 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4458 color = colormapPaletteColor(floor(f / 16), 0);
4460 else if(autocvar_hud_dock_color == "pants") {
4461 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4462 color = colormapPaletteColor(mod(f, 16), 1);
4465 color = stov(autocvar_hud_dock_color);
4467 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4468 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...
4470 if(autocvar_hud_radar || autocvar__hud_configure)
4471 if(autocvar_hud_radar != 0 && (autocvar_hud_radar == 2 || teamplay))
4473 if(autocvar_hud_weaponicons || autocvar__hud_configure)
4475 if(autocvar_hud_inventory || autocvar__hud_configure)
4477 if(autocvar_hud_powerups || autocvar__hud_configure)
4479 if(autocvar_hud_healtharmor || autocvar__hud_configure)
4481 if(autocvar_hud_notify || autocvar__hud_configure)
4483 if(autocvar_hud_timer || autocvar__hud_configure)
4485 if(autocvar_hud_score || autocvar__hud_configure)
4487 if(autocvar_hud_racetimer || autocvar__hud_configure)
4488 if(gametype == GAME_RACE || gametype == GAME_CTS || autocvar__hud_configure)
4490 if(autocvar_hud_vote || autocvar__hud_configure)
4492 if(autocvar_hud_modicons || autocvar__hud_configure)
4494 if(autocvar_hud_pressedkeys || autocvar__hud_configure)
4495 if(spectatee_status > 0 || autocvar_hud_pressedkeys >= 2 || autocvar__hud_configure)
4496 HUD_DrawPressedKeys();
4497 if(autocvar_hud_chat || autocvar__hud_configure)
4500 cvar_set("con_chatrect", "0");
4501 if(autocvar_hud_engineinfo || autocvar__hud_configure)
4504 // TODO hud_'ify these
4505 if (cvar("cl_showspeed"))
4507 if (cvar("cl_showacceleration"))
4508 HUD_ShowAcceleration();
4510 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)
4511 localcmd("cmd selectteam auto; cmd join\n");
4513 hud_configure_prev = autocvar__hud_configure;
4515 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again
4516 disable_menu_alphacheck = 0;