7 // a border picture is a texture containing nine parts:
8 // 1/4 width: left part
9 // 1/2 width: middle part (stretched)
10 // 1/4 width: right part
12 // 1/4 height: top part
13 // 1/2 height: middle part (stretched)
14 // 1/4 height: bottom part
15 void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize)
17 if (theBorderSize_x <= 0 && theBorderSize_y <= 0) // no border
19 // draw only the central part
20 drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
27 //pic = draw_UseSkinFor(pic);
28 width = eX * theSize_x;
29 height = eY * theSize_y;
30 if(theSize_x <= theBorderSize_x * 2)
32 // not wide enough... draw just left and right then
33 bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
34 if(theSize_y <= theBorderSize_y * 2)
36 // not high enough... draw just corners
37 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
38 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
39 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
40 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
41 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
45 dY = theBorderSize_x * eY;
46 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
47 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
48 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
49 drawsubpic(theOrigin + width * 0.5 + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0' + eX - bW, '0 0.5 0' + bW, theColor, theAlpha, 0);
50 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
51 drawsubpic(theOrigin + width * 0.5 + height - dY, width * 0.5 + dY, pic, '0 0.75 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
56 if(theSize_y <= theBorderSize_y * 2)
58 // not high enough... draw just top and bottom then
59 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
60 dX = theBorderSize_x * eX;
61 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
62 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
63 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
64 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
65 drawsubpic(theOrigin + dX + height * 0.5, width - 2 * dX + height * 0.5, pic, '0.25 0 0' + eY - bH, '0.5 0 0' + bH, theColor, theAlpha, 0);
66 drawsubpic(theOrigin + width - dX + height * 0.5, dX + height * 0.5, pic, '0.75 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
70 dX = theBorderSize_x * eX;
71 dY = theBorderSize_x * eY;
72 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
73 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
74 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
75 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
76 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
77 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
78 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
79 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
80 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
85 // drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
86 void drawpic_aspect(vector pos, string pic, vector sz, vector color, float alpha, float drawflag) {
88 imgsize = drawgetimagesize(pic);
90 imgaspect = imgsize_x/imgsize_y;
97 if(aspect > imgaspect) {
98 sz_x = sz_y * imgaspect;
99 drawpic(pos + eX * (oldsz_x - sz_x) * 0.5, pic, sz, color, alpha, drawflag);
101 sz_y = sz_x / imgaspect;
102 drawpic(pos + eY * (oldsz_y - sz_y) * 0.5, pic, sz, color, alpha, drawflag);
106 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
107 // TODO: make a default skin, and fallback to these!
108 void drawpic_skin(vector pos, string pic, vector sz, vector color, float alpha, float drawflag) {
109 drawpic_aspect(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, color, alpha, drawflag);
113 void drawpic_skin_expanding(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
115 //drawpic_aspect_expanding(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
118 void drawpic_skin_expanding_two(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
120 //drawpic_aspect_expanding_two(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
123 // return HUD background color
124 vector HUD_GetBgColor()
128 GetTeamRGB(myteam) * hud_color_bg_team;
130 // allow custom HUD colors in non-teamgames
131 color_x = cvar("hud_color_bg_r");
132 color_y = cvar("hud_color_bg_g");
133 color_z = cvar("hud_color_bg_b");
138 // return accuracy text color
139 vector HUD_AccuracyColor(float accuracy)
142 float yellow_accuracy = cvar("hud_weaponicons_accuracy_yellow"); // value at which this function returns yellow
143 if(accuracy >= 100) {
147 else if(accuracy > yellow_accuracy) {
148 rgb_x = 1 - (accuracy-yellow_accuracy)/(100-yellow_accuracy); // red value between 1 -> 0
153 rgb_y = accuracy/yellow_accuracy; // green value between 0 -> 1
159 vector HUD_Get_Num_Color (float x, float maxvalue)
167 else if(x > maxvalue * 0.75) {
168 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
169 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
172 else if(x > maxvalue * 0.5) {
173 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
174 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
175 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
177 else if(x > maxvalue * 0.25) {
180 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
182 else if(x > maxvalue * 0.1) {
184 color_y = (x-20)*90/27/100; // green value between 0 -> 1
185 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
195 float stringwidth_colors(string s, vector theSize)
197 return stringwidth(s, TRUE, theSize);
200 float stringwidth_nocolors(string s, vector theSize)
202 return stringwidth(s, FALSE, theSize);
205 #define CENTERPRINT_MAX_LINES 30
206 string centerprint_messages[CENTERPRINT_MAX_LINES];
207 float centerprint_width[CENTERPRINT_MAX_LINES];
208 vector centerprint_start;
209 float centerprint_expire;
210 float centerprint_num;
211 float centerprint_offset_hint;
212 vector centerprint_fontsize;
214 void centerprint(string strMessage)
216 float i, j, n, hcount;
219 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
221 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
223 if(cvar("scr_centertime") <= 0)
229 // strip trailing newlines
230 j = strlen(strMessage) - 1;
231 while(substring(strMessage, j, 1) == "\n" && j >= 0)
233 strMessage = substring(strMessage, 0, j + 1);
238 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
240 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
242 strMessage = substring(strMessage, j, strlen(strMessage) - j);
243 centerprint_offset_hint = j;
248 // if we get here, we have a message. Initialize its height.
251 n = tokenizebyseparator(strMessage, "\n");
253 for(j = 0; j < n; ++j)
255 getWrappedLine_remaining = argv(j);
256 while(getWrappedLine_remaining)
258 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
259 if(centerprint_messages[i])
260 strunzone(centerprint_messages[i]);
261 centerprint_messages[i] = strzone(s);
262 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
265 // half height for empty lines looks better
271 if(i >= CENTERPRINT_MAX_LINES)
277 h = centerprint_fontsize_y*hcount;
279 havail = vid_conheight;
280 if(cvar("con_chatpos") < 0)
281 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
282 if(havail > vid_conheight - 70)
283 havail = vid_conheight - 70; // avoid overlapping HUD
285 centerprint_start_x = 0;
288 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
290 // here, the centerprint would cover the crosshair. REALLY BAD.
291 forbiddenmin = vid_conheight * 0.5 - h - 16;
292 forbiddenmax = vid_conheight * 0.5 + 16;
294 allowedmin = scoreboard_bottom;
295 allowedmax = havail - h;
296 preferred = (havail - h)/2;
299 // possible orderings (total: 4! / 4 = 6)
300 // allowedmin allowedmax forbiddenmin forbiddenmax
301 // forbiddenmin forbiddenmax allowedmin allowedmax
302 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
304 // forbidden doesn't matter in this case
305 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
307 // allowedmin forbiddenmin allowedmax forbiddenmax
308 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
310 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
312 // allowedmin forbiddenmin forbiddenmax allowedmax
313 else if(allowedmin < forbiddenmin)
315 // make sure the forbidden zone is not covered
316 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
317 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
319 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
321 // forbiddenmin allowedmin allowedmax forbiddenmax
322 else if(allowedmax < forbiddenmax)
324 // it's better to leave the allowed zone (overlap with scoreboard) than
325 // to cover the forbidden zone (crosshair)
326 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
327 centerprint_start_y = forbiddenmax;
329 centerprint_start_y = forbiddenmin;
331 // forbiddenmin allowedmin forbiddenmax allowedmax
334 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
337 centerprint_start_y =
340 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
348 centerprint_expire = time + cvar("scr_centertime");
351 void HUD_DrawCenterPrint (void)
358 //if(time > centerprint_expire)
361 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
362 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
363 //sz = 1.2 / (a + 0.2);
368 pos = centerprint_start;
369 for (i=0; i<centerprint_num; i = i + 1)
371 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
372 ts = centerprint_messages[i];
375 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
376 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
377 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
378 pos_y = pos_y + centerprint_fontsize_y;
381 // half height for empty lines looks better
382 pos_y = pos_y + centerprint_fontsize_y * 0.5;
386 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
388 position_x -= 2 / 3 * strlen(text) * scale_x;
389 drawstring(position, text, scale, rgb, alpha, flag);
392 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
394 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
395 drawstring(position, text, scale, rgb, alpha, flag);
398 // return the string of the given race place
399 string race_PlaceName(float pos) {
407 return strcat(ftos(pos), "th");
410 // return the string of the onscreen race timer
411 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
419 if(histime == 0) // goal hit
423 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
433 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
439 lapstr = strcat(" (-", ftos(lapdelta), "L)");
442 else if(lapdelta < 0)
444 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
448 else if(histime > 0) // anticipation
450 if(mytime >= histime)
451 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
453 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
460 cpname = "Start line";
462 cpname = "Finish line";
464 cpname = strcat("Intermediate ", ftos(cp));
466 cpname = "Finish line";
469 return strcat(col, cpname);
470 else if(hisname == "")
471 return strcat(col, cpname, " (", timestr, ")");
473 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
476 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
477 float race_CheckName(string net_name) {
479 for (i=RANKINGS_CNT-1;i>=0;--i)
480 if(grecordholder[i] == net_name)
492 void HUD_Panel_ExportCfg(string cfgname)
495 fh = fopen(strcat("hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg"), FILE_WRITE);
498 fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
499 fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
500 fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
501 fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
502 fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
503 fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
504 fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
505 fputs(fh, strcat("seta hud_fg_alpha \"", cvar_string("hud_fg_alpha"), "\"", "\n"));
508 fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
509 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
510 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
511 fputs(fh, strcat("seta hud_dock_alpha \"", ftos(cvar("hud_dock_alpha")), "\"", "\n"));
514 fputs(fh, strcat("seta hud_progressbar_alpha ", ftos(cvar("hud_progressbar_alpha")), "\n"));
515 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
516 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
517 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
518 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
519 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
520 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
523 // common cvars for all panels
525 for (i = 0; i < HUD_PANEL_NUM; ++i)
527 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), " ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i)))), "\n"));
528 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_pos \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_pos")), "\"", "\n"));
529 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_size \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_size")), "\"", "\n"));
530 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg")), "\"", "\n"));
531 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color")), "\"", "\n"));
532 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color_team \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color_team")), "\"", "\n"));
533 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_alpha \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_alpha")), "\"", "\n"));
534 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_border \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_border")), "\"", "\n"));
535 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_padding \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_padding")), "\"", "\n"));
537 case HUD_PANEL_WEAPONICONS:
538 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_accuracy_yellow ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_accuracy_yellow"))), "\n"));
540 case HUD_PANEL_INVENTORY:
541 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_onlycurrent ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_onlycurrent"))), "\n"));
542 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_iconalign ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
544 case HUD_PANEL_POWERUPS:
545 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
546 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_iconalign ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
547 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_baralign ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
549 case HUD_PANEL_HEALTHARMOR:
550 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
551 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_iconalign ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
552 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_baralign ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_mirror"))), "\n"));
554 case HUD_PANEL_NOTIFY:
555 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_flip ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_flip"))), "\n"));
556 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_info_top ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_info_top"))), "\n"));
558 case HUD_PANEL_RADAR:
559 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_foreground_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_foreground_alpha"))), "\n"));
561 fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_alreadyvoted_alpha"))), "\n"));
567 print("^2Successfully exported to hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
572 // return active status of panel
573 float HUD_Panel_CheckActive(float id)
575 if (cvar_or(strcat("hud_", HUD_Panel_GetName(id)), 1))
580 // return size of given panel
581 vector HUD_Panel_GetSize(float id)
584 mySize = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_size")));
586 mySize = eX * mySize_x * vid_conwidth + eY * mySize_y * vid_conheight;
588 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
590 vector menu_enable_maxsize, menu_enable_size;
591 menu_enable_maxsize = '0 0 0'; // shut up FTEQCC
592 menu_enable_maxsize_x = 0.3 * vid_conwidth;
593 menu_enable_maxsize_y = 0.18 * vid_conheight;
594 if(mySize_x > mySize_y)
596 if(mySize_y > menu_enable_maxsize_y)
598 menu_enable_size_y = menu_enable_maxsize_y;
599 menu_enable_size_x = mySize_x * (menu_enable_maxsize_y/mySize_y);
600 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
605 if(mySize_x > menu_enable_maxsize_x)
607 menu_enable_size_x = menu_enable_maxsize_x;
608 menu_enable_size_y = mySize_y * (menu_enable_maxsize_x/mySize_x);
609 mySize = (1 - cvar("_menu_alpha")) * mySize + (cvar("_menu_alpha")) * menu_enable_size;
616 // return pos of given panel
617 vector HUD_Panel_GetPos(float id)
620 pos = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_pos")));
622 pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
624 if(disable_menu_alphacheck == 2 && id == highlightedPanel)
626 vector mySize, menu_enable_panelpos;
627 mySize = HUD_Panel_GetSize(id);
628 if(mySize_x > mySize_y)
629 menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * mySize_x + eY * 0.82 * vid_conheight;
631 menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * mySize_y + eX * 0.7 * vid_conwidth;
632 pos = (1 - cvar("_menu_alpha")) * pos + (cvar("_menu_alpha")) * menu_enable_panelpos;
637 float HUD_Panel_GetBorder(float id)
640 border = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_border"));
642 border = cvar_string("hud_bg_border");
646 vector HUD_Panel_GetColor(float id)
652 // fetch per-panel color
653 if(teamplay && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")) != "") {
654 f = stof(getplayerkey(self.sv_entnum, "colors"));
655 color = vtos(colormapPaletteColor(mod(f, 16), 1) * cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")));
658 color = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color"));
659 color_vec = stov(color);
661 if(color == "") { // fetch default color
662 color = cvar_string("hud_bg_color");
663 color_vec = stov(color);
664 if(teamplay && cvar(strcat("hud_bg_color_team"))) {
665 f = stof(getplayerkey(self.sv_entnum, "colors"));
666 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_bg_color_team");
668 else if(color == "shirt") {
669 f = stof(getplayerkey(self.sv_entnum, "colors"));
670 color_vec = colormapPaletteColor(floor(f / 16), 0);
672 else if(color == "pants") {
673 f = stof(getplayerkey(self.sv_entnum, "colors"));
674 color_vec = colormapPaletteColor(mod(f, 16), 1);
677 else if(color == "shirt") {
678 f = stof(getplayerkey(self.sv_entnum, "colors"));
679 color_vec = colormapPaletteColor(floor(f / 16), 0);
681 else if(color == "pants") {
682 f = stof(getplayerkey(self.sv_entnum, "colors"));
683 color_vec = colormapPaletteColor(mod(f, 16), 1);
688 vector HUD_Panel_Dock_GetColor(void)
693 color = cvar_string("hud_dock_color");
694 color_vec = stov(color);
695 if(teamplay && cvar(strcat("hud_dock_color_team"))) {
696 f = stof(getplayerkey(self.sv_entnum, "colors"));
697 color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_dock_color_team");
699 else if(color == "shirt") {
700 f = stof(getplayerkey(self.sv_entnum, "colors"));
701 color_vec = colormapPaletteColor(floor(f / 16), 0);
703 else if(color == "pants") {
704 f = stof(getplayerkey(self.sv_entnum, "colors"));
705 color_vec = colormapPaletteColor(mod(f, 16), 1);
710 float HUD_Panel_GetBgAlpha(float id)
713 alpha = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_alpha"));
715 alpha = cvar_string("hud_bg_alpha");
717 if(hud_configure && disable_menu_alphacheck == 2 && highlightedPanel == id) // do not set a minalpha cap when showing the config dialog for this panel
718 alpha = ftos((1 - cvar("_menu_alpha")) * max(cvar("hud_configure_bg_minalpha"), stof(alpha)) + (cvar("_menu_alpha")) * stof(alpha));
719 else if(hud_configure)
720 alpha = ftos(max(cvar("hud_configure_bg_minalpha"), stof(alpha)));
722 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
725 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
728 return stof(alpha) * menu_fade_alpha;
731 float HUD_Panel_GetFgAlpha(float id)
734 alpha = hud_fg_alpha;
736 if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
739 if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
742 return alpha * menu_fade_alpha;
745 float HUD_Panel_GetPadding(float id)
748 padding = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
750 padding = cvar_string("hud_bg_padding");
753 mySize = HUD_Panel_GetSize(id);
755 smallestsize = min(mySize_x, mySize_y);
756 return min(smallestsize/2 - 5, stof(padding));
759 // draw the background/borders
760 void HUD_Panel_DrawBg(float id, vector pos, vector mySize, float alpha)
762 if(!hud_configure && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg")) == "0")
766 bg = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg"));
768 bg = cvar_string("hud_bg");
770 if(bg == "0" && hud_configure) {
771 bg = "border"; // we probably want to see a background in config mode at all times...
777 border = HUD_Panel_GetBorder(id);
780 color = HUD_Panel_GetColor(id);
783 alpha = HUD_Panel_GetBgAlpha(id) * alpha; // allow panels to fade in/out by passing an alpha value
785 alpha = HUD_Panel_GetBgAlpha(id);
787 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));
791 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
797 pic = strcat("gfx/hud/", cvar_string("hud_skin"), "/");
799 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);
800 if(mySize_y/mySize_x > 2)
801 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);
802 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);
804 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);
805 if(mySize_x/mySize_y > 2)
806 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);
807 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);
811 vector HUD_Panel_GetProgressBarColor(string item)
813 return stov(cvar_string(strcat("hud_progressbar_", item, "_color")));
816 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
817 vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
828 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
829 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
831 for (i = 0; i < HUD_PANEL_NUM; ++i) {
832 if(i == id || !HUD_Panel_CheckActive(i))
835 targPos = HUD_Panel_GetPos(i) - '1 1 0' * HUD_Panel_GetBorder(id);
836 targSize = HUD_Panel_GetSize(i) + '2 2 0' * HUD_Panel_GetBorder(id);
838 if(myPos_y + mySize_y < targPos_y)
840 if(myPos_y > targPos_y + targSize_y)
843 if(myPos_x + mySize_x < targPos_x)
845 if(myPos_x > targPos_x + targSize_x)
848 // OK, there IS a collision.
850 myCenter_x = myPos_x + 0.5 * mySize_x;
851 myCenter_y = myPos_y + 0.5 * mySize_y;
853 targCenter_x = targPos_x + 0.5 * targSize_x;
854 targCenter_y = targPos_y + 0.5 * targSize_y;
856 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
858 if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
859 myTarget_x = targPos_x - mySize_x;
860 else // push it upwards
861 myTarget_y = targPos_y - mySize_y;
863 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
865 if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
866 myTarget_x = targPos_x + targSize_x;
867 else // push it upwards
868 myTarget_y = targPos_y - mySize_y;
870 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
872 if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
873 myTarget_x = targPos_x - mySize_x;
874 else // push it downwards
875 myTarget_y = targPos_y + targSize_y;
877 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
879 if(targPos_x + targSize_x - myPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
880 myTarget_x = targPos_x + targSize_x;
881 else // push it downwards
882 myTarget_y = targPos_y + targSize_y;
889 void HUD_Panel_SetPos(float id, vector pos)
892 oldPos = HUD_Panel_GetPos(id);
895 mySize = HUD_Panel_GetSize(id);
897 if(hud_configure_checkcollisions)
898 pos = HUD_Panel_CheckMove(id, pos, mySize);
900 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
901 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
903 if(cvar("hud_configure_grid"))
905 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;
906 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;
910 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
912 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
915 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
916 vector HUD_Panel_CheckResize(float id, vector mySize, vector resizeorigin) {
926 ratio = mySize_x/mySize_y;
928 for (i = 0; i < HUD_PANEL_NUM; ++i) {
929 if(i == id || !HUD_Panel_CheckActive(i))
932 targBorder = HUD_Panel_GetBorder(i);
933 targPos = HUD_Panel_GetPos(i) - '1 1 0' * targBorder;
934 targSize = HUD_Panel_GetSize(i) + '2 2 0' * targBorder;
935 targEndPos = targPos + targSize;
937 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
938 if(resizeorigin_x > targPos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > targPos_y && resizeorigin_y < targEndPos_y)
941 if (resizeCorner == 1)
943 // check if this panel is on our way
944 if (resizeorigin_x <= targPos_x)
946 if (resizeorigin_y <= targPos_y)
948 if (targEndPos_x <= resizeorigin_x - mySize_x)
950 if (targEndPos_y <= resizeorigin_y - mySize_y)
953 // there is a collision:
954 // detect which side of the panel we are facing is actually limiting the resizing
955 // (which side the resize direction finds for first) and reduce the size up to there
957 // dist is the distance between resizeorigin and the "analogous" point of the panel
958 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
959 dist_x = resizeorigin_x - targEndPos_x;
960 dist_y = resizeorigin_y - targEndPos_y;
961 if (dist_y < 0 || dist_x / dist_y > ratio)
962 mySize_x = min(mySize_x, dist_x);
964 mySize_y = min(mySize_y, dist_y);
966 else if (resizeCorner == 2)
968 if (resizeorigin_x >= targEndPos_x)
970 if (resizeorigin_y <= targPos_y)
972 if (targPos_x >= resizeorigin_x + mySize_x)
974 if (targEndPos_y <= resizeorigin_y - mySize_y)
977 dist_x = targPos_x - resizeorigin_x;
978 dist_y = resizeorigin_y - targEndPos_y;
979 if (dist_y < 0 || dist_x / dist_y > ratio)
980 mySize_x = min(mySize_x, dist_x);
982 mySize_y = min(mySize_y, dist_y);
984 else if (resizeCorner == 3)
986 if (resizeorigin_x <= targPos_x)
988 if (resizeorigin_y >= targEndPos_y)
990 if (targEndPos_x <= resizeorigin_x - mySize_x)
992 if (targPos_y >= resizeorigin_y + mySize_y)
995 dist_x = resizeorigin_x - targEndPos_x;
996 dist_y = targPos_y - resizeorigin_y;
997 if (dist_y < 0 || dist_x / dist_y > ratio)
998 mySize_x = min(mySize_x, dist_x);
1000 mySize_y = min(mySize_y, dist_y);
1002 else if (resizeCorner == 4)
1004 if (resizeorigin_x >= targEndPos_x)
1006 if (resizeorigin_y >= targEndPos_y)
1008 if (targPos_x >= resizeorigin_x + mySize_x)
1010 if (targPos_y >= resizeorigin_y + mySize_y)
1013 dist_x = targPos_x - resizeorigin_x;
1014 dist_y = targPos_y - resizeorigin_y;
1015 if (dist_y < 0 || dist_x / dist_y > ratio)
1016 mySize_x = min(mySize_x, dist_x);
1018 mySize_y = min(mySize_y, dist_y);
1020 if(cvar("hud_configure_checkcollisions_debug"))
1021 drawfill(targPos + '1 1 0' * targBorder, targSize - '2 2 0' * targBorder, '1 1 0', .3, DRAWFLAG_NORMAL);
1027 void HUD_Panel_SetPosSize(float id, vector mySize)
1029 vector resizeorigin;
1030 resizeorigin = panel_click_resizeorigin;
1033 // minimum panel size cap
1034 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1035 mySize_y = max(0.025 * vid_conheight, mySize_y);
1037 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.
1039 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
1040 mySize_y = max(2 * cvar("con_chatsize") + 2 * HUD_Panel_GetPadding(id), mySize_y);
1043 // collision testing|
1044 // -----------------+
1046 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
1047 if(resizeCorner == 1) {
1048 myPos_x = resizeorigin_x - mySize_x;
1049 myPos_y = resizeorigin_y - mySize_y;
1050 } else if(resizeCorner == 2) {
1051 myPos_x = resizeorigin_x;
1052 myPos_y = resizeorigin_y - mySize_y;
1053 } else if(resizeCorner == 3) {
1054 myPos_x = resizeorigin_x - mySize_x;
1055 myPos_y = resizeorigin_y;
1056 } else { // resizeCorner == 4
1057 myPos_x = resizeorigin_x;
1058 myPos_y = resizeorigin_y;
1061 // left/top screen edges
1063 mySize_x = mySize_x + myPos_x;
1065 mySize_y = mySize_y + myPos_y;
1067 // bottom/right screen edges
1068 if(myPos_x + mySize_x > vid_conwidth)
1069 mySize_x = vid_conwidth - myPos_x;
1070 if(myPos_y + mySize_y > vid_conheight)
1071 mySize_y = vid_conheight - myPos_y;
1073 if(cvar("hud_configure_checkcollisions_debug"))
1074 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
1076 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
1077 if(cvar("hud_configure_grid"))
1079 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;
1080 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;
1083 if(hud_configure_checkcollisions)
1084 mySize = HUD_Panel_CheckResize(id, mySize, resizeorigin);
1086 // minimum panel size cap, do this once more so we NEVER EVER EVER have a panel smaller than this, JUST IN CASE above code still makes the panel eg negative (impossible to resize back without changing cvars manually then)
1087 mySize_x = max(0.025 * vid_conwidth, mySize_x);
1088 mySize_y = max(0.025 * vid_conheight, mySize_y);
1090 // do another pos check, as size might have changed by now
1091 if(resizeCorner == 1) {
1092 myPos_x = resizeorigin_x - mySize_x;
1093 myPos_y = resizeorigin_y - mySize_y;
1094 } else if(resizeCorner == 2) {
1095 myPos_x = resizeorigin_x;
1096 myPos_y = resizeorigin_y - mySize_y;
1097 } else if(resizeCorner == 3) {
1098 myPos_x = resizeorigin_x - mySize_x;
1099 myPos_y = resizeorigin_y;
1100 } else { // resizeCorner == 4
1101 myPos_x = resizeorigin_x;
1102 myPos_y = resizeorigin_y;
1105 if(cvar("hud_configure_checkcollisions_debug"))
1106 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
1109 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
1110 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_size"), s);
1112 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
1113 cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
1116 float pressed_key_time;
1117 void HUD_Panel_Arrow_Action(float nPrimary)
1119 if (highlightedPanel_prev == -1)
1122 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
1125 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
1126 step = vid_conheight;
1128 step = vid_conwidth;
1129 if (hudShiftState & S_SHIFT)
1130 step = (step / 256); // more precision
1132 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
1134 highlightedPanel = highlightedPanel_prev;
1136 if (hudShiftState & S_ALT) // resize
1138 highlightedAction = 1;
1139 if(nPrimary == K_UPARROW)
1141 else if(nPrimary == K_RIGHTARROW)
1143 else if(nPrimary == K_LEFTARROW)
1145 else // if(nPrimary == K_DOWNARROW)
1148 // ctrl+arrow reduces the size, instead of increasing it
1149 // Note that ctrl disables collisions check too, but it's fine
1150 // since we don't collide with anything reducing the size
1151 if (hudShiftState & S_CTRL) {
1153 resizeCorner = 5 - resizeCorner;
1157 mySize = HUD_Panel_GetSize(highlightedPanel);
1158 panel_click_resizeorigin = HUD_Panel_GetPos(highlightedPanel);
1159 if(resizeCorner == 1) {
1160 panel_click_resizeorigin += mySize;
1162 } else if(resizeCorner == 2) {
1163 panel_click_resizeorigin_y += mySize_y;
1165 } else if(resizeCorner == 3) {
1166 panel_click_resizeorigin_x += mySize_x;
1168 } else { // resizeCorner == 4
1171 HUD_Panel_SetPosSize(highlightedPanel, mySize);
1175 highlightedAction = 2;
1177 pos = HUD_Panel_GetPos(highlightedPanel);
1178 if(nPrimary == K_UPARROW)
1180 else if(nPrimary == K_DOWNARROW)
1182 else if(nPrimary == K_LEFTARROW)
1184 else // if(nPrimary == K_RIGHTARROW)
1187 HUD_Panel_SetPos(highlightedPanel, pos);
1192 float prevMouseClicked; // previous state
1193 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
1194 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
1197 float menu_enabled_time;
1198 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1203 // allow console bind to work
1206 con_keys = findkeysforcommand("toggleconsole");
1207 keys = tokenize(con_keys);
1209 float hit_con_bind, i;
1210 for (i = 0; i < keys; ++i)
1212 if(nPrimary == stof(argv(i)))
1216 if(bInputType == 0) {
1217 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1218 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1219 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1221 else if(bInputType == 1) {
1222 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1223 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1224 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1227 if(nPrimary == K_MOUSE1)
1229 if(bInputType == 0) { // key pressed
1233 else if(bInputType == 1) {// key released
1238 else if(nPrimary == K_ESCAPE)
1240 if (bInputType == 1)
1242 disable_menu_alphacheck = 1;
1244 menu_enabled_time = time;
1245 localcmd("menu_showhudexit\n");
1247 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1249 if (bInputType == 1)
1251 pressed_key_time = 0;
1254 else if (pressed_key_time == 0)
1255 pressed_key_time = time;
1257 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1259 else if(hit_con_bind)
1262 return true; // Suppress ALL other input
1265 void HUD_Panel_Highlight()
1271 for(i = 0; i < HUD_PANEL_NUM; ++i)
1273 panelPos = HUD_Panel_GetPos(i);
1274 panelSize = HUD_Panel_GetSize(i);
1275 border = HUD_Panel_GetBorder(i);
1278 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1280 highlightedPanel = i;
1281 highlightedAction = 1;
1282 panel_click_distance = mousepos - panelPos;
1285 // resize from topleft border
1286 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)
1288 highlightedPanel = i;
1289 highlightedAction = 2;
1291 panel_click_distance = mousepos - panelPos;
1292 panel_click_resizeorigin = panelPos + panelSize;
1295 // resize from topright border
1296 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)
1298 highlightedPanel = i;
1299 highlightedAction = 2;
1301 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1302 panel_click_distance_y = mousepos_y - panelPos_y;
1303 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1306 // resize from bottomleft border
1307 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)
1309 highlightedPanel = i;
1310 highlightedAction = 2;
1312 panel_click_distance_x = mousepos_x - panelPos_x;
1313 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1314 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1317 // resize from bottomright border
1318 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)
1320 highlightedPanel = i;
1321 highlightedAction = 2;
1323 panel_click_distance = panelSize - mousepos + panelPos;
1324 panel_click_resizeorigin = panelPos;
1330 void HUD_Panel_Mouse()
1332 // 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
1333 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1334 disable_menu_alphacheck = 0;
1335 if (cvar("_menu_alpha") == 0 && time - menu_enabled_time > 0.5)
1339 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1340 print("Highlighted: ", ftos(highlightedPanel), "\n");
1341 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1344 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1345 highlightedPanel_prev = highlightedPanel;
1346 highlightedPanel = -1;
1347 highlightedAction = 0;
1350 mousepos = mousepos + getmousepos();
1352 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1353 mousepos_y = bound(0, mousepos_y, vid_conheight);
1355 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1359 if(prevMouseClicked == 0)
1360 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1362 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
1364 if(highlightedAction == 1)
1365 HUD_Panel_SetPos(highlightedPanel, mousepos - panel_click_distance);
1366 else if(highlightedAction == 2)
1369 if(resizeCorner == 1) {
1370 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1371 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1372 } else if(resizeCorner == 2) {
1373 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1374 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1375 } else if(resizeCorner == 3) {
1376 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1377 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1378 } else { // resizeCorner == 4
1379 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1380 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1382 HUD_Panel_SetPosSize(highlightedPanel, mySize);
1385 // doubleclick check
1386 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1388 mouseClicked = 0; // to prevent spam, I guess.
1389 disable_menu_alphacheck = 2;
1391 menu_enabled_time = time;
1392 localcmd("menu_showhudoptions ", ftos(highlightedPanel), "\n");
1395 if(prevMouseClicked == 0)
1397 prevMouseClickedTime = time;
1398 prevMouseClickedPos = mousepos;
1401 prevMouseClicked = mouseClicked;
1404 // Weapon icons (#0)
1406 float weaponspace[10];
1407 void HUD_WeaponIcons_Clear()
1410 for(idx = 0; idx < 10; ++idx)
1411 weaponspace[idx] = 0;
1414 entity weaponorder[WEP_MAXCOUNT];
1415 void weaponorder_swap(float i, float j, entity pass)
1419 weaponorder[i] = weaponorder[j];
1423 string weaponorder_cmp_str_save;
1424 string weaponorder_cmp_str;
1425 float weaponorder_cmp(float i, float j, entity pass)
1428 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1429 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1430 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)
1433 void HUD_WeaponIcons(void)
1435 float id = HUD_PANEL_WEAPONICONS;
1436 float alpha, stat_weapons; // "constants"
1437 vector pos, mySize, accuracy_color;
1438 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1440 pos = HUD_Panel_GetPos(id);
1441 mySize = HUD_Panel_GetSize(id);
1443 stat_weapons = getstati(STAT_WEAPONS);
1445 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1447 self = get_weaponinfo(i);
1448 if(self.impulse >= 0)
1452 // TODO make this configurable
1453 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1455 if(weaponorder_cmp_str != weaponorder_cmp_str_save)
1457 if(weaponorder_cmp_str_save)
1458 strunzone(weaponorder_cmp_str_save);
1459 weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
1461 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1463 self = get_weaponinfo(i);
1464 if(self.impulse >= 0)
1466 weaponorder[weapon_cnt] = self;
1470 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1473 HUD_Panel_DrawBg(id, pos, mySize, 0);
1475 padding = HUD_Panel_GetPadding(id);
1478 pos += '1 1 0' * padding;
1479 mySize -= '2 2 0' * padding;
1483 weapon_stats = getstati(STAT_DAMAGE_HITS);
1484 weapon_number = weapon_stats & 63;
1485 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1487 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1488 weapon_number = weapon_stats & 63;
1489 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1491 if(cvar_or("hud_weaponicons_fade", 1))
1493 fade = 3.2 - 2 * (time - weapontime);
1494 fade = bound(0.7, fade, 1);
1499 HUD_WeaponIcons_Clear();
1501 float rows, columns;
1502 rows = mySize_y/mySize_x;
1503 rows = bound(1, floor((sqrt(4 * (2/1) * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1504 // ^^^ weapon icon aspect goes here
1506 columns = ceil(WEP_COUNT/rows);
1508 for(i = 0; i < weapon_cnt; ++i)
1510 self = weaponorder[i];
1511 weapid = self.impulse;
1513 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1515 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1516 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1518 // draw background behind currently selected weapon
1519 if(self.weapon == activeweapon)
1520 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);
1522 // draw the weapon accuracy on the HUD
1523 if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
1526 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1528 accuracy_color = HUD_AccuracyColor(weapon_stats);
1530 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);
1533 // draw the weapon icon
1534 if((self.impulse >= 0) && (stat_weapons & self.weapons))
1536 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);
1538 if(cvar_or("hud_weaponicons_number", 1))
1539 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);
1541 // draw a "ghost weapon icon" if you don't have the weapon
1544 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);
1559 float GetAmmoStat(float i)
1563 case 0: return STAT_SHELLS;
1564 case 1: return STAT_NAILS;
1565 case 2: return STAT_ROCKETS;
1566 case 3: return STAT_CELLS;
1567 case 4: return STAT_FUEL;
1572 float GetAmmoItemCode(float i)
1576 case 0: return IT_SHELLS;
1577 case 1: return IT_NAILS;
1578 case 2: return IT_ROCKETS;
1579 case 3: return IT_CELLS;
1580 case 4: return IT_FUEL;
1585 string GetAmmoPicture(float i)
1589 case 0: return "ammo_shells";
1590 case 1: return "ammo_bullets";
1591 case 2: return "ammo_rockets";
1592 case 3: return "ammo_cells";
1593 case 4: return "ammo_fuel";
1598 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1601 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1612 if(currently_selected)
1617 vector newSize, newPos;
1618 if(mySize_x/mySize_y > 3)
1620 newSize_x = 3 * mySize_y;
1621 newSize_y = mySize_y;
1623 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1628 newSize_y = 1/3 * mySize_x;
1629 newSize_x = mySize_x;
1631 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1635 vector picpos, numpos;
1636 if(cvar("hud_inventory_iconalign"))
1639 picpos = newPos + eX * 2 * newSize_y;
1643 numpos = newPos + eX * newSize_y;
1647 if (currently_selected)
1648 drawpic_skin(newPos, "ammo_current_bg", newSize, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_INVENTORY), DRAWFLAG_NORMAL);
1650 drawfont = hud_bigfont;
1651 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);
1652 drawfont = hud_font;
1653 drawpic_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_INVENTORY) * alpha, DRAWFLAG_NORMAL);
1656 void HUD_Inventory(void)
1658 float id = HUD_PANEL_INVENTORY;
1659 float i, currently_selected;
1662 pos = HUD_Panel_GetPos(id);
1663 mySize = HUD_Panel_GetSize(id);
1665 HUD_Panel_DrawBg(id, pos, mySize, 0);
1667 padding = HUD_Panel_GetPadding(id);
1670 pos += '1 1 0' * padding;
1671 mySize -= '2 2 0' * padding;
1674 float rows, columns;
1675 rows = mySize_y/mySize_x;
1676 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1677 // ^^^ ammo item aspect goes here
1679 columns = ceil(AMMO_COUNT/rows);
1683 for (i = 0; i < AMMO_COUNT; ++i) {
1684 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1685 if(cvar("hud_inventory_onlycurrent")) {
1688 if (currently_selected || hud_configure)
1689 DrawAmmoItem(pos, mySize, i, currently_selected);
1692 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);
1697 column = column + 1;
1703 void DrawNumIcon(float id, vector myPos, vector mySize, float x, string icon, float left, vector color)
1705 vector newSize, newPos;
1706 if(mySize_x/mySize_y > 3)
1708 newSize_x = 3 * mySize_y;
1709 newSize_y = mySize_y;
1711 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1716 newSize_y = 1/3 * mySize_x;
1717 newSize_x = mySize_x;
1719 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1723 vector picpos, numpos;
1725 iconalign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_iconalign"));
1728 if(iconalign == 1 || iconalign == 3) // right align
1731 picpos = newPos + eX * 2 * newSize_y;
1735 numpos = newPos + eX * newSize_y;
1741 if(iconalign == 0 || iconalign == 3) // left align
1743 numpos = newPos + eX * newSize_y;
1749 picpos = newPos + eX * 2 * newSize_y;
1753 drawfont = hud_bigfont;
1754 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, newSize_y, color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1755 drawfont = hud_font;
1756 drawpic_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1761 void HUD_Powerups(void) {
1762 float id = HUD_PANEL_POWERUPS;
1764 stat_items = getstati(STAT_ITEMS);
1768 if not(stat_items & IT_STRENGTH)
1769 if not(stat_items & IT_INVINCIBLE)
1772 if (getstati(STAT_HEALTH) <= 0)
1777 pos = HUD_Panel_GetPos(id);
1778 mySize = HUD_Panel_GetSize(id);
1780 HUD_Panel_DrawBg(id, pos, mySize, 0);
1782 padding = HUD_Panel_GetPadding(id);
1785 pos += '1 1 0' * padding;
1786 mySize -= '2 2 0' * padding;
1789 float strength_time, shield_time;
1791 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1792 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1800 vector barpos, barsize;
1804 string leftname, rightname;
1805 float leftcnt, rightcnt;
1806 float leftexact, rightexact;
1807 float leftalpha, rightalpha;
1808 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) {
1809 leftname = "strength";
1810 leftcnt = ceil(strength_time);
1811 leftexact = strength_time;
1813 rightname = "shield";
1814 rightcnt = ceil(shield_time);
1815 rightexact = shield_time;
1817 leftname = "shield";
1818 leftcnt = ceil(shield_time);
1819 leftexact = shield_time;
1821 rightname = "strength";
1822 rightcnt = ceil(strength_time);
1823 rightexact = strength_time;
1825 leftalpha = bound(0, leftexact, 1);
1826 rightalpha = bound(0, rightexact, 1);
1828 float baralign, iconalign;
1829 baralign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_baralign"));
1830 iconalign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_iconalign"));
1832 if (mySize_x/mySize_y > 4)
1836 if(baralign == 1 || baralign == 3) { // right align
1837 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1838 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1839 } else { // left align
1841 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1844 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1845 DrawNumIcon(id, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1');
1848 // 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));
1850 // drawpic_skin(picpos, leftname, eX * (1/6) * mySize_x + eY * mySize_y, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1855 if(baralign == 0 || baralign == 3) { // left align
1856 barpos = pos + eX * 0.5 * mySize_x;
1857 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1858 } else { // right align
1859 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1860 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1863 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1864 DrawNumIcon(id, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1');
1867 else if (mySize_x/mySize_y > 1.5)
1871 if(baralign == 1 || baralign == 3) { // right align
1872 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1873 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1874 } else { // left align
1876 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1879 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1880 DrawNumIcon(id, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1');
1885 if(baralign == 0 || baralign == 3) { // left align
1886 barpos = pos + eY * 0.5 * mySize_y;
1887 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1888 } else { // right align
1889 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1890 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1893 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1894 DrawNumIcon(id, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1');
1901 if(baralign == 1 || baralign == 3) { // down align
1902 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1903 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1904 } else { // up align
1906 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1909 if(iconalign == 1 || iconalign == 3) { // down align
1910 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
1911 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
1912 } else { // up align
1913 picpos = pos + eX * 0.05 * mySize_x;
1914 numpos = pos + eY * 0.4 * mySize_x;
1917 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1919 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));
1921 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1922 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);
1927 if(baralign == 0 || baralign == 3) { // up align
1928 barpos = pos + eX * 0.5 * mySize_x;
1929 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1930 } else { // down align
1931 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1932 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1935 if(iconalign == 0 || iconalign == 3) { // up align
1936 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1937 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1938 } else { // down align
1939 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
1940 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
1943 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1945 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));
1947 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
1948 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);
1953 // Health/armor (#3)
1955 void HUD_HealthArmor(void)
1957 float id = HUD_PANEL_HEALTHARMOR;
1959 pos = HUD_Panel_GetPos(id);
1960 mySize = HUD_Panel_GetSize(id);
1962 HUD_Panel_DrawBg(id, pos, mySize, 0);
1964 padding = HUD_Panel_GetPadding(id);
1967 pos += '1 1 0' * padding;
1968 mySize -= '2 2 0' * padding;
1971 float armor, health;
1972 armor = getstati(STAT_ARMOR);
1973 health = getstati(STAT_HEALTH);
1976 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
1988 vector barpos, barsize;
1992 float baralign, iconalign;
1993 baralign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_baralign"));
1994 iconalign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_iconalign"));
1996 if(cvar("hud_healtharmor") == 2) // combined health and armor display
1999 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2004 if(baralign == 1 || baralign == 3) { // right align
2005 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2006 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2007 } else { // left align
2009 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2013 if(v_z) // NOT fully armored
2015 biggercount = "health";
2016 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("health"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2018 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);
2022 biggercount = "armor";
2023 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("armor"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2025 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);
2027 DrawNumIcon(id, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200));
2032 if(baralign == 0 || baralign == 3) { // left align
2033 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2034 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2037 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2039 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2044 string leftname, rightname;
2045 float leftcnt, rightcnt;
2046 float leftactive, rightactive;
2047 float leftalpha, rightalpha;
2048 if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) { // old style layout with armor left/top of health
2053 leftalpha = min((armor+10)/55, 1);
2055 rightname = "health";
2060 leftname = "health";
2065 rightname = "armor";
2069 rightalpha = min((armor+10)/55, 1);
2072 if (mySize_x/mySize_y > 4)
2076 if(baralign == 1 || baralign == 3) { // right align
2077 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2078 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2079 } else { // left align
2081 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2084 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2085 DrawNumIcon(id, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2090 if(baralign == 0 || baralign == 3) { // left align
2091 barpos = pos + eX * 0.5 * mySize_x;
2092 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2093 } else { // right align
2094 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2095 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2098 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2099 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));
2104 if(baralign == 0 || baralign == 3) { // left align
2105 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2106 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2109 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2111 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2114 else if (mySize_x/mySize_y > 1.5)
2118 if(baralign == 1 || baralign == 3) { // right align
2119 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2120 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2121 } else { // left align
2123 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2126 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2127 DrawNumIcon(id, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200));
2132 if(baralign == 0 || baralign == 3) { // left align
2133 barpos = pos + eY * 0.5 * mySize_y;
2134 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2135 } else { // right align
2136 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2137 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2140 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2141 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));
2146 if(baralign == 0 || baralign == 3) { // left align
2147 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2148 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2151 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2153 HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2160 if(baralign == 1 || baralign == 3) { // down align
2161 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2162 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2163 } else { // up align
2165 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2168 if(iconalign == 1 || iconalign == 3) { // down align
2169 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2170 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2171 } else { // up align
2172 picpos = pos + eX * 0.05 * mySize_x;
2173 numpos = pos + eY * 0.4 * mySize_x;
2176 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2177 drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2178 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);
2183 if(baralign == 0 || baralign == 3) { // up align
2184 barpos = pos + eX * 0.5 * mySize_x;
2185 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2186 } else { // down align
2187 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2188 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2191 if(iconalign == 0 || iconalign == 3) { // up align
2192 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2193 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2194 } else { // down align
2195 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2196 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2199 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2200 drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2201 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);
2206 if(baralign == 0 || baralign == 3) { // left align
2208 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2210 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2211 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2213 HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor("fuel"), HUD_Panel_GetFgAlpha(id) * 0.8, DRAWFLAG_NORMAL);
2220 // Notification area (#4)
2223 string Weapon_SuicideMessage(float deathtype)
2225 w_deathtype = deathtype;
2226 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2227 return w_deathtypestring;
2230 string Weapon_KillMessage(float deathtype)
2232 w_deathtype = deathtype;
2233 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2234 return w_deathtypestring;
2237 float killnotify_times[10];
2238 float killnotify_deathtype[10];
2239 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2240 string killnotify_attackers[10];
2241 string killnotify_victims[10];
2242 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2245 for (i = 9; i > 0; --i) {
2246 killnotify_times[i] = killnotify_times[i-1];
2247 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2248 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2249 if(killnotify_attackers[i])
2250 strunzone(killnotify_attackers[i]);
2251 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2252 if(killnotify_victims[i])
2253 strunzone(killnotify_victims[i]);
2254 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2256 killnotify_times[0] = time;
2257 killnotify_deathtype[0] = wpn;
2258 killnotify_actiontype[0] = actiontype;
2259 if(killnotify_attackers[0])
2260 strunzone(killnotify_attackers[0]);
2261 killnotify_attackers[0] = strzone(attacker);
2262 if(killnotify_victims[0])
2263 strunzone(killnotify_victims[0]);
2264 killnotify_victims[0] = strzone(victim);
2267 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2271 alsoprint = (cvar("hud_notify_print") || !HUD_Panel_CheckActive(4)); // print message to console if: notify panel disabled, or cvar to do so enabled
2273 if(msg == MSG_SUICIDE) {
2275 w = DEATH_WEAPONOF(type);
2277 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2279 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2280 } else if (type == DEATH_KILL) {
2281 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2283 print ("^1",s1, "^1 couldn't take it anymore\n");
2284 } else if (type == DEATH_ROT) {
2285 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2287 print ("^1",s1, "^1 died\n");
2288 } else if (type == DEATH_NOAMMO) {
2289 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2291 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2292 } else if (type == DEATH_CAMP) {
2293 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2295 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2296 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2297 HUD_KillNotify_Push(s1, "", 0, type);
2299 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2300 } else if (type == DEATH_CHEAT) {
2301 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2303 print ("^1",s1, "^1 unfairly eliminated themself\n");
2304 } else if (type == DEATH_FIRE) {
2305 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2307 print ("^1",s1, "^1 burned to death\n");
2308 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2309 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2311 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2314 if (stof(s2) > 2) // killcount > 2
2315 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2316 } else if(msg == MSG_KILL) {
2317 w = DEATH_WEAPONOF(type);
2319 HUD_KillNotify_Push(s2, s1, 1, w);
2321 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2323 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2324 HUD_KillNotify_Push(s1, s2, 1, type);
2327 if(cvar("cl_gentle")) {
2328 print ("^1", s1, "^1 took action against a team mate\n");
2330 print ("^1", s1, "^1 mows down a team mate\n");
2333 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2334 if(cvar("cl_gentle"))
2335 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2337 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2339 else if (stof(s2) > 2) {
2340 if(cvar("cl_gentle"))
2341 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2343 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2346 else if(type == KILL_FIRST_BLOOD)
2347 print("^1",s1, "^1 drew first blood", "\n");
2349 else if (type == DEATH_TELEFRAG)
2350 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2351 else if (type == DEATH_DROWN) {
2352 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2354 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2356 else if (type == DEATH_SLIME) {
2357 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2359 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2361 else if (type == DEATH_LAVA) {
2362 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2364 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2366 else if (type == DEATH_FALL) {
2367 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2369 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2371 else if (type == DEATH_SHOOTING_STAR) {
2372 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2374 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2376 else if (type == DEATH_SWAMP) {
2377 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2379 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2381 else if (type == DEATH_HURTTRIGGER)
2383 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2385 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2386 } else if(type == DEATH_SBCRUSH) {
2387 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2389 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2390 } else if(type == DEATH_SBMINIGUN) {
2391 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2393 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2394 } else if(type == DEATH_SBROCKET) {
2395 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2397 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2398 } else if(type == DEATH_SBBLOWUP) {
2399 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2401 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2402 } else if(type == DEATH_WAKIGUN) {
2403 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2405 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2406 } else if(type == DEATH_WAKIROCKET) {
2407 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2409 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2410 } else if(type == DEATH_WAKIBLOWUP) {
2411 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2413 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2414 } else if(type == DEATH_TURRET) {
2415 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2417 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2418 } else if(type == DEATH_TOUCHEXPLODE) {
2419 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2421 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2422 } else if(type == DEATH_CHEAT) {
2423 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2425 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2426 } else if (type == DEATH_FIRE) {
2427 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2429 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2430 } else if (type == DEATH_CUSTOM) {
2431 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2433 print ("^1",s1, "^1 ", s2, "\n");
2435 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2437 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2439 } else if(msg == MSG_SPREE) {
2440 if(type == KILL_END_SPREE) {
2441 if(cvar("cl_gentle"))
2442 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2444 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2445 } else if(type == KILL_SPREE) {
2446 if(cvar("cl_gentle"))
2447 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2449 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2450 } else if(type == KILL_SPREE_3) {
2451 if(cvar("cl_gentle"))
2452 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2454 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2455 } else if(type == KILL_SPREE_5) {
2456 if(cvar("cl_gentle"))
2457 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2459 print (s1,"^7 unleashes ^1RAGE\n");
2460 } else if(type == KILL_SPREE_10) {
2461 if(cvar("cl_gentle"))
2462 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2464 print (s1,"^7 starts the ^1MASSACRE!\n");
2465 } else if(type == KILL_SPREE_15) {
2466 if(cvar("cl_gentle"))
2467 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2469 print (s1,"^7 executes ^1MAYHEM!\n");
2470 } else if(type == KILL_SPREE_20) {
2471 if(cvar("cl_gentle"))
2472 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2474 print (s1,"^7 is a ^1BERSERKER!\n");
2475 } else if(type == KILL_SPREE_25) {
2476 if(cvar("cl_gentle"))
2477 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2479 print (s1,"^7 inflicts ^1CARNAGE!\n");
2480 } else if(type == KILL_SPREE_30) {
2481 if(cvar("cl_gentle"))
2482 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2484 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2486 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2487 if (type == DEATH_DROWN) {
2488 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2491 if(cvar("cl_gentle"))
2492 print ("^1",s1, "^1 was in the water for too long\n");
2494 print ("^1",s1, "^1 drowned\n");
2496 } else if (type == DEATH_SLIME) {
2497 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2499 print ("^1",s1, "^1 was slimed\n");
2500 } else if (type == DEATH_LAVA) {
2501 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2504 if(cvar("cl_gentle"))
2505 print ("^1",s1, "^1 found a hot place\n");
2507 print ("^1",s1, "^1 turned into hot slag\n");
2509 } else if (type == DEATH_FALL) {
2510 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2513 if(cvar("cl_gentle"))
2514 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2516 print ("^1",s1, "^1 hit the ground with a crunch\n");
2518 } else if (type == DEATH_SHOOTING_STAR) {
2519 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2521 print ("^1",s1, "^1 became a shooting star\n");
2522 } else if (type == DEATH_SWAMP) {
2523 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2526 if(cvar("cl_gentle"))
2527 print ("^1",s1, "^1 discovered a swamp\n");
2529 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2531 } else if(type == DEATH_TURRET) {
2532 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2534 print ("^1",s1, "^1 was mowed down by a turret \n");
2535 } else if (type == DEATH_CUSTOM) {
2536 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2538 print ("^1",s1, "^1 ", s2, "\n");
2539 } else if (type == DEATH_HURTTRIGGER) {
2540 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2542 print ("^1",s1, "^1 was in the wrong place\n");
2543 } else if(type == DEATH_TOUCHEXPLODE) {
2544 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2546 print ("^1",s1, "^1 died in an accident\n");
2547 } else if(type == DEATH_CHEAT) {
2548 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2550 print ("^1",s1, "^1 was unfairly eliminated\n");
2551 } else if(type == DEATH_FIRE) {
2552 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2555 if(cvar("cl_gentle"))
2556 print ("^1",s1, "^1 felt a little hot\n");
2558 print ("^1",s1, "^1 burnt to death\n");
2561 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2564 if(cvar("cl_gentle"))
2565 print ("^1",s1, "^1 needs a restart\n");
2567 print ("^1",s1, "^1 died\n");
2570 } else if(msg == MSG_KILL_ACTION_SPREE) {
2571 if(cvar("cl_gentle"))
2572 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2574 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2575 } else if(msg == MSG_INFO) {
2576 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2577 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2578 print(s1, "^7 got the ", s2, "\n");
2579 } else if(type == INFO_LOSTFLAG) {
2580 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2581 print(s1, "^7 lost the ", s2, "\n");
2582 } else if(type == INFO_PICKUPFLAG) {
2583 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2584 print(s1, "^7 picked up the ", s2, "\n");
2585 } else if(type == INFO_RETURNFLAG) {
2586 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2587 print(s1, "^7 returned the ", s2, "\n");
2592 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2594 void HUD_Centerprint(string s1, string s2, float type, float msg)
2596 if(msg == MSG_SUICIDE) {
2597 if (type == DEATH_TEAMCHANGE) {
2598 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2599 } else if (type == DEATH_AUTOTEAMCHANGE) {
2600 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2601 } else if (type == DEATH_CAMP) {
2602 if(cvar("cl_gentle"))
2603 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2605 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2606 } else if (type == DEATH_NOAMMO) {
2607 if(cvar("cl_gentle"))
2608 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2610 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2611 } else if (type == DEATH_ROT) {
2612 if(cvar("cl_gentle"))
2613 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2615 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2616 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2617 if(cvar("cl_gentle"))
2618 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2620 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2621 } else if (type == DEATH_QUIET) {
2623 } else if (type == DEATH_KILL) {
2624 if(cvar("cl_gentle"))
2625 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2627 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2629 } else if(msg == MSG_KILL) {
2630 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2631 if(cvar("cl_gentle")) {
2632 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2634 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2636 } else if (type == KILL_FIRST_BLOOD) {
2637 if(cvar("cl_gentle")) {
2638 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2640 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2642 } else if (type == KILL_FIRST_VICTIM) {
2643 if(cvar("cl_gentle")) {
2644 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2646 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2648 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2649 if(cvar("cl_gentle")) {
2650 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2652 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2654 } else if (type == KILL_TYPEFRAGGED) {
2655 if(cvar("cl_gentle")) {
2656 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2658 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2660 } else if (type == KILL_FRAG) {
2661 if(cvar("cl_gentle")) {
2662 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2664 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2666 } else if (type == KILL_FRAGGED) {
2667 if(cvar("cl_gentle")) {
2668 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2670 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2673 } else if(msg == MSG_KILL_ACTION) {
2674 // TODO: invent more centerprints here?
2675 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2679 void HUD_Notify (void)
2681 float id = HUD_PANEL_NOTIFY;
2683 pos = HUD_Panel_GetPos(id);
2684 mySize = HUD_Panel_GetSize(id);
2686 HUD_Panel_DrawBg(id, pos, mySize, 0);
2688 padding = HUD_Panel_GetPadding(id);
2691 pos += '1 1 0' * padding;
2692 mySize -= '2 2 0' * padding;
2695 float entries, height;
2696 entries = bound(1, floor(14 * mySize_y/mySize_x), 12);
2697 height = mySize_y/entries;
2698 entries -= 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2701 fontsize = '0.5 0.5 0' * height;
2705 when = cvar("hud_notify_time");
2707 fadetime = cvar("hud_notify_fadetime");
2711 vector pos_attacker, pos_victim;
2713 float width_attacker, width_victim;
2714 string attacker, victim;
2717 for(j = 0; j < entries; ++j)
2719 if(cvar("hud_notify_flip"))
2721 else // rather nasty hack for ordering items from the bottom up
2722 i = entries - j - 1;
2723 if(cvar("hud_notify_info_top"))
2724 i += 2; // top/bottom two lines reserved for info messaged, such as spec instructions
2728 if(killnotify_times[j] + when > time)
2731 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2735 if(killnotify_times[j] + when > time)
2741 // TODO: maybe print in team colors?
2742 // TODO: maybe this could be cleaned up somehow...
2743 // TODO: less copypaste code below
2746 if(killnotify_actiontype[j] == 0 && !hud_configure)
2748 attacker = textShortenToWidth(killnotify_attackers[j], mySize_x - 2 * height, fontsize, stringwidth_colors);
2750 width_attacker = stringwidth(attacker, TRUE, fontsize);
2751 pos_attacker = pos + eX * 0.5 * (mySize_x - width_attacker + 2 * height) + eY * 0.5 * fontsize_y + eY * i * height;
2753 weap_pos = pos + eX * 0.5 * (mySize_x - width_attacker) - eX * height + eY * i * height;
2754 if(killnotify_deathtype[j] == DEATH_GENERIC)
2756 drawpic_skin(weap_pos, "notify_death", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2757 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2759 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2761 drawpic_skin(weap_pos, "notify_outofammo", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2762 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2764 else if(killnotify_deathtype[j] == DEATH_KILL)
2766 drawpic_skin(weap_pos, "notify_selfkill", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2767 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2769 else if(killnotify_deathtype[j] == DEATH_CAMP)
2771 drawpic_skin(weap_pos, "notify_camping", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2772 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2774 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2776 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2777 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2779 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2781 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2782 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2784 else if(killnotify_deathtype[j] == DEATH_DROWN)
2786 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2787 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2789 else if(killnotify_deathtype[j] == DEATH_SLIME)
2791 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2792 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2794 else if(killnotify_deathtype[j] == DEATH_LAVA)
2796 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2797 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2799 else if(killnotify_deathtype[j] == DEATH_FALL)
2801 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2802 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2804 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2806 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2807 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2809 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2811 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2812 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2814 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2816 if(killnotify_victims[j] == "^1RED^7 flag")
2820 drawpic_skin(weap_pos, strcat("flag_", s, "_carrying"), '1 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);
2823 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2825 if(killnotify_victims[j] == "^1RED^7 flag")
2829 drawpic_skin(weap_pos, strcat("flag_", s, "_taken"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2830 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2832 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2834 if(killnotify_victims[j] == "^1RED^7 flag")
2838 drawpic_skin(weap_pos, strcat("flag_", s, "_lost"), '1 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2839 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2842 // X [did action to] Y
2847 attacker = textShortenToWidth("Player1", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2848 victim = textShortenToWidth("Player2", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2849 a = bound(0, (when - j) / 4, 1);
2853 attacker = textShortenToWidth(killnotify_attackers[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2854 victim = textShortenToWidth(killnotify_victims[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
2856 width_attacker = stringwidth(attacker, TRUE, fontsize);
2857 width_victim = stringwidth(victim, TRUE, fontsize);
2858 pos_attacker = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_attacker) + eY * 0.5 * fontsize_y + eY * i * height;
2859 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;
2860 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2862 if(hud_configure) // example actions for config mode
2864 drawpic_skin(weap_pos, strcat("weapon", "electro"), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2865 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2866 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2868 else if(WEP_VALID(killnotify_deathtype[j]))
2870 self = get_weaponinfo(killnotify_deathtype[j]);
2871 drawpic_skin(weap_pos, strcat("weapon", self.netname), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2872 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2873 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2875 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2877 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '1 0 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2878 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2879 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2881 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2883 drawpic_skin(weap_pos, "notify_teamkill", '2 1 0' * height, '0 0 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2884 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2885 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2887 else if(killnotify_deathtype[j] == DEATH_DROWN)
2889 drawpic_skin(weap_pos, "notify_water", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2890 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2891 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2893 else if(killnotify_deathtype[j] == DEATH_SLIME)
2895 drawpic_skin(weap_pos, "notify_slime", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2896 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2897 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2899 else if(killnotify_deathtype[j] == DEATH_LAVA)
2901 drawpic_skin(weap_pos, "notify_lava", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2902 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2903 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2905 else if(killnotify_deathtype[j] == DEATH_FALL)
2907 drawpic_skin(weap_pos, "notify_fall", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2908 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2909 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2911 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2913 drawpic_skin(weap_pos, "notify_shootingstar", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2914 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2915 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2917 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2919 drawpic_skin(weap_pos, "notify_void", '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2920 drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2921 drawcolorcodedstring(pos_victim, victim, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
2927 // TODO: separate panel for these?
2933 if(cvar("hud_notify_info_top"))
2936 o = pos + eY * mySize_y - eY * 2 * height;
2938 if(spectatee_status && !intermission)
2940 //drawfont = hud_bigfont;
2941 if(spectatee_status == -1)
2944 s = GetPlayerName(spectatee_status - 1);
2946 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
2947 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2948 //drawfont = hud_font;
2950 // spectator text in the upper right corner
2951 if(spectatee_status == -1)
2952 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
2954 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
2955 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2956 o += eY * fontsize_y;
2958 if(spectatee_status == -1)
2959 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
2961 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
2962 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2963 o += eY * fontsize_y;
2965 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
2966 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2967 o += eY * fontsize_y;
2969 if(gametype == GAME_ARENA)
2970 s = "^1Wait for your turn to join";
2971 else if(gametype == GAME_LMS)
2974 sk = playerslots[player_localentnum - 1];
2975 if(sk.(scores[ps_primary]) >= 666)
2976 s = "^1Match has already begun";
2977 else if(sk.(scores[ps_primary]) > 0)
2978 s = "^1You have no more lives left";
2980 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
2983 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
2984 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2985 o += eY * fontsize_y;
2987 //show restart countdown:
2988 if (time < getstatf(STAT_GAMESTARTTIME)) {
2990 //we need to ceil, otherwise the countdown would be off by .5 when using round()
2991 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
2992 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
2993 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
2994 o += eY * fontsize_y;
2997 if(warmup_stage && !intermission)
2999 s = "^2Currently in ^1warmup^2 stage!";
3000 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3001 o += eY * fontsize_y;
3005 if(mod(time, 1) >= 0.5)
3010 if(ready_waiting && !intermission && !spectatee_status)
3012 if(ready_waiting_for_me)
3015 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
3017 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
3022 s = strcat("^2Waiting for others to ready up to end warmup...");
3024 s = strcat("^2Waiting for others to ready up...");
3026 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3027 o += eY * fontsize_y;
3029 else if(warmup_stage && !intermission && !spectatee_status)
3031 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
3032 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3033 o += eY * fontsize_y;
3036 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
3038 float ts_min, ts_max;
3039 tm = teams.sort_next;
3042 for(; tm.sort_next; tm = tm.sort_next)
3044 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
3046 if(!ts_min) ts_min = tm.team_size;
3047 else ts_min = min(ts_min, tm.team_size);
3048 if(!ts_max) ts_max = tm.team_size;
3049 else ts_max = max(ts_max, tm.team_size);
3051 if ((ts_max - ts_min) > 1)
3053 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
3054 tm = GetTeam(myteam, false);
3056 if (tm.team != COLOR_SPECTATOR)
3057 if (tm.team_size == ts_max)
3058 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
3060 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3061 o += eY * fontsize_y;
3067 s = "^7Press ^3ESC ^7to show HUD options.";
3068 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3069 o += eY * fontsize_y;
3070 s = "^3Doubleclick a panel for panel-specific options.";
3071 drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3072 o += eY * fontsize_y;
3078 string seconds_tostring(float sec)
3081 minutes = floor(sec / 60);
3083 sec -= minutes * 60;
3086 s = ftos(100 + sec);
3088 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3091 void HUD_Timer(void)
3093 float id = HUD_PANEL_TIMER;
3095 pos = HUD_Panel_GetPos(id);
3096 mySize = HUD_Panel_GetSize(id);
3098 HUD_Panel_DrawBg(id, pos, mySize, 0);
3100 padding = HUD_Panel_GetPadding(id);
3103 pos += '1 1 0' * padding;
3104 mySize -= '2 2 0' * padding;
3108 float timelimit, elapsedTime, timeleft, minutesLeft;
3110 timelimit = getstatf(STAT_TIMELIMIT);
3112 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3113 timeleft = ceil(timeleft);
3115 minutesLeft = floor(timeleft / 60);
3118 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3119 timer_color = '1 1 1'; //white
3120 else if(minutesLeft >= 1)
3121 timer_color = '1 1 0'; //yellow
3123 timer_color = '1 0 0'; //red
3125 if (cvar("hud_timer_increment") || timelimit == 0 || warmup_stage) {
3126 if (time < getstatf(STAT_GAMESTARTTIME)) {
3127 //while restart is still active, show 00:00
3128 timer = seconds_tostring(0);
3130 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3131 timer = seconds_tostring(elapsedTime);
3134 timer = seconds_tostring(timeleft);
3137 drawfont = hud_bigfont;
3138 drawstring_aspect(pos, timer, mySize, mySize_y, timer_color, HUD_Panel_GetFgAlpha(HUD_PANEL_TIMER), DRAWFLAG_NORMAL);
3139 drawfont = hud_font;
3144 void HUD_Radar(void)
3146 float id = HUD_PANEL_RADAR;
3148 pos = HUD_Panel_GetPos(id);
3149 mySize = HUD_Panel_GetSize(id);
3151 HUD_Panel_DrawBg(id, pos, mySize, 0);
3153 padding = HUD_Panel_GetPadding(id);
3156 pos += '1 1 0' * padding;
3157 mySize -= '2 2 0' * padding;
3160 local float color1, color2; // color already declared as a global in hud.qc
3163 float scale2d, normalsize, bigsize;
3166 teamradar_origin2d = pos + 0.5 * mySize;
3167 teamradar_size2d = mySize;
3169 if(minimapname == "")
3172 teamradar_loadcvars();
3174 switch(hud_radar_zoommode)
3178 f = current_zoomfraction;
3181 f = 1 - current_zoomfraction;
3191 switch(hud_radar_rotation)
3194 teamradar_angle = view_angles_y - 90;
3197 teamradar_angle = 90 * hud_radar_rotation;
3201 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3202 teamradar_size2d = mySize;
3204 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3206 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3207 if(hud_radar_rotation == 0)
3209 // max-min distance must fit the radar in any rotation
3210 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3214 vector c0, c1, c2, c3, span;
3215 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3216 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3217 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3218 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3220 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3221 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3223 // max-min distance must fit the radar in x=x, y=y
3225 teamradar_size2d_x * scale2d / (1.05 * span_x),
3226 teamradar_size2d_y * scale2d / (1.05 * span_y)
3230 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3231 if(bigsize > normalsize)
3232 normalsize = bigsize;
3236 + (1 - f) * normalsize;
3237 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3238 f * (mi_min + mi_max) * 0.5
3239 + (1 - f) * view_origin);
3241 color1 = GetPlayerColor(player_localentnum-1);
3242 rgb = GetTeamRGB(color1);
3251 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3253 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3254 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3255 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3256 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, HUD_Panel_GetFgAlpha(id));
3257 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3259 color2 = GetPlayerColor(tm.sv_entnum);
3260 //if(color == COLOR_SPECTATOR || color == color2)
3261 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3263 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3265 drawresetcliparea();
3270 void HUD_Score(void)
3272 float id = HUD_PANEL_SCORE;
3274 pos = HUD_Panel_GetPos(id);
3275 mySize = HUD_Panel_GetSize(id);
3277 HUD_Panel_DrawBg(id, pos, mySize, 0);
3279 padding = HUD_Panel_GetPadding(id);
3282 pos += '1 1 0' * padding;
3283 mySize -= '2 2 0' * padding;
3286 float score, distribution, leader;
3288 vector distribution_color;
3290 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3292 // TODO... this (race part) still uses constant coordinates :/
3293 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3294 /*pl = players.sort_next;
3297 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3298 if(pl.scores[ps_primary] == 0)
3301 score = me.(scores[ps_primary]);
3303 float racemin, racesec, racemsec;
3304 float distsec, distmsec, minusplus;
3306 racemin = floor(score/(60 * TIME_FACTOR));
3307 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
3308 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
3310 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3311 // distribution display
3312 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3314 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
3315 distmsec = fabs(distribution);
3317 distsec = floor(fabs(distribution)/TIME_FACTOR);
3318 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
3319 if (distribution < 0)
3323 if (distribution <= 0) {
3324 distribution_color = eY;
3325 minusplus = 1; // minusplus 1: always prefix with minus sign
3328 distribution_color = eX;
3329 minusplus = 2; // minusplus 1: always prefix with plus sign
3331 //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);
3332 //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);
3333 drawpic_skin(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "num_dot", '16 16 0', distribution_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_ADDITIVE);
3335 // race record display
3336 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
3337 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);
3339 //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);
3340 //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);
3341 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);
3343 //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);
3344 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);
3346 } else if (!teamplay) { // non-teamgames
3347 // me vector := [team/connected frags id]
3348 pl = players.sort_next;
3355 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3359 score = me.(scores[ps_primary]);
3363 if(distribution >= 5) {
3364 distribution_color = eY;
3366 } else if(distribution >= 0) {
3367 distribution_color = '1 1 1';
3369 } else if(distribution >= -5)
3370 distribution_color = '1 1 0';
3372 distribution_color = eX;
3374 score_len = strlen(ftos(score));
3376 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);
3378 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);
3379 drawfont = hud_bigfont;
3380 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, mySize_y, distribution_color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3381 drawfont = hud_font;
3382 } else { // teamgames
3383 float max_fragcount;
3384 max_fragcount = -99;
3387 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3388 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !hud_configure)) // no players? don't display
3390 score = tm.(teamscores[ts_primary]);
3395 score_len = strlen(ftos(score));
3397 if (score > max_fragcount)
3398 max_fragcount = score;
3400 if(tm.team == myteam) {
3401 if (max_fragcount == score)
3404 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);
3405 drawfont = hud_bigfont;
3406 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);
3407 drawfont = hud_font;
3409 if (max_fragcount == score)
3412 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);
3413 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);
3422 void HUD_RaceTimer (void) {
3423 float id = HUD_PANEL_RACETIMER;
3425 pos = HUD_Panel_GetPos(id);
3426 mySize = HUD_Panel_GetSize(id);
3428 HUD_Panel_DrawBg(id, pos, mySize, 0);
3430 padding = HUD_Panel_GetPadding(id);
3433 pos += '1 1 0' * padding;
3434 mySize -= '2 2 0' * padding;
3437 // always force 2:1 aspect
3439 if(mySize_x/mySize_y > 2)
3441 newSize_x = 2 * mySize_y;
3442 newSize_y = mySize_y;
3444 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3448 newSize_y = 1/2 * mySize_x;
3449 newSize_x = mySize_x;
3451 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3455 drawfont = hud_bigfont;
3457 string s, forcetime;
3462 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);
3463 s = "^1Intermediate 1 (+15.42)";
3464 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);
3465 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3466 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);
3468 else if(race_checkpointtime)
3470 a = bound(0, 2 - (time - race_checkpointtime), 1);
3473 if(a > 0) // just hit a checkpoint?
3475 if(race_checkpoint != 254)
3477 if(race_time && race_previousbesttime)
3478 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3480 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3482 forcetime = TIME_ENCODED_TOSTRING(race_time);
3487 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3489 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3490 if(a > 0) // next one?
3492 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3497 if(s != "" && a > 0)
3499 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3500 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3501 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);
3504 if(race_penaltytime)
3506 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3509 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3510 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3511 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3512 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);
3518 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3519 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id), 0, a);
3520 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);
3525 if(race_laptime && race_checkpoint != 255)
3527 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3528 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3529 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);
3534 if(race_mycheckpointtime)
3536 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3537 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3538 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3539 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3540 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);
3542 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3544 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3545 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3546 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3547 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3548 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);
3551 if(race_penaltytime && !race_penaltyaccumulator)
3553 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3554 a = bound(0, (1 + t - time), 1);
3558 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3560 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3561 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
3562 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
3563 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);
3568 drawfont = hud_font;
3573 float vote_yescount;
3576 float vote_highlighted; // currently selected vote
3578 float vote_active; // is there an active vote?
3579 float vote_prev; // previous state of vote_active to check for a change
3581 float vote_change; // "time" when vote_active changed
3583 void HUD_VoteWindow(void)
3585 float id = HUD_PANEL_VOTE;
3587 pos = HUD_Panel_GetPos(id);
3588 mySize = HUD_Panel_GetSize(id);
3592 if(vote_active != vote_prev) {
3594 vote_prev = vote_active;
3597 if(vote_active || hud_configure)
3598 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3600 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3612 a = vote_alpha * bound(cvar_or("hud_vote_alreadyvoted_alpha", 0.75), 1 - vote_highlighted, 1);
3614 HUD_Panel_DrawBg(id, pos, mySize, a);
3616 padding = HUD_Panel_GetPadding(id);
3619 pos += '1 1 0' * padding;
3620 mySize -= '2 2 0' * padding;
3623 // always force 2:1 aspect
3625 if(mySize_x/mySize_y > 2)
3627 newSize_x = 2 * mySize_y;
3628 newSize_y = mySize_y;
3630 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3634 newSize_y = 1/2 * mySize_x;
3635 newSize_x = mySize_x;
3637 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3641 drawpic_skin(pos, "voteprogress_back", mySize, '1 1 1', a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3643 s = "A vote has been called for: ";
3644 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);
3645 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (3/12), stringwidth_colors); // TODO: broken?
3647 s = "Configure the HUD";
3648 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);
3650 // print the yes/no counts
3651 s = strcat("Yes: ", ftos(vote_yescount));
3652 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);
3653 s = strcat("No: ", ftos(vote_nocount));
3654 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);
3656 // draw the progress bars
3657 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3658 drawpic_skin(pos, "voteprogress_prog", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3660 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3661 drawpic_skin(pos, "voteprogress_prog", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3663 // draw the highlights
3664 if(vote_highlighted == 1) {
3665 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3666 drawpic_skin(pos, "voteprogress_voted", mySize, eY, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3668 else if(vote_highlighted == 2) {
3669 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3670 drawpic_skin(pos, "voteprogress_voted", mySize, eX, a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
3673 drawresetcliparea();
3676 vote_highlighted = 0;
3680 // Mod icons panel (#10)
3683 float mod_active; // is there any active mod icon?
3685 // CTF HUD modicon section
3686 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3687 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3688 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3690 void HUD_Mod_CTF_Reset(void)
3692 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3695 void HUD_Mod_CTF(vector pos, vector mySize)
3697 vector redflag_pos, blueflag_pos;
3699 float f; // every function should have that
3701 float redflag, blueflag; // current status
3702 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3705 stat_items = getstati(STAT_ITEMS);
3706 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3707 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3709 if(redflag || blueflag)
3720 // when status CHANGES, set old status into prevstatus and current status into status
3721 if (redflag != redflag_prevframe)
3723 redflag_statuschange_time = time;
3724 redflag_prevstatus = redflag_prevframe;
3725 redflag_prevframe = redflag;
3728 if (blueflag != blueflag_prevframe)
3730 blueflag_statuschange_time = time;
3731 blueflag_prevstatus = blueflag_prevframe;
3732 blueflag_prevframe = blueflag;
3735 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3736 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3738 float BLINK_FACTOR = 0.15;
3739 float BLINK_BASE = 0.85;
3741 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3743 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3745 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3747 string red_icon, red_icon_prevstatus;
3748 float red_alpha, red_alpha_prevstatus;
3749 red_alpha = red_alpha_prevstatus = 1;
3751 case 1: red_icon = "flag_red_taken"; break;
3752 case 2: red_icon = "flag_red_lost"; break;
3753 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3755 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3756 red_icon = "flag_red_shielded";
3758 red_icon = string_null;
3761 switch(redflag_prevstatus) {
3762 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3763 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3764 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3767 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3768 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3769 red_icon_prevstatus = "flag_red_shielded";
3771 red_icon_prevstatus = string_null;
3775 string blue_icon, blue_icon_prevstatus;
3776 float blue_alpha, blue_alpha_prevstatus;
3777 blue_alpha = blue_alpha_prevstatus = 1;
3779 case 1: blue_icon = "flag_blue_taken"; break;
3780 case 2: blue_icon = "flag_blue_lost"; break;
3781 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3783 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3784 blue_icon = "flag_blue_shielded";
3786 blue_icon = string_null;
3789 switch(blueflag_prevstatus) {
3790 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3791 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3792 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3795 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3796 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3797 blue_icon_prevstatus = "flag_blue_shielded";
3799 blue_icon_prevstatus = string_null;
3803 if(mySize_x > mySize_y) {
3804 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3806 blueflag_pos = pos + eX * 0.5 * mySize_x;
3809 redflag_pos = pos + eX * 0.5 * mySize_x;
3811 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3813 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3815 blueflag_pos = pos + eY * 0.5 * mySize_y;
3818 redflag_pos = pos + eY * 0.5 * mySize_y;
3820 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3823 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3824 if(red_icon_prevstatus && f < 1)
3825 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);
3827 drawpic_skin(redflag_pos, red_icon, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * red_alpha * f, DRAWFLAG_NORMAL);
3829 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3830 if(blue_icon_prevstatus && f < 1)
3831 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);
3833 drawpic_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * blue_alpha * f, DRAWFLAG_NORMAL);
3836 // Keyhunt HUD modicon section
3837 float kh_runheretime;
3839 void HUD_Mod_KH_Reset(void)
3844 void HUD_Mod_KH(vector pos, vector mySize)
3846 mod_active = 1; // keyhunt should never hide the mod icons panel
3850 vector p, pa, kh_size, kh_asize;
3852 kh_keys = getstati(STAT_KH_KEYS);
3855 if(mySize_x > mySize_y)
3857 p_y = pos_y + 0.25 * mySize_y;
3858 pa = p - eY * 0.25 * mySize_y;
3860 kh_size_x = mySize_x * 0.25;
3861 kh_size_y = 0.75 * mySize_y;
3862 kh_asize_x = mySize_x * 0.25;
3863 kh_asize_y = mySize_y * 0.25;
3867 p_y = pos_y + 0.125 * mySize_y;
3868 pa = p - eY * 0.125 * mySize_y;
3870 kh_size_x = mySize_x * 0.5;
3871 kh_size_y = 0.375 * mySize_y;
3872 kh_asize_x = mySize_x * 0.5;
3873 kh_asize_y = mySize_y * 0.125;
3880 for(i = 0; i < 4; ++i)
3882 key = floor(kh_keys / pow(32, i)) & 31;
3884 if(keyteam == 30 && keycount <= 4)
3886 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3890 // this yields 8 exactly if "RUN HERE" shows
3895 kh_runheretime = time;
3896 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3901 for(i = 0; i < 4; ++i)
3903 key = floor(kh_keys / pow(32, i)) & 31;
3916 default: // owned or dropped
3921 a = a * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3922 aa = aa * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS);
3928 drawpic_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3931 drawpic_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3934 drawpic_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3937 drawpic_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3942 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3945 drawpic_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3948 drawpic_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3951 drawpic_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3954 drawpic_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3958 if(mySize_x > mySize_y)
3960 p_x += 0.25 * mySize_x;
3961 pa_x += 0.25 * mySize_x;
3967 p_y = pos_y + 0.625 * mySize_y;
3968 pa_y = pos_y + 0.5 * mySize_y;
3974 p_x += 0.5 * mySize_x;
3975 pa_x += 0.5 * mySize_x;
3981 // Nexball HUD mod icon
3982 void HUD_Mod_NexBall(vector pos, vector mySize)
3984 float stat_items, nb_pb_starttime, dt, p;
3986 stat_items = getstati(STAT_ITEMS);
3987 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3989 if (stat_items & IT_KEY1)
3994 //Manage the progress bar if any
3995 if (nb_pb_starttime > 0)
3997 dt = mod(time - nb_pb_starttime, nb_pb_period);
3998 // one period of positive triangle
3999 p = 2 * dt / nb_pb_period;
4006 if(mySize_x > mySize_y)
4008 barsize = eX * p * mySize_x + eY * mySize_y;
4013 barsize = eX * mySize_x + eY * p * mySize_y;
4016 HUD_Panel_DrawProgressBar(pos, vertical, barsize, HUD_Panel_GetProgressBarColor("nexball"), cvar("hud_progressbar_alpha") * HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4019 if (stat_items & IT_KEY1)
4020 drawpic_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4023 // Race/CTS HUD mod icons
4024 float crecordtime_prev; // last remembered crecordtime
4025 float crecordtime_change_time; // time when crecordtime last changed
4026 float srecordtime_prev; // last remembered srecordtime
4027 float srecordtime_change_time; // time when srecordtime last changed
4029 float race_status_time;
4030 float race_status_prev;
4031 string race_status_name_prev;
4032 void HUD_Mod_Race(vector pos, vector mySize)
4034 mod_active = 1; // race should never hide the mod icons panel
4036 me = playerslots[player_localentnum - 1];
4038 float f; // yet another function has this
4039 score = me.(scores[ps_primary]);
4041 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
4042 return; // no records in the actual race
4044 drawfont = hud_bigfont;
4046 // clientside personal record
4048 if(gametype == GAME_CTS)
4052 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
4054 if(score && (score < t || !t)) {
4055 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
4056 if(cvar("cl_autodemo_delete_keeprecords"))
4058 f = cvar("cl_autodemo_delete");
4060 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
4064 if(t != crecordtime_prev) {
4065 crecordtime_prev = t;
4066 crecordtime_change_time = time;
4068 f = time - crecordtime_change_time;
4071 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);
4072 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);
4074 drawstring(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL);
4075 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);
4076 drawstring_expanding(pos, "Personal best ", '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS), DRAWFLAG_NORMAL, f);
4077 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);
4081 t = race_server_record;
4082 if(t != srecordtime_prev) {
4083 srecordtime_prev = t;
4084 srecordtime_change_time = time;
4086 f = time - srecordtime_change_time;
4089 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);
4090 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);
4092 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);
4093 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);
4094 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);
4095 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);
4098 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4099 race_status_time = time + 5;
4100 race_status_prev = race_status;
4101 if (race_status_name_prev)
4102 strunzone(race_status_name_prev);
4103 race_status_name_prev = strzone(race_status_name);
4106 pos_x += mySize_x/2;
4109 a = bound(0, race_status_time - time, 1);
4112 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4116 rank = race_CheckName(race_status_name);
4118 rankname = race_PlaceName(rank);
4121 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4123 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4125 if(race_status == 0)
4126 drawpic_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4127 else if(race_status == 1) {
4128 drawpic_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4129 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4130 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4131 } else if(race_status == 2) {
4132 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4133 drawpic_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4135 drawpic_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4136 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4137 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4138 } else if(race_status == 3) {
4139 drawpic_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4140 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4141 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', HUD_Panel_GetFgAlpha(HUD_PANEL_MODICONS) * a, DRAWFLAG_NORMAL);
4144 if (race_status_time - time <= 0) {
4145 race_status_prev = -1;
4147 if(race_status_name)
4148 strunzone(race_status_name);
4149 race_status_name = string_null;
4150 if(race_status_name_prev)
4151 strunzone(race_status_name_prev);
4152 race_status_name_prev = string_null;
4154 drawfont = hud_font;
4157 float mod_prev; // previous state of mod_active to check for a change
4159 float mod_change; // "time" when mod_active changed
4161 void HUD_ModIcons(void)
4163 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !hud_configure)
4166 float id = HUD_PANEL_MODICONS;
4168 pos = HUD_Panel_GetPos(id);
4169 mySize = HUD_Panel_GetSize(id);
4171 if(mod_active != mod_prev) {
4173 mod_prev = mod_active;
4176 if(mod_active || hud_configure)
4177 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4179 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4182 HUD_Panel_DrawBg(id, pos, mySize, mod_alpha);
4185 padding = HUD_Panel_GetPadding(id);
4188 pos += '1 1 0' * padding;
4189 mySize -= '2 2 0' * padding;
4192 // these MUST be ran in order to update mod_active
4193 if(gametype == GAME_KEYHUNT)
4194 HUD_Mod_KH(pos, mySize);
4195 else if(gametype == GAME_CTF || hud_configure)
4196 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4197 else if(gametype == GAME_NEXBALL)
4198 HUD_Mod_NexBall(pos, mySize);
4199 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4200 HUD_Mod_Race(pos, mySize);
4203 // Draw pressed keys (#11)
4205 void HUD_DrawPressedKeys(void)
4207 float id = HUD_PANEL_PRESSEDKEYS;
4209 pos = HUD_Panel_GetPos(id);
4210 mySize = HUD_Panel_GetSize(id);
4212 HUD_Panel_DrawBg(id, pos, mySize, 0);
4214 padding = HUD_Panel_GetPadding(id);
4217 pos += '1 1 0' * padding;
4218 mySize -= '2 2 0' * padding;
4222 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4225 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4226 drawpic_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4227 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);
4228 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);
4229 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);
4230 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);
4231 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);
4234 // Handle chat as a panel (#12)
4238 float id = HUD_PANEL_CHAT;
4240 pos = HUD_Panel_GetPos(id);
4241 mySize = HUD_Panel_GetSize(id);
4243 HUD_Panel_DrawBg(id, pos, mySize, 0);
4245 padding = HUD_Panel_GetPadding(id);
4248 pos += '1 1 0' * padding;
4249 mySize -= '2 2 0' * padding;
4252 cvar_set("con_chatrect", "1");
4254 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4255 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4257 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4258 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4263 chatsize = cvar("con_chatsize");
4264 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4266 for(i = 0; i < cvar("con_chat"); ++i)
4268 if(i == cvar("con_chat") - 1)
4269 a = HUD_Panel_GetFgAlpha(id);
4271 a = HUD_Panel_GetFgAlpha(id) * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4272 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);
4277 // Engine info panel (#13)
4284 float frametimeavg1; // 1 frame ago
4285 float frametimeavg2; // 2 frames ago
4286 void HUD_EngineInfo(void)
4288 float id = HUD_PANEL_ENGINEINFO;
4290 pos = HUD_Panel_GetPos(id);
4291 mySize = HUD_Panel_GetSize(id);
4293 HUD_Panel_DrawBg(id, pos, mySize, 0);
4295 padding = HUD_Panel_GetPadding(id);
4298 pos += '1 1 0' * padding;
4299 mySize -= '2 2 0' * padding;
4302 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4304 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4305 frametimeavg2 = frametimeavg1;
4306 frametimeavg1 = frametimeavg;
4309 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4310 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.
4312 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
4313 prevfps = (1/frametime);
4314 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"
4320 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4322 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4324 prevfps_time = time;
4329 color = HUD_Get_Num_Color (prevfps, 100);
4330 drawfont = hud_bigfont;
4331 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), mySize, mySize_y, color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
4332 drawfont = hud_font;
4340 void HUD_ShowSpeed(void)
4343 float pos, conversion_factor;
4344 string speed, zspeed, unit;
4346 switch(cvar("cl_showspeed_unit"))
4351 conversion_factor = 1.0;
4355 conversion_factor = 1.0;
4359 conversion_factor = 0.0254;
4363 conversion_factor = 0.0254 * 3.6;
4367 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4371 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4375 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4377 numsize_x = numsize_y = cvar("cl_showspeed_size");
4378 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4380 drawfont = hud_bigfont;
4381 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4383 if (cvar("cl_showspeed_z") == 1) {
4384 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4385 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4388 drawfont = hud_font;
4391 vector acc_prevspeed;
4395 void HUD_ShowAcceleration(void)
4397 float acceleration, sz, scale, alpha, f;
4398 vector pos, top, rgb;
4399 top_x = vid_conwidth/2;
4402 f = time - acc_prevtime;
4403 if(cvar("cl_showacceleration_z"))
4404 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4406 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4407 acc_prevspeed = pmove_vel;
4408 acc_prevtime = time;
4410 f = bound(0, f * 10, 1);
4411 acc_avg = acc_avg * (1 - f) + acceleration * f;
4412 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4414 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4416 sz = cvar("cl_showacceleration_size");
4417 scale = cvar("cl_showacceleration_scale");
4418 alpha = cvar("cl_showacceleration_alpha");
4419 if (cvar("cl_showacceleration_color_custom"))
4420 rgb = stov(cvar_string("cl_showacceleration_color"));
4423 if (acceleration < 0) {
4424 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4425 } else if (acceleration > 0) {
4426 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4430 if (acceleration > 0)
4431 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4432 else if (acceleration < 0)
4433 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4436 void HUD_Reset (void)
4438 // reset gametype specific icons
4439 if(gametype == GAME_KEYHUNT)
4441 else if(gametype == GAME_CTF)
4442 HUD_Mod_CTF_Reset();
4445 void HUD_Main (void)
4447 if(disable_menu_alphacheck == 1)
4448 menu_fade_alpha = 1;
4450 menu_fade_alpha = (1 - cvar("_menu_alpha"));
4451 hud_fg_alpha = cvar("hud_fg_alpha");
4453 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4454 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4455 hud_color_bg_team = cvar("hud_color_bg_team");
4457 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4458 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4460 hud_configure = cvar("_hud_configure");
4464 // HUD configure visible grid
4465 if(hud_configure && cvar("hud_configure_grid") && cvar("hud_configure_grid_alpha"))
4469 for(i = 0; i < 1/bound(0.005, cvar("hud_configure_grid_x"), 0.2); ++i)
4471 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);
4474 for(i = 0; i < 1/bound(0.005, cvar("hud_configure_grid_y"), 0.2); ++i)
4476 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);
4480 if(cvar_string("hud_dock") != "" && cvar_string("hud_dock") != "0")
4481 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...
4483 if(HUD_Panel_CheckActive(HUD_PANEL_RADAR) || hud_configure)
4484 if(cvar_string("hud_radar") != "0" && (cvar("hud_radar") == 2 || teamplay))
4486 if(HUD_Panel_CheckActive(HUD_PANEL_WEAPONICONS) || hud_configure)
4488 if(HUD_Panel_CheckActive(HUD_PANEL_INVENTORY) || hud_configure)
4490 if(HUD_Panel_CheckActive(HUD_PANEL_POWERUPS) || hud_configure)
4492 if(HUD_Panel_CheckActive(HUD_PANEL_HEALTHARMOR) || hud_configure)
4494 if(HUD_Panel_CheckActive(HUD_PANEL_NOTIFY) || hud_configure)
4496 if(HUD_Panel_CheckActive(HUD_PANEL_TIMER) || hud_configure)
4498 if(HUD_Panel_CheckActive(HUD_PANEL_SCORE) || hud_configure)
4500 if(HUD_Panel_CheckActive(HUD_PANEL_RACETIMER) || hud_configure)
4501 if(gametype == GAME_RACE || gametype == GAME_CTS || hud_configure)
4503 if(HUD_Panel_CheckActive(HUD_PANEL_VOTE) || hud_configure)
4505 if(HUD_Panel_CheckActive(HUD_PANEL_MODICONS) || hud_configure)
4508 if(HUD_Panel_CheckActive(HUD_PANEL_PRESSEDKEYS) || hud_configure)
4509 if(spectatee_status > 0 || cvar("hud_pressedkeys") >= 2 || hud_configure)
4510 HUD_DrawPressedKeys();
4511 if(HUD_Panel_CheckActive(HUD_PANEL_CHAT) || hud_configure)
4514 cvar_set("con_chatrect", "0");
4515 if(HUD_Panel_CheckActive(HUD_PANEL_ENGINEINFO) || hud_configure)
4518 // TODO hud_'ify these
4519 if (cvar("cl_showspeed"))
4521 if (cvar("cl_showacceleration"))
4522 HUD_ShowAcceleration();
4524 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)
4525 localcmd("cmd selectteam auto; cmd join\n");
4527 if (!hud_configure) // hud config mode disabled, enable normal alpha stuff again
4528 disable_menu_alphacheck = 0;