1 #include "hud_config.qh"
3 #include "autocvars.qh"
6 #include "miscfunctions.qh"
7 #include "../common/constants.qh"
8 #include "../dpdefs/csprogsdefs.qh"
9 #include "../dpdefs/keycodes.qh"
12 #define HUD_Write(s) fputs(fh, s)
13 // q: quoted, n: not quoted
14 #define HUD_Write_Cvar_n(cvar) HUD_Write(strcat("seta ", cvar, " ", cvar_string(cvar), "\n"))
15 #define HUD_Write_Cvar_q(cvar) HUD_Write(strcat("seta ", cvar, " \"", cvar_string(cvar), "\"\n"))
16 #define HUD_Write_PanelCvar_n(cvar_suf) HUD_Write_Cvar_n(strcat("hud_panel_", panel.panel_name, cvar_suf))
17 #define HUD_Write_PanelCvar_q(cvar_suf) HUD_Write_Cvar_q(strcat("hud_panel_", panel.panel_name, cvar_suf))
19 void HUD_Panel_ExportCfg(string cfgname)
22 string filename = strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg");
23 fh = fopen(filename, FILE_WRITE);
26 HUD_Write_Cvar_q("hud_skin");
27 HUD_Write_Cvar_q("hud_panel_bg");
28 HUD_Write_Cvar_q("hud_panel_bg_color");
29 HUD_Write_Cvar_q("hud_panel_bg_color_team");
30 HUD_Write_Cvar_q("hud_panel_bg_alpha");
31 HUD_Write_Cvar_q("hud_panel_bg_border");
32 HUD_Write_Cvar_q("hud_panel_bg_padding");
33 HUD_Write_Cvar_q("hud_panel_fg_alpha");
36 HUD_Write_Cvar_q("hud_dock");
37 HUD_Write_Cvar_q("hud_dock_color");
38 HUD_Write_Cvar_q("hud_dock_color_team");
39 HUD_Write_Cvar_q("hud_dock_alpha");
42 HUD_Write_Cvar_q("hud_progressbar_alpha");
43 HUD_Write_Cvar_q("hud_progressbar_strength_color");
44 HUD_Write_Cvar_q("hud_progressbar_shield_color");
45 HUD_Write_Cvar_q("hud_progressbar_health_color");
46 HUD_Write_Cvar_q("hud_progressbar_armor_color");
47 HUD_Write_Cvar_q("hud_progressbar_fuel_color");
48 HUD_Write_Cvar_q("hud_progressbar_nexball_color");
49 HUD_Write_Cvar_q("hud_progressbar_speed_color");
50 HUD_Write_Cvar_q("hud_progressbar_acceleration_color");
51 HUD_Write_Cvar_q("hud_progressbar_acceleration_neg_color");
54 HUD_Write_Cvar_q("_hud_panelorder");
57 HUD_Write_Cvar_q("hud_configure_grid");
58 HUD_Write_Cvar_q("hud_configure_grid_xsize");
59 HUD_Write_Cvar_q("hud_configure_grid_ysize");
62 // common cvars for all panels
64 for (i = 0; i < HUD_PANEL_NUM; ++i)
68 HUD_Write_PanelCvar_n("");
69 HUD_Write_PanelCvar_q("_pos");
70 HUD_Write_PanelCvar_q("_size");
71 HUD_Write_PanelCvar_q("_bg");
72 HUD_Write_PanelCvar_q("_bg_color");
73 HUD_Write_PanelCvar_q("_bg_color_team");
74 HUD_Write_PanelCvar_q("_bg_alpha");
75 HUD_Write_PanelCvar_q("_bg_border");
76 HUD_Write_PanelCvar_q("_bg_padding");
78 case HUD_PANEL_WEAPONS:
79 HUD_Write_PanelCvar_q("_accuracy");
80 HUD_Write_PanelCvar_q("_label");
81 HUD_Write_PanelCvar_q("_label_scale");
82 HUD_Write_PanelCvar_q("_complainbubble");
83 HUD_Write_PanelCvar_q("_complainbubble_padding");
84 HUD_Write_PanelCvar_q("_complainbubble_time");
85 HUD_Write_PanelCvar_q("_complainbubble_fadetime");
86 HUD_Write_PanelCvar_q("_complainbubble_color_outofammo");
87 HUD_Write_PanelCvar_q("_complainbubble_color_donthave");
88 HUD_Write_PanelCvar_q("_complainbubble_color_unavailable");
89 HUD_Write_PanelCvar_q("_ammo");
90 HUD_Write_PanelCvar_q("_ammo_color");
91 HUD_Write_PanelCvar_q("_ammo_alpha");
92 HUD_Write_PanelCvar_q("_aspect");
93 HUD_Write_PanelCvar_q("_timeout");
94 HUD_Write_PanelCvar_q("_timeout_effect");
95 HUD_Write_PanelCvar_q("_timeout_fadebgmin");
96 HUD_Write_PanelCvar_q("_timeout_fadefgmin");
97 HUD_Write_PanelCvar_q("_timeout_speed_in");
98 HUD_Write_PanelCvar_q("_timeout_speed_out");
99 HUD_Write_PanelCvar_q("_onlyowned");
102 HUD_Write_PanelCvar_q("_onlycurrent");
103 HUD_Write_PanelCvar_q("_noncurrent_alpha");
104 HUD_Write_PanelCvar_q("_noncurrent_scale");
105 HUD_Write_PanelCvar_q("_iconalign");
106 HUD_Write_PanelCvar_q("_progressbar");
107 HUD_Write_PanelCvar_q("_progressbar_name");
108 HUD_Write_PanelCvar_q("_progressbar_xoffset");
109 HUD_Write_PanelCvar_q("_text");
111 case HUD_PANEL_POWERUPS:
112 HUD_Write_PanelCvar_q("_flip");
113 HUD_Write_PanelCvar_q("_iconalign");
114 HUD_Write_PanelCvar_q("_baralign");
115 HUD_Write_PanelCvar_q("_progressbar");
116 HUD_Write_PanelCvar_q("_progressbar_strength");
117 HUD_Write_PanelCvar_q("_progressbar_shield");
118 HUD_Write_PanelCvar_q("_text");
120 case HUD_PANEL_HEALTHARMOR:
121 HUD_Write_PanelCvar_q("_flip");
122 HUD_Write_PanelCvar_q("_iconalign");
123 HUD_Write_PanelCvar_q("_baralign");
124 HUD_Write_PanelCvar_q("_progressbar");
125 HUD_Write_PanelCvar_q("_progressbar_health");
126 HUD_Write_PanelCvar_q("_progressbar_armor");
127 HUD_Write_PanelCvar_q("_progressbar_gfx");
128 HUD_Write_PanelCvar_q("_progressbar_gfx_smooth");
129 HUD_Write_PanelCvar_q("_text");
131 case HUD_PANEL_NOTIFY:
132 HUD_Write_PanelCvar_q("_flip");
133 HUD_Write_PanelCvar_q("_fontsize");
134 HUD_Write_PanelCvar_q("_time");
135 HUD_Write_PanelCvar_q("_fadetime");
136 HUD_Write_PanelCvar_q("_icon_aspect");
138 case HUD_PANEL_TIMER:
139 HUD_Write_PanelCvar_q("_increment");
141 case HUD_PANEL_RADAR:
142 HUD_Write_PanelCvar_q("_foreground_alpha");
143 HUD_Write_PanelCvar_q("_rotation");
144 HUD_Write_PanelCvar_q("_zoommode");
145 HUD_Write_PanelCvar_q("_scale");
146 HUD_Write_PanelCvar_q("_maximized_scale");
147 HUD_Write_PanelCvar_q("_maximized_size");
148 HUD_Write_PanelCvar_q("_maximized_rotation");
149 HUD_Write_PanelCvar_q("_maximized_zoommode");
151 case HUD_PANEL_SCORE:
152 HUD_Write_PanelCvar_q("_rankings");
155 HUD_Write_PanelCvar_q("_alreadyvoted_alpha");
157 case HUD_PANEL_MODICONS:
158 HUD_Write_PanelCvar_q("_ca_layout");
159 HUD_Write_PanelCvar_q("_dom_layout");
160 HUD_Write_PanelCvar_q("_freezetag_layout");
162 case HUD_PANEL_PRESSEDKEYS:
163 HUD_Write_PanelCvar_q("_aspect");
164 HUD_Write_PanelCvar_q("_attack");
166 case HUD_PANEL_ENGINEINFO:
167 HUD_Write_PanelCvar_q("_framecounter_time");
168 HUD_Write_PanelCvar_q("_framecounter_decimals");
170 case HUD_PANEL_INFOMESSAGES:
171 HUD_Write_PanelCvar_q("_flip");
173 case HUD_PANEL_PHYSICS:
174 HUD_Write_PanelCvar_q("_speed_unit");
175 HUD_Write_PanelCvar_q("_speed_unit_show");
176 HUD_Write_PanelCvar_q("_speed_max");
177 HUD_Write_PanelCvar_q("_speed_vertical");
178 HUD_Write_PanelCvar_q("_topspeed");
179 HUD_Write_PanelCvar_q("_topspeed_time");
180 HUD_Write_PanelCvar_q("_acceleration_max");
181 HUD_Write_PanelCvar_q("_acceleration_vertical");
182 HUD_Write_PanelCvar_q("_flip");
183 HUD_Write_PanelCvar_q("_baralign");
184 HUD_Write_PanelCvar_q("_progressbar");
185 HUD_Write_PanelCvar_q("_progressbar_acceleration_mode");
186 HUD_Write_PanelCvar_q("_progressbar_acceleration_scale");
187 HUD_Write_PanelCvar_q("_progressbar_acceleration_nonlinear");
188 HUD_Write_PanelCvar_q("_text");
189 HUD_Write_PanelCvar_q("_text_scale");
191 case HUD_PANEL_CENTERPRINT:
192 HUD_Write_PanelCvar_q("_align");
193 HUD_Write_PanelCvar_q("_flip");
194 HUD_Write_PanelCvar_q("_fontscale");
195 HUD_Write_PanelCvar_q("_time");
196 HUD_Write_PanelCvar_q("_fade_in");
197 HUD_Write_PanelCvar_q("_fade_out");
198 HUD_Write_PanelCvar_q("_fade_subsequent");
199 HUD_Write_PanelCvar_q("_fade_subsequent_passone");
200 HUD_Write_PanelCvar_q("_fade_subsequent_passone_minalpha");
201 HUD_Write_PanelCvar_q("_fade_subsequent_passtwo");
202 HUD_Write_PanelCvar_q("_fade_subsequent_passtwo_minalpha");
203 HUD_Write_PanelCvar_q("_fade_subsequent_minfontsize");
204 HUD_Write_PanelCvar_q("_fade_minfontsize");
209 HUD_Write("menu_sync\n"); // force the menu to reread the cvars, so that the dialogs are updated
211 printf(_("^2Successfully exported to %s! (Note: It's saved in data/data/)\n"), filename);
215 printf(_("^1Couldn't write to %s\n"), filename);
218 void HUD_Configure_Exit_Force()
223 localcmd("togglemenu\n");
225 cvar_set("_hud_configure", "0");
228 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
229 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
231 vector myCenter, targCenter;
232 vector myTarget = myPos;
234 for (i = 0; i < HUD_PANEL_NUM; ++i) {
235 panel = hud_panel[i];
236 if(panel == highlightedPanel) continue;
237 HUD_Panel_UpdatePosSize();
238 if(!panel_enabled) continue;
240 panel_pos -= '1 1 0' * panel_bg_border;
241 panel_size += '2 2 0' * panel_bg_border;
243 if(myPos.y + mySize.y < panel_pos.y)
245 if(myPos.y > panel_pos.y + panel_size.y)
248 if(myPos.x + mySize.x < panel_pos.x)
250 if(myPos.x > panel_pos.x + panel_size.x)
253 // OK, there IS a collision.
255 myCenter.x = myPos.x + 0.5 * mySize.x;
256 myCenter.y = myPos.y + 0.5 * mySize.y;
258 targCenter.x = panel_pos.x + 0.5 * panel_size.x;
259 targCenter.y = panel_pos.y + 0.5 * panel_size.y;
261 if(myCenter.x < targCenter.x && myCenter.y < targCenter.y) // top left (of the target panel)
263 if(myPos.x + mySize.x - panel_pos.x < myPos.y + mySize.y - panel_pos.y) // push it to the side
264 myTarget.x = panel_pos.x - mySize.x;
265 else // push it upwards
266 myTarget.y = panel_pos.y - mySize.y;
268 else if(myCenter.x > targCenter.x && myCenter.y < targCenter.y) // top right
270 if(panel_pos.x + panel_size.x - myPos.x < myPos.y + mySize.y - panel_pos.y) // push it to the side
271 myTarget.x = panel_pos.x + panel_size.x;
272 else // push it upwards
273 myTarget.y = panel_pos.y - mySize.y;
275 else if(myCenter.x < targCenter.x && myCenter.y > targCenter.y) // bottom left
277 if(myPos.x + mySize.x - panel_pos.x < panel_pos.y + panel_size.y - myPos.y) // push it to the side
278 myTarget.x = panel_pos.x - mySize.x;
279 else // push it downwards
280 myTarget.y = panel_pos.y + panel_size.y;
282 else if(myCenter.x > targCenter.x && myCenter.y > targCenter.y) // bottom right
284 if(panel_pos.x + panel_size.x - myPos.x < panel_pos.y + panel_size.y - myPos.y) // push it to the side
285 myTarget.x = panel_pos.x + panel_size.x;
286 else // push it downwards
287 myTarget.y = panel_pos.y + panel_size.y;
289 //if(cvar("hud_configure_checkcollisions_debug"))
290 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
296 void HUD_Panel_SetPos(vector pos)
298 panel = highlightedPanel;
299 HUD_Panel_UpdatePosSize();
303 //if(cvar("hud_configure_checkcollisions_debug"))
304 //drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
306 if(autocvar_hud_configure_grid)
308 pos.x = floor((pos.x/vid_conwidth)/hud_configure_gridSize.x + 0.5) * hud_configure_realGridSize.x;
309 pos.y = floor((pos.y/vid_conheight)/hud_configure_gridSize.y + 0.5) * hud_configure_realGridSize.y;
312 if(hud_configure_checkcollisions)
313 pos = HUD_Panel_CheckMove(pos, mySize);
315 pos.x = bound(0, pos.x, vid_conwidth - mySize.x);
316 pos.y = bound(0, pos.y, vid_conheight - mySize.y);
319 s = strcat(ftos(pos.x/vid_conwidth), " ", ftos(pos.y/vid_conheight));
321 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_pos"), s);
324 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
325 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
328 float ratio = mySize.x/mySize.y;
330 for (i = 0; i < HUD_PANEL_NUM; ++i) {
331 panel = hud_panel[i];
332 if(panel == highlightedPanel) continue;
333 HUD_Panel_UpdatePosSize();
334 if(!panel_enabled) continue;
336 panel_pos -= '1 1 0' * panel_bg_border;
337 panel_size += '2 2 0' * panel_bg_border;
339 targEndPos = panel_pos + panel_size;
341 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
342 if(resizeorigin.x > panel_pos.x && resizeorigin.x < targEndPos.x && resizeorigin.y > panel_pos.y && resizeorigin.y < targEndPos.y)
345 if (resizeCorner == 1)
347 // check if this panel is on our way
348 if (resizeorigin.x <= panel_pos.x)
350 if (resizeorigin.y <= panel_pos.y)
352 if (targEndPos.x <= resizeorigin.x - mySize.x)
354 if (targEndPos.y <= resizeorigin.y - mySize.y)
357 // there is a collision:
358 // detect which side of the panel we are facing is actually limiting the resizing
359 // (which side the resize direction finds for first) and reduce the size up to there
361 // dist is the distance between resizeorigin and the "analogous" point of the panel
362 // in this case between resizeorigin (bottom-right point) and the bottom-right point of the panel
363 dist.x = resizeorigin.x - targEndPos.x;
364 dist.y = resizeorigin.y - targEndPos.y;
365 if (dist.y <= 0 || dist.x / dist.y > ratio)
366 mySize.x = min(mySize.x, dist.x);
368 mySize.y = min(mySize.y, dist.y);
370 else if (resizeCorner == 2)
372 if (resizeorigin.x >= targEndPos.x)
374 if (resizeorigin.y <= panel_pos.y)
376 if (panel_pos.x >= resizeorigin.x + mySize.x)
378 if (targEndPos.y <= resizeorigin.y - mySize.y)
381 dist.x = panel_pos.x - resizeorigin.x;
382 dist.y = resizeorigin.y - targEndPos.y;
383 if (dist.y <= 0 || dist.x / dist.y > ratio)
384 mySize.x = min(mySize.x, dist.x);
386 mySize.y = min(mySize.y, dist.y);
388 else if (resizeCorner == 3)
390 if (resizeorigin.x <= panel_pos.x)
392 if (resizeorigin.y >= targEndPos.y)
394 if (targEndPos.x <= resizeorigin.x - mySize.x)
396 if (panel_pos.y >= resizeorigin.y + mySize.y)
399 dist.x = resizeorigin.x - targEndPos.x;
400 dist.y = panel_pos.y - resizeorigin.y;
401 if (dist.y <= 0 || dist.x / dist.y > ratio)
402 mySize.x = min(mySize.x, dist.x);
404 mySize.y = min(mySize.y, dist.y);
406 else if (resizeCorner == 4)
408 if (resizeorigin.x >= targEndPos.x)
410 if (resizeorigin.y >= targEndPos.y)
412 if (panel_pos.x >= resizeorigin.x + mySize.x)
414 if (panel_pos.y >= resizeorigin.y + mySize.y)
417 dist.x = panel_pos.x - resizeorigin.x;
418 dist.y = panel_pos.y - resizeorigin.y;
419 if (dist.y <= 0 || dist.x / dist.y > ratio)
420 mySize.x = min(mySize.x, dist.x);
422 mySize.y = min(mySize.y, dist.y);
424 //if(cvar("hud_configure_checkcollisions_debug"))
425 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
431 void HUD_Panel_SetPosSize(vector mySize)
433 panel = highlightedPanel;
434 HUD_Panel_UpdatePosSize();
436 resizeorigin = panel_click_resizeorigin;
439 // minimum panel size cap
440 mySize.x = max(0.025 * vid_conwidth, mySize.x);
441 mySize.y = max(0.025 * vid_conheight, mySize.y);
443 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.
445 mySize.x = max(17 * autocvar_con_chatsize, mySize.x);
446 mySize.y = max(2 * autocvar_con_chatsize + 2 * panel_bg_padding, mySize.y);
449 // collision testing|
450 // -----------------+
452 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
453 if(resizeCorner == 1) {
454 myPos.x = resizeorigin.x - mySize.x;
455 myPos.y = resizeorigin.y - mySize.y;
456 } else if(resizeCorner == 2) {
457 myPos.x = resizeorigin.x;
458 myPos.y = resizeorigin.y - mySize.y;
459 } else if(resizeCorner == 3) {
460 myPos.x = resizeorigin.x - mySize.x;
461 myPos.y = resizeorigin.y;
462 } else { // resizeCorner == 4
463 myPos.x = resizeorigin.x;
464 myPos.y = resizeorigin.y;
467 // left/top screen edges
469 mySize.x = mySize.x + myPos.x;
471 mySize.y = mySize.y + myPos.y;
473 // bottom/right screen edges
474 if(myPos.x + mySize.x > vid_conwidth)
475 mySize.x = vid_conwidth - myPos.x;
476 if(myPos.y + mySize.y > vid_conheight)
477 mySize.y = vid_conheight - myPos.y;
479 //if(cvar("hud_configure_checkcollisions_debug"))
480 //drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
482 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
483 if(autocvar_hud_configure_grid)
485 mySize.x = floor((mySize.x/vid_conwidth)/hud_configure_gridSize.x + 0.5) * hud_configure_realGridSize.x;
486 mySize.y = floor((mySize.y/vid_conheight)/hud_configure_gridSize.y + 0.5) * hud_configure_realGridSize.y;
489 if(hud_configure_checkcollisions)
490 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
492 // 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)
493 mySize.x = max(0.025 * vid_conwidth, mySize.x);
494 mySize.y = max(0.025 * vid_conheight, mySize.y);
496 // do another pos check, as size might have changed by now
497 if(resizeCorner == 1) {
498 myPos.x = resizeorigin.x - mySize.x;
499 myPos.y = resizeorigin.y - mySize.y;
500 } else if(resizeCorner == 2) {
501 myPos.x = resizeorigin.x;
502 myPos.y = resizeorigin.y - mySize.y;
503 } else if(resizeCorner == 3) {
504 myPos.x = resizeorigin.x - mySize.x;
505 myPos.y = resizeorigin.y;
506 } else { // resizeCorner == 4
507 myPos.x = resizeorigin.x;
508 myPos.y = resizeorigin.y;
511 //if(cvar("hud_configure_checkcollisions_debug"))
512 //drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
515 s = strcat(ftos(mySize.x/vid_conwidth), " ", ftos(mySize.y/vid_conheight));
516 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_size"), s);
518 s = strcat(ftos(myPos.x/vid_conwidth), " ", ftos(myPos.y/vid_conheight));
519 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_pos"), s);
522 float pressed_key_time;
523 vector highlightedPanel_initial_pos, highlightedPanel_initial_size;
524 void HUD_Panel_Arrow_Action(float nPrimary)
526 if(!highlightedPanel)
529 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
532 if(autocvar_hud_configure_grid)
534 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
536 if (hudShiftState & S_SHIFT)
537 step = hud_configure_realGridSize.y;
539 step = 2 * hud_configure_realGridSize.y;
543 if (hudShiftState & S_SHIFT)
544 step = hud_configure_realGridSize.x;
546 step = 2 * hud_configure_realGridSize.x;
551 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
552 step = vid_conheight;
555 if (hudShiftState & S_SHIFT)
556 step = (step / 256); // more precision
558 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
561 panel = highlightedPanel;
562 HUD_Panel_UpdatePosSize();
564 highlightedPanel_initial_pos = panel_pos;
565 highlightedPanel_initial_size = panel_size;
567 if (hudShiftState & S_ALT) // resize
569 highlightedAction = 1;
570 if(nPrimary == K_UPARROW)
572 else if(nPrimary == K_RIGHTARROW)
574 else if(nPrimary == K_LEFTARROW)
576 else // if(nPrimary == K_DOWNARROW)
579 // ctrl+arrow reduces the size, instead of increasing it
580 // Note that ctrl disables collisions check too, but it's fine
581 // since we don't collide with anything reducing the size
582 if (hudShiftState & S_CTRL) {
584 resizeCorner = 5 - resizeCorner;
589 panel_click_resizeorigin = panel_pos;
590 if(resizeCorner == 1) {
591 panel_click_resizeorigin += mySize;
593 } else if(resizeCorner == 2) {
594 panel_click_resizeorigin.y += mySize.y;
596 } else if(resizeCorner == 3) {
597 panel_click_resizeorigin.x += mySize.x;
599 } else { // resizeCorner == 4
602 HUD_Panel_SetPosSize(mySize);
606 highlightedAction = 2;
609 if(nPrimary == K_UPARROW)
611 else if(nPrimary == K_DOWNARROW)
613 else if(nPrimary == K_LEFTARROW)
615 else // if(nPrimary == K_RIGHTARROW)
618 HUD_Panel_SetPos(pos);
621 panel = highlightedPanel;
622 HUD_Panel_UpdatePosSize();
624 if (highlightedPanel_initial_pos != panel_pos || highlightedPanel_initial_size != panel_size)
627 panel_pos_backup = highlightedPanel_initial_pos;
628 panel_size_backup = highlightedPanel_initial_size;
629 highlightedPanel_backup = highlightedPanel;
633 const int S_MOUSE1 = 1;
634 const int S_MOUSE2 = 2;
635 const int S_MOUSE3 = 4;
637 int prevMouseClicked; // previous state
638 float prevMouseClickedTime; // time during previous left mouse click, to check for doubleclicks
639 vector prevMouseClickedPos; // pos during previous left mouse click, to check for doubleclicks
641 void HUD_Panel_EnableMenu();
642 entity tab_panels[HUD_PANEL_MAX];
644 vector tab_panel_pos;
646 void HUD_Panel_FirstInDrawQ(float id);
647 void reset_tab_panels()
650 for(i = 0; i < HUD_PANEL_NUM; ++i)
651 tab_panels[i] = world;
653 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
660 if(!autocvar__hud_configure)
665 mousepos.x = nPrimary;
666 mousepos.y = nSecondary;
670 // block any input while a menu dialog is fading
671 // don't block mousepos read as it leads to cursor jumps in the interaction with the menu
672 if(autocvar__menu_alpha)
679 // allow console bind to work
682 con_keys = findkeysforcommand("toggleconsole", 0);
683 keys = tokenize(con_keys); // findkeysforcommand returns data for this
685 bool hit_con_bind = false;
687 for (i = 0; i < keys; ++i)
689 if(nPrimary == stof(argv(i)))
693 if(bInputType == 0) {
694 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
695 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
696 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
698 else if(bInputType == 1) {
699 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
700 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
701 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
704 if(nPrimary == K_CTRL)
706 if (bInputType == 1) //ctrl has been released
710 //switch to selected panel
711 highlightedPanel = tab_panel;
712 highlightedAction = 0;
713 HUD_Panel_FirstInDrawQ(highlightedPanel.panel_id);
720 if(nPrimary == K_MOUSE1)
722 if(bInputType == 0) // key pressed
723 mouseClicked |= S_MOUSE1;
724 else if(bInputType == 1) // key released
725 mouseClicked -= (mouseClicked & S_MOUSE1);
727 else if(nPrimary == K_MOUSE2)
729 if(bInputType == 0) // key pressed
730 mouseClicked |= S_MOUSE2;
731 else if(bInputType == 1) // key released
732 mouseClicked -= (mouseClicked & S_MOUSE2);
734 else if(nPrimary == K_ESCAPE)
739 localcmd("menu_showhudexit\n");
741 else if(nPrimary == K_BACKSPACE && hudShiftState & S_CTRL)
746 cvar_set("_hud_configure", "0");
748 else if(nPrimary == K_TAB && hudShiftState & S_CTRL) // select and highlight another panel
750 if (bInputType == 1 || mouseClicked)
753 //FIXME: if a panel is highlighted, has the same pos_x and lays in the same level
754 //of other panels then next consecutive ctrl-tab will select the highlighted panel too
755 //(it should only after every other panel of the hud)
756 //It's a minor bug anyway, we can live with it
758 entity starting_panel;
759 entity old_tab_panel = tab_panel;
760 if (!tab_panel) //first press of TAB
762 if (highlightedPanel)
764 panel = highlightedPanel;
765 HUD_Panel_UpdatePosSize();
769 starting_panel = highlightedPanel;
770 tab_panel_pos = panel_pos; //to compute level
774 if ( ((!tab_backward) && (hudShiftState & S_SHIFT)) || (tab_backward && !(hudShiftState & S_SHIFT)) ) //tab direction changed?
776 starting_panel = tab_panel;
778 tab_backward = (hudShiftState & S_SHIFT);
780 float k, level = 0, start_posX;
781 vector candidate_pos = '0 0 0';
782 const float LEVELS_NUM = 4;
783 float level_height = vid_conheight / LEVELS_NUM;
785 level = floor(tab_panel_pos.y / level_height) * level_height; //starting level
786 candidate_pos.x = (!tab_backward) ? vid_conwidth : 0;
787 start_posX = tab_panel_pos.x;
792 for(i = 0; i < HUD_PANEL_NUM; ++i)
794 panel = hud_panel[i];
795 if (panel == tab_panels[i] || panel == starting_panel)
797 HUD_Panel_UpdatePosSize();
798 if (panel_pos.y >= level && (panel_pos.y - level) < level_height)
799 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)) )
800 || ( 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)) ) )
803 tab_panel_pos = candidate_pos = panel_pos;
808 if (k == LEVELS_NUM) //tab_panel not found
816 starting_panel = old_tab_panel;
817 old_tab_panel = world;
818 goto find_tab_panel; //u must find tab_panel!
822 level = (level + level_height) % vid_conheight;
824 candidate_pos.x = vid_conwidth;
828 level = (level - level_height) % vid_conheight;
829 start_posX = vid_conwidth;
834 tab_panels[tab_panel.panel_id] = tab_panel;
836 else if(nPrimary == K_SPACE && hudShiftState & S_CTRL) // enable/disable highlighted panel or dock
838 if (bInputType == 1 || mouseClicked)
841 if (highlightedPanel)
842 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name), ftos(!cvar(strcat("hud_panel_", highlightedPanel.panel_name))));
844 cvar_set(strcat("hud_dock"), (autocvar_hud_dock == "") ? "dock" : "");
846 else if(nPrimary == 'c' && hudShiftState & S_CTRL) // copy highlighted panel size
848 if (bInputType == 1 || mouseClicked)
851 if (highlightedPanel)
853 panel = highlightedPanel;
854 HUD_Panel_UpdatePosSize();
855 panel_size_copied = panel_size;
858 else if(nPrimary == 'v' && hudShiftState & S_CTRL) // past copied size on the highlighted panel
860 if (bInputType == 1 || mouseClicked)
863 if (panel_size_copied == '0 0 0' || !highlightedPanel)
866 panel = highlightedPanel;
867 HUD_Panel_UpdatePosSize();
869 // reduce size if it'd go beyond screen boundaries
870 vector tmp_size = panel_size_copied;
871 if (panel_pos.x + panel_size_copied.x > vid_conwidth)
872 tmp_size.x = vid_conwidth - panel_pos.x;
873 if (panel_pos.y + panel_size_copied.y > vid_conheight)
874 tmp_size.y = vid_conheight - panel_pos.y;
876 if (panel_size == tmp_size)
880 panel_pos_backup = panel_pos;
881 panel_size_backup = panel_size;
882 highlightedPanel_backup = highlightedPanel;
884 s = strcat(ftos(tmp_size.x/vid_conwidth), " ", ftos(tmp_size.y/vid_conheight));
885 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_size"), s);
887 else if(nPrimary == 'z' && hudShiftState & S_CTRL) // undo last action
889 if (bInputType == 1 || mouseClicked)
891 //restore previous values
892 if (highlightedPanel_backup)
894 s = strcat(ftos(panel_pos_backup.x/vid_conwidth), " ", ftos(panel_pos_backup.y/vid_conheight));
895 cvar_set(strcat("hud_panel_", highlightedPanel_backup.panel_name, "_pos"), s);
896 s = strcat(ftos(panel_size_backup.x/vid_conwidth), " ", ftos(panel_size_backup.y/vid_conheight));
897 cvar_set(strcat("hud_panel_", highlightedPanel_backup.panel_name, "_size"), s);
898 highlightedPanel_backup = world;
901 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
905 pressed_key_time = 0;
908 else if (pressed_key_time == 0)
909 pressed_key_time = time;
912 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
914 else if(nPrimary == K_ENTER || nPrimary == K_SPACE || nPrimary == K_KP_ENTER)
918 if (highlightedPanel)
919 HUD_Panel_EnableMenu();
921 else if(hit_con_bind)
927 float HUD_Panel_Check_Mouse_Pos(float allow_move)
930 while(j < HUD_PANEL_NUM)
935 panel = hud_panel[i];
936 HUD_Panel_UpdatePosSize();
938 float border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
941 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)
945 // resize from topleft border
946 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)
950 // resize from topright border
951 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)
955 // resize from bottomleft border
956 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)
960 // resize from bottomright border
961 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)
969 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
970 void HUD_Panel_FirstInDrawQ(float id)
974 // find out where in the array our current id is, save into place
975 for(i = 0; i < HUD_PANEL_NUM; ++i)
977 if(panel_order[i] == id)
983 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
985 place = HUD_PANEL_NUM - 1;
987 // move all ids up by one step in the array until "place"
988 for(i = place; i > 0; --i)
990 panel_order[i] = panel_order[i-1];
992 // now save the new top id
995 // let's save them into the cvar by some strcat trickery
997 for(i = 0; i < HUD_PANEL_NUM; ++i)
999 s = strcat(s, ftos(panel_order[i]), " ");
1001 cvar_set("_hud_panelorder", s);
1002 if(hud_panelorder_prev)
1003 strunzone(hud_panelorder_prev);
1004 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1007 void HUD_Panel_Highlight(float allow_move)
1011 while(j < HUD_PANEL_NUM)
1016 panel = hud_panel[i];
1017 HUD_Panel_UpdatePosSize();
1019 float border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1022 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)
1024 highlightedPanel = hud_panel[i];
1025 HUD_Panel_FirstInDrawQ(i);
1026 highlightedAction = 1;
1027 panel_click_distance = mousepos - panel_pos;
1030 // resize from topleft border
1031 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)
1033 highlightedPanel = hud_panel[i];
1034 HUD_Panel_FirstInDrawQ(i);
1035 highlightedAction = 2;
1037 panel_click_distance = mousepos - panel_pos;
1038 panel_click_resizeorigin = panel_pos + panel_size;
1041 // resize from topright border
1042 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)
1044 highlightedPanel = hud_panel[i];
1045 HUD_Panel_FirstInDrawQ(i);
1046 highlightedAction = 2;
1048 panel_click_distance.x = panel_size.x - mousepos.x + panel_pos.x;
1049 panel_click_distance.y = mousepos.y - panel_pos.y;
1050 panel_click_resizeorigin = panel_pos + eY * panel_size.y;
1053 // resize from bottomleft border
1054 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)
1056 highlightedPanel = hud_panel[i];
1057 HUD_Panel_FirstInDrawQ(i);
1058 highlightedAction = 2;
1060 panel_click_distance.x = mousepos.x - panel_pos.x;
1061 panel_click_distance.y = panel_size.y - mousepos.y + panel_pos.y;
1062 panel_click_resizeorigin = panel_pos + eX * panel_size.x;
1065 // resize from bottomright border
1066 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)
1068 highlightedPanel = hud_panel[i];
1069 HUD_Panel_FirstInDrawQ(i);
1070 highlightedAction = 2;
1072 panel_click_distance = panel_size - mousepos + panel_pos;
1073 panel_click_resizeorigin = panel_pos;
1077 highlightedPanel = world;
1078 highlightedAction = 0;
1081 void HUD_Panel_EnableMenu()
1084 localcmd("menu_showhudoptions ", highlightedPanel.panel_name, "\n");
1086 float mouse_over_panel;
1087 void HUD_Panel_Mouse()
1089 if(autocvar__menu_alpha == 1)
1092 if (!autocvar_hud_cursormode)
1094 mousepos = mousepos + getmousepos() * autocvar_menu_mouse_speed;
1096 mousepos.x = bound(0, mousepos.x, vid_conwidth);
1097 mousepos.y = bound(0, mousepos.y, vid_conheight);
1102 if(prevMouseClicked == 0)
1106 //stop ctrl-tab selection
1110 HUD_Panel_Highlight(mouseClicked & S_MOUSE1); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1111 // and calls HUD_Panel_UpdatePosSize() for the highlighted panel
1112 if (highlightedPanel)
1114 highlightedPanel_initial_pos = panel_pos;
1115 highlightedPanel_initial_size = panel_size;
1117 // doubleclick check
1118 if ((mouseClicked & S_MOUSE1) && time - prevMouseClickedTime < 0.4 && highlightedPanel && prevMouseClickedPos == mousepos)
1120 mouseClicked = 0; // to prevent spam, I guess.
1121 HUD_Panel_EnableMenu();
1125 if (mouseClicked & S_MOUSE1)
1127 prevMouseClickedTime = time;
1128 prevMouseClickedPos = mousepos;
1130 mouse_over_panel = HUD_Panel_Check_Mouse_Pos(mouseClicked & S_MOUSE1);
1135 panel = highlightedPanel;
1136 HUD_Panel_UpdatePosSize();
1139 if (highlightedPanel)
1141 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .1, DRAWFLAG_NORMAL);
1142 if (highlightedPanel_initial_pos != panel_pos || highlightedPanel_initial_size != panel_size)
1144 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1146 panel_pos_backup = highlightedPanel_initial_pos;
1147 panel_size_backup = highlightedPanel_initial_size;
1148 highlightedPanel_backup = highlightedPanel;
1151 // in case the clicked panel is inside another panel and we aren't
1152 // moving it, avoid the immediate "fix" of its position/size
1153 // (often unwanted and hateful) by disabling collisions check
1154 hud_configure_checkcollisions = false;
1157 if(highlightedAction == 1)
1158 HUD_Panel_SetPos(mousepos - panel_click_distance);
1159 else if(highlightedAction == 2)
1161 vector mySize = '0 0 0';
1162 if(resizeCorner == 1) {
1163 mySize.x = panel_click_resizeorigin.x - (mousepos.x - panel_click_distance.x);
1164 mySize.y = panel_click_resizeorigin.y - (mousepos.y - panel_click_distance.y);
1165 } else if(resizeCorner == 2) {
1166 mySize.x = mousepos.x + panel_click_distance.x - panel_click_resizeorigin.x;
1167 mySize.y = panel_click_distance.y + panel_click_resizeorigin.y - mousepos.y;
1168 } else if(resizeCorner == 3) {
1169 mySize.x = panel_click_resizeorigin.x + panel_click_distance.x - mousepos.x;
1170 mySize.y = mousepos.y + panel_click_distance.y - panel_click_resizeorigin.y;
1171 } else { // resizeCorner == 4
1172 mySize.x = mousepos.x - (panel_click_resizeorigin.x - panel_click_distance.x);
1173 mySize.y = mousepos.y - (panel_click_resizeorigin.y - panel_click_distance.y);
1175 HUD_Panel_SetPosSize(mySize);
1180 if(menu_enabled == 2)
1181 mouse_over_panel = 0;
1183 mouse_over_panel = HUD_Panel_Check_Mouse_Pos(true);
1184 if (mouse_over_panel && !tab_panel)
1185 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .1, DRAWFLAG_NORMAL);
1187 // draw cursor after performing move/resize to have the panel pos/size updated before mouse_over_panel
1188 const vector cursorsize = '32 32 0';
1189 float cursor_alpha = 1 - autocvar__menu_alpha;
1191 if(!mouse_over_panel)
1192 drawpic(mousepos, strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursorsize, '1 1 1', cursor_alpha, DRAWFLAG_NORMAL);
1193 else if(mouse_over_panel == 1)
1194 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_move.tga"), cursorsize, '1 1 1', cursor_alpha, DRAWFLAG_NORMAL);
1195 else if(mouse_over_panel == 2)
1196 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_resize.tga"), cursorsize, '1 1 1', cursor_alpha, DRAWFLAG_NORMAL);
1198 drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_resize2.tga"), cursorsize, '1 1 1', cursor_alpha, DRAWFLAG_NORMAL);
1200 prevMouseClicked = mouseClicked;
1202 void HUD_Configure_DrawGrid()
1205 if(autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
1207 hud_configure_gridSize.x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
1208 hud_configure_gridSize.y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
1209 hud_configure_realGridSize.x = hud_configure_gridSize.x * vid_conwidth;
1210 hud_configure_realGridSize.y = hud_configure_gridSize.y * vid_conheight;
1213 s = eX + eY * vid_conheight;
1214 for(i = 1; i < 1/hud_configure_gridSize.x; ++i)
1215 drawfill(eX * i * hud_configure_realGridSize.x, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
1217 s = eY + eX * vid_conwidth;
1218 for(i = 1; i < 1/hud_configure_gridSize.y; ++i)
1219 drawfill(eY * i * hud_configure_realGridSize.y, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
1223 float _menu_alpha_prev;
1224 void HUD_Configure_Frame()
1227 if(autocvar__hud_configure)
1229 if(isdemo() || intermission == 2)
1231 HUD_Configure_Exit_Force();
1235 if(!hud_configure_prev)
1237 if(autocvar_hud_cursormode)
1240 for(i = HUD_PANEL_NUM - 1; i >= 0; --i)
1241 hud_panel[panel_order[i]].update_time = time;
1244 // NOTE this check is necessary because _menu_alpha isn't updated the frame the menu gets enabled
1245 if(autocvar__menu_alpha != _menu_alpha_prev)
1247 if(autocvar__menu_alpha == 0)
1249 _menu_alpha_prev = autocvar__menu_alpha;
1252 HUD_Configure_DrawGrid();
1254 else if(hud_configure_prev)
1258 if(autocvar_hud_cursormode)
1263 const float hlBorderSize = 2;
1264 const string hlBorder = "gfx/hud/default/border_highlighted";
1265 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
1266 void HUD_Panel_HlBorder(float myBorder, vector color, float theAlpha)
1268 drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * theAlpha, DRAWFLAG_NORMAL);
1269 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);
1270 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);
1271 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);
1272 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);
1275 void HUD_Configure_PostDraw()
1277 if(autocvar__hud_configure)
1282 HUD_Panel_UpdatePosSize();
1283 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
1285 if(highlightedPanel)
1287 panel = highlightedPanel;
1288 HUD_Panel_UpdatePosSize();
1289 HUD_Panel_HlBorder(panel_bg_border * hlBorderSize, '0 0.5 1', 0.4 * (1 - autocvar__menu_alpha));