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)
20 //pic = draw_UseSkinFor(pic);
21 width = eX * theSize_x;
22 height = eY * theSize_y;
23 if(theSize_x <= theBorderSize_x * 2)
25 // not wide enough... draw just left and right then
26 bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
27 if(theSize_y <= theBorderSize_y * 2)
29 // not high enough... draw just corners
30 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
31 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
32 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
33 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
34 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
38 dY = theBorderSize_x * eY;
39 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
40 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
41 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
42 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);
43 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
44 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);
49 if(theSize_y <= theBorderSize_y * 2)
51 // not high enough... draw just top and bottom then
52 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
53 dX = theBorderSize_x * eX;
54 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
55 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
56 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
57 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
58 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);
59 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);
63 dX = theBorderSize_x * eX;
64 dY = theBorderSize_x * eY;
65 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
66 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
67 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
68 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
69 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
70 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
71 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
72 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
73 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
78 // drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
79 void drawpic_aspect(vector pos, string pic, vector sz, vector color, float alpha, float drawflag) {
81 imgsize = drawgetimagesize(pic);
83 imgaspect = imgsize_x/imgsize_y;
90 if(aspect > imgaspect) {
91 sz_x = sz_y * imgaspect;
92 drawpic(pos + eX * (oldsz_x - sz_x) * 0.5, pic, sz, color, alpha, drawflag);
94 sz_y = sz_x / imgaspect;
95 drawpic(pos + eY * (oldsz_y - sz_y) * 0.5, pic, sz, color, alpha, drawflag);
99 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
100 void drawpic_skin(vector pos, string pic, vector sz, vector color, float alpha, float drawflag) {
101 drawpic_aspect(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, color, alpha, drawflag);
105 void drawpic_skin_expanding(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
106 drawpic_expanding(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
109 void drawpic_skin_expanding_two(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
110 drawpic_expanding_two(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
113 // return HUD background color
114 vector HUD_GetBgColor()
118 GetTeamRGB(myteam) * hud_color_bg_team;
120 // allow custom HUD colors in non-teamgames
121 color_x = cvar("hud_color_bg_r");
122 color_y = cvar("hud_color_bg_g");
123 color_z = cvar("hud_color_bg_b");
128 // return accuracy text color
129 vector HUD_AccuracyColor(float accuracy)
132 float yellow_accuracy = cvar("hud_weaponicons_accuracy_yellow"); // value at which this function returns yellow
133 if(accuracy >= 100) {
137 else if(accuracy > yellow_accuracy) {
138 rgb_x = 1 - (accuracy-yellow_accuracy)/(100-yellow_accuracy); // red value between 1 -> 0
143 rgb_y = accuracy/yellow_accuracy; // green value between 0 -> 1
149 vector HUD_Get_Num_Color (float x, float maxvalue)
157 else if(x > maxvalue * 0.75) {
158 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
159 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
162 else if(x > maxvalue * 0.5) {
163 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
164 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
165 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
167 else if(x > maxvalue * 0.25) {
170 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
172 else if(x > maxvalue * 0.1) {
174 color_y = (x-20)*90/27/100; // green value between 0 -> 1
175 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
185 float stringwidth_colors(string s, vector theSize)
187 return stringwidth(s, TRUE, theSize);
190 float stringwidth_nocolors(string s, vector theSize)
192 return stringwidth(s, FALSE, theSize);
195 #define CENTERPRINT_MAX_LINES 30
196 string centerprint_messages[CENTERPRINT_MAX_LINES];
197 float centerprint_width[CENTERPRINT_MAX_LINES];
198 vector centerprint_start;
199 float centerprint_expire;
200 float centerprint_num;
201 float centerprint_offset_hint;
202 vector centerprint_fontsize;
204 void centerprint(string strMessage)
206 float i, j, n, hcount;
209 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
211 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
213 if(cvar("scr_centertime") <= 0)
219 // strip trailing newlines
220 j = strlen(strMessage) - 1;
221 while(substring(strMessage, j, 1) == "\n" && j >= 0)
223 strMessage = substring(strMessage, 0, j + 1);
228 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
230 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
232 strMessage = substring(strMessage, j, strlen(strMessage) - j);
233 centerprint_offset_hint = j;
238 // if we get here, we have a message. Initialize its height.
241 n = tokenizebyseparator(strMessage, "\n");
243 for(j = 0; j < n; ++j)
245 getWrappedLine_remaining = argv(j);
246 while(getWrappedLine_remaining)
248 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
249 if(centerprint_messages[i])
250 strunzone(centerprint_messages[i]);
251 centerprint_messages[i] = strzone(s);
252 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
255 // half height for empty lines looks better
261 if(i >= CENTERPRINT_MAX_LINES)
267 h = centerprint_fontsize_y*hcount;
269 havail = vid_conheight;
270 if(cvar("con_chatpos") < 0)
271 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
272 if(havail > vid_conheight - 70)
273 havail = vid_conheight - 70; // avoid overlapping HUD
275 centerprint_start_x = 0;
278 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
280 // here, the centerprint would cover the crosshair. REALLY BAD.
281 forbiddenmin = vid_conheight * 0.5 - h - 16;
282 forbiddenmax = vid_conheight * 0.5 + 16;
284 allowedmin = scoreboard_bottom;
285 allowedmax = havail - h;
286 preferred = (havail - h)/2;
289 // possible orderings (total: 4! / 4 = 6)
290 // allowedmin allowedmax forbiddenmin forbiddenmax
291 // forbiddenmin forbiddenmax allowedmin allowedmax
292 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
294 // forbidden doesn't matter in this case
295 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
297 // allowedmin forbiddenmin allowedmax forbiddenmax
298 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
300 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
302 // allowedmin forbiddenmin forbiddenmax allowedmax
303 else if(allowedmin < forbiddenmin)
305 // make sure the forbidden zone is not covered
306 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
307 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
309 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
311 // forbiddenmin allowedmin allowedmax forbiddenmax
312 else if(allowedmax < forbiddenmax)
314 // it's better to leave the allowed zone (overlap with scoreboard) than
315 // to cover the forbidden zone (crosshair)
316 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
317 centerprint_start_y = forbiddenmax;
319 centerprint_start_y = forbiddenmin;
321 // forbiddenmin allowedmin forbiddenmax allowedmax
324 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
327 centerprint_start_y =
330 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
338 centerprint_expire = time + cvar("scr_centertime");
341 void HUD_DrawCenterPrint (void)
348 //if(time > centerprint_expire)
351 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
352 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
353 //sz = 1.2 / (a + 0.2);
358 pos = centerprint_start;
359 for (i=0; i<centerprint_num; i = i + 1)
361 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
362 ts = centerprint_messages[i];
365 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
366 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
367 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
368 pos_y = pos_y + centerprint_fontsize_y;
371 // half height for empty lines looks better
372 pos_y = pos_y + centerprint_fontsize_y * 0.5;
376 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
378 position_x -= 2 / 3 * strlen(text) * scale_x;
379 drawstring(position, text, scale, rgb, alpha, flag);
382 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
384 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
385 drawstring(position, text, scale, rgb, alpha, flag);
388 // return the string of the given race place
389 string race_PlaceName(float pos) {
397 return strcat(ftos(pos), "th");
400 // return the string of the onscreen race timer
401 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
409 if(histime == 0) // goal hit
413 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
423 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
429 lapstr = strcat(" (-", ftos(lapdelta), "L)");
432 else if(lapdelta < 0)
434 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
438 else if(histime > 0) // anticipation
440 if(mytime >= histime)
441 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
443 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
450 cpname = "Start line";
452 cpname = "Finish line";
454 cpname = strcat("Intermediate ", ftos(cp));
456 cpname = "Finish line";
459 return strcat(col, cpname);
460 else if(hisname == "")
461 return strcat(col, cpname, " (", timestr, ")");
463 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
466 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
467 float race_CheckName(string net_name) {
469 for (i=RANKINGS_CNT-1;i>=0;--i)
470 if(grecordholder[i] == net_name)
482 void HUD_Panel_ExportCfg(string cfgname)
485 fh = fopen(strcat("hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg"), FILE_WRITE);
488 fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
489 fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
490 fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
491 fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
492 fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
493 fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
494 fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
495 fputs(fh, strcat("seta hud_fg_alpha \"", cvar_string("hud_fg_alpha"), "\"", "\n"));
498 fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
499 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
500 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
501 fputs(fh, strcat("seta hud_dock_alpha \"", ftos(cvar("hud_dock_alpha")), "\"", "\n"));
504 fputs(fh, strcat("seta hud_progressbar_alpha ", ftos(cvar("hud_progressbar_alpha")), "\n"));
505 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
506 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
507 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
508 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
509 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
510 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
513 // common cvars for all panels
515 for (i = 0; i < HUD_PANEL_NUM; ++i)
517 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), " ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i)))), "\n"));
518 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_pos \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_pos")), "\"", "\n"));
519 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_size \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_size")), "\"", "\n"));
520 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg")), "\"", "\n"));
521 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color")), "\"", "\n"));
522 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color_team \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color_team")), "\"", "\n"));
523 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_alpha \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_alpha")), "\"", "\n"));
524 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_border \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_border")), "\"", "\n"));
525 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_padding \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_padding")), "\"", "\n"));
528 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_accuracy_yellow ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_accuracy_yellow"))), "\n"));
531 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_onlycurrent ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_onlycurrent"))), "\n"));
534 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
535 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_mirror ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
538 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
539 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_mirror ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
542 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
543 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_info_top ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_info_top"))), "\n"));
546 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_foreground_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_foreground_alpha"))), "\n"));
548 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha"))), "\n"));
554 print("^2Successfully exported to hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
559 // return active status of panel
560 float HUD_Panel_CheckActive(float id)
562 if (cvar_or(strcat("hud_", HUD_Panel_GetName(id)), 1))
567 // return size of given panel
568 vector HUD_Panel_GetSize(float id)
571 mySize = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_size")));
573 mySize = eX * mySize_x * vid_conwidth + eY * mySize_y * vid_conheight;
575 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
577 vector menu_enable_maxsize, menu_enable_size;
578 menu_enable_maxsize = '0 0 0'; // shut up FTEQCC
579 menu_enable_maxsize_x = 0.3 * vid_conwidth;
580 menu_enable_maxsize_y = 0.18 * vid_conheight;
581 if(mySize_x > mySize_y)
583 if(mySize_y > menu_enable_maxsize_y)
585 menu_enable_size_y = menu_enable_maxsize_y;
586 menu_enable_size_x = mySize_x * (menu_enable_maxsize_y/mySize_y);
587 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
592 if(mySize_x > menu_enable_maxsize_x)
594 menu_enable_size_x = menu_enable_maxsize_x;
595 menu_enable_size_y = mySize_y * (menu_enable_maxsize_x/mySize_x);
596 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
603 // return pos of given panel
604 vector HUD_Panel_GetPos(float id)
607 pos = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_pos")));
609 pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
611 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
613 vector mySize, menu_enable_panelpos;
614 mySize = HUD_Panel_GetSize(id);
615 if(mySize_x > mySize_y)
616 menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * mySize_x + eY * 0.82 * vid_conheight;
618 menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * mySize_y + eX * 0.7 * vid_conwidth;
619 pos = (1 - cvar("_menu_alpha")) * pos + (cvar("_menu_alpha")) * menu_enable_panelpos;
624 float HUD_Panel_GetBorder(float id)
627 border = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_border"));
629 border = cvar_string("hud_bg_border");
633 vector HUD_Panel_GetColor(float id)
639 // fetch per-panel color
640 if(teamplay && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")) != "") {
641 f = stof(getplayerkey(self.sv_entnum, "colors"));
642 color = vtos(colormapPaletteColor(mod(f, 16), 1) * cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")));
645 color = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color"));
646 color_vec = stov(color);
648 if(color == "") { // fetch default color
649 color = cvar_string("hud_bg_color");
650 color_vec = stov(color);
651 if(teamplay && cvar(strcat("hud_bg_color_team"))) {
652 f = stof(getplayerkey(self.sv_entnum, "colors"));
653 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_bg_color_team");
655 else if(color == "shirt") {
656 f = stof(getplayerkey(self.sv_entnum, "colors"));
657 color_vec = colormapPaletteColor(floor(f / 16), 0);
659 else if(color == "pants") {
660 f = stof(getplayerkey(self.sv_entnum, "colors"));
661 color_vec = colormapPaletteColor(mod(f, 16), 1);
664 else if(color == "shirt") {
665 f = stof(getplayerkey(self.sv_entnum, "colors"));
666 color_vec = colormapPaletteColor(floor(f / 16), 0);
668 else if(color == "pants") {
669 f = stof(getplayerkey(self.sv_entnum, "colors"));
670 color_vec = colormapPaletteColor(mod(f, 16), 1);
675 vector HUD_Panel_Dock_GetColor(void)
680 color = cvar_string("hud_dock_color");
681 color_vec = stov(color);
682 if(teamplay && cvar(strcat("hud_dock_color_team"))) {
683 f = stof(getplayerkey(self.sv_entnum, "colors"));
684 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_dock_color_team");
686 else if(color == "shirt") {
687 f = stof(getplayerkey(self.sv_entnum, "colors"));
688 color_vec = colormapPaletteColor(floor(f / 16), 0);
690 else if(color == "pants") {
691 f = stof(getplayerkey(self.sv_entnum, "colors"));
692 color_vec = colormapPaletteColor(mod(f, 16), 1);
697 float HUD_Panel_GetBgAlpha(float id)
700 alpha = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_alpha"));
702 alpha = cvar_string("hud_bg_alpha");
704 if(hud_configure && disable_menu_alphacheck == 2 && highlightedPanel == id) // do not set a minalpha cap when showing the config dialog for this panel
705 alpha = ftos((1 - cvar("_menu_alpha")) * max(cvar("hud_configure_bg_minalpha"), stof(alpha)) + (cvar("_menu_alpha")) * stof(alpha));
706 else if(hud_configure)
707 alpha = ftos(max(cvar("hud_configure_bg_minalpha"), stof(alpha)));
709 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
712 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
715 return stof(alpha) * menu_fade_alpha;
718 float HUD_Panel_GetFgAlpha(float id)
721 alpha = hud_fg_alpha;
723 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
726 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
729 return alpha * menu_fade_alpha;
732 float HUD_Panel_GetPadding(float id)
735 padding = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
737 padding = cvar_string("hud_bg_padding");
740 mySize = HUD_Panel_GetSize(id);
742 smallestsize = min(mySize_x, mySize_y);
743 return min(smallestsize/2 - 5, stof(padding));
746 // draw the background/borders
747 void HUD_Panel_DrawBg(float id, vector pos, vector mySize, float alpha)
749 if(!hud_configure && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg")) == "0")
753 bg = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg"));
755 bg = cvar_string("hud_bg");
757 if(bg == "0" && hud_configure) {
758 bg = "border"; // we probably want to see a background in config mode at all times...
764 border = max(0.0000001, HUD_Panel_GetBorder(id)); // draw_BorderPicture does not like border = 0
767 color = HUD_Panel_GetColor(id);
770 alpha = HUD_Panel_GetBgAlpha(id) * alpha; // allow panels to fade in/out by passing an alpha value
772 alpha = HUD_Panel_GetBgAlpha(id);
774 draw_BorderPicture(pos - '1 1 0' * border, strcat("gfx/hud/", cvar_string("hud_skin"), "/", bg), mySize + '1 1 0' * 2 * border, color, alpha, '1 1 0' * (border/BORDER_MULTIPLIER));
778 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
784 pic = strcat("gfx/hud/", cvar_string("hud_skin"), "/");
786 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);
787 if(mySize_y/mySize_x > 2)
788 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);
789 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);
791 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);
792 if(mySize_x/mySize_y > 2)
793 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);
794 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);
798 vector HUD_Panel_GetProgressBarColor(string item)
800 return stov(cvar_string(strcat("hud_progressbar_", item, "_color")));
803 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
804 vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
815 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
816 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
818 for (i = 0; i < HUD_PANEL_NUM; ++i) {
819 if(i == id || !HUD_Panel_CheckActive(i))
822 targPos = HUD_Panel_GetPos(i) - '1 1 0' * HUD_Panel_GetBorder(id);
823 targSize = HUD_Panel_GetSize(i) + '2 2 0' * HUD_Panel_GetBorder(id);
825 if(myPos_y + mySize_y < targPos_y)
827 if(myPos_y > targPos_y + targSize_y)
830 if(myPos_x + mySize_x < targPos_x)
832 if(myPos_x > targPos_x + targSize_x)
835 // OK, there IS a collision.
837 myCenter_x = myPos_x + 0.5 * mySize_x;
838 myCenter_y = myPos_y + 0.5 * mySize_y;
840 targCenter_x = targPos_x + 0.5 * targSize_x;
841 targCenter_y = targPos_y + 0.5 * targSize_y;
843 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
845 if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
846 myTarget_x = targPos_x - mySize_x;
847 else // push it upwards
848 myTarget_y = targPos_y - mySize_y;
850 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
852 if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
853 myTarget_x = targPos_x + targSize_x;
854 else // push it upwards
855 myTarget_y = targPos_y - mySize_y;
857 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
859 if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
860 myTarget_x = targPos_x - mySize_x;
861 else // push it downwards
862 myTarget_y = targPos_y + targSize_y;
864 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
866 if(targPos_x + targSize_x - myPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
867 myTarget_x = targPos_x + targSize_x;
868 else // push it downwards
869 myTarget_y = targPos_y + targSize_y;
876 void HUD_Panel_SetPos(float id, vector pos)
879 oldPos = HUD_Panel_GetPos(id);
882 mySize = HUD_Panel_GetSize(id);
884 if(cvar("hud_configure_checkcollisions"))
885 pos = HUD_Panel_CheckMove(id, pos, mySize);
887 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
888 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
890 if(cvar("hud_configure_grid"))
892 pos_x = floor((pos_x/vid_conwidth)/bound(0.005, cvar("hud_configure_grid_x"), 0.2) + 0.5) * bound(0.005, cvar("hud_configure_grid_x"), 0.2) * vid_conwidth;
893 pos_y = floor((pos_y/vid_conheight)/bound(0.005, cvar("hud_configure_grid_y"), 0.2) + 0.5) * bound(0.005, cvar("hud_configure_grid_y"), 0.2) * vid_conheight;
897 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
899 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
902 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
903 vector HUD_Panel_CheckResize(float id, vector mySize, vector resizeorigin) {
912 for (i = 0; i < HUD_PANEL_NUM; ++i) {
913 if(i == id || !HUD_Panel_CheckActive(i))
916 targBorder = HUD_Panel_GetBorder(i);
917 targPos = HUD_Panel_GetPos(i) - '1 1 0' * targBorder;
918 targSize = HUD_Panel_GetSize(i) + '2 2 0' * targBorder;
919 targEndPos = targPos + targSize;
921 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
922 if(resizeorigin_x > targPos_x && resizeorigin_x < targPos_x + targSize_x && resizeorigin_y > targPos_y && resizeorigin_y < targPos_y + targSize_y)
925 if (resizeCorner == 1)
927 // check if this panel is on our way
928 if (resizeorigin_x <= targPos_x)
930 if (resizeorigin_y <= targPos_y)
932 if (targEndPos_x <= resizeorigin_x - mySize_x)
934 if (targEndPos_y <= resizeorigin_y - mySize_y)
937 // there is a collision:
938 // detect which side of the panel we are facing is actually limiting the resizing
939 // (which side the resize direction finds for first) and reduce the size up to there
941 // dist is the distance between resizeorigin and the "analogous" point of the panel
942 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
943 dist_x = resizeorigin_x - targEndPos_x;
944 dist_y = resizeorigin_y - targEndPos_y;
946 mySize_x = min(mySize_x, dist_x);
948 mySize_y = min(mySize_y, dist_y);
950 else if (resizeCorner == 2)
952 if (resizeorigin_x >= targEndPos_x)
954 if (resizeorigin_y <= targPos_y)
956 if (targPos_x >= resizeorigin_x + mySize_x)
958 if (targEndPos_y <= resizeorigin_y - mySize_y)
961 dist_x = targPos_x - resizeorigin_x;
962 dist_y = resizeorigin_y - targEndPos_y;
964 mySize_x = min(mySize_x, dist_x);
966 mySize_y = min(mySize_y, dist_y);
968 else if (resizeCorner == 3)
970 if (resizeorigin_x <= targPos_x)
972 if (resizeorigin_y >= targEndPos_y)
974 if (targEndPos_x <= resizeorigin_x - mySize_x)
976 if (targPos_y >= resizeorigin_y + mySize_y)
979 dist_x = resizeorigin_x - targEndPos_x;
980 dist_y = targPos_y - resizeorigin_y;
982 mySize_x = min(mySize_x, dist_x);
984 mySize_y = min(mySize_y, dist_y);
986 else if (resizeCorner == 4)
988 if (resizeorigin_x >= targEndPos_x)
990 if (resizeorigin_y >= targEndPos_y)
992 if (targPos_x >= resizeorigin_x + mySize_x)
994 if (targPos_y >= resizeorigin_y + mySize_y)
997 dist_x = targPos_x - resizeorigin_x;
998 dist_y = targPos_y - resizeorigin_y;
1000 mySize_x = min(mySize_x, dist_x);
1002 mySize_y = min(mySize_y, dist_y);
1004 if(cvar("hud_configure_checkcollisions_debug"))
1005 drawfill(targPos + '1 1 0' * targBorder, targSize - '2 2 0' * targBorder, '1 1 0', .3, DRAWFLAG_NORMAL);
1011 void HUD_Panel_SetPosSize(float id)
1013 vector resizeorigin;
1014 resizeorigin = panel_click_resizeorigin;
1015 vector mySize, myPos;
1017 if(resizeCorner == 1) {
1018 mySize_x = resizeorigin_x - (mousepos_x - panel_click_distance_x);
1019 mySize_y = resizeorigin_y - (mousepos_y - panel_click_distance_y);
1020 } else if(resizeCorner == 2) {
1021 mySize_x = mousepos_x + panel_click_distance_x - resizeorigin_x;
1022 mySize_y = panel_click_distance_y + resizeorigin_y - mousepos_y;
1023 } else if(resizeCorner == 3) {
1024 mySize_x = resizeorigin_x + panel_click_distance_x - mousepos_x;
1025 mySize_y = mousepos_y + panel_click_distance_y - resizeorigin_y;
1026 } else { // resizeCorner == 4
1027 mySize_x = mousepos_x - (resizeorigin_x - panel_click_distance_x);
1028 mySize_y = mousepos_y - (resizeorigin_y - panel_click_distance_y);
1031 // minimum panel size cap
1032 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1033 mySize_y = max(0.025 * vid_conheight, mySize_y);
1035 if(id == 12) // 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.
1037 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
1038 mySize_y = max(2 * cvar("con_chatsize") + 2 * HUD_Panel_GetPadding(id), mySize_y);
1041 // collision testing|
1042 // -----------------+
1044 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
1045 if(resizeCorner == 1) {
1046 myPos_x = resizeorigin_x - mySize_x;
1047 myPos_y = resizeorigin_y - mySize_y;
1048 } else if(resizeCorner == 2) {
1049 myPos_x = resizeorigin_x;
1050 myPos_y = resizeorigin_y - mySize_y;
1051 } else if(resizeCorner == 3) {
1052 myPos_x = resizeorigin_x - mySize_x;
1053 myPos_y = resizeorigin_y;
1054 } else { // resizeCorner == 4
1055 myPos_x = resizeorigin_x;
1056 myPos_y = resizeorigin_y;
1059 // left/top screen edges
1061 mySize_x = mySize_x + myPos_x;
1063 mySize_y = mySize_y + myPos_y;
1065 // bottom/right screen edges
1066 if(myPos_x + mySize_x > vid_conwidth)
1067 mySize_x = vid_conwidth - myPos_x;
1068 if(myPos_y + mySize_y > vid_conheight)
1069 mySize_y = vid_conheight - myPos_y;
1071 if(cvar("hud_configure_checkcollisions_debug"))
1072 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
1074 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
1075 if(cvar("hud_configure_grid"))
1077 mySize_x = floor((mySize_x/vid_conwidth)/bound(0.005, cvar("hud_configure_grid_x"), 0.2) + 0.5) * bound(0.005, cvar("hud_configure_grid_x"), 0.2) * vid_conwidth;
1078 mySize_y = floor((mySize_y/vid_conheight)/bound(0.005, cvar("hud_configure_grid_y"), 0.2) + 0.5) * bound(0.005, cvar("hud_configure_grid_y"), 0.2) * vid_conheight;
1081 if(cvar("hud_configure_checkcollisions"))
1083 mySize = HUD_Panel_CheckResize(id, mySize, resizeorigin);
1086 // 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)
1087 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1088 mySize_y = max(0.025 * vid_conheight, mySize_y);
1090 // do another pos check, as size might have changed by now
1091 if(resizeCorner == 1) {
1092 myPos_x = resizeorigin_x - mySize_x;
1093 myPos_y = resizeorigin_y - mySize_y;
1094 } else if(resizeCorner == 2) {
1095 myPos_x = resizeorigin_x;
1096 myPos_y = resizeorigin_y - mySize_y;
1097 } else if(resizeCorner == 3) {
1098 myPos_x = resizeorigin_x - mySize_x;
1099 myPos_y = resizeorigin_y;
1100 } else { // resizeCorner == 4
1101 myPos_x = resizeorigin_x;
1102 myPos_y = resizeorigin_y;
1105 if(cvar("hud_configure_checkcollisions_debug"))
1106 if(cvar("hud_configure_checkcollisions"))
1107 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
1110 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
1111 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_size"), s);
1113 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
1114 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
1118 float prevMouseClicked; // previous state
1119 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
1120 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
1123 float menu_enabled_time;
1124 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1129 // allow console bind to work
1132 con_keys = findkeysforcommand("toggleconsole");
1133 keys = tokenize(con_keys);
1135 float hit_con_bind, i;
1136 for (i = 0; i < keys; ++i)
1138 if(nPrimary == stof(argv(i)))
1142 if(nPrimary == K_MOUSE1)
1144 if(bInputType == 0) { // key pressed
1148 else if(bInputType == 1) {// key released
1153 else if(nPrimary == K_ESCAPE)
1155 disable_menu_alphacheck = 1;
1157 menu_enabled_time = time;
1158 localcmd("menu_showhudexit\n");
1161 else if(hit_con_bind)
1164 return true; // Suppress ALL other input
1167 void HUD_Panel_Mouse()
1169 // 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
1170 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1171 disable_menu_alphacheck = 0;
1172 if (cvar("_menu_alpha") == 0 && time - menu_enabled_time > 0.5)
1176 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1177 print("Highlighted: ", ftos(highlightedPanel), "\n");
1178 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1181 if(mouseClicked == 0 && disable_menu_alphacheck != 2) { // don't reset these variables in disable_menu_alphacheck mode 2!
1182 highlightedPanel = -1;
1183 highlightedAction = 0;
1186 mousepos = mousepos + getmousepos();
1188 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1189 mousepos_y = bound(0, mousepos_y, vid_conheight);
1191 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1199 for(i = 0; i < HUD_PANEL_NUM; ++i)
1201 panelPos = HUD_Panel_GetPos(i);
1202 panelSize = HUD_Panel_GetSize(i);
1203 border = HUD_Panel_GetBorder(i);
1204 if(prevMouseClicked == 0) {
1206 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1208 highlightedPanel = i;
1209 highlightedAction = 1;
1211 // resize from topleft border
1212 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)
1214 highlightedPanel = i;
1215 highlightedAction = 2;
1218 // resize from topright border
1219 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)
1221 highlightedPanel = i;
1222 highlightedAction = 2;
1225 // resize from bottomleft border
1226 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)
1228 highlightedPanel = i;
1229 highlightedAction = 2;
1232 // resize from bottomright border
1233 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)
1235 highlightedPanel = i;
1236 highlightedAction = 2;
1241 if(highlightedPanel == i)
1243 if(prevMouseClicked == 0)
1245 if(highlightedAction == 1)
1246 panel_click_distance = mousepos - panelPos;
1247 else if(highlightedAction == 2)
1249 if(resizeCorner == 1) {
1250 panel_click_distance = mousepos - panelPos;
1251 panel_click_resizeorigin = panelPos + panelSize;
1252 } else if(resizeCorner == 2) {
1253 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1254 panel_click_distance_y = mousepos_y - panelPos_y;
1255 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1256 } else if(resizeCorner == 3) {
1257 panel_click_distance_x = mousepos_x - panelPos_x;
1258 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1259 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1260 } else if(resizeCorner == 4) {
1261 panel_click_distance = panelSize - mousepos + panelPos;
1262 panel_click_resizeorigin = panelPos;
1267 if(cvar("hud_configure_checkcollisions_debug"))
1268 drawfill(panelPos, panelSize, '1 0 0', .3, DRAWFLAG_NORMAL);
1270 if(highlightedAction == 1)
1271 HUD_Panel_SetPos(i, mousepos - panel_click_distance);
1272 else if(highlightedAction == 2)
1273 HUD_Panel_SetPosSize(i);
1277 // doubleclick check
1278 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1280 mouseClicked = 0; // to prevent spam, I guess.
1281 disable_menu_alphacheck = 2;
1283 menu_enabled_time = time;
1284 localcmd("menu_showhudoptions ", ftos(highlightedPanel), "\n");
1287 if(prevMouseClicked == 0)
1289 prevMouseClickedTime = time;
1290 prevMouseClickedPos = mousepos;
1293 prevMouseClicked = mouseClicked;
1296 // Weapon icons (#0)
1298 float weaponspace[10];
1299 void HUD_WeaponIcons_Clear()
1302 for(idx = 0; idx < 10; ++idx)
1303 weaponspace[idx] = 0;
1306 entity weaponorder[WEP_MAXCOUNT];
1308 void weaponorder_swap(float i, float j, entity pass)
1312 weaponorder[i] = weaponorder[j];
1316 string weaponorder_cmp_str;
1317 float weaponorder_cmp(float i, float j, entity pass)
1320 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1321 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1322 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)
1325 void HUD_WeaponIcons(void)
1327 float id = HUD_PANEL_WEAPONICONS;
1328 float alpha, stat_weapons; // "constants"
1329 vector pos, mySize, accuracy_color;
1330 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1332 pos = HUD_Panel_GetPos(id);
1333 mySize = HUD_Panel_GetSize(id);
1335 stat_weapons = getstati(STAT_WEAPONS);
1336 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1338 self = get_weaponinfo(i);
1339 if(self.impulse >= 0)
1341 weaponorder[weapon_cnt] = self;
1346 // TODO make this configurable
1347 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1348 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1350 HUD_Panel_DrawBg(id, pos, mySize, 0);
1352 padding = HUD_Panel_GetPadding(id);
1355 pos += '1 1 0' * padding;
1356 mySize -= '2 2 0' * padding;
1360 weapon_stats = getstati(STAT_DAMAGE_HITS);
1361 weapon_number = weapon_stats & 63;
1362 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1364 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1365 weapon_number = weapon_stats & 63;
1366 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1368 if(cvar_or("hud_weaponicons_fade", 1))
1370 fade = 3.2 - 2 * (time - weapontime);
1371 fade = bound(0.7, fade, 1);
1376 HUD_WeaponIcons_Clear();
1378 float rows, columns;
1379 rows = mySize_y/mySize_x;
1380 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1381 // ^^^ weapon icon aspect goes here
1383 columns = ceil(WEP_COUNT/rows);
1385 for(i = 0; i < weapon_cnt; ++i)
1387 self = weaponorder[i];
1388 weapid = self.impulse;
1390 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1392 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1393 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1395 // draw background behind currently selected weapon
1396 if(self.weapon == activeweapon)
1397 drawpic_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 * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1399 // draw the weapon accuracy on the HUD
1400 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1403 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1405 accuracy_color = HUD_AccuracyColor(weapon_stats);
1407 drawpic_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), accuracy_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1410 // draw the weapon icon
1411 if((self.impulse >= 0) && (stat_weapons & self.weapons))
1413 drawpic_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 * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1415 if(cvar_or("hud_weaponicons_number", 1))
1416 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', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1420 drawpic_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', HUD_Panel_GetFgAlpha(id) * 0.5, DRAWFLAG_NORMAL);
1435 float GetAmmoStat(float i)
1439 case 0: return STAT_SHELLS;
1440 case 1: return STAT_NAILS;
1441 case 2: return STAT_ROCKETS;
1442 case 3: return STAT_CELLS;
1443 case 4: return STAT_FUEL;
1448 float GetAmmoItemCode(float i)
1452 case 0: return IT_SHELLS;
1453 case 1: return IT_NAILS;
1454 case 2: return IT_ROCKETS;
1455 case 3: return IT_CELLS;
1456 case 4: return IT_FUEL;
1461 string GetAmmoPicture(float i)
1465 case 0: return "ammo_shells";
1466 case 1: return "ammo_bullets";
1467 case 2: return "ammo_rockets";
1468 case 3: return "ammo_cells";
1469 case 4: return "ammo_fuel";
1474 void HUD_Inventory(void)
1476 float id = HUD_PANEL_INVENTORY;
1480 vector pos, mySize, mysize, mypos;
1481 pos = HUD_Panel_GetPos(id);
1482 mySize = HUD_Panel_GetSize(id);
1484 HUD_Panel_DrawBg(id, pos, mySize, 0);
1486 padding = HUD_Panel_GetPadding(id);
1489 pos += '1 1 0' * padding;
1490 mySize -= '2 2 0' * padding;
1494 stat_items = getstati(STAT_ITEMS);
1495 for (i = 0; i < 4; ++i) {
1497 a = getstati(GetAmmoStat(i)); // how much ammo do we have of type i?
1501 if(cvar("hud_inventory_onlycurrent")) {
1504 if (stat_items & GetAmmoItemCode(i) || hud_configure) {
1505 drawpic_skin(pos, GetAmmoPicture(i), '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1507 HUD_DrawXNum(pos + eX * mySize_y + eY * 0.25 * mySize_y, a, strlen(ftos(a)), 0, 0.5 * mySize_y, '0.7 0 0', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1509 HUD_DrawXNum(pos + eX * mySize_y + eY * 0.25 * mySize_y, a, strlen(ftos(a)), 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1515 if(mySize_x/mySize_y >= 10) { // arrange horizontally
1517 case 0: mypos_x = pos_x; mypos_y = pos_y; break; // shells
1518 case 1: mypos_x = pos_x + 0.25 * mySize_x; mypos_y = pos_y; break; // bullets
1519 case 2: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y; break; // rockets
1520 case 3: mypos_x = pos_x + 0.75 * mySize_x; mypos_y = pos_y; break; // cells
1522 mysize_x = 0.25 * mySize_x;
1523 mysize_y = mySize_y;
1524 } else if(mySize_x/mySize_y >= 2.5) { // arrange in a 2x2 grid
1526 case 0: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y + 0.5 * mySize_y; break; // shells
1527 case 1: mypos_x = pos_x + 0.5 * mySize_x; mypos_y = pos_y; break; // bullets
1528 case 2: mypos_x = pos_x; mypos_y = pos_y + 0.5 * mySize_y; break; // rockets
1529 case 3: mypos_x = pos_x; mypos_y = pos_y; break; // cells
1531 mysize_x = 0.5 * mySize_x;
1532 mysize_y = 0.5 * mySize_y;
1533 } else { // arrange vertically
1535 case 0: mypos_x = pos_x; mypos_y = pos_y; break; // shells
1536 case 1: mypos_x = pos_x; mypos_y = pos_y + 0.25 * mySize_y; break; // bullets
1537 case 2: mypos_x = pos_x; mypos_y = pos_y + 0.5 * mySize_y; break; // rockets
1538 case 3: mypos_x = pos_x; mypos_y = pos_y + 0.75 * mySize_y; break; // cells
1540 mysize_x = mySize_x;
1541 mysize_y = 0.25 * mySize_y;
1544 if (stat_items & GetAmmoItemCode(i))
1545 drawpic_skin(mypos, "ammo_current_bg", mysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1546 drawpic_skin(mypos + eY * 0.05 * mysize_y, GetAmmoPicture(i), '1 1 0' * 0.8 * mysize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1548 if(stat_items & GetAmmoItemCode(i))
1549 HUD_DrawXNum(mypos + eX * 0.8 * mysize_y + eY * 0.25 * mysize_y, a, strlen(ftos(a)), 0, 0.5 * mysize_y, '0.7 0 0', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1551 HUD_DrawXNum(mypos + eX * 0.8 * mysize_y + eY * 0.25 * mysize_y, a, strlen(ftos(a)), 0, 0.5 * mysize_y, '0.7 0 0', 0, 0, HUD_Panel_GetFgAlpha(id) * 0.7, DRAWFLAG_NORMAL);
1553 if(stat_items & GetAmmoItemCode(i))
1554 HUD_DrawXNum(mypos + eX * 0.8 * mysize_y + eY * 0.25 * mysize_y, a, strlen(ftos(a)), 0, 0.5 * mysize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1556 HUD_DrawXNum(mypos + eX * 0.8 * mysize_y + eY * 0.25 * mysize_y, a, strlen(ftos(a)), 0, 0.5 * mysize_y, '0.7 0.7 0.7', 0, 0, HUD_Panel_GetFgAlpha(id) * 0.7, DRAWFLAG_NORMAL);
1566 void HUD_Powerups(void) {
1567 float id = HUD_PANEL_POWERUPS;
1569 stat_items = getstati(STAT_ITEMS);
1573 if not(stat_items & IT_STRENGTH)
1574 if not(stat_items & IT_INVINCIBLE)
1577 if (getstati(STAT_HEALTH) <= 0)
1582 pos = HUD_Panel_GetPos(id);
1583 mySize = HUD_Panel_GetSize(id);
1585 HUD_Panel_DrawBg(id, pos, mySize, 0);
1587 padding = HUD_Panel_GetPadding(id);
1590 pos += '1 1 0' * padding;
1591 mySize -= '2 2 0' * padding;
1594 float strength_time, shield_time;
1596 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1597 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1607 vector barpos, barsize;
1611 string leftname, rightname;
1612 float leftcnt, rightcnt;
1613 float leftexact, rightexact;
1614 float leftalpha, rightalpha;
1615 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) {
1616 leftname = "strength";
1617 leftcnt = ceil(strength_time);
1618 leftexact = strength_time;
1620 rightname = "shield";
1621 rightcnt = ceil(shield_time);
1622 rightexact = shield_time;
1624 leftname = "shield";
1625 leftcnt = ceil(shield_time);
1626 leftexact = shield_time;
1628 rightname = "strength";
1629 rightcnt = ceil(strength_time);
1630 rightexact = strength_time;
1632 leftalpha = bound(0, leftexact, 1);
1633 rightalpha = bound(0, rightexact, 1);
1635 if (mySize_x/mySize_y > 4)
1639 len = strlen(ftos(leftcnt));
1641 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1642 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1643 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1644 picpos = pos + eX * 0.5 * mySize_x - eX * mySize_y;
1645 numpos = picpos - eX * 2 * 0.5 * mySize_y + eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1648 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1650 numpos = picpos + eX * mySize_y - eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1653 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1655 drawpic_skin_expanding_two(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE, bound(0, (leftcnt - leftexact) / 0.5, 1));
1657 drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1658 HUD_DrawXNum(numpos, leftcnt, 2, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1663 len = strlen(ftos(rightcnt));
1665 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1666 barpos = pos + eX * 0.5 * mySize_x;
1667 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1668 picpos = pos + eX * 0.5 * mySize_x;
1669 numpos = picpos + eX * mySize_y - eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1671 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1672 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1673 picpos = pos + eX * mySize_x - eX * mySize_y;
1674 numpos = picpos - eX * mySize_y + eY * 0.25 * mySize_y;
1677 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1679 drawpic_skin_expanding_two(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE, bound(0, (rightcnt - rightexact) / 0.5, 1));
1681 drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1682 HUD_DrawXNum(numpos, rightcnt, 2, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1685 else if (mySize_x/mySize_y > 1.5)
1689 len = strlen(ftos(leftcnt));
1691 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1692 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1693 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1694 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y;
1695 numpos = picpos - eX * len * 0.5 * mySize_y;
1698 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1700 numpos = picpos + eX * 0.5 * mySize_y;
1703 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1705 drawpic_skin_expanding_two(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE, bound(0, (leftcnt - leftexact) / 0.5, 1));
1707 drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1708 HUD_DrawXNum(numpos, leftcnt, len, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1713 len = strlen(ftos(rightcnt));
1715 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1716 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1717 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1718 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y + eY * 0.5 * mySize_y;
1719 numpos = picpos - eX * len * 0.5 * mySize_y;
1721 barpos = pos + eY * 0.5 * mySize_y;
1722 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1723 picpos = pos + eY * 0.5 * mySize_y;
1724 numpos = picpos + eX * 0.5 * mySize_y;
1727 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1729 drawpic_skin_expanding_two(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE, bound(0, (rightcnt - rightexact) / 0.5, 1));
1731 drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1732 HUD_DrawXNum(numpos, rightcnt, len, 0, 0.5 * mySize_y, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1739 len = strlen(ftos(leftcnt));
1741 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1743 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1744 picpos = pos + eX * 0.05 * mySize_x;
1745 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x;
1747 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1748 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1749 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.65 * mySize_x;
1750 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.25 * mySize_x;
1753 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1755 drawpic_skin_expanding_two(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE, bound(0, (leftcnt - leftexact) / 0.5, 1));
1757 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1758 HUD_DrawXNum(numpos, leftcnt, len, 0, 0.25 * mySize_x, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1763 len = strlen(ftos(rightcnt));
1765 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1766 barpos = pos + eX * 0.5 * mySize_x;
1767 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1768 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1769 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1771 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1772 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1773 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.65 * mySize_x + eX * 0.5 * mySize_x;
1774 numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
1777 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1779 drawpic_skin_expanding_two(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE, bound(0, (rightcnt - rightexact) / 0.5, 1));
1781 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1782 HUD_DrawXNum(numpos, rightcnt, len, 0, 0.25 * mySize_x, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1787 // Health/armor (#3)
1789 void HUD_HealthArmor(void)
1791 float id = HUD_PANEL_HEALTHARMOR;
1793 pos = HUD_Panel_GetPos(id);
1794 mySize = HUD_Panel_GetSize(id);
1796 HUD_Panel_DrawBg(id, pos, mySize, 0);
1798 padding = HUD_Panel_GetPadding(id);
1801 pos += '1 1 0' * padding;
1802 mySize -= '2 2 0' * padding;
1805 float armor, health;
1806 armor = getstati(STAT_ARMOR);
1807 health = getstati(STAT_HEALTH);
1810 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
1823 vector barpos, barsize;
1827 if(cvar("hud_healtharmor") == 2) // combined health and armor display
1830 v = healtharmor_maxdamage(health, armor, armorblockpercent);
1835 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1836 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
1837 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
1839 numpos = picpos + eX * 1.5 * mySize_y;
1842 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
1843 picpos = pos + eX * 3 * mySize_y;
1847 if(v_z) // NOT fully armored
1849 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("health"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1850 drawpic_skin(picpos, "health", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1852 drawpic_skin(picpos + eX * mySize_y, "armor", '0.5 0.5 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id) * armor / health, DRAWFLAG_NORMAL);
1856 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("armor"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1857 drawpic_skin(picpos + eX * mySize_y, "health", '0.5 0.5 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id) * health / armor, DRAWFLAG_NORMAL);
1859 drawpic_skin(picpos, "armor", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1861 HUD_DrawXNum_Colored(numpos, x, 3, mySize_y, HUD_Panel_GetFgAlpha(id)); // draw the combined health and armor
1864 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1865 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
1866 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
1869 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
1872 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
1877 string leftname, rightname;
1878 float leftcnt, rightcnt;
1879 float leftactive, rightactive;
1880 float leftalpha, rightalpha;
1881 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) { // old style layout with armor left/top of health
1886 leftalpha = min((armor+10)/55, 1);
1888 rightname = "health";
1893 leftname = "health";
1898 rightname = "armor";
1902 rightalpha = min((armor+10)/55, 1);
1905 if (mySize_x/mySize_y > 5)
1909 len = strlen(ftos(leftcnt));
1911 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1912 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
1913 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
1914 picpos = pos + eX * 0.5 * mySize_x - eX * mySize_y;
1915 numpos = picpos - eX * 3 * 0.5 * mySize_y + eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1918 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
1920 numpos = picpos + eX * mySize_y + eY * 0.25 * mySize_y;
1923 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1924 drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1925 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
1930 len = strlen(ftos(rightcnt));
1932 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1933 barpos = pos + eX * 0.5 * mySize_x;
1934 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
1935 picpos = pos + eX * 0.5 * mySize_x;
1936 numpos = picpos + eX * mySize_y - eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
1938 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
1939 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
1940 picpos = pos + eX * mySize_x - eX * mySize_y;
1941 numpos = picpos - eX * 1.5 * mySize_y + eY * 0.25 * mySize_y;
1944 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1945 drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1946 HUD_DrawXNum_Colored(numpos, rightcnt, 3, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
1949 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1950 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
1951 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
1954 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
1957 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
1959 else if (mySize_x/mySize_y > 2)
1963 len = strlen(ftos(leftcnt));
1965 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1966 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
1967 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
1968 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y;
1969 numpos = picpos - eX * len * 0.5 * mySize_y;
1972 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
1974 numpos = picpos + eX * 0.5 * mySize_y;
1977 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1978 drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1979 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
1984 len = strlen(ftos(rightcnt));
1986 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
1987 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
1988 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
1989 picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y + eY * 0.5 * mySize_y;
1990 numpos = picpos - eX * len * 0.5 * mySize_y;
1992 barpos = pos + eY * 0.5 * mySize_y;
1993 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
1994 picpos = pos + eY * 0.5 * mySize_y;
1995 numpos = picpos + eX * 0.5 * mySize_y;
1998 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1999 drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2000 HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.5 * mySize_y, HUD_Panel_GetFgAlpha(id));
2003 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2004 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2005 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2008 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2011 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2017 len = strlen(ftos(leftcnt));
2019 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2021 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2022 picpos = pos + eX * 0.05 * mySize_x;
2023 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x;
2025 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2026 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2027 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x;
2028 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x;
2031 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2032 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2033 HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.166 * mySize_x, HUD_Panel_GetFgAlpha(id));
2038 len = strlen(ftos(rightcnt));
2040 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2041 barpos = pos + eX * 0.5 * mySize_x;
2042 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2043 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2044 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2046 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2047 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2048 picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x + eX * 0.5 * mySize_x;
2049 numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x + eX * 0.5 * mySize_x;
2052 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2053 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2054 HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.166 * mySize_x, HUD_Panel_GetFgAlpha(id));
2057 if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
2059 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2061 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2062 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2065 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2071 // Notification area (#4)
2074 string Weapon_SuicideMessage(float deathtype)
2076 w_deathtype = deathtype;
2077 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2078 return w_deathtypestring;
2081 string Weapon_KillMessage(float deathtype)
2083 w_deathtype = deathtype;
2084 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2085 return w_deathtypestring;
2088 float killnotify_times[10];
2089 float killnotify_deathtype[10];
2090 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2091 string killnotify_attackers[10];
2092 string killnotify_victims[10];
2093 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2096 for (i = 9; i > 0; --i) {
2097 killnotify_times[i] = killnotify_times[i-1];
2098 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2099 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2100 if(killnotify_attackers[i])
2101 strunzone(killnotify_attackers[i]);
2102 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2103 if(killnotify_victims[i])
2104 strunzone(killnotify_victims[i]);
2105 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2107 killnotify_times[0] = time;
2108 killnotify_deathtype[0] = wpn;
2109 killnotify_actiontype[0] = actiontype;
2110 if(killnotify_attackers[0])
2111 strunzone(killnotify_attackers[0]);
2112 killnotify_attackers[0] = strzone(attacker);
2113 if(killnotify_victims[0])
2114 strunzone(killnotify_victims[0]);
2115 killnotify_victims[0] = strzone(victim);
2118 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2122 alsoprint = (cvar("hud_notify_print") || !HUD_Panel_CheckActive(4)); // print message to console if: notify panel disabled, or cvar to do so enabled
2124 if(msg == MSG_SUICIDE) {
2126 w = DEATH_WEAPONOF(type);
2128 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2130 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2131 } else if (type == DEATH_KILL) {
2132 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2134 print ("^1",s1, "^1 couldn't take it anymore\n");
2135 } else if (type == DEATH_ROT) {
2136 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2138 print ("^1",s1, "^1 died\n");
2139 } else if (type == DEATH_NOAMMO) {
2140 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2142 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2143 } else if (type == DEATH_CAMP) {
2144 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2146 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2147 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2148 HUD_KillNotify_Push(s1, "", 0, type);
2150 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2151 } else if (type == DEATH_CHEAT) {
2152 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2154 print ("^1",s1, "^1 unfairly eliminated themself\n");
2155 } else if (type == DEATH_FIRE) {
2156 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2158 print ("^1",s1, "^1 burned to death\n");
2159 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2160 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2162 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2165 if (stof(s2) > 2) // killcount > 2
2166 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2167 } else if(msg == MSG_KILL) {
2168 w = DEATH_WEAPONOF(type);
2170 HUD_KillNotify_Push(s2, s1, 1, w);
2172 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2174 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2175 HUD_KillNotify_Push(s1, s2, 1, type);
2178 if(cvar("cl_gentle")) {
2179 print ("^1", s1, "^1 took action against a team mate\n");
2181 print ("^1", s1, "^1 mows down a team mate\n");
2184 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2185 if(cvar("cl_gentle"))
2186 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2188 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2190 else if (stof(s2) > 2) {
2191 if(cvar("cl_gentle"))
2192 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2194 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2197 else if(type == KILL_FIRST_BLOOD)
2198 print("^1",s1, "^1 drew first blood", "\n");
2200 else if (type == DEATH_TELEFRAG)
2201 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2202 else if (type == DEATH_DROWN) {
2203 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2205 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2207 else if (type == DEATH_SLIME) {
2208 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2210 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2212 else if (type == DEATH_LAVA) {
2213 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2215 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2217 else if (type == DEATH_FALL) {
2218 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2220 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2222 else if (type == DEATH_SHOOTING_STAR) {
2223 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2225 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2227 else if (type == DEATH_SWAMP) {
2228 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2230 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2232 else if (type == DEATH_HURTTRIGGER)
2234 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2236 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2237 } else if(type == DEATH_SBCRUSH) {
2238 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2240 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2241 } else if(type == DEATH_SBMINIGUN) {
2242 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2244 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2245 } else if(type == DEATH_SBROCKET) {
2246 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2248 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2249 } else if(type == DEATH_SBBLOWUP) {
2250 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2252 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2253 } else if(type == DEATH_WAKIGUN) {
2254 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2256 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2257 } else if(type == DEATH_WAKIROCKET) {
2258 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2260 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2261 } else if(type == DEATH_WAKIBLOWUP) {
2262 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2264 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2265 } else if(type == DEATH_TURRET) {
2266 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2268 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2269 } else if(type == DEATH_TOUCHEXPLODE) {
2270 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2272 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2273 } else if(type == DEATH_CHEAT) {
2274 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2276 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2277 } else if (type == DEATH_FIRE) {
2278 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2280 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2281 } else if (type == DEATH_CUSTOM) {
2282 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2284 print ("^1",s1, "^1 ", s2, "\n");
2286 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2288 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2290 } else if(msg == MSG_SPREE) {
2291 if(type == KILL_END_SPREE) {
2292 if(cvar("cl_gentle"))
2293 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2295 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2296 } else if(type == KILL_SPREE) {
2297 if(cvar("cl_gentle"))
2298 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2300 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2301 } else if(type == KILL_SPREE_3) {
2302 if(cvar("cl_gentle"))
2303 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2305 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2306 } else if(type == KILL_SPREE_5) {
2307 if(cvar("cl_gentle"))
2308 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2310 print (s1,"^7 unleashes ^1RAGE\n");
2311 } else if(type == KILL_SPREE_10) {
2312 if(cvar("cl_gentle"))
2313 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2315 print (s1,"^7 starts the ^1MASSACRE!\n");
2316 } else if(type == KILL_SPREE_15) {
2317 if(cvar("cl_gentle"))
2318 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2320 print (s1,"^7 executes ^1MAYHEM!\n");
2321 } else if(type == KILL_SPREE_20) {
2322 if(cvar("cl_gentle"))
2323 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2325 print (s1,"^7 is a ^1BERSERKER!\n");
2326 } else if(type == KILL_SPREE_25) {
2327 if(cvar("cl_gentle"))
2328 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2330 print (s1,"^7 inflicts ^1CARNAGE!\n");
2331 } else if(type == KILL_SPREE_30) {
2332 if(cvar("cl_gentle"))
2333 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2335 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2337 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2338 if (type == DEATH_DROWN) {
2339 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2342 if(cvar("cl_gentle"))
2343 print ("^1",s1, "^1 was in the water for too long\n");
2345 print ("^1",s1, "^1 drowned\n");
2347 } else if (type == DEATH_SLIME) {
2348 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2350 print ("^1",s1, "^1 was slimed\n");
2351 } else if (type == DEATH_LAVA) {
2352 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2355 if(cvar("cl_gentle"))
2356 print ("^1",s1, "^1 found a hot place\n");
2358 print ("^1",s1, "^1 turned into hot slag\n");
2360 } else if (type == DEATH_FALL) {
2361 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2364 if(cvar("cl_gentle"))
2365 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2367 print ("^1",s1, "^1 hit the ground with a crunch\n");
2369 } else if (type == DEATH_SHOOTING_STAR) {
2370 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2372 print ("^1",s1, "^1 became a shooting star\n");
2373 } else if (type == DEATH_SWAMP) {
2374 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2377 if(cvar("cl_gentle"))
2378 print ("^1",s1, "^1 discovered a swamp\n");
2380 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2382 } else if(type == DEATH_TURRET) {
2383 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2385 print ("^1",s1, "^1 was mowed down by a turret \n");
2386 } else if (type == DEATH_CUSTOM) {
2387 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2389 print ("^1",s1, "^1 ", s2, "\n");
2390 } else if (type == DEATH_HURTTRIGGER) {
2391 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2393 print ("^1",s1, "^1 was in the wrong place\n");
2394 } else if(type == DEATH_TOUCHEXPLODE) {
2395 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2397 print ("^1",s1, "^1 died in an accident\n");
2398 } else if(type == DEATH_CHEAT) {
2399 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2401 print ("^1",s1, "^1 was unfairly eliminated\n");
2402 } else if(type == DEATH_FIRE) {
2403 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2406 if(cvar("cl_gentle"))
2407 print ("^1",s1, "^1 felt a little hot\n");
2409 print ("^1",s1, "^1 burnt to death\n");
2412 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2415 if(cvar("cl_gentle"))
2416 print ("^1",s1, "^1 needs a restart\n");
2418 print ("^1",s1, "^1 died\n");
2421 } else if(msg == MSG_KILL_ACTION_SPREE) {
2422 if(cvar("cl_gentle"))
2423 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2425 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2426 } else if(msg == MSG_INFO) {
2427 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2428 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2429 print(s1, "^7 got the ", s2, "\n");
2430 } else if(type == INFO_LOSTFLAG) {
2431 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2432 print(s1, "^7 lost the ", s2, "\n");
2433 } else if(type == INFO_PICKUPFLAG) {
2434 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2435 print(s1, "^7 picked up the ", s2, "\n");
2436 } else if(type == INFO_RETURNFLAG) {
2437 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2438 print(s1, "^7 returned the ", s2, "\n");
2443 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2445 void HUD_Centerprint(string s1, string s2, float type, float msg)
2447 if(msg == MSG_SUICIDE) {
2448 if (type == DEATH_TEAMCHANGE) {
2449 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2450 } else if (type == DEATH_AUTOTEAMCHANGE) {
2451 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2452 } else if (type == DEATH_CAMP) {
2453 if(cvar("cl_gentle"))
2454 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2456 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2457 } else if (type == DEATH_NOAMMO) {
2458 if(cvar("cl_gentle"))
2459 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2461 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2462 } else if (type == DEATH_ROT) {
2463 if(cvar("cl_gentle"))
2464 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2466 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2467 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2468 if(cvar("cl_gentle"))
2469 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2471 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2472 } else if (type == DEATH_QUIET) {
2474 } else if (type == DEATH_KILL) {
2475 if(cvar("cl_gentle"))
2476 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2478 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2480 } else if(msg == MSG_KILL) {
2481 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2482 if(cvar("cl_gentle")) {
2483 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2485 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2487 } else if (type == KILL_FIRST_BLOOD) {
2488 if(cvar("cl_gentle")) {
2489 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2491 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2493 } else if (type == KILL_FIRST_VICTIM) {
2494 if(cvar("cl_gentle")) {
2495 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2497 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2499 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2500 if(cvar("cl_gentle")) {
2501 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2503 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2505 } else if (type == KILL_TYPEFRAGGED) {
2506 if(cvar("cl_gentle")) {
2507 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2509 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2511 } else if (type == KILL_FRAG) {
2512 if(cvar("cl_gentle")) {
2513 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2515 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2517 } else if (type == KILL_FRAGGED) {
2518 if(cvar("cl_gentle")) {
2519 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2521 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2524 } else if(msg == MSG_KILL_ACTION) {
2525 // TODO: invent more centerprints here?
2526 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2530 void HUD_Notify (void)
2532 float id = HUD_PANEL_NOTIFY;
2534 pos = HUD_Panel_GetPos(id);
2535 mySize = HUD_Panel_GetSize(id);
2537 HUD_Panel_DrawBg(id, pos, mySize, 0);
2539 padding = HUD_Panel_GetPadding(id);
2542 pos += '1 1 0' * padding;
2543 mySize -= '2 2 0' * padding;
2546 float entries, height;
2547 entries = bound(1, floor(14 * mySize_y/mySize_x), 12);
2548 height = mySize_y/entries;
2549 entries -= 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2552 fontsize = '0.5 0.5 0' * height;
2556 when = cvar("hud_notify_time");
2558 fadetime = cvar("hud_notify_fadetime");
2562 vector pos_attacker, pos_victim;
2564 float width_attacker, width_victim;
2565 string attacker, victim;
2568 for(j = 0; j < entries; ++j)
2570 if(cvar("hud_notify_flip"))
2572 else // rather nasty hack for ordering items from the bottom up
2573 i = entries - j - 1;
2574 if(cvar("hud_notify_info_top"))
2575 i += 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2579 if(killnotify_times[j] + when > time)
2582 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2586 if(killnotify_times[j] + when > time)
2592 // TODO: maybe print in team colors?
2593 // TODO: maybe this could be cleaned up somehow...
2594 // TODO: less copypaste code below
2597 if(killnotify_actiontype[j] == 0 && !hud_configure)
2599 attacker = textShortenToWidth(killnotify_attackers[j], mySize_x - 2 * height, fontsize, stringwidth_colors);
2601 width_attacker = stringwidth(attacker, TRUE, fontsize);
2602 pos_attacker = pos + eX * 0.5 * (mySize_x - width_attacker + 2 * height) + eY * 0.5 * fontsize_y + eY * i * height;
2604 weap_pos = pos + eX * 0.5 * (mySize_x - width_attacker) - eX * height + eY * i * height;
2605 if(killnotify_deathtype[j] == DEATH_GENERIC)
2607 drawpic_skin(weap_pos, "notify_death", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2608 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2610 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2612 drawpic_skin(weap_pos, "notify_outofammo", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2613 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2615 else if(killnotify_deathtype[j] == DEATH_KILL)
2617 drawpic_skin(weap_pos, "notify_selfkill", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2618 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2620 else if(killnotify_deathtype[j] == DEATH_CAMP)
2622 drawpic_skin(weap_pos, "notify_camping", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2623 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2625 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2627 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2628 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2630 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2632 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2633 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2635 else if(killnotify_deathtype[j] == DEATH_DROWN)
2637 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2638 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2640 else if(killnotify_deathtype[j] == DEATH_SLIME)
2642 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2643 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2645 else if(killnotify_deathtype[j] == DEATH_LAVA)
2647 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2648 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2650 else if(killnotify_deathtype[j] == DEATH_FALL)
2652 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2653 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2655 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2657 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2658 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2660 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2662 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2663 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2665 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2667 if(killnotify_victims[j] == "^1RED^7 flag")
2671 drawpic_skin(weap_pos, strcat("flag_", s, "_carrying"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2672 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2674 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2676 if(killnotify_victims[j] == "^1RED^7 flag")
2680 drawpic_skin(weap_pos, strcat("flag_", s, "_taken"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2681 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2683 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2685 if(killnotify_victims[j] == "^1RED^7 flag")
2689 drawpic_skin(weap_pos, strcat("flag_", s, "_lost"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2690 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2693 // X [did action to] Y
2698 attacker = textShortenToWidth("Player1", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2699 victim = textShortenToWidth("Player2", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2700 a = bound(0, (when - j) / 4, 1);
2704 attacker = textShortenToWidth(killnotify_attackers[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2705 victim = textShortenToWidth(killnotify_victims[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2707 width_attacker = stringwidth(attacker, TRUE, fontsize);
2708 width_victim = stringwidth(victim, TRUE, fontsize);
2709 pos_attacker = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_attacker) + eY * 0.5 * fontsize_y + eY * i * height;
2710 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;
2711 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2713 if(hud_configure) // example actions for config mode
2715 drawpic_skin(weap_pos, strcat("weapon", "electro"), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2716 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2717 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2719 else if(WEP_VALID(killnotify_deathtype[j]))
2721 self = get_weaponinfo(killnotify_deathtype[j]);
2722 drawpic_skin(weap_pos, strcat("weapon", self.netname), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2723 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2724 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2726 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2728 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2729 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2730 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2732 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2734 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2735 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2736 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2738 else if(killnotify_deathtype[j] == DEATH_DROWN)
2740 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2741 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2742 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2744 else if(killnotify_deathtype[j] == DEATH_SLIME)
2746 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2747 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2748 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2750 else if(killnotify_deathtype[j] == DEATH_LAVA)
2752 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2753 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2754 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2756 else if(killnotify_deathtype[j] == DEATH_FALL)
2758 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2759 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2760 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2762 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2764 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2765 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2766 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2768 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2770 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2771 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2772 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2783 if(cvar("hud_notify_info_top"))
2786 o = pos + eY * mySize_y - eY * 2 * height;
2788 if(spectatee_status && !intermission)
2790 //drawfont = hud_bigfont;
2791 if(spectatee_status == -1)
2794 s = GetPlayerName(spectatee_status - 1);
2796 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
2797 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2798 //drawfont = hud_font;
2800 // spectator text in the upper right corner
2801 if(spectatee_status == -1)
2802 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
2804 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
2805 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2806 o += eY * fontsize_y;
2808 if(spectatee_status == -1)
2809 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
2811 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
2812 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2813 o += eY * fontsize_y;
2815 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
2816 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2817 o += eY * fontsize_y;
2819 if(gametype == GAME_ARENA)
2820 s = "^1Wait for your turn to join";
2821 else if(gametype == GAME_LMS)
2824 sk = playerslots[player_localentnum - 1];
2825 if(sk.(scores[ps_primary]) >= 666)
2826 s = "^1Match has already begun";
2827 else if(sk.(scores[ps_primary]) > 0)
2828 s = "^1You have no more lives left";
2830 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
2833 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
2834 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2835 o += eY * fontsize_y;
2837 //show restart countdown:
2838 if (time < getstatf(STAT_GAMESTARTTIME)) {
2840 //we need to ceil, otherwise the countdown would be off by .5 when using round()
2841 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
2842 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
2843 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2844 o += eY * fontsize_y;
2847 if(warmup_stage && !intermission)
2849 s = "^2Currently in ^1warmup^2 stage!";
2850 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2851 o += eY * fontsize_y;
2855 if(mod(time, 1) >= 0.5)
2860 if(ready_waiting && !intermission && !spectatee_status)
2862 if(ready_waiting_for_me)
2865 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
2867 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
2872 s = strcat("^2Waiting for others to ready up to end warmup...");
2874 s = strcat("^2Waiting for others to ready up...");
2876 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2877 o += eY * fontsize_y;
2879 else if(warmup_stage && !intermission && !spectatee_status)
2881 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
2882 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2883 o += eY * fontsize_y;
2886 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
2888 float ts_min, ts_max;
2889 tm = teams.sort_next;
2892 for(; tm.sort_next; tm = tm.sort_next)
2894 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
2896 if(!ts_min) ts_min = tm.team_size;
2897 else ts_min = min(ts_min, tm.team_size);
2898 if(!ts_max) ts_max = tm.team_size;
2899 else ts_max = max(ts_max, tm.team_size);
2901 if ((ts_max - ts_min) > 1)
2903 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
2904 tm = GetTeam(myteam, false);
2906 if (tm.team != COLOR_SPECTATOR)
2907 if (tm.team_size == ts_max)
2908 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
2910 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2911 o += eY * fontsize_y;
2917 s = "^7Press ^3ESC ^7to show HUD options.";
2918 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2919 o += eY * fontsize_y;
2920 s = "^3Doubleclick a panel for panel-specific options.";
2921 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2922 o += eY * fontsize_y;
2928 string seconds_tostring(float sec)
2931 minutes = floor(sec / 60);
2933 sec -= minutes * 60;
2936 s = ftos(100 + sec);
2938 return strcat(ftos(minutes), ":", substring(s, 1, 3));
2941 void HUD_Timer(void)
2943 float id = HUD_PANEL_TIMER;
2945 pos = HUD_Panel_GetPos(id);
2946 mySize = HUD_Panel_GetSize(id);
2948 HUD_Panel_DrawBg(id, pos, mySize, 0);
2950 padding = HUD_Panel_GetPadding(id);
2953 pos += '1 1 0' * padding;
2954 mySize -= '2 2 0' * padding;
2958 float timelimit, elapsedTime, timeleft, minutesLeft;
2960 timelimit = getstatf(STAT_TIMELIMIT);
2962 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
2963 timeleft = ceil(timeleft);
2965 minutesLeft = floor(timeleft / 60);
2968 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
2969 timer_color = '1 1 1'; //white
2970 else if(minutesLeft >= 1)
2971 timer_color = '1 1 0'; //yellow
2973 timer_color = '1 0 0'; //red
2975 if (cvar("hud_timer_increment") || timelimit == 0 || warmup_stage) {
2976 if (time < getstatf(STAT_GAMESTARTTIME)) {
2977 //while restart is still active, show 00:00
2978 timer = seconds_tostring(0);
2980 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
2981 timer = seconds_tostring(elapsedTime);
2984 timer = seconds_tostring(timeleft);
2987 drawstring_aspect(pos, timer, mySize, mySize_y, timer_color, HUD_Panel_GetFgAlpha(HUD_PANEL_TIMER), DRAWFLAG_NORMAL);
2992 void HUD_Radar(void)
2994 float id = HUD_PANEL_RADAR;
2996 pos = HUD_Panel_GetPos(id);
2997 mySize = HUD_Panel_GetSize(id);
2999 HUD_Panel_DrawBg(id, pos, mySize, 0);
3001 padding = HUD_Panel_GetPadding(id);
3004 pos += '1 1 0' * padding;
3005 mySize -= '2 2 0' * padding;
3008 local float color1, color2; // color already declared as a global in hud.qc
3011 float scale2d, normalsize, bigsize;
3014 teamradar_origin2d = pos + 0.5 * mySize;
3015 teamradar_size2d = mySize;
3017 if(minimapname == "")
3020 teamradar_loadcvars();
3022 switch(hud_radar_zoommode)
3026 f = current_zoomfraction;
3029 f = 1 - current_zoomfraction;
3039 switch(hud_radar_rotation)
3042 teamradar_angle = view_angles_y - 90;
3045 teamradar_angle = 90 * hud_radar_rotation;
3049 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3050 teamradar_size2d = mySize;
3052 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3054 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3055 if(hud_radar_rotation == 0)
3057 // max-min distance must fit the radar in any rotation
3058 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3062 vector c0, c1, c2, c3, span;
3063 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3064 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3065 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3066 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3068 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3069 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3071 // max-min distance must fit the radar in x=x, y=y
3073 teamradar_size2d_x * scale2d / (1.05 * span_x),
3074 teamradar_size2d_y * scale2d / (1.05 * span_y)
3078 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3079 if(bigsize > normalsize)
3080 normalsize = bigsize;
3084 + (1 - f) * normalsize;
3085 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3086 f * (mi_min + mi_max) * 0.5
3087 + (1 - f) * view_origin);
3089 color1 = GetPlayerColor(player_localentnum-1);
3090 rgb = GetTeamRGB(color1);
3099 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3101 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3102 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3103 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3104 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, HUD_Panel_GetFgAlpha(id));
3105 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3107 color2 = GetPlayerColor(tm.sv_entnum);
3108 //if(color == COLOR_SPECTATOR || color == color2)
3109 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3111 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3113 drawresetcliparea();
3118 void HUD_Score(void)
3120 float id = HUD_PANEL_SCORE;
3122 pos = HUD_Panel_GetPos(id);
3123 mySize = HUD_Panel_GetSize(id);
3125 HUD_Panel_DrawBg(id, pos, mySize, 0);
3127 padding = HUD_Panel_GetPadding(id);
3130 pos += '1 1 0' * padding;
3131 mySize -= '2 2 0' * padding;
3134 float score, distribution, leader;
3136 vector distribution_color;
3138 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3140 // TODO... this (race part) still uses constant coordinates :/
3141 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3142 /*pl = players.sort_next;
3145 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3146 if(pl.scores[ps_primary] == 0)
3149 score = me.(scores[ps_primary]);
3151 float racemin, racesec, racemsec;
3152 float distsec, distmsec, minusplus;
3154 racemin = floor(score/(60 * TIME_FACTOR));
3155 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
3156 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
3158 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3159 // distribution display
3160 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3162 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
3163 distmsec = fabs(distribution);
3165 distsec = floor(fabs(distribution)/TIME_FACTOR);
3166 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
3167 if (distribution < 0)
3171 if (distribution <= 0) {
3172 distribution_color = eY;
3173 minusplus = 1; // minusplus 1: always prefix with minus sign
3176 distribution_color = eX;
3177 minusplus = 2; // minusplus 1: always prefix with plus sign
3179 HUD_DrawXNum(bottomright - '0 48 0' - '16 0 0' * TIME_DECIMALS, distmsec, -TIME_DECIMALS, 0, 16, distribution_color, 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3180 HUD_DrawXNum(bottomright - '68 48 0' - '16 0 0' * TIME_DECIMALS, distsec, 4, minusplus, 16, distribution_color, 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3181 drawpic_skin(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "num_dot", '16 16 0', distribution_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE);
3183 // race record display
3184 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
3185 drawpic_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', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3187 HUD_DrawXNum(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0', racemsec, -TIME_DECIMALS, 0, 30, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3188 HUD_DrawXNum(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '66 0 0', racesec, -2, 0, 30, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3189 drawpic_skin(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '18 0 0', "num_dot", '30 30 0', '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE);
3191 HUD_DrawXNum(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '132 0 0', racemin, -2, 0, 30, '1 1 1', 0, 0, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3192 drawpic_skin(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '84 0 0', "num_colon", '30 30 0', '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE);
3194 } else if (!teamplay) { // non-teamgames
3195 // me vector := [team/connected frags id]
3196 pl = players.sort_next;
3203 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3207 score = me.(scores[ps_primary]);
3211 if(distribution >= 5) {
3212 distribution_color = eY;
3214 } else if(distribution >= 0) {
3215 distribution_color = '1 1 1';
3217 } else if(distribution >= -5)
3218 distribution_color = '1 1 0';
3220 distribution_color = eX;
3222 score_len = strlen(ftos(score));
3224 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, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3226 drawpic_skin(pos, strcat("num_leading_", ftos(score_len)), eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3227 drawfont = hud_bigfont;
3228 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, mySize_y, distribution_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3229 drawfont = hud_font;
3230 } else { // teamgames
3231 float max_fragcount;
3232 max_fragcount = -99;
3235 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3236 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !hud_configure)) // no players? don't display
3238 score = tm.(teamscores[ts_primary]);
3243 score_len = strlen(ftos(score));
3245 if (score > max_fragcount)
3246 max_fragcount = score;
3248 if(tm.team == myteam) {
3249 if (max_fragcount == score)
3252 drawpic_skin(pos, strcat("num_leading_", ftos(score_len)), eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3253 drawfont = hud_bigfont;
3254 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, mySize_y, GetTeamRGB(tm.team) * 0.8, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3255 drawfont = hud_font;
3257 if (max_fragcount == score)
3260 drawpic_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', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3261 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, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3270 void HUD_RaceTimer (void) {
3271 float id = HUD_PANEL_RACETIMER;
3273 pos = HUD_Panel_GetPos(id);
3274 mySize = HUD_Panel_GetSize(id);
3276 HUD_Panel_DrawBg(id, pos, mySize, 0);
3278 padding = HUD_Panel_GetPadding(id);
3281 pos += '1 1 0' * padding;
3282 mySize -= '2 2 0' * padding;
3285 drawfont = hud_bigfont;
3287 string s, forcetime;
3292 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', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3293 s = "^1Intermediate 1 (+15.42)";
3294 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, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3295 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3296 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, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3298 else if(race_checkpointtime)
3300 a = bound(0, 2 - (time - race_checkpointtime), 1);
3303 if(a > 0) // just hit a checkpoint?
3305 if(race_checkpoint != 254)
3307 if(race_time && race_previousbesttime)
3308 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3310 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3312 forcetime = TIME_ENCODED_TOSTRING(race_time);
3317 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3319 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3320 if(a > 0) // next one?
3322 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3327 if(s != "" && a > 0)
3329 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3330 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3331 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, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3334 if(race_penaltytime)
3336 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3339 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3340 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3341 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3342 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, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3348 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3349 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id), 0, a);
3350 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', HUD_Panel_GetFgAlpha(id), 0, a);
3355 if(race_laptime && race_checkpoint != 255)
3357 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3358 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3359 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', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3364 if(race_mycheckpointtime)
3366 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3367 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3368 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3369 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3370 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, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3372 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3374 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3375 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3376 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3377 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3378 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, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3381 if(race_penaltytime && !race_penaltyaccumulator)
3383 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3384 a = bound(0, (1 + t - time), 1);
3388 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3390 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3391 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3392 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3393 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, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3398 drawfont = hud_font;
3403 float vote_yescount;
3406 float vote_highlighted; // currently selected vote
3408 float vote_active; // is there an active vote?
3409 float vote_prev; // previous state of vote_active to check for a change
3411 float vote_change; // "time" when vote_active changed
3413 void HUD_VoteWindow(void)
3415 float id = HUD_PANEL_VOTE;
3417 pos = HUD_Panel_GetPos(id);
3418 mySize = HUD_Panel_GetSize(id);
3422 if(vote_active != vote_prev) {
3424 vote_prev = vote_active;
3427 if(vote_active || hud_configure)
3428 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3430 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3442 a = vote_alpha * bound(cvar_or("hud_vote_alreadyvoted_alpha", 0.75), 1 - vote_highlighted, 1);
3444 HUD_Panel_DrawBg(id, pos, mySize, a);
3446 padding = HUD_Panel_GetPadding(id);
3449 pos += '1 1 0' * padding;
3450 mySize -= '2 2 0' * padding;
3453 drawpic_skin(pos, "voteprogress_back", mySize, '1 1 1', a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3455 s = "A vote has been called for: ";
3456 drawstring(pos + '0.5 0 0' * mySize_x + '0 0.1 0' * mySize_y - eX * stringwidth(s, FALSE, '1 1 0' * 0.5 * mySize_y*(1/5)), s, '1 1 0' * mySize_y*(1/5), '1 1 1', a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3457 s = textShortenToWidth(vote_called_vote, mySize_x * 0.96, '1 1 0' * mySize_y*(1/5), stringwidth_colors); // TODO: broken?
3459 s = "Configure the HUD";
3460 drawcolorcodedstring(pos + '0.52 0 0' * mySize_x + '0 0.3 0' * mySize_y - eX * stringwidth(s, FALSE, '1 1 0' * 0.5 * mySize_y*(1/6)), s, '1 1 0' * mySize_y*(1/6), a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3462 // print the yes/no counts
3463 s = strcat("Yes: ", ftos(vote_yescount));
3464 drawstring(pos + '0 0.6 0' * mySize_y + '0.02 0 0' * mySize_x, s, '1 1 0' * mySize_y*(1/6) , eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3465 s = strcat("No: ", ftos(vote_nocount));
3466 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 * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3468 // draw the progress bars
3469 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3470 drawpic_skin(pos, "voteprogress_prog", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3472 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3473 drawpic_skin(pos, "voteprogress_prog", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3475 // draw the highlights
3476 if(vote_highlighted == 1) {
3477 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3478 drawpic_skin(pos, "voteprogress_voted", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3480 else if(vote_highlighted == 2) {
3481 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3482 drawpic_skin(pos, "voteprogress_voted", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3485 drawresetcliparea();
3488 vote_highlighted = 0;
3492 // Mod icons panel (#10)
3495 float mod_active; // is there any active mod icon?
3497 // CTF HUD modicon section
3498 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3499 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3500 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3502 void HUD_Mod_CTF_Reset(void)
3504 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3507 void HUD_Mod_CTF(vector pos, vector mySize)
3509 vector redflag_pos, blueflag_pos;
3511 float f; // every function should have that
3513 float redflag, blueflag; // current status
3514 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3517 stat_items = getstati(STAT_ITEMS);
3518 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3519 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3521 if(redflag || blueflag)
3532 // when status CHANGES, set old status into prevstatus and current status into status
3533 if (redflag != redflag_prevframe)
3535 redflag_statuschange_time = time;
3536 redflag_prevstatus = redflag_prevframe;
3537 redflag_prevframe = redflag;
3540 if (blueflag != blueflag_prevframe)
3542 blueflag_statuschange_time = time;
3543 blueflag_prevstatus = blueflag_prevframe;
3544 blueflag_prevframe = blueflag;
3547 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3548 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3550 float BLINK_FACTOR = 0.15;
3551 float BLINK_BASE = 0.85;
3553 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3555 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3557 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3559 string red_icon, red_icon_prevstatus;
3560 float red_alpha, red_alpha_prevstatus;
3561 red_alpha = red_alpha_prevstatus = 1;
3563 case 1: red_icon = "flag_red_taken"; break;
3564 case 2: red_icon = "flag_red_lost"; break;
3565 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3567 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3568 red_icon = "flag_red_shielded";
3570 red_icon = string_null;
3573 switch(redflag_prevstatus) {
3574 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3575 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3576 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3579 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3580 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3581 red_icon_prevstatus = "flag_red_shielded";
3583 red_icon_prevstatus = string_null;
3587 string blue_icon, blue_icon_prevstatus;
3588 float blue_alpha, blue_alpha_prevstatus;
3589 blue_alpha = blue_alpha_prevstatus = 1;
3591 case 1: blue_icon = "flag_blue_taken"; break;
3592 case 2: blue_icon = "flag_blue_lost"; break;
3593 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3595 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3596 blue_icon = "flag_blue_shielded";
3598 blue_icon = string_null;
3601 switch(blueflag_prevstatus) {
3602 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3603 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3604 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3607 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3608 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3609 blue_icon_prevstatus = "flag_blue_shielded";
3611 blue_icon_prevstatus = string_null;
3615 if(mySize_x > mySize_y) {
3616 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3618 blueflag_pos = pos + eX * 0.5 * mySize_x;
3621 redflag_pos = pos + eX * 0.5 * mySize_x;
3623 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3625 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3627 blueflag_pos = pos + eY * 0.5 * mySize_y;
3630 redflag_pos = pos + eY * 0.5 * mySize_y;
3632 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3635 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3636 if(red_icon_prevstatus && f < 1)
3637 drawpic_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3639 drawpic_skin(redflag_pos, red_icon, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * red_alpha * f, DRAWFLAG_NORMAL);
3641 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3642 if(blue_icon_prevstatus && f < 1)
3643 drawpic_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3645 drawpic_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * blue_alpha * f, DRAWFLAG_NORMAL);
3648 // Keyhunt HUD modicon section
3649 float kh_runheretime;
3651 void HUD_Mod_KH_Reset(void)
3656 void HUD_Mod_KH(vector pos, vector mySize)
3658 mod_active = 1; // keyhunt should never hide the mod icons panel
3662 vector p, pa, kh_size, kh_asize;
3664 kh_keys = getstati(STAT_KH_KEYS);
3667 if(mySize_x > mySize_y)
3669 p_y = pos_y + 0.25 * mySize_y;
3670 pa = p - eY * 0.25 * mySize_y;
3672 kh_size_x = mySize_x * 0.25;
3673 kh_size_y = 0.75 * mySize_y;
3674 kh_asize_x = mySize_x * 0.25;
3675 kh_asize_y = mySize_y * 0.25;
3679 p_y = pos_y + 0.125 * mySize_y;
3680 pa = p - eY * 0.125 * mySize_y;
3682 kh_size_x = mySize_x * 0.5;
3683 kh_size_y = 0.375 * mySize_y;
3684 kh_asize_x = mySize_x * 0.5;
3685 kh_asize_y = mySize_y * 0.125;
3692 for(i = 0; i < 4; ++i)
3694 key = floor(kh_keys / pow(32, i)) & 31;
3696 if(keyteam == 30 && keycount <= 4)
3698 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3702 // this yields 8 exactly if "RUN HERE" shows
3707 kh_runheretime = time;
3708 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3713 for(i = 0; i < 4; ++i)
3715 key = floor(kh_keys / pow(32, i)) & 31;
3728 default: // owned or dropped
3733 a = a * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3734 aa = aa * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3740 drawpic_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3743 drawpic_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3746 drawpic_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3749 drawpic_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3754 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3757 drawpic_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3760 drawpic_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3763 drawpic_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3766 drawpic_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3770 if(mySize_x > mySize_y)
3772 p_x += 0.25 * mySize_x;
3773 pa_x += 0.25 * mySize_x;
3779 p_y = pos_y + 0.625 * mySize_y;
3780 pa_y = pos_y + 0.5 * mySize_y;
3786 p_x += 0.5 * mySize_x;
3787 pa_x += 0.5 * mySize_x;
3793 // Nexball HUD mod icon
3794 void HUD_Mod_NexBall(vector pos, vector mySize)
3796 float stat_items, nb_pb_starttime, dt, p;
3798 stat_items = getstati(STAT_ITEMS);
3799 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3801 if (stat_items & IT_KEY1)
3806 //Manage the progress bar if any
3807 if (nb_pb_starttime > 0)
3809 dt = mod(time - nb_pb_starttime, nb_pb_period);
3810 // one period of positive triangle
3811 p = 2 * dt / nb_pb_period;
3818 if(mySize_x > mySize_y)
3820 barsize = eX * p * mySize_x + eY * mySize_y;
3825 barsize = eX * mySize_x + eY * p * mySize_y;
3828 HUD_Panel_DrawProgressBar(pos, vertical, barsize, HUD_Panel_GetProgressBarColor("nexball"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3831 if (stat_items & IT_KEY1)
3832 drawpic_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3835 // Race/CTS HUD mod icons
3836 float crecordtime_prev; // last remembered crecordtime
3837 float crecordtime_change_time; // time when crecordtime last changed
3838 float srecordtime_prev; // last remembered srecordtime
3839 float srecordtime_change_time; // time when srecordtime last changed
3841 float race_status_time;
3842 float race_status_prev;
3843 string race_status_name_prev;
3844 void HUD_Mod_Race(vector pos, vector mySize)
3846 mod_active = 1; // race should never hide the mod icons panel
3848 me = playerslots[player_localentnum - 1];
3850 float f; // yet another function has this
3851 score = me.(scores[ps_primary]);
3853 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3854 return; // no records in the actual race
3856 drawfont = hud_bigfont;
3858 // clientside personal record
3860 if(gametype == GAME_CTS)
3864 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3866 if(score && (score < t || !t)) {
3867 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3868 if(cvar("cl_autodemo_delete_keeprecords"))
3870 f = cvar("cl_autodemo_delete");
3872 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3876 if(t != crecordtime_prev) {
3877 crecordtime_prev = t;
3878 crecordtime_change_time = time;
3880 f = time - crecordtime_change_time;
3883 drawstring_aspect(pos, "Personal best ", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3884 drawstring(pos + eY * 0.2 * mySize_y, TIME_ENCODED_TOSTRING(t), '1 1 0' * 0.2 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3886 drawstring(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3887 drawstring(pos + eY * 0.2 * mySize_y, TIME_ENCODED_TOSTRING(t), '1 1 0' * 0.2 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3888 drawstring_expanding(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL, f);
3889 drawstring_expanding(pos + eY * 0.2 * mySize_y, TIME_ENCODED_TOSTRING(t), '1 1 0' * 0.2 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL, f);
3893 t = race_server_record;
3894 if(t != srecordtime_prev) {
3895 srecordtime_prev = t;
3896 srecordtime_change_time = time;
3898 f = time - srecordtime_change_time;
3901 drawstring(pos + eY * 0.5 * mySize_y, "Server best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3902 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', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3904 drawstring(pos + eY * 0.5 * mySize_y, "Server best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3905 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', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3906 drawstring_expanding(pos + eY * 0.5 * mySize_y, "Server best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL, f);
3907 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', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL, f);
3910 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
3911 race_status_time = time + 5;
3912 race_status_prev = race_status;
3913 if (race_status_name_prev)
3914 strunzone(race_status_name_prev);
3915 race_status_name_prev = strzone(race_status_name);
3918 pos_x += mySize_x/2;
3921 a = bound(0, race_status_time - time, 1);
3924 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
3928 rank = race_CheckName(race_status_name);
3930 rankname = race_PlaceName(rank);
3933 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
3935 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
3937 if(race_status == 0)
3938 drawpic_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3939 else if(race_status == 1) {
3940 drawpic_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3941 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3942 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3943 } else if(race_status == 2) {
3944 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
3945 drawpic_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3947 drawpic_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3948 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3949 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3950 } else if(race_status == 3) {
3951 drawpic_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3952 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3953 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
3956 if (race_status_time - time <= 0) {
3957 race_status_prev = -1;
3959 if(race_status_name)
3960 strunzone(race_status_name);
3961 race_status_name = string_null;
3962 if(race_status_name_prev)
3963 strunzone(race_status_name_prev);
3964 race_status_name_prev = string_null;
3966 drawfont = hud_font;
3969 float mod_prev; // previous state of mod_active to check for a change
3971 float mod_change; // "time" when mod_active changed
3973 void HUD_ModIcons(void)
3975 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !hud_configure)
3978 float id = HUD_PANEL_MODICONS;
3980 pos = HUD_Panel_GetPos(id);
3981 mySize = HUD_Panel_GetSize(id);
3983 if(mod_active != mod_prev) {
3985 mod_prev = mod_active;
3988 if(mod_active || hud_configure)
3989 mod_alpha = bound(0, (time - mod_change) * 2, 1);
3991 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
3994 HUD_Panel_DrawBg(id, pos, mySize, mod_alpha);
3997 padding = HUD_Panel_GetPadding(id);
4000 pos += '1 1 0' * padding;
4001 mySize -= '2 2 0' * padding;
4004 // these MUST be ran in order to update mod_active
4005 if(gametype == GAME_KEYHUNT)
4006 HUD_Mod_KH(pos, mySize);
4007 else if(gametype == GAME_CTF || hud_configure)
4008 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4009 else if(gametype == GAME_NEXBALL)
4010 HUD_Mod_NexBall(pos, mySize);
4011 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4012 HUD_Mod_Race(pos, mySize);
4015 // Draw pressed keys (#11)
4017 void HUD_DrawPressedKeys(void)
4019 float id = HUD_PANEL_PRESSEDKEYS;
4021 pos = HUD_Panel_GetPos(id);
4022 mySize = HUD_Panel_GetSize(id);
4024 HUD_Panel_DrawBg(id, pos, mySize, 0);
4026 padding = HUD_Panel_GetPadding(id);
4029 pos += '1 1 0' * padding;
4030 mySize -= '2 2 0' * padding;
4034 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4037 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4038 drawpic_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4039 drawpic_skin(pos + eX * mySize_x * (1/3), ((pressedkeys & KEY_FORWARD) ? "key_forward_inv.tga" : "key_forward.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4040 drawpic_skin(pos + eX * mySize_x * (2/3), ((pressedkeys & KEY_JUMP) ? "key_jump_inv.tga" : "key_jump.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4041 drawpic_skin(pos + eY * 0.5 * mySize_y, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4042 drawpic_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', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4043 drawpic_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', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4046 // Handle chat as a panel (#12)
4050 float id = HUD_PANEL_CHAT;
4052 pos = HUD_Panel_GetPos(id);
4053 mySize = HUD_Panel_GetSize(id);
4055 HUD_Panel_DrawBg(id, pos, mySize, 0);
4057 padding = HUD_Panel_GetPadding(id);
4060 pos += '1 1 0' * padding;
4061 mySize -= '2 2 0' * padding;
4064 cvar_set("con_chatrect", "1");
4066 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4067 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4069 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4070 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4075 chatsize = cvar("con_chatsize");
4076 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4078 for(i = 0; i < cvar("con_chat"); ++i)
4080 if(i == cvar("con_chat") - 1)
4081 a = HUD_Panel_GetFgAlpha(id);
4083 a = HUD_Panel_GetFgAlpha(id) * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4084 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);
4089 // Engine info panel (#13)
4096 float frametimeavg1; // 1 frame ago
4097 float frametimeavg2; // 2 frames ago
4098 void HUD_EngineInfo(void)
4100 float id = HUD_PANEL_ENGINEINFO;
4102 pos = HUD_Panel_GetPos(id);
4103 mySize = HUD_Panel_GetSize(id);
4105 HUD_Panel_DrawBg(id, pos, mySize, 0);
4107 padding = HUD_Panel_GetPadding(id);
4110 pos += '1 1 0' * padding;
4111 mySize -= '2 2 0' * padding;
4114 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4116 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4117 frametimeavg2 = frametimeavg1;
4118 frametimeavg1 = frametimeavg;
4121 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4122 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.
4124 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
4125 prevfps = (1/frametime);
4126 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"
4132 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4134 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4136 prevfps_time = time;
4141 color = HUD_Get_Num_Color (prevfps, 100);
4142 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), mySize, mySize_y, color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4150 void HUD_ShowSpeed(void)
4153 float pos, conversion_factor;
4154 string speed, zspeed, unit;
4156 switch(cvar("cl_showspeed_unit"))
4161 conversion_factor = 1.0;
4165 conversion_factor = 1.0;
4169 conversion_factor = 0.0254;
4173 conversion_factor = 0.0254 * 3.6;
4177 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4181 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4185 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4187 numsize_x = numsize_y = cvar("cl_showspeed_size");
4188 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4190 drawfont = hud_bigfont;
4191 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4193 if (cvar("cl_showspeed_z") == 1) {
4194 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4195 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4198 drawfont = hud_font;
4201 vector acc_prevspeed;
4205 void HUD_ShowAcceleration(void)
4207 float acceleration, sz, scale, alpha, f;
4208 vector pos, top, rgb;
4209 top_x = vid_conwidth/2;
4212 f = time - acc_prevtime;
4213 if(cvar("cl_showacceleration_z"))
4214 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4216 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4217 acc_prevspeed = pmove_vel;
4218 acc_prevtime = time;
4220 f = bound(0, f * 10, 1);
4221 acc_avg = acc_avg * (1 - f) + acceleration * f;
4222 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4224 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4226 sz = cvar("cl_showacceleration_size");
4227 scale = cvar("cl_showacceleration_scale");
4228 alpha = cvar("cl_showacceleration_alpha");
4229 if (cvar("cl_showacceleration_color_custom"))
4230 rgb = stov(cvar_string("cl_showacceleration_color"));
4233 if (acceleration < 0) {
4234 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4235 } else if (acceleration > 0) {
4236 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4240 if (acceleration > 0)
4241 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4242 else if (acceleration < 0)
4243 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4246 void HUD_Reset (void)
4248 // reset gametype specific icons
4249 if(gametype == GAME_KEYHUNT)
4251 else if(gametype == GAME_CTF)
4252 HUD_Mod_CTF_Reset();
4255 void HUD_Main (void)
4257 if(disable_menu_alphacheck == 1)
4258 menu_fade_alpha = 1;
4260 menu_fade_alpha = (1 - cvar("_menu_alpha"));
4261 hud_fg_alpha = cvar("hud_fg_alpha");
4263 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4264 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4265 hud_color_bg_team = cvar("hud_color_bg_team");
4267 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4268 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4270 hud_configure = cvar("_hud_configure");
4274 // HUD configure visible grid
4275 if(hud_configure && cvar("hud_configure_grid") && cvar("hud_configure_grid_alpha"))
4279 for(i = 0; i < 1/bound(0.005, cvar("hud_configure_grid_x"), 0.2); ++i)
4281 drawfill(eX * i * vid_conwidth * bound(0.005, cvar("hud_configure_grid_x"), 0.2), eX + eY * vid_conheight, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
4284 for(i = 0; i < 1/bound(0.005, cvar("hud_configure_grid_y"), 0.2); ++i)
4286 drawfill(eY * i * vid_conheight * bound(0.005, cvar("hud_configure_grid_y"), 0.2), eY + eX * vid_conwidth, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
4290 if(cvar_string("hud_dock") != "" && cvar_string("hud_dock") != "0")
4291 drawpic('0 0 0', strcat("gfx/hud/", cvar_string("hud_skin"), "/", cvar_string("hud_dock")), eX * vid_conwidth + eY * vid_conheight, HUD_Panel_Dock_GetColor(), cvar("hud_dock_alpha") * menu_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
4293 if(HUD_Panel_CheckActive(HUD_PANEL_RADAR) || hud_configure)
4294 if(cvar_string("hud_radar") != "0" && (cvar("hud_radar") == 2 || teamplay))
4296 if(HUD_Panel_CheckActive(HUD_PANEL_WEAPONICONS) || hud_configure)
4298 if(HUD_Panel_CheckActive(HUD_PANEL_INVENTORY) || hud_configure)
4300 if(HUD_Panel_CheckActive(HUD_PANEL_POWERUPS) || hud_configure)
4302 if(HUD_Panel_CheckActive(HUD_PANEL_HEALTHARMOR) || hud_configure)
4304 if(HUD_Panel_CheckActive(HUD_PANEL_NOTIFY) || hud_configure)
4306 if(HUD_Panel_CheckActive(HUD_PANEL_TIMER) || hud_configure)
4308 if(HUD_Panel_CheckActive(HUD_PANEL_SCORE) || hud_configure)
4310 if(HUD_Panel_CheckActive(HUD_PANEL_RACETIMER) || hud_configure)
4311 if(gametype == GAME_RACE || gametype == GAME_CTS || hud_configure)
4313 if(HUD_Panel_CheckActive(HUD_PANEL_VOTE) || hud_configure)
4315 if(HUD_Panel_CheckActive(HUD_PANEL_MODICONS) || hud_configure)
4318 if(HUD_Panel_CheckActive(HUD_PANEL_PRESSEDKEYS) || hud_configure)
4319 if(spectatee_status > 0 || cvar("hud_pressedkeys") >= 2 || hud_configure)
4320 HUD_DrawPressedKeys();
4321 if(HUD_Panel_CheckActive(HUD_PANEL_CHAT) || hud_configure)
4324 cvar_set("con_chatrect", "0");
4325 if(HUD_Panel_CheckActive(HUD_PANEL_ENGINEINFO) || hud_configure)
4328 // TODO hud_'ify these
4329 if (cvar("cl_showspeed"))
4331 if (cvar("cl_showacceleration"))
4332 HUD_ShowAcceleration();
4334 if (hud_configure && spectatee_status) // try to join if we are in hud_configure mode, but still spectating (in order to get rid of motd and such)
4335 localcmd("cmd selectteam auto; cmd join\n");
4337 if (!hud_configure) // hud config mode disabled, enable normal alpha stuff again
4338 disable_menu_alphacheck = 0;