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 // TODO: make a default skin, and fallback to these!
101 void drawpic_skin(vector pos, string pic, vector sz, vector color, float alpha, float drawflag) {
102 drawpic_aspect(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, color, alpha, drawflag);
106 void drawpic_skin_expanding(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
108 //drawpic_aspect_expanding(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
111 void drawpic_skin_expanding_two(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
113 //drawpic_aspect_expanding_two(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
116 // return HUD background color
117 vector HUD_GetBgColor()
121 GetTeamRGB(myteam) * hud_color_bg_team;
123 // allow custom HUD colors in non-teamgames
124 color_x = cvar("hud_color_bg_r");
125 color_y = cvar("hud_color_bg_g");
126 color_z = cvar("hud_color_bg_b");
131 // return accuracy text color
132 vector HUD_AccuracyColor(float accuracy)
135 float yellow_accuracy = cvar("hud_weaponicons_accuracy_yellow"); // value at which this function returns yellow
136 if(accuracy >= 100) {
140 else if(accuracy > yellow_accuracy) {
141 rgb_x = 1 - (accuracy-yellow_accuracy)/(100-yellow_accuracy); // red value between 1 -> 0
146 rgb_y = accuracy/yellow_accuracy; // green value between 0 -> 1
152 vector HUD_Get_Num_Color (float x, float maxvalue)
160 else if(x > maxvalue * 0.75) {
161 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
162 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
165 else if(x > maxvalue * 0.5) {
166 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
167 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
168 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
170 else if(x > maxvalue * 0.25) {
173 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
175 else if(x > maxvalue * 0.1) {
177 color_y = (x-20)*90/27/100; // green value between 0 -> 1
178 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
188 float stringwidth_colors(string s, vector theSize)
190 return stringwidth(s, TRUE, theSize);
193 float stringwidth_nocolors(string s, vector theSize)
195 return stringwidth(s, FALSE, theSize);
198 #define CENTERPRINT_MAX_LINES 30
199 string centerprint_messages[CENTERPRINT_MAX_LINES];
200 float centerprint_width[CENTERPRINT_MAX_LINES];
201 vector centerprint_start;
202 float centerprint_expire;
203 float centerprint_num;
204 float centerprint_offset_hint;
205 vector centerprint_fontsize;
207 void centerprint(string strMessage)
209 float i, j, n, hcount;
212 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
214 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
216 if(cvar("scr_centertime") <= 0)
222 // strip trailing newlines
223 j = strlen(strMessage) - 1;
224 while(substring(strMessage, j, 1) == "\n" && j >= 0)
226 strMessage = substring(strMessage, 0, j + 1);
231 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
233 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
235 strMessage = substring(strMessage, j, strlen(strMessage) - j);
236 centerprint_offset_hint = j;
241 // if we get here, we have a message. Initialize its height.
244 n = tokenizebyseparator(strMessage, "\n");
246 for(j = 0; j < n; ++j)
248 getWrappedLine_remaining = argv(j);
249 while(getWrappedLine_remaining)
251 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
252 if(centerprint_messages[i])
253 strunzone(centerprint_messages[i]);
254 centerprint_messages[i] = strzone(s);
255 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
258 // half height for empty lines looks better
264 if(i >= CENTERPRINT_MAX_LINES)
270 h = centerprint_fontsize_y*hcount;
272 havail = vid_conheight;
273 if(cvar("con_chatpos") < 0)
274 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
275 if(havail > vid_conheight - 70)
276 havail = vid_conheight - 70; // avoid overlapping HUD
278 centerprint_start_x = 0;
281 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
283 // here, the centerprint would cover the crosshair. REALLY BAD.
284 forbiddenmin = vid_conheight * 0.5 - h - 16;
285 forbiddenmax = vid_conheight * 0.5 + 16;
287 allowedmin = scoreboard_bottom;
288 allowedmax = havail - h;
289 preferred = (havail - h)/2;
292 // possible orderings (total: 4! / 4 = 6)
293 // allowedmin allowedmax forbiddenmin forbiddenmax
294 // forbiddenmin forbiddenmax allowedmin allowedmax
295 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
297 // forbidden doesn't matter in this case
298 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
300 // allowedmin forbiddenmin allowedmax forbiddenmax
301 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
303 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
305 // allowedmin forbiddenmin forbiddenmax allowedmax
306 else if(allowedmin < forbiddenmin)
308 // make sure the forbidden zone is not covered
309 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
310 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
312 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
314 // forbiddenmin allowedmin allowedmax forbiddenmax
315 else if(allowedmax < forbiddenmax)
317 // it's better to leave the allowed zone (overlap with scoreboard) than
318 // to cover the forbidden zone (crosshair)
319 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
320 centerprint_start_y = forbiddenmax;
322 centerprint_start_y = forbiddenmin;
324 // forbiddenmin allowedmin forbiddenmax allowedmax
327 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
330 centerprint_start_y =
333 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
341 centerprint_expire = time + cvar("scr_centertime");
344 void HUD_DrawCenterPrint (void)
351 //if(time > centerprint_expire)
354 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
355 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
356 //sz = 1.2 / (a + 0.2);
361 pos = centerprint_start;
362 for (i=0; i<centerprint_num; i = i + 1)
364 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
365 ts = centerprint_messages[i];
368 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
369 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
370 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
371 pos_y = pos_y + centerprint_fontsize_y;
374 // half height for empty lines looks better
375 pos_y = pos_y + centerprint_fontsize_y * 0.5;
379 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
381 position_x -= 2 / 3 * strlen(text) * scale_x;
382 drawstring(position, text, scale, rgb, alpha, flag);
385 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
387 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
388 drawstring(position, text, scale, rgb, alpha, flag);
391 // return the string of the given race place
392 string race_PlaceName(float pos) {
400 return strcat(ftos(pos), "th");
403 // return the string of the onscreen race timer
404 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
412 if(histime == 0) // goal hit
416 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
426 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
432 lapstr = strcat(" (-", ftos(lapdelta), "L)");
435 else if(lapdelta < 0)
437 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
441 else if(histime > 0) // anticipation
443 if(mytime >= histime)
444 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
446 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
453 cpname = "Start line";
455 cpname = "Finish line";
457 cpname = strcat("Intermediate ", ftos(cp));
459 cpname = "Finish line";
462 return strcat(col, cpname);
463 else if(hisname == "")
464 return strcat(col, cpname, " (", timestr, ")");
466 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
469 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
470 float race_CheckName(string net_name) {
472 for (i=RANKINGS_CNT-1;i>=0;--i)
473 if(grecordholder[i] == net_name)
485 void HUD_Panel_ExportCfg(string cfgname)
488 fh = fopen(strcat("hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg"), FILE_WRITE);
491 fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
492 fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
493 fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
494 fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
495 fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
496 fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
497 fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
498 fputs(fh, strcat("seta hud_fg_alpha \"", cvar_string("hud_fg_alpha"), "\"", "\n"));
501 fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
502 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
503 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
504 fputs(fh, strcat("seta hud_dock_alpha \"", ftos(cvar("hud_dock_alpha")), "\"", "\n"));
507 fputs(fh, strcat("seta hud_progressbar_alpha ", ftos(cvar("hud_progressbar_alpha")), "\n"));
508 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
509 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
510 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
511 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
512 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
513 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
516 // common cvars for all panels
518 for (i = 0; i < HUD_PANEL_NUM; ++i)
520 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), " ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i)))), "\n"));
521 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_pos \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_pos")), "\"", "\n"));
522 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_size \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_size")), "\"", "\n"));
523 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg")), "\"", "\n"));
524 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color")), "\"", "\n"));
525 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color_team \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color_team")), "\"", "\n"));
526 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_alpha \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_alpha")), "\"", "\n"));
527 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_border \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_border")), "\"", "\n"));
528 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_padding \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_padding")), "\"", "\n"));
530 case HUD_PANEL_WEAPONICONS:
531 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_accuracy_yellow ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_accuracy_yellow"))), "\n"));
533 case HUD_PANEL_INVENTORY:
534 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_onlycurrent ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_onlycurrent"))), "\n"));
535 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_iconalign ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
537 case HUD_PANEL_POWERUPS:
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), "_iconalign ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
540 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_baralign ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
542 case HUD_PANEL_HEALTHARMOR:
543 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
544 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_iconalign ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
545 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_baralign ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
547 case HUD_PANEL_NOTIFY:
548 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
549 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_info_top ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_info_top"))), "\n"));
551 case HUD_PANEL_RADAR:
552 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_foreground_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_foreground_alpha"))), "\n"));
554 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha"))), "\n"));
560 print("^2Successfully exported to hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
565 // return active status of panel
566 float HUD_Panel_CheckActive(float id)
568 if (cvar_or(strcat("hud_", HUD_Panel_GetName(id)), 1))
573 // return size of given panel
574 vector HUD_Panel_GetSize(float id)
577 mySize = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_size")));
579 mySize = eX * mySize_x * vid_conwidth + eY * mySize_y * vid_conheight;
581 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
583 vector menu_enable_maxsize, menu_enable_size;
584 menu_enable_maxsize = '0 0 0'; // shut up FTEQCC
585 menu_enable_maxsize_x = 0.3 * vid_conwidth;
586 menu_enable_maxsize_y = 0.18 * vid_conheight;
587 if(mySize_x > mySize_y)
589 if(mySize_y > menu_enable_maxsize_y)
591 menu_enable_size_y = menu_enable_maxsize_y;
592 menu_enable_size_x = mySize_x * (menu_enable_maxsize_y/mySize_y);
593 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
598 if(mySize_x > menu_enable_maxsize_x)
600 menu_enable_size_x = menu_enable_maxsize_x;
601 menu_enable_size_y = mySize_y * (menu_enable_maxsize_x/mySize_x);
602 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
609 // return pos of given panel
610 vector HUD_Panel_GetPos(float id)
613 pos = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_pos")));
615 pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
617 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
619 vector mySize, menu_enable_panelpos;
620 mySize = HUD_Panel_GetSize(id);
621 if(mySize_x > mySize_y)
622 menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * mySize_x + eY * 0.82 * vid_conheight;
624 menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * mySize_y + eX * 0.7 * vid_conwidth;
625 pos = (1 - cvar("_menu_alpha")) * pos + (cvar("_menu_alpha")) * menu_enable_panelpos;
630 float HUD_Panel_GetBorder(float id)
633 border = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_border"));
635 border = cvar_string("hud_bg_border");
639 vector HUD_Panel_GetColor(float id)
645 // fetch per-panel color
646 if(teamplay && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")) != "") {
647 f = stof(getplayerkey(self.sv_entnum, "colors"));
648 color = vtos(colormapPaletteColor(mod(f, 16), 1) * cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")));
651 color = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color"));
652 color_vec = stov(color);
654 if(color == "") { // fetch default color
655 color = cvar_string("hud_bg_color");
656 color_vec = stov(color);
657 if(teamplay && cvar(strcat("hud_bg_color_team"))) {
658 f = stof(getplayerkey(self.sv_entnum, "colors"));
659 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_bg_color_team");
661 else if(color == "shirt") {
662 f = stof(getplayerkey(self.sv_entnum, "colors"));
663 color_vec = colormapPaletteColor(floor(f / 16), 0);
665 else if(color == "pants") {
666 f = stof(getplayerkey(self.sv_entnum, "colors"));
667 color_vec = colormapPaletteColor(mod(f, 16), 1);
670 else if(color == "shirt") {
671 f = stof(getplayerkey(self.sv_entnum, "colors"));
672 color_vec = colormapPaletteColor(floor(f / 16), 0);
674 else if(color == "pants") {
675 f = stof(getplayerkey(self.sv_entnum, "colors"));
676 color_vec = colormapPaletteColor(mod(f, 16), 1);
681 vector HUD_Panel_Dock_GetColor(void)
686 color = cvar_string("hud_dock_color");
687 color_vec = stov(color);
688 if(teamplay && cvar(strcat("hud_dock_color_team"))) {
689 f = stof(getplayerkey(self.sv_entnum, "colors"));
690 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_dock_color_team");
692 else if(color == "shirt") {
693 f = stof(getplayerkey(self.sv_entnum, "colors"));
694 color_vec = colormapPaletteColor(floor(f / 16), 0);
696 else if(color == "pants") {
697 f = stof(getplayerkey(self.sv_entnum, "colors"));
698 color_vec = colormapPaletteColor(mod(f, 16), 1);
703 float HUD_Panel_GetBgAlpha(float id)
706 alpha = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_alpha"));
708 alpha = cvar_string("hud_bg_alpha");
710 if(hud_configure && disable_menu_alphacheck == 2 && highlightedPanel == id) // do not set a minalpha cap when showing the config dialog for this panel
711 alpha = ftos((1 - cvar("_menu_alpha")) * max(cvar("hud_configure_bg_minalpha"), stof(alpha)) + (cvar("_menu_alpha")) * stof(alpha));
712 else if(hud_configure)
713 alpha = ftos(max(cvar("hud_configure_bg_minalpha"), stof(alpha)));
715 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
718 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
721 return stof(alpha) * menu_fade_alpha;
724 float HUD_Panel_GetFgAlpha(float id)
727 alpha = hud_fg_alpha;
729 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
732 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
735 return alpha * menu_fade_alpha;
738 float HUD_Panel_GetPadding(float id)
741 padding = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
743 padding = cvar_string("hud_bg_padding");
746 mySize = HUD_Panel_GetSize(id);
748 smallestsize = min(mySize_x, mySize_y);
749 return min(smallestsize/2 - 5, stof(padding));
752 // draw the background/borders
753 void HUD_Panel_DrawBg(float id, vector pos, vector mySize, float alpha)
755 if(!hud_configure && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg")) == "0")
759 bg = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg"));
761 bg = cvar_string("hud_bg");
763 if(bg == "0" && hud_configure) {
764 bg = "border"; // we probably want to see a background in config mode at all times...
770 border = max(0.0000001, HUD_Panel_GetBorder(id)); // draw_BorderPicture does not like border = 0
773 color = HUD_Panel_GetColor(id);
776 alpha = HUD_Panel_GetBgAlpha(id) * alpha; // allow panels to fade in/out by passing an alpha value
778 alpha = HUD_Panel_GetBgAlpha(id);
780 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));
784 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
790 pic = strcat("gfx/hud/", cvar_string("hud_skin"), "/");
792 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);
793 if(mySize_y/mySize_x > 2)
794 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);
795 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);
797 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);
798 if(mySize_x/mySize_y > 2)
799 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);
800 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);
804 vector HUD_Panel_GetProgressBarColor(string item)
806 return stov(cvar_string(strcat("hud_progressbar_", item, "_color")));
809 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
810 vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
821 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
822 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
824 for (i = 0; i < HUD_PANEL_NUM; ++i) {
825 if(i == id || !HUD_Panel_CheckActive(i))
828 targPos = HUD_Panel_GetPos(i) - '1 1 0' * HUD_Panel_GetBorder(id);
829 targSize = HUD_Panel_GetSize(i) + '2 2 0' * HUD_Panel_GetBorder(id);
831 if(myPos_y + mySize_y < targPos_y)
833 if(myPos_y > targPos_y + targSize_y)
836 if(myPos_x + mySize_x < targPos_x)
838 if(myPos_x > targPos_x + targSize_x)
841 // OK, there IS a collision.
843 myCenter_x = myPos_x + 0.5 * mySize_x;
844 myCenter_y = myPos_y + 0.5 * mySize_y;
846 targCenter_x = targPos_x + 0.5 * targSize_x;
847 targCenter_y = targPos_y + 0.5 * targSize_y;
849 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
851 if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
852 myTarget_x = targPos_x - mySize_x;
853 else // push it upwards
854 myTarget_y = targPos_y - mySize_y;
856 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
858 if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
859 myTarget_x = targPos_x + targSize_x;
860 else // push it upwards
861 myTarget_y = targPos_y - mySize_y;
863 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
865 if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
866 myTarget_x = targPos_x - mySize_x;
867 else // push it downwards
868 myTarget_y = targPos_y + targSize_y;
870 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
872 if(targPos_x + targSize_x - myPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
873 myTarget_x = targPos_x + targSize_x;
874 else // push it downwards
875 myTarget_y = targPos_y + targSize_y;
882 void HUD_Panel_SetPos(float id, vector pos)
885 oldPos = HUD_Panel_GetPos(id);
888 mySize = HUD_Panel_GetSize(id);
890 if(hud_configure_checkcollisions)
891 pos = HUD_Panel_CheckMove(id, pos, mySize);
893 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
894 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
896 if(cvar("hud_configure_grid"))
898 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;
899 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;
903 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
905 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
908 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
909 vector HUD_Panel_CheckResize(float id, vector mySize, vector resizeorigin) {
919 ratio = mySize_x/mySize_y;
921 for (i = 0; i < HUD_PANEL_NUM; ++i) {
922 if(i == id || !HUD_Panel_CheckActive(i))
925 targBorder = HUD_Panel_GetBorder(i);
926 targPos = HUD_Panel_GetPos(i) - '1 1 0' * targBorder;
927 targSize = HUD_Panel_GetSize(i) + '2 2 0' * targBorder;
928 targEndPos = targPos + targSize;
930 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
931 if(resizeorigin_x > targPos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > targPos_y && resizeorigin_y < targEndPos_y)
934 if (resizeCorner == 1)
936 // check if this panel is on our way
937 if (resizeorigin_x <= targPos_x)
939 if (resizeorigin_y <= targPos_y)
941 if (targEndPos_x <= resizeorigin_x - mySize_x)
943 if (targEndPos_y <= resizeorigin_y - mySize_y)
946 // there is a collision:
947 // detect which side of the panel we are facing is actually limiting the resizing
948 // (which side the resize direction finds for first) and reduce the size up to there
950 // dist is the distance between resizeorigin and the "analogous" point of the panel
951 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
952 dist_x = resizeorigin_x - targEndPos_x;
953 dist_y = resizeorigin_y - targEndPos_y;
954 if (dist_y < 0 || dist_x / dist_y > ratio)
955 mySize_x = min(mySize_x, dist_x);
957 mySize_y = min(mySize_y, dist_y);
959 else if (resizeCorner == 2)
961 if (resizeorigin_x >= targEndPos_x)
963 if (resizeorigin_y <= targPos_y)
965 if (targPos_x >= resizeorigin_x + mySize_x)
967 if (targEndPos_y <= resizeorigin_y - mySize_y)
970 dist_x = targPos_x - resizeorigin_x;
971 dist_y = resizeorigin_y - targEndPos_y;
972 if (dist_y < 0 || dist_x / dist_y > ratio)
973 mySize_x = min(mySize_x, dist_x);
975 mySize_y = min(mySize_y, dist_y);
977 else if (resizeCorner == 3)
979 if (resizeorigin_x <= targPos_x)
981 if (resizeorigin_y >= targEndPos_y)
983 if (targEndPos_x <= resizeorigin_x - mySize_x)
985 if (targPos_y >= resizeorigin_y + mySize_y)
988 dist_x = resizeorigin_x - targEndPos_x;
989 dist_y = targPos_y - resizeorigin_y;
990 if (dist_y < 0 || dist_x / dist_y > ratio)
991 mySize_x = min(mySize_x, dist_x);
993 mySize_y = min(mySize_y, dist_y);
995 else if (resizeCorner == 4)
997 if (resizeorigin_x >= targEndPos_x)
999 if (resizeorigin_y >= targEndPos_y)
1001 if (targPos_x >= resizeorigin_x + mySize_x)
1003 if (targPos_y >= resizeorigin_y + mySize_y)
1006 dist_x = targPos_x - resizeorigin_x;
1007 dist_y = targPos_y - resizeorigin_y;
1008 if (dist_y < 0 || dist_x / dist_y > ratio)
1009 mySize_x = min(mySize_x, dist_x);
1011 mySize_y = min(mySize_y, dist_y);
1013 if(cvar("hud_configure_checkcollisions_debug"))
1014 drawfill(targPos + '1 1 0' * targBorder, targSize - '2 2 0' * targBorder, '1 1 0', .3, DRAWFLAG_NORMAL);
1020 void HUD_Panel_SetPosSize(float id)
1022 vector resizeorigin;
1023 resizeorigin = panel_click_resizeorigin;
1024 vector mySize, myPos;
1026 if(resizeCorner == 1) {
1027 mySize_x = resizeorigin_x - (mousepos_x - panel_click_distance_x);
1028 mySize_y = resizeorigin_y - (mousepos_y - panel_click_distance_y);
1029 } else if(resizeCorner == 2) {
1030 mySize_x = mousepos_x + panel_click_distance_x - resizeorigin_x;
1031 mySize_y = panel_click_distance_y + resizeorigin_y - mousepos_y;
1032 } else if(resizeCorner == 3) {
1033 mySize_x = resizeorigin_x + panel_click_distance_x - mousepos_x;
1034 mySize_y = mousepos_y + panel_click_distance_y - resizeorigin_y;
1035 } else { // resizeCorner == 4
1036 mySize_x = mousepos_x - (resizeorigin_x - panel_click_distance_x);
1037 mySize_y = mousepos_y - (resizeorigin_y - panel_click_distance_y);
1040 // minimum panel size cap
1041 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1042 mySize_y = max(0.025 * vid_conheight, mySize_y);
1044 if(id == HUD_PANEL_CHAT) // some panels have their own restrictions, like the chat panel (which actually only moves the engine chat print around). Looks bad if it's too small.
1046 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
1047 mySize_y = max(2 * cvar("con_chatsize") + 2 * HUD_Panel_GetPadding(id), mySize_y);
1050 // collision testing|
1051 // -----------------+
1053 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
1054 if(resizeCorner == 1) {
1055 myPos_x = resizeorigin_x - mySize_x;
1056 myPos_y = resizeorigin_y - mySize_y;
1057 } else if(resizeCorner == 2) {
1058 myPos_x = resizeorigin_x;
1059 myPos_y = resizeorigin_y - mySize_y;
1060 } else if(resizeCorner == 3) {
1061 myPos_x = resizeorigin_x - mySize_x;
1062 myPos_y = resizeorigin_y;
1063 } else { // resizeCorner == 4
1064 myPos_x = resizeorigin_x;
1065 myPos_y = resizeorigin_y;
1068 // left/top screen edges
1070 mySize_x = mySize_x + myPos_x;
1072 mySize_y = mySize_y + myPos_y;
1074 // bottom/right screen edges
1075 if(myPos_x + mySize_x > vid_conwidth)
1076 mySize_x = vid_conwidth - myPos_x;
1077 if(myPos_y + mySize_y > vid_conheight)
1078 mySize_y = vid_conheight - myPos_y;
1080 if(cvar("hud_configure_checkcollisions_debug"))
1081 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
1083 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
1084 if(cvar("hud_configure_grid"))
1086 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;
1087 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;
1090 if(hud_configure_checkcollisions)
1091 mySize = HUD_Panel_CheckResize(id, mySize, resizeorigin);
1093 // 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)
1094 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1095 mySize_y = max(0.025 * vid_conheight, mySize_y);
1097 // do another pos check, as size might have changed by now
1098 if(resizeCorner == 1) {
1099 myPos_x = resizeorigin_x - mySize_x;
1100 myPos_y = resizeorigin_y - mySize_y;
1101 } else if(resizeCorner == 2) {
1102 myPos_x = resizeorigin_x;
1103 myPos_y = resizeorigin_y - mySize_y;
1104 } else if(resizeCorner == 3) {
1105 myPos_x = resizeorigin_x - mySize_x;
1106 myPos_y = resizeorigin_y;
1107 } else { // resizeCorner == 4
1108 myPos_x = resizeorigin_x;
1109 myPos_y = resizeorigin_y;
1112 if(cvar("hud_configure_checkcollisions_debug"))
1113 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
1116 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
1117 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_size"), s);
1119 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
1120 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
1124 float prevMouseClicked; // previous state
1125 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
1126 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
1129 float menu_enabled_time;
1130 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1135 // allow console bind to work
1138 con_keys = findkeysforcommand("toggleconsole");
1139 keys = tokenize(con_keys);
1141 float hit_con_bind, i;
1142 for (i = 0; i < keys; ++i)
1144 if(nPrimary == stof(argv(i)))
1148 if(bInputType == 0) {
1149 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1150 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1151 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1153 else if(bInputType == 1) {
1154 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1155 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1156 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1159 if(nPrimary == K_MOUSE1)
1161 if(bInputType == 0) { // key pressed
1165 else if(bInputType == 1) {// key released
1170 else if(nPrimary == K_ESCAPE)
1172 if (bInputType == 1)
1174 disable_menu_alphacheck = 1;
1176 menu_enabled_time = time;
1177 localcmd("menu_showhudexit\n");
1180 else if(hit_con_bind)
1183 return true; // Suppress ALL other input
1186 void HUD_Panel_Mouse()
1188 // 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
1189 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1190 disable_menu_alphacheck = 0;
1191 if (cvar("_menu_alpha") == 0 && time - menu_enabled_time > 0.5)
1195 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1196 print("Highlighted: ", ftos(highlightedPanel), "\n");
1197 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1200 if(mouseClicked == 0 && disable_menu_alphacheck != 2) { // don't reset these variables in disable_menu_alphacheck mode 2!
1201 highlightedPanel = -1;
1202 highlightedAction = 0;
1205 mousepos = mousepos + getmousepos();
1207 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1208 mousepos_y = bound(0, mousepos_y, vid_conheight);
1210 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1218 for(i = 0; i < HUD_PANEL_NUM; ++i)
1220 panelPos = HUD_Panel_GetPos(i);
1221 panelSize = HUD_Panel_GetSize(i);
1222 border = HUD_Panel_GetBorder(i);
1223 if(prevMouseClicked == 0) {
1225 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1227 highlightedPanel = i;
1228 highlightedAction = 1;
1230 // resize from topleft border
1231 else if(mousepos_x >= panelPos_x - border && mousepos_y >= panelPos_y - border && mousepos_x <= panelPos_x + 0.5 * panelSize_x && mousepos_y <= panelPos_y + 0.5 * panelSize_y)
1233 highlightedPanel = i;
1234 highlightedAction = 2;
1237 // resize from topright border
1238 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)
1240 highlightedPanel = i;
1241 highlightedAction = 2;
1244 // resize from bottomleft border
1245 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)
1247 highlightedPanel = i;
1248 highlightedAction = 2;
1251 // resize from bottomright border
1252 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)
1254 highlightedPanel = i;
1255 highlightedAction = 2;
1260 if(highlightedPanel == i)
1262 if(prevMouseClicked == 0)
1264 if(highlightedAction == 1)
1265 panel_click_distance = mousepos - panelPos;
1266 else if(highlightedAction == 2)
1268 if(resizeCorner == 1) {
1269 panel_click_distance = mousepos - panelPos;
1270 panel_click_resizeorigin = panelPos + panelSize;
1271 } else if(resizeCorner == 2) {
1272 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1273 panel_click_distance_y = mousepos_y - panelPos_y;
1274 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1275 } else if(resizeCorner == 3) {
1276 panel_click_distance_x = mousepos_x - panelPos_x;
1277 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1278 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1279 } else if(resizeCorner == 4) {
1280 panel_click_distance = panelSize - mousepos + panelPos;
1281 panel_click_resizeorigin = panelPos;
1286 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
1288 if(cvar("hud_configure_checkcollisions_debug"))
1289 drawfill(panelPos, panelSize, '1 0 0', .3, DRAWFLAG_NORMAL);
1291 if(highlightedAction == 1)
1292 HUD_Panel_SetPos(i, mousepos - panel_click_distance);
1293 else if(highlightedAction == 2)
1294 HUD_Panel_SetPosSize(i);
1298 // doubleclick check
1299 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1301 mouseClicked = 0; // to prevent spam, I guess.
1302 disable_menu_alphacheck = 2;
1304 menu_enabled_time = time;
1305 localcmd("menu_showhudoptions ", ftos(highlightedPanel), "\n");
1308 if(prevMouseClicked == 0)
1310 prevMouseClickedTime = time;
1311 prevMouseClickedPos = mousepos;
1314 prevMouseClicked = mouseClicked;
1317 // Weapon icons (#0)
1319 float weaponspace[10];
1320 void HUD_WeaponIcons_Clear()
1323 for(idx = 0; idx < 10; ++idx)
1324 weaponspace[idx] = 0;
1327 entity weaponorder[WEP_MAXCOUNT];
1328 void weaponorder_swap(float i, float j, entity pass)
1332 weaponorder[i] = weaponorder[j];
1336 string weaponorder_cmp_str_save;
1337 string weaponorder_cmp_str;
1338 float weaponorder_cmp(float i, float j, entity pass)
1341 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1342 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1343 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)
1346 void HUD_WeaponIcons(void)
1348 float id = HUD_PANEL_WEAPONICONS;
1349 float alpha, stat_weapons; // "constants"
1350 vector pos, mySize, accuracy_color;
1351 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1353 pos = HUD_Panel_GetPos(id);
1354 mySize = HUD_Panel_GetSize(id);
1356 stat_weapons = getstati(STAT_WEAPONS);
1358 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1360 self = get_weaponinfo(i);
1361 if(self.impulse >= 0)
1365 // TODO make this configurable
1366 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1368 if(weaponorder_cmp_str != weaponorder_cmp_str_save)
1370 if(weaponorder_cmp_str_save)
1371 strunzone(weaponorder_cmp_str_save);
1372 weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
1374 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1376 self = get_weaponinfo(i);
1377 if(self.impulse >= 0)
1379 weaponorder[weapon_cnt] = self;
1383 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1386 HUD_Panel_DrawBg(id, pos, mySize, 0);
1388 padding = HUD_Panel_GetPadding(id);
1391 pos += '1 1 0' * padding;
1392 mySize -= '2 2 0' * padding;
1396 weapon_stats = getstati(STAT_DAMAGE_HITS);
1397 weapon_number = weapon_stats & 63;
1398 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1400 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1401 weapon_number = weapon_stats & 63;
1402 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1404 if(cvar_or("hud_weaponicons_fade", 1))
1406 fade = 3.2 - 2 * (time - weapontime);
1407 fade = bound(0.7, fade, 1);
1412 HUD_WeaponIcons_Clear();
1414 float rows, columns;
1415 rows = mySize_y/mySize_x;
1416 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1417 // ^^^ weapon icon aspect goes here
1419 columns = ceil(WEP_COUNT/rows);
1421 for(i = 0; i < weapon_cnt; ++i)
1423 self = weaponorder[i];
1424 weapid = self.impulse;
1426 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1428 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1429 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1431 // draw background behind currently selected weapon
1432 if(self.weapon == activeweapon)
1433 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);
1435 // draw the weapon accuracy on the HUD
1436 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1439 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1441 accuracy_color = HUD_AccuracyColor(weapon_stats);
1443 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);
1446 // draw the weapon icon
1447 if((self.impulse >= 0) && (stat_weapons & self.weapons))
1449 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);
1451 if(cvar_or("hud_weaponicons_number", 1))
1452 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);
1454 // draw a "ghost weapon icon" if you don't have the weapon
1457 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);
1472 float GetAmmoStat(float i)
1476 case 0: return STAT_SHELLS;
1477 case 1: return STAT_NAILS;
1478 case 2: return STAT_ROCKETS;
1479 case 3: return STAT_CELLS;
1480 case 4: return STAT_FUEL;
1485 float GetAmmoItemCode(float i)
1489 case 0: return IT_SHELLS;
1490 case 1: return IT_NAILS;
1491 case 2: return IT_ROCKETS;
1492 case 3: return IT_CELLS;
1493 case 4: return IT_FUEL;
1498 string GetAmmoPicture(float i)
1502 case 0: return "ammo_shells";
1503 case 1: return "ammo_bullets";
1504 case 2: return "ammo_rockets";
1505 case 3: return "ammo_cells";
1506 case 4: return "ammo_fuel";
1511 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1514 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1525 if(currently_selected)
1530 vector newSize, newPos;
1531 if(mySize_x/mySize_y > 3)
1533 newSize_x = 3 * mySize_y;
1534 newSize_y = mySize_y;
1536 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1541 newSize_y = 1/3 * mySize_x;
1542 newSize_x = mySize_x;
1544 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1548 vector picpos, numpos;
1549 if(cvar("hud_inventory_iconalign"))
1552 picpos = newPos + eX * 2 * newSize_y;
1556 numpos = newPos + eX * newSize_y;
1560 if (currently_selected)
1561 drawpic_skin(newPos, "ammo_current_bg", newSize, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_INVENTORY), DRAWFLAG_NORMAL);
1563 drawfont = hud_bigfont;
1564 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, newSize_y, color, HUD_Panel_GetFgAlpha(HUD_PANEL_INVENTORY) * alpha, DRAWFLAG_NORMAL);
1565 drawfont = hud_font;
1566 drawpic_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_INVENTORY) * alpha, DRAWFLAG_NORMAL);
1569 void HUD_Inventory(void)
1571 float id = HUD_PANEL_INVENTORY;
1572 float i, currently_selected;
1575 pos = HUD_Panel_GetPos(id);
1576 mySize = HUD_Panel_GetSize(id);
1578 HUD_Panel_DrawBg(id, pos, mySize, 0);
1580 padding = HUD_Panel_GetPadding(id);
1583 pos += '1 1 0' * padding;
1584 mySize -= '2 2 0' * padding;
1587 float rows, columns;
1588 rows = mySize_y/mySize_x;
1589 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1590 // ^^^ ammo item aspect goes here
1592 columns = ceil(AMMO_COUNT/rows);
1596 for (i = 0; i < AMMO_COUNT; ++i) {
1597 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1598 if(cvar("hud_inventory_onlycurrent")) {
1601 if (currently_selected || hud_configure)
1602 DrawAmmoItem(pos, mySize, i, currently_selected);
1605 DrawAmmoItem(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), i, currently_selected);
1610 column = column + 1;
1616 void DrawNumIcon(float id, vector myPos, vector mySize, float x, string icon, float left, vector color)
1618 vector newSize, newPos;
1619 if(mySize_x/mySize_y > 3)
1621 newSize_x = 3 * mySize_y;
1622 newSize_y = mySize_y;
1624 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1629 newSize_y = 1/3 * mySize_x;
1630 newSize_x = mySize_x;
1632 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1636 vector picpos, numpos;
1638 iconalign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_iconalign"));
1641 if(iconalign == 1 || iconalign == 3) // right align
1644 picpos = newPos + eX * 2 * newSize_y;
1648 numpos = newPos + eX * newSize_y;
1654 if(iconalign == 0 || iconalign == 3) // left align
1656 numpos = newPos + eX * newSize_y;
1662 picpos = newPos + eX * 2 * newSize_y;
1666 drawfont = hud_bigfont;
1667 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, newSize_y, color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1668 drawfont = hud_font;
1669 drawpic_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1674 void HUD_Powerups(void) {
1675 float id = HUD_PANEL_POWERUPS;
1677 stat_items = getstati(STAT_ITEMS);
1681 if not(stat_items & IT_STRENGTH)
1682 if not(stat_items & IT_INVINCIBLE)
1685 if (getstati(STAT_HEALTH) <= 0)
1690 pos = HUD_Panel_GetPos(id);
1691 mySize = HUD_Panel_GetSize(id);
1693 HUD_Panel_DrawBg(id, pos, mySize, 0);
1695 padding = HUD_Panel_GetPadding(id);
1698 pos += '1 1 0' * padding;
1699 mySize -= '2 2 0' * padding;
1702 float strength_time, shield_time;
1704 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1705 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1713 vector barpos, barsize;
1717 string leftname, rightname;
1718 float leftcnt, rightcnt;
1719 float leftexact, rightexact;
1720 float leftalpha, rightalpha;
1721 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) {
1722 leftname = "strength";
1723 leftcnt = ceil(strength_time);
1724 leftexact = strength_time;
1726 rightname = "shield";
1727 rightcnt = ceil(shield_time);
1728 rightexact = shield_time;
1730 leftname = "shield";
1731 leftcnt = ceil(shield_time);
1732 leftexact = shield_time;
1734 rightname = "strength";
1735 rightcnt = ceil(strength_time);
1736 rightexact = strength_time;
1738 leftalpha = bound(0, leftexact, 1);
1739 rightalpha = bound(0, rightexact, 1);
1741 float baralign, iconalign;
1742 baralign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_baralign"));
1743 iconalign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_iconalign"));
1745 if (mySize_x/mySize_y > 4)
1749 if(baralign == 1 || baralign == 3) { // right align
1750 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1751 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1752 } else { // left align
1754 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1757 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1758 DrawNumIcon(id, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1');
1761 // 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));
1763 // drawpic_skin(picpos, leftname, eX * (1/6) * mySize_x + eY * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1768 if(baralign == 0 || baralign == 3) { // left align
1769 barpos = pos + eX * 0.5 * mySize_x;
1770 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1771 } else { // right align
1772 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1773 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1776 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1777 DrawNumIcon(id, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1');
1780 else if (mySize_x/mySize_y > 1.5)
1784 if(baralign == 1 || baralign == 3) { // right align
1785 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1786 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1787 } else { // left align
1789 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1792 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1793 DrawNumIcon(id, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1');
1798 if(baralign == 0 || baralign == 3) { // left align
1799 barpos = pos + eY * 0.5 * mySize_y;
1800 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1801 } else { // right align
1802 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1803 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1806 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1807 DrawNumIcon(id, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1');
1814 if(baralign == 1 || baralign == 3) { // down align
1815 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1816 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1817 } else { // up align
1819 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1822 if(iconalign == 1 || iconalign == 3) { // down align
1823 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
1824 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
1825 } else { // up align
1826 picpos = pos + eX * 0.05 * mySize_x;
1827 numpos = pos + eY * 0.4 * mySize_x;
1830 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1832 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));
1834 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1835 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, 0.25 * mySize_x, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1840 if(baralign == 0 || baralign == 3) { // up align
1841 barpos = pos + eX * 0.5 * mySize_x;
1842 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1843 } else { // down align
1844 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1845 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1848 if(iconalign == 0 || iconalign == 3) { // up align
1849 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1850 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1851 } else { // down align
1852 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
1853 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
1856 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1858 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));
1860 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1861 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, 0.25 * mySize_x, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1866 // Health/armor (#3)
1868 void HUD_HealthArmor(void)
1870 float id = HUD_PANEL_HEALTHARMOR;
1872 pos = HUD_Panel_GetPos(id);
1873 mySize = HUD_Panel_GetSize(id);
1875 HUD_Panel_DrawBg(id, pos, mySize, 0);
1877 padding = HUD_Panel_GetPadding(id);
1880 pos += '1 1 0' * padding;
1881 mySize -= '2 2 0' * padding;
1884 float armor, health;
1885 armor = getstati(STAT_ARMOR);
1886 health = getstati(STAT_HEALTH);
1889 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
1901 vector barpos, barsize;
1905 float baralign, iconalign;
1906 baralign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_baralign"));
1907 iconalign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_iconalign"));
1909 if(cvar("hud_healtharmor") == 2) // combined health and armor display
1912 v = healtharmor_maxdamage(health, armor, armorblockpercent);
1917 if(baralign == 1 || baralign == 3) { // right align
1918 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
1919 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
1920 } else { // left align
1922 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
1926 if(v_z) // NOT fully armored
1928 biggercount = "health";
1929 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("health"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1931 drawpic_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "armor", '0.5 0.5 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id) * armor / health, DRAWFLAG_NORMAL);
1935 biggercount = "armor";
1936 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("armor"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1938 drawpic_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "health", '0.5 0.5 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1940 DrawNumIcon(id, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200));
1945 if(baralign == 0 || baralign == 3) { // left align
1946 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
1947 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
1950 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
1952 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
1957 string leftname, rightname;
1958 float leftcnt, rightcnt;
1959 float leftactive, rightactive;
1960 float leftalpha, rightalpha;
1961 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) { // old style layout with armor left/top of health
1966 leftalpha = min((armor+10)/55, 1);
1968 rightname = "health";
1973 leftname = "health";
1978 rightname = "armor";
1982 rightalpha = min((armor+10)/55, 1);
1985 if (mySize_x/mySize_y > 4)
1989 if(baralign == 1 || baralign == 3) { // right align
1990 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
1991 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
1992 } else { // left align
1994 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
1997 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1998 DrawNumIcon(id, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2003 if(baralign == 0 || baralign == 3) { // left align
2004 barpos = pos + eX * 0.5 * mySize_x;
2005 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2006 } else { // right align
2007 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2008 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2011 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2012 DrawNumIcon(id, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(leftcnt, 200));
2017 if(baralign == 0 || baralign == 3) { // left align
2018 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2019 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2022 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2024 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2027 else if (mySize_x/mySize_y > 1.5)
2031 if(baralign == 1 || baralign == 3) { // right align
2032 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2033 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2034 } else { // left align
2036 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2039 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2040 DrawNumIcon(id, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2045 if(baralign == 0 || baralign == 3) { // left align
2046 barpos = pos + eY * 0.5 * mySize_y;
2047 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2048 } else { // right align
2049 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2050 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2053 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2054 DrawNumIcon(id, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(leftcnt, 200));
2059 if(baralign == 0 || baralign == 3) { // left align
2060 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2061 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2064 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2066 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2073 if(baralign == 1 || baralign == 3) { // down align
2074 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2075 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2076 } else { // up align
2078 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2081 if(iconalign == 1 || iconalign == 3) { // down align
2082 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2083 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2084 } else { // up align
2085 picpos = pos + eX * 0.05 * mySize_x;
2086 numpos = pos + eY * 0.4 * mySize_x;
2089 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2090 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2091 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, 0.25 * mySize_x, HUD_Get_Num_Color(leftcnt, 200), HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2096 if(baralign == 0 || baralign == 3) { // up align
2097 barpos = pos + eX * 0.5 * mySize_x;
2098 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2099 } else { // down align
2100 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2101 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2104 if(iconalign == 0 || iconalign == 3) { // up align
2105 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2106 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2107 } else { // down align
2108 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2109 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2112 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2113 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2114 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, 0.25 * mySize_x, HUD_Get_Num_Color(rightcnt, 200), HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2119 if(baralign == 0 || baralign == 3) { // left align
2121 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2123 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2124 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2126 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2133 // Notification area (#4)
2136 string Weapon_SuicideMessage(float deathtype)
2138 w_deathtype = deathtype;
2139 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2140 return w_deathtypestring;
2143 string Weapon_KillMessage(float deathtype)
2145 w_deathtype = deathtype;
2146 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2147 return w_deathtypestring;
2150 float killnotify_times[10];
2151 float killnotify_deathtype[10];
2152 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2153 string killnotify_attackers[10];
2154 string killnotify_victims[10];
2155 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2158 for (i = 9; i > 0; --i) {
2159 killnotify_times[i] = killnotify_times[i-1];
2160 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2161 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2162 if(killnotify_attackers[i])
2163 strunzone(killnotify_attackers[i]);
2164 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2165 if(killnotify_victims[i])
2166 strunzone(killnotify_victims[i]);
2167 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2169 killnotify_times[0] = time;
2170 killnotify_deathtype[0] = wpn;
2171 killnotify_actiontype[0] = actiontype;
2172 if(killnotify_attackers[0])
2173 strunzone(killnotify_attackers[0]);
2174 killnotify_attackers[0] = strzone(attacker);
2175 if(killnotify_victims[0])
2176 strunzone(killnotify_victims[0]);
2177 killnotify_victims[0] = strzone(victim);
2180 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2184 alsoprint = (cvar("hud_notify_print") || !HUD_Panel_CheckActive(4)); // print message to console if: notify panel disabled, or cvar to do so enabled
2186 if(msg == MSG_SUICIDE) {
2188 w = DEATH_WEAPONOF(type);
2190 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2192 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2193 } else if (type == DEATH_KILL) {
2194 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2196 print ("^1",s1, "^1 couldn't take it anymore\n");
2197 } else if (type == DEATH_ROT) {
2198 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2200 print ("^1",s1, "^1 died\n");
2201 } else if (type == DEATH_NOAMMO) {
2202 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2204 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2205 } else if (type == DEATH_CAMP) {
2206 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2208 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2209 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2210 HUD_KillNotify_Push(s1, "", 0, type);
2212 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2213 } else if (type == DEATH_CHEAT) {
2214 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2216 print ("^1",s1, "^1 unfairly eliminated themself\n");
2217 } else if (type == DEATH_FIRE) {
2218 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2220 print ("^1",s1, "^1 burned to death\n");
2221 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2222 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2224 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2227 if (stof(s2) > 2) // killcount > 2
2228 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2229 } else if(msg == MSG_KILL) {
2230 w = DEATH_WEAPONOF(type);
2232 HUD_KillNotify_Push(s2, s1, 1, w);
2234 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2236 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2237 HUD_KillNotify_Push(s1, s2, 1, type);
2240 if(cvar("cl_gentle")) {
2241 print ("^1", s1, "^1 took action against a team mate\n");
2243 print ("^1", s1, "^1 mows down a team mate\n");
2246 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2247 if(cvar("cl_gentle"))
2248 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2250 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2252 else if (stof(s2) > 2) {
2253 if(cvar("cl_gentle"))
2254 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2256 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2259 else if(type == KILL_FIRST_BLOOD)
2260 print("^1",s1, "^1 drew first blood", "\n");
2262 else if (type == DEATH_TELEFRAG)
2263 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2264 else if (type == DEATH_DROWN) {
2265 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2267 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2269 else if (type == DEATH_SLIME) {
2270 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2272 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2274 else if (type == DEATH_LAVA) {
2275 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2277 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2279 else if (type == DEATH_FALL) {
2280 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2282 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2284 else if (type == DEATH_SHOOTING_STAR) {
2285 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2287 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2289 else if (type == DEATH_SWAMP) {
2290 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2292 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2294 else if (type == DEATH_HURTTRIGGER)
2296 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2298 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2299 } else if(type == DEATH_SBCRUSH) {
2300 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2302 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2303 } else if(type == DEATH_SBMINIGUN) {
2304 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2306 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2307 } else if(type == DEATH_SBROCKET) {
2308 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2310 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2311 } else if(type == DEATH_SBBLOWUP) {
2312 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2314 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2315 } else if(type == DEATH_WAKIGUN) {
2316 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2318 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2319 } else if(type == DEATH_WAKIROCKET) {
2320 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2322 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2323 } else if(type == DEATH_WAKIBLOWUP) {
2324 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2326 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2327 } else if(type == DEATH_TURRET) {
2328 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2330 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2331 } else if(type == DEATH_TOUCHEXPLODE) {
2332 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2334 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2335 } else if(type == DEATH_CHEAT) {
2336 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2338 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2339 } else if (type == DEATH_FIRE) {
2340 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2342 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2343 } else if (type == DEATH_CUSTOM) {
2344 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2346 print ("^1",s1, "^1 ", s2, "\n");
2348 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2350 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2352 } else if(msg == MSG_SPREE) {
2353 if(type == KILL_END_SPREE) {
2354 if(cvar("cl_gentle"))
2355 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2357 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2358 } else if(type == KILL_SPREE) {
2359 if(cvar("cl_gentle"))
2360 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2362 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2363 } else if(type == KILL_SPREE_3) {
2364 if(cvar("cl_gentle"))
2365 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2367 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2368 } else if(type == KILL_SPREE_5) {
2369 if(cvar("cl_gentle"))
2370 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2372 print (s1,"^7 unleashes ^1RAGE\n");
2373 } else if(type == KILL_SPREE_10) {
2374 if(cvar("cl_gentle"))
2375 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2377 print (s1,"^7 starts the ^1MASSACRE!\n");
2378 } else if(type == KILL_SPREE_15) {
2379 if(cvar("cl_gentle"))
2380 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2382 print (s1,"^7 executes ^1MAYHEM!\n");
2383 } else if(type == KILL_SPREE_20) {
2384 if(cvar("cl_gentle"))
2385 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2387 print (s1,"^7 is a ^1BERSERKER!\n");
2388 } else if(type == KILL_SPREE_25) {
2389 if(cvar("cl_gentle"))
2390 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2392 print (s1,"^7 inflicts ^1CARNAGE!\n");
2393 } else if(type == KILL_SPREE_30) {
2394 if(cvar("cl_gentle"))
2395 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2397 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2399 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2400 if (type == DEATH_DROWN) {
2401 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2404 if(cvar("cl_gentle"))
2405 print ("^1",s1, "^1 was in the water for too long\n");
2407 print ("^1",s1, "^1 drowned\n");
2409 } else if (type == DEATH_SLIME) {
2410 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2412 print ("^1",s1, "^1 was slimed\n");
2413 } else if (type == DEATH_LAVA) {
2414 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2417 if(cvar("cl_gentle"))
2418 print ("^1",s1, "^1 found a hot place\n");
2420 print ("^1",s1, "^1 turned into hot slag\n");
2422 } else if (type == DEATH_FALL) {
2423 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2426 if(cvar("cl_gentle"))
2427 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2429 print ("^1",s1, "^1 hit the ground with a crunch\n");
2431 } else if (type == DEATH_SHOOTING_STAR) {
2432 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2434 print ("^1",s1, "^1 became a shooting star\n");
2435 } else if (type == DEATH_SWAMP) {
2436 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2439 if(cvar("cl_gentle"))
2440 print ("^1",s1, "^1 discovered a swamp\n");
2442 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2444 } else if(type == DEATH_TURRET) {
2445 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2447 print ("^1",s1, "^1 was mowed down by a turret \n");
2448 } else if (type == DEATH_CUSTOM) {
2449 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2451 print ("^1",s1, "^1 ", s2, "\n");
2452 } else if (type == DEATH_HURTTRIGGER) {
2453 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2455 print ("^1",s1, "^1 was in the wrong place\n");
2456 } else if(type == DEATH_TOUCHEXPLODE) {
2457 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2459 print ("^1",s1, "^1 died in an accident\n");
2460 } else if(type == DEATH_CHEAT) {
2461 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2463 print ("^1",s1, "^1 was unfairly eliminated\n");
2464 } else if(type == DEATH_FIRE) {
2465 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2468 if(cvar("cl_gentle"))
2469 print ("^1",s1, "^1 felt a little hot\n");
2471 print ("^1",s1, "^1 burnt to death\n");
2474 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2477 if(cvar("cl_gentle"))
2478 print ("^1",s1, "^1 needs a restart\n");
2480 print ("^1",s1, "^1 died\n");
2483 } else if(msg == MSG_KILL_ACTION_SPREE) {
2484 if(cvar("cl_gentle"))
2485 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2487 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2488 } else if(msg == MSG_INFO) {
2489 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2490 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2491 print(s1, "^7 got the ", s2, "\n");
2492 } else if(type == INFO_LOSTFLAG) {
2493 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2494 print(s1, "^7 lost the ", s2, "\n");
2495 } else if(type == INFO_PICKUPFLAG) {
2496 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2497 print(s1, "^7 picked up the ", s2, "\n");
2498 } else if(type == INFO_RETURNFLAG) {
2499 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2500 print(s1, "^7 returned the ", s2, "\n");
2505 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2507 void HUD_Centerprint(string s1, string s2, float type, float msg)
2509 if(msg == MSG_SUICIDE) {
2510 if (type == DEATH_TEAMCHANGE) {
2511 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2512 } else if (type == DEATH_AUTOTEAMCHANGE) {
2513 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2514 } else if (type == DEATH_CAMP) {
2515 if(cvar("cl_gentle"))
2516 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2518 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2519 } else if (type == DEATH_NOAMMO) {
2520 if(cvar("cl_gentle"))
2521 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2523 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2524 } else if (type == DEATH_ROT) {
2525 if(cvar("cl_gentle"))
2526 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2528 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2529 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2530 if(cvar("cl_gentle"))
2531 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2533 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2534 } else if (type == DEATH_QUIET) {
2536 } else if (type == DEATH_KILL) {
2537 if(cvar("cl_gentle"))
2538 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2540 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2542 } else if(msg == MSG_KILL) {
2543 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2544 if(cvar("cl_gentle")) {
2545 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2547 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2549 } else if (type == KILL_FIRST_BLOOD) {
2550 if(cvar("cl_gentle")) {
2551 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2553 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2555 } else if (type == KILL_FIRST_VICTIM) {
2556 if(cvar("cl_gentle")) {
2557 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2559 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2561 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2562 if(cvar("cl_gentle")) {
2563 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2565 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2567 } else if (type == KILL_TYPEFRAGGED) {
2568 if(cvar("cl_gentle")) {
2569 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2571 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2573 } else if (type == KILL_FRAG) {
2574 if(cvar("cl_gentle")) {
2575 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2577 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2579 } else if (type == KILL_FRAGGED) {
2580 if(cvar("cl_gentle")) {
2581 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2583 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2586 } else if(msg == MSG_KILL_ACTION) {
2587 // TODO: invent more centerprints here?
2588 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2592 void HUD_Notify (void)
2594 float id = HUD_PANEL_NOTIFY;
2596 pos = HUD_Panel_GetPos(id);
2597 mySize = HUD_Panel_GetSize(id);
2599 HUD_Panel_DrawBg(id, pos, mySize, 0);
2601 padding = HUD_Panel_GetPadding(id);
2604 pos += '1 1 0' * padding;
2605 mySize -= '2 2 0' * padding;
2608 float entries, height;
2609 entries = bound(1, floor(14 * mySize_y/mySize_x), 12);
2610 height = mySize_y/entries;
2611 entries -= 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2614 fontsize = '0.5 0.5 0' * height;
2618 when = cvar("hud_notify_time");
2620 fadetime = cvar("hud_notify_fadetime");
2624 vector pos_attacker, pos_victim;
2626 float width_attacker, width_victim;
2627 string attacker, victim;
2630 for(j = 0; j < entries; ++j)
2632 if(cvar("hud_notify_flip"))
2634 else // rather nasty hack for ordering items from the bottom up
2635 i = entries - j - 1;
2636 if(cvar("hud_notify_info_top"))
2637 i += 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2641 if(killnotify_times[j] + when > time)
2644 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2648 if(killnotify_times[j] + when > time)
2654 // TODO: maybe print in team colors?
2655 // TODO: maybe this could be cleaned up somehow...
2656 // TODO: less copypaste code below
2659 if(killnotify_actiontype[j] == 0 && !hud_configure)
2661 attacker = textShortenToWidth(killnotify_attackers[j], mySize_x - 2 * height, fontsize, stringwidth_colors);
2663 width_attacker = stringwidth(attacker, TRUE, fontsize);
2664 pos_attacker = pos + eX * 0.5 * (mySize_x - width_attacker + 2 * height) + eY * 0.5 * fontsize_y + eY * i * height;
2666 weap_pos = pos + eX * 0.5 * (mySize_x - width_attacker) - eX * height + eY * i * height;
2667 if(killnotify_deathtype[j] == DEATH_GENERIC)
2669 drawpic_skin(weap_pos, "notify_death", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2670 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2672 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2674 drawpic_skin(weap_pos, "notify_outofammo", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2675 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2677 else if(killnotify_deathtype[j] == DEATH_KILL)
2679 drawpic_skin(weap_pos, "notify_selfkill", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2680 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2682 else if(killnotify_deathtype[j] == DEATH_CAMP)
2684 drawpic_skin(weap_pos, "notify_camping", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2685 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2687 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2689 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2690 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2692 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2694 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2695 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2697 else if(killnotify_deathtype[j] == DEATH_DROWN)
2699 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2700 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2702 else if(killnotify_deathtype[j] == DEATH_SLIME)
2704 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2705 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2707 else if(killnotify_deathtype[j] == DEATH_LAVA)
2709 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2710 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2712 else if(killnotify_deathtype[j] == DEATH_FALL)
2714 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2715 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2717 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2719 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2720 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2722 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2724 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2725 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2727 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2729 if(killnotify_victims[j] == "^1RED^7 flag")
2733 drawpic_skin(weap_pos, strcat("flag_", s, "_carrying"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2734 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2736 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2738 if(killnotify_victims[j] == "^1RED^7 flag")
2742 drawpic_skin(weap_pos, strcat("flag_", s, "_taken"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2743 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2745 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2747 if(killnotify_victims[j] == "^1RED^7 flag")
2751 drawpic_skin(weap_pos, strcat("flag_", s, "_lost"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2752 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2755 // X [did action to] Y
2760 attacker = textShortenToWidth("Player1", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2761 victim = textShortenToWidth("Player2", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2762 a = bound(0, (when - j) / 4, 1);
2766 attacker = textShortenToWidth(killnotify_attackers[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2767 victim = textShortenToWidth(killnotify_victims[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2769 width_attacker = stringwidth(attacker, TRUE, fontsize);
2770 width_victim = stringwidth(victim, TRUE, fontsize);
2771 pos_attacker = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_attacker) + eY * 0.5 * fontsize_y + eY * i * height;
2772 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;
2773 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2775 if(hud_configure) // example actions for config mode
2777 drawpic_skin(weap_pos, strcat("weapon", "electro"), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2778 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2779 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2781 else if(WEP_VALID(killnotify_deathtype[j]))
2783 self = get_weaponinfo(killnotify_deathtype[j]);
2784 drawpic_skin(weap_pos, strcat("weapon", self.netname), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2785 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2786 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2788 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2790 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2791 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2792 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2794 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2796 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2797 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2798 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2800 else if(killnotify_deathtype[j] == DEATH_DROWN)
2802 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2803 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2804 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2806 else if(killnotify_deathtype[j] == DEATH_SLIME)
2808 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2809 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2810 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2812 else if(killnotify_deathtype[j] == DEATH_LAVA)
2814 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2815 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2816 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2818 else if(killnotify_deathtype[j] == DEATH_FALL)
2820 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2821 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2822 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2824 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2826 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2827 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2828 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2830 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2832 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2833 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2834 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2840 // TODO: separate panel for these?
2846 if(cvar("hud_notify_info_top"))
2849 o = pos + eY * mySize_y - eY * 2 * height;
2851 if(spectatee_status && !intermission)
2853 //drawfont = hud_bigfont;
2854 if(spectatee_status == -1)
2857 s = GetPlayerName(spectatee_status - 1);
2859 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
2860 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2861 //drawfont = hud_font;
2863 // spectator text in the upper right corner
2864 if(spectatee_status == -1)
2865 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
2867 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
2868 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2869 o += eY * fontsize_y;
2871 if(spectatee_status == -1)
2872 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
2874 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
2875 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2876 o += eY * fontsize_y;
2878 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
2879 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2880 o += eY * fontsize_y;
2882 if(gametype == GAME_ARENA)
2883 s = "^1Wait for your turn to join";
2884 else if(gametype == GAME_LMS)
2887 sk = playerslots[player_localentnum - 1];
2888 if(sk.(scores[ps_primary]) >= 666)
2889 s = "^1Match has already begun";
2890 else if(sk.(scores[ps_primary]) > 0)
2891 s = "^1You have no more lives left";
2893 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
2896 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
2897 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2898 o += eY * fontsize_y;
2900 //show restart countdown:
2901 if (time < getstatf(STAT_GAMESTARTTIME)) {
2903 //we need to ceil, otherwise the countdown would be off by .5 when using round()
2904 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
2905 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
2906 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2907 o += eY * fontsize_y;
2910 if(warmup_stage && !intermission)
2912 s = "^2Currently in ^1warmup^2 stage!";
2913 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2914 o += eY * fontsize_y;
2918 if(mod(time, 1) >= 0.5)
2923 if(ready_waiting && !intermission && !spectatee_status)
2925 if(ready_waiting_for_me)
2928 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
2930 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
2935 s = strcat("^2Waiting for others to ready up to end warmup...");
2937 s = strcat("^2Waiting for others to ready up...");
2939 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2940 o += eY * fontsize_y;
2942 else if(warmup_stage && !intermission && !spectatee_status)
2944 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
2945 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2946 o += eY * fontsize_y;
2949 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
2951 float ts_min, ts_max;
2952 tm = teams.sort_next;
2955 for(; tm.sort_next; tm = tm.sort_next)
2957 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
2959 if(!ts_min) ts_min = tm.team_size;
2960 else ts_min = min(ts_min, tm.team_size);
2961 if(!ts_max) ts_max = tm.team_size;
2962 else ts_max = max(ts_max, tm.team_size);
2964 if ((ts_max - ts_min) > 1)
2966 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
2967 tm = GetTeam(myteam, false);
2969 if (tm.team != COLOR_SPECTATOR)
2970 if (tm.team_size == ts_max)
2971 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
2973 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2974 o += eY * fontsize_y;
2980 s = "^7Press ^3ESC ^7to show HUD options.";
2981 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2982 o += eY * fontsize_y;
2983 s = "^3Doubleclick a panel for panel-specific options.";
2984 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2985 o += eY * fontsize_y;
2991 string seconds_tostring(float sec)
2994 minutes = floor(sec / 60);
2996 sec -= minutes * 60;
2999 s = ftos(100 + sec);
3001 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3004 void HUD_Timer(void)
3006 float id = HUD_PANEL_TIMER;
3008 pos = HUD_Panel_GetPos(id);
3009 mySize = HUD_Panel_GetSize(id);
3011 HUD_Panel_DrawBg(id, pos, mySize, 0);
3013 padding = HUD_Panel_GetPadding(id);
3016 pos += '1 1 0' * padding;
3017 mySize -= '2 2 0' * padding;
3021 float timelimit, elapsedTime, timeleft, minutesLeft;
3023 timelimit = getstatf(STAT_TIMELIMIT);
3025 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3026 timeleft = ceil(timeleft);
3028 minutesLeft = floor(timeleft / 60);
3031 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3032 timer_color = '1 1 1'; //white
3033 else if(minutesLeft >= 1)
3034 timer_color = '1 1 0'; //yellow
3036 timer_color = '1 0 0'; //red
3038 if (cvar("hud_timer_increment") || timelimit == 0 || warmup_stage) {
3039 if (time < getstatf(STAT_GAMESTARTTIME)) {
3040 //while restart is still active, show 00:00
3041 timer = seconds_tostring(0);
3043 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3044 timer = seconds_tostring(elapsedTime);
3047 timer = seconds_tostring(timeleft);
3050 drawfont = hud_bigfont;
3051 drawstring_aspect(pos, timer, mySize, mySize_y, timer_color, HUD_Panel_GetFgAlpha(HUD_PANEL_TIMER), DRAWFLAG_NORMAL);
3052 drawfont = hud_font;
3057 void HUD_Radar(void)
3059 float id = HUD_PANEL_RADAR;
3061 pos = HUD_Panel_GetPos(id);
3062 mySize = HUD_Panel_GetSize(id);
3064 HUD_Panel_DrawBg(id, pos, mySize, 0);
3066 padding = HUD_Panel_GetPadding(id);
3069 pos += '1 1 0' * padding;
3070 mySize -= '2 2 0' * padding;
3073 local float color1, color2; // color already declared as a global in hud.qc
3076 float scale2d, normalsize, bigsize;
3079 teamradar_origin2d = pos + 0.5 * mySize;
3080 teamradar_size2d = mySize;
3082 if(minimapname == "")
3085 teamradar_loadcvars();
3087 switch(hud_radar_zoommode)
3091 f = current_zoomfraction;
3094 f = 1 - current_zoomfraction;
3104 switch(hud_radar_rotation)
3107 teamradar_angle = view_angles_y - 90;
3110 teamradar_angle = 90 * hud_radar_rotation;
3114 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3115 teamradar_size2d = mySize;
3117 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3119 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3120 if(hud_radar_rotation == 0)
3122 // max-min distance must fit the radar in any rotation
3123 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3127 vector c0, c1, c2, c3, span;
3128 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3129 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3130 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3131 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3133 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3134 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3136 // max-min distance must fit the radar in x=x, y=y
3138 teamradar_size2d_x * scale2d / (1.05 * span_x),
3139 teamradar_size2d_y * scale2d / (1.05 * span_y)
3143 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3144 if(bigsize > normalsize)
3145 normalsize = bigsize;
3149 + (1 - f) * normalsize;
3150 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3151 f * (mi_min + mi_max) * 0.5
3152 + (1 - f) * view_origin);
3154 color1 = GetPlayerColor(player_localentnum-1);
3155 rgb = GetTeamRGB(color1);
3164 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3166 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3167 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3168 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3169 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, HUD_Panel_GetFgAlpha(id));
3170 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3172 color2 = GetPlayerColor(tm.sv_entnum);
3173 //if(color == COLOR_SPECTATOR || color == color2)
3174 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3176 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3178 drawresetcliparea();
3183 void HUD_Score(void)
3185 float id = HUD_PANEL_SCORE;
3187 pos = HUD_Panel_GetPos(id);
3188 mySize = HUD_Panel_GetSize(id);
3190 HUD_Panel_DrawBg(id, pos, mySize, 0);
3192 padding = HUD_Panel_GetPadding(id);
3195 pos += '1 1 0' * padding;
3196 mySize -= '2 2 0' * padding;
3199 float score, distribution, leader;
3201 vector distribution_color;
3203 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3205 // TODO... this (race part) still uses constant coordinates :/
3206 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3207 /*pl = players.sort_next;
3210 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3211 if(pl.scores[ps_primary] == 0)
3214 score = me.(scores[ps_primary]);
3216 float racemin, racesec, racemsec;
3217 float distsec, distmsec, minusplus;
3219 racemin = floor(score/(60 * TIME_FACTOR));
3220 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
3221 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
3223 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3224 // distribution display
3225 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3227 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
3228 distmsec = fabs(distribution);
3230 distsec = floor(fabs(distribution)/TIME_FACTOR);
3231 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
3232 if (distribution < 0)
3236 if (distribution <= 0) {
3237 distribution_color = eY;
3238 minusplus = 1; // minusplus 1: always prefix with minus sign
3241 distribution_color = eX;
3242 minusplus = 2; // minusplus 1: always prefix with plus sign
3244 //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);
3245 //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);
3246 drawpic_skin(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "num_dot", '16 16 0', distribution_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE);
3248 // race record display
3249 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
3250 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);
3252 //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);
3253 //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);
3254 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);
3256 //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);
3257 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);
3259 } else if (!teamplay) { // non-teamgames
3260 // me vector := [team/connected frags id]
3261 pl = players.sort_next;
3268 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3272 score = me.(scores[ps_primary]);
3276 if(distribution >= 5) {
3277 distribution_color = eY;
3279 } else if(distribution >= 0) {
3280 distribution_color = '1 1 1';
3282 } else if(distribution >= -5)
3283 distribution_color = '1 1 0';
3285 distribution_color = eX;
3287 score_len = strlen(ftos(score));
3289 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);
3291 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);
3292 drawfont = hud_bigfont;
3293 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, mySize_y, distribution_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3294 drawfont = hud_font;
3295 } else { // teamgames
3296 float max_fragcount;
3297 max_fragcount = -99;
3300 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3301 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !hud_configure)) // no players? don't display
3303 score = tm.(teamscores[ts_primary]);
3308 score_len = strlen(ftos(score));
3310 if (score > max_fragcount)
3311 max_fragcount = score;
3313 if(tm.team == myteam) {
3314 if (max_fragcount == score)
3317 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);
3318 drawfont = hud_bigfont;
3319 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);
3320 drawfont = hud_font;
3322 if (max_fragcount == score)
3325 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);
3326 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);
3335 void HUD_RaceTimer (void) {
3336 float id = HUD_PANEL_RACETIMER;
3338 pos = HUD_Panel_GetPos(id);
3339 mySize = HUD_Panel_GetSize(id);
3341 HUD_Panel_DrawBg(id, pos, mySize, 0);
3343 padding = HUD_Panel_GetPadding(id);
3346 pos += '1 1 0' * padding;
3347 mySize -= '2 2 0' * padding;
3350 // always force 2:1 aspect
3352 if(mySize_x/mySize_y > 2)
3354 newSize_x = 2 * mySize_y;
3355 newSize_y = mySize_y;
3357 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3361 newSize_y = 1/2 * mySize_x;
3362 newSize_x = mySize_x;
3364 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3368 drawfont = hud_bigfont;
3370 string s, forcetime;
3375 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);
3376 s = "^1Intermediate 1 (+15.42)";
3377 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);
3378 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3379 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);
3381 else if(race_checkpointtime)
3383 a = bound(0, 2 - (time - race_checkpointtime), 1);
3386 if(a > 0) // just hit a checkpoint?
3388 if(race_checkpoint != 254)
3390 if(race_time && race_previousbesttime)
3391 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3393 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3395 forcetime = TIME_ENCODED_TOSTRING(race_time);
3400 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3402 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3403 if(a > 0) // next one?
3405 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3410 if(s != "" && a > 0)
3412 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3413 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3414 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3417 if(race_penaltytime)
3419 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3422 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3423 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3424 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3425 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);
3431 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3432 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id), 0, a);
3433 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);
3438 if(race_laptime && race_checkpoint != 255)
3440 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3441 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3442 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);
3447 if(race_mycheckpointtime)
3449 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3450 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3451 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3452 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3453 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);
3455 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3457 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3458 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3459 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3460 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3461 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3464 if(race_penaltytime && !race_penaltyaccumulator)
3466 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3467 a = bound(0, (1 + t - time), 1);
3471 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3473 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3474 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3475 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3476 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);
3481 drawfont = hud_font;
3486 float vote_yescount;
3489 float vote_highlighted; // currently selected vote
3491 float vote_active; // is there an active vote?
3492 float vote_prev; // previous state of vote_active to check for a change
3494 float vote_change; // "time" when vote_active changed
3496 void HUD_VoteWindow(void)
3498 float id = HUD_PANEL_VOTE;
3500 pos = HUD_Panel_GetPos(id);
3501 mySize = HUD_Panel_GetSize(id);
3505 if(vote_active != vote_prev) {
3507 vote_prev = vote_active;
3510 if(vote_active || hud_configure)
3511 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3513 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3525 a = vote_alpha * bound(cvar_or("hud_vote_alreadyvoted_alpha", 0.75), 1 - vote_highlighted, 1);
3527 HUD_Panel_DrawBg(id, pos, mySize, a);
3529 padding = HUD_Panel_GetPadding(id);
3532 pos += '1 1 0' * padding;
3533 mySize -= '2 2 0' * padding;
3536 // always force 2:1 aspect
3538 if(mySize_x/mySize_y > 2)
3540 newSize_x = 2 * mySize_y;
3541 newSize_y = mySize_y;
3543 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3547 newSize_y = 1/2 * mySize_x;
3548 newSize_x = mySize_x;
3550 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3554 drawpic_skin(pos, "voteprogress_back", mySize, '1 1 1', a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3556 s = "A vote has been called for: ";
3557 drawstring_aspect(pos + eY * (1/12) * mySize_y, s, eX * mySize_x + eY * (3/12) * mySize_y, mySize_y*(3/12), '1 1 1', a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3558 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (3/12), stringwidth_colors); // TODO: broken?
3560 s = "Configure the HUD";
3561 drawstring_aspect(pos + eY * (4/12) * mySize_y, s, eX * mySize_x + eY * (2/12) * mySize_y, mySize_y*(2/12), '1 1 1', a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3563 // print the yes/no counts
3564 s = strcat("Yes: ", ftos(vote_yescount));
3565 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);
3566 s = strcat("No: ", ftos(vote_nocount));
3567 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);
3569 // draw the progress bars
3570 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3571 drawpic_skin(pos, "voteprogress_prog", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3573 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3574 drawpic_skin(pos, "voteprogress_prog", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3576 // draw the highlights
3577 if(vote_highlighted == 1) {
3578 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3579 drawpic_skin(pos, "voteprogress_voted", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3581 else if(vote_highlighted == 2) {
3582 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3583 drawpic_skin(pos, "voteprogress_voted", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3586 drawresetcliparea();
3589 vote_highlighted = 0;
3593 // Mod icons panel (#10)
3596 float mod_active; // is there any active mod icon?
3598 // CTF HUD modicon section
3599 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3600 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3601 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3603 void HUD_Mod_CTF_Reset(void)
3605 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3608 void HUD_Mod_CTF(vector pos, vector mySize)
3610 vector redflag_pos, blueflag_pos;
3612 float f; // every function should have that
3614 float redflag, blueflag; // current status
3615 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3618 stat_items = getstati(STAT_ITEMS);
3619 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3620 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3622 if(redflag || blueflag)
3633 // when status CHANGES, set old status into prevstatus and current status into status
3634 if (redflag != redflag_prevframe)
3636 redflag_statuschange_time = time;
3637 redflag_prevstatus = redflag_prevframe;
3638 redflag_prevframe = redflag;
3641 if (blueflag != blueflag_prevframe)
3643 blueflag_statuschange_time = time;
3644 blueflag_prevstatus = blueflag_prevframe;
3645 blueflag_prevframe = blueflag;
3648 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3649 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3651 float BLINK_FACTOR = 0.15;
3652 float BLINK_BASE = 0.85;
3654 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3656 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3658 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3660 string red_icon, red_icon_prevstatus;
3661 float red_alpha, red_alpha_prevstatus;
3662 red_alpha = red_alpha_prevstatus = 1;
3664 case 1: red_icon = "flag_red_taken"; break;
3665 case 2: red_icon = "flag_red_lost"; break;
3666 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3668 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3669 red_icon = "flag_red_shielded";
3671 red_icon = string_null;
3674 switch(redflag_prevstatus) {
3675 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3676 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3677 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3680 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3681 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3682 red_icon_prevstatus = "flag_red_shielded";
3684 red_icon_prevstatus = string_null;
3688 string blue_icon, blue_icon_prevstatus;
3689 float blue_alpha, blue_alpha_prevstatus;
3690 blue_alpha = blue_alpha_prevstatus = 1;
3692 case 1: blue_icon = "flag_blue_taken"; break;
3693 case 2: blue_icon = "flag_blue_lost"; break;
3694 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3696 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3697 blue_icon = "flag_blue_shielded";
3699 blue_icon = string_null;
3702 switch(blueflag_prevstatus) {
3703 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3704 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3705 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3708 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3709 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3710 blue_icon_prevstatus = "flag_blue_shielded";
3712 blue_icon_prevstatus = string_null;
3716 if(mySize_x > mySize_y) {
3717 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3719 blueflag_pos = pos + eX * 0.5 * mySize_x;
3722 redflag_pos = pos + eX * 0.5 * mySize_x;
3724 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3726 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3728 blueflag_pos = pos + eY * 0.5 * mySize_y;
3731 redflag_pos = pos + eY * 0.5 * mySize_y;
3733 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3736 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3737 if(red_icon_prevstatus && f < 1)
3738 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);
3740 drawpic_skin(redflag_pos, red_icon, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * red_alpha * f, DRAWFLAG_NORMAL);
3742 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3743 if(blue_icon_prevstatus && f < 1)
3744 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);
3746 drawpic_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * blue_alpha * f, DRAWFLAG_NORMAL);
3749 // Keyhunt HUD modicon section
3750 float kh_runheretime;
3752 void HUD_Mod_KH_Reset(void)
3757 void HUD_Mod_KH(vector pos, vector mySize)
3759 mod_active = 1; // keyhunt should never hide the mod icons panel
3763 vector p, pa, kh_size, kh_asize;
3765 kh_keys = getstati(STAT_KH_KEYS);
3768 if(mySize_x > mySize_y)
3770 p_y = pos_y + 0.25 * mySize_y;
3771 pa = p - eY * 0.25 * mySize_y;
3773 kh_size_x = mySize_x * 0.25;
3774 kh_size_y = 0.75 * mySize_y;
3775 kh_asize_x = mySize_x * 0.25;
3776 kh_asize_y = mySize_y * 0.25;
3780 p_y = pos_y + 0.125 * mySize_y;
3781 pa = p - eY * 0.125 * mySize_y;
3783 kh_size_x = mySize_x * 0.5;
3784 kh_size_y = 0.375 * mySize_y;
3785 kh_asize_x = mySize_x * 0.5;
3786 kh_asize_y = mySize_y * 0.125;
3793 for(i = 0; i < 4; ++i)
3795 key = floor(kh_keys / pow(32, i)) & 31;
3797 if(keyteam == 30 && keycount <= 4)
3799 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3803 // this yields 8 exactly if "RUN HERE" shows
3808 kh_runheretime = time;
3809 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3814 for(i = 0; i < 4; ++i)
3816 key = floor(kh_keys / pow(32, i)) & 31;
3829 default: // owned or dropped
3834 a = a * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3835 aa = aa * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3841 drawpic_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3844 drawpic_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3847 drawpic_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3850 drawpic_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3855 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3858 drawpic_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3861 drawpic_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3864 drawpic_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3867 drawpic_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3871 if(mySize_x > mySize_y)
3873 p_x += 0.25 * mySize_x;
3874 pa_x += 0.25 * mySize_x;
3880 p_y = pos_y + 0.625 * mySize_y;
3881 pa_y = pos_y + 0.5 * mySize_y;
3887 p_x += 0.5 * mySize_x;
3888 pa_x += 0.5 * mySize_x;
3894 // Nexball HUD mod icon
3895 void HUD_Mod_NexBall(vector pos, vector mySize)
3897 float stat_items, nb_pb_starttime, dt, p;
3899 stat_items = getstati(STAT_ITEMS);
3900 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3902 if (stat_items & IT_KEY1)
3907 //Manage the progress bar if any
3908 if (nb_pb_starttime > 0)
3910 dt = mod(time - nb_pb_starttime, nb_pb_period);
3911 // one period of positive triangle
3912 p = 2 * dt / nb_pb_period;
3919 if(mySize_x > mySize_y)
3921 barsize = eX * p * mySize_x + eY * mySize_y;
3926 barsize = eX * mySize_x + eY * p * mySize_y;
3929 HUD_Panel_DrawProgressBar(pos, vertical, barsize, HUD_Panel_GetProgressBarColor("nexball"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3932 if (stat_items & IT_KEY1)
3933 drawpic_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3936 // Race/CTS HUD mod icons
3937 float crecordtime_prev; // last remembered crecordtime
3938 float crecordtime_change_time; // time when crecordtime last changed
3939 float srecordtime_prev; // last remembered srecordtime
3940 float srecordtime_change_time; // time when srecordtime last changed
3942 float race_status_time;
3943 float race_status_prev;
3944 string race_status_name_prev;
3945 void HUD_Mod_Race(vector pos, vector mySize)
3947 mod_active = 1; // race should never hide the mod icons panel
3949 me = playerslots[player_localentnum - 1];
3951 float f; // yet another function has this
3952 score = me.(scores[ps_primary]);
3954 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3955 return; // no records in the actual race
3957 drawfont = hud_bigfont;
3959 // clientside personal record
3961 if(gametype == GAME_CTS)
3965 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3967 if(score && (score < t || !t)) {
3968 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3969 if(cvar("cl_autodemo_delete_keeprecords"))
3971 f = cvar("cl_autodemo_delete");
3973 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3977 if(t != crecordtime_prev) {
3978 crecordtime_prev = t;
3979 crecordtime_change_time = time;
3981 f = time - crecordtime_change_time;
3984 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);
3985 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);
3987 drawstring(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
3988 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);
3989 drawstring_expanding(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL, f);
3990 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);
3994 t = race_server_record;
3995 if(t != srecordtime_prev) {
3996 srecordtime_prev = t;
3997 srecordtime_change_time = time;
3999 f = time - srecordtime_change_time;
4002 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);
4003 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);
4005 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);
4006 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);
4007 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);
4008 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);
4011 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4012 race_status_time = time + 5;
4013 race_status_prev = race_status;
4014 if (race_status_name_prev)
4015 strunzone(race_status_name_prev);
4016 race_status_name_prev = strzone(race_status_name);
4019 pos_x += mySize_x/2;
4022 a = bound(0, race_status_time - time, 1);
4025 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4029 rank = race_CheckName(race_status_name);
4031 rankname = race_PlaceName(rank);
4034 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4036 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4038 if(race_status == 0)
4039 drawpic_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4040 else if(race_status == 1) {
4041 drawpic_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4042 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4043 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4044 } else if(race_status == 2) {
4045 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4046 drawpic_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4048 drawpic_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4049 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4050 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4051 } else if(race_status == 3) {
4052 drawpic_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4053 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4054 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4057 if (race_status_time - time <= 0) {
4058 race_status_prev = -1;
4060 if(race_status_name)
4061 strunzone(race_status_name);
4062 race_status_name = string_null;
4063 if(race_status_name_prev)
4064 strunzone(race_status_name_prev);
4065 race_status_name_prev = string_null;
4067 drawfont = hud_font;
4070 float mod_prev; // previous state of mod_active to check for a change
4072 float mod_change; // "time" when mod_active changed
4074 void HUD_ModIcons(void)
4076 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !hud_configure)
4079 float id = HUD_PANEL_MODICONS;
4081 pos = HUD_Panel_GetPos(id);
4082 mySize = HUD_Panel_GetSize(id);
4084 if(mod_active != mod_prev) {
4086 mod_prev = mod_active;
4089 if(mod_active || hud_configure)
4090 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4092 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4095 HUD_Panel_DrawBg(id, pos, mySize, mod_alpha);
4098 padding = HUD_Panel_GetPadding(id);
4101 pos += '1 1 0' * padding;
4102 mySize -= '2 2 0' * padding;
4105 // these MUST be ran in order to update mod_active
4106 if(gametype == GAME_KEYHUNT)
4107 HUD_Mod_KH(pos, mySize);
4108 else if(gametype == GAME_CTF || hud_configure)
4109 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4110 else if(gametype == GAME_NEXBALL)
4111 HUD_Mod_NexBall(pos, mySize);
4112 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4113 HUD_Mod_Race(pos, mySize);
4116 // Draw pressed keys (#11)
4118 void HUD_DrawPressedKeys(void)
4120 float id = HUD_PANEL_PRESSEDKEYS;
4122 pos = HUD_Panel_GetPos(id);
4123 mySize = HUD_Panel_GetSize(id);
4125 HUD_Panel_DrawBg(id, pos, mySize, 0);
4127 padding = HUD_Panel_GetPadding(id);
4130 pos += '1 1 0' * padding;
4131 mySize -= '2 2 0' * padding;
4135 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4138 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4139 drawpic_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4140 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);
4141 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);
4142 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);
4143 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);
4144 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);
4147 // Handle chat as a panel (#12)
4151 float id = HUD_PANEL_CHAT;
4153 pos = HUD_Panel_GetPos(id);
4154 mySize = HUD_Panel_GetSize(id);
4156 HUD_Panel_DrawBg(id, pos, mySize, 0);
4158 padding = HUD_Panel_GetPadding(id);
4161 pos += '1 1 0' * padding;
4162 mySize -= '2 2 0' * padding;
4165 cvar_set("con_chatrect", "1");
4167 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4168 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4170 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4171 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4176 chatsize = cvar("con_chatsize");
4177 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4179 for(i = 0; i < cvar("con_chat"); ++i)
4181 if(i == cvar("con_chat") - 1)
4182 a = HUD_Panel_GetFgAlpha(id);
4184 a = HUD_Panel_GetFgAlpha(id) * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4185 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);
4190 // Engine info panel (#13)
4197 float frametimeavg1; // 1 frame ago
4198 float frametimeavg2; // 2 frames ago
4199 void HUD_EngineInfo(void)
4201 float id = HUD_PANEL_ENGINEINFO;
4203 pos = HUD_Panel_GetPos(id);
4204 mySize = HUD_Panel_GetSize(id);
4206 HUD_Panel_DrawBg(id, pos, mySize, 0);
4208 padding = HUD_Panel_GetPadding(id);
4211 pos += '1 1 0' * padding;
4212 mySize -= '2 2 0' * padding;
4215 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4217 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4218 frametimeavg2 = frametimeavg1;
4219 frametimeavg1 = frametimeavg;
4222 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4223 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.
4225 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
4226 prevfps = (1/frametime);
4227 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"
4233 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4235 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4237 prevfps_time = time;
4242 color = HUD_Get_Num_Color (prevfps, 100);
4243 drawfont = hud_bigfont;
4244 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), mySize, mySize_y, color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4245 drawfont = hud_font;
4253 void HUD_ShowSpeed(void)
4256 float pos, conversion_factor;
4257 string speed, zspeed, unit;
4259 switch(cvar("cl_showspeed_unit"))
4264 conversion_factor = 1.0;
4268 conversion_factor = 1.0;
4272 conversion_factor = 0.0254;
4276 conversion_factor = 0.0254 * 3.6;
4280 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4284 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4288 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4290 numsize_x = numsize_y = cvar("cl_showspeed_size");
4291 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4293 drawfont = hud_bigfont;
4294 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4296 if (cvar("cl_showspeed_z") == 1) {
4297 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4298 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4301 drawfont = hud_font;
4304 vector acc_prevspeed;
4308 void HUD_ShowAcceleration(void)
4310 float acceleration, sz, scale, alpha, f;
4311 vector pos, top, rgb;
4312 top_x = vid_conwidth/2;
4315 f = time - acc_prevtime;
4316 if(cvar("cl_showacceleration_z"))
4317 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4319 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4320 acc_prevspeed = pmove_vel;
4321 acc_prevtime = time;
4323 f = bound(0, f * 10, 1);
4324 acc_avg = acc_avg * (1 - f) + acceleration * f;
4325 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4327 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4329 sz = cvar("cl_showacceleration_size");
4330 scale = cvar("cl_showacceleration_scale");
4331 alpha = cvar("cl_showacceleration_alpha");
4332 if (cvar("cl_showacceleration_color_custom"))
4333 rgb = stov(cvar_string("cl_showacceleration_color"));
4336 if (acceleration < 0) {
4337 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4338 } else if (acceleration > 0) {
4339 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4343 if (acceleration > 0)
4344 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4345 else if (acceleration < 0)
4346 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4349 void HUD_Reset (void)
4351 // reset gametype specific icons
4352 if(gametype == GAME_KEYHUNT)
4354 else if(gametype == GAME_CTF)
4355 HUD_Mod_CTF_Reset();
4358 void HUD_Main (void)
4360 if(disable_menu_alphacheck == 1)
4361 menu_fade_alpha = 1;
4363 menu_fade_alpha = (1 - cvar("_menu_alpha"));
4364 hud_fg_alpha = cvar("hud_fg_alpha");
4366 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4367 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4368 hud_color_bg_team = cvar("hud_color_bg_team");
4370 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4371 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4373 hud_configure = cvar("_hud_configure");
4377 // HUD configure visible grid
4378 if(hud_configure && cvar("hud_configure_grid") && cvar("hud_configure_grid_alpha"))
4382 for(i = 0; i < 1/bound(0.005, cvar("hud_configure_grid_x"), 0.2); ++i)
4384 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);
4387 for(i = 0; i < 1/bound(0.005, cvar("hud_configure_grid_y"), 0.2); ++i)
4389 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);
4393 if(cvar_string("hud_dock") != "" && cvar_string("hud_dock") != "0")
4394 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...
4396 if(HUD_Panel_CheckActive(HUD_PANEL_RADAR) || hud_configure)
4397 if(cvar_string("hud_radar") != "0" && (cvar("hud_radar") == 2 || teamplay))
4399 if(HUD_Panel_CheckActive(HUD_PANEL_WEAPONICONS) || hud_configure)
4401 if(HUD_Panel_CheckActive(HUD_PANEL_INVENTORY) || hud_configure)
4403 if(HUD_Panel_CheckActive(HUD_PANEL_POWERUPS) || hud_configure)
4405 if(HUD_Panel_CheckActive(HUD_PANEL_HEALTHARMOR) || hud_configure)
4407 if(HUD_Panel_CheckActive(HUD_PANEL_NOTIFY) || hud_configure)
4409 if(HUD_Panel_CheckActive(HUD_PANEL_TIMER) || hud_configure)
4411 if(HUD_Panel_CheckActive(HUD_PANEL_SCORE) || hud_configure)
4413 if(HUD_Panel_CheckActive(HUD_PANEL_RACETIMER) || hud_configure)
4414 if(gametype == GAME_RACE || gametype == GAME_CTS || hud_configure)
4416 if(HUD_Panel_CheckActive(HUD_PANEL_VOTE) || hud_configure)
4418 if(HUD_Panel_CheckActive(HUD_PANEL_MODICONS) || hud_configure)
4421 if(HUD_Panel_CheckActive(HUD_PANEL_PRESSEDKEYS) || hud_configure)
4422 if(spectatee_status > 0 || cvar("hud_pressedkeys") >= 2 || hud_configure)
4423 HUD_DrawPressedKeys();
4424 if(HUD_Panel_CheckActive(HUD_PANEL_CHAT) || hud_configure)
4427 cvar_set("con_chatrect", "0");
4428 if(HUD_Panel_CheckActive(HUD_PANEL_ENGINEINFO) || hud_configure)
4431 // TODO hud_'ify these
4432 if (cvar("cl_showspeed"))
4434 if (cvar("cl_showacceleration"))
4435 HUD_ShowAcceleration();
4437 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)
4438 localcmd("cmd selectteam auto; cmd join\n");
4440 if (!hud_configure) // hud config mode disabled, enable normal alpha stuff again
4441 disable_menu_alphacheck = 0;