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 vector HUD_Get_Num_Color (float x, float maxvalue)
93 else if(x > maxvalue * 0.75) {
94 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
95 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
98 else if(x > maxvalue * 0.5) {
99 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
100 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
101 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
103 else if(x > maxvalue * 0.25) {
106 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
108 else if(x > maxvalue * 0.1) {
110 color_y = (x-20)*90/27/100; // green value between 0 -> 1
111 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
121 float stringwidth_colors(string s, vector theSize)
123 return stringwidth(s, TRUE, theSize);
126 float stringwidth_nocolors(string s, vector theSize)
128 return stringwidth(s, FALSE, theSize);
131 #define CENTERPRINT_MAX_LINES 30
132 string centerprint_messages[CENTERPRINT_MAX_LINES];
133 float centerprint_width[CENTERPRINT_MAX_LINES];
134 vector centerprint_start;
135 float centerprint_expire;
136 float centerprint_num;
137 float centerprint_offset_hint;
138 vector centerprint_fontsize;
140 void centerprint(string strMessage)
142 float i, j, n, hcount;
145 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
147 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
149 if(cvar("scr_centertime") <= 0)
155 // strip trailing newlines
156 j = strlen(strMessage) - 1;
157 while(substring(strMessage, j, 1) == "\n" && j >= 0)
159 strMessage = substring(strMessage, 0, j + 1);
164 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
166 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
168 strMessage = substring(strMessage, j, strlen(strMessage) - j);
169 centerprint_offset_hint = j;
174 // if we get here, we have a message. Initialize its height.
177 n = tokenizebyseparator(strMessage, "\n");
179 for(j = 0; j < n; ++j)
181 getWrappedLine_remaining = argv(j);
182 while(getWrappedLine_remaining)
184 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
185 if(centerprint_messages[i])
186 strunzone(centerprint_messages[i]);
187 centerprint_messages[i] = strzone(s);
188 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
191 // half height for empty lines looks better
197 if(i >= CENTERPRINT_MAX_LINES)
203 h = centerprint_fontsize_y*hcount;
205 havail = vid_conheight;
206 if(cvar("con_chatpos") < 0)
207 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
208 if(havail > vid_conheight - 70)
209 havail = vid_conheight - 70; // avoid overlapping HUD
211 centerprint_start_x = 0;
214 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
216 // here, the centerprint would cover the crosshair. REALLY BAD.
217 forbiddenmin = vid_conheight * 0.5 - h - 16;
218 forbiddenmax = vid_conheight * 0.5 + 16;
220 allowedmin = scoreboard_bottom;
221 allowedmax = havail - h;
222 preferred = (havail - h)/2;
225 // possible orderings (total: 4! / 4 = 6)
226 // allowedmin allowedmax forbiddenmin forbiddenmax
227 // forbiddenmin forbiddenmax allowedmin allowedmax
228 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
230 // forbidden doesn't matter in this case
231 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
233 // allowedmin forbiddenmin allowedmax forbiddenmax
234 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
236 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
238 // allowedmin forbiddenmin forbiddenmax allowedmax
239 else if(allowedmin < forbiddenmin)
241 // make sure the forbidden zone is not covered
242 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
243 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
245 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
247 // forbiddenmin allowedmin allowedmax forbiddenmax
248 else if(allowedmax < forbiddenmax)
250 // it's better to leave the allowed zone (overlap with scoreboard) than
251 // to cover the forbidden zone (crosshair)
252 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
253 centerprint_start_y = forbiddenmax;
255 centerprint_start_y = forbiddenmin;
257 // forbiddenmin allowedmin forbiddenmax allowedmax
260 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
263 centerprint_start_y =
266 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
274 centerprint_expire = time + cvar("scr_centertime");
277 void HUD_DrawCenterPrint (void)
284 //if(time > centerprint_expire)
287 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
288 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
289 //sz = 1.2 / (a + 0.2);
294 pos = centerprint_start;
295 for (i=0; i<centerprint_num; i = i + 1)
297 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
298 ts = centerprint_messages[i];
301 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
302 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
303 pos_y = pos_y + centerprint_fontsize_y;
306 // half height for empty lines looks better
307 pos_y = pos_y + centerprint_fontsize_y * 0.5;
311 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
313 position_x -= 2 / 3 * strlen(text) * scale_x;
314 drawstring(position, text, scale, rgb, alpha, flag);
317 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
319 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
320 drawstring(position, text, scale, rgb, alpha, flag);
323 // return the string of the given race place
324 string race_PlaceName(float pos) {
332 return strcat(ftos(pos), "th");
335 // return the string of the onscreen race timer
336 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
344 if(histime == 0) // goal hit
348 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
358 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
364 lapstr = strcat(" (-", ftos(lapdelta), "L)");
367 else if(lapdelta < 0)
369 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
373 else if(histime > 0) // anticipation
375 if(mytime >= histime)
376 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
378 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
385 cpname = "Start line";
387 cpname = "Finish line";
389 cpname = strcat("Intermediate ", ftos(cp));
391 cpname = "Finish line";
394 return strcat(col, cpname);
395 else if(hisname == "")
396 return strcat(col, cpname, " (", timestr, ")");
398 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
401 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
402 float race_CheckName(string net_name) {
404 for (i=RANKINGS_CNT-1;i>=0;--i)
405 if(grecordholder[i] == net_name)
417 void HUD_Panel_ExportCfg(string cfgname)
420 fh = fopen(strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg"), FILE_WRITE);
423 fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
424 fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
425 fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
426 fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
427 fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
428 fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
429 fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
430 fputs(fh, strcat("seta hud_fg_alpha \"", cvar_string("hud_fg_alpha"), "\"", "\n"));
433 fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
434 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
435 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
436 fputs(fh, strcat("seta hud_dock_alpha \"", cvar_string("hud_dock_alpha"), "\"", "\n"));
439 fputs(fh, strcat("seta hud_progressbar_alpha \"", cvar_string("hud_progressbar_alpha"), "\"", "\n"));
440 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
441 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
442 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
443 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
444 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
445 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
448 fputs(fh, strcat("seta _hud_panelorder \"", cvar_string("_hud_panelorder"), "\"", "\n"));
451 // common cvars for all panels
453 for (i = 0; i < HUD_PANEL_NUM; ++i)
457 fputs(fh, strcat("seta hud_", panel_name, " ", cvar_string(strcat("hud_", panel_name)), "\n"));
458 fputs(fh, strcat("seta hud_", panel_name, "_pos \"", cvar_string(strcat("hud_", panel_name, "_pos")), "\"", "\n"));
459 fputs(fh, strcat("seta hud_", panel_name, "_size \"", cvar_string(strcat("hud_", panel_name, "_size")), "\"", "\n"));
460 fputs(fh, strcat("seta hud_", panel_name, "_bg \"", cvar_string(strcat("hud_", panel_name, "_bg")), "\"", "\n"));
461 fputs(fh, strcat("seta hud_", panel_name, "_bg_color \"", cvar_string(strcat("hud_", panel_name, "_bg_color")), "\"", "\n"));
462 fputs(fh, strcat("seta hud_", panel_name, "_bg_color_team \"", cvar_string(strcat("hud_", panel_name, "_bg_color_team")), "\"", "\n"));
463 fputs(fh, strcat("seta hud_", panel_name, "_bg_alpha \"", cvar_string(strcat("hud_", panel_name, "_bg_alpha")), "\"", "\n"));
464 fputs(fh, strcat("seta hud_", panel_name, "_bg_border \"", cvar_string(strcat("hud_", panel_name, "_bg_border")), "\"", "\n"));
465 fputs(fh, strcat("seta hud_", panel_name, "_bg_padding \"", cvar_string(strcat("hud_", panel_name, "_bg_padding")), "\"", "\n"));
467 case HUD_PANEL_WEAPONICONS:
468 fputs(fh, strcat("seta hud_", panel_name, "_complainbubble \"", cvar_string(strcat("hud_", panel_name, "_complainbubble")), "\"", "\n"));
469 fputs(fh, strcat("seta hud_", panel_name, "_complainbubble_padding \"", cvar_string(strcat("hud_", panel_name, "_complainbubble_padding")), "\"", "\n"));
470 fputs(fh, strcat("seta hud_", panel_name, "_complainbubble_color_outofammo \"", cvar_string(strcat("hud_", panel_name, "_complainbubble_color_outofammo")), "\"", "\n"));
471 fputs(fh, strcat("seta hud_", panel_name, "_complainbubble_color_donthave \"", cvar_string(strcat("hud_", panel_name, "_complainbubble_color_donthave")), "\"", "\n"));
472 fputs(fh, strcat("seta hud_", panel_name, "_complainbubble_color_unavailable \"", cvar_string(strcat("hud_", panel_name, "_complainbubble_color_unavailable")), "\"", "\n"));
473 fputs(fh, strcat("seta hud_", panel_name, "_ammo_color \"", cvar_string(strcat("hud_", panel_name, "_ammo_color")), "\"", "\n"));
474 fputs(fh, strcat("seta hud_", panel_name, "_ammo_alpha \"", cvar_string(strcat("hud_", panel_name, "_ammo_alpha")), "\"", "\n"));
475 fputs(fh, strcat("seta hud_", panel_name, "_aspect \"", cvar_string(strcat("hud_", panel_name, "_ammo_alpha")), "\"", "\n"));
477 case HUD_PANEL_INVENTORY:
478 fputs(fh, strcat("seta hud_", panel_name, "_onlycurrent \"", cvar_string(strcat("hud_", panel_name, "_onlycurrent")), "\"", "\n"));
479 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
481 case HUD_PANEL_POWERUPS:
482 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\"", "\n"));
483 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
484 fputs(fh, strcat("seta hud_", panel_name, "_baralign \"", cvar_string(strcat("hud_", panel_name, "_baralign")), "\"", "\n"));
486 case HUD_PANEL_HEALTHARMOR:
487 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\n"));
488 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
489 fputs(fh, strcat("seta hud_", panel_name, "_baralign \"", cvar_string(strcat("hud_", panel_name, "_baralign")), "\"", "\n"));
491 case HUD_PANEL_NOTIFY:
492 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\"", "\n"));
493 fputs(fh, strcat("seta hud_", panel_name, "_print \"", cvar_string(strcat("hud_", panel_name, "_print")), "\"", "\n"));
495 case HUD_PANEL_RADAR:
496 fputs(fh, strcat("seta hud_", panel_name, "_foreground_alpha \"", cvar_string(strcat("hud_", panel_name, "_foreground_alpha")), "\"", "\n"));
499 fputs(fh, strcat("seta hud_", panel_name, "_alreadyvoted_alpha \"", cvar_string(strcat("hud_", panel_name, "_alreadyvoted_alpha")), "\"", "\n"));
501 case HUD_PANEL_PRESSEDKEYS:
502 fputs(fh, strcat("seta hud_", panel_name, "_aspect \"", cvar_string(strcat("hud_", panel_name, "_aspect")), "\"", "\n"));
508 print("^2Successfully exported to hud_", autocvar_hud_skin, "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
513 const float hlBorderSize = 4;
514 const string hlBorder = "gfx/hud/default/border_highlighted";
515 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
516 void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
518 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
519 drawpic_tiled(panel_pos - '1 1 0' * myBorder, hlBorder, '8 1 0' * hlBorderSize, eX * (panel_size_x + 2 * myBorder) + eY * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
520 drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * (panel_size_y + 2 * myBorder - hlBorderSize), hlBorder, '8 1 0' * hlBorderSize, eX * (panel_size_x + 2 * myBorder) + eY * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
521 drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * hlBorderSize, hlBorder2, '1 8 0' * hlBorderSize, eY * (panel_size_y + 2 * myBorder - 2 * hlBorderSize) + eX * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
522 drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * hlBorderSize + eX * (panel_size_x + 2 * myBorder - hlBorderSize), hlBorder2, '1 8 0' * hlBorderSize, eY * (panel_size_y + 2 * myBorder - 2 * hlBorderSize) + eX * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
525 // draw the background/borders
526 #define HUD_Panel_DrawBg(alpha)\
528 draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * alpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));\
529 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
530 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);
532 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
539 pic = strcat(hud_skin_path, "/statusbar_vertical");
540 if(precache_pic(pic) == "") {
541 pic = "gfx/hud/default/statusbar_vertical";
543 drawsubpic(pos, eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, pic, '0 0 0', '1 0.25 0', color, alpha, drawflag);
544 if(mySize_y/mySize_x > 2)
545 drawsubpic(pos + eY * mySize_x, eY * (mySize_y - 2 * mySize_x) + eX * mySize_x, pic, '0 0.25 0', '1 0.5 0', color, alpha, drawflag);
546 drawsubpic(pos + eY * mySize_y - eY * min(mySize_y * 0.5, mySize_x), eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, pic, '0 0.75 0', '1 0.25 0', color, alpha, drawflag);
548 pic = strcat(hud_skin_path, "/statusbar");
549 if(precache_pic(pic) == "") {
550 pic = "gfx/hud/default/statusbar";
552 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
553 if(mySize_x/mySize_y > 2)
554 drawsubpic(pos + eX * mySize_y, eX * (mySize_x - 2 * mySize_y) + eY * mySize_y, pic, '0.25 0 0', '0.5 1 0', color, alpha, drawflag);
555 drawsubpic(pos + eX * mySize_x - eX * min(mySize_x * 0.5, mySize_y), eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0.75 0 0', '0.25 1 0', color, alpha, drawflag);
559 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
565 pic = strcat(hud_skin_path, "/num_leading");
566 if(precache_pic(pic) == "") {
567 pic = "gfx/hud/default/num_leading";
570 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
571 if(mySize_x/mySize_y > 2)
572 drawsubpic(pos + eX * mySize_y, eX * (mySize_x - 2 * mySize_y) + eY * mySize_y, pic, '0.25 0 0', '0.5 1 0', color, alpha, drawflag);
573 drawsubpic(pos + eX * mySize_x - eX * min(mySize_x * 0.5, mySize_y), eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0.75 0 0', '0.25 1 0', color, alpha, drawflag);
576 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
577 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
588 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
589 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
591 for (i = 0; i < HUD_PANEL_NUM; ++i) {
592 if(i == highlightedPanel || !panel_enabled)
595 HUD_Panel_UpdatePosSizeForId(i)
597 panel_pos -= '1 1 0' * panel_bg_border;
598 panel_size += '2 2 0' * panel_bg_border;
600 if(myPos_y + mySize_y < panel_pos_y)
602 if(myPos_y > panel_pos_y + panel_size_y)
605 if(myPos_x + mySize_x < panel_pos_x)
607 if(myPos_x > panel_pos_x + panel_size_x)
610 // OK, there IS a collision.
612 myCenter_x = myPos_x + 0.5 * mySize_x;
613 myCenter_y = myPos_y + 0.5 * mySize_y;
615 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
616 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
618 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
620 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
621 myTarget_x = panel_pos_x - mySize_x;
622 else // push it upwards
623 myTarget_y = panel_pos_y - mySize_y;
625 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
627 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
628 myTarget_x = panel_pos_x + panel_size_x;
629 else // push it upwards
630 myTarget_y = panel_pos_y - mySize_y;
632 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
634 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
635 myTarget_x = panel_pos_x - mySize_x;
636 else // push it downwards
637 myTarget_y = panel_pos_y + panel_size_y;
639 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
641 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
642 myTarget_x = panel_pos_x + panel_size_x;
643 else // push it downwards
644 myTarget_y = panel_pos_y + panel_size_y;
646 if(cvar("hud_configure_checkcollisions_debug"))
647 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
653 void HUD_Panel_SetPos(vector pos)
655 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
659 if(cvar("hud_configure_checkcollisions_debug"))
660 drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
662 if(autocvar_hud_configure_grid)
664 pos_x = floor((pos_x/vid_conwidth)/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
665 pos_y = floor((pos_y/vid_conheight)/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
668 if(hud_configure_checkcollisions)
669 pos = HUD_Panel_CheckMove(pos, mySize);
671 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
672 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
675 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
677 HUD_Panel_GetName(highlightedPanel);
678 cvar_set(strcat("hud_", panel_name, "_pos"), s);
681 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
682 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
692 ratio = mySize_x/mySize_y;
694 for (i = 0; i < HUD_PANEL_NUM; ++i) {
695 if(i == highlightedPanel || !panel_enabled)
698 HUD_Panel_UpdatePosSizeForId(i)
700 panel_pos -= '1 1 0' * panel_bg_border;
701 panel_size += '2 2 0' * panel_bg_border;
703 targEndPos = panel_pos + panel_size;
705 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
706 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
709 if (resizeCorner == 1)
711 // check if this panel is on our way
712 if (resizeorigin_x <= panel_pos_x)
714 if (resizeorigin_y <= panel_pos_y)
716 if (targEndPos_x <= resizeorigin_x - mySize_x)
718 if (targEndPos_y <= resizeorigin_y - mySize_y)
721 // there is a collision:
722 // detect which side of the panel we are facing is actually limiting the resizing
723 // (which side the resize direction finds for first) and reduce the size up to there
725 // dist is the distance between resizeorigin and the "analogous" point of the panel
726 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
727 dist_x = resizeorigin_x - targEndPos_x;
728 dist_y = resizeorigin_y - targEndPos_y;
729 if (dist_y <= 0 || dist_x / dist_y > ratio)
730 mySize_x = min(mySize_x, dist_x);
732 mySize_y = min(mySize_y, dist_y);
734 else if (resizeCorner == 2)
736 if (resizeorigin_x >= targEndPos_x)
738 if (resizeorigin_y <= panel_pos_y)
740 if (panel_pos_x >= resizeorigin_x + mySize_x)
742 if (targEndPos_y <= resizeorigin_y - mySize_y)
745 dist_x = panel_pos_x - resizeorigin_x;
746 dist_y = resizeorigin_y - targEndPos_y;
747 if (dist_y <= 0 || dist_x / dist_y > ratio)
748 mySize_x = min(mySize_x, dist_x);
750 mySize_y = min(mySize_y, dist_y);
752 else if (resizeCorner == 3)
754 if (resizeorigin_x <= panel_pos_x)
756 if (resizeorigin_y >= targEndPos_y)
758 if (targEndPos_x <= resizeorigin_x - mySize_x)
760 if (panel_pos_y >= resizeorigin_y + mySize_y)
763 dist_x = resizeorigin_x - targEndPos_x;
764 dist_y = panel_pos_y - resizeorigin_y;
765 if (dist_y <= 0 || dist_x / dist_y > ratio)
766 mySize_x = min(mySize_x, dist_x);
768 mySize_y = min(mySize_y, dist_y);
770 else if (resizeCorner == 4)
772 if (resizeorigin_x >= targEndPos_x)
774 if (resizeorigin_y >= targEndPos_y)
776 if (panel_pos_x >= resizeorigin_x + mySize_x)
778 if (panel_pos_y >= resizeorigin_y + mySize_y)
781 dist_x = panel_pos_x - resizeorigin_x;
782 dist_y = panel_pos_y - resizeorigin_y;
783 if (dist_y <= 0 || dist_x / dist_y > ratio)
784 mySize_x = min(mySize_x, dist_x);
786 mySize_y = min(mySize_y, dist_y);
788 if(cvar("hud_configure_checkcollisions_debug"))
789 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
795 void HUD_Panel_SetPosSize(vector mySize)
797 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
799 resizeorigin = panel_click_resizeorigin;
802 // minimum panel size cap
803 mySize_x = max(0.025 * vid_conwidth, mySize_x);
804 mySize_y = max(0.025 * vid_conheight, mySize_y);
806 if(highlightedPanel == HUD_PANEL_CHAT) // some panels have their own restrictions, like the chat panel (which actually only moves the engine chat print around). Looks bad if it's too small.
808 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
809 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
812 // collision testing|
813 // -----------------+
815 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
816 if(resizeCorner == 1) {
817 myPos_x = resizeorigin_x - mySize_x;
818 myPos_y = resizeorigin_y - mySize_y;
819 } else if(resizeCorner == 2) {
820 myPos_x = resizeorigin_x;
821 myPos_y = resizeorigin_y - mySize_y;
822 } else if(resizeCorner == 3) {
823 myPos_x = resizeorigin_x - mySize_x;
824 myPos_y = resizeorigin_y;
825 } else { // resizeCorner == 4
826 myPos_x = resizeorigin_x;
827 myPos_y = resizeorigin_y;
830 // left/top screen edges
832 mySize_x = mySize_x + myPos_x;
834 mySize_y = mySize_y + myPos_y;
836 // bottom/right screen edges
837 if(myPos_x + mySize_x > vid_conwidth)
838 mySize_x = vid_conwidth - myPos_x;
839 if(myPos_y + mySize_y > vid_conheight)
840 mySize_y = vid_conheight - myPos_y;
842 if(cvar("hud_configure_checkcollisions_debug"))
843 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
845 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
846 if(autocvar_hud_configure_grid)
848 mySize_x = floor((mySize_x/vid_conwidth)/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
849 mySize_y = floor((mySize_y/vid_conheight)/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
852 if(hud_configure_checkcollisions)
853 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
855 // 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)
856 mySize_x = max(0.025 * vid_conwidth, mySize_x);
857 mySize_y = max(0.025 * vid_conheight, mySize_y);
859 // do another pos check, as size might have changed by now
860 if(resizeCorner == 1) {
861 myPos_x = resizeorigin_x - mySize_x;
862 myPos_y = resizeorigin_y - mySize_y;
863 } else if(resizeCorner == 2) {
864 myPos_x = resizeorigin_x;
865 myPos_y = resizeorigin_y - mySize_y;
866 } else if(resizeCorner == 3) {
867 myPos_x = resizeorigin_x - mySize_x;
868 myPos_y = resizeorigin_y;
869 } else { // resizeCorner == 4
870 myPos_x = resizeorigin_x;
871 myPos_y = resizeorigin_y;
874 if(cvar("hud_configure_checkcollisions_debug"))
875 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
877 HUD_Panel_GetName(highlightedPanel);
879 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
880 cvar_set(strcat("hud_", panel_name, "_size"), s);
882 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
883 cvar_set(strcat("hud_", panel_name, "_pos"), s);
887 float prevMouseClicked; // previous state
888 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
889 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
892 float menu_enabled_time;
893 float pressed_key_time;
894 void HUD_Panel_Arrow_Action(float nPrimary)
896 if (highlightedPanel_prev == -1 || mouseClicked)
899 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
902 if(autocvar_hud_configure_grid)
904 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
906 if (hudShiftState & S_SHIFT)
907 step = bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
909 step = 2 * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
913 if (hudShiftState & S_SHIFT)
914 step = bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
916 step = 2 * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
921 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
922 step = vid_conheight;
925 if (hudShiftState & S_SHIFT)
926 step = (step / 256); // more precision
928 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
931 highlightedPanel = highlightedPanel_prev;
933 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
935 if (hudShiftState & S_ALT) // resize
937 highlightedAction = 1;
938 if(nPrimary == K_UPARROW)
940 else if(nPrimary == K_RIGHTARROW)
942 else if(nPrimary == K_LEFTARROW)
944 else // if(nPrimary == K_DOWNARROW)
947 // ctrl+arrow reduces the size, instead of increasing it
948 // Note that ctrl disables collisions check too, but it's fine
949 // since we don't collide with anything reducing the size
950 if (hudShiftState & S_CTRL) {
952 resizeCorner = 5 - resizeCorner;
957 panel_click_resizeorigin = panel_pos;
958 if(resizeCorner == 1) {
959 panel_click_resizeorigin += mySize;
961 } else if(resizeCorner == 2) {
962 panel_click_resizeorigin_y += mySize_y;
964 } else if(resizeCorner == 3) {
965 panel_click_resizeorigin_x += mySize_x;
967 } else { // resizeCorner == 4
970 HUD_Panel_SetPosSize(mySize);
974 highlightedAction = 2;
977 if(nPrimary == K_UPARROW)
979 else if(nPrimary == K_DOWNARROW)
981 else if(nPrimary == K_LEFTARROW)
983 else // if(nPrimary == K_RIGHTARROW)
986 HUD_Panel_SetPos(pos);
990 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
992 if(!autocvar__hud_configure)
995 // allow console bind to work
998 con_keys = findkeysforcommand("toggleconsole");
999 keys = tokenize(con_keys);
1001 float hit_con_bind, i;
1002 for (i = 0; i < keys; ++i)
1004 if(nPrimary == stof(argv(i)))
1008 if(bInputType == 0) {
1009 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1010 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1011 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1013 else if(bInputType == 1) {
1014 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1015 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1016 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1019 if(nPrimary == K_MOUSE1)
1021 if(bInputType == 0) { // key pressed
1025 else if(bInputType == 1) {// key released
1030 else if(nPrimary == K_ESCAPE)
1032 if (bInputType == 1)
1034 disable_menu_alphacheck = 1;
1036 menu_enabled_time = time;
1037 localcmd("menu_showhudexit\n");
1039 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1041 if (bInputType == 1)
1043 pressed_key_time = 0;
1046 else if (pressed_key_time == 0)
1047 pressed_key_time = time;
1049 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1051 else if(hit_con_bind)
1054 return true; // Suppress ALL other input
1057 float HUD_Panel_HighlightCheck()
1063 while(j <= HUD_PANEL_NUM)
1068 HUD_Panel_UpdatePosSizeForId(i)
1070 panelPos = panel_pos;
1071 panelSize = panel_size;
1072 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1075 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1079 // resize from topleft border
1080 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)
1084 // resize from topright border
1085 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)
1089 // resize from bottomleft border
1090 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)
1094 // resize from bottomright border
1095 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)
1103 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1104 void HUD_Panel_FirstInDrawQ(float id)
1107 var float place = -1;
1108 // find out where in the array our current id is, save into place
1109 for(i = 0; i < HUD_PANEL_NUM; ++i)
1111 if(panel_order[i] == id)
1117 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1119 place = HUD_PANEL_NUM - 1;
1121 // move all ids up by one step in the array until "place"
1122 for(i = place; i > 0; --i)
1124 panel_order[i] = panel_order[i-1];
1126 // now save the new top id
1127 panel_order[0] = id;
1129 // let's save them into the cvar by some strcat trickery
1131 for(i = 0; i < HUD_PANEL_NUM; ++i)
1133 s = strcat(s, ftos(panel_order[i]), " ");
1135 cvar_set("_hud_panelorder", s);
1136 if(hud_panelorder_prev)
1137 strunzone(hud_panelorder_prev);
1138 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1141 void HUD_Panel_Highlight()
1147 while(j <= HUD_PANEL_NUM)
1152 HUD_Panel_UpdatePosSizeForId(i)
1154 panelPos = panel_pos;
1155 panelSize = panel_size;
1156 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1159 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1161 highlightedPanel = i;
1162 HUD_Panel_FirstInDrawQ(i);
1163 highlightedAction = 1;
1164 panel_click_distance = mousepos - panelPos;
1167 // resize from topleft border
1168 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)
1170 highlightedPanel = i;
1171 HUD_Panel_FirstInDrawQ(i);
1172 highlightedAction = 2;
1174 panel_click_distance = mousepos - panelPos;
1175 panel_click_resizeorigin = panelPos + panelSize;
1178 // resize from topright border
1179 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)
1181 highlightedPanel = i;
1182 HUD_Panel_FirstInDrawQ(i);
1183 highlightedAction = 2;
1185 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1186 panel_click_distance_y = mousepos_y - panelPos_y;
1187 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1190 // resize from bottomleft border
1191 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)
1193 highlightedPanel = i;
1194 HUD_Panel_FirstInDrawQ(i);
1195 highlightedAction = 2;
1197 panel_click_distance_x = mousepos_x - panelPos_x;
1198 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1199 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1202 // resize from bottomright border
1203 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)
1205 highlightedPanel = i;
1206 HUD_Panel_FirstInDrawQ(i);
1207 highlightedAction = 2;
1209 panel_click_distance = panelSize - mousepos + panelPos;
1210 panel_click_resizeorigin = panelPos;
1215 highlightedPanel_prev = -1;
1220 float highlightcheck;
1221 void HUD_Panel_Mouse()
1223 // 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
1224 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1225 disable_menu_alphacheck = 0;
1226 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1230 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1231 print("Highlighted: ", ftos(highlightedPanel), "\n");
1232 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1235 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1236 highlightedPanel = -1;
1237 highlightedAction = 0;
1239 if(highlightedPanel != -1)
1240 highlightedPanel_prev = highlightedPanel;
1242 mousepos = mousepos + getmousepos() * cvar("menu_mouse_speed");
1244 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1245 mousepos_y = bound(0, mousepos_y, vid_conheight);
1249 if(prevMouseClicked == 0)
1250 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1252 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1254 if(highlightedAction == 1)
1255 HUD_Panel_SetPos(mousepos - panel_click_distance);
1256 else if(highlightedAction == 2)
1259 if(resizeCorner == 1) {
1260 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1261 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1262 } else if(resizeCorner == 2) {
1263 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1264 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1265 } else if(resizeCorner == 3) {
1266 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1267 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1268 } else { // resizeCorner == 4
1269 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1270 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1272 HUD_Panel_SetPosSize(mySize);
1275 // doubleclick check
1276 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1278 mouseClicked = 0; // to prevent spam, I guess.
1279 disable_menu_alphacheck = 2;
1281 menu_enabled_time = time;
1282 HUD_Panel_GetName(highlightedPanel)
1283 localcmd("menu_showhudoptions ", panel_name, "\n");
1286 if(prevMouseClicked == 0)
1288 prevMouseClickedTime = time;
1289 prevMouseClickedPos = mousepos;
1294 highlightcheck = HUD_Panel_HighlightCheck();
1296 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1299 cursorsize = '32 32 0';
1301 if(highlightcheck == 0)
1302 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1303 else if(highlightcheck == 1)
1304 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1305 else if(highlightcheck == 2)
1306 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1308 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1310 prevMouseClicked = mouseClicked;
1313 // Weapon icons (#0)
1315 float weaponspace[10];
1316 #define HUD_WeaponIcons_Clear()\
1318 for(idx = 0; idx < 10; ++idx)\
1319 weaponspace[idx] = 0;
1321 entity weaponorder[WEP_MAXCOUNT];
1322 void weaponorder_swap(float i, float j, entity pass)
1326 weaponorder[i] = weaponorder[j];
1330 string weaponorder_cmp_str_save;
1331 string weaponorder_cmp_str;
1332 float weaponorder_cmp(float i, float j, entity pass)
1335 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1336 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1337 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)
1340 float GetAmmoStat(float i)
1344 case 0: return STAT_SHELLS;
1345 case 1: return STAT_NAILS;
1346 case 2: return STAT_ROCKETS;
1347 case 3: return STAT_CELLS;
1348 case 4: return STAT_FUEL;
1353 float GetAmmoTypeForWep(float i)
1357 case WEP_SHOTGUN: return 0;
1358 case WEP_UZI: return 1;
1359 case WEP_CAMPINGRIFLE: return 1;
1360 case WEP_GRENADE_LAUNCHER: return 2;
1361 case WEP_ELECTRO: return 3;
1362 case WEP_CRYLINK: return 3;
1363 case WEP_HLAC: return 3;
1364 case WEP_MINSTANEX: return 3;
1365 case WEP_NEX: return 3;
1366 case WEP_HAGAR: return 2;
1367 case WEP_ROCKET_LAUNCHER: return 2;
1368 case WEP_SEEKER: return 2;
1369 case WEP_FIREBALL: return 4;
1370 case WEP_HOOK: return 3;
1375 #define MAX_ACCURACY_LEVELS 10
1376 float acc_lev[MAX_ACCURACY_LEVELS];
1378 void HUD_WeaponIcons(void)
1380 if(!autocvar_hud_weaponicons && !autocvar__hud_configure)
1383 active_panel = HUD_PANEL_WEAPONICONS;
1384 HUD_Panel_UpdateCvars(weaponicons);
1386 float i, weapid, fade, weapon_stats, weapon_number, weapon_cnt;
1389 mySize = panel_size;
1392 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1394 self = get_weaponinfo(i);
1395 if(self.impulse >= 0)
1399 // TODO make this configurable
1400 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1402 if(weaponorder_cmp_str != weaponorder_cmp_str_save)
1404 if(weaponorder_cmp_str_save)
1405 strunzone(weaponorder_cmp_str_save);
1406 weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
1408 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1410 self = get_weaponinfo(i);
1411 if(self.impulse >= 0)
1413 weaponorder[weapon_cnt] = self;
1417 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1420 HUD_Panel_DrawBg(1);
1421 if(panel_bg_padding)
1423 pos += '1 1 0' * panel_bg_padding;
1424 mySize -= '2 2 0' * panel_bg_padding;
1428 weapon_stats = getstati(STAT_DAMAGE_HITS);
1429 weapon_number = weapon_stats & 63;
1430 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1432 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1433 weapon_number = weapon_stats & 63;
1434 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1436 if(cvar_or("hud_weaponicons_fade", 1))
1438 fade = 3.2 - 2 * (time - weapontime);
1439 fade = bound(0.7, fade, 1);
1444 HUD_WeaponIcons_Clear();
1446 float rows, columns;
1447 rows = mySize_y/mySize_x;
1448 rows = bound(1, floor((sqrt(4 * autocvar_hud_weaponicons_aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1450 columns = ceil(WEP_COUNT/rows);
1453 float a, type, fullammo;
1455 when = autocvar_hud_weaponicons_complainbubble_time;
1457 fadetime = autocvar_hud_weaponicons_complainbubble_fadetime;
1464 if(autocvar_hud_weaponicons_accuracy && !(gametype == GAME_RACE || gametype == GAME_CTS))
1466 acc_levels = tokenize(cvar_string("hud_weaponicons_accuracy_color_levels"));
1467 if (acc_levels > MAX_ACCURACY_LEVELS)
1468 acc_levels = MAX_ACCURACY_LEVELS;
1470 for (i = 0; i < acc_levels; ++i)
1471 acc_lev[i] = stof(argv(i));
1474 for(i = 0; i < weapon_cnt; ++i)
1476 wpnpos = pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows);
1477 wpnsize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
1479 self = weaponorder[i];
1480 weapid = self.impulse;
1482 // draw background behind currently selected weapon
1483 if(self.weapon == activeweapon)
1484 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1486 // draw the weapon accuracy
1489 float weapon_hit, weapon_damage;
1490 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1493 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1494 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1497 // find the max level lower than weapon_stats
1500 while ( j && weapon_stats < acc_lev[j] )
1503 #define acc_color(i) stov(cvar_string(strcat("hud_weaponicons_accuracy_color", ftos(i))))
1505 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
1507 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
1508 color = acc_color(j);
1509 color = color + factor * (acc_color(j+1) - color);
1512 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1515 // draw the weapon icon
1516 if((self.impulse >= 0) && (getstati(STAT_WEAPONS) & self.weapons))
1518 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1520 if(autocvar_hud_weaponicons_number == 1) // weapon number
1521 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * mySize_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1522 else if(autocvar_hud_weaponicons_number == 2) // bind
1523 drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * mySize_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1525 // draw ammo status bar
1526 if(autocvar_hud_weaponicons_ammo && weapid != WEP_TUBA && weapid != WEP_LASER && weapid != WEP_PORTO)
1529 type = GetAmmoTypeForWep(weapid);
1531 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
1536 case 0: fullammo = autocvar_hud_weaponicons_ammo_full_shells; break;
1537 case 1: fullammo = autocvar_hud_weaponicons_ammo_full_nails; break;
1538 case 2: fullammo = autocvar_hud_weaponicons_ammo_full_rockets; break;
1539 case 3: fullammo = autocvar_hud_weaponicons_ammo_full_cells; break;
1540 case 4: fullammo = autocvar_hud_weaponicons_ammo_full_fuel; break;
1541 default: fullammo = 60;
1546 if(wpnsize_x/wpnsize_y > autocvar_hud_weaponicons_aspect)
1548 barsize_x = autocvar_hud_weaponicons_aspect * wpnsize_y;
1549 barsize_y = wpnsize_y;
1551 barpos_x = wpnpos_x + (wpnsize_x - barsize_x) / 2;
1552 barpos_y = wpnpos_y;
1556 barsize_y = 1/autocvar_hud_weaponicons_aspect * wpnsize_x;
1557 barsize_x = wpnsize_x;
1559 barpos_y = wpnpos_y + (wpnsize_y - barsize_y) / 2;
1560 barpos_x = wpnpos_x;
1566 barsize_x * bound(0, a/fullammo, 1),
1568 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, autocvar_hud_weaponicons_ammo_color, panel_fg_alpha * autocvar_hud_weaponicons_ammo_alpha, DRAWFLAG_NORMAL);
1569 drawresetcliparea();
1574 // draw a "ghost weapon icon" if you don't have the weapon
1577 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
1580 // draw the complain message
1581 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_weaponicons_complainbubble)
1585 if(complain_weapon_time + when > time)
1588 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1592 if(complain_weapon_time + when > time)
1599 if(complain_weapon_type == 0) {
1601 color = autocvar_hud_weaponicons_complainbubble_color_outofammo;
1603 else if(complain_weapon_type == 1) {
1605 color = autocvar_hud_weaponicons_complainbubble_color_donthave;
1609 color = autocvar_hud_weaponicons_complainbubble_color_unavailable;
1611 drawpic_aspect_skin(wpnpos + '1 1 0' * autocvar_hud_weaponicons_complainbubble_padding, "weapon_complainbubble", wpnsize - '2 2 0' * autocvar_hud_weaponicons_complainbubble_padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
1612 drawstring_aspect(wpnpos + '1 1 0' * autocvar_hud_weaponicons_complainbubble_padding, s, wpnsize - '2 2 0' * autocvar_hud_weaponicons_complainbubble_padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
1628 float GetAmmoItemCode(float i)
1632 case 0: return IT_SHELLS;
1633 case 1: return IT_NAILS;
1634 case 2: return IT_ROCKETS;
1635 case 3: return IT_CELLS;
1636 case 4: return IT_FUEL;
1641 string GetAmmoPicture(float i)
1645 case 0: return "ammo_shells";
1646 case 1: return "ammo_bullets";
1647 case 2: return "ammo_rockets";
1648 case 3: return "ammo_cells";
1649 case 4: return "ammo_fuel";
1654 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1657 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1658 if(autocvar__hud_configure)
1668 if(currently_selected)
1673 vector newSize, newPos;
1674 if(mySize_x/mySize_y > 3)
1676 newSize_x = 3 * mySize_y;
1677 newSize_y = mySize_y;
1679 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1684 newSize_y = 1/3 * mySize_x;
1685 newSize_x = mySize_x;
1687 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1691 vector picpos, numpos;
1692 if(autocvar_hud_inventory_iconalign)
1695 picpos = newPos + eX * 2 * newSize_y;
1699 numpos = newPos + eX * newSize_y;
1703 if (currently_selected)
1704 drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1706 drawfont = hud_bigfont;
1707 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1708 drawfont = hud_font;
1709 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1712 void HUD_Inventory(void)
1714 if(!autocvar_hud_inventory && !autocvar__hud_configure)
1717 active_panel = HUD_PANEL_INVENTORY;
1718 HUD_Panel_UpdateCvars(inventory);
1719 float i, currently_selected;
1723 mySize = panel_size;
1725 HUD_Panel_DrawBg(1);
1726 if(panel_bg_padding)
1728 pos += '1 1 0' * panel_bg_padding;
1729 mySize -= '2 2 0' * panel_bg_padding;
1732 float rows, columns;
1733 rows = mySize_y/mySize_x;
1734 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1735 // ^^^ ammo item aspect goes here
1737 columns = ceil(AMMO_COUNT/rows);
1741 for (i = 0; i < AMMO_COUNT; ++i) {
1742 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1743 if(autocvar_hud_inventory_onlycurrent) {
1744 if(autocvar__hud_configure)
1746 if (currently_selected || autocvar__hud_configure)
1748 DrawAmmoItem(pos, mySize, i, currently_selected);
1752 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);
1757 column = column + 1;
1763 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float alpha)
1765 vector newSize, newPos;
1766 if(mySize_x/mySize_y > 3)
1768 newSize_x = 3 * mySize_y;
1769 newSize_y = mySize_y;
1771 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1776 newSize_y = 1/3 * mySize_x;
1777 newSize_x = mySize_x;
1779 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1783 vector picpos, numpos;
1786 if(iconalign == 1 || iconalign == 3) // right align
1789 picpos = newPos + eX * 2 * newSize_y;
1793 numpos = newPos + eX * newSize_y;
1799 if(iconalign == 0 || iconalign == 3) // left align
1801 numpos = newPos + eX * newSize_y;
1807 picpos = newPos + eX * 2 * newSize_y;
1811 drawfont = hud_bigfont;
1812 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1813 drawfont = hud_font;
1814 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1817 void DrawNumIcon_expanding(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float fadelerp)
1820 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
1822 DrawNumIcon(iconalign, myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, left, color, (1 - fadelerp));
1827 void HUD_Powerups(void) {
1828 if(!autocvar_hud_powerups && !autocvar__hud_configure)
1831 active_panel = HUD_PANEL_POWERUPS;
1832 HUD_Panel_UpdateCvars(powerups);
1834 stat_items = getstati(STAT_ITEMS);
1836 if(!autocvar__hud_configure)
1838 if not(stat_items & IT_STRENGTH)
1839 if not(stat_items & IT_INVINCIBLE)
1842 if (getstati(STAT_HEALTH) <= 0)
1848 mySize = panel_size;
1850 float strength_time, shield_time;
1852 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1853 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1855 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
1856 if(panel_bg_padding)
1858 pos += '1 1 0' * panel_bg_padding;
1859 mySize -= '2 2 0' * panel_bg_padding;
1862 if(autocvar__hud_configure)
1868 vector barpos, barsize;
1872 string leftname, rightname;
1873 float leftcnt, rightcnt;
1874 float leftexact, rightexact;
1875 if (autocvar_hud_powerups_flip) {
1876 leftname = "strength";
1877 leftcnt = ceil(strength_time);
1878 leftexact = strength_time;
1880 rightname = "shield";
1881 rightcnt = ceil(shield_time);
1882 rightexact = shield_time;
1884 leftname = "shield";
1885 leftcnt = ceil(shield_time);
1886 leftexact = shield_time;
1888 rightname = "strength";
1889 rightcnt = ceil(strength_time);
1890 rightexact = strength_time;
1893 drawfont = hud_bigfont;
1894 if (mySize_x/mySize_y > 4)
1898 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1899 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1900 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1901 } else { // left align
1903 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1906 HUD_Panel_GetProgressBarColor(leftname)
1907 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
1909 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
1911 DrawNumIcon_expanding(autocvar_hud_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
1916 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1917 barpos = pos + eX * 0.5 * mySize_x;
1918 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1919 } else { // right align
1920 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1921 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1924 HUD_Panel_GetProgressBarColor(rightname)
1925 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1) * panel_fg_alpha, DRAWFLAG_NORMAL);
1927 DrawNumIcon(autocvar_hud_powerups_iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
1929 DrawNumIcon_expanding(autocvar_hud_powerups_iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1));
1932 else if (mySize_x/mySize_y > 1.5)
1936 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1937 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1938 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1939 } else { // left align
1941 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1944 HUD_Panel_GetProgressBarColor(leftname)
1945 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1) * panel_fg_alpha, DRAWFLAG_NORMAL);
1947 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
1949 DrawNumIcon_expanding(autocvar_hud_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
1954 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1955 barpos = pos + eY * 0.5 * mySize_y;
1956 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1957 } else { // right align
1958 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1959 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1962 HUD_Panel_GetProgressBarColor(rightname)
1963 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1) * panel_fg_alpha, DRAWFLAG_NORMAL);
1965 DrawNumIcon(autocvar_hud_powerups_iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
1967 DrawNumIcon_expanding(autocvar_hud_powerups_iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1));
1974 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // down align
1975 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1976 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1977 } else { // up align
1979 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1982 if(autocvar_hud_powerups_iconalign == 1 || autocvar_hud_powerups_iconalign == 3) { // down align
1983 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
1984 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
1985 } else { // up align
1986 picpos = pos + eX * 0.05 * mySize_x;
1987 numpos = pos + eY * 0.4 * mySize_x;
1990 HUD_Panel_GetProgressBarColor(leftname)
1991 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1) * panel_fg_alpha, DRAWFLAG_NORMAL);
1993 drawpic_aspect_skin_expanding(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, bound(0, (leftcnt - leftexact) / 0.5, 1));
1995 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1996 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2001 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // up align
2002 barpos = pos + eX * 0.5 * mySize_x;
2003 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2004 } else { // down align
2005 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
2006 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2009 if(autocvar_hud_powerups_iconalign == 0 || autocvar_hud_powerups_iconalign == 3) { // up align
2010 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2011 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2012 } else { // down align
2013 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2014 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2017 HUD_Panel_GetProgressBarColor(rightname)
2018 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1) * panel_fg_alpha, DRAWFLAG_NORMAL);
2020 drawpic_aspect_skin_expanding(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, bound(0, (rightcnt - rightexact) / 0.5, 1));
2022 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2023 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2026 drawfont = hud_font;
2029 // Health/armor (#3)
2031 void HUD_HealthArmor(void)
2033 if(!autocvar_hud_healtharmor && !autocvar__hud_configure)
2036 active_panel = HUD_PANEL_HEALTHARMOR;
2037 HUD_Panel_UpdateCvars(healtharmor);
2040 mySize = panel_size;
2042 HUD_Panel_DrawBg(1);
2043 if(panel_bg_padding)
2045 pos += '1 1 0' * panel_bg_padding;
2046 mySize -= '2 2 0' * panel_bg_padding;
2049 float armor, health;
2050 armor = getstati(STAT_ARMOR);
2051 health = getstati(STAT_HEALTH);
2054 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
2056 if(autocvar__hud_configure)
2066 vector barpos, barsize;
2070 drawfont = hud_bigfont;
2071 if(autocvar_hud_healtharmor == 2) // combined health and armor display
2074 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2079 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2080 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2081 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2082 } else { // left align
2084 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2088 if(v_z) // NOT fully armored
2090 biggercount = "health";
2091 HUD_Panel_GetProgressBarColor("health")
2092 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2094 drawpic_aspect_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "armor", '0.5 0.5 0' * mySize_y, '1 1 1', panel_fg_alpha * armor / health, DRAWFLAG_NORMAL);
2098 biggercount = "armor";
2099 HUD_Panel_GetProgressBarColor("armor")
2100 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2102 drawpic_aspect_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "health", '0.5 0.5 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2104 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200), 1);
2109 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2110 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2111 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2114 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2116 HUD_Panel_GetProgressBarColor("fuel")
2117 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2122 string leftname, rightname;
2123 float leftcnt, rightcnt;
2124 float leftactive, rightactive;
2125 float leftalpha, rightalpha;
2126 if (autocvar_hud_healtharmor_flip) { // old style layout with armor left/top of health
2131 leftalpha = min((armor+10)/55, 1);
2133 rightname = "health";
2138 leftname = "health";
2143 rightname = "armor";
2147 rightalpha = min((armor+10)/55, 1);
2150 if (mySize_x/mySize_y > 4)
2154 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2155 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2156 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2157 } else { // left align
2159 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2162 HUD_Panel_GetProgressBarColor(leftname)
2163 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2164 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
2169 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2170 barpos = pos + eX * 0.5 * mySize_x;
2171 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2172 } else { // right align
2173 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2174 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2177 HUD_Panel_GetProgressBarColor(rightname)
2178 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2179 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(leftcnt, 200), 1);
2184 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2185 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2186 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2189 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2191 HUD_Panel_GetProgressBarColor("fuel")
2192 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2195 else if (mySize_x/mySize_y > 1.5)
2199 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2200 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2201 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2202 } else { // left align
2204 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2207 HUD_Panel_GetProgressBarColor(leftname)
2208 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2209 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
2214 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2215 barpos = pos + eY * 0.5 * mySize_y;
2216 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2217 } else { // right align
2218 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2219 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2222 HUD_Panel_GetProgressBarColor(rightname)
2223 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2224 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(leftcnt, 200), 1);
2229 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2230 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2231 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2234 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2236 HUD_Panel_GetProgressBarColor("fuel")
2237 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2244 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // down align
2245 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2246 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2247 } else { // up align
2249 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2252 if(autocvar_hud_healtharmor_iconalign == 1 || autocvar_hud_healtharmor_iconalign == 3) { // down align
2253 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2254 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2255 } else { // up align
2256 picpos = pos + eX * 0.05 * mySize_x;
2257 numpos = pos + eY * 0.4 * mySize_x;
2260 HUD_Panel_GetProgressBarColor(leftname)
2261 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2262 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2263 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, HUD_Get_Num_Color(leftcnt, 200), panel_fg_alpha, DRAWFLAG_NORMAL);
2268 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // up align
2269 barpos = pos + eX * 0.5 * mySize_x;
2270 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2271 } else { // down align
2272 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2273 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2276 if(autocvar_hud_healtharmor_iconalign == 0 || autocvar_hud_healtharmor_iconalign == 3) { // up align
2277 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2278 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2279 } else { // down align
2280 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2281 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2284 HUD_Panel_GetProgressBarColor(rightname)
2285 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2286 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2287 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, HUD_Get_Num_Color(rightcnt, 200), panel_fg_alpha, DRAWFLAG_NORMAL);
2292 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2294 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2296 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2297 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2299 HUD_Panel_GetProgressBarColor("fuel")
2300 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2304 drawfont = hud_font;
2307 // Notification area (#4)
2310 string Weapon_SuicideMessage(float deathtype)
2312 w_deathtype = deathtype;
2313 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2314 return w_deathtypestring;
2317 string Weapon_KillMessage(float deathtype)
2319 w_deathtype = deathtype;
2320 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2321 return w_deathtypestring;
2324 float killnotify_times[10];
2325 float killnotify_deathtype[10];
2326 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2327 string killnotify_attackers[10];
2328 string killnotify_victims[10];
2329 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2332 for (i = 9; i > 0; --i) {
2333 killnotify_times[i] = killnotify_times[i-1];
2334 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2335 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2336 if(killnotify_attackers[i])
2337 strunzone(killnotify_attackers[i]);
2338 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2339 if(killnotify_victims[i])
2340 strunzone(killnotify_victims[i]);
2341 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2343 killnotify_times[0] = time;
2344 killnotify_deathtype[0] = wpn;
2345 killnotify_actiontype[0] = actiontype;
2346 if(killnotify_attackers[0])
2347 strunzone(killnotify_attackers[0]);
2348 killnotify_attackers[0] = strzone(attacker);
2349 if(killnotify_victims[0])
2350 strunzone(killnotify_victims[0]);
2351 killnotify_victims[0] = strzone(victim);
2354 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2357 float alsoprint, gentle;
2358 alsoprint = (autocvar_hud_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2359 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2361 if(msg == MSG_SUICIDE) {
2362 w = DEATH_WEAPONOF(type);
2364 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2366 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2367 } else if (type == DEATH_KILL) {
2368 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2370 print ("^1",s1, "^1 couldn't take it anymore\n");
2371 } else if (type == DEATH_ROT) {
2372 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2374 print ("^1",s1, "^1 died\n");
2375 } else if (type == DEATH_NOAMMO) {
2376 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2378 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2379 } else if (type == DEATH_CAMP) {
2380 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2382 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2383 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2384 HUD_KillNotify_Push(s1, "", 0, type);
2386 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2387 } else if (type == DEATH_CHEAT) {
2388 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2390 print ("^1",s1, "^1 unfairly eliminated themself\n");
2391 } else if (type == DEATH_FIRE) {
2392 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2394 print ("^1",s1, "^1 burned to death\n");
2395 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2396 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2398 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2401 if (stof(s2) > 2) // killcount > 2
2402 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2403 } else if(msg == MSG_KILL) {
2404 w = DEATH_WEAPONOF(type);
2406 HUD_KillNotify_Push(s2, s1, 1, w);
2408 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2410 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2411 HUD_KillNotify_Push(s1, s2, 1, type);
2415 print ("^1", s1, "^1 took action against a team mate\n");
2417 print ("^1", s1, "^1 mows down a team mate\n");
2420 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2422 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2424 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2426 else if (stof(s2) > 2) {
2428 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2430 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2433 else if(type == KILL_FIRST_BLOOD)
2434 print("^1",s1, "^1 drew first blood", "\n");
2436 else if (type == DEATH_TELEFRAG)
2437 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2438 else if (type == DEATH_DROWN) {
2439 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2441 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2443 else if (type == DEATH_SLIME) {
2444 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2446 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2448 else if (type == DEATH_LAVA) {
2449 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2451 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2453 else if (type == DEATH_FALL) {
2454 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2456 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2458 else if (type == DEATH_SHOOTING_STAR) {
2459 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2461 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2463 else if (type == DEATH_SWAMP) {
2464 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2466 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2468 else if (type == DEATH_HURTTRIGGER)
2470 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2472 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2473 } else if(type == DEATH_SBCRUSH) {
2474 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2476 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2477 } else if(type == DEATH_SBMINIGUN) {
2478 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2480 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2481 } else if(type == DEATH_SBROCKET) {
2482 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2484 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2485 } else if(type == DEATH_SBBLOWUP) {
2486 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2488 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2489 } else if(type == DEATH_WAKIGUN) {
2490 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2492 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2493 } else if(type == DEATH_WAKIROCKET) {
2494 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2496 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2497 } else if(type == DEATH_WAKIBLOWUP) {
2498 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2500 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2501 } else if(type == DEATH_TURRET) {
2502 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2504 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2505 } else if(type == DEATH_TOUCHEXPLODE) {
2506 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2508 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2509 } else if(type == DEATH_CHEAT) {
2510 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2512 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2513 } else if (type == DEATH_FIRE) {
2514 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2516 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2517 } else if (type == DEATH_CUSTOM) {
2518 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2520 print ("^1",s1, "^1 ", s2, "\n");
2522 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2524 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2526 } else if(msg == MSG_SPREE) {
2527 if(type == KILL_END_SPREE) {
2529 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2531 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2532 } else if(type == KILL_SPREE) {
2534 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2536 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2537 } else if(type == KILL_SPREE_3) {
2539 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2541 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2542 } else if(type == KILL_SPREE_5) {
2544 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2546 print (s1,"^7 unleashes ^1RAGE\n");
2547 } else if(type == KILL_SPREE_10) {
2549 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2551 print (s1,"^7 starts the ^1MASSACRE!\n");
2552 } else if(type == KILL_SPREE_15) {
2554 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2556 print (s1,"^7 executes ^1MAYHEM!\n");
2557 } else if(type == KILL_SPREE_20) {
2559 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2561 print (s1,"^7 is a ^1BERSERKER!\n");
2562 } else if(type == KILL_SPREE_25) {
2564 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2566 print (s1,"^7 inflicts ^1CARNAGE!\n");
2567 } else if(type == KILL_SPREE_30) {
2569 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2571 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2573 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2574 if (type == DEATH_DROWN) {
2575 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2579 print ("^1",s1, "^1 was in the water for too long\n");
2581 print ("^1",s1, "^1 drowned\n");
2583 } else if (type == DEATH_SLIME) {
2584 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2586 print ("^1",s1, "^1 was slimed\n");
2587 } else if (type == DEATH_LAVA) {
2588 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2592 print ("^1",s1, "^1 found a hot place\n");
2594 print ("^1",s1, "^1 turned into hot slag\n");
2596 } else if (type == DEATH_FALL) {
2597 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2601 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2603 print ("^1",s1, "^1 hit the ground with a crunch\n");
2605 } else if (type == DEATH_SHOOTING_STAR) {
2606 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2608 print ("^1",s1, "^1 became a shooting star\n");
2609 } else if (type == DEATH_SWAMP) {
2610 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2614 print ("^1",s1, "^1 discovered a swamp\n");
2616 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2618 } else if(type == DEATH_TURRET) {
2619 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2621 print ("^1",s1, "^1 was mowed down by a turret \n");
2622 } else if (type == DEATH_CUSTOM) {
2623 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2625 print ("^1",s1, "^1 ", s2, "\n");
2626 } else if (type == DEATH_HURTTRIGGER) {
2627 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2629 print ("^1",s1, "^1 was in the wrong place\n");
2630 } else if(type == DEATH_TOUCHEXPLODE) {
2631 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2633 print ("^1",s1, "^1 died in an accident\n");
2634 } else if(type == DEATH_CHEAT) {
2635 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2637 print ("^1",s1, "^1 was unfairly eliminated\n");
2638 } else if(type == DEATH_FIRE) {
2639 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2643 print ("^1",s1, "^1 felt a little hot\n");
2645 print ("^1",s1, "^1 burnt to death\n");
2648 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2652 print ("^1",s1, "^1 needs a restart\n");
2654 print ("^1",s1, "^1 died\n");
2657 } else if(msg == MSG_KILL_ACTION_SPREE) {
2659 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2661 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2662 } else if(msg == MSG_INFO) {
2663 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2664 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2665 print(s1, "^7 got the ", s2, "\n");
2666 } else if(type == INFO_LOSTFLAG) {
2667 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2668 print(s1, "^7 lost the ", s2, "\n");
2669 } else if(type == INFO_PICKUPFLAG) {
2670 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2671 print(s1, "^7 picked up the ", s2, "\n");
2672 } else if(type == INFO_RETURNFLAG) {
2673 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2674 print(s1, "^7 returned the ", s2, "\n");
2675 } else if(type == INFO_CAPTUREFLAG) {
2676 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
2677 print(s1, "^7 captured the ", s2, s3, "\n");
2682 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2684 void HUD_Centerprint(string s1, string s2, float type, float msg)
2687 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2688 if(msg == MSG_SUICIDE) {
2689 if (type == DEATH_TEAMCHANGE) {
2690 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2691 } else if (type == DEATH_AUTOTEAMCHANGE) {
2692 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2693 } else if (type == DEATH_CAMP) {
2695 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2697 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2698 } else if (type == DEATH_NOAMMO) {
2700 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2702 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2703 } else if (type == DEATH_ROT) {
2705 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2707 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2708 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2710 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2712 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2713 } else if (type == DEATH_QUIET) {
2715 } else if (type == DEATH_KILL) {
2717 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2719 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2721 } else if(msg == MSG_KILL) {
2722 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2724 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2726 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2728 } else if (type == KILL_FIRST_BLOOD) {
2730 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2732 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2734 } else if (type == KILL_FIRST_VICTIM) {
2736 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2738 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2740 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2742 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2744 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2746 } else if (type == KILL_TYPEFRAGGED) {
2748 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2750 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2752 } else if (type == KILL_FRAG) {
2754 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2756 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2758 } else if (type == KILL_FRAGGED) {
2760 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2762 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2765 } else if(msg == MSG_KILL_ACTION) {
2766 // TODO: invent more centerprints here?
2767 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2771 void HUD_Notify (void)
2773 if(!autocvar_hud_notify && !autocvar__hud_configure)
2776 active_panel = HUD_PANEL_NOTIFY;
2777 HUD_Panel_UpdateCvars(notify);
2780 mySize = panel_size;
2782 HUD_Panel_DrawBg(1);
2783 if(panel_bg_padding)
2785 pos += '1 1 0' * panel_bg_padding;
2786 mySize -= '2 2 0' * panel_bg_padding;
2789 float entries, height;
2790 entries = bound(1, floor(10 * mySize_y/mySize_x), 10);
2791 height = mySize_y/entries;
2794 fontsize = '0.5 0.5 0' * height;
2798 when = autocvar_hud_notify_time;
2800 fadetime = autocvar_hud_notify_fadetime;
2804 vector pos_attacker, pos_victim;
2806 float width_attacker;
2807 string attacker, victim;
2810 for(j = 0; j < entries; ++j)
2813 if(autocvar_hud_notify_flip)
2815 else // rather nasty hack for ordering items from the bottom up
2816 i = entries - j - 1;
2820 if(killnotify_times[j] + when > time)
2823 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2827 if(killnotify_times[j] + when > time)
2833 // TODO: maybe print in team colors?
2836 if(killnotify_actiontype[j] == 0 && !autocvar__hud_configure)
2838 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2839 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
2840 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2842 if(killnotify_deathtype[j] == DEATH_GENERIC)
2846 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2848 s = "notify_outofammo";
2850 else if(killnotify_deathtype[j] == DEATH_KILL)
2852 s = "notify_selfkill";
2854 else if(killnotify_deathtype[j] == DEATH_CAMP)
2856 s = "notify_camping";
2858 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2860 s = "notify_teamkill_red";
2862 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2864 s = "notify_teamkill_blue";
2866 else if(killnotify_deathtype[j] == DEATH_DROWN)
2870 else if(killnotify_deathtype[j] == DEATH_SLIME)
2874 else if(killnotify_deathtype[j] == DEATH_LAVA)
2878 else if(killnotify_deathtype[j] == DEATH_FALL)
2882 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2884 s = "notify_shootingstar";
2886 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2890 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2892 if(killnotify_victims[j] == "^1RED^7 flag")
2894 s = "notify_red_taken";
2898 s = "notify_blue_taken";
2901 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2903 if(killnotify_victims[j] == "^1RED^7 flag")
2905 s = "notify_red_returned";
2909 s = "notify_blue_returned";
2912 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2914 if(killnotify_victims[j] == "^1RED^7 flag")
2916 s = "notify_red_lost";
2920 s = "notify_blue_lost";
2923 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
2925 if(killnotify_victims[j] == "^1RED^7 flag")
2927 s = "notify_red_captured";
2931 s = "notify_blue_captured";
2936 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2937 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2940 // X [did action to] Y
2943 if(autocvar__hud_configure)
2945 attacker = textShortenToWidth("Player1", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2946 victim = textShortenToWidth("Player2", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2947 a = bound(0, (when - j) / 4, 1);
2951 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2952 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2954 width_attacker = stringwidth(attacker, TRUE, fontsize);
2955 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
2956 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
2957 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2959 if(autocvar__hud_configure) // example actions for config mode
2961 s = "weaponelectro";
2963 else if(WEP_VALID(killnotify_deathtype[j]))
2965 self = get_weaponinfo(killnotify_deathtype[j]);
2966 s = strcat("weapon", self.netname);
2968 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2970 s = "notify_teamkill_red";
2972 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2974 s = "notify_teamkill_red";
2976 else if(killnotify_deathtype[j] == DEATH_DROWN)
2980 else if(killnotify_deathtype[j] == DEATH_SLIME)
2984 else if(killnotify_deathtype[j] == DEATH_LAVA)
2988 else if(killnotify_deathtype[j] == DEATH_FALL)
2992 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2994 s = "notify_shootingstar";
2996 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
3002 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3003 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3004 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3013 string seconds_tostring(float sec)
3016 minutes = floor(sec / 60);
3018 sec -= minutes * 60;
3021 s = ftos(100 + sec);
3023 return strcat(ftos(minutes), ":", substring(s, 1, 3));
3026 void HUD_Timer(void)
3028 if(!autocvar_hud_timer && !autocvar__hud_configure)
3031 active_panel = HUD_PANEL_TIMER;
3032 HUD_Panel_UpdateCvars(timer);
3035 mySize = panel_size;
3037 HUD_Panel_DrawBg(1);
3038 if(panel_bg_padding)
3040 pos += '1 1 0' * panel_bg_padding;
3041 mySize -= '2 2 0' * panel_bg_padding;
3045 float timelimit, elapsedTime, timeleft, minutesLeft;
3047 timelimit = getstatf(STAT_TIMELIMIT);
3049 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
3050 timeleft = ceil(timeleft);
3052 minutesLeft = floor(timeleft / 60);
3055 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
3056 timer_color = '1 1 1'; //white
3057 else if(minutesLeft >= 1)
3058 timer_color = '1 1 0'; //yellow
3060 timer_color = '1 0 0'; //red
3062 if (autocvar_hud_timer_increment || timelimit == 0 || warmup_stage) {
3063 if (time < getstatf(STAT_GAMESTARTTIME)) {
3064 //while restart is still active, show 00:00
3065 timer = seconds_tostring(0);
3067 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
3068 timer = seconds_tostring(elapsedTime);
3071 timer = seconds_tostring(timeleft);
3074 drawfont = hud_bigfont;
3075 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3076 drawfont = hud_font;
3081 void HUD_Radar(void)
3083 if ((autocvar_hud_radar == 0 || (autocvar_hud_radar != 2 && !teamplay)) && !autocvar__hud_configure)
3086 active_panel = HUD_PANEL_RADAR;
3087 HUD_Panel_UpdateCvars(radar);
3090 mySize = panel_size;
3092 HUD_Panel_DrawBg(1);
3093 if(panel_bg_padding)
3095 pos += '1 1 0' * panel_bg_padding;
3096 mySize -= '2 2 0' * panel_bg_padding;
3099 local float color1, color2; // color already declared as a global in hud.qc
3102 float scale2d, normalsize, bigsize;
3105 teamradar_origin2d = pos + 0.5 * mySize;
3106 teamradar_size2d = mySize;
3108 if(minimapname == "")
3111 teamradar_loadcvars();
3113 switch(hud_radar_zoommode)
3117 f = current_zoomfraction;
3120 f = 1 - current_zoomfraction;
3130 switch(hud_radar_rotation)
3133 teamradar_angle = view_angles_y - 90;
3136 teamradar_angle = 90 * hud_radar_rotation;
3140 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
3141 teamradar_size2d = mySize;
3143 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
3145 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
3146 if(hud_radar_rotation == 0)
3148 // max-min distance must fit the radar in any rotation
3149 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
3153 vector c0, c1, c2, c3, span;
3154 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
3155 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
3156 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
3157 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
3159 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
3160 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
3162 // max-min distance must fit the radar in x=x, y=y
3164 teamradar_size2d_x * scale2d / (1.05 * span_x),
3165 teamradar_size2d_y * scale2d / (1.05 * span_y)
3169 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
3170 if(bigsize > normalsize)
3171 normalsize = bigsize;
3175 + (1 - f) * normalsize;
3176 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
3177 f * (mi_min + mi_max) * 0.5
3178 + (1 - f) * view_origin);
3180 color1 = GetPlayerColor(player_localentnum-1);
3181 rgb = GetTeamRGB(color1);
3190 draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
3192 for(tm = world; (tm = find(tm, classname, "radarlink")); )
3193 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
3194 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
3195 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
3196 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
3198 color2 = GetPlayerColor(tm.sv_entnum);
3199 //if(color == COLOR_SPECTATOR || color == color2)
3200 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
3202 draw_teamradar_player(view_origin, view_angles, '1 1 1');
3204 drawresetcliparea();
3209 void HUD_Score(void)
3211 if(!autocvar_hud_score && !autocvar__hud_configure)
3214 active_panel = HUD_PANEL_SCORE;
3215 HUD_Panel_UpdateCvars(score);
3218 mySize = panel_size;
3220 HUD_Panel_DrawBg(1);
3221 if(panel_bg_padding)
3223 pos += '1 1 0' * panel_bg_padding;
3224 mySize -= '2 2 0' * panel_bg_padding;
3227 float score, distribution, leader;
3228 vector distribution_color;
3230 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
3232 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
3233 string timer, distrtimer;
3235 pl = players.sort_next;
3238 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
3239 if(pl.scores[ps_primary] == 0)
3242 score = me.(scores[ps_primary]);
3243 timer = TIME_ENCODED_TOSTRING(score);
3245 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
3246 // distribution display
3247 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3249 distrtimer = ftos(distribution/pow(10, TIME_DECIMALS));
3251 if (distribution <= 0) {
3252 distribution_color = '0 1 0';
3255 distribution_color = '1 0 0';
3257 drawstring_aspect(pos + eX * 0.75 * mySize_x, distrtimer, eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3259 // race record display
3260 if (distribution <= 0)
3261 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3262 drawfont = hud_bigfont;
3263 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3264 drawfont = hud_font;
3265 } else if (!teamplay) { // non-teamgames
3266 // me vector := [team/connected frags id]
3267 pl = players.sort_next;
3271 if(autocvar__hud_configure)
3274 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
3278 score = me.(scores[ps_primary]);
3279 if(autocvar__hud_configure)
3282 if(distribution >= 5) {
3283 distribution_color = eY;
3285 } else if(distribution >= 0) {
3286 distribution_color = '1 1 1';
3288 } else if(distribution >= -5)
3289 distribution_color = '1 1 0';
3291 distribution_color = eX;
3293 drawstring_aspect(pos + eX * 0.75 * mySize_x, ftos(distribution), eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3295 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3296 drawfont = hud_bigfont;
3297 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
3298 drawfont = hud_font;
3299 } else { // teamgames
3300 float max_fragcount;
3301 max_fragcount = -99;
3304 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
3305 if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !autocvar__hud_configure)) // no players? don't display
3307 score = tm.(teamscores[ts_primary]);
3308 if(autocvar__hud_configure)
3312 if (score > max_fragcount)
3313 max_fragcount = score;
3315 if(tm.team == myteam) {
3316 if (max_fragcount == score)
3319 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3320 drawfont = hud_bigfont;
3321 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3322 drawfont = hud_font;
3324 if (max_fragcount == score)
3327 HUD_Panel_DrawHighlight(pos + eX * 0.75 * mySize_x + eY * (1/3) * teamnum * mySize_y, eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3328 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, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
3337 void HUD_RaceTimer (void) {
3338 if(!autocvar_hud_racetimer && !(gametype == GAME_RACE || gametype == GAME_CTS) && !autocvar__hud_configure)
3341 active_panel = HUD_PANEL_RACETIMER;
3342 HUD_Panel_UpdateCvars(racetimer);
3345 mySize = panel_size;
3347 HUD_Panel_DrawBg(1);
3348 if(panel_bg_padding)
3350 pos += '1 1 0' * panel_bg_padding;
3351 mySize -= '2 2 0' * panel_bg_padding;
3354 // always force 4:1 aspect
3356 if(mySize_x/mySize_y > 4)
3358 newSize_x = 4 * mySize_y;
3359 newSize_y = mySize_y;
3361 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3365 newSize_y = 1/4 * mySize_x;
3366 newSize_x = mySize_x;
3368 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3372 drawfont = hud_bigfont;
3374 string s, forcetime;
3376 if(autocvar__hud_configure)
3379 drawstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, FALSE, '0.60 0.60 0' * mySize_y), s, '0.60 0.60 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3380 s = "^1Intermediate 1 (+15.42)";
3381 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.20 * mySize_y) + eY * 0.60 * mySize_y, s, '1 1 0' * 0.20 * mySize_y, panel_fg_alpha, DRAWFLAG_NORMAL);
3382 s = strcat("^1PENALTY: ", ftos_decimals(20 * 0.1, 1), " (missing a checkpoint)");
3383 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.20 * mySize_y) + eY * 0.80 * mySize_y, s, '1 1 0' * 0.20 * mySize_y, panel_fg_alpha, DRAWFLAG_NORMAL);
3385 else if(race_checkpointtime)
3387 a = bound(0, 2 - (time - race_checkpointtime), 1);
3390 if(a > 0) // just hit a checkpoint?
3392 if(race_checkpoint != 254)
3394 if(race_time && race_previousbesttime)
3395 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
3397 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3399 forcetime = TIME_ENCODED_TOSTRING(race_time);
3404 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3406 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3407 if(a > 0) // next one?
3409 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3414 if(s != "" && a > 0)
3416 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3419 if(race_penaltytime)
3421 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3424 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
3425 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.8 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3431 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3432 drawstring_expanding(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(forcetime, FALSE, '1 1 0' * 0.6 * mySize_y), forcetime, '1 1 0' * 0.6 * mySize_y, '1 1 1', panel_fg_alpha, 0, a);
3437 if(race_laptime && race_checkpoint != 255)
3439 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3440 drawstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, FALSE, '0.6 0.6 0' * mySize_y), s, '0.6 0.6 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3445 if(race_mycheckpointtime)
3447 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3448 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3449 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3451 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3453 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3454 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3455 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3458 if(race_penaltytime && !race_penaltyaccumulator)
3460 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3461 a = bound(0, (1 + t - time), 1);
3465 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
3467 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
3468 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3473 drawfont = hud_font;
3478 float vote_yescount;
3481 float vote_highlighted; // currently selected vote
3483 float vote_active; // is there an active vote?
3484 float vote_prev; // previous state of vote_active to check for a change
3486 float vote_change; // "time" when vote_active changed
3488 void HUD_VoteWindow(void)
3490 if(!autocvar_hud_vote && !autocvar__hud_configure)
3493 active_panel = HUD_PANEL_VOTE;
3494 HUD_Panel_UpdateCvars(vote);
3497 mySize = panel_size;
3501 if(vote_active != vote_prev) {
3503 vote_prev = vote_active;
3506 if(vote_active || autocvar__hud_configure)
3507 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3509 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3511 if(autocvar__hud_configure)
3521 a = vote_alpha * bound(autocvar_hud_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3523 HUD_Panel_DrawBg(a);
3524 if(panel_bg_padding)
3526 pos += '1 1 0' * panel_bg_padding;
3527 mySize -= '2 2 0' * panel_bg_padding;
3530 // always force 3:1 aspect
3532 if(mySize_x/mySize_y > 3)
3534 newSize_x = 3 * mySize_y;
3535 newSize_y = mySize_y;
3537 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3541 newSize_y = 1/3 * mySize_x;
3542 newSize_x = mySize_x;
3544 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3548 s = "A vote has been called for:";
3549 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3550 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1.75/8), stringwidth_colors);
3551 if(autocvar__hud_configure)
3552 s = "^1Configure the HUD";
3553 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a * panel_fg_alpha, DRAWFLAG_NORMAL);
3555 // print the yes/no counts
3556 s = strcat("Yes (", getcommandkey("not bound", "vyes"), "): ", ftos(vote_yescount));
3557 drawstring_aspect(pos + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '0 1 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3558 s = strcat("No (", getcommandkey("not bound", "vno"), "): ", ftos(vote_nocount));
3559 drawstring_aspect(pos + eX * 0.5 * mySize_x + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '1 0 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3561 // draw the progress bar backgrounds
3562 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3564 // draw the highlights
3565 if(vote_highlighted == 1) {
3566 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3567 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '0 1 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3569 else if(vote_highlighted == 2) {
3570 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3571 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '0 1 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3574 // draw the progress bars
3575 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3576 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '0 1 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3578 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3579 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 0 0', a * panel_fg_alpha, DRAWFLAG_NORMAL);
3581 drawresetcliparea();
3584 vote_highlighted = 0;
3588 // Mod icons panel (#10)
3591 float mod_active; // is there any active mod icon?
3593 // CTF HUD modicon section
3594 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3595 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3596 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3598 void HUD_Mod_CTF_Reset(void)
3600 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3603 void HUD_Mod_CTF(vector pos, vector mySize)
3605 vector redflag_pos, blueflag_pos;
3607 float f; // every function should have that
3609 float redflag, blueflag; // current status
3610 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3613 stat_items = getstati(STAT_ITEMS);
3614 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3615 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3617 if(redflag || blueflag)
3622 if(autocvar__hud_configure)
3628 // when status CHANGES, set old status into prevstatus and current status into status
3629 if (redflag != redflag_prevframe)
3631 redflag_statuschange_time = time;
3632 redflag_prevstatus = redflag_prevframe;
3633 redflag_prevframe = redflag;
3636 if (blueflag != blueflag_prevframe)
3638 blueflag_statuschange_time = time;
3639 blueflag_prevstatus = blueflag_prevframe;
3640 blueflag_prevframe = blueflag;
3643 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3644 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3646 float BLINK_FACTOR = 0.15;
3647 float BLINK_BASE = 0.85;
3649 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3651 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3653 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3655 string red_icon, red_icon_prevstatus;
3656 float red_alpha, red_alpha_prevstatus;
3657 red_alpha = red_alpha_prevstatus = 1;
3659 case 1: red_icon = "flag_red_taken"; break;
3660 case 2: red_icon = "flag_red_lost"; break;
3661 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3663 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3664 red_icon = "flag_red_shielded";
3666 red_icon = string_null;
3669 switch(redflag_prevstatus) {
3670 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3671 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3672 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3675 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3676 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3677 red_icon_prevstatus = "flag_red_shielded";
3679 red_icon_prevstatus = string_null;
3683 string blue_icon, blue_icon_prevstatus;
3684 float blue_alpha, blue_alpha_prevstatus;
3685 blue_alpha = blue_alpha_prevstatus = 1;
3687 case 1: blue_icon = "flag_blue_taken"; break;
3688 case 2: blue_icon = "flag_blue_lost"; break;
3689 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3691 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3692 blue_icon = "flag_blue_shielded";
3694 blue_icon = string_null;
3697 switch(blueflag_prevstatus) {
3698 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3699 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3700 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3703 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3704 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3705 blue_icon_prevstatus = "flag_blue_shielded";
3707 blue_icon_prevstatus = string_null;
3711 if(mySize_x > mySize_y) {
3712 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3714 blueflag_pos = pos + eX * 0.5 * mySize_x;
3717 redflag_pos = pos + eX * 0.5 * mySize_x;
3719 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3721 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3723 blueflag_pos = pos + eY * 0.5 * mySize_y;
3726 redflag_pos = pos + eY * 0.5 * mySize_y;
3728 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3731 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3732 if(red_icon_prevstatus && f < 1)
3733 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3735 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3737 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3738 if(blue_icon_prevstatus && f < 1)
3739 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3741 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3744 // Keyhunt HUD modicon section
3745 float kh_runheretime;
3747 void HUD_Mod_KH_Reset(void)
3752 void HUD_Mod_KH(vector pos, vector mySize)
3754 mod_active = 1; // keyhunt should never hide the mod icons panel
3758 vector p, pa, kh_size, kh_asize;
3760 kh_keys = getstati(STAT_KH_KEYS);
3763 if(mySize_x > mySize_y)
3765 p_y = pos_y + 0.25 * mySize_y;
3766 pa = p - eY * 0.25 * mySize_y;
3768 kh_size_x = mySize_x * 0.25;
3769 kh_size_y = 0.75 * mySize_y;
3770 kh_asize_x = mySize_x * 0.25;
3771 kh_asize_y = mySize_y * 0.25;
3775 p_y = pos_y + 0.125 * mySize_y;
3776 pa = p - eY * 0.125 * mySize_y;
3778 kh_size_x = mySize_x * 0.5;
3779 kh_size_y = 0.375 * mySize_y;
3780 kh_asize_x = mySize_x * 0.5;
3781 kh_asize_y = mySize_y * 0.125;
3788 for(i = 0; i < 4; ++i)
3790 key = floor(kh_keys / pow(32, i)) & 31;
3792 if(keyteam == 30 && keycount <= 4)
3794 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3798 // this yields 8 exactly if "RUN HERE" shows
3803 kh_runheretime = time;
3804 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3809 for(i = 0; i < 4; ++i)
3811 key = floor(kh_keys / pow(32, i)) & 31;
3824 default: // owned or dropped
3829 a = a * panel_fg_alpha;
3830 aa = aa * panel_fg_alpha;
3836 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3839 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3842 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3845 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3850 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3853 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3856 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3859 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3862 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3866 if(mySize_x > mySize_y)
3868 p_x += 0.25 * mySize_x;
3869 pa_x += 0.25 * mySize_x;
3875 p_y = pos_y + 0.625 * mySize_y;
3876 pa_y = pos_y + 0.5 * mySize_y;
3882 p_x += 0.5 * mySize_x;
3883 pa_x += 0.5 * mySize_x;
3889 // Nexball HUD mod icon
3890 void HUD_Mod_NexBall(vector pos, vector mySize)
3892 float stat_items, nb_pb_starttime, dt, p;
3894 stat_items = getstati(STAT_ITEMS);
3895 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3897 if (stat_items & IT_KEY1)
3902 //Manage the progress bar if any
3903 if (nb_pb_starttime > 0)
3905 dt = mod(time - nb_pb_starttime, nb_pb_period);
3906 // one period of positive triangle
3907 p = 2 * dt / nb_pb_period;
3914 if(mySize_x > mySize_y)
3916 barsize = eX * p * mySize_x + eY * mySize_y;
3921 barsize = eX * mySize_x + eY * p * mySize_y;
3924 HUD_Panel_GetProgressBarColor("nexball")
3925 HUD_Panel_DrawProgressBar(pos, vertical, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3928 if (stat_items & IT_KEY1)
3929 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3932 // Race/CTS HUD mod icons
3933 float crecordtime_prev; // last remembered crecordtime
3934 float crecordtime_change_time; // time when crecordtime last changed
3935 float srecordtime_prev; // last remembered srecordtime
3936 float srecordtime_change_time; // time when srecordtime last changed
3938 float race_status_time;
3939 float race_status_prev;
3940 string race_status_name_prev;
3941 void HUD_Mod_Race(vector pos, vector mySize)
3943 mod_active = 1; // race should never hide the mod icons panel
3945 me = playerslots[player_localentnum - 1];
3947 float f; // yet another function has this
3948 score = me.(scores[ps_primary]);
3950 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3951 return; // no records in the actual race
3953 drawfont = hud_bigfont;
3955 // clientside personal record
3957 if(gametype == GAME_CTS)
3961 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3963 if(score && (score < t || !t)) {
3964 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3965 if(cvar("cl_autodemo_delete_keeprecords"))
3967 f = cvar("cl_autodemo_delete");
3969 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3973 if(t != crecordtime_prev) {
3974 crecordtime_prev = t;
3975 crecordtime_change_time = time;
3977 f = time - crecordtime_change_time;
3980 drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3981 drawstring_aspect(pos + eY * 0.25 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3983 drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3984 drawstring_aspect(pos + eY * 0.25 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3985 drawstring_aspect_expanding(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
3986 drawstring_aspect_expanding(pos + eY * 0.25 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
3990 t = race_server_record;
3991 if(t != srecordtime_prev) {
3992 srecordtime_prev = t;
3993 srecordtime_change_time = time;
3995 f = time - srecordtime_change_time;
3998 drawstring_aspect(pos + eY * 0.5 * mySize_y, "Server best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3999 drawstring_aspect(pos + eY * 0.75 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4001 drawstring_aspect(pos + eY * 0.5 * mySize_y, "Server best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4002 drawstring_aspect(pos + eY * 0.75 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4003 drawstring_aspect_expanding(pos + eY * 0.5 * mySize_y, "Server best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4004 drawstring_aspect_expanding(pos + eY * 0.75 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
4007 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
4008 race_status_time = time + 5;
4009 race_status_prev = race_status;
4010 if (race_status_name_prev)
4011 strunzone(race_status_name_prev);
4012 race_status_name_prev = strzone(race_status_name);
4015 pos_x += mySize_x/2;
4018 a = bound(0, race_status_time - time, 1);
4021 s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
4025 rank = race_CheckName(race_status_name);
4027 rankname = race_PlaceName(rank);
4030 namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
4032 rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
4034 if(race_status == 0)
4035 drawpic_aspect_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4036 else if(race_status == 1) {
4037 drawpic_aspect_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4038 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4039 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4040 } else if(race_status == 2) {
4041 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
4042 drawpic_aspect_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4044 drawpic_aspect_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4045 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4046 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4047 } else if(race_status == 3) {
4048 drawpic_aspect_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4049 drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
4050 drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
4053 if (race_status_time - time <= 0) {
4054 race_status_prev = -1;
4056 if(race_status_name)
4057 strunzone(race_status_name);
4058 race_status_name = string_null;
4059 if(race_status_name_prev)
4060 strunzone(race_status_name_prev);
4061 race_status_name_prev = string_null;
4063 drawfont = hud_font;
4066 float mod_prev; // previous state of mod_active to check for a change
4068 float mod_change; // "time" when mod_active changed
4070 void HUD_ModIcons(void)
4072 if(!autocvar_hud_modicons && !autocvar__hud_configure)
4075 if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !autocvar__hud_configure)
4078 active_panel = HUD_PANEL_MODICONS;
4079 HUD_Panel_UpdateCvars(modicons);
4082 mySize = panel_size;
4084 if(mod_active != mod_prev) {
4086 mod_prev = mod_active;
4089 if(mod_active || autocvar__hud_configure)
4090 mod_alpha = bound(0, (time - mod_change) * 2, 1);
4092 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
4095 HUD_Panel_DrawBg(mod_alpha);
4097 if(panel_bg_padding)
4099 pos += '1 1 0' * panel_bg_padding;
4100 mySize -= '2 2 0' * panel_bg_padding;
4103 // these MUST be ran in order to update mod_active
4104 if(gametype == GAME_KEYHUNT)
4105 HUD_Mod_KH(pos, mySize);
4106 else if(gametype == GAME_CTF || autocvar__hud_configure)
4107 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
4108 else if(gametype == GAME_NEXBALL)
4109 HUD_Mod_NexBall(pos, mySize);
4110 else if(gametype == GAME_CTS || gametype == GAME_RACE)
4111 HUD_Mod_Race(pos, mySize);
4114 // Draw pressed keys (#11)
4116 void HUD_DrawPressedKeys(void)
4118 if(!autocvar_hud_pressedkeys && !autocvar__hud_configure)
4121 if(!(spectatee_status > 0 || autocvar_hud_pressedkeys >= 2 || autocvar__hud_configure))
4124 active_panel = HUD_PANEL_PRESSEDKEYS;
4125 HUD_Panel_UpdateCvars(pressedkeys);
4128 mySize = panel_size;
4130 HUD_Panel_DrawBg(1);
4131 if(panel_bg_padding)
4133 pos += '1 1 0' * panel_bg_padding;
4134 mySize -= '2 2 0' * panel_bg_padding;
4137 // force custom aspect
4138 if(autocvar_hud_pressedkeys_aspect)
4141 if(mySize_x/mySize_y > autocvar_hud_pressedkeys_aspect)
4143 newSize_x = autocvar_hud_pressedkeys_aspect * mySize_y;
4144 newSize_y = mySize_y;
4146 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4150 newSize_y = 1/autocvar_hud_pressedkeys_aspect * mySize_x;
4151 newSize_x = mySize_x;
4153 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4159 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
4162 pressedkeys = getstatf(STAT_PRESSED_KEYS);
4163 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4164 drawpic_aspect_skin(pos + eX * mySize_x * (1/3), ((pressedkeys & KEY_FORWARD) ? "key_forward_inv.tga" : "key_forward.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4165 drawpic_aspect_skin(pos + eX * mySize_x * (2/3), ((pressedkeys & KEY_JUMP) ? "key_jump_inv.tga" : "key_jump.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4166 drawpic_aspect_skin(pos + eY * 0.5 * mySize_y, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4167 drawpic_aspect_skin(pos + eY * 0.5 * mySize_y + eX * mySize_x * (1/3), ((pressedkeys & KEY_BACKWARD) ? "key_backward_inv.tga" : "key_backward.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4168 drawpic_aspect_skin(pos + eY * 0.5 * mySize_y + eX * mySize_x * (2/3), ((pressedkeys & KEY_RIGHT) ? "key_right_inv.tga" : "key_right.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4171 // Handle chat as a panel (#12)
4175 if(!autocvar_hud_chat && !autocvar__hud_configure)
4177 cvar_set("con_chatrect", "0");
4181 active_panel = HUD_PANEL_CHAT;
4182 HUD_Panel_UpdateCvars(chat);
4185 mySize = panel_size;
4187 HUD_Panel_DrawBg(1);
4188 if(panel_bg_padding)
4190 pos += '1 1 0' * panel_bg_padding;
4191 mySize -= '2 2 0' * panel_bg_padding;
4194 cvar_set("con_chatrect", "1");
4196 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4197 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4199 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4200 cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
4202 if(autocvar__hud_configure)
4205 chatsize = cvar("con_chatsize");
4206 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4208 for(i = 0; i < cvar("con_chat"); ++i)
4210 if(i == cvar("con_chat") - 1)
4213 a = panel_fg_alpha * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
4214 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);
4219 // Engine info panel (#13)
4226 float frametimeavg1; // 1 frame ago
4227 float frametimeavg2; // 2 frames ago
4228 void HUD_EngineInfo(void)
4230 if(!autocvar_hud_engineinfo && !autocvar__hud_configure)
4233 active_panel = HUD_PANEL_ENGINEINFO;
4234 HUD_Panel_UpdateCvars(engineinfo);
4237 mySize = panel_size;
4239 HUD_Panel_DrawBg(1);
4240 if(panel_bg_padding)
4242 pos += '1 1 0' * panel_bg_padding;
4243 mySize -= '2 2 0' * panel_bg_padding;
4246 if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
4248 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4249 frametimeavg2 = frametimeavg1;
4250 frametimeavg1 = frametimeavg;
4253 weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4254 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.
4256 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
4257 prevfps = (1/frametime);
4258 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"
4264 if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
4266 prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
4268 prevfps_time = time;
4273 color = HUD_Get_Num_Color (prevfps, 100);
4274 drawfont = hud_bigfont;
4275 drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4276 drawfont = hud_font;
4279 // Info messages panel (#14)
4281 void HUD_InfoMessages(void)
4283 if(!autocvar_hud_infomessages && !autocvar__hud_configure)
4286 active_panel = HUD_PANEL_INFOMESSAGES;
4287 HUD_Panel_UpdateCvars(infomessages);
4290 mySize = panel_size;
4292 HUD_Panel_DrawBg(1);
4293 if(panel_bg_padding)
4295 pos += '1 1 0' * panel_bg_padding;
4296 mySize -= '2 2 0' * panel_bg_padding;
4299 // always force 6:1 aspect
4301 if(mySize_x/mySize_y > 6)
4303 newSize_x = 6 * mySize_y;
4304 newSize_y = mySize_y;
4306 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4310 newSize_y = 1/6 * mySize_x;
4311 newSize_x = mySize_x;
4313 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4322 fontsize = '0.25 0.25 0' * mySize_y;
4325 if(!autocvar__hud_configure)
4327 if(spectatee_status && !intermission)
4329 //drawfont = hud_bigfont;
4330 if(spectatee_status == -1)
4333 s = GetPlayerName(spectatee_status - 1);
4335 //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
4336 //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, panel_fg_alpha, DRAWFLAG_NORMAL);
4337 //drawfont = hud_font;
4339 // spectator text in the upper right corner
4340 if(spectatee_status == -1)
4341 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
4343 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
4344 if(autocvar_hud_infomessages_flip)
4345 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4346 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4347 o += eY * fontsize_y;
4349 if(spectatee_status == -1)
4350 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
4352 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
4353 if(autocvar_hud_infomessages_flip)
4354 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4355 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4356 o += eY * fontsize_y;
4358 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
4359 if(autocvar_hud_infomessages_flip)
4360 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4361 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4362 o += eY * fontsize_y;
4364 if(gametype == GAME_ARENA)
4365 s = "^1Wait for your turn to join";
4366 else if(gametype == GAME_LMS)
4369 sk = playerslots[player_localentnum - 1];
4370 if(sk.(scores[ps_primary]) >= 666)
4371 s = "^1Match has already begun";
4372 else if(sk.(scores[ps_primary]) > 0)
4373 s = "^1You have no more lives left";
4375 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4378 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
4379 if(autocvar_hud_infomessages_flip)
4380 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4381 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4382 o += eY * fontsize_y;
4384 //show restart countdown:
4385 if (time < getstatf(STAT_GAMESTARTTIME)) {
4387 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4388 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4389 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
4390 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4391 o += eY * fontsize_y;
4394 if(warmup_stage && !intermission)
4396 s = "^2Currently in ^1warmup^2 stage!";
4397 if(autocvar_hud_infomessages_flip)
4398 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4399 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4400 o += eY * fontsize_y;
4404 if(mod(time, 1) >= 0.5)
4409 if(ready_waiting && !intermission && !spectatee_status)
4411 if(ready_waiting_for_me)
4414 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
4416 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
4421 s = strcat("^2Waiting for others to ready up to end warmup...");
4423 s = strcat("^2Waiting for others to ready up...");
4425 if(autocvar_hud_infomessages_flip)
4426 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4427 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4428 o += eY * fontsize_y;
4430 else if(warmup_stage && !intermission && !spectatee_status)
4432 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
4433 if(autocvar_hud_infomessages_flip)
4434 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4435 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4436 o += eY * fontsize_y;
4439 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4441 float ts_min, ts_max;
4442 tm = teams.sort_next;
4445 for(; tm.sort_next; tm = tm.sort_next)
4447 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4449 if(!ts_min) ts_min = tm.team_size;
4450 else ts_min = min(ts_min, tm.team_size);
4451 if(!ts_max) ts_max = tm.team_size;
4452 else ts_max = max(ts_max, tm.team_size);
4454 if ((ts_max - ts_min) > 1)
4456 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
4457 tm = GetTeam(myteam, false);
4459 if (tm.team != COLOR_SPECTATOR)
4460 if (tm.team_size == ts_max)
4461 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
4463 if(autocvar_hud_infomessages_flip)
4464 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4465 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4466 o += eY * fontsize_y;
4473 s = "^7Press ^3ESC ^7to show HUD options.";
4474 if(autocvar_hud_infomessages_flip)
4475 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4476 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4477 o += eY * fontsize_y;
4478 s = "^3Doubleclick ^7a panel for panel-specific options.";
4479 if(autocvar_hud_infomessages_flip)
4480 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4481 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4482 o += eY * fontsize_y;
4483 s = "^3CTRL ^7to disable collision testing, ^3SHIFT ^7and";
4484 if(autocvar_hud_infomessages_flip)
4485 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4486 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4487 o += eY * fontsize_y;
4488 s = "^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.";
4489 if(autocvar_hud_infomessages_flip)
4490 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);
4491 drawcolorcodedstring(o, s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
4492 o += eY * fontsize_y;
4502 void HUD_ShowSpeed(void)
4505 float pos, conversion_factor;
4506 string speed, zspeed, unit;
4508 switch(cvar("cl_showspeed_unit"))
4513 conversion_factor = 1.0;
4517 conversion_factor = 1.0;
4521 conversion_factor = 0.0254;
4525 conversion_factor = 0.0254 * 3.6;
4529 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4533 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4537 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
4539 numsize_x = numsize_y = cvar("cl_showspeed_size");
4540 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
4542 drawfont = hud_bigfont;
4543 drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4545 if (cvar("cl_showspeed_z") == 1) {
4546 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
4547 drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
4550 drawfont = hud_font;
4553 vector acc_prevspeed;
4557 void HUD_ShowAcceleration(void)
4559 float acceleration, sz, scale, alpha, f;
4560 vector pos, top, rgb;
4561 top_x = vid_conwidth/2;
4564 f = time - acc_prevtime;
4565 if(cvar("cl_showacceleration_z"))
4566 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
4568 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
4569 acc_prevspeed = pmove_vel;
4570 acc_prevtime = time;
4572 f = bound(0, f * 10, 1);
4573 acc_avg = acc_avg * (1 - f) + acceleration * f;
4574 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
4576 pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
4578 sz = cvar("cl_showacceleration_size");
4579 scale = cvar("cl_showacceleration_scale");
4580 alpha = cvar("cl_showacceleration_alpha");
4581 if (cvar("cl_showacceleration_color_custom"))
4582 rgb = stov(cvar_string("cl_showacceleration_color"));
4585 if (acceleration < 0) {
4586 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
4587 } else if (acceleration > 0) {
4588 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
4592 if (acceleration > 0)
4593 HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4594 else if (acceleration < 0)
4595 HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_fg_alpha, DRAWFLAG_NORMAL);
4598 void HUD_Reset (void)
4600 // reset gametype specific icons
4601 if(gametype == GAME_KEYHUNT)
4603 else if(gametype == GAME_CTF)
4604 HUD_Mod_CTF_Reset();
4607 #define HUD_DrawPanel(id)\
4609 case (HUD_PANEL_RADAR):\
4610 HUD_Radar(); break;\
4611 case (HUD_PANEL_WEAPONICONS):\
4612 HUD_WeaponIcons(); break;\
4613 case (HUD_PANEL_INVENTORY):\
4614 HUD_Inventory(); break;\
4615 case (HUD_PANEL_POWERUPS):\
4616 HUD_Powerups(); break;\
4617 case (HUD_PANEL_HEALTHARMOR):\
4618 HUD_HealthArmor(); break;\
4619 case (HUD_PANEL_NOTIFY):\
4620 HUD_Notify(); break;\
4621 case (HUD_PANEL_TIMER):\
4622 HUD_Timer(); break;\
4623 case (HUD_PANEL_SCORE):\
4624 HUD_Score(); break;\
4625 case (HUD_PANEL_RACETIMER):\
4626 HUD_RaceTimer(); break;\
4627 case (HUD_PANEL_VOTE):\
4628 HUD_VoteWindow(); break;\
4629 case (HUD_PANEL_MODICONS):\
4630 HUD_ModIcons(); break;\
4631 case (HUD_PANEL_PRESSEDKEYS):\
4632 HUD_DrawPressedKeys(); break;\
4633 case (HUD_PANEL_CHAT):\
4635 case (HUD_PANEL_ENGINEINFO):\
4636 HUD_EngineInfo(); break;\
4637 case (HUD_PANEL_INFOMESSAGES):\
4638 HUD_InfoMessages(); break;\
4641 void HUD_Main (void)
4643 hud_skin_path = strcat("gfx/hud/", autocvar_hud_skin);
4645 if(disable_menu_alphacheck == 1)
4646 menu_fade_alpha = 1;
4648 menu_fade_alpha = (1 - autocvar__menu_alpha);
4649 hud_fg_alpha = cvar("hud_fg_alpha");
4651 hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
4652 hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
4653 hud_color_bg_team = cvar("hud_color_bg_team");
4655 hud_fontsize = HUD_GetFontsize("hud_fontsize");
4656 hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
4660 // HUD configure visible grid
4661 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4665 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_xsize, 0.2); ++i)
4667 drawfill(eX * i * vid_conwidth * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2), eX + eY * vid_conheight, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4670 for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_ysize, 0.2); ++i)
4672 drawfill(eY * i * vid_conheight * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2), eY + eX * vid_conwidth, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4678 if((teamplay) && autocvar_hud_dock_color_team) {
4679 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4680 color = colormapPaletteColor(mod(f, 16), 1) * autocvar_hud_dock_color_team;
4682 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && autocvar_hud_dock_color_team) {
4683 color = '1 0 0' * autocvar_hud_dock_color_team;
4685 else if(autocvar_hud_dock_color == "shirt") {
4686 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4687 color = colormapPaletteColor(floor(f / 16), 0);
4689 else if(autocvar_hud_dock_color == "pants") {
4690 f = stof(getplayerkey(player_localentnum - 1, "colors"));
4691 color = colormapPaletteColor(mod(f, 16), 1);
4694 color = stov(autocvar_hud_dock_color);
4697 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4700 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4701 if(precache_pic(pic) == "") {
4702 pic = "gfx/hud/default/dock";
4704 drawpic('0 0 0', pic, eX * vid_conwidth + eY * vid_conheight, color, autocvar_hud_dock_alpha * menu_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
4707 // cache the panel order into the panel_order array
4708 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4709 if(hud_panelorder_prev)
4710 strunzone(hud_panelorder_prev);
4711 hud_panelorder_prev = strzone(autocvar__hud_panelorder);
4712 tokenize_console(autocvar__hud_panelorder);
4713 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4714 panel_order[i] = stof(argv(i));
4717 // draw panels in order specified by panel_order array
4718 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
4719 HUD_DrawPanel(panel_order[i]);
4722 // TODO hud_'ify these
4723 if (cvar("cl_showspeed"))
4725 if (cvar("cl_showacceleration"))
4726 HUD_ShowAcceleration();
4728 if (autocvar__hud_configure && spectatee_status && hud_configure_prev == -1) // try to join if we are in hud_configure mode, but still spectating, and in the first frame (in order to get rid of motd when launching a server via the menu "HUD Setup" button)
4729 localcmd("cmd selectteam auto; cmd join\n");
4731 hud_configure_prev = autocvar__hud_configure;
4733 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again
4734 disable_menu_alphacheck = 0;