1 #include "hud_config.qh"
6 #include "../common/constants.qh"
8 #include "../dpdefs/keycodes.qh"
11 #define HUD_Write(s) fputs(fh, s)
12 // q: quoted, n: not quoted
13 #define HUD_Write_Cvar_n(cvar) HUD_Write(strcat("seta ", cvar, " ", cvar_string(cvar), "\n"))
14 #define HUD_Write_Cvar_q(cvar) HUD_Write(strcat("seta ", cvar, " \"", cvar_string(cvar), "\"\n"))
15 #define HUD_Write_PanelCvar_n(cvar_suf) HUD_Write_Cvar_n(strcat("hud_panel_", panel.panel_name, cvar_suf))
16 #define HUD_Write_PanelCvar_q(cvar_suf) HUD_Write_Cvar_q(strcat("hud_panel_", panel.panel_name, cvar_suf))
18 void HUD_Panel_ExportCfg(string cfgname)
21 string filename = strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg");
22 fh = fopen(filename, FILE_WRITE);
25 HUD_Write_Cvar_q("hud_skin");
26 HUD_Write_Cvar_q("hud_panel_bg");
27 HUD_Write_Cvar_q("hud_panel_bg_color");
28 HUD_Write_Cvar_q("hud_panel_bg_color_team");
29 HUD_Write_Cvar_q("hud_panel_bg_alpha");
30 HUD_Write_Cvar_q("hud_panel_bg_border");
31 HUD_Write_Cvar_q("hud_panel_bg_padding");
32 HUD_Write_Cvar_q("hud_panel_fg_alpha");
35 HUD_Write_Cvar_q("hud_dock");
36 HUD_Write_Cvar_q("hud_dock_color");
37 HUD_Write_Cvar_q("hud_dock_color_team");
38 HUD_Write_Cvar_q("hud_dock_alpha");
41 HUD_Write_Cvar_q("hud_progressbar_alpha");
42 HUD_Write_Cvar_q("hud_progressbar_strength_color");
43 HUD_Write_Cvar_q("hud_progressbar_shield_color");
44 HUD_Write_Cvar_q("hud_progressbar_health_color");
45 HUD_Write_Cvar_q("hud_progressbar_armor_color");
46 HUD_Write_Cvar_q("hud_progressbar_fuel_color");
47 HUD_Write_Cvar_q("hud_progressbar_nexball_color");
48 HUD_Write_Cvar_q("hud_progressbar_speed_color");
49 HUD_Write_Cvar_q("hud_progressbar_acceleration_color");
50 HUD_Write_Cvar_q("hud_progressbar_acceleration_neg_color");
53 HUD_Write_Cvar_q("_hud_panelorder");
56 HUD_Write_Cvar_q("hud_configure_grid");
57 HUD_Write_Cvar_q("hud_configure_grid_xsize");
58 HUD_Write_Cvar_q("hud_configure_grid_ysize");
61 // common cvars for all panels
63 for (i = 0; i < HUD_PANEL_NUM; ++i)
67 HUD_Write_PanelCvar_n("");
68 HUD_Write_PanelCvar_q("_pos");
69 HUD_Write_PanelCvar_q("_size");
70 HUD_Write_PanelCvar_q("_bg");
71 HUD_Write_PanelCvar_q("_bg_color");
72 HUD_Write_PanelCvar_q("_bg_color_team");
73 HUD_Write_PanelCvar_q("_bg_alpha");
74 HUD_Write_PanelCvar_q("_bg_border");
75 HUD_Write_PanelCvar_q("_bg_padding");
77 case HUD_PANEL_WEAPONS:
78 HUD_Write_PanelCvar_q("_accuracy");
79 HUD_Write_PanelCvar_q("_label");
80 HUD_Write_PanelCvar_q("_label_scale");
81 HUD_Write_PanelCvar_q("_complainbubble");
82 HUD_Write_PanelCvar_q("_complainbubble_padding");
83 HUD_Write_PanelCvar_q("_complainbubble_time");
84 HUD_Write_PanelCvar_q("_complainbubble_fadetime");
85 HUD_Write_PanelCvar_q("_complainbubble_color_outofammo");
86 HUD_Write_PanelCvar_q("_complainbubble_color_donthave");
87 HUD_Write_PanelCvar_q("_complainbubble_color_unavailable");
88 HUD_Write_PanelCvar_q("_ammo");
89 HUD_Write_PanelCvar_q("_ammo_color");
90 HUD_Write_PanelCvar_q("_ammo_alpha");
91 HUD_Write_PanelCvar_q("_aspect");
92 HUD_Write_PanelCvar_q("_timeout");
93 HUD_Write_PanelCvar_q("_timeout_effect");
94 HUD_Write_PanelCvar_q("_timeout_fadebgmin");
95 HUD_Write_PanelCvar_q("_timeout_fadefgmin");
96 HUD_Write_PanelCvar_q("_timeout_speed_in");
97 HUD_Write_PanelCvar_q("_timeout_speed_out");
98 HUD_Write_PanelCvar_q("_onlyowned");
101 HUD_Write_PanelCvar_q("_onlycurrent");
102 HUD_Write_PanelCvar_q("_noncurrent_alpha");
103 HUD_Write_PanelCvar_q("_noncurrent_scale");
104 HUD_Write_PanelCvar_q("_iconalign");
105 HUD_Write_PanelCvar_q("_progressbar");
106 HUD_Write_PanelCvar_q("_progressbar_name");
107 HUD_Write_PanelCvar_q("_progressbar_xoffset");
108 HUD_Write_PanelCvar_q("_text");
110 case HUD_PANEL_POWERUPS:
111 HUD_Write_PanelCvar_q("_flip");
112 HUD_Write_PanelCvar_q("_iconalign");
113 HUD_Write_PanelCvar_q("_baralign");
114 HUD_Write_PanelCvar_q("_progressbar");
115 HUD_Write_PanelCvar_q("_progressbar_strength");
116 HUD_Write_PanelCvar_q("_progressbar_shield");
117 HUD_Write_PanelCvar_q("_text");
119 case HUD_PANEL_HEALTHARMOR:
120 HUD_Write_PanelCvar_q("_flip");
121 HUD_Write_PanelCvar_q("_iconalign");
122 HUD_Write_PanelCvar_q("_baralign");
123 HUD_Write_PanelCvar_q("_progressbar");
124 HUD_Write_PanelCvar_q("_progressbar_health");
125 HUD_Write_PanelCvar_q("_progressbar_armor");
126 HUD_Write_PanelCvar_q("_progressbar_gfx");
127 HUD_Write_PanelCvar_q("_progressbar_gfx_smooth");
128 HUD_Write_PanelCvar_q("_text");
130 case HUD_PANEL_NOTIFY:
131 HUD_Write_PanelCvar_q("_flip");
132 HUD_Write_PanelCvar_q("_fontsize");
133 HUD_Write_PanelCvar_q("_time");
134 HUD_Write_PanelCvar_q("_fadetime");
135 HUD_Write_PanelCvar_q("_icon_aspect");
137 case HUD_PANEL_TIMER:
138 HUD_Write_PanelCvar_q("_increment");
140 case HUD_PANEL_RADAR:
141 HUD_Write_PanelCvar_q("_foreground_alpha");
142 HUD_Write_PanelCvar_q("_rotation");
143 HUD_Write_PanelCvar_q("_zoommode");
144 HUD_Write_PanelCvar_q("_scale");
145 HUD_Write_PanelCvar_q("_maximized_scale");
146 HUD_Write_PanelCvar_q("_maximized_size");
147 HUD_Write_PanelCvar_q("_maximized_rotation");
148 HUD_Write_PanelCvar_q("_maximized_zoommode");
150 case HUD_PANEL_SCORE:
151 HUD_Write_PanelCvar_q("_rankings");
154 HUD_Write_PanelCvar_q("_alreadyvoted_alpha");
156 case HUD_PANEL_MODICONS:
157 HUD_Write_PanelCvar_q("_ca_layout");
158 HUD_Write_PanelCvar_q("_dom_layout");
159 HUD_Write_PanelCvar_q("_freezetag_layout");
161 case HUD_PANEL_PRESSEDKEYS:
162 HUD_Write_PanelCvar_q("_aspect");
163 HUD_Write_PanelCvar_q("_attack");
165 case HUD_PANEL_ENGINEINFO:
166 HUD_Write_PanelCvar_q("_framecounter_time");
167 HUD_Write_PanelCvar_q("_framecounter_decimals");
169 case HUD_PANEL_INFOMESSAGES:
170 HUD_Write_PanelCvar_q("_flip");
172 case HUD_PANEL_PHYSICS:
173 HUD_Write_PanelCvar_q("_speed_unit");
174 HUD_Write_PanelCvar_q("_speed_unit_show");
175 HUD_Write_PanelCvar_q("_speed_max");
176 HUD_Write_PanelCvar_q("_speed_vertical");
177 HUD_Write_PanelCvar_q("_topspeed");
178 HUD_Write_PanelCvar_q("_topspeed_time");
179 HUD_Write_PanelCvar_q("_acceleration_max");
180 HUD_Write_PanelCvar_q("_acceleration_vertical");
181 HUD_Write_PanelCvar_q("_flip");
182 HUD_Write_PanelCvar_q("_baralign");
183 HUD_Write_PanelCvar_q("_progressbar");
184 HUD_Write_PanelCvar_q("_progressbar_acceleration_mode");
185 HUD_Write_PanelCvar_q("_progressbar_acceleration_scale");
186 HUD_Write_PanelCvar_q("_progressbar_acceleration_nonlinear");
187 HUD_Write_PanelCvar_q("_text");
188 HUD_Write_PanelCvar_q("_text_scale");
190 case HUD_PANEL_CENTERPRINT:
191 HUD_Write_PanelCvar_q("_align");
192 HUD_Write_PanelCvar_q("_flip");
193 HUD_Write_PanelCvar_q("_fontscale");
194 HUD_Write_PanelCvar_q("_time");
195 HUD_Write_PanelCvar_q("_fade_in");
196 HUD_Write_PanelCvar_q("_fade_out");
197 HUD_Write_PanelCvar_q("_fade_subsequent");
198 HUD_Write_PanelCvar_q("_fade_subsequent_passone");
199 HUD_Write_PanelCvar_q("_fade_subsequent_passone_minalpha");
200 HUD_Write_PanelCvar_q("_fade_subsequent_passtwo");
201 HUD_Write_PanelCvar_q("_fade_subsequent_passtwo_minalpha");
202 HUD_Write_PanelCvar_q("_fade_subsequent_minfontsize");
203 HUD_Write_PanelCvar_q("_fade_minfontsize");
205 case HUD_PANEL_QUICKMENU:
206 HUD_Write_PanelCvar_q("_align");
211 HUD_Write("menu_sync\n"); // force the menu to reread the cvars, so that the dialogs are updated
213 printf(_("^2Successfully exported to %s! (Note: It's saved in data/data/)\n"), filename);
217 printf(_("^1Couldn't write to %s\n"), filename);
220 void HUD_Configure_Exit_Force()
225 localcmd("togglemenu\n");
227 cvar_set("_hud_configure", "0");
230 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
231 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
233 vector myCenter, targCenter;
234 vector myTarget = myPos;
236 for (i = 0; i < HUD_PANEL_NUM; ++i) {
237 panel = hud_panel[i];
238 if(panel == highlightedPanel) continue;
239 HUD_Panel_UpdatePosSize();
240 if(!panel_enabled) continue;
242 panel_pos -= '1 1 0' * panel_bg_border;
243 panel_size += '2 2 0' * panel_bg_border;
245 if(myPos.y + mySize.y < panel_pos.y)
247 if(myPos.y > panel_pos.y + panel_size.y)
250 if(myPos.x + mySize.x < panel_pos.x)
252 if(myPos.x > panel_pos.x + panel_size.x)
255 // OK, there IS a collision.
257 myCenter.x = myPos.x + 0.5 * mySize.x;
258 myCenter.y = myPos.y + 0.5 * mySize.y;
260 targCenter.x = panel_pos.x + 0.5 * panel_size.x;
261 targCenter.y = panel_pos.y + 0.5 * panel_size.y;
263 if(myCenter.x < targCenter.x && myCenter.y < targCenter.y) // top left (of the target panel)
265 if(myPos.x + mySize.x - panel_pos.x < myPos.y + mySize.y - panel_pos.y) // push it to the side
266 myTarget.x = panel_pos.x - mySize.x;
267 else // push it upwards
268 myTarget.y = panel_pos.y - mySize.y;
270 else if(myCenter.x > targCenter.x && myCenter.y < targCenter.y) // top right
272 if(panel_pos.x + panel_size.x - myPos.x < myPos.y + mySize.y - panel_pos.y) // push it to the side
273 myTarget.x = panel_pos.x + panel_size.x;
274 else // push it upwards
275 myTarget.y = panel_pos.y - mySize.y;
277 else if(myCenter.x < targCenter.x && myCenter.y > targCenter.y) // bottom left
279 if(myPos.x + mySize.x - panel_pos.x < panel_pos.y + panel_size.y - myPos.y) // push it to the side
280 myTarget.x = panel_pos.x - mySize.x;
281 else // push it downwards
282 myTarget.y = panel_pos.y + panel_size.y;
284 else if(myCenter.x > targCenter.x && myCenter.y > targCenter.y) // bottom right
286 if(panel_pos.x + panel_size.x - myPos.x < panel_pos.y + panel_size.y - myPos.y) // push it to the side
287 myTarget.x = panel_pos.x + panel_size.x;
288 else // push it downwards
289 myTarget.y = panel_pos.y + panel_size.y;
291 //if(cvar("hud_configure_checkcollisions_debug"))
292 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
298 void HUD_Panel_SetPos(vector pos)
300 panel = highlightedPanel;
301 HUD_Panel_UpdatePosSize();
305 //if(cvar("hud_configure_checkcollisions_debug"))
306 //drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
308 if(autocvar_hud_configure_grid)
310 pos.x = floor((pos.x/vid_conwidth)/hud_configure_gridSize.x + 0.5) * hud_configure_realGridSize.x;
311 pos.y = floor((pos.y/vid_conheight)/hud_configure_gridSize.y + 0.5) * hud_configure_realGridSize.y;
314 if(hud_configure_checkcollisions)
315 pos = HUD_Panel_CheckMove(pos, mySize);
317 pos.x = bound(0, pos.x, vid_conwidth - mySize.x);
318 pos.y = bound(0, pos.y, vid_conheight - mySize.y);
321 s = strcat(ftos(pos.x/vid_conwidth), " ", ftos(pos.y/vid_conheight));
323 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_pos"), s);
326 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
327 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
330 float ratio = mySize.x/mySize.y;
332 for (i = 0; i < HUD_PANEL_NUM; ++i) {
333 panel = hud_panel[i];
334 if(panel == highlightedPanel) continue;
335 HUD_Panel_UpdatePosSize();
336 if(!panel_enabled) continue;
338 panel_pos -= '1 1 0' * panel_bg_border;
339 panel_size += '2 2 0' * panel_bg_border;
341 targEndPos = panel_pos + panel_size;
343 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
344 if(resizeorigin.x > panel_pos.x && resizeorigin.x < targEndPos.x && resizeorigin.y > panel_pos.y && resizeorigin.y < targEndPos.y)
347 if (resizeCorner == 1)
349 // check if this panel is on our way
350 if (resizeorigin.x <= panel_pos.x)
352 if (resizeorigin.y <= panel_pos.y)
354 if (targEndPos.x <= resizeorigin.x - mySize.x)
356 if (targEndPos.y <= resizeorigin.y - mySize.y)
359 // there is a collision:
360 // detect which side of the panel we are facing is actually limiting the resizing
361 // (which side the resize direction finds for first) and reduce the size up to there
363 // dist is the distance between resizeorigin and the "analogous" point of the panel
364 // in this case between resizeorigin (bottom-right point) and the bottom-right point of the panel
365 dist.x = resizeorigin.x - targEndPos.x;
366 dist.y = resizeorigin.y - targEndPos.y;
367 if (dist.y <= 0 || dist.x / dist.y > ratio)
368 mySize.x = min(mySize.x, dist.x);
370 mySize.y = min(mySize.y, dist.y);
372 else if (resizeCorner == 2)
374 if (resizeorigin.x >= targEndPos.x)
376 if (resizeorigin.y <= panel_pos.y)
378 if (panel_pos.x >= resizeorigin.x + mySize.x)
380 if (targEndPos.y <= resizeorigin.y - mySize.y)
383 dist.x = panel_pos.x - resizeorigin.x;
384 dist.y = resizeorigin.y - targEndPos.y;
385 if (dist.y <= 0 || dist.x / dist.y > ratio)
386 mySize.x = min(mySize.x, dist.x);
388 mySize.y = min(mySize.y, dist.y);
390 else if (resizeCorner == 3)
392 if (resizeorigin.x <= panel_pos.x)
394 if (resizeorigin.y >= targEndPos.y)
396 if (targEndPos.x <= resizeorigin.x - mySize.x)
398 if (panel_pos.y >= resizeorigin.y + mySize.y)
401 dist.x = resizeorigin.x - targEndPos.x;
402 dist.y = panel_pos.y - resizeorigin.y;
403 if (dist.y <= 0 || dist.x / dist.y > ratio)
404 mySize.x = min(mySize.x, dist.x);
406 mySize.y = min(mySize.y, dist.y);
408 else if (resizeCorner == 4)
410 if (resizeorigin.x >= targEndPos.x)
412 if (resizeorigin.y >= targEndPos.y)
414 if (panel_pos.x >= resizeorigin.x + mySize.x)
416 if (panel_pos.y >= resizeorigin.y + mySize.y)
419 dist.x = panel_pos.x - resizeorigin.x;
420 dist.y = panel_pos.y - resizeorigin.y;
421 if (dist.y <= 0 || dist.x / dist.y > ratio)
422 mySize.x = min(mySize.x, dist.x);
424 mySize.y = min(mySize.y, dist.y);
426 //if(cvar("hud_configure_checkcollisions_debug"))
427 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
433 void HUD_Panel_SetPosSize(vector mySize)
435 panel = highlightedPanel;
436 HUD_Panel_UpdatePosSize();
438 resizeorigin = panel_click_resizeorigin;
441 // minimum panel size cap
442 mySize.x = max(0.025 * vid_conwidth, mySize.x);
443 mySize.y = max(0.025 * vid_conheight, mySize.y);
445 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.
447 mySize.x = max(17 * autocvar_con_chatsize, mySize.x);
448 mySize.y = max(2 * autocvar_con_chatsize + 2 * panel_bg_padding, mySize.y);
451 // collision testing|
452 // -----------------+
454 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
455 if(resizeCorner == 1) {
456 myPos.x = resizeorigin.x - mySize.x;
457 myPos.y = resizeorigin.y - mySize.y;
458 } else if(resizeCorner == 2) {
459 myPos.x = resizeorigin.x;
460 myPos.y = resizeorigin.y - mySize.y;
461 } else if(resizeCorner == 3) {
462 myPos.x = resizeorigin.x - mySize.x;
463 myPos.y = resizeorigin.y;
464 } else { // resizeCorner == 4
465 myPos.x = resizeorigin.x;
466 myPos.y = resizeorigin.y;
469 // left/top screen edges
471 mySize.x = mySize.x + myPos.x;
473 mySize.y = mySize.y + myPos.y;
475 // bottom/right screen edges
476 if(myPos.x + mySize.x > vid_conwidth)
477 mySize.x = vid_conwidth - myPos.x;
478 if(myPos.y + mySize.y > vid_conheight)
479 mySize.y = vid_conheight - myPos.y;
481 //if(cvar("hud_configure_checkcollisions_debug"))
482 //drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
484 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
485 if(autocvar_hud_configure_grid)
487 mySize.x = floor((mySize.x/vid_conwidth)/hud_configure_gridSize.x + 0.5) * hud_configure_realGridSize.x;
488 mySize.y = floor((mySize.y/vid_conheight)/hud_configure_gridSize.y + 0.5) * hud_configure_realGridSize.y;
491 if(hud_configure_checkcollisions)
492 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
494 // 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)
495 mySize.x = max(0.025 * vid_conwidth, mySize.x);
496 mySize.y = max(0.025 * vid_conheight, mySize.y);
498 // do another pos check, as size might have changed by now
499 if(resizeCorner == 1) {
500 myPos.x = resizeorigin.x - mySize.x;
501 myPos.y = resizeorigin.y - mySize.y;
502 } else if(resizeCorner == 2) {
503 myPos.x = resizeorigin.x;
504 myPos.y = resizeorigin.y - mySize.y;
505 } else if(resizeCorner == 3) {
506 myPos.x = resizeorigin.x - mySize.x;
507 myPos.y = resizeorigin.y;
508 } else { // resizeCorner == 4
509 myPos.x = resizeorigin.x;
510 myPos.y = resizeorigin.y;
513 //if(cvar("hud_configure_checkcollisions_debug"))
514 //drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
517 s = strcat(ftos(mySize.x/vid_conwidth), " ", ftos(mySize.y/vid_conheight));
518 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_size"), s);
520 s = strcat(ftos(myPos.x/vid_conwidth), " ", ftos(myPos.y/vid_conheight));
521 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_pos"), s);
524 float pressed_key_time;
525 vector highlightedPanel_initial_pos, highlightedPanel_initial_size;
526 void HUD_Panel_Arrow_Action(float nPrimary)
528 if(!highlightedPanel)
531 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
534 if(autocvar_hud_configure_grid)
536 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
538 if (hudShiftState & S_SHIFT)
539 step = hud_configure_realGridSize.y;
541 step = 2 * hud_configure_realGridSize.y;
545 if (hudShiftState & S_SHIFT)
546 step = hud_configure_realGridSize.x;
548 step = 2 * hud_configure_realGridSize.x;
553 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
554 step = vid_conheight;
557 if (hudShiftState & S_SHIFT)
558 step = (step / 256); // more precision
560 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
563 panel = highlightedPanel;
564 HUD_Panel_UpdatePosSize();
566 highlightedPanel_initial_pos = panel_pos;
567 highlightedPanel_initial_size = panel_size;
569 if (hudShiftState & S_ALT) // resize
571 highlightedAction = 1;
572 if(nPrimary == K_UPARROW)
574 else if(nPrimary == K_RIGHTARROW)
576 else if(nPrimary == K_LEFTARROW)
578 else // if(nPrimary == K_DOWNARROW)
581 // ctrl+arrow reduces the size, instead of increasing it
582 // Note that ctrl disables collisions check too, but it's fine
583 // since we don't collide with anything reducing the size
584 if (hudShiftState & S_CTRL) {
586 resizeCorner = 5 - resizeCorner;
591 panel_click_resizeorigin = panel_pos;
592 if(resizeCorner == 1) {
593 panel_click_resizeorigin += mySize;
595 } else if(resizeCorner == 2) {
596 panel_click_resizeorigin.y += mySize.y;
598 } else if(resizeCorner == 3) {
599 panel_click_resizeorigin.x += mySize.x;
601 } else { // resizeCorner == 4
604 HUD_Panel_SetPosSize(mySize);
608 highlightedAction = 2;
611 if(nPrimary == K_UPARROW)
613 else if(nPrimary == K_DOWNARROW)
615 else if(nPrimary == K_LEFTARROW)
617 else // if(nPrimary == K_RIGHTARROW)
620 HUD_Panel_SetPos(pos);
623 panel = highlightedPanel;
624 HUD_Panel_UpdatePosSize();
626 if (highlightedPanel_initial_pos != panel_pos || highlightedPanel_initial_size != panel_size)
629 panel_pos_backup = highlightedPanel_initial_pos;
630 panel_size_backup = highlightedPanel_initial_size;
631 highlightedPanel_backup = highlightedPanel;
635 void HUD_Panel_EnableMenu();
636 entity tab_panels[HUD_PANEL_MAX];
638 vector tab_panel_pos;
640 void HUD_Panel_FirstInDrawQ(float id);
641 void reset_tab_panels()
644 for(i = 0; i < HUD_PANEL_NUM; ++i)
645 tab_panels[i] = world;
647 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
654 if(!autocvar__hud_configure)
659 mousepos.x = nPrimary;
660 mousepos.y = nSecondary;
664 // block any input while a menu dialog is fading
665 // don't block mousepos read as it leads to cursor jumps in the interaction with the menu
666 if(autocvar__menu_alpha)
673 // allow console bind to work
676 con_keys = findkeysforcommand("toggleconsole", 0);
677 keys = tokenize(con_keys); // findkeysforcommand returns data for this
679 bool hit_con_bind = false;
681 for (i = 0; i < keys; ++i)
683 if(nPrimary == stof(argv(i)))
687 if(bInputType == 0) {
688 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
689 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
690 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
692 else if(bInputType == 1) {
693 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
694 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
695 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
698 if(nPrimary == K_CTRL)
700 if (bInputType == 1) //ctrl has been released
704 //switch to selected panel
705 highlightedPanel = tab_panel;
706 highlightedAction = 0;
707 HUD_Panel_FirstInDrawQ(highlightedPanel.panel_id);
714 if(nPrimary == K_MOUSE1)
716 if(bInputType == 0) // key pressed
717 mouseClicked |= S_MOUSE1;
718 else if(bInputType == 1) // key released
719 mouseClicked -= (mouseClicked & S_MOUSE1);
721 else if(nPrimary == K_MOUSE2)
723 if(bInputType == 0) // key pressed
724 mouseClicked |= S_MOUSE2;
725 else if(bInputType == 1) // key released
726 mouseClicked -= (mouseClicked & S_MOUSE2);
728 else if(nPrimary == K_ESCAPE)
733 localcmd("menu_showhudexit\n");
735 else if(nPrimary == K_BACKSPACE && hudShiftState & S_CTRL)
740 cvar_set("_hud_configure", "0");
742 else if(nPrimary == K_TAB && hudShiftState & S_CTRL) // select and highlight another panel
744 if (bInputType == 1 || mouseClicked)
747 //FIXME: if a panel is highlighted, has the same pos_x and lays in the same level
748 //of other panels then next consecutive ctrl-tab will select the highlighted panel too
749 //(it should only after every other panel of the hud)
750 //It's a minor bug anyway, we can live with it
752 entity starting_panel;
753 entity old_tab_panel = tab_panel;
754 if (!tab_panel) //first press of TAB
756 if (highlightedPanel)
758 panel = highlightedPanel;
759 HUD_Panel_UpdatePosSize();
763 starting_panel = highlightedPanel;
764 tab_panel_pos = panel_pos; //to compute level
768 if ( ((!tab_backward) && (hudShiftState & S_SHIFT)) || (tab_backward && !(hudShiftState & S_SHIFT)) ) //tab direction changed?
770 starting_panel = tab_panel;
772 tab_backward = (hudShiftState & S_SHIFT);
774 float k, level = 0, start_posX;
775 vector candidate_pos = '0 0 0';
776 const float LEVELS_NUM = 4;
777 float level_height = vid_conheight / LEVELS_NUM;
779 level = floor(tab_panel_pos.y / level_height) * level_height; //starting level
780 candidate_pos.x = (!tab_backward) ? vid_conwidth : 0;
781 start_posX = tab_panel_pos.x;
786 for(i = 0; i < HUD_PANEL_NUM; ++i)
788 panel = hud_panel[i];
789 if (panel == tab_panels[i] || panel == starting_panel)
791 HUD_Panel_UpdatePosSize();
792 if (panel_pos.y >= level && (panel_pos.y - level) < level_height)
793 if ( ( !tab_backward && panel_pos.x >= start_posX && (panel_pos.x < candidate_pos.x || (panel_pos.x == candidate_pos.x && panel_pos.y <= candidate_pos.y)) )
794 || ( tab_backward && panel_pos.x <= start_posX && (panel_pos.x > candidate_pos.x || (panel_pos.x == candidate_pos.x && panel_pos.y >= candidate_pos.y)) ) )
797 tab_panel_pos = candidate_pos = panel_pos;
802 if (k == LEVELS_NUM) //tab_panel not found
810 starting_panel = old_tab_panel;
811 old_tab_panel = world;
812 goto find_tab_panel; //u must find tab_panel!
816 level = (level + level_height) % vid_conheight;
818 candidate_pos.x = vid_conwidth;
822 level = (level - level_height) % vid_conheight;
823 start_posX = vid_conwidth;
828 tab_panels[tab_panel.panel_id] = tab_panel;
830 else if(nPrimary == K_SPACE && hudShiftState & S_CTRL) // enable/disable highlighted panel or dock
832 if (bInputType == 1 || mouseClicked)
835 if (highlightedPanel)
836 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name), ftos(!cvar(strcat("hud_panel_", highlightedPanel.panel_name))));
838 cvar_set(strcat("hud_dock"), (autocvar_hud_dock == "") ? "dock" : "");
840 else if(nPrimary == 'c' && hudShiftState & S_CTRL) // copy highlighted panel size
842 if (bInputType == 1 || mouseClicked)
845 if (highlightedPanel)
847 panel = highlightedPanel;
848 HUD_Panel_UpdatePosSize();
849 panel_size_copied = panel_size;
852 else if(nPrimary == 'v' && hudShiftState & S_CTRL) // past copied size on the highlighted panel
854 if (bInputType == 1 || mouseClicked)
857 if (panel_size_copied == '0 0 0' || !highlightedPanel)
860 panel = highlightedPanel;
861 HUD_Panel_UpdatePosSize();
863 // reduce size if it'd go beyond screen boundaries
864 vector tmp_size = panel_size_copied;
865 if (panel_pos.x + panel_size_copied.x > vid_conwidth)
866 tmp_size.x = vid_conwidth - panel_pos.x;
867 if (panel_pos.y + panel_size_copied.y > vid_conheight)
868 tmp_size.y = vid_conheight - panel_pos.y;
870 if (panel_size == tmp_size)
874 panel_pos_backup = panel_pos;
875 panel_size_backup = panel_size;
876 highlightedPanel_backup = highlightedPanel;
878 s = strcat(ftos(tmp_size.x/vid_conwidth), " ", ftos(tmp_size.y/vid_conheight));
879 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_size"), s);
881 else if(nPrimary == 'z' && hudShiftState & S_CTRL) // undo last action
883 if (bInputType == 1 || mouseClicked)
885 //restore previous values
886 if (highlightedPanel_backup)
888 s = strcat(ftos(panel_pos_backup.x/vid_conwidth), " ", ftos(panel_pos_backup.y/vid_conheight));
889 cvar_set(strcat("hud_panel_", highlightedPanel_backup.panel_name, "_pos"), s);
890 s = strcat(ftos(panel_size_backup.x/vid_conwidth), " ", ftos(panel_size_backup.y/vid_conheight));
891 cvar_set(strcat("hud_panel_", highlightedPanel_backup.panel_name, "_size"), s);
892 highlightedPanel_backup = world;
895 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
899 pressed_key_time = 0;
902 else if (pressed_key_time == 0)
903 pressed_key_time = time;
906 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
908 else if(nPrimary == K_ENTER || nPrimary == K_SPACE || nPrimary == K_KP_ENTER)
912 if (highlightedPanel)
913 HUD_Panel_EnableMenu();
915 else if(hit_con_bind)
921 float HUD_Panel_Check_Mouse_Pos(float allow_move)
924 while(j < HUD_PANEL_NUM)
929 panel = hud_panel[i];
930 HUD_Panel_UpdatePosSize();
932 float border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
935 if(allow_move && mousepos.x > panel_pos.x && mousepos.y > panel_pos.y && mousepos.x < panel_pos.x + panel_size.x && mousepos.y < panel_pos.y + panel_size.y)
939 // resize from topleft border
940 else if(mousepos.x >= panel_pos.x - border && mousepos.y >= panel_pos.y - border && mousepos.x <= panel_pos.x + 0.5 * panel_size.x && mousepos.y <= panel_pos.y + 0.5 * panel_size.y)
944 // resize from topright border
945 else if(mousepos.x >= panel_pos.x + 0.5 * panel_size.x && mousepos.y >= panel_pos.y - border && mousepos.x <= panel_pos.x + panel_size.x + border && mousepos.y <= panel_pos.y + 0.5 * panel_size.y)
949 // resize from bottomleft border
950 else if(mousepos.x >= panel_pos.x - border && mousepos.y >= panel_pos.y + 0.5 * panel_size.y && mousepos.x <= panel_pos.x + 0.5 * panel_size.x && mousepos.y <= panel_pos.y + panel_size.y + border)
954 // resize from bottomright border
955 else if(mousepos.x >= panel_pos.x + 0.5 * panel_size.x && mousepos.y >= panel_pos.y + 0.5 * panel_size.y && mousepos.x <= panel_pos.x + panel_size.x + border && mousepos.y <= panel_pos.y + panel_size.y + border)
963 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
964 void HUD_Panel_FirstInDrawQ(float id)
968 // find out where in the array our current id is, save into place
969 for(i = 0; i < HUD_PANEL_NUM; ++i)
971 if(panel_order[i] == id)
977 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
979 place = HUD_PANEL_NUM - 1;
981 // move all ids up by one step in the array until "place"
982 for(i = place; i > 0; --i)
984 panel_order[i] = panel_order[i-1];
986 // now save the new top id
989 // let's save them into the cvar by some strcat trickery
991 for(i = 0; i < HUD_PANEL_NUM; ++i)
993 s = strcat(s, ftos(panel_order[i]), " ");
995 cvar_set("_hud_panelorder", s);
996 if(hud_panelorder_prev)
997 strunzone(hud_panelorder_prev);
998 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1001 void HUD_Panel_Highlight(float allow_move)
1005 while(j < HUD_PANEL_NUM)
1010 panel = hud_panel[i];
1011 HUD_Panel_UpdatePosSize();
1013 float border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1016 if(allow_move && mousepos.x > panel_pos.x && mousepos.y > panel_pos.y && mousepos.x < panel_pos.x + panel_size.x && mousepos.y < panel_pos.y + panel_size.y)
1018 highlightedPanel = hud_panel[i];
1019 HUD_Panel_FirstInDrawQ(i);
1020 highlightedAction = 1;
1021 panel_click_distance = mousepos - panel_pos;
1024 // resize from topleft border
1025 else if(mousepos.x >= panel_pos.x - border && mousepos.y >= panel_pos.y - border && mousepos.x <= panel_pos.x + 0.5 * panel_size.x && mousepos.y <= panel_pos.y + 0.5 * panel_size.y)
1027 highlightedPanel = hud_panel[i];
1028 HUD_Panel_FirstInDrawQ(i);
1029 highlightedAction = 2;
1031 panel_click_distance = mousepos - panel_pos;
1032 panel_click_resizeorigin = panel_pos + panel_size;
1035 // resize from topright border
1036 else if(mousepos.x >= panel_pos.x + 0.5 * panel_size.x && mousepos.y >= panel_pos.y - border && mousepos.x <= panel_pos.x + panel_size.x + border && mousepos.y <= panel_pos.y + 0.5 * panel_size.y)
1038 highlightedPanel = hud_panel[i];
1039 HUD_Panel_FirstInDrawQ(i);
1040 highlightedAction = 2;
1042 panel_click_distance.x = panel_size.x - mousepos.x + panel_pos.x;
1043 panel_click_distance.y = mousepos.y - panel_pos.y;
1044 panel_click_resizeorigin = panel_pos + eY * panel_size.y;
1047 // resize from bottomleft border
1048 else if(mousepos.x >= panel_pos.x - border && mousepos.y >= panel_pos.y + 0.5 * panel_size.y && mousepos.x <= panel_pos.x + 0.5 * panel_size.x && mousepos.y <= panel_pos.y + panel_size.y + border)
1050 highlightedPanel = hud_panel[i];
1051 HUD_Panel_FirstInDrawQ(i);
1052 highlightedAction = 2;
1054 panel_click_distance.x = mousepos.x - panel_pos.x;
1055 panel_click_distance.y = panel_size.y - mousepos.y + panel_pos.y;
1056 panel_click_resizeorigin = panel_pos + eX * panel_size.x;
1059 // resize from bottomright border
1060 else if(mousepos.x >= panel_pos.x + 0.5 * panel_size.x && mousepos.y >= panel_pos.y + 0.5 * panel_size.y && mousepos.x <= panel_pos.x + panel_size.x + border && mousepos.y <= panel_pos.y + panel_size.y + border)
1062 highlightedPanel = hud_panel[i];
1063 HUD_Panel_FirstInDrawQ(i);
1064 highlightedAction = 2;
1066 panel_click_distance = panel_size - mousepos + panel_pos;
1067 panel_click_resizeorigin = panel_pos;
1071 highlightedPanel = world;
1072 highlightedAction = 0;
1075 void HUD_Panel_EnableMenu()
1078 localcmd("menu_showhudoptions ", highlightedPanel.panel_name, "\n");
1080 float mouse_over_panel;
1081 void HUD_Panel_Mouse()
1083 if(autocvar__menu_alpha == 1)
1086 if (!autocvar_hud_cursormode)
1088 mousepos = mousepos + getmousepos() * autocvar_menu_mouse_speed;
1090 mousepos.x = bound(0, mousepos.x, vid_conwidth);
1091 mousepos.y = bound(0, mousepos.y, vid_conheight);
1096 if(prevMouseClicked == 0)
1100 //stop ctrl-tab selection
1104 HUD_Panel_Highlight(mouseClicked & S_MOUSE1); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1105 // and calls HUD_Panel_UpdatePosSize() for the highlighted panel
1106 if (highlightedPanel)
1108 highlightedPanel_initial_pos = panel_pos;
1109 highlightedPanel_initial_size = panel_size;
1111 // doubleclick check
1112 if ((mouseClicked & S_MOUSE1) && time - prevMouseClickedTime < 0.4 && highlightedPanel && prevMouseClickedPos == mousepos)
1114 mouseClicked = 0; // to prevent spam, I guess.
1115 HUD_Panel_EnableMenu();
1119 if (mouseClicked & S_MOUSE1)
1121 prevMouseClickedTime = time;
1122 prevMouseClickedPos = mousepos;
1124 mouse_over_panel = HUD_Panel_Check_Mouse_Pos(mouseClicked & S_MOUSE1);
1129 panel = highlightedPanel;
1130 HUD_Panel_UpdatePosSize();
1133 if (highlightedPanel)
1135 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .1, DRAWFLAG_NORMAL);
1136 if (highlightedPanel_initial_pos != panel_pos || highlightedPanel_initial_size != panel_size)
1138 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1140 panel_pos_backup = highlightedPanel_initial_pos;
1141 panel_size_backup = highlightedPanel_initial_size;
1142 highlightedPanel_backup = highlightedPanel;
1145 // in case the clicked panel is inside another panel and we aren't
1146 // moving it, avoid the immediate "fix" of its position/size
1147 // (often unwanted and hateful) by disabling collisions check
1148 hud_configure_checkcollisions = false;
1151 if(highlightedAction == 1)
1152 HUD_Panel_SetPos(mousepos - panel_click_distance);
1153 else if(highlightedAction == 2)
1155 vector mySize = '0 0 0';
1156 if(resizeCorner == 1) {
1157 mySize.x = panel_click_resizeorigin.x - (mousepos.x - panel_click_distance.x);
1158 mySize.y = panel_click_resizeorigin.y - (mousepos.y - panel_click_distance.y);
1159 } else if(resizeCorner == 2) {
1160 mySize.x = mousepos.x + panel_click_distance.x - panel_click_resizeorigin.x;
1161 mySize.y = panel_click_distance.y + panel_click_resizeorigin.y - mousepos.y;
1162 } else if(resizeCorner == 3) {
1163 mySize.x = panel_click_resizeorigin.x + panel_click_distance.x - mousepos.x;
1164 mySize.y = mousepos.y + panel_click_distance.y - panel_click_resizeorigin.y;
1165 } else { // resizeCorner == 4
1166 mySize.x = mousepos.x - (panel_click_resizeorigin.x - panel_click_distance.x);
1167 mySize.y = mousepos.y - (panel_click_resizeorigin.y - panel_click_distance.y);
1169 HUD_Panel_SetPosSize(mySize);
1174 if(menu_enabled == 2)
1175 mouse_over_panel = 0;
1177 mouse_over_panel = HUD_Panel_Check_Mouse_Pos(true);
1178 if (mouse_over_panel && !tab_panel)
1179 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .1, DRAWFLAG_NORMAL);
1181 // draw cursor after performing move/resize to have the panel pos/size updated before mouse_over_panel
1182 const vector cursorsize = '32 32 0';
1183 float cursor_alpha = 1 - autocvar__menu_alpha;
1185 if(!mouse_over_panel)
1186 drawpic(mousepos, strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursorsize, '1 1 1', cursor_alpha, DRAWFLAG_NORMAL);
1187 else if(mouse_over_panel == 1)
1188 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_move.tga"), cursorsize, '1 1 1', cursor_alpha, DRAWFLAG_NORMAL);
1189 else if(mouse_over_panel == 2)
1190 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_resize.tga"), cursorsize, '1 1 1', cursor_alpha, DRAWFLAG_NORMAL);
1192 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_resize2.tga"), cursorsize, '1 1 1', cursor_alpha, DRAWFLAG_NORMAL);
1194 prevMouseClicked = mouseClicked;
1196 void HUD_Configure_DrawGrid()
1199 if(autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
1201 hud_configure_gridSize.x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
1202 hud_configure_gridSize.y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
1203 hud_configure_realGridSize.x = hud_configure_gridSize.x * vid_conwidth;
1204 hud_configure_realGridSize.y = hud_configure_gridSize.y * vid_conheight;
1207 s = eX + eY * vid_conheight;
1208 for(i = 1; i < 1/hud_configure_gridSize.x; ++i)
1209 drawfill(eX * i * hud_configure_realGridSize.x, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
1211 s = eY + eX * vid_conwidth;
1212 for(i = 1; i < 1/hud_configure_gridSize.y; ++i)
1213 drawfill(eY * i * hud_configure_realGridSize.y, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
1217 float _menu_alpha_prev;
1218 void HUD_Configure_Frame()
1221 if(autocvar__hud_configure)
1223 if(isdemo() || intermission == 2)
1225 HUD_Configure_Exit_Force();
1229 if(!hud_configure_prev)
1231 if(autocvar_hud_cursormode)
1234 for(i = HUD_PANEL_NUM - 1; i >= 0; --i)
1235 hud_panel[panel_order[i]].update_time = time;
1238 // NOTE this check is necessary because _menu_alpha isn't updated the frame the menu gets enabled
1239 if(autocvar__menu_alpha != _menu_alpha_prev)
1241 if(autocvar__menu_alpha == 0)
1243 _menu_alpha_prev = autocvar__menu_alpha;
1246 HUD_Configure_DrawGrid();
1248 else if(hud_configure_prev)
1252 if(autocvar_hud_cursormode)
1257 const float hlBorderSize = 2;
1258 const string hlBorder = "gfx/hud/default/border_highlighted";
1259 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
1260 void HUD_Panel_HlBorder(float myBorder, vector color, float theAlpha)
1262 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * theAlpha, DRAWFLAG_NORMAL);
1263 drawpic_tiled(panel_pos - '1 1 0' * myBorder, hlBorder, '8 1 0' * hlBorderSize, eX * (panel_size.x + 2 * myBorder) + eY * hlBorderSize, color, theAlpha, DRAWFLAG_NORMAL);
1264 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, theAlpha, DRAWFLAG_NORMAL);
1265 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, theAlpha, DRAWFLAG_NORMAL);
1266 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, theAlpha, DRAWFLAG_NORMAL);
1269 void HUD_Configure_PostDraw()
1271 if(autocvar__hud_configure)
1276 HUD_Panel_UpdatePosSize();
1277 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
1279 if(highlightedPanel)
1281 panel = highlightedPanel;
1282 HUD_Panel_UpdatePosSize();
1283 HUD_Panel_HlBorder(panel_bg_border * hlBorderSize, '0 0.5 1', 0.4 * (1 - autocvar__menu_alpha));