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, "_ammo_color \"", cvar_string(strcat("hud_", panel_name, "_ammo_color")), "\"", "\n"));
471 fputs(fh, strcat("seta hud_", panel_name, "_ammo_alpha \"", cvar_string(strcat("hud_", panel_name, "_ammo_alpha")), "\"", "\n"));
472 fputs(fh, strcat("seta hud_", panel_name, "_aspect \"", cvar_string(strcat("hud_", panel_name, "_ammo_alpha")), "\"", "\n"));
474 case HUD_PANEL_INVENTORY:
475 fputs(fh, strcat("seta hud_", panel_name, "_onlycurrent \"", cvar_string(strcat("hud_", panel_name, "_onlycurrent")), "\"", "\n"));
476 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
478 case HUD_PANEL_POWERUPS:
479 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\"", "\n"));
480 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
481 fputs(fh, strcat("seta hud_", panel_name, "_baralign \"", cvar_string(strcat("hud_", panel_name, "_baralign")), "\"", "\n"));
483 case HUD_PANEL_HEALTHARMOR:
484 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\n"));
485 fputs(fh, strcat("seta hud_", panel_name, "_iconalign \"", cvar_string(strcat("hud_", panel_name, "_iconalign")), "\"", "\n"));
486 fputs(fh, strcat("seta hud_", panel_name, "_baralign \"", cvar_string(strcat("hud_", panel_name, "_baralign")), "\"", "\n"));
488 case HUD_PANEL_NOTIFY:
489 fputs(fh, strcat("seta hud_", panel_name, "_flip \"", cvar_string(strcat("hud_", panel_name, "_flip")), "\"", "\n"));
490 fputs(fh, strcat("seta hud_", panel_name, "_print \"", cvar_string(strcat("hud_", panel_name, "_print")), "\"", "\n"));
492 case HUD_PANEL_RADAR:
493 fputs(fh, strcat("seta hud_", panel_name, "_foreground_alpha \"", cvar_string(strcat("hud_", panel_name, "_foreground_alpha")), "\"", "\n"));
496 fputs(fh, strcat("seta hud_", panel_name, "_alreadyvoted_alpha \"", cvar_string(strcat("hud_", panel_name, "_alreadyvoted_alpha")), "\"", "\n"));
498 case HUD_PANEL_PRESSEDKEYS:
499 fputs(fh, strcat("seta hud_", panel_name, "_aspect \"", cvar_string(strcat("hud_", panel_name, "_aspect")), "\"", "\n"));
505 print("^2Successfully exported to hud_", autocvar_hud_skin, "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
510 const float hlBorderSize = 4;
511 const string hlBorder = "gfx/hud/default/border_highlighted";
512 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
513 void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
515 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
516 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);
517 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);
518 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);
519 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);
522 // draw the background/borders
523 #define HUD_Panel_DrawBg(alpha)\
525 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));\
526 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
527 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);
529 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
536 pic = strcat(hud_skin_path, "/statusbar_vertical");
537 if(precache_pic(pic) == "") {
538 pic = "gfx/hud/default/statusbar_vertical";
540 drawsubpic(pos, eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, pic, '0 0 0', '1 0.25 0', color, alpha, drawflag);
541 if(mySize_y/mySize_x > 2)
542 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);
543 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);
545 pic = strcat(hud_skin_path, "/statusbar");
546 if(precache_pic(pic) == "") {
547 pic = "gfx/hud/default/statusbar";
549 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
550 if(mySize_x/mySize_y > 2)
551 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);
552 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);
556 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
562 pic = strcat(hud_skin_path, "/num_leading");
563 if(precache_pic(pic) == "") {
564 pic = "gfx/hud/default/num_leading";
567 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
568 if(mySize_x/mySize_y > 2)
569 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);
570 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);
573 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
574 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
585 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
586 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
588 for (i = 0; i < HUD_PANEL_NUM; ++i) {
589 if(i == highlightedPanel || !panel_enabled)
592 HUD_Panel_UpdatePosSizeForId(i)
594 panel_pos -= '1 1 0' * panel_bg_border;
595 panel_size += '2 2 0' * panel_bg_border;
597 if(myPos_y + mySize_y < panel_pos_y)
599 if(myPos_y > panel_pos_y + panel_size_y)
602 if(myPos_x + mySize_x < panel_pos_x)
604 if(myPos_x > panel_pos_x + panel_size_x)
607 // OK, there IS a collision.
609 myCenter_x = myPos_x + 0.5 * mySize_x;
610 myCenter_y = myPos_y + 0.5 * mySize_y;
612 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
613 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
615 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
617 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
618 myTarget_x = panel_pos_x - mySize_x;
619 else // push it upwards
620 myTarget_y = panel_pos_y - mySize_y;
622 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
624 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
625 myTarget_x = panel_pos_x + panel_size_x;
626 else // push it upwards
627 myTarget_y = panel_pos_y - mySize_y;
629 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
631 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
632 myTarget_x = panel_pos_x - mySize_x;
633 else // push it downwards
634 myTarget_y = panel_pos_y + panel_size_y;
636 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
638 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
639 myTarget_x = panel_pos_x + panel_size_x;
640 else // push it downwards
641 myTarget_y = panel_pos_y + panel_size_y;
643 if(cvar("hud_configure_checkcollisions_debug"))
644 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
650 void HUD_Panel_SetPos(vector pos)
652 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
656 if(cvar("hud_configure_checkcollisions_debug"))
657 drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
659 if(autocvar_hud_configure_grid)
661 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;
662 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;
665 if(hud_configure_checkcollisions)
666 pos = HUD_Panel_CheckMove(pos, mySize);
668 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
669 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
672 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
674 HUD_Panel_GetName(highlightedPanel);
675 cvar_set(strcat("hud_", panel_name, "_pos"), s);
678 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
679 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
689 ratio = mySize_x/mySize_y;
691 for (i = 0; i < HUD_PANEL_NUM; ++i) {
692 if(i == highlightedPanel || !panel_enabled)
695 HUD_Panel_UpdatePosSizeForId(i)
697 panel_pos -= '1 1 0' * panel_bg_border;
698 panel_size += '2 2 0' * panel_bg_border;
700 targEndPos = panel_pos + panel_size;
702 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
703 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
706 if (resizeCorner == 1)
708 // check if this panel is on our way
709 if (resizeorigin_x <= panel_pos_x)
711 if (resizeorigin_y <= panel_pos_y)
713 if (targEndPos_x <= resizeorigin_x - mySize_x)
715 if (targEndPos_y <= resizeorigin_y - mySize_y)
718 // there is a collision:
719 // detect which side of the panel we are facing is actually limiting the resizing
720 // (which side the resize direction finds for first) and reduce the size up to there
722 // dist is the distance between resizeorigin and the "analogous" point of the panel
723 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
724 dist_x = resizeorigin_x - targEndPos_x;
725 dist_y = resizeorigin_y - targEndPos_y;
726 if (dist_y <= 0 || dist_x / dist_y > ratio)
727 mySize_x = min(mySize_x, dist_x);
729 mySize_y = min(mySize_y, dist_y);
731 else if (resizeCorner == 2)
733 if (resizeorigin_x >= targEndPos_x)
735 if (resizeorigin_y <= panel_pos_y)
737 if (panel_pos_x >= resizeorigin_x + mySize_x)
739 if (targEndPos_y <= resizeorigin_y - mySize_y)
742 dist_x = panel_pos_x - resizeorigin_x;
743 dist_y = resizeorigin_y - targEndPos_y;
744 if (dist_y <= 0 || dist_x / dist_y > ratio)
745 mySize_x = min(mySize_x, dist_x);
747 mySize_y = min(mySize_y, dist_y);
749 else if (resizeCorner == 3)
751 if (resizeorigin_x <= panel_pos_x)
753 if (resizeorigin_y >= targEndPos_y)
755 if (targEndPos_x <= resizeorigin_x - mySize_x)
757 if (panel_pos_y >= resizeorigin_y + mySize_y)
760 dist_x = resizeorigin_x - targEndPos_x;
761 dist_y = panel_pos_y - resizeorigin_y;
762 if (dist_y <= 0 || dist_x / dist_y > ratio)
763 mySize_x = min(mySize_x, dist_x);
765 mySize_y = min(mySize_y, dist_y);
767 else if (resizeCorner == 4)
769 if (resizeorigin_x >= targEndPos_x)
771 if (resizeorigin_y >= targEndPos_y)
773 if (panel_pos_x >= resizeorigin_x + mySize_x)
775 if (panel_pos_y >= resizeorigin_y + mySize_y)
778 dist_x = panel_pos_x - resizeorigin_x;
779 dist_y = panel_pos_y - resizeorigin_y;
780 if (dist_y <= 0 || dist_x / dist_y > ratio)
781 mySize_x = min(mySize_x, dist_x);
783 mySize_y = min(mySize_y, dist_y);
785 if(cvar("hud_configure_checkcollisions_debug"))
786 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
792 void HUD_Panel_SetPosSize(vector mySize)
794 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
796 resizeorigin = panel_click_resizeorigin;
799 // minimum panel size cap
800 mySize_x = max(0.025 * vid_conwidth, mySize_x);
801 mySize_y = max(0.025 * vid_conheight, mySize_y);
803 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.
805 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
806 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
809 // collision testing|
810 // -----------------+
812 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
813 if(resizeCorner == 1) {
814 myPos_x = resizeorigin_x - mySize_x;
815 myPos_y = resizeorigin_y - mySize_y;
816 } else if(resizeCorner == 2) {
817 myPos_x = resizeorigin_x;
818 myPos_y = resizeorigin_y - mySize_y;
819 } else if(resizeCorner == 3) {
820 myPos_x = resizeorigin_x - mySize_x;
821 myPos_y = resizeorigin_y;
822 } else { // resizeCorner == 4
823 myPos_x = resizeorigin_x;
824 myPos_y = resizeorigin_y;
827 // left/top screen edges
829 mySize_x = mySize_x + myPos_x;
831 mySize_y = mySize_y + myPos_y;
833 // bottom/right screen edges
834 if(myPos_x + mySize_x > vid_conwidth)
835 mySize_x = vid_conwidth - myPos_x;
836 if(myPos_y + mySize_y > vid_conheight)
837 mySize_y = vid_conheight - myPos_y;
839 if(cvar("hud_configure_checkcollisions_debug"))
840 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
842 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
843 if(autocvar_hud_configure_grid)
845 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;
846 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;
849 if(hud_configure_checkcollisions)
850 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
852 // 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)
853 mySize_x = max(0.025 * vid_conwidth, mySize_x);
854 mySize_y = max(0.025 * vid_conheight, mySize_y);
856 // do another pos check, as size might have changed by now
857 if(resizeCorner == 1) {
858 myPos_x = resizeorigin_x - mySize_x;
859 myPos_y = resizeorigin_y - mySize_y;
860 } else if(resizeCorner == 2) {
861 myPos_x = resizeorigin_x;
862 myPos_y = resizeorigin_y - mySize_y;
863 } else if(resizeCorner == 3) {
864 myPos_x = resizeorigin_x - mySize_x;
865 myPos_y = resizeorigin_y;
866 } else { // resizeCorner == 4
867 myPos_x = resizeorigin_x;
868 myPos_y = resizeorigin_y;
871 if(cvar("hud_configure_checkcollisions_debug"))
872 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
874 HUD_Panel_GetName(highlightedPanel);
876 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
877 cvar_set(strcat("hud_", panel_name, "_size"), s);
879 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
880 cvar_set(strcat("hud_", panel_name, "_pos"), s);
884 float prevMouseClicked; // previous state
885 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
886 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
889 float menu_enabled_time;
890 float pressed_key_time;
891 void HUD_Panel_Arrow_Action(float nPrimary)
893 if (highlightedPanel_prev == -1 || mouseClicked)
896 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
899 if(autocvar_hud_configure_grid)
901 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
903 if (hudShiftState & S_SHIFT)
904 step = bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
906 step = 2 * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
910 if (hudShiftState & S_SHIFT)
911 step = bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
913 step = 2 * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
918 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
919 step = vid_conheight;
922 if (hudShiftState & S_SHIFT)
923 step = (step / 256); // more precision
925 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
928 highlightedPanel = highlightedPanel_prev;
930 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
932 if (hudShiftState & S_ALT) // resize
934 highlightedAction = 1;
935 if(nPrimary == K_UPARROW)
937 else if(nPrimary == K_RIGHTARROW)
939 else if(nPrimary == K_LEFTARROW)
941 else // if(nPrimary == K_DOWNARROW)
944 // ctrl+arrow reduces the size, instead of increasing it
945 // Note that ctrl disables collisions check too, but it's fine
946 // since we don't collide with anything reducing the size
947 if (hudShiftState & S_CTRL) {
949 resizeCorner = 5 - resizeCorner;
954 panel_click_resizeorigin = panel_pos;
955 if(resizeCorner == 1) {
956 panel_click_resizeorigin += mySize;
958 } else if(resizeCorner == 2) {
959 panel_click_resizeorigin_y += mySize_y;
961 } else if(resizeCorner == 3) {
962 panel_click_resizeorigin_x += mySize_x;
964 } else { // resizeCorner == 4
967 HUD_Panel_SetPosSize(mySize);
971 highlightedAction = 2;
974 if(nPrimary == K_UPARROW)
976 else if(nPrimary == K_DOWNARROW)
978 else if(nPrimary == K_LEFTARROW)
980 else // if(nPrimary == K_RIGHTARROW)
983 HUD_Panel_SetPos(pos);
987 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
989 if(!autocvar__hud_configure)
992 // allow console bind to work
995 con_keys = findkeysforcommand("toggleconsole");
996 keys = tokenize(con_keys);
998 float hit_con_bind, i;
999 for (i = 0; i < keys; ++i)
1001 if(nPrimary == stof(argv(i)))
1005 if(bInputType == 0) {
1006 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1007 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1008 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1010 else if(bInputType == 1) {
1011 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1012 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1013 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1016 if(nPrimary == K_MOUSE1)
1018 if(bInputType == 0) { // key pressed
1022 else if(bInputType == 1) {// key released
1027 else if(nPrimary == K_ESCAPE)
1029 if (bInputType == 1)
1031 disable_menu_alphacheck = 1;
1033 menu_enabled_time = time;
1034 localcmd("menu_showhudexit\n");
1036 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1038 if (bInputType == 1)
1040 pressed_key_time = 0;
1043 else if (pressed_key_time == 0)
1044 pressed_key_time = time;
1046 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1048 else if(hit_con_bind)
1051 return true; // Suppress ALL other input
1054 float HUD_Panel_HighlightCheck()
1060 while(j <= HUD_PANEL_NUM)
1065 HUD_Panel_UpdatePosSizeForId(i)
1067 panelPos = panel_pos;
1068 panelSize = panel_size;
1069 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1072 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1076 // resize from topleft border
1077 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)
1081 // resize from topright border
1082 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)
1086 // resize from bottomleft border
1087 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)
1091 // resize from bottomright border
1092 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)
1100 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1101 void HUD_Panel_FirstInDrawQ(float id)
1104 var float place = -1;
1105 // find out where in the array our current id is, save into place
1106 for(i = 0; i < HUD_PANEL_NUM; ++i)
1108 if(panel_order[i] == id)
1114 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1116 place = HUD_PANEL_NUM - 1;
1118 // move all ids up by one step in the array until "place"
1119 for(i = place; i > 0; --i)
1121 panel_order[i] = panel_order[i-1];
1123 // now save the new top id
1124 panel_order[0] = id;
1126 // let's save them into the cvar by some strcat trickery
1128 for(i = 0; i < HUD_PANEL_NUM; ++i)
1130 s = strcat(s, ftos(panel_order[i]), " ");
1132 cvar_set("_hud_panelorder", s);
1133 if(hud_panelorder_prev)
1134 strunzone(hud_panelorder_prev);
1135 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1138 void HUD_Panel_Highlight()
1144 while(j <= HUD_PANEL_NUM)
1149 HUD_Panel_UpdatePosSizeForId(i)
1151 panelPos = panel_pos;
1152 panelSize = panel_size;
1153 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1156 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1158 highlightedPanel = i;
1159 HUD_Panel_FirstInDrawQ(i);
1160 highlightedAction = 1;
1161 panel_click_distance = mousepos - panelPos;
1164 // resize from topleft border
1165 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)
1167 highlightedPanel = i;
1168 HUD_Panel_FirstInDrawQ(i);
1169 highlightedAction = 2;
1171 panel_click_distance = mousepos - panelPos;
1172 panel_click_resizeorigin = panelPos + panelSize;
1175 // resize from topright border
1176 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)
1178 highlightedPanel = i;
1179 HUD_Panel_FirstInDrawQ(i);
1180 highlightedAction = 2;
1182 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1183 panel_click_distance_y = mousepos_y - panelPos_y;
1184 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1187 // resize from bottomleft border
1188 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)
1190 highlightedPanel = i;
1191 HUD_Panel_FirstInDrawQ(i);
1192 highlightedAction = 2;
1194 panel_click_distance_x = mousepos_x - panelPos_x;
1195 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1196 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1199 // resize from bottomright border
1200 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)
1202 highlightedPanel = i;
1203 HUD_Panel_FirstInDrawQ(i);
1204 highlightedAction = 2;
1206 panel_click_distance = panelSize - mousepos + panelPos;
1207 panel_click_resizeorigin = panelPos;
1212 highlightedPanel_prev = -1;
1217 float highlightcheck;
1218 void HUD_Panel_Mouse()
1220 // 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
1221 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1222 disable_menu_alphacheck = 0;
1223 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1227 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1228 print("Highlighted: ", ftos(highlightedPanel), "\n");
1229 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1232 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1233 highlightedPanel = -1;
1234 highlightedAction = 0;
1236 if(highlightedPanel != -1)
1237 highlightedPanel_prev = highlightedPanel;
1239 mousepos = mousepos + getmousepos();
1241 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1242 mousepos_y = bound(0, mousepos_y, vid_conheight);
1246 if(prevMouseClicked == 0)
1247 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1249 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1251 if(highlightedAction == 1)
1252 HUD_Panel_SetPos(mousepos - panel_click_distance);
1253 else if(highlightedAction == 2)
1256 if(resizeCorner == 1) {
1257 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1258 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1259 } else if(resizeCorner == 2) {
1260 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1261 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1262 } else if(resizeCorner == 3) {
1263 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1264 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1265 } else { // resizeCorner == 4
1266 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1267 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1269 HUD_Panel_SetPosSize(mySize);
1272 // doubleclick check
1273 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1275 mouseClicked = 0; // to prevent spam, I guess.
1276 disable_menu_alphacheck = 2;
1278 menu_enabled_time = time;
1279 HUD_Panel_GetName(highlightedPanel)
1280 localcmd("menu_showhudoptions ", panel_name, "\n");
1283 if(prevMouseClicked == 0)
1285 prevMouseClickedTime = time;
1286 prevMouseClickedPos = mousepos;
1291 highlightcheck = HUD_Panel_HighlightCheck();
1293 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1296 cursorsize = '32 32 0';
1298 if(highlightcheck == 0)
1299 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1300 else if(highlightcheck == 1)
1301 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1302 else if(highlightcheck == 2)
1303 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1305 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1307 prevMouseClicked = mouseClicked;
1310 // Weapon icons (#0)
1312 float weaponspace[10];
1313 #define HUD_WeaponIcons_Clear()\
1315 for(idx = 0; idx < 10; ++idx)\
1316 weaponspace[idx] = 0;
1318 entity weaponorder[WEP_MAXCOUNT];
1319 void weaponorder_swap(float i, float j, entity pass)
1323 weaponorder[i] = weaponorder[j];
1327 string weaponorder_cmp_str_save;
1328 string weaponorder_cmp_str;
1329 float weaponorder_cmp(float i, float j, entity pass)
1332 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1333 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1334 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)
1337 float GetAmmoStat(float i)
1341 case 0: return STAT_SHELLS;
1342 case 1: return STAT_NAILS;
1343 case 2: return STAT_ROCKETS;
1344 case 3: return STAT_CELLS;
1345 case 4: return STAT_FUEL;
1350 float GetAmmoTypeForWep(float i)
1354 case WEP_SHOTGUN: return 0;
1355 case WEP_UZI: return 1;
1356 case WEP_CAMPINGRIFLE: return 1;
1357 case WEP_GRENADE_LAUNCHER: return 2;
1358 case WEP_ELECTRO: return 3;
1359 case WEP_CRYLINK: return 3;
1360 case WEP_HLAC: return 3;
1361 case WEP_MINSTANEX: return 3;
1362 case WEP_NEX: return 3;
1363 case WEP_HAGAR: return 2;
1364 case WEP_ROCKET_LAUNCHER: return 2;
1365 case WEP_SEEKER: return 2;
1366 case WEP_FIREBALL: return 4;
1367 case WEP_HOOK: return 3;
1372 void HUD_WeaponIcons(void)
1374 if(!autocvar_hud_weaponicons && !autocvar__hud_configure)
1377 float id = HUD_PANEL_WEAPONICONS;
1378 HUD_Panel_UpdateCvarsForId(id);
1379 float alpha, stat_weapons; // "constants"
1381 float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
1384 mySize = panel_size;
1386 stat_weapons = getstati(STAT_WEAPONS);
1388 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1390 self = get_weaponinfo(i);
1391 if(self.impulse >= 0)
1395 // TODO make this configurable
1396 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1398 if(weaponorder_cmp_str != weaponorder_cmp_str_save)
1400 if(weaponorder_cmp_str_save)
1401 strunzone(weaponorder_cmp_str_save);
1402 weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
1404 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1406 self = get_weaponinfo(i);
1407 if(self.impulse >= 0)
1409 weaponorder[weapon_cnt] = self;
1413 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1416 HUD_Panel_DrawBg(1);
1417 if(panel_bg_padding)
1419 pos += '1 1 0' * panel_bg_padding;
1420 mySize -= '2 2 0' * panel_bg_padding;
1424 weapon_stats = getstati(STAT_DAMAGE_HITS);
1425 weapon_number = weapon_stats & 63;
1426 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1428 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1429 weapon_number = weapon_stats & 63;
1430 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1432 if(cvar_or("hud_weaponicons_fade", 1))
1434 fade = 3.2 - 2 * (time - weapontime);
1435 fade = bound(0.7, fade, 1);
1440 HUD_WeaponIcons_Clear();
1442 float rows, columns;
1443 rows = mySize_y/mySize_x;
1444 rows = bound(1, floor((sqrt(4 * autocvar_hud_weaponicons_aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1446 columns = ceil(WEP_COUNT/rows);
1449 float a, type, fullammo;
1451 when = autocvar_hud_weaponicons_complainbubble_time;
1453 fadetime = autocvar_hud_weaponicons_complainbubble_fadetime;
1458 for(i = 0; i < weapon_cnt; ++i)
1460 wpnpos = pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows);
1461 wpnsize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
1463 self = weaponorder[i];
1464 weapid = self.impulse;
1466 alpha = (self.weapon == activeweapon) ? 1 : 0.6;
1468 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1469 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1471 // draw background behind currently selected weapon
1472 if(self.weapon == activeweapon)
1473 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1475 // draw the weapon accuracy
1476 if(autocvar_hud_weaponicons_accuracy && !(gametype == GAME_RACE || gametype == GAME_CTS))
1479 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1481 // yellow_accuracy = value at which accuracy becomes yellow
1482 if(weapon_stats >= 100) {
1486 else if(weapon_stats > autocvar_hud_weaponicons_accuracy_yellow) {
1487 color_x = 1 - (weapon_stats-autocvar_hud_weaponicons_accuracy_yellow)/(100-autocvar_hud_weaponicons_accuracy_yellow); // red value between 1 -> 0
1491 color_y = weapon_stats/autocvar_hud_weaponicons_accuracy_yellow; // green value between 0 -> 1
1496 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1499 // draw the weapon icon
1500 if((self.impulse >= 0) && (stat_weapons & self.weapons))
1502 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1504 if(autocvar_hud_weaponicons_number == 1) // weapon number
1505 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * mySize_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1506 else if(autocvar_hud_weaponicons_number == 2) // bind
1507 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);
1509 // draw ammo status bar
1510 if(autocvar_hud_weaponicons_ammo && weapid != WEP_TUBA && weapid != WEP_LASER && weapid != WEP_PORTO)
1513 type = GetAmmoTypeForWep(weapid);
1515 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
1520 case 0: fullammo = autocvar_hud_weaponicons_ammo_full_shells; break;
1521 case 1: fullammo = autocvar_hud_weaponicons_ammo_full_nails; break;
1522 case 2: fullammo = autocvar_hud_weaponicons_ammo_full_rockets; break;
1523 case 3: fullammo = autocvar_hud_weaponicons_ammo_full_cells; break;
1524 case 4: fullammo = autocvar_hud_weaponicons_ammo_full_fuel; break;
1525 default: fullammo = 60;
1530 if(wpnsize_x/wpnsize_y > autocvar_hud_weaponicons_aspect)
1532 barsize_x = autocvar_hud_weaponicons_aspect * wpnsize_y;
1533 barsize_y = wpnsize_y;
1535 barpos_x = wpnpos_x + (wpnsize_x - barsize_x) / 2;
1536 barpos_y = wpnpos_y;
1540 barsize_y = 1/autocvar_hud_weaponicons_aspect * wpnsize_x;
1541 barsize_x = wpnsize_x;
1543 barpos_y = wpnpos_y + (wpnsize_y - barsize_y) / 2;
1544 barpos_x = wpnpos_x;
1550 barsize_x * bound(0, a/fullammo, 1),
1552 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, autocvar_hud_weaponicons_ammo_color, panel_fg_alpha * autocvar_hud_weaponicons_ammo_alpha, DRAWFLAG_NORMAL);
1553 drawresetcliparea();
1558 // draw a "ghost weapon icon" if you don't have the weapon
1561 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
1564 // draw the complain message
1565 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_weaponicons_complainbubble)
1569 if(complain_weapon_time + when > time)
1572 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1576 if(complain_weapon_time + when > time)
1583 if(complain_weapon_type == 0) {
1587 else if(complain_weapon_type == 1) {
1595 drawpic_aspect_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows) + '1 1 0' * autocvar_hud_weaponicons_complainbubble_padding, "weapon_complainbubble", eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows) - '2 2 0' * autocvar_hud_weaponicons_complainbubble_padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
1596 drawstring_aspect(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows) + '1 1 0' * autocvar_hud_weaponicons_complainbubble_padding, s, eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows) - '2 2 0' * autocvar_hud_weaponicons_complainbubble_padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
1612 float GetAmmoItemCode(float i)
1616 case 0: return IT_SHELLS;
1617 case 1: return IT_NAILS;
1618 case 2: return IT_ROCKETS;
1619 case 3: return IT_CELLS;
1620 case 4: return IT_FUEL;
1625 string GetAmmoPicture(float i)
1629 case 0: return "ammo_shells";
1630 case 1: return "ammo_bullets";
1631 case 2: return "ammo_rockets";
1632 case 3: return "ammo_cells";
1633 case 4: return "ammo_fuel";
1638 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1641 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1642 if(autocvar__hud_configure)
1652 if(currently_selected)
1657 vector newSize, newPos;
1658 if(mySize_x/mySize_y > 3)
1660 newSize_x = 3 * mySize_y;
1661 newSize_y = mySize_y;
1663 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1668 newSize_y = 1/3 * mySize_x;
1669 newSize_x = mySize_x;
1671 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1675 vector picpos, numpos;
1676 if(autocvar_hud_inventory_iconalign)
1679 picpos = newPos + eX * 2 * newSize_y;
1683 numpos = newPos + eX * newSize_y;
1687 if (currently_selected)
1688 drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1690 drawfont = hud_bigfont;
1691 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1692 drawfont = hud_font;
1693 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1696 void HUD_Inventory(void)
1698 if(!autocvar_hud_inventory && !autocvar__hud_configure)
1701 float id = HUD_PANEL_INVENTORY;
1702 HUD_Panel_UpdateCvarsForId(id);
1703 float i, currently_selected;
1707 mySize = panel_size;
1709 HUD_Panel_DrawBg(1);
1710 if(panel_bg_padding)
1712 pos += '1 1 0' * panel_bg_padding;
1713 mySize -= '2 2 0' * panel_bg_padding;
1716 float rows, columns;
1717 rows = mySize_y/mySize_x;
1718 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1719 // ^^^ ammo item aspect goes here
1721 columns = ceil(AMMO_COUNT/rows);
1725 for (i = 0; i < AMMO_COUNT; ++i) {
1726 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1727 if(autocvar_hud_inventory_onlycurrent) {
1728 if(autocvar__hud_configure)
1730 if (currently_selected || autocvar__hud_configure)
1732 DrawAmmoItem(pos, mySize, i, currently_selected);
1736 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);
1741 column = column + 1;
1747 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float alpha)
1749 vector newSize, newPos;
1750 if(mySize_x/mySize_y > 3)
1752 newSize_x = 3 * mySize_y;
1753 newSize_y = mySize_y;
1755 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1760 newSize_y = 1/3 * mySize_x;
1761 newSize_x = mySize_x;
1763 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1767 vector picpos, numpos;
1770 if(iconalign == 1 || iconalign == 3) // right align
1773 picpos = newPos + eX * 2 * newSize_y;
1777 numpos = newPos + eX * newSize_y;
1783 if(iconalign == 0 || iconalign == 3) // left align
1785 numpos = newPos + eX * newSize_y;
1791 picpos = newPos + eX * 2 * newSize_y;
1795 drawfont = hud_bigfont;
1796 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1797 drawfont = hud_font;
1798 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1801 void DrawNumIcon_expanding(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float fadelerp)
1804 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
1806 DrawNumIcon(iconalign, myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, left, color, (1 - fadelerp));
1811 void HUD_Powerups(void) {
1812 if(!autocvar_hud_powerups && !autocvar__hud_configure)
1815 float id = HUD_PANEL_POWERUPS;
1816 HUD_Panel_UpdateCvarsForId(id);
1818 stat_items = getstati(STAT_ITEMS);
1820 if(!autocvar__hud_configure)
1822 if not(stat_items & IT_STRENGTH)
1823 if not(stat_items & IT_INVINCIBLE)
1826 if (getstati(STAT_HEALTH) <= 0)
1832 mySize = panel_size;
1834 float strength_time, shield_time;
1836 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1837 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1839 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
1840 if(panel_bg_padding)
1842 pos += '1 1 0' * panel_bg_padding;
1843 mySize -= '2 2 0' * panel_bg_padding;
1846 if(autocvar__hud_configure)
1852 vector barpos, barsize;
1856 string leftname, rightname;
1857 float leftcnt, rightcnt;
1858 float leftexact, rightexact;
1859 if (autocvar_hud_powerups_flip) {
1860 leftname = "strength";
1861 leftcnt = ceil(strength_time);
1862 leftexact = strength_time;
1864 rightname = "shield";
1865 rightcnt = ceil(shield_time);
1866 rightexact = shield_time;
1868 leftname = "shield";
1869 leftcnt = ceil(shield_time);
1870 leftexact = shield_time;
1872 rightname = "strength";
1873 rightcnt = ceil(strength_time);
1874 rightexact = strength_time;
1877 drawfont = hud_bigfont;
1878 if (mySize_x/mySize_y > 4)
1882 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1883 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1884 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1885 } else { // left align
1887 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1890 HUD_Panel_GetProgressBarColor(leftname)
1891 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);
1893 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
1895 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));
1900 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1901 barpos = pos + eX * 0.5 * mySize_x;
1902 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1903 } else { // right align
1904 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1905 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1908 HUD_Panel_GetProgressBarColor(rightname)
1909 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);
1911 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);
1913 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));
1916 else if (mySize_x/mySize_y > 1.5)
1920 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // right align
1921 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1922 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1923 } else { // left align
1925 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1928 HUD_Panel_GetProgressBarColor(leftname)
1929 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);
1931 DrawNumIcon(autocvar_hud_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
1933 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));
1938 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // left align
1939 barpos = pos + eY * 0.5 * mySize_y;
1940 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1941 } else { // right align
1942 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1943 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1946 HUD_Panel_GetProgressBarColor(rightname)
1947 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);
1949 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);
1951 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));
1958 if(autocvar_hud_powerups_baralign == 1 || autocvar_hud_powerups_baralign == 3) { // down align
1959 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1960 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1961 } else { // up align
1963 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1966 if(autocvar_hud_powerups_iconalign == 1 || autocvar_hud_powerups_iconalign == 3) { // down align
1967 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
1968 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
1969 } else { // up align
1970 picpos = pos + eX * 0.05 * mySize_x;
1971 numpos = pos + eY * 0.4 * mySize_x;
1974 HUD_Panel_GetProgressBarColor(leftname)
1975 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);
1977 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));
1979 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1980 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1985 if(autocvar_hud_powerups_baralign == 0 || autocvar_hud_powerups_baralign == 3) { // up align
1986 barpos = pos + eX * 0.5 * mySize_x;
1987 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1988 } else { // down align
1989 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
1990 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
1993 if(autocvar_hud_powerups_iconalign == 0 || autocvar_hud_powerups_iconalign == 3) { // up align
1994 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
1995 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
1996 } else { // down align
1997 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
1998 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2001 HUD_Panel_GetProgressBarColor(rightname)
2002 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);
2004 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));
2006 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2007 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2010 drawfont = hud_font;
2013 // Health/armor (#3)
2015 void HUD_HealthArmor(void)
2017 if(!autocvar_hud_healtharmor && !autocvar__hud_configure)
2020 float id = HUD_PANEL_HEALTHARMOR;
2021 HUD_Panel_UpdateCvarsForId(id);
2024 mySize = panel_size;
2026 HUD_Panel_DrawBg(1);
2027 if(panel_bg_padding)
2029 pos += '1 1 0' * panel_bg_padding;
2030 mySize -= '2 2 0' * panel_bg_padding;
2033 float armor, health;
2034 armor = getstati(STAT_ARMOR);
2035 health = getstati(STAT_HEALTH);
2038 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
2040 if(autocvar__hud_configure)
2050 vector barpos, barsize;
2054 drawfont = hud_bigfont;
2055 if(autocvar_hud_healtharmor == 2) // combined health and armor display
2058 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2063 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2064 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2065 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2066 } else { // left align
2068 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2072 if(v_z) // NOT fully armored
2074 biggercount = "health";
2075 HUD_Panel_GetProgressBarColor("health")
2076 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2078 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);
2082 biggercount = "armor";
2083 HUD_Panel_GetProgressBarColor("armor")
2084 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2086 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);
2088 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200), 1);
2093 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2094 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2095 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2098 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2100 HUD_Panel_GetProgressBarColor("fuel")
2101 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2106 string leftname, rightname;
2107 float leftcnt, rightcnt;
2108 float leftactive, rightactive;
2109 float leftalpha, rightalpha;
2110 if (autocvar_hud_healtharmor_flip) { // old style layout with armor left/top of health
2115 leftalpha = min((armor+10)/55, 1);
2117 rightname = "health";
2122 leftname = "health";
2127 rightname = "armor";
2131 rightalpha = min((armor+10)/55, 1);
2134 if (mySize_x/mySize_y > 4)
2138 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2139 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2140 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2141 } else { // left align
2143 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2146 HUD_Panel_GetProgressBarColor(leftname)
2147 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2148 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
2153 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2154 barpos = pos + eX * 0.5 * mySize_x;
2155 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2156 } else { // right align
2157 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2158 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2161 HUD_Panel_GetProgressBarColor(rightname)
2162 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2163 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);
2168 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2169 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2170 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2173 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2175 HUD_Panel_GetProgressBarColor("fuel")
2176 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2179 else if (mySize_x/mySize_y > 1.5)
2183 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // right align
2184 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2185 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2186 } else { // left align
2188 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2191 HUD_Panel_GetProgressBarColor(leftname)
2192 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2193 DrawNumIcon(autocvar_hud_healtharmor_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
2198 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2199 barpos = pos + eY * 0.5 * mySize_y;
2200 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2201 } else { // right align
2202 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2203 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2206 HUD_Panel_GetProgressBarColor(rightname)
2207 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2208 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);
2213 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2214 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2215 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2218 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2220 HUD_Panel_GetProgressBarColor("fuel")
2221 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2228 if(autocvar_hud_healtharmor_baralign == 1 || autocvar_hud_healtharmor_baralign == 3) { // down align
2229 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2230 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2231 } else { // up align
2233 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2236 if(autocvar_hud_healtharmor_iconalign == 1 || autocvar_hud_healtharmor_iconalign == 3) { // down align
2237 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2238 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2239 } else { // up align
2240 picpos = pos + eX * 0.05 * mySize_x;
2241 numpos = pos + eY * 0.4 * mySize_x;
2244 HUD_Panel_GetProgressBarColor(leftname)
2245 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2246 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2247 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);
2252 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // up align
2253 barpos = pos + eX * 0.5 * mySize_x;
2254 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2255 } else { // down align
2256 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2257 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2260 if(autocvar_hud_healtharmor_iconalign == 0 || autocvar_hud_healtharmor_iconalign == 3) { // up align
2261 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2262 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2263 } else { // down align
2264 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2265 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2268 HUD_Panel_GetProgressBarColor(rightname)
2269 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2270 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2271 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);
2276 if(autocvar_hud_healtharmor_baralign == 0 || autocvar_hud_healtharmor_baralign == 3) { // left align
2278 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2280 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2281 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2283 HUD_Panel_GetProgressBarColor("fuel")
2284 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2288 drawfont = hud_font;
2291 // Notification area (#4)
2294 string Weapon_SuicideMessage(float deathtype)
2296 w_deathtype = deathtype;
2297 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2298 return w_deathtypestring;
2301 string Weapon_KillMessage(float deathtype)
2303 w_deathtype = deathtype;
2304 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2305 return w_deathtypestring;
2308 float killnotify_times[10];
2309 float killnotify_deathtype[10];
2310 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2311 string killnotify_attackers[10];
2312 string killnotify_victims[10];
2313 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2316 for (i = 9; i > 0; --i) {
2317 killnotify_times[i] = killnotify_times[i-1];
2318 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2319 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2320 if(killnotify_attackers[i])
2321 strunzone(killnotify_attackers[i]);
2322 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2323 if(killnotify_victims[i])
2324 strunzone(killnotify_victims[i]);
2325 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2327 killnotify_times[0] = time;
2328 killnotify_deathtype[0] = wpn;
2329 killnotify_actiontype[0] = actiontype;
2330 if(killnotify_attackers[0])
2331 strunzone(killnotify_attackers[0]);
2332 killnotify_attackers[0] = strzone(attacker);
2333 if(killnotify_victims[0])
2334 strunzone(killnotify_victims[0]);
2335 killnotify_victims[0] = strzone(victim);
2338 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2341 float alsoprint, gentle;
2342 alsoprint = (autocvar_hud_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2343 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2345 if(msg == MSG_SUICIDE) {
2346 w = DEATH_WEAPONOF(type);
2348 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2350 print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
2351 } else if (type == DEATH_KILL) {
2352 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2354 print ("^1",s1, "^1 couldn't take it anymore\n");
2355 } else if (type == DEATH_ROT) {
2356 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2358 print ("^1",s1, "^1 died\n");
2359 } else if (type == DEATH_NOAMMO) {
2360 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2362 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2363 } else if (type == DEATH_CAMP) {
2364 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2366 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2367 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2368 HUD_KillNotify_Push(s1, "", 0, type);
2370 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2371 } else if (type == DEATH_CHEAT) {
2372 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2374 print ("^1",s1, "^1 unfairly eliminated themself\n");
2375 } else if (type == DEATH_FIRE) {
2376 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2378 print ("^1",s1, "^1 burned to death\n");
2379 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2380 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2382 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2385 if (stof(s2) > 2) // killcount > 2
2386 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2387 } else if(msg == MSG_KILL) {
2388 w = DEATH_WEAPONOF(type);
2390 HUD_KillNotify_Push(s2, s1, 1, w);
2392 print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
2394 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2395 HUD_KillNotify_Push(s1, s2, 1, type);
2399 print ("^1", s1, "^1 took action against a team mate\n");
2401 print ("^1", s1, "^1 mows down a team mate\n");
2404 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2406 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2408 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2410 else if (stof(s2) > 2) {
2412 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2414 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2417 else if(type == KILL_FIRST_BLOOD)
2418 print("^1",s1, "^1 drew first blood", "\n");
2420 else if (type == DEATH_TELEFRAG)
2421 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2422 else if (type == DEATH_DROWN) {
2423 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2425 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2427 else if (type == DEATH_SLIME) {
2428 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2430 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2432 else if (type == DEATH_LAVA) {
2433 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2435 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2437 else if (type == DEATH_FALL) {
2438 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2440 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2442 else if (type == DEATH_SHOOTING_STAR) {
2443 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2445 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2447 else if (type == DEATH_SWAMP) {
2448 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2450 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2452 else if (type == DEATH_HURTTRIGGER)
2454 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2456 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2457 } else if(type == DEATH_SBCRUSH) {
2458 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2460 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2461 } else if(type == DEATH_SBMINIGUN) {
2462 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2464 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2465 } else if(type == DEATH_SBROCKET) {
2466 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2468 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2469 } else if(type == DEATH_SBBLOWUP) {
2470 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2472 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2473 } else if(type == DEATH_WAKIGUN) {
2474 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2476 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2477 } else if(type == DEATH_WAKIROCKET) {
2478 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2480 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2481 } else if(type == DEATH_WAKIBLOWUP) {
2482 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2484 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2485 } else if(type == DEATH_TURRET) {
2486 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2488 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2489 } else if(type == DEATH_TOUCHEXPLODE) {
2490 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2492 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2493 } else if(type == DEATH_CHEAT) {
2494 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2496 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2497 } else if (type == DEATH_FIRE) {
2498 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2500 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2501 } else if (type == DEATH_CUSTOM) {
2502 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2504 print ("^1",s1, "^1 ", s2, "\n");
2506 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2508 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2510 } else if(msg == MSG_SPREE) {
2511 if(type == KILL_END_SPREE) {
2513 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2515 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2516 } else if(type == KILL_SPREE) {
2518 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2520 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2521 } else if(type == KILL_SPREE_3) {
2523 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2525 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2526 } else if(type == KILL_SPREE_5) {
2528 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2530 print (s1,"^7 unleashes ^1RAGE\n");
2531 } else if(type == KILL_SPREE_10) {
2533 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2535 print (s1,"^7 starts the ^1MASSACRE!\n");
2536 } else if(type == KILL_SPREE_15) {
2538 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2540 print (s1,"^7 executes ^1MAYHEM!\n");
2541 } else if(type == KILL_SPREE_20) {
2543 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2545 print (s1,"^7 is a ^1BERSERKER!\n");
2546 } else if(type == KILL_SPREE_25) {
2548 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2550 print (s1,"^7 inflicts ^1CARNAGE!\n");
2551 } else if(type == KILL_SPREE_30) {
2553 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2555 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2557 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2558 if (type == DEATH_DROWN) {
2559 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2563 print ("^1",s1, "^1 was in the water for too long\n");
2565 print ("^1",s1, "^1 drowned\n");
2567 } else if (type == DEATH_SLIME) {
2568 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2570 print ("^1",s1, "^1 was slimed\n");
2571 } else if (type == DEATH_LAVA) {
2572 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2576 print ("^1",s1, "^1 found a hot place\n");
2578 print ("^1",s1, "^1 turned into hot slag\n");
2580 } else if (type == DEATH_FALL) {
2581 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2585 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2587 print ("^1",s1, "^1 hit the ground with a crunch\n");
2589 } else if (type == DEATH_SHOOTING_STAR) {
2590 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2592 print ("^1",s1, "^1 became a shooting star\n");
2593 } else if (type == DEATH_SWAMP) {
2594 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2598 print ("^1",s1, "^1 discovered a swamp\n");
2600 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2602 } else if(type == DEATH_TURRET) {
2603 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2605 print ("^1",s1, "^1 was mowed down by a turret \n");
2606 } else if (type == DEATH_CUSTOM) {
2607 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2609 print ("^1",s1, "^1 ", s2, "\n");
2610 } else if (type == DEATH_HURTTRIGGER) {
2611 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2613 print ("^1",s1, "^1 was in the wrong place\n");
2614 } else if(type == DEATH_TOUCHEXPLODE) {
2615 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2617 print ("^1",s1, "^1 died in an accident\n");
2618 } else if(type == DEATH_CHEAT) {
2619 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2621 print ("^1",s1, "^1 was unfairly eliminated\n");
2622 } else if(type == DEATH_FIRE) {
2623 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2627 print ("^1",s1, "^1 felt a little hot\n");
2629 print ("^1",s1, "^1 burnt to death\n");
2632 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2636 print ("^1",s1, "^1 needs a restart\n");
2638 print ("^1",s1, "^1 died\n");
2641 } else if(msg == MSG_KILL_ACTION_SPREE) {
2643 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2645 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2646 } else if(msg == MSG_INFO) {
2647 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2648 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2649 print(s1, "^7 got the ", s2, "\n");
2650 } else if(type == INFO_LOSTFLAG) {
2651 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2652 print(s1, "^7 lost the ", s2, "\n");
2653 } else if(type == INFO_PICKUPFLAG) {
2654 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2655 print(s1, "^7 picked up the ", s2, "\n");
2656 } else if(type == INFO_RETURNFLAG) {
2657 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2658 print(s1, "^7 returned the ", s2, "\n");
2659 } else if(type == INFO_CAPTUREFLAG) {
2660 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
2661 print(s1, "^7 captured the ", s2, s3, "\n");
2666 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2668 void HUD_Centerprint(string s1, string s2, float type, float msg)
2671 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2672 if(msg == MSG_SUICIDE) {
2673 if (type == DEATH_TEAMCHANGE) {
2674 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2675 } else if (type == DEATH_AUTOTEAMCHANGE) {
2676 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2677 } else if (type == DEATH_CAMP) {
2679 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2681 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2682 } else if (type == DEATH_NOAMMO) {
2684 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2686 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2687 } else if (type == DEATH_ROT) {
2689 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2691 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2692 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2694 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2696 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2697 } else if (type == DEATH_QUIET) {
2699 } else if (type == DEATH_KILL) {
2701 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
2703 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
2705 } else if(msg == MSG_KILL) {
2706 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2708 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against", s1, ",a team mate!"));
2710 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
2712 } else if (type == KILL_FIRST_BLOOD) {
2714 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First score"));
2716 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First blood"));
2718 } else if (type == KILL_FIRST_VICTIM) {
2720 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First casualty"));
2722 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
2724 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2726 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^1 who was typing!", s2));
2728 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
2730 } else if (type == KILL_TYPEFRAGGED) {
2732 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^1 while you were typing!", s2));
2734 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
2736 } else if (type == KILL_FRAG) {
2738 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
2740 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
2742 } else if (type == KILL_FRAGGED) {
2744 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, s2));
2746 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were fragged by ^7", s1, s2));
2749 } else if(msg == MSG_KILL_ACTION) {
2750 // TODO: invent more centerprints here?
2751 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
2755 void HUD_Notify (void)
2757 if(!autocvar_hud_notify && !autocvar__hud_configure)
2760 float id = HUD_PANEL_NOTIFY;
2761 HUD_Panel_UpdateCvarsForId(id);
2764 mySize = panel_size;
2766 HUD_Panel_DrawBg(1);
2767 if(panel_bg_padding)
2769 pos += '1 1 0' * panel_bg_padding;
2770 mySize -= '2 2 0' * panel_bg_padding;