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_panel_bg \"", cvar_string("hud_panel_bg"), "\"", "\n"));
425 fputs(fh, strcat("seta hud_panel_bg_color \"", cvar_string("hud_panel_bg_color"), "\"", "\n"));
426 fputs(fh, strcat("seta hud_panel_bg_color_team \"", cvar_string("hud_panel_bg_color_team"), "\"", "\n"));
427 fputs(fh, strcat("seta hud_panel_bg_alpha \"", cvar_string("hud_panel_bg_alpha"), "\"", "\n"));
428 fputs(fh, strcat("seta hud_panel_bg_border \"", cvar_string("hud_panel_bg_border"), "\"", "\n"));
429 fputs(fh, strcat("seta hud_panel_bg_padding \"", cvar_string("hud_panel_bg_padding"), "\"", "\n"));
430 fputs(fh, strcat("seta hud_panel_fg_alpha \"", cvar_string("hud_panel_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 fputs(fh, strcat("seta hud_configure_grid \"", cvar_string("hud_configure_grid"), "\"", "\n"));
452 fputs(fh, strcat("seta hud_configure_grid_xsize \"", cvar_string("hud_configure_grid_xsize"), "\"", "\n"));
453 fputs(fh, strcat("seta hud_configure_grid_ysize \"", cvar_string("hud_configure_grid_ysize"), "\"", "\n"));
456 // common cvars for all panels
458 for (i = 0; i < HUD_PANEL_NUM; ++i)
462 fputs(fh, strcat("seta hud_panel_", panel_name, " ", cvar_string(strcat("hud_panel_", panel_name)), "\n"));
463 fputs(fh, strcat("seta hud_panel_", panel_name, "_pos \"", cvar_string(strcat("hud_panel_", panel_name, "_pos")), "\"", "\n"));
464 fputs(fh, strcat("seta hud_panel_", panel_name, "_size \"", cvar_string(strcat("hud_panel_", panel_name, "_size")), "\"", "\n"));
465 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg \"", cvar_string(strcat("hud_panel_", panel_name, "_bg")), "\"", "\n"));
466 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_color \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_color")), "\"", "\n"));
467 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_color_team \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_color_team")), "\"", "\n"));
468 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_alpha")), "\"", "\n"));
469 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_border \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_border")), "\"", "\n"));
470 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_padding \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_padding")), "\"", "\n"));
472 case HUD_PANEL_WEAPONS:
473 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble")), "\"", "\n"));
474 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_padding \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_padding")), "\"", "\n"));
475 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_outofammo \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_outofammo")), "\"", "\n"));
476 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_donthave \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_donthave")), "\"", "\n"));
477 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_unavailable \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_unavailable")), "\"", "\n"));
478 fputs(fh, strcat("seta hud_panel_", panel_name, "_ammo_color \"", cvar_string(strcat("hud_panel_", panel_name, "_ammo_color")), "\"", "\n"));
479 fputs(fh, strcat("seta hud_panel_", panel_name, "_ammo_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_ammo_alpha")), "\"", "\n"));
480 fputs(fh, strcat("seta hud_panel_", panel_name, "_aspect \"", cvar_string(strcat("hud_panel_", panel_name, "_aspect")), "\"", "\n"));
483 fputs(fh, strcat("seta hud_panel_", panel_name, "_onlycurrent \"", cvar_string(strcat("hud_panel_", panel_name, "_onlycurrent")), "\"", "\n"));
484 fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
486 case HUD_PANEL_POWERUPS:
487 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\"", "\n"));
488 fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
489 fputs(fh, strcat("seta hud_panel_", panel_name, "_baralign \"", cvar_string(strcat("hud_panel_", panel_name, "_baralign")), "\"", "\n"));
490 fputs(fh, strcat("seta hud_panel_", panel_name, "_progressbar \"", cvar_string(strcat("hud_panel_", panel_name, "_progressbar")), "\"", "\n"));
492 case HUD_PANEL_HEALTHARMOR:
493 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\n"));
494 fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
495 fputs(fh, strcat("seta hud_panel_", panel_name, "_baralign \"", cvar_string(strcat("hud_panel_", panel_name, "_baralign")), "\"", "\n"));
496 fputs(fh, strcat("seta hud_panel_", panel_name, "_progressbar \"", cvar_string(strcat("hud_panel_", panel_name, "_progressbar")), "\"", "\n"));
498 case HUD_PANEL_NOTIFY:
499 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\"", "\n"));
500 fputs(fh, strcat("seta hud_panel_", panel_name, "_print \"", cvar_string(strcat("hud_panel_", panel_name, "_print")), "\"", "\n"));
502 case HUD_PANEL_RADAR:
503 fputs(fh, strcat("seta hud_panel_", panel_name, "_foreground_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_foreground_alpha")), "\"", "\n"));
506 fputs(fh, strcat("seta hud_panel_", panel_name, "_alreadyvoted_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_alreadyvoted_alpha")), "\"", "\n"));
508 case HUD_PANEL_PRESSEDKEYS:
509 fputs(fh, strcat("seta hud_panel_", panel_name, "_aspect \"", cvar_string(strcat("hud_panel_", panel_name, "_aspect")), "\"", "\n"));
514 fputs(fh, strcat("menu_restart", "\n")); // force a menu update when execing config, so that the dialogs are updated
516 print("^2Successfully exported to hud_", autocvar_hud_skin, "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
521 const float hlBorderSize = 4;
522 const string hlBorder = "gfx/hud/default/border_highlighted";
523 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
524 void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
526 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
527 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);
528 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);
529 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);
530 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);
533 // draw the background/borders
534 #define HUD_Panel_DrawBg(alpha)\
536 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));\
537 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
538 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);
540 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
547 pic = strcat(hud_skin_path, "/statusbar_vertical");
548 if(precache_pic(pic) == "") {
549 pic = "gfx/hud/default/statusbar_vertical";
551 drawsubpic(pos, eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, pic, '0 0 0', '1 0.25 0', color, alpha, drawflag);
552 if(mySize_y/mySize_x > 2)
553 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);
554 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);
556 pic = strcat(hud_skin_path, "/statusbar");
557 if(precache_pic(pic) == "") {
558 pic = "gfx/hud/default/statusbar";
560 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
561 if(mySize_x/mySize_y > 2)
562 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);
563 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);
567 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
573 pic = strcat(hud_skin_path, "/num_leading");
574 if(precache_pic(pic) == "") {
575 pic = "gfx/hud/default/num_leading";
578 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
579 if(mySize_x/mySize_y > 2)
580 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);
581 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);
584 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
585 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
596 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
597 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
599 for (i = 0; i < HUD_PANEL_NUM; ++i) {
600 if(i == highlightedPanel || !panel_enabled)
603 HUD_Panel_UpdatePosSizeForId(i)
605 panel_pos -= '1 1 0' * panel_bg_border;
606 panel_size += '2 2 0' * panel_bg_border;
608 if(myPos_y + mySize_y < panel_pos_y)
610 if(myPos_y > panel_pos_y + panel_size_y)
613 if(myPos_x + mySize_x < panel_pos_x)
615 if(myPos_x > panel_pos_x + panel_size_x)
618 // OK, there IS a collision.
620 myCenter_x = myPos_x + 0.5 * mySize_x;
621 myCenter_y = myPos_y + 0.5 * mySize_y;
623 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
624 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
626 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
628 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
629 myTarget_x = panel_pos_x - mySize_x;
630 else // push it upwards
631 myTarget_y = panel_pos_y - mySize_y;
633 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
635 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
636 myTarget_x = panel_pos_x + panel_size_x;
637 else // push it upwards
638 myTarget_y = panel_pos_y - mySize_y;
640 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
642 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
643 myTarget_x = panel_pos_x - mySize_x;
644 else // push it downwards
645 myTarget_y = panel_pos_y + panel_size_y;
647 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
649 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
650 myTarget_x = panel_pos_x + panel_size_x;
651 else // push it downwards
652 myTarget_y = panel_pos_y + panel_size_y;
654 if(cvar("hud_configure_checkcollisions_debug"))
655 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
661 void HUD_Panel_SetPos(vector pos)
663 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
667 if(cvar("hud_configure_checkcollisions_debug"))
668 drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
670 if(autocvar_hud_configure_grid)
672 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;
673 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;
676 if(hud_configure_checkcollisions)
677 pos = HUD_Panel_CheckMove(pos, mySize);
679 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
680 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
683 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
685 HUD_Panel_GetName(highlightedPanel);
686 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
689 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
690 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
700 ratio = mySize_x/mySize_y;
702 for (i = 0; i < HUD_PANEL_NUM; ++i) {
703 if(i == highlightedPanel || !panel_enabled)
706 HUD_Panel_UpdatePosSizeForId(i)
708 panel_pos -= '1 1 0' * panel_bg_border;
709 panel_size += '2 2 0' * panel_bg_border;
711 targEndPos = panel_pos + panel_size;
713 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
714 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
717 if (resizeCorner == 1)
719 // check if this panel is on our way
720 if (resizeorigin_x <= panel_pos_x)
722 if (resizeorigin_y <= panel_pos_y)
724 if (targEndPos_x <= resizeorigin_x - mySize_x)
726 if (targEndPos_y <= resizeorigin_y - mySize_y)
729 // there is a collision:
730 // detect which side of the panel we are facing is actually limiting the resizing
731 // (which side the resize direction finds for first) and reduce the size up to there
733 // dist is the distance between resizeorigin and the "analogous" point of the panel
734 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
735 dist_x = resizeorigin_x - targEndPos_x;
736 dist_y = resizeorigin_y - targEndPos_y;
737 if (dist_y <= 0 || dist_x / dist_y > ratio)
738 mySize_x = min(mySize_x, dist_x);
740 mySize_y = min(mySize_y, dist_y);
742 else if (resizeCorner == 2)
744 if (resizeorigin_x >= targEndPos_x)
746 if (resizeorigin_y <= panel_pos_y)
748 if (panel_pos_x >= resizeorigin_x + mySize_x)
750 if (targEndPos_y <= resizeorigin_y - mySize_y)
753 dist_x = panel_pos_x - resizeorigin_x;
754 dist_y = resizeorigin_y - targEndPos_y;
755 if (dist_y <= 0 || dist_x / dist_y > ratio)
756 mySize_x = min(mySize_x, dist_x);
758 mySize_y = min(mySize_y, dist_y);
760 else if (resizeCorner == 3)
762 if (resizeorigin_x <= panel_pos_x)
764 if (resizeorigin_y >= targEndPos_y)
766 if (targEndPos_x <= resizeorigin_x - mySize_x)
768 if (panel_pos_y >= resizeorigin_y + mySize_y)
771 dist_x = resizeorigin_x - targEndPos_x;
772 dist_y = panel_pos_y - resizeorigin_y;
773 if (dist_y <= 0 || dist_x / dist_y > ratio)
774 mySize_x = min(mySize_x, dist_x);
776 mySize_y = min(mySize_y, dist_y);
778 else if (resizeCorner == 4)
780 if (resizeorigin_x >= targEndPos_x)
782 if (resizeorigin_y >= targEndPos_y)
784 if (panel_pos_x >= resizeorigin_x + mySize_x)
786 if (panel_pos_y >= resizeorigin_y + mySize_y)
789 dist_x = panel_pos_x - resizeorigin_x;
790 dist_y = panel_pos_y - resizeorigin_y;
791 if (dist_y <= 0 || dist_x / dist_y > ratio)
792 mySize_x = min(mySize_x, dist_x);
794 mySize_y = min(mySize_y, dist_y);
796 if(cvar("hud_configure_checkcollisions_debug"))
797 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
803 void HUD_Panel_SetPosSize(vector mySize)
805 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
807 resizeorigin = panel_click_resizeorigin;
810 // minimum panel size cap
811 mySize_x = max(0.025 * vid_conwidth, mySize_x);
812 mySize_y = max(0.025 * vid_conheight, mySize_y);
814 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.
816 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
817 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
820 // collision testing|
821 // -----------------+
823 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
824 if(resizeCorner == 1) {
825 myPos_x = resizeorigin_x - mySize_x;
826 myPos_y = resizeorigin_y - mySize_y;
827 } else if(resizeCorner == 2) {
828 myPos_x = resizeorigin_x;
829 myPos_y = resizeorigin_y - mySize_y;
830 } else if(resizeCorner == 3) {
831 myPos_x = resizeorigin_x - mySize_x;
832 myPos_y = resizeorigin_y;
833 } else { // resizeCorner == 4
834 myPos_x = resizeorigin_x;
835 myPos_y = resizeorigin_y;
838 // left/top screen edges
840 mySize_x = mySize_x + myPos_x;
842 mySize_y = mySize_y + myPos_y;
844 // bottom/right screen edges
845 if(myPos_x + mySize_x > vid_conwidth)
846 mySize_x = vid_conwidth - myPos_x;
847 if(myPos_y + mySize_y > vid_conheight)
848 mySize_y = vid_conheight - myPos_y;
850 if(cvar("hud_configure_checkcollisions_debug"))
851 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
853 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
854 if(autocvar_hud_configure_grid)
856 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;
857 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;
860 if(hud_configure_checkcollisions)
861 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
863 // 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)
864 mySize_x = max(0.025 * vid_conwidth, mySize_x);
865 mySize_y = max(0.025 * vid_conheight, mySize_y);
867 // do another pos check, as size might have changed by now
868 if(resizeCorner == 1) {
869 myPos_x = resizeorigin_x - mySize_x;
870 myPos_y = resizeorigin_y - mySize_y;
871 } else if(resizeCorner == 2) {
872 myPos_x = resizeorigin_x;
873 myPos_y = resizeorigin_y - mySize_y;
874 } else if(resizeCorner == 3) {
875 myPos_x = resizeorigin_x - mySize_x;
876 myPos_y = resizeorigin_y;
877 } else { // resizeCorner == 4
878 myPos_x = resizeorigin_x;
879 myPos_y = resizeorigin_y;
882 if(cvar("hud_configure_checkcollisions_debug"))
883 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
885 HUD_Panel_GetName(highlightedPanel);
887 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
888 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
890 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
891 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
895 float prevMouseClicked; // previous state
896 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
897 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
900 float menu_enabled_time;
901 float pressed_key_time;
902 void HUD_Panel_Arrow_Action(float nPrimary)
904 if (highlightedPanel_prev == -1 || mouseClicked)
907 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
910 if(autocvar_hud_configure_grid)
912 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
914 if (hudShiftState & S_SHIFT)
915 step = bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
917 step = 2 * bound(0.005, autocvar_hud_configure_grid_ysize, 0.2) * vid_conheight;
921 if (hudShiftState & S_SHIFT)
922 step = bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
924 step = 2 * bound(0.005, autocvar_hud_configure_grid_xsize, 0.2) * vid_conwidth;
929 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
930 step = vid_conheight;
933 if (hudShiftState & S_SHIFT)
934 step = (step / 256); // more precision
936 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
939 highlightedPanel = highlightedPanel_prev;
941 HUD_Panel_UpdatePosSizeForId(highlightedPanel)
943 if (hudShiftState & S_ALT) // resize
945 highlightedAction = 1;
946 if(nPrimary == K_UPARROW)
948 else if(nPrimary == K_RIGHTARROW)
950 else if(nPrimary == K_LEFTARROW)
952 else // if(nPrimary == K_DOWNARROW)
955 // ctrl+arrow reduces the size, instead of increasing it
956 // Note that ctrl disables collisions check too, but it's fine
957 // since we don't collide with anything reducing the size
958 if (hudShiftState & S_CTRL) {
960 resizeCorner = 5 - resizeCorner;
965 panel_click_resizeorigin = panel_pos;
966 if(resizeCorner == 1) {
967 panel_click_resizeorigin += mySize;
969 } else if(resizeCorner == 2) {
970 panel_click_resizeorigin_y += mySize_y;
972 } else if(resizeCorner == 3) {
973 panel_click_resizeorigin_x += mySize_x;
975 } else { // resizeCorner == 4
978 HUD_Panel_SetPosSize(mySize);
982 highlightedAction = 2;
985 if(nPrimary == K_UPARROW)
987 else if(nPrimary == K_DOWNARROW)
989 else if(nPrimary == K_LEFTARROW)
991 else // if(nPrimary == K_RIGHTARROW)
994 HUD_Panel_SetPos(pos);
998 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1000 if(!autocvar__hud_configure)
1003 // allow console bind to work
1006 con_keys = findkeysforcommand("toggleconsole");
1007 keys = tokenize(con_keys);
1009 float hit_con_bind, i;
1010 for (i = 0; i < keys; ++i)
1012 if(nPrimary == stof(argv(i)))
1016 if(bInputType == 0) {
1017 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1018 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1019 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1021 else if(bInputType == 1) {
1022 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1023 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1024 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1027 if(nPrimary == K_MOUSE1)
1029 if(bInputType == 0) { // key pressed
1033 else if(bInputType == 1) {// key released
1038 else if(nPrimary == K_ESCAPE)
1040 if (bInputType == 1)
1042 disable_menu_alphacheck = 1;
1044 menu_enabled_time = time;
1045 localcmd("menu_showhudexit\n");
1047 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1049 if (bInputType == 1)
1051 pressed_key_time = 0;
1054 else if (pressed_key_time == 0)
1055 pressed_key_time = time;
1057 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1059 else if(hit_con_bind)
1062 return true; // Suppress ALL other input
1065 float HUD_Panel_HighlightCheck()
1071 while(j <= HUD_PANEL_NUM)
1076 HUD_Panel_UpdatePosSizeForId(i)
1078 panelPos = panel_pos;
1079 panelSize = panel_size;
1080 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1083 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1087 // resize from topleft border
1088 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)
1092 // resize from topright border
1093 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)
1097 // resize from bottomleft border
1098 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)
1102 // resize from bottomright border
1103 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)
1111 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1112 void HUD_Panel_FirstInDrawQ(float id)
1115 var float place = -1;
1116 // find out where in the array our current id is, save into place
1117 for(i = 0; i < HUD_PANEL_NUM; ++i)
1119 if(panel_order[i] == id)
1125 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1127 place = HUD_PANEL_NUM - 1;
1129 // move all ids up by one step in the array until "place"
1130 for(i = place; i > 0; --i)
1132 panel_order[i] = panel_order[i-1];
1134 // now save the new top id
1135 panel_order[0] = id;
1137 // let's save them into the cvar by some strcat trickery
1139 for(i = 0; i < HUD_PANEL_NUM; ++i)
1141 s = strcat(s, ftos(panel_order[i]), " ");
1143 cvar_set("_hud_panelorder", s);
1144 if(hud_panelorder_prev)
1145 strunzone(hud_panelorder_prev);
1146 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1149 void HUD_Panel_Highlight()
1155 while(j <= HUD_PANEL_NUM)
1160 HUD_Panel_UpdatePosSizeForId(i)
1162 panelPos = panel_pos;
1163 panelSize = panel_size;
1164 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1167 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1169 highlightedPanel = i;
1170 HUD_Panel_FirstInDrawQ(i);
1171 highlightedAction = 1;
1172 panel_click_distance = mousepos - panelPos;
1175 // resize from topleft border
1176 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)
1178 highlightedPanel = i;
1179 HUD_Panel_FirstInDrawQ(i);
1180 highlightedAction = 2;
1182 panel_click_distance = mousepos - panelPos;
1183 panel_click_resizeorigin = panelPos + panelSize;
1186 // resize from topright border
1187 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)
1189 highlightedPanel = i;
1190 HUD_Panel_FirstInDrawQ(i);
1191 highlightedAction = 2;
1193 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1194 panel_click_distance_y = mousepos_y - panelPos_y;
1195 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1198 // resize from bottomleft border
1199 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)
1201 highlightedPanel = i;
1202 HUD_Panel_FirstInDrawQ(i);
1203 highlightedAction = 2;
1205 panel_click_distance_x = mousepos_x - panelPos_x;
1206 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1207 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1210 // resize from bottomright border
1211 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)
1213 highlightedPanel = i;
1214 HUD_Panel_FirstInDrawQ(i);
1215 highlightedAction = 2;
1217 panel_click_distance = panelSize - mousepos + panelPos;
1218 panel_click_resizeorigin = panelPos;
1223 highlightedPanel_prev = -1;
1228 float highlightcheck;
1229 void HUD_Panel_Mouse()
1231 // 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
1232 if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
1233 disable_menu_alphacheck = 0;
1234 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1238 print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
1239 print("Highlighted: ", ftos(highlightedPanel), "\n");
1240 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1243 if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
1244 highlightedPanel = -1;
1245 highlightedAction = 0;
1247 if(highlightedPanel != -1)
1248 highlightedPanel_prev = highlightedPanel;
1250 mousepos = mousepos + getmousepos() * cvar("menu_mouse_speed");
1252 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1253 mousepos_y = bound(0, mousepos_y, vid_conheight);
1257 if(prevMouseClicked == 0)
1258 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1260 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1262 if(highlightedAction == 1)
1263 HUD_Panel_SetPos(mousepos - panel_click_distance);
1264 else if(highlightedAction == 2)
1267 if(resizeCorner == 1) {
1268 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1269 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1270 } else if(resizeCorner == 2) {
1271 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1272 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1273 } else if(resizeCorner == 3) {
1274 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1275 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1276 } else { // resizeCorner == 4
1277 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1278 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1280 HUD_Panel_SetPosSize(mySize);
1283 // doubleclick check
1284 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1286 mouseClicked = 0; // to prevent spam, I guess.
1287 disable_menu_alphacheck = 2;
1289 menu_enabled_time = time;
1290 HUD_Panel_GetName(highlightedPanel)
1291 localcmd("menu_showhudoptions ", panel_name, "\n");
1294 if(prevMouseClicked == 0)
1296 prevMouseClickedTime = time;
1297 prevMouseClickedPos = mousepos;
1302 highlightcheck = HUD_Panel_HighlightCheck();
1304 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1307 cursorsize = '32 32 0';
1309 if(highlightcheck == 0)
1310 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1311 else if(highlightcheck == 1)
1312 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1313 else if(highlightcheck == 2)
1314 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1316 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1318 prevMouseClicked = mouseClicked;
1321 // Weapon icons (#0)
1323 float weaponspace[10];
1324 #define HUD_Weapons_Clear()\
1326 for(idx = 0; idx < 10; ++idx)\
1327 weaponspace[idx] = 0;
1329 entity weaponorder[WEP_MAXCOUNT];
1330 void weaponorder_swap(float i, float j, entity pass)
1334 weaponorder[i] = weaponorder[j];
1338 string weaponorder_cmp_str_save;
1339 string weaponorder_cmp_str;
1340 float weaponorder_cmp(float i, float j, entity pass)
1343 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1344 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1345 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)
1348 float GetAmmoStat(float i)
1352 case 0: return STAT_SHELLS;
1353 case 1: return STAT_NAILS;
1354 case 2: return STAT_ROCKETS;
1355 case 3: return STAT_CELLS;
1356 case 4: return STAT_FUEL;
1361 float GetAmmoTypeForWep(float i)
1365 case WEP_SHOTGUN: return 0;
1366 case WEP_UZI: return 1;
1367 case WEP_CAMPINGRIFLE: return 1;
1368 case WEP_GRENADE_LAUNCHER: return 2;
1369 case WEP_ELECTRO: return 3;
1370 case WEP_CRYLINK: return 3;
1371 case WEP_HLAC: return 3;
1372 case WEP_MINSTANEX: return 3;
1373 case WEP_NEX: return 3;
1374 case WEP_HAGAR: return 2;
1375 case WEP_ROCKET_LAUNCHER: return 2;
1376 case WEP_SEEKER: return 2;
1377 case WEP_FIREBALL: return 4;
1378 case WEP_HOOK: return 3;
1383 void HUD_Weapons(void)
1385 if(!autocvar_hud_panel_weapons && !autocvar__hud_configure)
1388 active_panel = HUD_PANEL_WEAPONS;
1389 HUD_Panel_UpdateCvars(weapons);
1391 float i, weapid, fade, weapon_stats, weapon_number, weapon_cnt;
1394 mySize = panel_size;
1397 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1399 self = get_weaponinfo(i);
1400 if(self.impulse >= 0)
1404 // TODO make this configurable
1405 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1407 if(weaponorder_cmp_str != weaponorder_cmp_str_save)
1409 if(weaponorder_cmp_str_save)
1410 strunzone(weaponorder_cmp_str_save);
1411 weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
1413 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1415 self = get_weaponinfo(i);
1416 if(self.impulse >= 0)
1418 weaponorder[weapon_cnt] = self;
1422 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1425 HUD_Panel_DrawBg(1);
1426 if(panel_bg_padding)
1428 pos += '1 1 0' * panel_bg_padding;
1429 mySize -= '2 2 0' * panel_bg_padding;
1433 weapon_stats = getstati(STAT_DAMAGE_HITS);
1434 weapon_number = weapon_stats & 63;
1435 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1437 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1438 weapon_number = weapon_stats & 63;
1439 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1441 if(cvar_or("hud_panel_weapons_fade", 1))
1443 fade = 3.2 - 2 * (time - weapontime);
1444 fade = bound(0.7, fade, 1);
1449 HUD_Weapons_Clear();
1451 float rows, columns;
1452 rows = mySize_y/mySize_x;
1453 rows = bound(1, floor((sqrt(4 * autocvar_hud_panel_weapons_aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1455 columns = ceil(WEP_COUNT/rows);
1458 float a, type, fullammo;
1460 when = autocvar_hud_panel_weapons_complainbubble_time;
1462 fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
1468 for(i = 0; i < weapon_cnt; ++i)
1470 wpnpos = pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows);
1471 wpnsize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
1473 self = weaponorder[i];
1474 weapid = self.impulse;
1476 // draw background behind currently selected weapon
1477 if(self.weapon == activeweapon)
1478 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1480 // draw the weapon accuracy
1483 float weapon_hit, weapon_damage;
1484 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1487 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1488 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1491 // find the max level lower than weapon_stats
1494 while ( j && weapon_stats < acc_lev[j] )
1497 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
1499 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
1500 color = acc_color(j);
1501 color = color + factor * (acc_color(j+1) - color);
1504 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1507 // draw the weapon icon
1508 if((self.impulse >= 0) && (getstati(STAT_WEAPONS) & self.weapons))
1510 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1512 if(autocvar_hud_panel_weapons_label == 1) // weapon number
1513 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * mySize_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1514 else if(autocvar_hud_panel_weapons_label == 2) // bind
1515 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);
1517 // draw ammo status bar
1518 if(autocvar_hud_panel_weapons_ammo && weapid != WEP_TUBA && weapid != WEP_LASER && weapid != WEP_PORTO)
1521 type = GetAmmoTypeForWep(weapid);
1523 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
1528 case 0: fullammo = autocvar_hud_panel_weapons_ammo_full_shells; break;
1529 case 1: fullammo = autocvar_hud_panel_weapons_ammo_full_nails; break;
1530 case 2: fullammo = autocvar_hud_panel_weapons_ammo_full_rockets; break;
1531 case 3: fullammo = autocvar_hud_panel_weapons_ammo_full_cells; break;
1532 case 4: fullammo = autocvar_hud_panel_weapons_ammo_full_fuel; break;
1533 default: fullammo = 60;
1538 if(wpnsize_x/wpnsize_y > autocvar_hud_panel_weapons_aspect)
1540 barsize_x = autocvar_hud_panel_weapons_aspect * wpnsize_y;
1541 barsize_y = wpnsize_y;
1543 barpos_x = wpnpos_x + (wpnsize_x - barsize_x) / 2;
1544 barpos_y = wpnpos_y;
1548 barsize_y = 1/autocvar_hud_panel_weapons_aspect * wpnsize_x;
1549 barsize_x = wpnsize_x;
1551 barpos_y = wpnpos_y + (wpnsize_y - barsize_y) / 2;
1552 barpos_x = wpnpos_x;
1558 barsize_x * bound(0, a/fullammo, 1),
1560 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, autocvar_hud_panel_weapons_ammo_color, panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha, DRAWFLAG_NORMAL);
1561 drawresetcliparea();
1566 // draw a "ghost weapon icon" if you don't have the weapon
1569 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
1572 // draw the complain message
1573 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
1577 if(complain_weapon_time + when > time)
1580 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1584 if(complain_weapon_time + when > time)
1591 if(complain_weapon_type == 0) {
1593 color = autocvar_hud_panel_weapons_complainbubble_color_outofammo;
1595 else if(complain_weapon_type == 1) {
1597 color = autocvar_hud_panel_weapons_complainbubble_color_donthave;
1601 color = autocvar_hud_panel_weapons_complainbubble_color_unavailable;
1603 drawpic_aspect_skin(wpnpos + '1 1 0' * autocvar_hud_panel_weapons_complainbubble_padding, "weapon_complainbubble", wpnsize - '2 2 0' * autocvar_hud_panel_weapons_complainbubble_padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
1604 drawstring_aspect(wpnpos + '1 1 0' * autocvar_hud_panel_weapons_complainbubble_padding, s, wpnsize - '2 2 0' * autocvar_hud_panel_weapons_complainbubble_padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
1620 float GetAmmoItemCode(float i)
1624 case 0: return IT_SHELLS;
1625 case 1: return IT_NAILS;
1626 case 2: return IT_ROCKETS;
1627 case 3: return IT_CELLS;
1628 case 4: return IT_FUEL;
1633 string GetAmmoPicture(float i)
1637 case 0: return "ammo_shells";
1638 case 1: return "ammo_bullets";
1639 case 2: return "ammo_rockets";
1640 case 3: return "ammo_cells";
1641 case 4: return "ammo_fuel";
1646 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1649 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1650 if(autocvar__hud_configure)
1660 if(currently_selected)
1665 vector newSize, newPos;
1666 if(mySize_x/mySize_y > 3)
1668 newSize_x = 3 * mySize_y;
1669 newSize_y = mySize_y;
1671 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1676 newSize_y = 1/3 * mySize_x;
1677 newSize_x = mySize_x;
1679 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1683 vector picpos, numpos;
1684 if(autocvar_hud_panel_ammo_iconalign)
1687 picpos = newPos + eX * 2 * newSize_y;
1691 numpos = newPos + eX * newSize_y;
1695 if (currently_selected)
1696 drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1698 drawfont = hud_bigfont;
1700 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1701 else // "ghost" ammo count
1702 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1703 drawfont = hud_font;
1705 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1706 else // "ghost" ammo icon
1707 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1712 if(!autocvar_hud_panel_ammo && !autocvar__hud_configure)
1715 active_panel = HUD_PANEL_AMMO;
1716 HUD_Panel_UpdateCvars(ammo);
1717 float i, currently_selected;
1721 mySize = panel_size;
1723 HUD_Panel_DrawBg(1);
1724 if(panel_bg_padding)
1726 pos += '1 1 0' * panel_bg_padding;
1727 mySize -= '2 2 0' * panel_bg_padding;
1730 float rows, columns;
1731 rows = mySize_y/mySize_x;
1732 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1733 // ^^^ ammo item aspect goes here
1735 columns = ceil(AMMO_COUNT/rows);
1739 for (i = 0; i < AMMO_COUNT; ++i) {
1740 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1741 if(autocvar_hud_panel_ammo_onlycurrent) {
1742 if(autocvar__hud_configure)
1744 if (currently_selected || autocvar__hud_configure)
1746 DrawAmmoItem(pos, mySize, i, currently_selected);
1750 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);
1755 column = column + 1;
1761 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float alpha)
1763 vector newSize, newPos;
1764 if(mySize_x/mySize_y > 3)
1766 newSize_x = 3 * mySize_y;
1767 newSize_y = mySize_y;
1769 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1774 newSize_y = 1/3 * mySize_x;
1775 newSize_x = mySize_x;
1777 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1781 vector picpos, numpos;
1784 if(iconalign == 1 || iconalign == 3) // right align
1787 picpos = newPos + eX * 2 * newSize_y;
1791 numpos = newPos + eX * newSize_y;
1797 if(iconalign == 0 || iconalign == 3) // left align
1799 numpos = newPos + eX * newSize_y;
1805 picpos = newPos + eX * 2 * newSize_y;
1809 drawfont = hud_bigfont;
1810 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1811 drawfont = hud_font;
1812 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1815 void DrawNumIcon_expanding(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float fadelerp)
1818 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
1820 DrawNumIcon(iconalign, myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, left, color, (1 - fadelerp));
1825 void HUD_Powerups(void) {
1826 if(!autocvar_hud_panel_powerups && !autocvar__hud_configure)
1829 active_panel = HUD_PANEL_POWERUPS;
1830 HUD_Panel_UpdateCvars(powerups);
1832 stat_items = getstati(STAT_ITEMS);
1834 if(!autocvar__hud_configure)
1836 if not(stat_items & IT_STRENGTH)
1837 if not(stat_items & IT_INVINCIBLE)
1840 if (getstati(STAT_HEALTH) <= 0)
1846 mySize = panel_size;
1848 float strength_time, shield_time;
1850 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1851 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1853 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
1854 if(panel_bg_padding)
1856 pos += '1 1 0' * panel_bg_padding;
1857 mySize -= '2 2 0' * panel_bg_padding;
1860 if(autocvar__hud_configure)
1866 vector barpos, barsize;
1870 string leftname, rightname;
1871 float leftcnt, rightcnt;
1872 float leftexact, rightexact;
1873 if (autocvar_hud_panel_powerups_flip) {
1874 leftname = "strength";
1875 leftcnt = ceil(strength_time);
1876 leftexact = strength_time;
1878 rightname = "shield";
1879 rightcnt = ceil(shield_time);
1880 rightexact = shield_time;
1882 leftname = "shield";
1883 leftcnt = ceil(shield_time);
1884 leftexact = shield_time;
1886 rightname = "strength";
1887 rightcnt = ceil(strength_time);
1888 rightexact = strength_time;
1891 drawfont = hud_bigfont;
1892 if (mySize_x/mySize_y > 4)
1896 if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // right align
1897 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
1898 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1899 } else { // left align
1901 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
1904 if(autocvar_hud_panel_powerups_progressbar)
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);
1910 DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
1912 DrawNumIcon_expanding(autocvar_hud_panel_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
1917 if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // left align
1918 barpos = pos + eX * 0.5 * mySize_x;
1919 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1920 } else { // right align
1921 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
1922 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
1925 if(autocvar_hud_panel_powerups_progressbar)
1927 HUD_Panel_GetProgressBarColor(rightname)
1928 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_panel_powerups_iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
1933 DrawNumIcon_expanding(autocvar_hud_panel_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));
1936 else if (mySize_x/mySize_y > 1.5)
1940 if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // right align
1941 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
1942 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1943 } else { // left align
1945 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
1948 if(autocvar_hud_panel_powerups_progressbar)
1950 HUD_Panel_GetProgressBarColor(leftname)
1951 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);
1954 DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
1956 DrawNumIcon_expanding(autocvar_hud_panel_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
1961 if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // left align
1962 barpos = pos + eY * 0.5 * mySize_y;
1963 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1964 } else { // right align
1965 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1966 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
1969 if(autocvar_hud_panel_powerups_progressbar)
1971 HUD_Panel_GetProgressBarColor(rightname)
1972 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);
1975 DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
1977 DrawNumIcon_expanding(autocvar_hud_panel_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));
1984 if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // down align
1985 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
1986 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1987 } else { // up align
1989 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
1992 if(autocvar_hud_panel_powerups_iconalign == 1 || autocvar_hud_panel_powerups_iconalign == 3) { // down align
1993 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
1994 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
1995 } else { // up align
1996 picpos = pos + eX * 0.05 * mySize_x;
1997 numpos = pos + eY * 0.4 * mySize_x;
2000 if(autocvar_hud_panel_powerups_progressbar)
2002 HUD_Panel_GetProgressBarColor(leftname)
2003 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);
2006 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));
2008 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2009 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2014 if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // up align
2015 barpos = pos + eX * 0.5 * mySize_x;
2016 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2017 } else { // down align
2018 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
2019 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2022 if(autocvar_hud_panel_powerups_iconalign == 0 || autocvar_hud_panel_powerups_iconalign == 3) { // up align
2023 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2024 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2025 } else { // down align
2026 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2027 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2030 if(autocvar_hud_panel_powerups_progressbar)
2032 HUD_Panel_GetProgressBarColor(rightname)
2033 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);
2036 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));
2038 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2039 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2042 drawfont = hud_font;
2045 // Health/armor (#3)
2047 void HUD_HealthArmor(void)
2049 if(!autocvar_hud_panel_healtharmor && !autocvar__hud_configure)
2052 active_panel = HUD_PANEL_HEALTHARMOR;
2053 HUD_Panel_UpdateCvars(healtharmor);
2056 mySize = panel_size;
2058 HUD_Panel_DrawBg(1);
2059 if(panel_bg_padding)
2061 pos += '1 1 0' * panel_bg_padding;
2062 mySize -= '2 2 0' * panel_bg_padding;
2065 float armor, health;
2066 armor = getstati(STAT_ARMOR);
2067 health = getstati(STAT_HEALTH);
2070 fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
2072 if(autocvar__hud_configure)
2082 vector barpos, barsize;
2086 drawfont = hud_bigfont;
2087 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
2090 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2095 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
2096 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2097 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2098 } else { // left align
2100 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2104 if(v_z) // NOT fully armored
2106 biggercount = "health";
2107 if(autocvar_hud_panel_healtharmor_progressbar)
2109 HUD_Panel_GetProgressBarColor("health")
2110 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2113 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);
2117 biggercount = "armor";
2118 if(autocvar_hud_panel_healtharmor_progressbar)
2120 HUD_Panel_GetProgressBarColor("armor")
2121 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2124 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);
2126 DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200), 1);
2131 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2132 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2133 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2136 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2138 HUD_Panel_GetProgressBarColor("fuel")
2139 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2144 string leftname, rightname;
2145 float leftcnt, rightcnt;
2146 float leftactive, rightactive;
2147 float leftalpha, rightalpha;
2148 if (autocvar_hud_panel_healtharmor_flip) { // old style layout with armor left/top of health
2153 leftalpha = min((armor+10)/55, 1);
2155 rightname = "health";
2160 leftname = "health";
2165 rightname = "armor";
2169 rightalpha = min((armor+10)/55, 1);
2172 if (mySize_x/mySize_y > 4)
2176 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
2177 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2178 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2179 } else { // left align
2181 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2184 if(autocvar_hud_panel_healtharmor_progressbar)
2186 HUD_Panel_GetProgressBarColor(leftname)
2187 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2189 DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
2194 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2195 barpos = pos + eX * 0.5 * mySize_x;
2196 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2197 } else { // right align
2198 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2199 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2202 if(autocvar_hud_panel_healtharmor_progressbar)
2204 HUD_Panel_GetProgressBarColor(rightname)
2205 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2207 DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(rightcnt, 200), 1);
2212 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2213 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2214 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2217 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2219 HUD_Panel_GetProgressBarColor("fuel")
2220 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2223 else if (mySize_x/mySize_y > 1.5)
2227 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
2228 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2229 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2230 } else { // left align
2232 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2235 if(autocvar_hud_panel_healtharmor_progressbar)
2237 HUD_Panel_GetProgressBarColor(leftname)
2238 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2240 DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
2245 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2246 barpos = pos + eY * 0.5 * mySize_y;
2247 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2248 } else { // right align
2249 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2250 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2253 if(autocvar_hud_panel_healtharmor_progressbar)
2255 HUD_Panel_GetProgressBarColor(rightname)
2256 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2258 DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(rightcnt, 200), 1);
2263 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2264 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2265 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2268 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2270 HUD_Panel_GetProgressBarColor("fuel")
2271 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2278 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // down align
2279 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2280 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2281 } else { // up align
2283 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2286 if(autocvar_hud_panel_healtharmor_iconalign == 1 || autocvar_hud_panel_healtharmor_iconalign == 3) { // down align
2287 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2288 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2289 } else { // up align
2290 picpos = pos + eX * 0.05 * mySize_x;
2291 numpos = pos + eY * 0.4 * mySize_x;
2294 if(autocvar_hud_panel_healtharmor_progressbar)
2296 HUD_Panel_GetProgressBarColor(leftname)
2297 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2299 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2300 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);
2305 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // up align
2306 barpos = pos + eX * 0.5 * mySize_x;
2307 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2308 } else { // down align
2309 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2310 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2313 if(autocvar_hud_panel_healtharmor_iconalign == 0 || autocvar_hud_panel_healtharmor_iconalign == 3) { // up align
2314 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2315 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2316 } else { // down align
2317 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2318 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2321 if(autocvar_hud_panel_healtharmor_progressbar)
2323 HUD_Panel_GetProgressBarColor(rightname)
2324 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2326 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2327 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);
2332 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2334 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2336 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2337 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2339 HUD_Panel_GetProgressBarColor("fuel")
2340 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2344 drawfont = hud_font;
2347 // Notification area (#4)
2350 string Weapon_SuicideMessage(float deathtype)
2352 w_deathtype = deathtype;
2353 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2354 return w_deathtypestring;
2357 string Weapon_KillMessage(float deathtype)
2359 w_deathtype = deathtype;
2360 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2361 return w_deathtypestring;
2364 float killnotify_times[10];
2365 float killnotify_deathtype[10];
2366 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2367 string killnotify_attackers[10];
2368 string killnotify_victims[10];
2369 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2372 for (i = 9; i > 0; --i) {
2373 killnotify_times[i] = killnotify_times[i-1];
2374 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2375 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2376 if(killnotify_attackers[i])
2377 strunzone(killnotify_attackers[i]);
2378 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2379 if(killnotify_victims[i])
2380 strunzone(killnotify_victims[i]);
2381 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2383 killnotify_times[0] = time;
2384 killnotify_deathtype[0] = wpn;
2385 killnotify_actiontype[0] = actiontype;
2386 if(killnotify_attackers[0])
2387 strunzone(killnotify_attackers[0]);
2388 killnotify_attackers[0] = strzone(attacker);
2389 if(killnotify_victims[0])
2390 strunzone(killnotify_victims[0]);
2391 killnotify_victims[0] = strzone(victim);
2394 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
2397 float alsoprint, gentle;
2398 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2399 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2401 if(msg == MSG_SUICIDE) {
2402 w = DEATH_WEAPONOF(type);
2404 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2406 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
2407 } else if (type == DEATH_KILL) {
2408 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2410 print ("^1",s1, "^1 couldn't take it anymore\n");
2411 } else if (type == DEATH_ROT) {
2412 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2414 print ("^1",s1, "^1 died\n");
2415 } else if (type == DEATH_NOAMMO) {
2416 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2418 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2419 } else if (type == DEATH_CAMP) {
2420 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2422 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2423 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2424 HUD_KillNotify_Push(s1, "", 0, type);
2426 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2427 } else if (type == DEATH_CHEAT) {
2428 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2430 print ("^1",s1, "^1 unfairly eliminated themself\n");
2431 } else if (type == DEATH_FIRE) {
2432 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2434 print ("^1",s1, "^1 burned to death\n");
2435 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2436 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2438 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2441 if (stof(s2) > 2) // killcount > 2
2442 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2443 } else if(msg == MSG_KILL) {
2444 w = DEATH_WEAPONOF(type);
2446 HUD_KillNotify_Push(s1, s2, 1, type);
2448 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
2450 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2451 HUD_KillNotify_Push(s1, s2, 1, type);
2455 print ("^1", s1, "^1 took action against a team mate\n");
2457 print ("^1", s1, "^1 mows down a team mate\n");
2460 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2462 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2464 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2466 else if (stof(s2) > 2) {
2468 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2470 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2473 else if(type == KILL_FIRST_BLOOD)
2474 print("^1",s1, "^1 drew first blood", "\n");
2476 else if (type == DEATH_TELEFRAG)
2477 print ("^1",s1, "^1 was telefragged by ", s2, "\n");
2478 else if (type == DEATH_DROWN) {
2479 HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN);
2481 print ("^1",s1, "^1 was drowned by ", s2, "\n");
2483 else if (type == DEATH_SLIME) {
2484 HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME);
2486 print ("^1",s1, "^1 was slimed by ", s2, "\n");
2488 else if (type == DEATH_LAVA) {
2489 HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA);
2491 print ("^1",s1, "^1 was cooked by ", s2, "\n");
2493 else if (type == DEATH_FALL) {
2494 HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL);
2496 print ("^1",s1, "^1 was grounded by ", s2, "\n");
2498 else if (type == DEATH_SHOOTING_STAR) {
2499 HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR);
2501 print ("^1",s1, "^1 was shot into space by ", s2, "\n");
2503 else if (type == DEATH_SWAMP) {
2504 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2506 print ("^1",s1, "^1 was conserved by ", s2, "\n");
2508 else if (type == DEATH_HURTTRIGGER)
2510 HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER);
2512 print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n");
2513 } else if(type == DEATH_SBCRUSH) {
2514 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2516 print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
2517 } else if(type == DEATH_SBMINIGUN) {
2518 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2520 print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
2521 } else if(type == DEATH_SBROCKET) {
2522 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2524 print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
2525 } else if(type == DEATH_SBBLOWUP) {
2526 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2528 print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n");
2529 } else if(type == DEATH_WAKIGUN) {
2530 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2532 print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
2533 } else if(type == DEATH_WAKIROCKET) {
2534 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2536 print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
2537 } else if(type == DEATH_WAKIBLOWUP) {
2538 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2540 print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
2541 } else if(type == DEATH_TURRET) {
2542 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2544 print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
2545 } else if(type == DEATH_TOUCHEXPLODE) {
2546 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2548 print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
2549 } else if(type == DEATH_CHEAT) {
2550 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2552 print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
2553 } else if (type == DEATH_FIRE) {
2554 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2556 print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
2557 } else if (type == DEATH_CUSTOM) {
2558 HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM);
2560 print ("^1",s1, "^1 ", s2, "\n");
2562 HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC);
2564 print ("^1",s1, "^1 was fragged by ", s2, "\n");
2566 } else if(msg == MSG_SPREE) {
2567 if(type == KILL_END_SPREE) {
2569 print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
2571 print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
2572 } else if(type == KILL_SPREE) {
2574 print ("^1",s1,"^1 made ",s2," scores in a row\n");
2576 print ("^1",s1,"^1 has ",s2," frags in a row\n");
2577 } else if(type == KILL_SPREE_3) {
2579 print (s1,"^7 made a ^1TRIPLE SCORE\n");
2581 print (s1,"^7 made a ^1TRIPLE FRAG\n");
2582 } else if(type == KILL_SPREE_5) {
2584 print (s1,"^7 unleashes ^1SCORING RAGE\n");
2586 print (s1,"^7 unleashes ^1RAGE\n");
2587 } else if(type == KILL_SPREE_10) {
2589 print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
2591 print (s1,"^7 starts the ^1MASSACRE!\n");
2592 } else if(type == KILL_SPREE_15) {
2594 print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
2596 print (s1,"^7 executes ^1MAYHEM!\n");
2597 } else if(type == KILL_SPREE_20) {
2599 print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
2601 print (s1,"^7 is a ^1BERSERKER!\n");
2602 } else if(type == KILL_SPREE_25) {
2604 print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
2606 print (s1,"^7 inflicts ^1CARNAGE!\n");
2607 } else if(type == KILL_SPREE_30) {
2609 print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
2611 print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
2613 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
2614 if (type == DEATH_DROWN) {
2615 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
2619 print ("^1",s1, "^1 was in the water for too long\n");
2621 print ("^1",s1, "^1 drowned\n");
2623 } else if (type == DEATH_SLIME) {
2624 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
2626 print ("^1",s1, "^1 was slimed\n");
2627 } else if (type == DEATH_LAVA) {
2628 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
2632 print ("^1",s1, "^1 found a hot place\n");
2634 print ("^1",s1, "^1 turned into hot slag\n");
2636 } else if (type == DEATH_FALL) {
2637 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2641 print ("^1",s1, "^1 tested gravity (and it worked)\n");
2643 print ("^1",s1, "^1 hit the ground with a crunch\n");
2645 } else if (type == DEATH_SHOOTING_STAR) {
2646 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
2648 print ("^1",s1, "^1 became a shooting star\n");
2649 } else if (type == DEATH_SWAMP) {
2650 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2654 print ("^1",s1, "^1 discovered a swamp\n");
2656 print ("^1",s1, "^1 is now conserved for centuries to come\n");
2658 } else if(type == DEATH_TURRET) {
2659 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2661 print ("^1",s1, "^1 was mowed down by a turret \n");
2662 } else if (type == DEATH_CUSTOM) {
2663 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
2665 print ("^1",s1, "^1 ", s2, "\n");
2666 } else if (type == DEATH_HURTTRIGGER) {
2667 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
2669 print ("^1",s1, "^1 was in the wrong place\n");
2670 } else if(type == DEATH_TOUCHEXPLODE) {
2671 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2673 print ("^1",s1, "^1 died in an accident\n");
2674 } else if(type == DEATH_CHEAT) {
2675 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2677 print ("^1",s1, "^1 was unfairly eliminated\n");
2678 } else if(type == DEATH_FIRE) {
2679 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2683 print ("^1",s1, "^1 felt a little hot\n");
2685 print ("^1",s1, "^1 burnt to death\n");
2688 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2692 print ("^1",s1, "^1 needs a restart\n");
2694 print ("^1",s1, "^1 died\n");
2697 } else if(msg == MSG_KILL_ACTION_SPREE) {
2699 print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
2701 print ("^1",s1,"^1 died with a ",s2," kill spree\n");
2702 } else if(msg == MSG_INFO) {
2703 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
2704 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2705 print(s1, "^7 got the ", s2, "\n");
2706 } else if(type == INFO_LOSTFLAG) {
2707 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2708 print(s1, "^7 lost the ", s2, "\n");
2709 } else if(type == INFO_PICKUPFLAG) {
2710 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2711 print(s1, "^7 picked up the ", s2, "\n");
2712 } else if(type == INFO_RETURNFLAG) {
2713 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2714 print(s1, "^7 returned the ", s2, "\n");
2715 } else if(type == INFO_CAPTUREFLAG) {
2716 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
2717 print(s1, "^7 captured the ", s2, s3, "\n");
2722 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2724 void HUD_Centerprint(string s1, string s2, float type, float msg)
2727 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2728 if(msg == MSG_SUICIDE) {
2729 if (type == DEATH_TEAMCHANGE) {
2730 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
2731 } else if (type == DEATH_AUTOTEAMCHANGE) {
2732 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
2733 } else if (type == DEATH_CAMP) {
2735 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
2737 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
2738 } else if (type == DEATH_NOAMMO) {
2740 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
2742 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
2743 } else if (type == DEATH_ROT) {
2745 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
2747 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
2748 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2750 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
2752 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
2753 } else if (type == DEATH_QUIET) {
2755 } else if (type == DEATH_KILL) {
2757 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));