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 float centerprint_time;
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] != s) // don't fade the same message in, looks stupid
186 centerprint_time = time;
187 if(centerprint_messages[i])
188 strunzone(centerprint_messages[i]);
189 centerprint_messages[i] = strzone(s);
190 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
193 // half height for empty lines looks better
199 if(i >= CENTERPRINT_MAX_LINES)
205 h = centerprint_fontsize_y*hcount;
207 havail = vid_conheight;
208 if(cvar("con_chatpos") < 0)
209 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
210 if(havail > vid_conheight - 70)
211 havail = vid_conheight - 70; // avoid overlapping HUD
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);
267 centerprint_expire = time + cvar("scr_centertime");
270 void HUD_DrawCenterPrint (void)
277 if(time - centerprint_time < 0.25)
278 a = (time - centerprint_time) / 0.25;
280 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
287 if(centerprint_num * cvar("scr_centersize") > 24 && scoreboard_active) // 24 = height of Scoreboard text
288 centerprint_start_y = scoreboard_bottom + centerprint_fontsize_y;
290 pos = centerprint_start;
291 for (i=0; i<centerprint_num; i = i + 1)
293 ts = centerprint_messages[i];
294 drawfontscale = sz * '1 1 0';
295 drawfont = hud_bigfont;
296 pos_x = (vid_conwidth - stringwidth(ts, TRUE, centerprint_fontsize)) * 0.5;
299 drawcolorcodedstring(pos + '0 1 0' * (1 - sz) * 0.5 *centerprint_fontsize_y, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
300 pos_y = pos_y + centerprint_fontsize_y;
303 // half height for empty lines looks better
304 pos_y = pos_y + sz * centerprint_fontsize_y * 0.5;
305 drawfontscale = '1 1 0';
310 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
312 position_x -= 2 / 3 * strlen(text) * scale_x;
313 drawstring(position, text, scale, rgb, alpha, flag);
316 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
318 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
319 drawstring(position, text, scale, rgb, alpha, flag);
322 // return the string of the given race place
323 string race_PlaceName(float pos) {
331 return strcat(ftos(pos), "th");
334 // return the string of the onscreen race timer
335 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
343 if(histime == 0) // goal hit
347 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
357 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
363 lapstr = strcat(" (-", ftos(lapdelta), "L)");
366 else if(lapdelta < 0)
368 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
372 else if(histime > 0) // anticipation
374 if(mytime >= histime)
375 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
377 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
384 cpname = "Start line";
386 cpname = "Finish line";
388 cpname = strcat("Intermediate ", ftos(cp));
390 cpname = "Finish line";
393 return strcat(col, cpname);
394 else if(hisname == "")
395 return strcat(col, cpname, " (", timestr, ")");
397 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
400 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
401 float race_CheckName(string net_name) {
403 for (i=RANKINGS_CNT-1;i>=0;--i)
404 if(grecordholder[i] == net_name)
416 void HUD_Panel_ExportCfg(string cfgname)
419 fh = fopen(strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg"), FILE_WRITE);
422 fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
423 fputs(fh, strcat("seta hud_panel_bg \"", cvar_string("hud_panel_bg"), "\"", "\n"));
424 fputs(fh, strcat("seta hud_panel_bg_color \"", cvar_string("hud_panel_bg_color"), "\"", "\n"));
425 fputs(fh, strcat("seta hud_panel_bg_color_team \"", cvar_string("hud_panel_bg_color_team"), "\"", "\n"));
426 fputs(fh, strcat("seta hud_panel_bg_alpha \"", cvar_string("hud_panel_bg_alpha"), "\"", "\n"));
427 fputs(fh, strcat("seta hud_panel_bg_border \"", cvar_string("hud_panel_bg_border"), "\"", "\n"));
428 fputs(fh, strcat("seta hud_panel_bg_padding \"", cvar_string("hud_panel_bg_padding"), "\"", "\n"));
429 fputs(fh, strcat("seta hud_panel_fg_alpha \"", cvar_string("hud_panel_fg_alpha"), "\"", "\n"));
432 fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
433 fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
434 fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
435 fputs(fh, strcat("seta hud_dock_alpha \"", cvar_string("hud_dock_alpha"), "\"", "\n"));
438 fputs(fh, strcat("seta hud_progressbar_alpha \"", cvar_string("hud_progressbar_alpha"), "\"", "\n"));
439 fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
440 fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
441 fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
442 fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
443 fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
444 fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
447 fputs(fh, strcat("seta _hud_panelorder \"", cvar_string("_hud_panelorder"), "\"", "\n"));
450 fputs(fh, strcat("seta hud_configure_grid \"", cvar_string("hud_configure_grid"), "\"", "\n"));
451 fputs(fh, strcat("seta hud_configure_grid_xsize \"", cvar_string("hud_configure_grid_xsize"), "\"", "\n"));
452 fputs(fh, strcat("seta hud_configure_grid_ysize \"", cvar_string("hud_configure_grid_ysize"), "\"", "\n"));
455 fputs(fh, strcat("seta scr_centerpos \"", cvar_string("scr_centerpos"), "\"", "\n"));
458 // common cvars for all panels
460 for (i = 0; i < HUD_PANEL_NUM; ++i)
462 HUD_Panel_GetName(i);
464 fputs(fh, strcat("seta hud_panel_", panel_name, " ", cvar_string(strcat("hud_panel_", panel_name)), "\n"));
465 fputs(fh, strcat("seta hud_panel_", panel_name, "_pos \"", cvar_string(strcat("hud_panel_", panel_name, "_pos")), "\"", "\n"));
466 fputs(fh, strcat("seta hud_panel_", panel_name, "_size \"", cvar_string(strcat("hud_panel_", panel_name, "_size")), "\"", "\n"));
467 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg \"", cvar_string(strcat("hud_panel_", panel_name, "_bg")), "\"", "\n"));
468 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_color \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_color")), "\"", "\n"));
469 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_color_team \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_color_team")), "\"", "\n"));
470 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_alpha")), "\"", "\n"));
471 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_border \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_border")), "\"", "\n"));
472 fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_padding \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_padding")), "\"", "\n"));
474 case HUD_PANEL_WEAPONS:
475 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble")), "\"", "\n"));
476 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_padding \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_padding")), "\"", "\n"));
477 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_outofammo \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_outofammo")), "\"", "\n"));
478 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_donthave \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_donthave")), "\"", "\n"));
479 fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_unavailable \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_unavailable")), "\"", "\n"));
480 fputs(fh, strcat("seta hud_panel_", panel_name, "_ammo_color \"", cvar_string(strcat("hud_panel_", panel_name, "_ammo_color")), "\"", "\n"));
481 fputs(fh, strcat("seta hud_panel_", panel_name, "_ammo_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_ammo_alpha")), "\"", "\n"));
482 fputs(fh, strcat("seta hud_panel_", panel_name, "_aspect \"", cvar_string(strcat("hud_panel_", panel_name, "_aspect")), "\"", "\n"));
485 fputs(fh, strcat("seta hud_panel_", panel_name, "_onlycurrent \"", cvar_string(strcat("hud_panel_", panel_name, "_onlycurrent")), "\"", "\n"));
486 fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
488 case HUD_PANEL_POWERUPS:
489 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\"", "\n"));
490 fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
491 fputs(fh, strcat("seta hud_panel_", panel_name, "_baralign \"", cvar_string(strcat("hud_panel_", panel_name, "_baralign")), "\"", "\n"));
492 fputs(fh, strcat("seta hud_panel_", panel_name, "_progressbar \"", cvar_string(strcat("hud_panel_", panel_name, "_progressbar")), "\"", "\n"));
494 case HUD_PANEL_HEALTHARMOR:
495 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\n"));
496 fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
497 fputs(fh, strcat("seta hud_panel_", panel_name, "_baralign \"", cvar_string(strcat("hud_panel_", panel_name, "_baralign")), "\"", "\n"));
498 fputs(fh, strcat("seta hud_panel_", panel_name, "_progressbar \"", cvar_string(strcat("hud_panel_", panel_name, "_progressbar")), "\"", "\n"));
500 case HUD_PANEL_NOTIFY:
501 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\"", "\n"));
502 fputs(fh, strcat("seta hud_panel_", panel_name, "_print \"", cvar_string(strcat("hud_panel_", panel_name, "_print")), "\"", "\n"));
504 case HUD_PANEL_RADAR:
505 fputs(fh, strcat("seta hud_panel_", panel_name, "_foreground_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_foreground_alpha")), "\"", "\n"));
508 fputs(fh, strcat("seta hud_panel_", panel_name, "_alreadyvoted_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_alreadyvoted_alpha")), "\"", "\n"));
510 case HUD_PANEL_PRESSEDKEYS:
511 fputs(fh, strcat("seta hud_panel_", panel_name, "_aspect \"", cvar_string(strcat("hud_panel_", panel_name, "_aspect")), "\"", "\n"));
513 case HUD_PANEL_INFOMESSAGES:
514 fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\"", "\n"));
519 fputs(fh, strcat("menu_sync", "\n")); // force the menu to reread the cvars, so that the dialogs are updated
521 print("^2Successfully exported to hud_", autocvar_hud_skin, "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
526 const float hlBorderSize = 4;
527 const string hlBorder = "gfx/hud/default/border_highlighted";
528 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
529 void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
531 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
532 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);
533 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);
534 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);
535 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);
538 // draw the background/borders
539 #define HUD_Panel_DrawBg(alpha)\
541 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));\
542 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
544 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);\
545 } ENDS_WITH_CURLY_BRACE
547 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
554 pic = strcat(hud_skin_path, "/statusbar_vertical");
555 if(precache_pic(pic) == "") {
556 pic = "gfx/hud/default/statusbar_vertical";
558 drawsubpic(pos, eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, pic, '0 0 0', '1 0.25 0', color, alpha, drawflag);
559 if(mySize_y/mySize_x > 2)
560 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);
561 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);
563 pic = strcat(hud_skin_path, "/statusbar");
564 if(precache_pic(pic) == "") {
565 pic = "gfx/hud/default/statusbar";
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);
574 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
580 pic = strcat(hud_skin_path, "/num_leading");
581 if(precache_pic(pic) == "") {
582 pic = "gfx/hud/default/num_leading";
585 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
586 if(mySize_x/mySize_y > 2)
587 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);
588 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);
591 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
592 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
601 myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
602 targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
604 for (i = 0; i < HUD_PANEL_NUM; ++i) {
605 if(i == highlightedPanel || !panel_enabled)
608 HUD_Panel_UpdatePosSizeForId(i);
610 panel_pos -= '1 1 0' * panel_bg_border;
611 panel_size += '2 2 0' * panel_bg_border;
613 if(myPos_y + mySize_y < panel_pos_y)
615 if(myPos_y > panel_pos_y + panel_size_y)
618 if(myPos_x + mySize_x < panel_pos_x)
620 if(myPos_x > panel_pos_x + panel_size_x)
623 // OK, there IS a collision.
625 myCenter_x = myPos_x + 0.5 * mySize_x;
626 myCenter_y = myPos_y + 0.5 * mySize_y;
628 targCenter_x = panel_pos_x + 0.5 * panel_size_x;
629 targCenter_y = panel_pos_y + 0.5 * panel_size_y;
631 if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
633 if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
634 myTarget_x = panel_pos_x - mySize_x;
635 else // push it upwards
636 myTarget_y = panel_pos_y - mySize_y;
638 else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
640 if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side
641 myTarget_x = panel_pos_x + panel_size_x;
642 else // push it upwards
643 myTarget_y = panel_pos_y - mySize_y;
645 else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
647 if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
648 myTarget_x = panel_pos_x - mySize_x;
649 else // push it downwards
650 myTarget_y = panel_pos_y + panel_size_y;
652 else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right
654 if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side
655 myTarget_x = panel_pos_x + panel_size_x;
656 else // push it downwards
657 myTarget_y = panel_pos_y + panel_size_y;
659 if(cvar("hud_configure_checkcollisions_debug"))
660 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
666 void HUD_Panel_SetPos(vector pos)
668 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
672 if(cvar("hud_configure_checkcollisions_debug"))
673 drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
675 if(autocvar_hud_configure_grid)
677 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;
678 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;
681 if(hud_configure_checkcollisions)
682 pos = HUD_Panel_CheckMove(pos, mySize);
684 pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
685 pos_y = bound(0, pos_y, vid_conheight - mySize_y);
688 s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
690 HUD_Panel_GetName(highlightedPanel);
691 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
694 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
695 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
700 float dist_x, dist_y;
702 ratio = mySize_x/mySize_y;
704 for (i = 0; i < HUD_PANEL_NUM; ++i) {
705 if(i == highlightedPanel || !panel_enabled)
708 HUD_Panel_UpdatePosSizeForId(i);
710 panel_pos -= '1 1 0' * panel_bg_border;
711 panel_size += '2 2 0' * panel_bg_border;
713 targEndPos = panel_pos + panel_size;
715 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
716 if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y)
719 if (resizeCorner == 1)
721 // check if this panel is on our way
722 if (resizeorigin_x <= panel_pos_x)
724 if (resizeorigin_y <= panel_pos_y)
726 if (targEndPos_x <= resizeorigin_x - mySize_x)
728 if (targEndPos_y <= resizeorigin_y - mySize_y)
731 // there is a collision:
732 // detect which side of the panel we are facing is actually limiting the resizing
733 // (which side the resize direction finds for first) and reduce the size up to there
735 // dist is the distance between resizeorigin and the "analogous" point of the panel
736 // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
737 dist_x = resizeorigin_x - targEndPos_x;
738 dist_y = resizeorigin_y - targEndPos_y;
739 if (dist_y <= 0 || dist_x / dist_y > ratio)
740 mySize_x = min(mySize_x, dist_x);
742 mySize_y = min(mySize_y, dist_y);
744 else if (resizeCorner == 2)
746 if (resizeorigin_x >= targEndPos_x)
748 if (resizeorigin_y <= panel_pos_y)
750 if (panel_pos_x >= resizeorigin_x + mySize_x)
752 if (targEndPos_y <= resizeorigin_y - mySize_y)
755 dist_x = panel_pos_x - resizeorigin_x;
756 dist_y = resizeorigin_y - targEndPos_y;
757 if (dist_y <= 0 || dist_x / dist_y > ratio)
758 mySize_x = min(mySize_x, dist_x);
760 mySize_y = min(mySize_y, dist_y);
762 else if (resizeCorner == 3)
764 if (resizeorigin_x <= panel_pos_x)
766 if (resizeorigin_y >= targEndPos_y)
768 if (targEndPos_x <= resizeorigin_x - mySize_x)
770 if (panel_pos_y >= resizeorigin_y + mySize_y)
773 dist_x = resizeorigin_x - targEndPos_x;
774 dist_y = panel_pos_y - resizeorigin_y;
775 if (dist_y <= 0 || dist_x / dist_y > ratio)
776 mySize_x = min(mySize_x, dist_x);
778 mySize_y = min(mySize_y, dist_y);
780 else if (resizeCorner == 4)
782 if (resizeorigin_x >= targEndPos_x)
784 if (resizeorigin_y >= targEndPos_y)
786 if (panel_pos_x >= resizeorigin_x + mySize_x)
788 if (panel_pos_y >= resizeorigin_y + mySize_y)
791 dist_x = panel_pos_x - resizeorigin_x;
792 dist_y = panel_pos_y - resizeorigin_y;
793 if (dist_y <= 0 || dist_x / dist_y > ratio)
794 mySize_x = min(mySize_x, dist_x);
796 mySize_y = min(mySize_y, dist_y);
798 if(cvar("hud_configure_checkcollisions_debug"))
799 drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
805 void HUD_Panel_SetPosSize(vector mySize)
807 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
809 resizeorigin = panel_click_resizeorigin;
812 // minimum panel size cap
813 mySize_x = max(0.025 * vid_conwidth, mySize_x);
814 mySize_y = max(0.025 * vid_conheight, mySize_y);
816 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.
818 mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
819 mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
822 // collision testing|
823 // -----------------+
825 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
826 if(resizeCorner == 1) {
827 myPos_x = resizeorigin_x - mySize_x;
828 myPos_y = resizeorigin_y - mySize_y;
829 } else if(resizeCorner == 2) {
830 myPos_x = resizeorigin_x;
831 myPos_y = resizeorigin_y - mySize_y;
832 } else if(resizeCorner == 3) {
833 myPos_x = resizeorigin_x - mySize_x;
834 myPos_y = resizeorigin_y;
835 } else { // resizeCorner == 4
836 myPos_x = resizeorigin_x;
837 myPos_y = resizeorigin_y;
840 // left/top screen edges
842 mySize_x = mySize_x + myPos_x;
844 mySize_y = mySize_y + myPos_y;
846 // bottom/right screen edges
847 if(myPos_x + mySize_x > vid_conwidth)
848 mySize_x = vid_conwidth - myPos_x;
849 if(myPos_y + mySize_y > vid_conheight)
850 mySize_y = vid_conheight - myPos_y;
852 if(cvar("hud_configure_checkcollisions_debug"))
853 drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
855 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
856 if(autocvar_hud_configure_grid)
858 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;
859 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;
862 if(hud_configure_checkcollisions)
863 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
865 // 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)
866 mySize_x = max(0.025 * vid_conwidth, mySize_x);
867 mySize_y = max(0.025 * vid_conheight, mySize_y);
869 // do another pos check, as size might have changed by now
870 if(resizeCorner == 1) {
871 myPos_x = resizeorigin_x - mySize_x;
872 myPos_y = resizeorigin_y - mySize_y;
873 } else if(resizeCorner == 2) {
874 myPos_x = resizeorigin_x;
875 myPos_y = resizeorigin_y - mySize_y;
876 } else if(resizeCorner == 3) {
877 myPos_x = resizeorigin_x - mySize_x;
878 myPos_y = resizeorigin_y;
879 } else { // resizeCorner == 4
880 myPos_x = resizeorigin_x;
881 myPos_y = resizeorigin_y;
884 if(cvar("hud_configure_checkcollisions_debug"))
885 drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
887 HUD_Panel_GetName(highlightedPanel);
889 s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
890 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
892 s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
893 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
897 float prevMouseClicked; // previous state
898 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
899 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
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 vector prev_pos, prev_size;
944 prev_pos = panel_pos;
945 prev_size = panel_size;
947 if (hudShiftState & S_ALT) // resize
949 highlightedAction = 1;
950 if(nPrimary == K_UPARROW)
952 else if(nPrimary == K_RIGHTARROW)
954 else if(nPrimary == K_LEFTARROW)
956 else // if(nPrimary == K_DOWNARROW)
959 // ctrl+arrow reduces the size, instead of increasing it
960 // Note that ctrl disables collisions check too, but it's fine
961 // since we don't collide with anything reducing the size
962 if (hudShiftState & S_CTRL) {
964 resizeCorner = 5 - resizeCorner;
969 panel_click_resizeorigin = panel_pos;
970 if(resizeCorner == 1) {
971 panel_click_resizeorigin += mySize;
973 } else if(resizeCorner == 2) {
974 panel_click_resizeorigin_y += mySize_y;
976 } else if(resizeCorner == 3) {
977 panel_click_resizeorigin_x += mySize_x;
979 } else { // resizeCorner == 4
982 HUD_Panel_SetPosSize(mySize);
986 highlightedAction = 2;
989 if(nPrimary == K_UPARROW)
991 else if(nPrimary == K_DOWNARROW)
993 else if(nPrimary == K_LEFTARROW)
995 else // if(nPrimary == K_RIGHTARROW)
998 HUD_Panel_SetPos(pos);
1001 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
1003 if (prev_pos != panel_pos || prev_size != panel_size)
1006 panel_pos_backup = prev_pos;
1007 panel_size_backup = prev_size;
1008 highlightedPanel_backup = highlightedPanel;
1012 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
1016 if(!autocvar__hud_configure)
1019 // allow console bind to work
1022 con_keys = findkeysforcommand("toggleconsole");
1023 keys = tokenize(con_keys);
1025 float hit_con_bind, i;
1026 for (i = 0; i < keys; ++i)
1028 if(nPrimary == stof(argv(i)))
1032 if(bInputType == 0) {
1033 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
1034 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
1035 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
1037 else if(bInputType == 1) {
1038 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
1039 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
1040 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
1043 if(nPrimary == K_MOUSE1)
1045 if(bInputType == 0) { // key pressed
1049 else if(bInputType == 1) {// key released
1054 else if(nPrimary == K_ESCAPE)
1056 if (bInputType == 1)
1059 menu_enabled_time = time;
1060 localcmd("menu_showhudexit\n");
1062 else if(hudShiftState & S_CTRL)
1067 if(nPrimary == K_SPACE) // enable/disable highlighted panel or dock
1069 if (bInputType == 1)
1072 if (highlightedPanel_prev != -1)
1073 cvar_set(strcat("hud_panel_", panel_name), ftos(!(panel_enabled)));
1075 cvar_set(strcat("hud_dock"), (autocvar_hud_dock == "") ? "dock" : "");
1077 if(nPrimary == 'c') // copy highlighted panel size
1079 if (bInputType == 1)
1082 if (highlightedPanel_prev != -1)
1084 panel_size_copied = panel_size;
1085 highlightedPanel_copied = highlightedPanel_prev;
1088 else if(nPrimary == 'v') // past copied size on the highlighted panel
1090 if (bInputType == 1)
1093 if (highlightedPanel_copied == -1 || highlightedPanel_prev == -1)
1096 HUD_Panel_UpdatePosSizeForId(highlightedPanel_prev);
1098 // reduce size if it'd go beyond screen boundaries
1099 vector tmp_size = panel_size_copied;
1100 if (panel_pos_x + panel_size_copied_x > vid_conwidth)
1101 tmp_size_x = vid_conwidth - panel_pos_x;
1102 if (panel_pos_y + panel_size_copied_y > vid_conheight)
1103 tmp_size_y = vid_conheight - panel_pos_y;
1105 if (panel_size == tmp_size)
1109 panel_pos_backup = panel_pos;
1110 panel_size_backup = panel_size;
1111 highlightedPanel_backup = highlightedPanel_prev;
1113 s = strcat(ftos(tmp_size_x/vid_conwidth), " ", ftos(tmp_size_y/vid_conheight));
1114 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
1116 else if(nPrimary == 'z') // undo last action
1118 if (bInputType == 1)
1120 //restore previous values
1121 if (highlightedPanel_backup != -1)
1123 HUD_Panel_GetName(highlightedPanel_backup);
1124 s = strcat(ftos(panel_pos_backup_x/vid_conwidth), " ", ftos(panel_pos_backup_y/vid_conheight));
1125 cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
1126 s = strcat(ftos(panel_size_backup_x/vid_conwidth), " ", ftos(panel_size_backup_y/vid_conheight));
1127 cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
1128 highlightedPanel_backup = -1;
1132 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
1134 if (bInputType == 1)
1136 pressed_key_time = 0;
1139 else if (pressed_key_time == 0)
1140 pressed_key_time = time;
1142 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
1144 else if(hit_con_bind)
1147 return true; // Suppress ALL other input
1150 float HUD_Panel_HighlightCheck()
1156 while(j <= HUD_PANEL_NUM)
1161 HUD_Panel_UpdatePosSizeForId(i);
1163 panelPos = panel_pos;
1164 panelSize = panel_size;
1165 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1168 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1172 // resize from topleft border
1173 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)
1177 // resize from topright border
1178 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)
1182 // resize from bottomleft border
1183 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)
1187 // resize from bottomright border
1188 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)
1196 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1197 void HUD_Panel_FirstInDrawQ(float id)
1200 var float place = -1;
1201 // find out where in the array our current id is, save into place
1202 for(i = 0; i < HUD_PANEL_NUM; ++i)
1204 if(panel_order[i] == id)
1210 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1212 place = HUD_PANEL_NUM - 1;
1214 // move all ids up by one step in the array until "place"
1215 for(i = place; i > 0; --i)
1217 panel_order[i] = panel_order[i-1];
1219 // now save the new top id
1220 panel_order[0] = id;
1222 // let's save them into the cvar by some strcat trickery
1224 for(i = 0; i < HUD_PANEL_NUM; ++i)
1226 s = strcat(s, ftos(panel_order[i]), " ");
1228 cvar_set("_hud_panelorder", s);
1229 if(hud_panelorder_prev)
1230 strunzone(hud_panelorder_prev);
1231 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1234 void HUD_Panel_Highlight()
1240 while(j <= HUD_PANEL_NUM)
1245 HUD_Panel_UpdatePosSizeForId(i);
1247 panelPos = panel_pos;
1248 panelSize = panel_size;
1249 border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1252 if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
1254 highlightedPanel = i;
1255 HUD_Panel_FirstInDrawQ(i);
1256 highlightedAction = 1;
1257 panel_click_distance = mousepos - panelPos;
1260 // resize from topleft border
1261 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)
1263 highlightedPanel = i;
1264 HUD_Panel_FirstInDrawQ(i);
1265 highlightedAction = 2;
1267 panel_click_distance = mousepos - panelPos;
1268 panel_click_resizeorigin = panelPos + panelSize;
1271 // resize from topright border
1272 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)
1274 highlightedPanel = i;
1275 HUD_Panel_FirstInDrawQ(i);
1276 highlightedAction = 2;
1278 panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
1279 panel_click_distance_y = mousepos_y - panelPos_y;
1280 panel_click_resizeorigin = panelPos + eY * panelSize_y;
1283 // resize from bottomleft border
1284 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)
1286 highlightedPanel = i;
1287 HUD_Panel_FirstInDrawQ(i);
1288 highlightedAction = 2;
1290 panel_click_distance_x = mousepos_x - panelPos_x;
1291 panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
1292 panel_click_resizeorigin = panelPos + eX * panelSize_x;
1295 // resize from bottomright border
1296 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)
1298 highlightedPanel = i;
1299 HUD_Panel_FirstInDrawQ(i);
1300 highlightedAction = 2;
1302 panel_click_distance = panelSize - mousepos + panelPos;
1303 panel_click_resizeorigin = panelPos;
1308 highlightedPanel_prev = -1;
1313 float highlightcheck;
1314 vector prev_pos, prev_size;
1315 void HUD_Panel_Mouse()
1317 // 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
1318 if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
1322 print("menu_enabled: ", ftos(menu_enabled), "\n");
1323 print("Highlighted: ", ftos(highlightedPanel), "\n");
1324 print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
1327 // instantly hide the editor cursor if we open the HUDExit dialog
1328 // as hud_fade_alpha doesn't decrease to 0 in this case
1329 // TODO: find a way to fade the cursor out even in this case
1330 if(menu_enabled == 1 || (menu_enabled == 2 && !hud_fade_alpha))
1333 if(mouseClicked == 0 && menu_enabled != 2 && highlightedPanel >= 0) { // don't reset these variables in menu_enabled mode 2!
1334 highlightedPanel = -1;
1335 highlightedAction = 0;
1337 if(highlightedPanel != -1)
1338 highlightedPanel_prev = highlightedPanel;
1340 mousepos = mousepos + getmousepos() * cvar("menu_mouse_speed");
1342 mousepos_x = bound(0, mousepos_x, vid_conwidth);
1343 mousepos_y = bound(0, mousepos_y, vid_conheight);
1347 if(prevMouseClicked == 0)
1349 HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1350 // and calls HUD_Panel_UpdatePosSizeForId() for the highlighted panel
1351 prev_pos = panel_pos;
1352 prev_size = panel_size;
1355 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
1357 if (prev_pos != panel_pos || prev_size != panel_size)
1359 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1361 panel_pos_backup = prev_pos;
1362 panel_size_backup = prev_size;
1363 highlightedPanel_backup = highlightedPanel;
1366 // in case the clicked panel is inside another panel and we aren't
1367 // moving it, avoid the immediate "fix" of its position/size
1368 // (often unwanted and hateful) by disabling collisions check
1369 hud_configure_checkcollisions = false;
1371 if(highlightedAction == 1)
1372 HUD_Panel_SetPos(mousepos - panel_click_distance);
1373 else if(highlightedAction == 2)
1376 if(resizeCorner == 1) {
1377 mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x);
1378 mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y);
1379 } else if(resizeCorner == 2) {
1380 mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x;
1381 mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y;
1382 } else if(resizeCorner == 3) {
1383 mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x;
1384 mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y;
1385 } else { // resizeCorner == 4
1386 mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
1387 mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
1389 HUD_Panel_SetPosSize(mySize);
1392 // doubleclick check
1393 if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
1395 mouseClicked = 0; // to prevent spam, I guess.
1397 menu_enabled_time = time;
1398 HUD_Panel_GetName(highlightedPanel);
1399 localcmd("menu_showhudoptions ", panel_name, "\n");
1402 if(prevMouseClicked == 0)
1404 prevMouseClickedTime = time;
1405 prevMouseClickedPos = mousepos;
1410 highlightcheck = HUD_Panel_HighlightCheck();
1412 // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
1414 cursorsize = '32 32 0';
1416 if(highlightcheck == 0)
1417 drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1418 else if(highlightcheck == 1)
1419 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1420 else if(highlightcheck == 2)
1421 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1423 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
1425 prevMouseClicked = mouseClicked;
1428 // Weapon icons (#0)
1430 float weaponspace[10];
1431 #define HUD_Weapons_Clear()\
1433 for(idx = 0; idx < 10; ++idx)\
1434 weaponspace[idx] = 0
1436 entity weaponorder[WEP_MAXCOUNT];
1437 void weaponorder_swap(float i, float j, entity pass)
1441 weaponorder[i] = weaponorder[j];
1445 string weaponorder_cmp_str;
1446 float weaponorder_cmp(float i, float j, entity pass)
1449 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
1450 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
1451 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)
1454 float GetAmmoStat(float i)
1458 case 0: return STAT_SHELLS;
1459 case 1: return STAT_NAILS;
1460 case 2: return STAT_ROCKETS;
1461 case 3: return STAT_CELLS;
1462 case 4: return STAT_FUEL;
1467 float GetAmmoTypeForWep(float i)
1471 case WEP_SHOTGUN: return 0;
1472 case WEP_UZI: return 1;
1473 case WEP_GRENADE_LAUNCHER: return 2;
1474 case WEP_MINE_LAYER: return 2;
1475 case WEP_ELECTRO: return 3;
1476 case WEP_CRYLINK: return 3;
1477 case WEP_HLAC: return 3;
1478 case WEP_MINSTANEX: return 3;
1479 case WEP_NEX: return 3;
1480 case WEP_CAMPINGRIFLE: return 1;
1481 case WEP_HAGAR: return 2;
1482 case WEP_ROCKET_LAUNCHER: return 2;
1483 case WEP_SEEKER: return 2;
1484 case WEP_FIREBALL: return 4;
1485 case WEP_HOOK: return 3;
1490 void HUD_Weapons(void)
1493 float center_x, center_y;
1495 if(!autocvar_hud_panel_weapons && !autocvar__hud_configure)
1498 float timeout = cvar("hud_panel_weapons_timeout");
1499 float timeout_effect_length, timein_effect_length;
1500 if (cvar("hud_panel_weapons_timeout_effect") == 0)
1502 timeout_effect_length = 0;
1503 timein_effect_length = 0;
1507 timeout_effect_length = 0.75;
1508 timein_effect_length = 0.375;
1511 if (timeout && time >= weapontime + timeout + timeout_effect_length && !autocvar__hud_configure)
1513 weaponprevtime = time;
1517 active_panel = HUD_PANEL_WEAPONS;
1518 HUD_Panel_UpdateCvars(weapons);
1520 if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
1522 f = (time - (weapontime + timeout)) / timeout_effect_length;
1523 if (cvar("hud_panel_weapons_timeout_effect"))
1525 panel_bg_alpha *= (1 - f);
1526 panel_fg_alpha *= (1 - f);
1528 if (cvar("hud_panel_weapons_timeout_effect") == 1)
1530 f *= f; // for a cooler movement
1531 center_x = panel_pos_x + panel_size_x/2;
1532 center_y = panel_pos_y + panel_size_y/2;
1533 screen_ar = vid_conwidth/vid_conheight;
1534 if (center_x/center_y < screen_ar) //bottom left
1536 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
1537 panel_pos_y += f * (vid_conheight - panel_pos_y);
1539 panel_pos_x -= f * (panel_pos_x + panel_size_x);
1543 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
1544 panel_pos_x += f * (vid_conwidth - panel_pos_x);
1546 panel_pos_y -= f * (panel_pos_y + panel_size_y);
1549 weaponprevtime = time - (1 - f) * timein_effect_length;
1551 else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure)
1553 f = (time - weaponprevtime) / timein_effect_length;
1554 if (cvar("hud_panel_weapons_timeout_effect"))
1556 panel_bg_alpha *= (f);
1557 panel_fg_alpha *= (f);
1559 if (cvar("hud_panel_weapons_timeout_effect") == 1)
1561 f *= f; // for a cooler movement
1563 center_x = panel_pos_x + panel_size_x/2;
1564 center_y = panel_pos_y + panel_size_y/2;
1565 screen_ar = vid_conwidth/vid_conheight;
1566 if (center_x/center_y < screen_ar) //bottom left
1568 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
1569 panel_pos_y += f * (vid_conheight - panel_pos_y);
1571 panel_pos_x -= f * (panel_pos_x + panel_size_x);
1575 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
1576 panel_pos_x += f * (vid_conwidth - panel_pos_x);
1578 panel_pos_y -= f * (panel_pos_y + panel_size_y);
1583 float i, weapid, fade, weapon_stats, weapon_number, weapon_cnt;
1585 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1587 self = get_weaponinfo(i);
1588 if(self.impulse >= 0)
1592 // TODO make this configurable
1593 if(weaponorder_bypriority != cvar_string("cl_weaponpriority"))
1595 if(weaponorder_bypriority)
1596 strunzone(weaponorder_bypriority);
1597 if(weaponorder_byimpulse)
1598 strunzone(weaponorder_byimpulse);
1600 weaponorder_bypriority = strzone(cvar_string("cl_weaponpriority"));
1601 weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
1602 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
1605 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1607 self = get_weaponinfo(i);
1608 if(self.impulse >= 0)
1610 weaponorder[weapon_cnt] = self;
1614 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
1616 weaponorder_cmp_str = string_null;
1619 HUD_Panel_DrawBg(1);
1620 if(panel_bg_padding)
1622 panel_pos += '1 1 0' * panel_bg_padding;
1623 panel_size -= '2 2 0' * panel_bg_padding;
1627 weapon_stats = getstati(STAT_DAMAGE_HITS);
1628 weapon_number = weapon_stats & 63;
1629 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1631 weapon_stats = getstati(STAT_DAMAGE_FIRED);
1632 weapon_number = weapon_stats & 63;
1633 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
1635 if(cvar_or("hud_panel_weapons_fade", 1))
1637 fade = 3.2 - 2 * (time - weapontime);
1638 fade = bound(0.7, fade, 1);
1643 HUD_Weapons_Clear();
1645 float rows, columns;
1646 rows = panel_size_y/panel_size_x;
1647 rows = bound(1, floor((sqrt(4 * autocvar_hud_panel_weapons_aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
1649 columns = ceil(WEP_COUNT/rows);
1652 float a, type, fullammo;
1654 when = autocvar_hud_panel_weapons_complainbubble_time;
1656 fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
1662 float show_accuracy;
1663 if(autocvar_hud_panel_weapons_accuracy && acc_levels)
1664 show_accuracy = true;
1666 for(i = 0; i < weapon_cnt; ++i)
1668 wpnpos = panel_pos + eX * column * panel_size_x*(1/columns) + eY * row * panel_size_y*(1/rows);
1669 wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
1671 self = weaponorder[i];
1672 weapid = self.impulse;
1674 // draw background behind currently selected weapon
1675 if(self.weapon == activeweapon)
1676 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1678 // draw the weapon accuracy
1681 float weapon_hit, weapon_damage;
1682 weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
1685 weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
1686 weapon_stats = floor(100 * weapon_hit / weapon_damage);
1689 // find the max level lower than weapon_stats
1692 while ( j && weapon_stats < acc_lev[j] )
1695 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
1697 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
1698 color = acc_color(j);
1699 color = color + factor * (acc_color(j+1) - color);
1702 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
1705 // draw the weapon icon
1706 if((self.impulse >= 0) && (getstati(STAT_WEAPONS) & self.weapons))
1708 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
1710 if(autocvar_hud_panel_weapons_label == 1) // weapon number
1711 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * panel_size_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1712 else if(autocvar_hud_panel_weapons_label == 2) // bind
1713 drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * panel_size_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1715 // draw ammo status bar
1716 if(autocvar_hud_panel_weapons_ammo && weapid != WEP_TUBA && weapid != WEP_LASER && weapid != WEP_PORTO)
1719 type = GetAmmoTypeForWep(weapid);
1721 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
1726 case 0: fullammo = autocvar_hud_panel_weapons_ammo_full_shells; break;
1727 case 1: fullammo = autocvar_hud_panel_weapons_ammo_full_nails; break;
1728 case 2: fullammo = autocvar_hud_panel_weapons_ammo_full_rockets; break;
1729 case 3: fullammo = autocvar_hud_panel_weapons_ammo_full_cells; break;
1730 case 4: fullammo = autocvar_hud_panel_weapons_ammo_full_fuel; break;
1731 default: fullammo = 60;
1734 float barsize_x, barsize_y, barpos_x, barpos_y;
1735 if(wpnsize_x/wpnsize_y > autocvar_hud_panel_weapons_aspect)
1737 barsize_x = autocvar_hud_panel_weapons_aspect * wpnsize_y;
1738 barsize_y = wpnsize_y;
1740 barpos_x = wpnpos_x + (wpnsize_x - barsize_x) / 2;
1741 barpos_y = wpnpos_y;
1745 barsize_y = 1/autocvar_hud_panel_weapons_aspect * wpnsize_x;
1746 barsize_x = wpnsize_x;
1748 barpos_y = wpnpos_y + (wpnsize_y - barsize_y) / 2;
1749 barpos_x = wpnpos_x;
1755 barsize_x * bound(0, a/fullammo, 1),
1757 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, autocvar_hud_panel_weapons_ammo_color, panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha, DRAWFLAG_NORMAL);
1758 drawresetcliparea();
1763 // draw a "ghost weapon icon" if you don't have the weapon
1766 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
1769 // draw the complain message
1770 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
1774 if(complain_weapon_time + when > time)
1777 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
1781 if(complain_weapon_time + when > time)
1788 if(complain_weapon_type == 0) {
1790 color = autocvar_hud_panel_weapons_complainbubble_color_outofammo;
1792 else if(complain_weapon_type == 1) {
1794 color = autocvar_hud_panel_weapons_complainbubble_color_donthave;
1798 color = autocvar_hud_panel_weapons_complainbubble_color_unavailable;
1800 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);
1801 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);
1817 float GetAmmoItemCode(float i)
1821 case 0: return IT_SHELLS;
1822 case 1: return IT_NAILS;
1823 case 2: return IT_ROCKETS;
1824 case 3: return IT_CELLS;
1825 case 4: return IT_FUEL;
1830 string GetAmmoPicture(float i)
1834 case 0: return "ammo_shells";
1835 case 1: return "ammo_bullets";
1836 case 2: return "ammo_rockets";
1837 case 3: return "ammo_cells";
1838 case 4: return "ammo_fuel";
1843 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1846 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1847 if(autocvar__hud_configure)
1857 if(currently_selected)
1862 vector newSize, newPos;
1863 if(mySize_x/mySize_y > 3)
1865 newSize_x = 3 * mySize_y;
1866 newSize_y = mySize_y;
1868 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1873 newSize_y = 1/3 * mySize_x;
1874 newSize_x = mySize_x;
1876 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1880 vector picpos, numpos;
1881 if(autocvar_hud_panel_ammo_iconalign)
1884 picpos = newPos + eX * 2 * newSize_y;
1888 numpos = newPos + eX * newSize_y;
1892 if (currently_selected)
1893 drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1895 drawfont = hud_bigfont;
1897 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1898 else // "ghost" ammo count
1899 drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1900 drawfont = hud_font;
1902 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1903 else // "ghost" ammo icon
1904 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1909 if(!autocvar_hud_panel_ammo && !autocvar__hud_configure)
1912 active_panel = HUD_PANEL_AMMO;
1913 HUD_Panel_UpdateCvars(ammo);
1914 float i, currently_selected;
1918 mySize = panel_size;
1920 HUD_Panel_DrawBg(1);
1921 if(panel_bg_padding)
1923 pos += '1 1 0' * panel_bg_padding;
1924 mySize -= '2 2 0' * panel_bg_padding;
1927 float rows, columns;
1928 rows = mySize_y/mySize_x;
1929 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1930 // ^^^ ammo item aspect goes here
1932 columns = ceil(AMMO_COUNT/rows);
1936 for (i = 0; i < AMMO_COUNT; ++i) {
1937 currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
1938 if(autocvar_hud_panel_ammo_onlycurrent) {
1939 if(autocvar__hud_configure)
1941 if (currently_selected || autocvar__hud_configure)
1943 DrawAmmoItem(pos, mySize, i, currently_selected);
1947 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);
1952 column = column + 1;
1958 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float alpha)
1961 float newSize_x, newSize_y;
1962 if(mySize_x/mySize_y > 3)
1964 newSize_x = 3 * mySize_y;
1965 newSize_y = mySize_y;
1967 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1972 newSize_y = 1/3 * mySize_x;
1973 newSize_x = mySize_x;
1975 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1979 vector picpos, numpos;
1982 if(iconalign == 1 || iconalign == 3) // right align
1985 picpos = newPos + eX * 2 * newSize_y;
1989 numpos = newPos + eX * newSize_y;
1995 if(iconalign == 0 || iconalign == 3) // left align
1997 numpos = newPos + eX * newSize_y;
2003 picpos = newPos + eX * 2 * newSize_y;
2007 drawfont = hud_bigfont;
2008 drawstring_aspect(numpos, ftos(x), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
2009 drawfont = hud_font;
2010 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
2013 void DrawNumIcon_expanding(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float fadelerp)
2016 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
2018 DrawNumIcon(iconalign, myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, left, color, (1 - fadelerp));
2023 void HUD_Powerups(void) {
2024 if(!autocvar_hud_panel_powerups && !autocvar__hud_configure)
2027 active_panel = HUD_PANEL_POWERUPS;
2028 HUD_Panel_UpdateCvars(powerups);
2030 stat_items = getstati(STAT_ITEMS);
2032 if(!autocvar__hud_configure)
2034 if not(stat_items & IT_STRENGTH)
2035 if not(stat_items & IT_INVINCIBLE)
2038 if (getstati(STAT_HEALTH) <= 0)
2044 mySize = panel_size;
2046 float strength_time, shield_time;
2047 if(autocvar__hud_configure)
2054 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
2055 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
2058 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
2059 if(panel_bg_padding)
2061 pos += '1 1 0' * panel_bg_padding;
2062 mySize -= '2 2 0' * panel_bg_padding;
2065 vector barpos, barsize;
2069 string leftname, rightname;
2070 float leftcnt, rightcnt;
2071 float leftexact, rightexact;
2072 if (autocvar_hud_panel_powerups_flip) {
2073 leftname = "strength";
2074 leftcnt = ceil(strength_time);
2075 leftexact = strength_time;
2077 rightname = "shield";
2078 rightcnt = ceil(shield_time);
2079 rightexact = shield_time;
2081 leftname = "shield";
2082 leftcnt = ceil(shield_time);
2083 leftexact = shield_time;
2085 rightname = "strength";
2086 rightcnt = ceil(strength_time);
2087 rightexact = strength_time;
2090 drawfont = hud_bigfont;
2091 if (mySize_x/mySize_y > 4)
2095 if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // right align
2096 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
2097 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
2098 } else { // left align
2100 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
2103 if(autocvar_hud_panel_powerups_progressbar)
2105 HUD_Panel_GetProgressBarColorForString(leftname);
2106 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);
2109 DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
2111 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));
2116 if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // left align
2117 barpos = pos + eX * 0.5 * mySize_x;
2118 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
2119 } else { // right align
2120 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/30);
2121 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
2124 if(autocvar_hud_panel_powerups_progressbar)
2126 HUD_Panel_GetProgressBarColorForString(rightname);
2127 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);
2130 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);
2132 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));
2135 else if (mySize_x/mySize_y > 1.5)
2139 if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // right align
2140 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
2141 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
2142 } else { // left align
2144 barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
2147 if(autocvar_hud_panel_powerups_progressbar)
2149 HUD_Panel_GetProgressBarColorForString(leftname);
2150 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);
2153 DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
2155 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));
2160 if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // left align
2161 barpos = pos + eY * 0.5 * mySize_y;
2162 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
2163 } else { // right align
2164 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
2165 barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
2168 if(autocvar_hud_panel_powerups_progressbar)
2170 HUD_Panel_GetProgressBarColorForString(rightname);
2171 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);
2174 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);
2176 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));
2183 if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // down align
2184 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
2185 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
2186 } else { // up align
2188 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
2191 if(autocvar_hud_panel_powerups_iconalign == 1 || autocvar_hud_panel_powerups_iconalign == 3) { // down align
2192 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2193 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2194 } else { // up align
2195 picpos = pos + eX * 0.05 * mySize_x;
2196 numpos = pos + eY * 0.4 * mySize_x;
2199 if(autocvar_hud_panel_powerups_progressbar)
2201 HUD_Panel_GetProgressBarColorForString(leftname);
2202 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);
2205 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));
2207 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2208 drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2213 if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // up align
2214 barpos = pos + eX * 0.5 * mySize_x;
2215 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2216 } else { // down align
2217 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/30) + eX * 0.5 * mySize_x;
2218 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
2221 if(autocvar_hud_panel_powerups_iconalign == 0 || autocvar_hud_panel_powerups_iconalign == 3) { // up align
2222 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2223 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2224 } else { // down align
2225 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2226 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2229 if(autocvar_hud_panel_powerups_progressbar)
2231 HUD_Panel_GetProgressBarColorForString(rightname);
2232 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);
2235 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));
2237 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2238 drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2241 drawfont = hud_font;
2244 // Health/armor (#3)
2246 void HUD_HealthArmor(void)
2248 if(!autocvar_hud_panel_healtharmor && !autocvar__hud_configure)
2251 active_panel = HUD_PANEL_HEALTHARMOR;
2252 HUD_Panel_UpdateCvars(healtharmor);
2255 mySize = panel_size;
2257 HUD_Panel_DrawBg(1);
2258 if(panel_bg_padding)
2260 pos += '1 1 0' * panel_bg_padding;
2261 mySize -= '2 2 0' * panel_bg_padding;
2264 float armor, health, fuel;
2265 armor = getstati(STAT_ARMOR);
2266 health = getstati(STAT_HEALTH);
2267 fuel = getstati(STAT_FUEL);
2269 if(autocvar__hud_configure)
2279 vector barpos, barsize;
2283 drawfont = hud_bigfont;
2284 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
2287 v = healtharmor_maxdamage(health, armor, armorblockpercent);
2292 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
2293 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
2294 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2295 } else { // left align
2297 barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
2301 if(v_z) // NOT fully armored
2303 biggercount = "health";
2304 if(autocvar_hud_panel_healtharmor_progressbar)
2306 HUD_Panel_GetProgressBarColor(health);
2307 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2310 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);
2314 biggercount = "armor";
2315 if(autocvar_hud_panel_healtharmor_progressbar)
2317 HUD_Panel_GetProgressBarColor(armor);
2318 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2321 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);
2323 DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200), 1);
2328 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2329 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2330 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2333 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2335 HUD_Panel_GetProgressBarColor(fuel);
2336 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2341 string leftname, rightname;
2342 float leftcnt, rightcnt;
2343 float leftactive, rightactive;
2344 float leftalpha, rightalpha;
2345 if (autocvar_hud_panel_healtharmor_flip) { // old style layout with armor left/top of health
2350 leftalpha = min((armor+10)/55, 1);
2352 rightname = "health";
2357 leftname = "health";
2362 rightname = "armor";
2366 rightalpha = min((armor+10)/55, 1);
2369 if (mySize_x/mySize_y > 4)
2373 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
2374 barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
2375 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2376 } else { // left align
2378 barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
2381 if(autocvar_hud_panel_healtharmor_progressbar)
2383 HUD_Panel_GetProgressBarColorForString(leftname);
2384 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2386 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);
2391 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2392 barpos = pos + eX * 0.5 * mySize_x;
2393 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2394 } else { // right align
2395 barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
2396 barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
2399 if(autocvar_hud_panel_healtharmor_progressbar)
2401 HUD_Panel_GetProgressBarColorForString(rightname);
2402 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2404 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);
2409 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2410 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2411 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2414 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
2416 HUD_Panel_GetProgressBarColor(fuel);
2417 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2420 else if (mySize_x/mySize_y > 1.5)
2424 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
2425 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
2426 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2427 } else { // left align
2429 barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
2432 if(autocvar_hud_panel_healtharmor_progressbar)
2434 HUD_Panel_GetProgressBarColorForString(leftname);
2435 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2437 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);
2442 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2443 barpos = pos + eY * 0.5 * mySize_y;
2444 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2445 } else { // right align
2446 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2447 barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
2450 if(autocvar_hud_panel_healtharmor_progressbar)
2452 HUD_Panel_GetProgressBarColorForString(rightname);
2453 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2455 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);
2460 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2461 barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
2462 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2465 barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
2467 HUD_Panel_GetProgressBarColor(fuel);
2468 HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2475 if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // down align
2476 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
2477 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2478 } else { // up align
2480 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
2483 if(autocvar_hud_panel_healtharmor_iconalign == 1 || autocvar_hud_panel_healtharmor_iconalign == 3) { // down align
2484 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
2485 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
2486 } else { // up align
2487 picpos = pos + eX * 0.05 * mySize_x;
2488 numpos = pos + eY * 0.4 * mySize_x;
2491 if(autocvar_hud_panel_healtharmor_progressbar)
2493 HUD_Panel_GetProgressBarColorForString(leftname);
2494 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2496 drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2497 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);
2502 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // up align
2503 barpos = pos + eX * 0.5 * mySize_x;
2504 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2505 } else { // down align
2506 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
2507 barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
2510 if(autocvar_hud_panel_healtharmor_iconalign == 0 || autocvar_hud_panel_healtharmor_iconalign == 3) { // up align
2511 picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
2512 numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
2513 } else { // down align
2514 picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x;
2515 numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
2518 if(autocvar_hud_panel_healtharmor_progressbar)
2520 HUD_Panel_GetProgressBarColorForString(rightname);
2521 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2523 drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2524 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);
2529 if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
2531 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2533 barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
2534 barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
2536 HUD_Panel_GetProgressBarColor(fuel);
2537 HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
2541 drawfont = hud_font;
2544 // Notification area (#4)
2547 string Weapon_SuicideMessage(float deathtype)
2549 w_deathtype = deathtype;
2550 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
2551 return w_deathtypestring;
2554 string Weapon_KillMessage(float deathtype)
2556 w_deathtype = deathtype;
2557 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
2558 return w_deathtypestring;
2561 float killnotify_times[10];
2562 float killnotify_deathtype[10];
2563 float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
2564 string killnotify_attackers[10];
2565 string killnotify_victims[10];
2566 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
2569 for (i = 9; i > 0; --i) {
2570 killnotify_times[i] = killnotify_times[i-1];
2571 killnotify_deathtype[i] = killnotify_deathtype[i-1];
2572 killnotify_actiontype[i] = killnotify_actiontype[i-1];
2573 if(killnotify_attackers[i])
2574 strunzone(killnotify_attackers[i]);
2575 killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
2576 if(killnotify_victims[i])
2577 strunzone(killnotify_victims[i]);
2578 killnotify_victims[i] = strzone(killnotify_victims[i-1]);
2580 killnotify_times[0] = time;
2581 killnotify_deathtype[0] = wpn;
2582 killnotify_actiontype[0] = actiontype;
2583 if(killnotify_attackers[0])
2584 strunzone(killnotify_attackers[0]);
2585 killnotify_attackers[0] = strzone(attacker);
2586 if(killnotify_victims[0])
2587 strunzone(killnotify_victims[0]);
2588 killnotify_victims[0] = strzone(victim);
2591 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
2594 float alsoprint, gentle;
2595 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
2596 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2598 if ((msg == MSG_SUICIDE || msg == MSG_KILL || msg == MSG_KILL_ACTION) && gametype == GAME_CTS) // selfkill isn't interesting in CTS and only spams up the notify panel
2601 if(msg == MSG_SUICIDE) {
2602 w = DEATH_WEAPONOF(type);
2604 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2606 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
2607 } else if (type == DEATH_KILL) {
2608 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
2610 print ("^1",s1, "^1 couldn't take it anymore\n");
2611 } else if (type == DEATH_ROT) {
2612 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2614 print ("^1",s1, "^1 died\n");
2615 } else if (type == DEATH_NOAMMO) {
2616 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
2618 print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
2619 } else if (type == DEATH_CAMP) {
2620 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
2622 print ("^1",s1, "^1 thought they found a nice camping ground\n");
2623 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2624 HUD_KillNotify_Push(s1, "", 0, type);
2626 print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
2627 } else if (type == DEATH_CHEAT) {
2628 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2630 print ("^1",s1, "^1 unfairly eliminated themself\n");
2631 } else if (type == DEATH_FIRE) {
2632 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2634 print ("^1",s1, "^1 burned to death\n");
2635 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
2636 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
2638 print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
2641 if (stof(s2) > 2) // killcount > 2
2642 print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
2643 } else if(msg == MSG_KILL) {
2644 w = DEATH_WEAPONOF(type);
2646 if(type & HITTYPE_HEADSHOT)
2647 HUD_KillNotify_Push(s1, s2, 1, DEATH_HEADSHOT);
2650 HUD_KillNotify_Push(s1, s2, 1, type);
2652 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
2655 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
2656 HUD_KillNotify_Push(s1, s2, 1, type);
2660 print ("^1", s1, "^1 took action against a team mate\n");
2662 print ("^1", s1, "^1 mows down a team mate\n");
2665 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
2667 print ("^1",s1,"^1 ended a ",s3," scoring spree by going against a team mate\n");
2669 print ("^1",s1,"^1 ended a ",s3," kill spree by killing a team mate\n");
2671 else if (stof(s2) > 2) {
2673 print ("^1",s1,"'s ^1",s3," scoring spree was ended by a team mate!\n");
2675 print ("^1",s1,"'s ^1",s3," kill spree was ended by a team mate!\n");
2678 else if(type == KILL_FIRST_BLOOD)
2679 print("^1",s1, "^1 drew first blood", "\n");
2680 else if (type == DEATH_TELEFRAG) {
2681 HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
2683 print ("^1",s2, "^1 tried to occupy ", s1, "^1's teleport destination space\n");
2685 print ("^1",s2, "^1 was telefragged by ", s1, "\n");
2687 else if (type == DEATH_DROWN) {
2688 HUD_KillNotify_Push(s1, s2, 1, DEATH_DROWN);
2690 print ("^1",s2, "^1 was drowned by ", s1, "\n");
2692 else if (type == DEATH_SLIME) {
2693 HUD_KillNotify_Push(s1, s2, 1, DEATH_SLIME);
2695 print ("^1",s2, "^1 was slimed by ", s1, "\n");
2697 else if (type == DEATH_LAVA) {
2698 HUD_KillNotify_Push(s1, s2, 1, DEATH_LAVA);
2700 print ("^1",s2, "^1 was cooked by ", s1, "\n");
2702 else if (type == DEATH_FALL) {
2703 HUD_KillNotify_Push(s1, s2, 1, DEATH_FALL);
2705 print ("^1",s2, "^1 was grounded by ", s1, "\n");
2707 else if (type == DEATH_SHOOTING_STAR) {
2708 HUD_KillNotify_Push(s1, s2, 1, DEATH_SHOOTING_STAR);
2710 print ("^1",s2, "^1 was shot into space by ", s1, "\n");
2712 else if (type == DEATH_SWAMP) {
2713 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2715 print ("^1",s2, "^1 was conserved by ", s1, "\n");
2717 else if (type == DEATH_HURTTRIGGER)
2719 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
2721 print("^1",s2, "^1 was thrown into a world of hurt by ", s1, "\n");
2722 } else if(type == DEATH_SBCRUSH) {
2723 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2725 print ("^1",s2, "^1 was crushed by ^1", s1, "\n");
2726 } else if(type == DEATH_SBMINIGUN) {
2727 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2729 print ("^1",s2, "^1 got shredded by ^1", s1, "\n");
2730 } else if(type == DEATH_SBROCKET) {
2731 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2733 print ("^1",s2, "^1 was blased to bits by ^1", s1, "\n");
2734 } else if(type == DEATH_SBBLOWUP) {
2735 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2737 print ("^1",s2, "^1 got caught in the destruction of ^1", s1, "'s vehicle\n");
2738 } else if(type == DEATH_WAKIGUN) {
2739 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2741 print ("^1",s2, "^1 was bolted down by ^1", s1, "\n");
2742 } else if(type == DEATH_WAKIROCKET) {
2743 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2745 print ("^1",s2, "^1 could find no shelter from ^1", s1, "'s rockets\n");
2746 } else if(type == DEATH_WAKIBLOWUP) {
2747 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2749 print ("^1",s2, "^1 dies when ^1", s1, "'s wakizashi dies.\n");
2750 } else if(type == DEATH_TURRET) {
2751 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2753 print ("^1",s2, "^1 was pushed into the line of fire by ^1", s1, "\n");
2754 } else if(type == DEATH_TOUCHEXPLODE) {
2755 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2757 print ("^1",s2, "^1 was pushed into an accident by ^1", s1, "\n");
2758 } else if(type == DEATH_CHEAT) {
2759 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2761 print ("^1",s2, "^1 was unfairly eliminated by ^1", s1, "\n");
2762 } else if (type == DEATH_FIRE) {
2763 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
2765 print ("^1",s2, "^1 was burnt to death by ^1", s1, "\n");
2766 } else if (type == DEATH_CUSTOM) {
2767 HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM);
2769 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
2770 } else if (type == DEATH_HURTTRIGGER) {
2771 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
2773 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");