7 // a border picture is a texture containing nine parts:
8 // 1/4 width: left part
9 // 1/2 width: middle part (stretched)
10 // 1/4 width: right part
12 // 1/4 height: top part
13 // 1/2 height: middle part (stretched)
14 // 1/4 height: bottom part
15 void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize)
17 if (theBorderSize_x <= 0 && theBorderSize_y <= 0) // no border
19 // draw only the central part
20 drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
27 //pic = draw_UseSkinFor(pic);
28 width = eX * theSize_x;
29 height = eY * theSize_y;
30 if(theSize_x <= theBorderSize_x * 2)
32 // not wide enough... draw just left and right then
33 bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
34 if(theSize_y <= theBorderSize_y * 2)
36 // not high enough... draw just corners
37 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
38 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
39 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
40 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
41 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
45 dY = theBorderSize_x * eY;
46 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
47 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
48 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
49 drawsubpic(theOrigin + width * 0.5 + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0' + eX - bW, '0 0.5 0' + bW, theColor, theAlpha, 0);
50 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
51 drawsubpic(theOrigin + width * 0.5 + height - dY, width * 0.5 + dY, pic, '0 0.75 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
56 if(theSize_y <= theBorderSize_y * 2)
58 // not high enough... draw just top and bottom then
59 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
60 dX = theBorderSize_x * eX;
61 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
62 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
63 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
64 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
65 drawsubpic(theOrigin + dX + height * 0.5, width - 2 * dX + height * 0.5, pic, '0.25 0 0' + eY - bH, '0.5 0 0' + bH, theColor, theAlpha, 0);
66 drawsubpic(theOrigin + width - dX + height * 0.5, dX + height * 0.5, pic, '0.75 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
70 dX = theBorderSize_x * eX;
71 dY = theBorderSize_x * eY;
72 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
73 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
74 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
75 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
76 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
77 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
78 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
79 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
80 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
85 // drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
88 #define drawpic_aspect(pos,pic,mySize,color,alpha,drawflag)\
91 imgsize = drawgetimagesize(pic);\
92 imgaspect = imgsize_x/imgsize_y;\
96 if(aspect > imgaspect) {\
97 sz_x = sz_y * imgaspect;\
98 drawpic(pos + eX * (oldsz_x - sz_x) * 0.5, pic, sz, color, alpha, drawflag);\
100 sz_y = sz_x / imgaspect;\
101 drawpic(pos + eY * (oldsz_y - sz_y) * 0.5, pic, sz, color, alpha, drawflag);\
106 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
107 #define drawpic_aspect_skin(pos,pic,sz,color,alpha,drawflag)\
109 pic_path = strcat(hud_skin_path, "/", pic);\
110 if(precache_pic(pic_path) == "") {\
111 drawpic_aspect(pos, strcat("gfx/hud/default/", pic), sz, color, alpha, drawflag);\
113 drawpic_aspect(pos, pic_path, sz, color, alpha, drawflag);\
118 void drawpic_aspect_skin_expanding(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
120 //drawpic_aspect_expanding(pos, strcat("gfx/hud/", autocvar_hud_skin, "/", pic), sz, rgb, alpha, flag, fadelerp);
123 void drawpic_aspect_skin_expanding_two(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
125 //drawpic_aspect_expanding_two(pos, strcat("gfx/hud/", autocvar_hud_skin, "/", pic), sz, rgb, alpha, flag, fadelerp);
128 vector HUD_Get_Num_Color (float x, float maxvalue)
136 else if(x > maxvalue * 0.75) {
137 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
138 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
141 else if(x > maxvalue * 0.5) {
142 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
143 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
144 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
146 else if(x > maxvalue * 0.25) {
149 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
151 else if(x > maxvalue * 0.1) {
153 color_y = (x-20)*90/27/100; // green value between 0 -> 1
154 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
164 float stringwidth_colors(string s, vector theSize)
166 return stringwidth(s, TRUE, theSize);
169 float stringwidth_nocolors(string s, vector theSize)
171 return stringwidth(s, FALSE, theSize);
174 #define CENTERPRINT_MAX_LINES 30
175 string centerprint_messages[CENTERPRINT_MAX_LINES];
176 float centerprint_width[CENTERPRINT_MAX_LINES];
177 vector centerprint_start;
178 float centerprint_expire;
179 float centerprint_num;
180 float centerprint_offset_hint;
181 vector centerprint_fontsize;
183 void centerprint(string strMessage)
185 float i, j, n, hcount;
188 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
190 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
192 if(cvar("scr_centertime") <= 0)
198 // strip trailing newlines
199 j = strlen(strMessage) - 1;
200 while(substring(strMessage, j, 1) == "\n" && j >= 0)
202 strMessage = substring(strMessage, 0, j + 1);
207 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
209 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
211 strMessage = substring(strMessage, j, strlen(strMessage) - j);
212 centerprint_offset_hint = j;
217 // if we get here, we have a message. Initialize its height.
220 n = tokenizebyseparator(strMessage, "\n");
222 for(j = 0; j < n; ++j)
224 getWrappedLine_remaining = argv(j);
225 while(getWrappedLine_remaining)
227 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
228 if(centerprint_messages[i])
229 strunzone(centerprint_messages[i]);
230 centerprint_messages[i] = strzone(s);
231 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
234 // half height for empty lines looks better
240 if(i >= CENTERPRINT_MAX_LINES)
246 h = centerprint_fontsize_y*hcount;
248 havail = vid_conheight;
249 if(cvar("con_chatpos") < 0)
250 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
251 if(havail > vid_conheight - 70)
252 havail = vid_conheight - 70; // avoid overlapping HUD
254 centerprint_start_x = 0;
257 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
259 // here, the centerprint would cover the crosshair. REALLY BAD.
260 forbiddenmin = vid_conheight * 0.5 - h - 16;
261 forbiddenmax = vid_conheight * 0.5 + 16;
263 allowedmin = scoreboard_bottom;
264 allowedmax = havail - h;
265 preferred = (havail - h)/2;
268 // possible orderings (total: 4! / 4 = 6)
269 // allowedmin allowedmax forbiddenmin forbiddenmax
270 // forbiddenmin forbiddenmax allowedmin allowedmax
271 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
273 // forbidden doesn't matter in this case
274 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
276 // allowedmin forbiddenmin allowedmax forbiddenmax
277 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
279 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
281 // allowedmin forbiddenmin forbiddenmax allowedmax
282 else if(allowedmin < forbiddenmin)
284 // make sure the forbidden zone is not covered
285 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
286 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
288 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
290 // forbiddenmin allowedmin allowedmax forbiddenmax
291 else if(allowedmax < forbiddenmax)
293 // it's better to leave the allowed zone (overlap with scoreboard) than
294 // to cover the forbidden zone (crosshair)
295 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
296 centerprint_start_y = forbiddenmax;
298 centerprint_start_y = forbiddenmin;
300 // forbiddenmin allowedmin forbiddenmax allowedmax
303 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
306 centerprint_start_y =
309 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
317 centerprint_expire = time + cvar("scr_centertime");
320 void HUD_DrawCenterPrint (void)
327 //if(time > centerprint_expire)
330 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
331 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
332 //sz = 1.2 / (a + 0.2);
337 pos = centerprint_start;
338 for (i=0; i<centerprint_num; i = i + 1)
340 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
341 ts = centerprint_messages[i];
344 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
345 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
346 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
347 pos_y = pos_y + centerprint_fontsize_y;
350 // half height for empty lines looks better
351 pos_y = pos_y + centerprint_fontsize_y * 0.5;
355 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
357 position_x -= 2 / 3 * strlen(text) * scale_x;
358 drawstring(position, text, scale, rgb, alpha, flag);
361 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
363 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
364 drawstring(position, text, scale, rgb, alpha, flag);
367 // return the string of the given race place
368 string race_PlaceName(float pos) {
376 return strcat(ftos(pos), "th");
379 // return the string of the onscreen race timer
380 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
388 if(histime == 0) // goal hit
392 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
402 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
408 lapstr = strcat(" (-", ftos(lapdelta), "L)");
411 else if(lapdelta < 0)
413 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
417 else if(histime > 0) // anticipation
419 if(mytime >= histime)
420 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
422 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
429 cpname = "Start line";
431 cpname = "Finish line";
433 cpname = strcat("Intermediate ", ftos(cp));
435 cpname = "Finish line";
438 return strcat(col, cpname);
439 else if(hisname == "")
440 return strcat(col, cpname, " (", timestr, ")");
442 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
445 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
446 float race_CheckName(string net_name) {
448 for (i=RANKINGS_CNT-1;i>=0;--i)
449 if(grecordholder[i] == net_name)
461 void HUD_Panel_ExportCfg(string cfgname)
464 fh = fopen(strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg"), FILE_WRITE);
467 fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
468 fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
469 fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
470 fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
471 fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
472 fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
473 fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
474 fputs(fh, strcat("seta hud_fg_alpha \"", cvar_string("hud_fg_alpha"), "\"", "\n"));
477 fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
478 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
479 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
480 fputs(fh, strcat("seta hud_dock_alpha \"", cvar_string("hud_dock_alpha"), "\"", "\n"));
483 fputs(fh, strcat("seta hud_progressbar_alpha \"", cvar_string("hud_progressbar_alpha"), "\"", "\n"));
484 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
485 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
486 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
487 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
488 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
489 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
492 fputs(fh, strcat("seta _hud_panelorder \"", cvar_string("hud_nexball_color"), "\"", "\n"));
495 // common cvars for all panels
497 for (i = 0; i < HUD_PANEL_NUM; ++i)
501 fputs(fh, strcat("seta hud_", panel_name, " ", cvar_string(strcat("hud_", panel_name)), "\n"));
502 fputs(fh, strcat("seta hud_", panel_name, "_pos \"", cvar_string(strcat("hud_", panel_name, "_pos")), "\"", "\n"));
503 fputs(fh, strcat("seta hud_", panel_name, "_size \"", cvar_string(strcat("hud_", panel_name, "_size")), "\"", "\n"));
504 fputs(fh, strcat("seta hud_", panel_name, "_bg \"", cvar_string(strcat("hud_", panel_name, "_bg")), "\"", "\n"));
505 fputs(fh, strcat("seta hud_", panel_name, "_bg_color \"", cvar_string(strcat("hud_", panel_name, "_bg_color")), "\"", "\n"));
506 fputs(fh, strcat("seta hud_", panel_name, "_bg_color_team \"", cvar_string(strcat("hud_", panel_name, "_bg_color_team")), "\"", "\n"));
507 fputs(fh, strcat("seta hud_", panel_name, "_bg_alpha \"", cvar_string(strcat("hud_", panel_name, "_bg_alpha")), "\"", "\n"));
508 fputs(fh, strcat("seta hud_", panel_name, "_bg_border \"", cvar_string(strcat("hud_", panel_name, "_bg_border")), "\"", "\n"));
509 fputs(fh, strcat("seta hud_", panel_name, "_bg_padding \"", cvar_string(strcat("hud_", panel_name, "_bg_padding")), "\"", "\n"));
511 case HUD_PANEL_WEAPONICONS:
512 fputs(fh, strcat("seta hud_", panel_name, "_accuracy_yellow \"", cvar_string(strcat("hud_", panel_name, "_accuracy_yellow")), "\"", "\n"));
513 fputs(fh, strcat("seta hud_", panel_name, "_complainbubble \"", cvar_string(strcat("hud_", panel_name, "_complainbubble")), "\"", "\n"));
514 fputs(fh, strcat("seta hud_", panel_name, "_complainbubble_size \"", cvar_string(strcat("hud_", panel_name, "_complainbubble_size")), "\"", "\n"));
516 case HUD_PANEL_INVENTORY:
517 fputs(fh, strcat("seta hud_", panel_name, "_onlycurrent \"", cvar_string(strcat("hud_", panel_name, "_onlycurrent")), "\"", "\n"));
518 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
520 case HUD_PANEL_POWERUPS:
521 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\"", "\n"));
522 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
523 fputs(fh, strcat("seta hud_", panel_name, "_baralign \"", cvar_string(strcat("hud_", panel_name, "_baralign")), "\"", "\n"));
525 case HUD_PANEL_HEALTHARMOR:
526 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\n"));
527 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
528 fputs(fh, strcat("seta hud_", panel_name, "_baralign \"", cvar_string(strcat("hud_", panel_name, "_baralign")), "\"", "\n"));
530 case HUD_PANEL_NOTIFY:
531 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\"", "\n"));
532 fputs(fh, strcat("seta hud_", panel_name, "_info_top \"", cvar_string(strcat("hud_", panel_name, "_info_top")), "\"", "\n"));
534 case HUD_PANEL_RADAR:
535 fputs(fh, strcat("seta hud_", panel_name, "_foreground_alpha \"", cvar_string(strcat("hud_", panel_name, "_foreground_alpha")), "\"", "\n"));
538 fputs(fh, strcat("seta hud_", panel_name, "_alreadyvoted_alpha \"", cvar_string(strcat("hud_", panel_name, "_alreadyvoted_alpha")), "\"", "\n"));
544 print("^2Successfully exported to hud_", autocvar_hud_skin, "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
549 // return smoothly faded size of given panel when a dialog is active
550 vector HUD_Panel_GetMenuSize(float id)
555 mySize = eX * mySize_x * vid_conwidth + eY * mySize_y * vid_conheight;
557 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
559 vector menu_enable_maxsize, menu_enable_size;
560 menu_enable_maxsize = '0 0 0'; // shut up FTEQCC
561 menu_enable_maxsize_x = 0.3 * vid_conwidth;
562 menu_enable_maxsize_y = 0.18 * vid_conheight;
563 if(mySize_x > mySize_y)
565 if(mySize_y > menu_enable_maxsize_y)
567 menu_enable_size_y = menu_enable_maxsize_y;
568 menu_enable_size_x = mySize_x * (menu_enable_maxsize_y/mySize_y);
569 mySize = (1 - autocvar__menu_alpha) * mySize + (autocvar__menu_alpha) * menu_enable_size;
574 if(mySize_x > menu_enable_maxsize_x)
576 menu_enable_size_x = menu_enable_maxsize_x;
577 menu_enable_size_y = mySize_y * (menu_enable_maxsize_x/mySize_x);
578 mySize = (1 - autocvar__menu_alpha) * mySize + (autocvar__menu_alpha) * menu_enable_size;
585 // return smoothly faded pos of given panel when a dialog is active
586 vector HUD_Panel_GetMenuPos(float id)
591 pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
593 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
595 vector mySize, menu_enable_panelpos;
596 mySize = HUD_Panel_GetMenuSize(id);
597 if(mySize_x > mySize_y)
598 menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * mySize_x + eY * 0.82 * vid_conheight;
600 menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * mySize_y + eX * 0.7 * vid_conwidth;
601 pos = (1 - autocvar__menu_alpha) * pos + (autocvar__menu_alpha) * menu_enable_panelpos;
606 const float hlBorderSize = 4;
607 const string hlBorder = "gfx/hud/default/border_highlighted";
608 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
609 void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
611 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
612 drawpic_tiled(panel_pos - '1 1 0' * myBorder, hlBorder, '8 1 0' * hlBorderSize, eX * (panel_size_x + 2 * myBorder) + eY * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
613 drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * (panel_size_y + 2 * myBorder - hlBorderSize), hlBorder, '8 1 0' * hlBorderSize, eX * (panel_size_x + 2 * myBorder) + eY * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
614 drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * hlBorderSize, hlBorder2, '1 8 0' * hlBorderSize, eY * (panel_size_y + 2 * myBorder - 2 * hlBorderSize) + eX * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
615 drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * hlBorderSize + eX * (panel_size_x + 2 * myBorder - hlBorderSize), hlBorder2, '1 8 0' * hlBorderSize, eY * (panel_size_y + 2 * myBorder - 2 * hlBorderSize) + eX * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
618 // draw the background/borders
619 #define HUD_Panel_DrawBg(alpha)\
621 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));\
622 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
623 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);
625 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
631 pic = strcat(hud_skin_path, "/");
633 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);
634 if(mySize_y/mySize_x > 2)
635 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);
636 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);
638 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);
639 if(mySize_x/mySize_y > 2)
640 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);
641 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);
645 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
646 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
657 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
658 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
660 for (i = 0; i < HUD_PANEL_NUM; ++i) {
661 if(i == highlightedPanel || !panel_enabled)
664 HUD_Panel_UpdatePosSizeForId(i)
666 panel_pos -= '1 1 0' * panel_bg_border;
667 panel_size += '2 2 0' * panel_bg_border;
669 if(myPos_y + mySize_y < panel_pos_y)
671 if(myPos_y > panel_pos_y + panel_size_y)
674 if(myPos_x + mySize_x < panel_pos_x)
676 if(myPos_x > panel_pos_x + panel_size_x)
679 // OK, there IS a collision.
681 myCenter_x = myPos_x + 0.5 * mySize_x;
682 myCenter_y = myPos_y + 0.5 * mySize_y;
684 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
685 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
687 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
689 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
690 myTarget_x = panel_pos_x - mySize_x;
691 else // push it upwards
692 myTarget_y = panel_pos_y - mySize_y;
694 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
696 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
697 myTarget_x = panel_pos_x + panel_size_x;
698 else // push it upwards
699 myTarget_y = panel_pos_y - mySize_y;
701 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
703 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
704 myTarget_x = panel_pos_x - mySize_x;
705 else // push it downwards
706 myTarget_y = panel_pos_y + panel_size_y;
708 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
710 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
711 myTarget_x = panel_pos_x + panel_size_x;
712 else // push it downwards
713 myTarget_y = panel_pos_y + panel_size_y;
715 if(cvar("hud_configure_checkcollisions_debug"))
716 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
722 void HUD_Panel_SetPos(vector pos)
724 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
728 if(cvar("hud_configure_checkcollisions_debug"))
729 drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
731 if(autocvar_hud_configure_grid)
733 pos_x = floor((pos_x/vid_conwidth)/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
734 pos_y = floor((pos_y/vid_conheight)/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
737 if(hud_configure_checkcollisions)
738 pos = HUD_Panel_CheckMove(pos, mySize);
740 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
741 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
744 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
746 HUD_Panel_GetName(highlightedPanel);
747 cvar_set(strcat("hud_", panel_name, "_pos"), s);
750 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
751 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
761 ratio = mySize_x/mySize_y;
763 for (i = 0; i < HUD_PANEL_NUM; ++i) {
764 if(i == highlightedPanel || !panel_enabled)
767 HUD_Panel_UpdatePosSizeForId(i)
769 panel_pos -= '1 1 0' * panel_bg_border;
770 panel_size += '2 2 0' * panel_bg_border;
772 targEndPos = panel_pos + panel_size;
774 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
775 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
778 if (resizeCorner == 1)
780 // check if this panel is on our way
781 if (resizeorigin_x <= panel_pos_x)
783 if (resizeorigin_y <= panel_pos_y)
785 if (targEndPos_x <= resizeorigin_x - mySize_x)
787 if (targEndPos_y <= resizeorigin_y - mySize_y)
790 // there is a collision:
791 // detect which side of the panel we are facing is actually limiting the resizing
792 // (which side the resize direction finds for first) and reduce the size up to there
794 // dist is the distance between resizeorigin and the "analogous" point of the panel
795 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
796 dist_x = resizeorigin_x - targEndPos_x;
797 dist_y = resizeorigin_y - targEndPos_y;
798 if (dist_y <= 0 || dist_x / dist_y > ratio)
799 mySize_x = min(mySize_x, dist_x);
801 mySize_y = min(mySize_y, dist_y);
803 else if (resizeCorner == 2)
805 if (resizeorigin_x >= targEndPos_x)
807 if (resizeorigin_y <= panel_pos_y)
809 if (panel_pos_x >= resizeorigin_x + mySize_x)
811 if (targEndPos_y <= resizeorigin_y - mySize_y)
814 dist_x = panel_pos_x - resizeorigin_x;
815 dist_y = resizeorigin_y - targEndPos_y;
816 if (dist_y <= 0 || dist_x / dist_y > ratio)
817 mySize_x = min(mySize_x, dist_x);
819 mySize_y = min(mySize_y, dist_y);
821 else if (resizeCorner == 3)
823 if (resizeorigin_x <= panel_pos_x)
825 if (resizeorigin_y >= targEndPos_y)
827 if (targEndPos_x <= resizeorigin_x - mySize_x)
829 if (panel_pos_y >= resizeorigin_y + mySize_y)
832 dist_x = resizeorigin_x - targEndPos_x;
833 dist_y = panel_pos_y - resizeorigin_y;
834 if (dist_y <= 0 || dist_x / dist_y > ratio)
835 mySize_x = min(mySize_x, dist_x);
837 mySize_y = min(mySize_y, dist_y);
839 else if (resizeCorner == 4)
841 if (resizeorigin_x >= targEndPos_x)
843 if (resizeorigin_y >= targEndPos_y)
845 if (panel_pos_x >= resizeorigin_x + mySize_x)
847 if (panel_pos_y >= resizeorigin_y + mySize_y)
850 dist_x = panel_pos_x - resizeorigin_x;
851 dist_y = panel_pos_y - resizeorigin_y;
852 if (dist_y <= 0 || dist_x / dist_y > ratio)
853 mySize_x = min(mySize_x, dist_x);
855 mySize_y = min(mySize_y, dist_y);
857 if(cvar("hud_configure_checkcollisions_debug"))
858 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
864 void HUD_Panel_SetPosSize(vector mySize)
866 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
868 resizeorigin = panel_click_resizeorigin;
871 // minimum panel size cap
872 mySize_x = max(0.025 * vid_conwidth, mySize_x);
873 mySize_y = max(0.025 * vid_conheight, mySize_y);
875 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.
877 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
878 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
881 // collision testing|
882 // -----------------+
884 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
885 if(resizeCorner == 1) {
886 myPos_x = resizeorigin_x - mySize_x;
887 myPos_y = resizeorigin_y - mySize_y;
888 } else if(resizeCorner == 2) {
889 myPos_x = resizeorigin_x;
890 myPos_y = resizeorigin_y - mySize_y;
891 } else if(resizeCorner == 3) {
892 myPos_x = resizeorigin_x - mySize_x;
893 myPos_y = resizeorigin_y;
894 } else { // resizeCorner == 4
895 myPos_x = resizeorigin_x;
896 myPos_y = resizeorigin_y;
899 // left/top screen edges
901 mySize_x = mySize_x + myPos_x;
903 mySize_y = mySize_y + myPos_y;
905 // bottom/right screen edges
906 if(myPos_x + mySize_x > vid_conwidth)
907 mySize_x = vid_conwidth - myPos_x;
908 if(myPos_y + mySize_y > vid_conheight)
909 mySize_y = vid_conheight - myPos_y;
911 if(cvar("hud_configure_checkcollisions_debug"))
912 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
914 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
915 if(autocvar_hud_configure_grid)
917 mySize_x = floor((mySize_x/vid_conwidth)/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
918 mySize_y = floor((mySize_y/vid_conheight)/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
921 if(hud_configure_checkcollisions)
922 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
924 // 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)
925 mySize_x = max(0.025 * vid_conwidth, mySize_x);
926 mySize_y = max(0.025 * vid_conheight, mySize_y);
928 // do another pos check, as size might have changed by now
929 if(resizeCorner == 1) {
930 myPos_x = resizeorigin_x - mySize_x;
931 myPos_y = resizeorigin_y - mySize_y;
932 } else if(resizeCorner == 2) {
933 myPos_x = resizeorigin_x;
934 myPos_y = resizeorigin_y - mySize_y;
935 } else if(resizeCorner == 3) {
936 myPos_x = resizeorigin_x - mySize_x;
937 myPos_y = resizeorigin_y;
938 } else { // resizeCorner == 4
939 myPos_x = resizeorigin_x;
940 myPos_y = resizeorigin_y;
943 if(cvar("hud_configure_checkcollisions_debug"))
944 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
946 HUD_Panel_GetName(highlightedPanel);
948 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
949 cvar_set(strcat("hud_", panel_name, "_size"), s);
951 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
952 cvar_set(strcat("hud_", panel_name, "_pos"), s);
956 float prevMouseClicked; // previous state
957 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
958 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
961 float menu_enabled_time;
962 float pressed_key_time;
963 void HUD_Panel_Arrow_Action(float nPrimary)
965 if (highlightedPanel_prev == -1 || mouseClicked)
968 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
971 if(autocvar_hud_configure_grid)
973 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
975 if (hudShiftState & S_SHIFT)
976 step = bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
978 step = 2 * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
982 if (hudShiftState & S_SHIFT)
983 step = bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
985 step = 2 * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
990 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
991 step = vid_conheight;
994 if (hudShiftState & S_SHIFT)
995 step = (step / 256); // more precision
997 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
1000 highlightedPanel = highlightedPanel_prev;
1002 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
1004 if (hudShiftState & S_ALT) // resize
1006 highlightedAction = 1;
1007 if(nPrimary == K_UPARROW)
1009 else if(nPrimary == K_RIGHTARROW)
1011 else if(nPrimary == K_LEFTARROW)
1013 else // if(nPrimary == K_DOWNARROW)
1016 // ctrl+arrow reduces the size, instead of increasing it
1017 // Note that ctrl disables collisions check too, but it's fine
1018 // since we don't collide with anything reducing the size
1019 if (hudShiftState & S_CTRL) {
1021 resizeCorner = 5 - resizeCorner;
1025 mySize = panel_size;
1026 panel_click_resizeorigin = panel_pos;
1027 if(resizeCorner == 1) {
1028 panel_click_resizeorigin += mySize;
1030 } else if(resizeCorner == 2) {
1031 panel_click_resizeorigin_y += mySize_y;
1033 } else if(resizeCorner == 3) {
1034 panel_click_resizeorigin_x += mySize_x;
1036 } else { // resizeCorner == 4
1039 HUD_Panel_SetPosSize(mySize);
1043 highlightedAction = 2;
1046 if(nPrimary == K_UPARROW)
1048 else if(nPrimary == K_DOWNARROW)
1050 else if(nPrimary == K_LEFTARROW)
1052 else // if(nPrimary == K_RIGHTARROW)
1055 HUD_Panel_SetPos(pos);
1059 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1061 if(!autocvar__hud_configure)
1064 // allow console bind to work
1067 con_keys = findkeysforcommand("toggleconsole");
1068 keys = tokenize(con_keys);
1070 float hit_con_bind, i;
1071 for (i = 0; i < keys; ++i)
1073 if(nPrimary == stof(argv(i)))
1077 if(bInputType == 0) {
1078 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1079 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1080 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1082 else if(bInputType == 1) {
1083 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1084 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1085 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1088 if(nPrimary == K_MOUSE1)
1090 if(bInputType == 0) { // key pressed
1094 else if(bInputType == 1) {// key released
1099 else if(nPrimary == K_ESCAPE)
1101 if (bInputType == 1)
1103 disable_menu_alphacheck = 1;
1105 menu_enabled_time = time;
1106 localcmd("menu_showhudexit\n");
1108 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1110 if (bInputType == 1)
1112 pressed_key_time = 0;
1115 else if (pressed_key_time == 0)
1116 pressed_key_time = time;
1118 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1120 else if(hit_con_bind)
1123 return true; // Suppress ALL other input
1126 float HUD_Panel_HighlightCheck()
1132 for(i = 0; i < HUD_PANEL_NUM; ++i)
1134 HUD_Panel_UpdatePosSizeForId(i)
1136 panelPos = panel_pos;
1137 panelSize = panel_size;
1138 border = 10; // FORCED border so a small border size doesn't mean you can't resize
1141 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1145 // resize from topleft border
1146 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)
1150 // resize from topright border
1151 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)
1155 // resize from bottomleft border
1156 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)
1160 // resize from bottomright border
1161 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)
1169 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1170 void HUD_Panel_FirstInDrawQ(float id)
1174 // find out where in the array our current id is, save into place
1175 for(i = 0; i < HUD_PANEL_NUM; ++i)
1177 if(panel_order[i] == id)
1184 // move all ids up by one step in the array until "place"
1185 for(i = place; i > 0; --i)
1187 panel_order[i] = panel_order[i-1];
1189 // now save the new top id
1190 panel_order[0] = id;
1192 // let's save them into the cvar by some strcat trickery
1194 for(i = 0; i < HUD_PANEL_NUM; ++i)
1196 s = strcat(s, ftos(panel_order[i]), " ");
1198 cvar_set("_hud_panelorder", s);
1199 if(hud_panelorder_prev)
1200 strunzone(hud_panelorder_prev);
1201 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1204 void HUD_Panel_Highlight()
1210 while(j <= HUD_PANEL_NUM)
1215 HUD_Panel_UpdatePosSizeForId(i)
1217 panelPos = panel_pos;
1218 panelSize = panel_size;
1219 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1222 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1224 highlightedPanel = i;
1225 HUD_Panel_FirstInDrawQ(i);
1226 highlightedAction = 1;
1227 panel_click_distance = mousepos - panelPos;
1230 // resize from topleft border
1231 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)
1233 highlightedPanel = i;
1234 HUD_Panel_FirstInDrawQ(i);
1235 highlightedAction = 2;
1237 panel_click_distance = mousepos - panelPos;
1238 panel_click_resizeorigin = panelPos + panelSize;
1241 // resize from topright border
1242 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)
1244 highlightedPanel = i;
1245 HUD_Panel_FirstInDrawQ(i);
1246 highlightedAction = 2;
1248 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1249 panel_click_distance_y = mousepos_y - panelPos_y;
1250 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1253 // resize from bottomleft border
1254 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)
1256 highlightedPanel = i;
1257 HUD_Panel_FirstInDrawQ(i);
1258 highlightedAction = 2;
1260 panel_click_distance_x = mousepos_x - panelPos_x;
1261 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1262 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1265 // resize from bottomright border
1266 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)
1268 highlightedPanel = i;
1269 HUD_Panel_FirstInDrawQ(i);
1270 highlightedAction = 2;
1272 panel_click_distance = panelSize - mousepos + panelPos;
1273 panel_click_resizeorigin = panelPos;
1278 highlightedPanel_prev = -1;
1283 float highlightcheck;
1284 void HUD_Panel_Mouse()
1286 // 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
1287 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1288 disable_menu_alphacheck = 0;
1289 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1293 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1294 print("Highlighted: ", ftos(highlightedPanel), "\n");
1295 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1298 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1299 highlightedPanel = -1;
1300 highlightedAction = 0;
1302 if(highlightedPanel != -1)
1303 highlightedPanel_prev = highlightedPanel;
1305 mousepos = mousepos + getmousepos();
1307 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1308 mousepos_y = bound(0, mousepos_y, vid_conheight);
1312 if(prevMouseClicked == 0)
1313 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1315 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1317 if(highlightedAction == 1)
1318 HUD_Panel_SetPos(mousepos - panel_click_distance);
1319 else if(highlightedAction == 2)
1322 if(resizeCorner == 1) {
1323 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1324 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1325 } else if(resizeCorner == 2) {
1326 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1327 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1328 } else if(resizeCorner == 3) {
1329 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1330 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1331 } else { // resizeCorner == 4
1332 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1333 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1335 HUD_Panel_SetPosSize(mySize);
1338 // doubleclick check
1339 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1341 mouseClicked = 0; // to prevent spam, I guess.
1342 disable_menu_alphacheck = 2;
1344 menu_enabled_time = time;
1345 HUD_Panel_GetName(highlightedPanel)
1346 localcmd("menu_showhudoptions ", panel_name, "\n");
1349 if(prevMouseClicked == 0)
1351 prevMouseClickedTime = time;
1352 prevMouseClickedPos = mousepos;
1357 highlightcheck = HUD_Panel_HighlightCheck();
1359 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1362 cursorsize = '32 32 0';
1364 if(highlightcheck == 0)
1365 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1366 else if(highlightcheck == 1)
1367 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1368 else if(highlightcheck == 2)
1369 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1371 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1373 prevMouseClicked = mouseClicked;
1376 // Weapon icons (#0)
1378 float weaponspace[10];
1379 #define HUD_WeaponIcons_Clear()\
1381 for(idx = 0; idx < 10; ++idx)\
1382 weaponspace[idx] = 0;
1384 entity weaponorder[WEP_MAXCOUNT];
1385 void weaponorder_swap(float i, float j, entity pass)
1389 weaponorder[i] = weaponorder[j];
1393 string weaponorder_cmp_str_save;
1394 string weaponorder_cmp_str;
1395 float weaponorder_cmp(float i, float j, entity pass)
1398 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1399 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1400 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)
1403 void HUD_WeaponIcons(void)
1405 if(!autocvar_hud_weaponicons && !autocvar__hud_configure)
1408 float id = HUD_PANEL_WEAPONICONS;
1409 HUD_Panel_UpdateCvarsForId(id);
1410 float alpha, stat_weapons; // "constants"
1412 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1415 mySize = panel_size;
1417 stat_weapons = getstati(STAT_WEAPONS);
1419 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1421 self = get_weaponinfo(i);
1422 if(self.impulse >= 0)
1426 // TODO make this configurable
1427 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1429 if(weaponorder_cmp_str != weaponorder_cmp_str_save)
1431 if(weaponorder_cmp_str_save)
1432 strunzone(weaponorder_cmp_str_save);
1433 weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
1435 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1437 self = get_weaponinfo(i);
1438 if(self.impulse >= 0)
1440 weaponorder[weapon_cnt] = self;
1444 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1447 HUD_Panel_DrawBg(1);
1448 if(panel_bg_padding)
1450 pos += '1 1 0' * panel_bg_padding;
1451 mySize -= '2 2 0' * panel_bg_padding;
1455 weapon_stats = getstati(STAT_DAMAGE_HITS);
1456 weapon_number = weapon_stats & 63;
1457 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1459 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1460 weapon_number = weapon_stats & 63;
1461 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1463 if(cvar_or("hud_weaponicons_fade", 1))
1465 fade = 3.2 - 2 * (time - weapontime);
1466 fade = bound(0.7, fade, 1);
1471 HUD_WeaponIcons_Clear();
1473 float rows, columns;
1474 rows = mySize_y/mySize_x;
1475 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1476 // ^^^ weapon icon aspect goes here
1478 columns = ceil(WEP_COUNT/rows);
1483 when = autocvar_hud_weaponicons_complainbubble_time;
1485 fadetime = autocvar_hud_weaponicons_complainbubble_fadetime;
1488 for(i = 0; i < weapon_cnt; ++i)
1490 self = weaponorder[i];
1491 weapid = self.impulse;
1493 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1495 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1496 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1498 // draw background behind currently selected weapon
1499 if(self.weapon == activeweapon)
1500 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);
1502 // draw the weapon accuracy on the HUD
1503 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1506 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1508 // yellow_accuracy = value at which accuracy becomes yellow
1509 if(weapon_stats >= 100) {
1513 else if(weapon_stats > autocvar_hud_weaponicons_accuracy_yellow) {
1514 color_x = 1 - (weapon_stats-autocvar_hud_weaponicons_accuracy_yellow)/(100-autocvar_hud_weaponicons_accuracy_yellow); // red value between 1 -> 0
1518 color_y = weapon_stats/autocvar_hud_weaponicons_accuracy_yellow; // green value between 0 -> 1
1522 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);
1525 // draw the weapon icon
1526 if((self.impulse >= 0) && (stat_weapons & self.weapons))
1528 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);
1530 if(autocvar_hud_weaponicons_number == 1) // weapon number
1531 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);
1532 else if(autocvar_hud_weaponicons_number == 2) // bind
1533 drawstring(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * mySize_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1536 // draw a "ghost weapon icon" if you don't have the weapon
1539 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);
1542 // draw the complain message
1543 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_weaponicons_complainbubble)
1547 if(complain_weapon_time + when > time)
1550 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1554 if(complain_weapon_time + when > time)
1560 vector complain_bubble_size = '100 50 0' * bound(0.25, autocvar_hud_weaponicons_complainbubble_size, 2);
1561 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);
1564 if(complain_weapon_type == 0) {
1565 s = "Out of ammo for the";
1568 else if(complain_weapon_type == 1) {
1569 s = "You don't have the";
1573 s = "Map doesn't have the";
1576 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);
1577 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);
1593 float GetAmmoStat(float i)
1597 case 0: return STAT_SHELLS;
1598 case 1: return STAT_NAILS;
1599 case 2: return STAT_ROCKETS;
1600 case 3: return STAT_CELLS;
1601 case 4: return STAT_FUEL;
1606 float GetAmmoItemCode(float i)
1610 case 0: return IT_SHELLS;
1611 case 1: return IT_NAILS;
1612 case 2: return IT_ROCKETS;
1613 case 3: return IT_CELLS;
1614 case 4: return IT_FUEL;
1619 string GetAmmoPicture(float i)
1623 case 0: return "ammo_shells";
1624 case 1: return "ammo_bullets";
1625 case 2: return "ammo_rockets";
1626 case 3: return "ammo_cells";
1627 case 4: return "ammo_fuel";
1632 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1635 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1636 if(autocvar__hud_configure)
1646 if(currently_selected)
1651 vector newSize, newPos;
1652 if(mySize_x/mySize_y > 3)
1654 newSize_x = 3 * mySize_y;
1655 newSize_y = mySize_y;
1657 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1662 newSize_y = 1/3 * mySize_x;
1663 newSize_x = mySize_x;
1665 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1669 vector picpos, numpos;
1670 if(autocvar_hud_inventory_iconalign)
1673 picpos = newPos + eX * 2 * newSize_y;
1677 numpos = newPos + eX * newSize_y;
1681 if (currently_selected)
1682 drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1684 drawfont = hud_bigfont;
1685 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1686 drawfont = hud_font;
1687 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1690 void HUD_Inventory(void)
1692 if(!autocvar_hud_inventory && !autocvar__hud_configure)
1695 float id = HUD_PANEL_INVENTORY;
1696 HUD_Panel_UpdateCvarsForId(id);
1697 float i, currently_selected;
1701 mySize = panel_size;
1703 HUD_Panel_DrawBg(1);
1704 if(panel_bg_padding)
1706 pos += '1 1 0' * panel_bg_padding;
1707 mySize -= '2 2 0' * panel_bg_padding;
1710 float rows, columns;
1711 rows = mySize_y/mySize_x;
1712 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1713 // ^^^ ammo item aspect goes here
1715 columns = ceil(AMMO_COUNT/rows);
1719 for (i = 0; i < AMMO_COUNT; ++i) {
1720 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1721 if(autocvar_hud_inventory_onlycurrent) {
1722 if(autocvar__hud_configure)
1724 if (currently_selected || autocvar__hud_configure)
1725 DrawAmmoItem(pos, mySize, i, currently_selected);
1728 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);
1733 column = column + 1;
1739 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color)
1741 vector newSize, newPos;
1742 if(mySize_x/mySize_y > 3)
1744 newSize_x = 3 * mySize_y;
1745 newSize_y = mySize_y;
1747 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1752 newSize_y = 1/3 * mySize_x;
1753 newSize_x = mySize_x;
1755 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1759 vector picpos, numpos;
1762 if(iconalign == 1 || iconalign == 3) // right align
1765 picpos = newPos + eX * 2 * newSize_y;
1769 numpos = newPos + eX * newSize_y;
1775 if(iconalign == 0 || iconalign == 3) // left align
1777 numpos = newPos + eX * newSize_y;
1783 picpos = newPos + eX * 2 * newSize_y;
1787 drawfont = hud_bigfont;
1788 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, newSize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1789 drawfont = hud_font;
1790 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1795 void HUD_Powerups(void) {
1796 if(!autocvar_hud_powerups && !autocvar__hud_configure)
1799 float id = HUD_PANEL_POWERUPS;
1800 HUD_Panel_UpdateCvarsForId(id);
1802 stat_items = getstati(STAT_ITEMS);
1804 if(!autocvar__hud_configure)
1806 if not(stat_items & IT_STRENGTH)
1807 if not(stat_items & IT_INVINCIBLE)
1810 if (getstati(STAT_HEALTH) <= 0)
1816 mySize = panel_size;
1818 HUD_Panel_DrawBg(1);
1819 if(panel_bg_padding)
1821 pos += '1 1 0' * panel_bg_padding;
1822 mySize -= '2 2 0' * panel_bg_padding;
1825 float strength_time, shield_time;
1827 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1828 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1830 if(autocvar__hud_configure)
1836 vector barpos, barsize;
1840 string leftname, rightname;
1841 float leftcnt, rightcnt;
1842 float leftexact, rightexact;
1843 float leftalpha, rightalpha;
1844 if (autocvar_hud_powerups_flip) {
1845 leftname = "strength";
1846 leftcnt = ceil(strength_time);
1847 leftexact = strength_time;
1849 rightname = "shield";
1850 rightcnt = ceil(shield_time);
1851 rightexact = shield_time;
1853 leftname = "shield";
1854 leftcnt = ceil(shield_time);
1855 leftexact = shield_time;
1857 rightname = "strength";
1858 rightcnt = ceil(strength_time);
1859 rightexact = strength_time;
1861 leftalpha = bound(0, leftexact, 1);
1862 rightalpha = bound(0, rightexact, 1);
1864 drawfont = hud_bigfont;
1865 if (mySize_x/mySize_y > 4)
1869 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1870 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1871 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1872 } else { // left align
1874 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1877 HUD_Panel_GetProgressBarColor(leftname)
1878 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1879 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1');
1882 // 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));
1884 // drawpic_aspect_skin(picpos, leftname, eX * (1/6) * mySize_x + eY * mySize_y, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1889 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1890 barpos = pos + eX * 0.5 * mySize_x;
1891 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1892 } else { // right align
1893 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1894 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1897 HUD_Panel_GetProgressBarColor(rightname)
1898 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1899 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');
1902 else if (mySize_x/mySize_y > 1.5)
1906 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1907 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1908 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1909 } else { // left align
1911 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1914 HUD_Panel_GetProgressBarColor(leftname)
1915 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1916 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1');
1921 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1922 barpos = pos + eY * 0.5 * mySize_y;
1923 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1924 } else { // right align
1925 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1926 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1929 HUD_Panel_GetProgressBarColor(rightname)
1930 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1931 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');
1938 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // down align
1939 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1940 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1941 } else { // up align
1943 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1946 if(autocvar_hud_powerups_iconalign == 1 || autocvar_hud_powerups_iconalign == 3) { // down align
1947 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
1948 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
1949 } else { // up align
1950 picpos = pos + eX * 0.05 * mySize_x;
1951 numpos = pos + eY * 0.4 * mySize_x;
1954 HUD_Panel_GetProgressBarColor(leftname)
1955 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1957 //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));
1959 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1960 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);
1965 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // up align
1966 barpos = pos + eX * 0.5 * mySize_x;
1967 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1968 } else { // down align
1969 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1970 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1973 if(autocvar_hud_powerups_iconalign == 0 || autocvar_hud_powerups_iconalign == 3) { // up align
1974 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1975 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1976 } else { // down align
1977 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
1978 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
1981 HUD_Panel_GetProgressBarColor(rightname)
1982 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1984 // 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));
1986 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1987 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);
1990 drawfont = hud_font;
1993 // Health/armor (#3)
1995 void HUD_HealthArmor(void)
1997 if(!autocvar_hud_healtharmor && !autocvar__hud_configure)
2000 float id = HUD_PANEL_HEALTHARMOR;
2001 HUD_Panel_UpdateCvarsForId(id);
2004 mySize = panel_size;
2006 HUD_Panel_DrawBg(1);
2007 if(panel_bg_padding)
2009 pos += '1 1 0' * panel_bg_padding;
2010 mySize -= '2 2 0' * panel_bg_padding;
2013 float armor, health;
2014 armor = getstati(STAT_ARMOR);
2015 health = getstati(STAT_HEALTH);
2018 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
2020 if(autocvar__hud_configure)
2030 vector barpos, barsize;
2034 drawfont = hud_bigfont;
2035 if(autocvar_hud_healtharmor == 2) // combined health and armor display
2038 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2043 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2044 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2045 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2046 } else { // left align
2048 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2052 if(v_z) // NOT fully armored
2054 biggercount = "health";
2055 HUD_Panel_GetProgressBarColor("health")
2056 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2058 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);
2062 biggercount = "armor";
2063 HUD_Panel_GetProgressBarColor("armor")
2064 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2066 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);
2068 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200));
2073 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2074 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2075 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2078 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2080 HUD_Panel_GetProgressBarColor("fuel")
2081 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2086 string leftname, rightname;
2087 float leftcnt, rightcnt;
2088 float leftactive, rightactive;
2089 float leftalpha, rightalpha;
2090 if (autocvar_hud_healtharmor_flip) { // old style layout with armor left/top of health
2095 leftalpha = min((armor+10)/55, 1);
2097 rightname = "health";
2102 leftname = "health";
2107 rightname = "armor";
2111 rightalpha = min((armor+10)/55, 1);
2114 if (mySize_x/mySize_y > 4)
2118 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2119 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2120 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2121 } else { // left align
2123 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2126 HUD_Panel_GetProgressBarColor(leftname)
2127 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2128 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2133 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2134 barpos = pos + eX * 0.5 * mySize_x;
2135 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2136 } else { // right align
2137 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2138 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2141 HUD_Panel_GetProgressBarColor(rightname)
2142 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2143 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));
2148 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2149 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2150 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2153 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2155 HUD_Panel_GetProgressBarColor("fuel")
2156 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2159 else if (mySize_x/mySize_y > 1.5)
2163 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2164 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2165 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2166 } else { // left align
2168 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2171 HUD_Panel_GetProgressBarColor(leftname)
2172 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2173 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2178 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2179 barpos = pos + eY * 0.5 * mySize_y;
2180 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2181 } else { // right align
2182 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2183 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2186 HUD_Panel_GetProgressBarColor(rightname)
2187 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2188 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));
2193 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2194 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2195 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2198 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2200 HUD_Panel_GetProgressBarColor("fuel")
2201 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2208 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // down align
2209 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2210 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2211 } else { // up align
2213 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2216 if(autocvar_hud_healtharmor_iconalign == 1 || autocvar_hud_healtharmor_iconalign == 3) { // down align
2217 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2218 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2219 } else { // up align
2220 picpos = pos + eX * 0.05 * mySize_x;
2221 numpos = pos + eY * 0.4 * mySize_x;
2224 HUD_Panel_GetProgressBarColor(leftname)
2225 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2226 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2227 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);
2232 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // up align
2233 barpos = pos + eX * 0.5 * mySize_x;
2234 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2235 } else { // down align
2236 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2237 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2240 if(autocvar_hud_healtharmor_iconalign == 0 || autocvar_hud_healtharmor_iconalign == 3) { // up align
2241 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2242 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2243 } else { // down align
2244 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2245 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2248 HUD_Panel_GetProgressBarColor(rightname)
2249 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2250 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2251 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);
2256 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2258 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2260 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2261 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2263 HUD_Panel_GetProgressBarColor("fuel")
2264 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2268 drawfont = hud_font;
2272 // Notification area (#4)
2275 string Weapon_SuicideMessage(float deathtype)
2277 w_deathtype = deathtype;
2278 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2279 return w_deathtypestring;
2282 string Weapon_KillMessage(float deathtype)
2284 w_deathtype = deathtype;
2285 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2286 return w_deathtypestring;
2289 float killnotify_times[10];
2290 float killnotify_deathtype[10];
2291 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2292 string killnotify_attackers[10];
2293 string killnotify_victims[10];
2294 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2297 for (i = 9; i > 0; --i) {
2298 killnotify_times[i] = killnotify_times[i-1];
2299 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2300 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2301 if(killnotify_attackers[i])
2302 strunzone(killnotify_attackers[i]);
2303 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2304 if(killnotify_victims[i])
2305 strunzone(killnotify_victims[i]);
2306 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2308 killnotify_times[0] = time;
2309 killnotify_deathtype[0] = wpn;
2310 killnotify_actiontype[0] = actiontype;
2311 if(killnotify_attackers[0])
2312 strunzone(killnotify_attackers[0]);
2313 killnotify_attackers[0] = strzone(attacker);
2314 if(killnotify_victims[0])
2315 strunzone(killnotify_victims[0]);
2316 killnotify_victims[0] = strzone(victim);
2319 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2323 alsoprint = (autocvar_hud_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2325 if(msg == MSG_SUICIDE) {
2327 w = DEATH_WEAPONOF(type);
2329 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2331 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2332 } else if (type == DEATH_KILL) {
2333 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2335 print ("^1",s1, "^1 couldn't take it anymore\n");
2336 } else if (type == DEATH_ROT) {
2337 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2339 print ("^1",s1, "^1 died\n");
2340 } else if (type == DEATH_NOAMMO) {
2341 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2343 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2344 } else if (type == DEATH_CAMP) {
2345 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2347 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2348 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2349 HUD_KillNotify_Push(s1, "", 0, type);
2351 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2352 } else if (type == DEATH_CHEAT) {
2353 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2355 print ("^1",s1, "^1 unfairly eliminated themself\n");
2356 } else if (type == DEATH_FIRE) {
2357 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2359 print ("^1",s1, "^1 burned to death\n");
2360 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2361 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2363 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2366 if (stof(s2) > 2) // killcount > 2
2367 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2368 } else if(msg == MSG_KILL) {
2369 w = DEATH_WEAPONOF(type);
2371 HUD_KillNotify_Push(s2, s1, 1, w);
2373 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2375 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2376 HUD_KillNotify_Push(s1, s2, 1, type);
2379 if(cvar("cl_gentle")) {
2380 print ("^1", s1, "^1 took action against a team mate\n");
2382 print ("^1", s1, "^1 mows down a team mate\n");
2385 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2386 if(cvar("cl_gentle"))
2387 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2389 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2391 else if (stof(s2) > 2) {
2392 if(cvar("cl_gentle"))
2393 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2395 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2398 else if(type == KILL_FIRST_BLOOD)
2399 print("^1",s1, "^1 drew first blood", "\n");
2401 else if (type == DEATH_TELEFRAG)
2402 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2403 else if (type == DEATH_DROWN) {
2404 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2406 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2408 else if (type == DEATH_SLIME) {
2409 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2411 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2413 else if (type == DEATH_LAVA) {
2414 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2416 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2418 else if (type == DEATH_FALL) {
2419 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2421 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2423 else if (type == DEATH_SHOOTING_STAR) {
2424 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2426 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2428 else if (type == DEATH_SWAMP) {
2429 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2431 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2433 else if (type == DEATH_HURTTRIGGER)
2435 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2437 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2438 } else if(type == DEATH_SBCRUSH) {
2439 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2441 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2442 } else if(type == DEATH_SBMINIGUN) {
2443 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2445 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2446 } else if(type == DEATH_SBROCKET) {
2447 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2449 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2450 } else if(type == DEATH_SBBLOWUP) {
2451 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2453 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2454 } else if(type == DEATH_WAKIGUN) {
2455 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2457 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2458 } else if(type == DEATH_WAKIROCKET) {
2459 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2461 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2462 } else if(type == DEATH_WAKIBLOWUP) {
2463 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2465 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2466 } else if(type == DEATH_TURRET) {
2467 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2469 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2470 } else if(type == DEATH_TOUCHEXPLODE) {
2471 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2473 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2474 } else if(type == DEATH_CHEAT) {
2475 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2477 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2478 } else if (type == DEATH_FIRE) {
2479 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2481 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2482 } else if (type == DEATH_CUSTOM) {
2483 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2485 print ("^1",s1, "^1 ", s2, "\n");
2487 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2489 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2491 } else if(msg == MSG_SPREE) {
2492 if(type == KILL_END_SPREE) {
2493 if(cvar("cl_gentle"))
2494 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2496 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2497 } else if(type == KILL_SPREE) {
2498 if(cvar("cl_gentle"))
2499 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2501 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2502 } else if(type == KILL_SPREE_3) {
2503 if(cvar("cl_gentle"))
2504 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2506 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2507 } else if(type == KILL_SPREE_5) {
2508 if(cvar("cl_gentle"))
2509 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2511 print (s1,"^7 unleashes ^1RAGE\n");
2512 } else if(type == KILL_SPREE_10) {
2513 if(cvar("cl_gentle"))
2514 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2516 print (s1,"^7 starts the ^1MASSACRE!\n");
2517 } else if(type == KILL_SPREE_15) {
2518 if(cvar("cl_gentle"))
2519 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2521 print (s1,"^7 executes ^1MAYHEM!\n");
2522 } else if(type == KILL_SPREE_20) {
2523 if(cvar("cl_gentle"))
2524 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2526 print (s1,"^7 is a ^1BERSERKER!\n");
2527 } else if(type == KILL_SPREE_25) {
2528 if(cvar("cl_gentle"))
2529 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2531 print (s1,"^7 inflicts ^1CARNAGE!\n");
2532 } else if(type == KILL_SPREE_30) {
2533 if(cvar("cl_gentle"))
2534 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2536 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2538 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2539 if (type == DEATH_DROWN) {
2540 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2543 if(cvar("cl_gentle"))
2544 print ("^1",s1, "^1 was in the water for too long\n");
2546 print ("^1",s1, "^1 drowned\n");
2548 } else if (type == DEATH_SLIME) {
2549 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2551 print ("^1",s1, "^1 was slimed\n");
2552 } else if (type == DEATH_LAVA) {
2553 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2556 if(cvar("cl_gentle"))
2557 print ("^1",s1, "^1 found a hot place\n");
2559 print ("^1",s1, "^1 turned into hot slag\n");
2561 } else if (type == DEATH_FALL) {
2562 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2565 if(cvar("cl_gentle"))
2566 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2568 print ("^1",s1, "^1 hit the ground with a crunch\n");
2570 } else if (type == DEATH_SHOOTING_STAR) {
2571 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2573 print ("^1",s1, "^1 became a shooting star\n");
2574 } else if (type == DEATH_SWAMP) {
2575 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2578 if(cvar("cl_gentle"))
2579 print ("^1",s1, "^1 discovered a swamp\n");
2581 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2583 } else if(type == DEATH_TURRET) {
2584 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2586 print ("^1",s1, "^1 was mowed down by a turret \n");
2587 } else if (type == DEATH_CUSTOM) {
2588 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2590 print ("^1",s1, "^1 ", s2, "\n");
2591 } else if (type == DEATH_HURTTRIGGER) {
2592 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2594 print ("^1",s1, "^1 was in the wrong place\n");
2595 } else if(type == DEATH_TOUCHEXPLODE) {
2596 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2598 print ("^1",s1, "^1 died in an accident\n");
2599 } else if(type == DEATH_CHEAT) {
2600 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2602 print ("^1",s1, "^1 was unfairly eliminated\n");
2603 } else if(type == DEATH_FIRE) {
2604 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2607 if(cvar("cl_gentle"))
2608 print ("^1",s1, "^1 felt a little hot\n");
2610 print ("^1",s1, "^1 burnt to death\n");
2613 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2616 if(cvar("cl_gentle"))
2617 print ("^1",s1, "^1 needs a restart\n");
2619 print ("^1",s1, "^1 died\n");
2622 } else if(msg == MSG_KILL_ACTION_SPREE) {
2623 if(cvar("cl_gentle"))
2624 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2626 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2627 } else if(msg == MSG_INFO) {
2628 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2629 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2630 print(s1, "^7 got the ", s2, "\n");
2631 } else if(type == INFO_LOSTFLAG) {
2632 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2633 print(s1, "^7 lost the ", s2, "\n");
2634 } else if(type == INFO_PICKUPFLAG) {
2635 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2636 print(s1, "^7 picked up the ", s2, "\n");
2637 } else if(type == INFO_RETURNFLAG) {
2638 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2639 print(s1, "^7 returned the ", s2, "\n");
2644 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2646 void HUD_Centerprint(string s1, string s2, float type, float msg)
2648 if(msg == MSG_SUICIDE) {
2649 if (type == DEATH_TEAMCHANGE) {
2650 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2651 } else if (type == DEATH_AUTOTEAMCHANGE) {
2652 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2653 } else if (type == DEATH_CAMP) {
2654 if(cvar("cl_gentle"))
2655 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2657 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2658 } else if (type == DEATH_NOAMMO) {
2659 if(cvar("cl_gentle"))
2660 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2662 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2663 } else if (type == DEATH_ROT) {
2664 if(cvar("cl_gentle"))
2665 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2667 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2668 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2669 if(cvar("cl_gentle"))
2670 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2672 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2673 } else if (type == DEATH_QUIET) {
2675 } else if (type == DEATH_KILL) {
2676 if(cvar("cl_gentle"))
2677 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2679 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2681 } else if(msg == MSG_KILL) {
2682 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2683 if(cvar("cl_gentle")) {
2684 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2686 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2688 } else if (type == KILL_FIRST_BLOOD) {
2689 if(cvar("cl_gentle")) {
2690 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2692 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2694 } else if (type == KILL_FIRST_VICTIM) {
2695 if(cvar("cl_gentle")) {
2696 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2698 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2700 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2701 if(cvar("cl_gentle")) {
2702 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2704 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2706 } else if (type == KILL_TYPEFRAGGED) {
2707 if(cvar("cl_gentle")) {
2708 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2710 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2712 } else if (type == KILL_FRAG) {
2713 if(cvar("cl_gentle")) {
2714 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2716 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2718 } else if (type == KILL_FRAGGED) {
2719 if(cvar("cl_gentle")) {
2720 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2722 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2725 } else if(msg == MSG_KILL_ACTION) {
2726 // TODO: invent more centerprints here?
2727 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2731 void HUD_Notify (void)
2733 if(!autocvar_hud_notify && !autocvar__hud_configure)
2736 float id = HUD_PANEL_NOTIFY;
2737 HUD_Panel_UpdateCvarsForId(id);
2740 mySize = panel_size;
2742 HUD_Panel_DrawBg(1);
2743 if(panel_bg_padding)
2745 pos += '1 1 0' * panel_bg_padding;
2746 mySize -= '2 2 0' * panel_bg_padding;
2749 float entries, height;
2750 entries = bound(1, floor(14 * mySize_y/mySize_x), 12);
2751 height = mySize_y/entries;
2752 entries -= 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2755 fontsize = '0.5 0.5 0' * height;
2759 when = autocvar_hud_notify_time;
2761 fadetime = autocvar_hud_notify_fadetime;
2765 vector pos_attacker, pos_victim;
2767 float width_attacker, width_victim;
2768 string attacker, victim;
2771 for(j = 0; j < entries; ++j)
2773 if(autocvar_hud_notify_flip)
2775 else // rather nasty hack for ordering items from the bottom up
2776 i = entries - j - 1;
2777 if(autocvar_hud_notify_info_top)
2778 i += 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2782 if(killnotify_times[j] + when > time)
2785 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2789 if(killnotify_times[j] + when > time)
2795 // TODO: maybe print in team colors?
2796 // TODO: maybe this could be cleaned up somehow...
2797 // TODO: less copypaste code below
2800 if(killnotify_actiontype[j] == 0 && !autocvar__hud_configure)
2802 attacker = textShortenToWidth(killnotify_attackers[j], mySize_x - 2 * height, fontsize, stringwidth_colors);
2804 width_attacker = stringwidth(attacker, TRUE, fontsize);
2805 pos_attacker = pos + eX * 0.5 * (mySize_x - width_attacker + 2 * height) + eY * 0.5 * fontsize_y + eY * i * height;
2807 weap_pos = pos + eX * 0.5 * (mySize_x - width_attacker) - eX * height + eY * i * height;
2808 if(killnotify_deathtype[j] == DEATH_GENERIC)
2810 drawpic_aspect_skin(weap_pos, "notify_death", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2811 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2813 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2815 drawpic_aspect_skin(weap_pos, "notify_outofammo", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2816 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2818 else if(killnotify_deathtype[j] == DEATH_KILL)
2820 drawpic_aspect_skin(weap_pos, "notify_selfkill", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2821 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2823 else if(killnotify_deathtype[j] == DEATH_CAMP)
2825 drawpic_aspect_skin(weap_pos, "notify_camping", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2826 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2828 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2830 drawpic_aspect_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2831 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2833 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2835 drawpic_aspect_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2836 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2838 else if(killnotify_deathtype[j] == DEATH_DROWN)
2840 drawpic_aspect_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2841 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2843 else if(killnotify_deathtype[j] == DEATH_SLIME)
2845 drawpic_aspect_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2846 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2848 else if(killnotify_deathtype[j] == DEATH_LAVA)
2850 drawpic_aspect_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2851 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2853 else if(killnotify_deathtype[j] == DEATH_FALL)
2855 drawpic_aspect_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2856 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2858 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2860 drawpic_aspect_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2861 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2863 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2865 drawpic_aspect_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2866 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2868 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2870 if(killnotify_victims[j] == "^1RED^7 flag")
2874 drawpic_aspect_skin(weap_pos, strcat("flag_", s, "_carrying"), '1 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2875 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2877 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2879 if(killnotify_victims[j] == "^1RED^7 flag")
2883 drawpic_aspect_skin(weap_pos, strcat("flag_", s, "_taken"), '1 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2884 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2886 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2888 if(killnotify_victims[j] == "^1RED^7 flag")
2892 drawpic_aspect_skin(weap_pos, strcat("flag_", s, "_lost"), '1 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2893 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2896 // X [did action to] Y
2899 if(autocvar__hud_configure)
2901 attacker = textShortenToWidth("Player1", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2902 victim = textShortenToWidth("Player2", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2903 a = bound(0, (when - j) / 4, 1);
2907 attacker = textShortenToWidth(killnotify_attackers[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2908 victim = textShortenToWidth(killnotify_victims[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2910 width_attacker = stringwidth(attacker, TRUE, fontsize);
2911 width_victim = stringwidth(victim, TRUE, fontsize);
2912 pos_attacker = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_attacker) + eY * 0.5 * fontsize_y + eY * i * height;
2913 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;
2914 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2916 if(autocvar__hud_configure) // example actions for config mode
2918 drawpic_aspect_skin(weap_pos, strcat("weapon", "electro"), '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2919 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2920 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2922 else if(WEP_VALID(killnotify_deathtype[j]))
2924 self = get_weaponinfo(killnotify_deathtype[j]);
2925 drawpic_aspect_skin(weap_pos, strcat("weapon", self.netname), '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2926 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2927 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2929 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2931 drawpic_aspect_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2932 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2933 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2935 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2937 drawpic_aspect_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2938 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2939 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2941 else if(killnotify_deathtype[j] == DEATH_DROWN)
2943 drawpic_aspect_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2944 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2945 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2947 else if(killnotify_deathtype[j] == DEATH_SLIME)
2949 drawpic_aspect_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2950 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2951 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2953 else if(killnotify_deathtype[j] == DEATH_LAVA)
2955 drawpic_aspect_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2956 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2957 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2959 else if(killnotify_deathtype[j] == DEATH_FALL)
2961 drawpic_aspect_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2962 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2963 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2965 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2967 drawpic_aspect_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2968 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2969 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2971 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2973 drawpic_aspect_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2974 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2975 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2981 // TODO: separate panel for these?
2987 if(autocvar_hud_notify_info_top)
2990 o = pos + eY * mySize_y - eY * 2 * height;
2992 if(spectatee_status && !intermission)
2994 //drawfont = hud_bigfont;
2995 if(spectatee_status == -1)
2998 s = GetPlayerName(spectatee_status - 1);
3000 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
3001 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, panel_fg_alpha, DRAWFLAG_NORMAL);
3002 //drawfont = hud_font;
3004 // spectator text in the upper right corner
3005 if(spectatee_status == -1)
3006 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
3008 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
3009 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3010 o += eY * fontsize_y;
3012 if(spectatee_status == -1)
3013 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
3015 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
3016 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3017 o += eY * fontsize_y;
3019 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
3020 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3021 o += eY * fontsize_y;
3023 if(gametype == GAME_ARENA)
3024 s = "^1Wait for your turn to join";
3025 else if(gametype == GAME_LMS)
3028 sk = playerslots[player_localentnum - 1];
3029 if(sk.(scores[ps_primary]) >= 666)
3030 s = "^1Match has already begun";
3031 else if(sk.(scores[ps_primary]) > 0)
3032 s = "^1You have no more lives left";
3034 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
3037 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
3038 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3039 o += eY * fontsize_y;
3041 //show restart countdown:
3042 if (time < getstatf(STAT_GAMESTARTTIME)) {
3044 //we need to ceil, otherwise the countdown would be off by .5 when using round()
3045 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
3046 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
3047 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3048 o += eY * fontsize_y;
3051 if(warmup_stage && !intermission)
3053 s = "^2Currently in ^1warmup^2 stage!";
3054 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3055 o += eY * fontsize_y;
3059 if(mod(time, 1) >= 0.5)
3064 if(ready_waiting && !intermission && !spectatee_status)
3066 if(ready_waiting_for_me)
3069 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
3071 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
3076 s = strcat("^2Waiting for others to ready up to end warmup...");
3078 s = strcat("^2Waiting for others to ready up...");
3080 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3081 o += eY * fontsize_y;
3083 else if(warmup_stage && !intermission && !spectatee_status)
3085 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
3086 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3087 o += eY * fontsize_y;
3090 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
3092 float ts_min, ts_max;
3093 tm = teams.sort_next;
3096 for(; tm.sort_next; tm = tm.sort_next)
3098 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
3100 if(!ts_min) ts_min = tm.team_size;
3101 else ts_min = min(ts_min, tm.team_size);
3102 if(!ts_max) ts_max = tm.team_size;
3103 else ts_max = max(ts_max, tm.team_size);
3105 if ((ts_max - ts_min) > 1)
3107 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
3108 tm = GetTeam(myteam, false);
3110 if (tm.team != COLOR_SPECTATOR)
3111 if (tm.team_size == ts_max)
3112 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
3114 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3115 o += eY * fontsize_y;
3119 if(autocvar__hud_configure)
3121 s = "^7Press ^3ESC ^7to show HUD options.";
3122 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3123 o += eY * fontsize_y;
3124 s = "^3Doubleclick a panel for panel-specific options.";
3125 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
3126 o += eY * fontsize_y;
3133 string seconds_tostring(float sec)
3136 minutes = floor(sec / 60);
3138 sec -= minutes * 60;
3141 s = ftos(100 + sec);
3143 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3146 void HUD_Timer(void)
3148 if(!autocvar_hud_timer && !autocvar__hud_configure)
3151 float id = HUD_PANEL_TIMER;
3152 HUD_Panel_UpdateCvarsForId(id);
3155 mySize = panel_size;
3157 HUD_Panel_DrawBg(1);
3158 if(panel_bg_padding)
3160 pos += '1 1 0' * panel_bg_padding;
3161 mySize -= '2 2 0' * panel_bg_padding;
3165 float timelimit, elapsedTime, timeleft, minutesLeft;
3167 timelimit = getstatf(STAT_TIMELIMIT);
3169 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3170 timeleft = ceil(timeleft);
3172 minutesLeft = floor(timeleft / 60);
3175 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3176 timer_color = '1 1 1'; //white
3177 else if(minutesLeft >= 1)
3178 timer_color = '1 1 0'; //yellow
3180 timer_color = '1 0 0'; //red
3182 if (autocvar_hud_timer_increment || timelimit == 0 || warmup_stage) {
3183 if (time < getstatf(STAT_GAMESTARTTIME)) {
3184 //while restart is still active, show 00:00
3185 timer = seconds_tostring(0);
3187 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3188 timer = seconds_tostring(elapsedTime);
3191 timer = seconds_tostring(timeleft);
3194 drawfont = hud_bigfont;
3195 drawstring_aspect(pos, timer, mySize, mySize_y, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3196 drawfont = hud_font;
3201 void HUD_Radar(void)
3203 if (!(autocvar_hud_radar != 0 && (autocvar_hud_radar == 2 || teamplay || autocvar__hud_configure)))
3206 float id = HUD_PANEL_RADAR;
3207 HUD_Panel_UpdateCvarsForId(id);
3210 mySize = panel_size;
3212 HUD_Panel_DrawBg(1);
3213 if(panel_bg_padding)
3215 pos += '1 1 0' * panel_bg_padding;
3216 mySize -= '2 2 0' * panel_bg_padding;
3219 local float color1, color2; // color already declared as a global in hud.qc
3222 float scale2d, normalsize, bigsize;
3225 teamradar_origin2d = pos + 0.5 * mySize;
3226 teamradar_size2d = mySize;
3228 if(minimapname == "")
3231 teamradar_loadcvars();
3233 switch(hud_radar_zoommode)
3237 f = current_zoomfraction;
3240 f = 1 - current_zoomfraction;
3250 switch(hud_radar_rotation)
3253 teamradar_angle = view_angles_y - 90;
3256 teamradar_angle = 90 * hud_radar_rotation;
3260 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3261 teamradar_size2d = mySize;
3263 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3265 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3266 if(hud_radar_rotation == 0)
3268 // max-min distance must fit the radar in any rotation
3269 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3273 vector c0, c1, c2, c3, span;
3274 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3275 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3276 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3277 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3279 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3280 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3282 // max-min distance must fit the radar in x=x, y=y
3284 teamradar_size2d_x * scale2d / (1.05 * span_x),
3285 teamradar_size2d_y * scale2d / (1.05 * span_y)
3289 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3290 if(bigsize > normalsize)
3291 normalsize = bigsize;
3295 + (1 - f) * normalsize;
3296 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3297 f * (mi_min + mi_max) * 0.5
3298 + (1 - f) * view_origin);
3300 color1 = GetPlayerColor(player_localentnum-1);
3301 rgb = GetTeamRGB(color1);
3310 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3312 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3313 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3314 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3315 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3316 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3318 color2 = GetPlayerColor(tm.sv_entnum);
3319 //if(color == COLOR_SPECTATOR || color == color2)
3320 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3322 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3324 drawresetcliparea();
3329 void HUD_Score(void)
3331 if(!autocvar_hud_score && !autocvar__hud_configure)
3334 float id = HUD_PANEL_SCORE;
3335 HUD_Panel_UpdateCvarsForId(id);
3338 mySize = panel_size;
3340 HUD_Panel_DrawBg(1);
3341 if(panel_bg_padding)
3343 pos += '1 1 0' * panel_bg_padding;
3344 mySize -= '2 2 0' * panel_bg_padding;
3347 float score, distribution, leader;
3349 vector distribution_color;
3351 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3353 // TODO... this (race part) still uses constant coordinates :/
3354 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3355 /*pl = players.sort_next;
3358 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3359 if(pl.scores[ps_primary] == 0)
3362 score = me.(scores[ps_primary]);
3364 float racemin, racesec, racemsec;
3365 float distsec, distmsec, minusplus;
3367 racemin = floor(score/(60 * TIME_FACTOR));
3368 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
3369 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
3371 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3372 // distribution display
3373 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3375 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
3376 distmsec = fabs(distribution);
3378 distsec = floor(fabs(distribution)/TIME_FACTOR);
3379 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
3380 if (distribution < 0)
3384 if (distribution <= 0) {
3385 distribution_color = eY;
3386 minusplus = 1; // minusplus 1: always prefix with minus sign
3389 distribution_color = eX;
3390 minusplus = 2; // minusplus 1: always prefix with plus sign
3392 //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);
3393 //HUD_DrawXNum(bottomright - '68 48 0' - '16 0 0' * TIME_DECIMALS, distsec, 4, minusplus, 16, distribution_color, 0, 0, panel_fg_alpha, DRAWFLAG_NORMAL);
3394 drawpic_aspect_skin(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "num_dot", '16 16 0', distribution_color, panel_fg_alpha, DRAWFLAG_ADDITIVE);
3396 // race record display
3397 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
3398 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);
3400 //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);
3401 //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);
3402 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);
3404 //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);
3405 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);
3407 } else if (!teamplay) { // non-teamgames
3408 // me vector := [team/connected frags id]
3409 pl = players.sort_next;
3413 if(autocvar__hud_configure)
3416 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3420 score = me.(scores[ps_primary]);
3421 if(autocvar__hud_configure)
3424 if(distribution >= 5) {
3425 distribution_color = eY;
3427 } else if(distribution >= 0) {
3428 distribution_color = '1 1 1';
3430 } else if(distribution >= -5)
3431 distribution_color = '1 1 0';
3433 distribution_color = eX;
3435 score_len = strlen(ftos(score));
3437 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);
3439 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);
3440 drawfont = hud_bigfont;
3441 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3442 drawfont = hud_font;
3443 } else { // teamgames
3444 float max_fragcount;
3445 max_fragcount = -99;
3448 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3449 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !autocvar__hud_configure)) // no players? don't display
3451 score = tm.(teamscores[ts_primary]);
3452 if(autocvar__hud_configure)
3456 score_len = strlen(ftos(score));
3458 if (score > max_fragcount)
3459 max_fragcount = score;
3461 if(tm.team == myteam) {
3462 if (max_fragcount == score)
3465 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);
3466 drawfont = hud_bigfont;
3467 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);
3468 drawfont = hud_font;
3470 if (max_fragcount == score)
3473 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);
3474 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);
3483 void HUD_RaceTimer (void) {
3484 if(!autocvar_hud_racetimer && !(gametype == GAME_RACE || gametype == GAME_CTS) && !autocvar__hud_configure)
3487 float id = HUD_PANEL_RACETIMER;
3488 HUD_Panel_UpdateCvarsForId(id);
3491 mySize = panel_size;
3493 HUD_Panel_DrawBg(1);
3494 if(panel_bg_padding)
3496 pos += '1 1 0' * panel_bg_padding;
3497 mySize -= '2 2 0' * panel_bg_padding;
3500 // always force 2:1 aspect
3502 if(mySize_x/mySize_y > 2)
3504 newSize_x = 2 * mySize_y;
3505 newSize_y = mySize_y;
3507 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3511 newSize_y = 1/2 * mySize_x;
3512 newSize_x = mySize_x;
3514 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3518 drawfont = hud_bigfont;
3520 string s, forcetime;
3522 if(autocvar__hud_configure)
3525 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);
3526 s = "^1Intermediate 1 (+15.42)";
3527 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);
3528 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3529 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);
3531 else if(race_checkpointtime)
3533 a = bound(0, 2 - (time - race_checkpointtime), 1);
3536 if(a > 0) // just hit a checkpoint?
3538 if(race_checkpoint != 254)
3540 if(race_time && race_previousbesttime)
3541 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3543 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3545 forcetime = TIME_ENCODED_TOSTRING(race_time);
3550 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3552 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3553 if(a > 0) // next one?
3555 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3560 if(s != "" && a > 0)
3562 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3563 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3564 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);
3567 if(race_penaltytime)
3569 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3572 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3573 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3574 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3575 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);
3581 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3582 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', panel_fg_alpha, 0, a);
3583 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);
3588 if(race_laptime && race_checkpoint != 255)
3590 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3591 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3592 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);
3597 if(race_mycheckpointtime)
3599 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3600 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3601 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3602 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3603 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);
3605 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3607 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3608 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3609 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3610 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3611 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);
3614 if(race_penaltytime && !race_penaltyaccumulator)
3616 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3617 a = bound(0, (1 + t - time), 1);
3621 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3623 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3624 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3625 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3626 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);
3631 drawfont = hud_font;
3636 float vote_yescount;
3639 float vote_highlighted; // currently selected vote
3641 float vote_active; // is there an active vote?
3642 float vote_prev; // previous state of vote_active to check for a change
3644 float vote_change; // "time" when vote_active changed
3646 void HUD_VoteWindow(void)
3648 if(!autocvar_hud_vote && !autocvar__hud_configure)
3651 float id = HUD_PANEL_VOTE;
3652 HUD_Panel_UpdateCvarsForId(id);
3655 mySize = panel_size;
3659 if(vote_active != vote_prev) {
3661 vote_prev = vote_active;
3664 if(vote_active || autocvar__hud_configure)
3665 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3667 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3669 if(autocvar__hud_configure)
3679 a = vote_alpha * bound(autocvar_hud_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3681 HUD_Panel_DrawBg(1);
3682 if(panel_bg_padding)
3684 pos += '1 1 0' * panel_bg_padding;
3685 mySize -= '2 2 0' * panel_bg_padding;
3688 // always force 2:1 aspect
3690 if(mySize_x/mySize_y > 2)
3692 newSize_x = 2 * mySize_y;
3693 newSize_y = mySize_y;
3695 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3699 newSize_y = 1/2 * mySize_x;
3700 newSize_x = mySize_x;
3702 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3706 drawpic_aspect_skin(pos, "voteprogress_back", mySize, '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3708 s = "A vote has been called for: ";
3709 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);
3710 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (3/12), stringwidth_colors); // TODO: broken?
3711 if(autocvar__hud_configure)
3712 s = "Configure the HUD";
3713 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);
3715 // print the yes/no counts
3716 s = strcat("Yes: ", ftos(vote_yescount));
3717 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);
3718 s = strcat("No: ", ftos(vote_nocount));
3719 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);
3721 // draw the progress bars
3722 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3723 drawpic_aspect_skin(pos, "voteprogress_prog", mySize, eY, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3725 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3726 drawpic_aspect_skin(pos, "voteprogress_prog", mySize, eX, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3728 // draw the highlights
3729 if(vote_highlighted == 1) {
3730 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3731 drawpic_aspect_skin(pos, "voteprogress_voted", mySize, eY, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3733 else if(vote_highlighted == 2) {
3734 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3735 drawpic_aspect_skin(pos, "voteprogress_voted", mySize, eX, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3738 drawresetcliparea();
3741 vote_highlighted = 0;
3745 // Mod icons panel (#10)
3748 float mod_active; // is there any active mod icon?
3750 // CTF HUD modicon section
3751 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3752 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3753 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3755 void HUD_Mod_CTF_Reset(void)
3757 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3760 void HUD_Mod_CTF(vector pos, vector mySize)
3762 vector redflag_pos, blueflag_pos;
3764 float f; // every function should have that
3766 float redflag, blueflag; // current status
3767 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3770 stat_items = getstati(STAT_ITEMS);
3771 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3772 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3774 if(redflag || blueflag)
3779 if(autocvar__hud_configure)
3785 // when status CHANGES, set old status into prevstatus and current status into status
3786 if (redflag != redflag_prevframe)
3788 redflag_statuschange_time = time;
3789 redflag_prevstatus = redflag_prevframe;
3790 redflag_prevframe = redflag;
3793 if (blueflag != blueflag_prevframe)
3795 blueflag_statuschange_time = time;
3796 blueflag_prevstatus = blueflag_prevframe;
3797 blueflag_prevframe = blueflag;
3800 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3801 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3803 float BLINK_FACTOR = 0.15;
3804 float BLINK_BASE = 0.85;
3806 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3808 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3810 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3812 string red_icon, red_icon_prevstatus;
3813 float red_alpha, red_alpha_prevstatus;
3814 red_alpha = red_alpha_prevstatus = 1;
3816 case 1: red_icon = "flag_red_taken"; break;
3817 case 2: red_icon = "flag_red_lost"; break;
3818 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3820 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3821 red_icon = "flag_red_shielded";
3823 red_icon = string_null;
3826 switch(redflag_prevstatus) {
3827 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3828 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3829 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3832 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3833 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3834 red_icon_prevstatus = "flag_red_shielded";
3836 red_icon_prevstatus = string_null;
3840 string blue_icon, blue_icon_prevstatus;
3841 float blue_alpha, blue_alpha_prevstatus;
3842 blue_alpha = blue_alpha_prevstatus = 1;
3844 case 1: blue_icon = "flag_blue_taken"; break;
3845 case 2: blue_icon = "flag_blue_lost"; break;
3846 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3848 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3849 blue_icon = "flag_blue_shielded";
3851 blue_icon = string_null;
3854 switch(blueflag_prevstatus) {
3855 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3856 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3857 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3860 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3861 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3862 blue_icon_prevstatus = "flag_blue_shielded";
3864 blue_icon_prevstatus = string_null;
3868 if(mySize_x > mySize_y) {
3869 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3871 blueflag_pos = pos + eX * 0.5 * mySize_x;
3874 redflag_pos = pos + eX * 0.5 * mySize_x;
3876 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3878 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3880 blueflag_pos = pos + eY * 0.5 * mySize_y;
3883 redflag_pos = pos + eY * 0.5 * mySize_y;
3885 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3888 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3889 if(red_icon_prevstatus && f < 1)
3890 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3892 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3894 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3895 if(blue_icon_prevstatus && f < 1)
3896 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3898 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3901 // Keyhunt HUD modicon section
3902 float kh_runheretime;
3904 void HUD_Mod_KH_Reset(void)
3909 void HUD_Mod_KH(vector pos, vector mySize)
3911 mod_active = 1; // keyhunt should never hide the mod icons panel
3915 vector p, pa, kh_size, kh_asize;
3917 kh_keys = getstati(STAT_KH_KEYS);
3920 if(mySize_x > mySize_y)
3922 p_y = pos_y + 0.25 * mySize_y;
3923 pa = p - eY * 0.25 * mySize_y;
3925 kh_size_x = mySize_x * 0.25;
3926 kh_size_y = 0.75 * mySize_y;
3927 kh_asize_x = mySize_x * 0.25;
3928 kh_asize_y = mySize_y * 0.25;
3932 p_y = pos_y + 0.125 * mySize_y;
3933 pa = p - eY * 0.125 * mySize_y;
3935 kh_size_x = mySize_x * 0.5;
3936 kh_size_y = 0.375 * mySize_y;
3937 kh_asize_x = mySize_x * 0.5;
3938 kh_asize_y = mySize_y * 0.125;
3945 for(i = 0; i < 4; ++i)
3947 key = floor(kh_keys / pow(32, i)) & 31;
3949 if(keyteam == 30 && keycount <= 4)
3951 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3955 // this yields 8 exactly if "RUN HERE" shows
3960 kh_runheretime = time;
3961 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3966 for(i = 0; i < 4; ++i)
3968 key = floor(kh_keys / pow(32, i)) & 31;
3981 default: // owned or dropped
3986 a = a * panel_fg_alpha;
3987 aa = aa * panel_fg_alpha;
3993 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3996 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3999 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4002 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
4007 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
4010 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4013 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4016 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4019 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
4023 if(mySize_x > mySize_y)
4025 p_x += 0.25 * mySize_x;
4026 pa_x += 0.25 * mySize_x;
4032 p_y = pos_y + 0.625 * mySize_y;
4033 pa_y = pos_y + 0.5 * mySize_y;
4039 p_x += 0.5 * mySize_x;
4040 pa_x += 0.5 * mySize_x;
4046 // Nexball HUD mod icon
4047 void HUD_Mod_NexBall(vector pos, vector mySize)
4049 float stat_items, nb_pb_starttime, dt, p;
4051 stat_items = getstati(STAT_ITEMS);
4052 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
4054 if (stat_items & IT_KEY1)
4059 //Manage the progress bar if any
4060 if (nb_pb_starttime > 0)
4062 dt = mod(time - nb_pb_starttime, nb_pb_period);
4063 // one period of positive triangle
4064 p = 2 * dt / nb_pb_period;
4071 if(mySize_x > mySize_y)
4073 barsize = eX * p * mySize_x + eY * mySize_y;
4078 barsize = eX * mySize_x + eY * p * mySize_y;
4081 HUD_Panel_GetProgressBarColor("nexball")
4082 HUD_Panel_DrawProgressBar(pos, vertical, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4085 if (stat_items & IT_KEY1)
4086 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4089 // Race/CTS HUD mod icons
4090 float crecordtime_prev; // last remembered crecordtime
4091 float crecordtime_change_time; // time when crecordtime last changed
4092 float srecordtime_prev; // last remembered srecordtime
4093 float srecordtime_change_time; // time when srecordtime last changed
4095 float race_status_time;
4096 float race_status_prev;
4097 string race_status_name_prev;
4098 void HUD_Mod_Race(vector pos, vector mySize)
4100 mod_active = 1; // race should never hide the mod icons panel
4102 me = playerslots[player_localentnum - 1];
4104 float f; // yet another function has this
4105 score = me.(scores[ps_primary]);
4107 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
4108 return; // no records in the actual race
4110 drawfont = hud_bigfont;
4112 // clientside personal record
4114 if(gametype == GAME_CTS)
4118 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4120 if(score && (score < t || !t)) {
4121 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4122 if(cvar("cl_autodemo_delete_keeprecords"))
4124 f = cvar("cl_autodemo_delete");
4126 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4130 if(t != crecordtime_prev) {
4131 crecordtime_prev = t;
4132 crecordtime_change_time = time;
4134 f = time - crecordtime_change_time;
4137 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);
4138 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);
4140 drawstring(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4141 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);
4142 drawstring_expanding(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4143 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);
4147 t = race_server_record;
4148 if(t != srecordtime_prev) {
4149 srecordtime_prev = t;
4150 srecordtime_change_time = time;
4152 f = time - srecordtime_change_time;
4155 drawstring(pos + eY * 0.5 * mySize_y, "Server best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4156 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);
4158 drawstring(pos + eY * 0.5 * mySize_y, "Server best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4159 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);
4160 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);
4161 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);
4164 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4165 race_status_time = time + 5;
4166 race_status_prev = race_status;
4167 if (race_status_name_prev)
4168 strunzone(race_status_name_prev);
4169 race_status_name_prev = strzone(race_status_name);
4172 pos_x += mySize_x/2;
4175 a = bound(0, race_status_time - time, 1);
4178 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4182 rank = race_CheckName(race_status_name);
4184 rankname = race_PlaceName(rank);
4187 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4189 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4191 if(race_status == 0)
4192 drawpic_aspect_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4193 else if(race_status == 1) {
4194 drawpic_aspect_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4195 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4196 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4197 } else if(race_status == 2) {
4198 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4199 drawpic_aspect_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4201 drawpic_aspect_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4202 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4203 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4204 } else if(race_status == 3) {
4205 drawpic_aspect_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4206 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4207 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4210 if (race_status_time - time <= 0) {
4211 race_status_prev = -1;
4213 if(race_status_name)
4214 strunzone(race_status_name);
4215 race_status_name = string_null;
4216 if(race_status_name_prev)
4217 strunzone(race_status_name_prev);
4218 race_status_name_prev = string_null;
4220 drawfont = hud_font;
4223 float mod_prev; // previous state of mod_active to check for a change
4225 float mod_change; // "time" when mod_active changed
4227 void HUD_ModIcons(void)
4229 if(!autocvar_hud_modicons && !autocvar__hud_configure)
4232 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !autocvar__hud_configure)
4235 float id = HUD_PANEL_MODICONS;
4236 HUD_Panel_UpdateCvarsForId(id);
4239 mySize = panel_size;
4241 if(mod_active != mod_prev) {
4243 mod_prev = mod_active;
4246 if(mod_active || autocvar__hud_configure)
4247 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4249 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4252 HUD_Panel_DrawBg(mod_alpha);
4254 if(panel_bg_padding)
4256 pos += '1 1 0' * panel_bg_padding;
4257 mySize -= '2 2 0' * panel_bg_padding;
4260 // these MUST be ran in order to update mod_active
4261 if(gametype == GAME_KEYHUNT)
4262 HUD_Mod_KH(pos, mySize);
4263 else if(gametype == GAME_CTF || autocvar__hud_configure)
4264 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4265 else if(gametype == GAME_NEXBALL)
4266 HUD_Mod_NexBall(pos, mySize);
4267 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4268 HUD_Mod_Race(pos, mySize);
4271 // Draw pressed keys (#11)
4273 void HUD_DrawPressedKeys(void)
4275 if(!autocvar_hud_pressedkeys && !autocvar__hud_configure)
4278 if(!(spectatee_status > 0 || autocvar_hud_pressedkeys >= 2 || autocvar__hud_configure))
4281 float id = HUD_PANEL_PRESSEDKEYS;
4282 HUD_Panel_UpdateCvarsForId(id);
4285 mySize = panel_size;
4287 HUD_Panel_DrawBg(1);
4288 if(panel_bg_padding)
4290 pos += '1 1 0' * panel_bg_padding;
4291 mySize -= '2 2 0' * panel_bg_padding;
4295 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4298 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4299 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4300 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);
4301 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);
4302 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);
4303 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);
4304 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);
4307 // Handle chat as a panel (#12)
4311 if(!autocvar_hud_chat && !autocvar__hud_configure)
4313 cvar_set("con_chatrect", "0");
4317 float id = HUD_PANEL_CHAT;
4318 HUD_Panel_UpdateCvarsForId(id);
4321 mySize = panel_size;
4323 HUD_Panel_DrawBg(1);
4324 if(panel_bg_padding)
4326 pos += '1 1 0' * panel_bg_padding;
4327 mySize -= '2 2 0' * panel_bg_padding;
4330 cvar_set("con_chatrect", "1");
4332 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4333 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4335 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4336 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4338 if(autocvar__hud_configure)
4341 chatsize = cvar("con_chatsize");
4342 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4344 for(i = 0; i < cvar("con_chat"); ++i)
4346 if(i == cvar("con_chat") - 1)
4349 a = panel_fg_alpha * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4350 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);
4355 // Engine info panel (#13)
4362 float frametimeavg1; // 1 frame ago
4363 float frametimeavg2; // 2 frames ago
4364 void HUD_EngineInfo(void)
4366 if(!autocvar_hud_engineinfo && !autocvar__hud_configure)
4369 float id = HUD_PANEL_ENGINEINFO;
4370 HUD_Panel_UpdateCvarsForId(id);
4373 mySize = panel_size;
4375 HUD_Panel_DrawBg(1);
4376 if(panel_bg_padding)
4378 pos += '1 1 0' * panel_bg_padding;
4379 mySize -= '2 2 0' * panel_bg_padding;
4382 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4384 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4385 frametimeavg2 = frametimeavg1;
4386 frametimeavg1 = frametimeavg;
4389 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4390 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.
4392 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
4393 prevfps = (1/frametime);
4394 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"
4400 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4402 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4404 prevfps_time = time;
4409 color = HUD_Get_Num_Color (prevfps, 100);
4410 drawfont = hud_bigfont;
4411 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), mySize, mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4412 drawfont = hud_font;
4420 void HUD_ShowSpeed(void)
4423 float pos, conversion_factor;
4424 string speed, zspeed, unit;
4426 switch(cvar("cl_showspeed_unit"))
4431 conversion_factor = 1.0;
4435 conversion_factor = 1.0;
4439 conversion_factor = 0.0254;
4443 conversion_factor = 0.0254 * 3.6;
4447 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4451 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4455 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4457 numsize_x = numsize_y = cvar("cl_showspeed_size");
4458 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4460 drawfont = hud_bigfont;
4461 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4463 if (cvar("cl_showspeed_z") == 1) {
4464 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4465 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4468 drawfont = hud_font;
4471 vector acc_prevspeed;
4475 void HUD_ShowAcceleration(void)
4477 float acceleration, sz, scale, alpha, f;
4478 vector pos, top, rgb;
4479 top_x = vid_conwidth/2;
4482 f = time - acc_prevtime;
4483 if(cvar("cl_showacceleration_z"))
4484 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4486 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4487 acc_prevspeed = pmove_vel;
4488 acc_prevtime = time;
4490 f = bound(0, f * 10, 1);
4491 acc_avg = acc_avg * (1 - f) + acceleration * f;
4492 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4494 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4496 sz = cvar("cl_showacceleration_size");
4497 scale = cvar("cl_showacceleration_scale");
4498 alpha = cvar("cl_showacceleration_alpha");
4499 if (cvar("cl_showacceleration_color_custom"))
4500 rgb = stov(cvar_string("cl_showacceleration_color"));
4503 if (acceleration < 0) {
4504 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4505 } else if (acceleration > 0) {
4506 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4510 if (acceleration > 0)
4511 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4512 else if (acceleration < 0)
4513 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4516 void HUD_Reset (void)
4518 // reset gametype specific icons
4519 if(gametype == GAME_KEYHUNT)
4521 else if(gametype == GAME_CTF)
4522 HUD_Mod_CTF_Reset();
4525 #define HUD_DrawPanel(id)\
4527 case (HUD_PANEL_RADAR):\
4528 HUD_Radar(); break;\
4529 case (HUD_PANEL_WEAPONICONS):\
4530 HUD_WeaponIcons(); break;\
4531 case (HUD_PANEL_INVENTORY):\
4532 HUD_Inventory(); break;\
4533 case (HUD_PANEL_POWERUPS):\
4534 HUD_Powerups(); break;\
4535 case (HUD_PANEL_HEALTHARMOR):\
4536 HUD_HealthArmor(); break;\
4537 case (HUD_PANEL_NOTIFY):\
4538 HUD_Notify(); break;\
4539 case (HUD_PANEL_TIMER):\
4540 HUD_Timer(); break;\
4541 case (HUD_PANEL_SCORE):\
4542 HUD_Score(); break;\
4543 case (HUD_PANEL_RACETIMER):\
4544 HUD_RaceTimer(); break;\
4545 case (HUD_PANEL_VOTE):\
4546 HUD_VoteWindow(); break;\
4547 case (HUD_PANEL_MODICONS):\
4548 HUD_ModIcons(); break;\
4549 case (HUD_PANEL_PRESSEDKEYS):\
4550 HUD_DrawPressedKeys(); break;\
4551 case (HUD_PANEL_CHAT):\
4553 case (HUD_PANEL_ENGINEINFO):\
4554 HUD_EngineInfo(); break;\
4557 void HUD_Main (void)
4559 // TODO: render order?
4560 hud_skin_path = strcat("gfx/hud/", autocvar_hud_skin);
4562 if(disable_menu_alphacheck == 1)
4563 menu_fade_alpha = 1;
4565 menu_fade_alpha = (1 - autocvar__menu_alpha);
4566 hud_fg_alpha = cvar("hud_fg_alpha");
4568 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4569 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4570 hud_color_bg_team = cvar("hud_color_bg_team");
4572 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4573 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4577 // HUD configure visible grid
4578 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4582 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2); ++i)
4584 drawfill(eX * i * vid_conwidth * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2), eX + eY * vid_conheight, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4587 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2); ++i)
4589 drawfill(eY * i * vid_conheight * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2), eY + eX * vid_conwidth, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4595 if(teamplay && autocvar_hud_dock_color_team) {
4596 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4597 color = colormapPaletteColor(mod(f, 16), 1) * autocvar_hud_dock_color_team;
4599 else if(autocvar_hud_dock_color == "shirt") {
4600 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4601 color = colormapPaletteColor(floor(f / 16), 0);
4603 else if(autocvar_hud_dock_color == "pants") {
4604 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4605 color = colormapPaletteColor(mod(f, 16), 1);
4608 color = stov(autocvar_hud_dock_color);
4610 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4611 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...
4613 // cache the panel order into the panel_order array
4614 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4615 if(hud_panelorder_prev)
4616 strunzone(hud_panelorder_prev);
4617 hud_panelorder_prev = strzone(autocvar__hud_panelorder);
4618 tokenize_console(autocvar__hud_panelorder);
4619 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4620 panel_order[i] = stof(argv(i));
4623 // draw panels in order specified by panel_order array
4624 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
4625 HUD_DrawPanel(panel_order[i]);
4628 // TODO hud_'ify these
4629 if (cvar("cl_showspeed"))
4631 if (cvar("cl_showacceleration"))
4632 HUD_ShowAcceleration();
4634 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)
4635 localcmd("cmd selectteam auto; cmd join\n");
4637 hud_configure_prev = autocvar__hud_configure;
4639 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again
4640 disable_menu_alphacheck = 0;