1 #include "hud_config.qh"
4 #include "panel/scoreboard.qh"
5 #include <client/autocvars.qh>
6 #include <client/defs.qh>
7 #include <client/miscfunctions.qh>
8 #include <client/view.qh>
10 #define HUD_Write(s) fputs(fh, s)
11 #define HUD_Write_Cvar(cvar) HUD_Write(strcat("seta ", cvar, " \"", cvar_string(cvar), "\"\n"))
12 #define HUD_Write_PanelCvar(cvar_suf) str = strcat("hud_panel_", panel.panel_name, cvar_suf), HUD_Write_Cvar(str)
14 void HUD_Panel_ExportCfg(string cfgname)
17 string filename = strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg");
19 fh = fopen(filename, FILE_WRITE);
22 HUD_Write("//title \n");
23 HUD_Write("//author \n");
25 HUD_Write_Cvar("hud_skin");
26 HUD_Write_Cvar("hud_panel_bg");
27 HUD_Write_Cvar("hud_panel_bg_color");
28 HUD_Write_Cvar("hud_panel_bg_color_team");
29 HUD_Write_Cvar("hud_panel_bg_alpha");
30 HUD_Write_Cvar("hud_panel_bg_border");
31 HUD_Write_Cvar("hud_panel_bg_padding");
32 HUD_Write_Cvar("hud_panel_fg_alpha");
35 HUD_Write_Cvar("hud_dock");
36 HUD_Write_Cvar("hud_dock_color");
37 HUD_Write_Cvar("hud_dock_color_team");
38 HUD_Write_Cvar("hud_dock_alpha");
41 HUD_Write_Cvar("hud_progressbar_alpha");
42 HUD_Write_Cvar("hud_progressbar_strength_color");
43 HUD_Write_Cvar("hud_progressbar_superweapons_color");
44 HUD_Write_Cvar("hud_progressbar_shield_color");
45 HUD_Write_Cvar("hud_progressbar_health_color");
46 HUD_Write_Cvar("hud_progressbar_armor_color");
47 HUD_Write_Cvar("hud_progressbar_fuel_color");
48 HUD_Write_Cvar("hud_progressbar_nexball_color");
49 HUD_Write_Cvar("hud_progressbar_speed_color");
50 HUD_Write_Cvar("hud_progressbar_acceleration_color");
51 HUD_Write_Cvar("hud_progressbar_acceleration_neg_color");
52 HUD_Write_Cvar("hud_progressbar_vehicles_ammo1_color");
53 HUD_Write_Cvar("hud_progressbar_vehicles_ammo2_color");
56 HUD_Write_Cvar("_hud_panelorder");
59 HUD_Write_Cvar("hud_configure_grid");
60 HUD_Write_Cvar("hud_configure_grid_xsize");
61 HUD_Write_Cvar("hud_configure_grid_ysize");
64 // common cvars for all panels
65 for (int i = 0; i < hud_panels_COUNT; ++i)
67 panel = hud_panels_from(i);
69 HUD_Write_PanelCvar("_pos");
70 HUD_Write_PanelCvar("_size");
71 HUD_Write_PanelCvar("_bg");
72 HUD_Write_PanelCvar("_bg_color");
73 HUD_Write_PanelCvar("_bg_color_team");
74 HUD_Write_PanelCvar("_bg_alpha");
75 HUD_Write_PanelCvar("_bg_border");
76 HUD_Write_PanelCvar("_bg_padding");
78 case HUD_PANEL_WEAPONS:
79 HUD_Write_Cvar("hud_panel_weapons_accuracy");
80 HUD_Write_Cvar("hud_panel_weapons_label");
81 HUD_Write_Cvar("hud_panel_weapons_label_scale");
82 HUD_Write_Cvar("hud_panel_weapons_complainbubble");
83 HUD_Write_Cvar("hud_panel_weapons_complainbubble_padding");
84 HUD_Write_Cvar("hud_panel_weapons_complainbubble_time");
85 HUD_Write_Cvar("hud_panel_weapons_complainbubble_fadetime");
86 HUD_Write_Cvar("hud_panel_weapons_complainbubble_color_outofammo");
87 HUD_Write_Cvar("hud_panel_weapons_complainbubble_color_donthave");
88 HUD_Write_Cvar("hud_panel_weapons_complainbubble_color_unavailable");
89 HUD_Write_Cvar("hud_panel_weapons_ammo");
90 HUD_Write_Cvar("hud_panel_weapons_ammo_color");
91 HUD_Write_Cvar("hud_panel_weapons_ammo_alpha");
92 HUD_Write_Cvar("hud_panel_weapons_aspect");
93 HUD_Write_Cvar("hud_panel_weapons_timeout");
94 HUD_Write_Cvar("hud_panel_weapons_timeout_effect");
95 HUD_Write_Cvar("hud_panel_weapons_timeout_fadebgmin");
96 HUD_Write_Cvar("hud_panel_weapons_timeout_fadefgmin");
97 HUD_Write_Cvar("hud_panel_weapons_timeout_speed_in");
98 HUD_Write_Cvar("hud_panel_weapons_timeout_speed_out");
99 HUD_Write_Cvar("hud_panel_weapons_onlyowned");
100 HUD_Write_Cvar("hud_panel_weapons_orderbyimpulse");
101 HUD_Write_Cvar("hud_panel_weapons_noncurrent_alpha");
102 HUD_Write_Cvar("hud_panel_weapons_noncurrent_scale");
103 HUD_Write_Cvar("hud_panel_weapons_selection_radius");
104 HUD_Write_Cvar("hud_panel_weapons_selection_speed");
107 HUD_Write_Cvar("hud_panel_ammo_onlycurrent");
108 HUD_Write_Cvar("hud_panel_ammo_noncurrent_alpha");
109 HUD_Write_Cvar("hud_panel_ammo_noncurrent_scale");
110 HUD_Write_Cvar("hud_panel_ammo_iconalign");
111 HUD_Write_Cvar("hud_panel_ammo_progressbar");
112 HUD_Write_Cvar("hud_panel_ammo_progressbar_name");
113 HUD_Write_Cvar("hud_panel_ammo_progressbar_xoffset");
114 HUD_Write_Cvar("hud_panel_ammo_text");
116 case HUD_PANEL_POWERUPS:
117 HUD_Write_Cvar("hud_panel_powerups_iconalign");
118 HUD_Write_Cvar("hud_panel_powerups_baralign");
119 HUD_Write_Cvar("hud_panel_powerups_progressbar");
120 HUD_Write_Cvar("hud_panel_powerups_text");
122 case HUD_PANEL_HEALTHARMOR:
123 HUD_Write_Cvar("hud_panel_healtharmor_combined");
124 HUD_Write_Cvar("hud_panel_healtharmor_flip");
125 HUD_Write_Cvar("hud_panel_healtharmor_iconalign");
126 HUD_Write_Cvar("hud_panel_healtharmor_baralign");
127 HUD_Write_Cvar("hud_panel_healtharmor_progressbar");
128 HUD_Write_Cvar("hud_panel_healtharmor_progressbar_health");
129 HUD_Write_Cvar("hud_panel_healtharmor_progressbar_armor");
130 HUD_Write_Cvar("hud_panel_healtharmor_progressbar_gfx");
131 HUD_Write_Cvar("hud_panel_healtharmor_progressbar_gfx_smooth");
132 HUD_Write_Cvar("hud_panel_healtharmor_text");
134 case HUD_PANEL_NOTIFY:
135 HUD_Write_Cvar("hud_panel_notify_flip");
136 HUD_Write_Cvar("hud_panel_notify_fontsize");
137 HUD_Write_Cvar("hud_panel_notify_time");
138 HUD_Write_Cvar("hud_panel_notify_fadetime");
139 HUD_Write_Cvar("hud_panel_notify_icon_aspect");
141 case HUD_PANEL_TIMER:
143 case HUD_PANEL_RADAR:
144 HUD_Write_Cvar("hud_panel_radar_foreground_alpha");
145 HUD_Write_Cvar("hud_panel_radar_rotation");
146 HUD_Write_Cvar("hud_panel_radar_zoommode");
147 HUD_Write_Cvar("hud_panel_radar_scale");
148 HUD_Write_Cvar("hud_panel_radar_maximized_scale");
149 HUD_Write_Cvar("hud_panel_radar_maximized_size");
150 HUD_Write_Cvar("hud_panel_radar_maximized_rotation");
151 HUD_Write_Cvar("hud_panel_radar_maximized_zoommode");
153 case HUD_PANEL_SCORE:
154 HUD_Write_Cvar("hud_panel_score_rankings");
157 HUD_Write_Cvar("hud_panel_vote_alreadyvoted_alpha");
159 case HUD_PANEL_MODICONS:
160 HUD_Write_Cvar("hud_panel_modicons_ca_layout");
161 HUD_Write_Cvar("hud_panel_modicons_dom_layout");
162 HUD_Write_Cvar("hud_panel_modicons_freezetag_layout");
164 case HUD_PANEL_PRESSEDKEYS:
165 HUD_Write_Cvar("hud_panel_pressedkeys_aspect");
166 HUD_Write_Cvar("hud_panel_pressedkeys_attack");
168 case HUD_PANEL_ENGINEINFO:
169 HUD_Write_Cvar("hud_panel_engineinfo_framecounter_time");
170 HUD_Write_Cvar("hud_panel_engineinfo_framecounter_decimals");
172 case HUD_PANEL_INFOMESSAGES:
173 HUD_Write_Cvar("hud_panel_infomessages_flip");
175 case HUD_PANEL_PHYSICS:
176 HUD_Write_Cvar("hud_panel_physics_speed_unit_show");
177 HUD_Write_Cvar("hud_panel_physics_speed_max");
178 HUD_Write_Cvar("hud_panel_physics_speed_vertical");
179 HUD_Write_Cvar("hud_panel_physics_topspeed");
180 HUD_Write_Cvar("hud_panel_physics_topspeed_time");
181 HUD_Write_Cvar("hud_panel_physics_acceleration_max");
182 HUD_Write_Cvar("hud_panel_physics_acceleration_vertical");
183 HUD_Write_Cvar("hud_panel_physics_flip");
184 HUD_Write_Cvar("hud_panel_physics_baralign");
185 HUD_Write_Cvar("hud_panel_physics_progressbar");
186 HUD_Write_Cvar("hud_panel_physics_acceleration_progressbar_mode");
187 HUD_Write_Cvar("hud_panel_physics_acceleration_progressbar_scale");
188 HUD_Write_Cvar("hud_panel_physics_acceleration_progressbar_nonlinear");
189 HUD_Write_Cvar("hud_panel_physics_text");
190 HUD_Write_Cvar("hud_panel_physics_text_scale");
192 case HUD_PANEL_CENTERPRINT:
193 HUD_Write_Cvar("hud_panel_centerprint_align");
194 HUD_Write_Cvar("hud_panel_centerprint_flip");
195 HUD_Write_Cvar("hud_panel_centerprint_fontscale");
196 HUD_Write_Cvar("hud_panel_centerprint_time");
197 HUD_Write_Cvar("hud_panel_centerprint_fade_in");
198 HUD_Write_Cvar("hud_panel_centerprint_fade_out");
199 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent");
200 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent_passone");
201 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent_passone_minalpha");
202 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent_passtwo");
203 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent_passtwo_minalpha");
204 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent_minfontsize");
205 HUD_Write_Cvar("hud_panel_centerprint_fade_minfontsize");
207 case HUD_PANEL_ITEMSTIME:
208 HUD_Write_Cvar("hud_panel_itemstime_iconalign");
209 HUD_Write_Cvar("hud_panel_itemstime_progressbar");
210 HUD_Write_Cvar("hud_panel_itemstime_progressbar_name");
211 HUD_Write_Cvar("hud_panel_itemstime_progressbar_reduced");
212 HUD_Write_Cvar("hud_panel_itemstime_text");
213 HUD_Write_Cvar("hud_panel_itemstime_ratio");
214 HUD_Write_Cvar("hud_panel_itemstime_dynamicsize");
216 case HUD_PANEL_MAPVOTE:
217 HUD_Write_Cvar("hud_panel_mapvote_highlight_border");
219 case HUD_PANEL_QUICKMENU:
220 HUD_Write_Cvar("hud_panel_quickmenu_align");
222 case HUD_PANEL_SCOREBOARD:
223 HUD_Write_Cvar("hud_panel_scoreboard_fadeinspeed");
224 HUD_Write_Cvar("hud_panel_scoreboard_fadeoutspeed");
225 HUD_Write_Cvar("hud_panel_scoreboard_respawntime_decimals");
226 HUD_Write_Cvar("hud_panel_scoreboard_table_bg_alpha");
227 HUD_Write_Cvar("hud_panel_scoreboard_table_bg_scale");
228 HUD_Write_Cvar("hud_panel_scoreboard_table_fg_alpha");
229 HUD_Write_Cvar("hud_panel_scoreboard_table_fg_alpha_self");
230 HUD_Write_Cvar("hud_panel_scoreboard_table_highlight");
231 HUD_Write_Cvar("hud_panel_scoreboard_table_highlight_alpha");
232 HUD_Write_Cvar("hud_panel_scoreboard_table_highlight_alpha_self");
233 HUD_Write_Cvar("hud_panel_scoreboard_bg_teams_color_team");
234 HUD_Write_Cvar("hud_panel_scoreboard_accuracy_doublerows");
235 HUD_Write_Cvar("hud_panel_scoreboard_accuracy_nocolors");
240 MUTATOR_CALLHOOK(HUD_WriteCvars, fh);
242 HUD_Write("menu_sync\n"); // force the menu to reread the cvars, so that the dialogs are updated
244 LOG_INFOF(_("^2Successfully exported to %s! (Note: It's saved in data/data/)"), filename);
248 LOG_INFOF(_("^1Couldn't write to %s"), filename);
251 void HUD_Configure_Exit_Force()
253 if (hud_configure_menu_open)
255 hud_configure_menu_open = 0;
256 localcmd("togglemenu\n");
258 cursor_type = CURSOR_NORMAL;
259 cvar_set("_hud_configure", "0");
262 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
263 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
265 vector myCenter, targCenter;
266 vector myTarget = myPos;
268 for (i = 0; i < hud_panels_COUNT; ++i) {
269 panel = hud_panels_from(i);
270 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
271 if(panel == highlightedPanel) continue;
272 HUD_Panel_UpdatePosSize();
273 if(!panel_enabled) continue;
275 panel_pos -= '1 1 0' * panel_bg_border;
276 panel_size += '2 2 0' * panel_bg_border;
278 if(myPos.y + mySize.y < panel_pos.y)
280 if(myPos.y > panel_pos.y + panel_size.y)
283 if(myPos.x + mySize.x < panel_pos.x)
285 if(myPos.x > panel_pos.x + panel_size.x)
288 // OK, there IS a collision.
290 myCenter.x = myPos.x + 0.5 * mySize.x;
291 myCenter.y = myPos.y + 0.5 * mySize.y;
293 targCenter.x = panel_pos.x + 0.5 * panel_size.x;
294 targCenter.y = panel_pos.y + 0.5 * panel_size.y;
296 if(myCenter.x < targCenter.x && myCenter.y < targCenter.y) // top left (of the target panel)
298 if(myPos.x + mySize.x - panel_pos.x < myPos.y + mySize.y - panel_pos.y) // push it to the side
299 myTarget.x = panel_pos.x - mySize.x;
300 else // push it upwards
301 myTarget.y = panel_pos.y - mySize.y;
303 else if(myCenter.x > targCenter.x && myCenter.y < targCenter.y) // top right
305 if(panel_pos.x + panel_size.x - myPos.x < myPos.y + mySize.y - panel_pos.y) // push it to the side
306 myTarget.x = panel_pos.x + panel_size.x;
307 else // push it upwards
308 myTarget.y = panel_pos.y - mySize.y;
310 else if(myCenter.x < targCenter.x && myCenter.y > targCenter.y) // bottom left
312 if(myPos.x + mySize.x - panel_pos.x < panel_pos.y + panel_size.y - myPos.y) // push it to the side
313 myTarget.x = panel_pos.x - mySize.x;
314 else // push it downwards
315 myTarget.y = panel_pos.y + panel_size.y;
317 else if(myCenter.x > targCenter.x && myCenter.y > targCenter.y) // bottom right
319 if(panel_pos.x + panel_size.x - myPos.x < panel_pos.y + panel_size.y - myPos.y) // push it to the side
320 myTarget.x = panel_pos.x + panel_size.x;
321 else // push it downwards
322 myTarget.y = panel_pos.y + panel_size.y;
324 //if(cvar("hud_configure_checkcollisions_debug"))
325 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
331 void HUD_Panel_SetPos(vector pos)
333 panel = highlightedPanel;
334 HUD_Panel_UpdatePosSize();
338 //if(cvar("hud_configure_checkcollisions_debug"))
339 //drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
341 if(autocvar_hud_configure_grid)
343 pos.x = floor((pos.x/vid_conwidth)/hud_configure_gridSize.x + 0.5) * hud_configure_realGridSize.x;
344 pos.y = floor((pos.y/vid_conheight)/hud_configure_gridSize.y + 0.5) * hud_configure_realGridSize.y;
347 if(hud_configure_checkcollisions)
348 pos = HUD_Panel_CheckMove(pos, mySize);
350 pos.x = bound(0, pos.x, vid_conwidth - mySize.x);
351 pos.y = bound(0, pos.y, vid_conheight - mySize.y);
354 s = strcat(ftos(pos.x/vid_conwidth), " ", ftos(pos.y/vid_conheight));
356 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_pos"), s);
359 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
360 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
363 float ratio = mySize.x/mySize.y;
365 for (i = 0; i < hud_panels_COUNT; ++i) {
366 panel = hud_panels_from(i);
367 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
368 if(panel == highlightedPanel) continue;
369 HUD_Panel_UpdatePosSize();
370 if(!panel_enabled) continue;
372 panel_pos -= '1 1 0' * panel_bg_border;
373 panel_size += '2 2 0' * panel_bg_border;
375 targEndPos = panel_pos + panel_size;
377 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
378 if(resizeorigin.x > panel_pos.x && resizeorigin.x < targEndPos.x && resizeorigin.y > panel_pos.y && resizeorigin.y < targEndPos.y)
381 if (resizeCorner == 1)
383 // check if this panel is on our way
384 if (resizeorigin.x <= panel_pos.x)
386 if (resizeorigin.y <= panel_pos.y)
388 if (targEndPos.x <= resizeorigin.x - mySize.x)
390 if (targEndPos.y <= resizeorigin.y - mySize.y)
393 // there is a collision:
394 // detect which side of the panel we are facing is actually limiting the resizing
395 // (which side the resize direction finds for first) and reduce the size up to there
397 // dist is the distance between resizeorigin and the "analogous" point of the panel
398 // in this case between resizeorigin (bottom-right point) and the bottom-right point of the panel
399 dist.x = resizeorigin.x - targEndPos.x;
400 dist.y = resizeorigin.y - targEndPos.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 == 2)
408 if (resizeorigin.x >= targEndPos.x)
410 if (resizeorigin.y <= panel_pos.y)
412 if (panel_pos.x >= resizeorigin.x + mySize.x)
414 if (targEndPos.y <= resizeorigin.y - mySize.y)
417 dist.x = panel_pos.x - resizeorigin.x;
418 dist.y = resizeorigin.y - targEndPos.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 else if (resizeCorner == 3)
426 if (resizeorigin.x <= panel_pos.x)
428 if (resizeorigin.y >= targEndPos.y)
430 if (targEndPos.x <= resizeorigin.x - mySize.x)
432 if (panel_pos.y >= resizeorigin.y + mySize.y)
435 dist.x = resizeorigin.x - targEndPos.x;
436 dist.y = panel_pos.y - resizeorigin.y;
437 if (dist.y <= 0 || dist.x / dist.y > ratio)
438 mySize.x = min(mySize.x, dist.x);
440 mySize.y = min(mySize.y, dist.y);
442 else if (resizeCorner == 4)
444 if (resizeorigin.x >= targEndPos.x)
446 if (resizeorigin.y >= targEndPos.y)
448 if (panel_pos.x >= resizeorigin.x + mySize.x)
450 if (panel_pos.y >= resizeorigin.y + mySize.y)
453 dist.x = panel_pos.x - resizeorigin.x;
454 dist.y = panel_pos.y - resizeorigin.y;
455 if (dist.y <= 0 || dist.x / dist.y > ratio)
456 mySize.x = min(mySize.x, dist.x);
458 mySize.y = min(mySize.y, dist.y);
460 //if(cvar("hud_configure_checkcollisions_debug"))
461 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
467 void HUD_Panel_SetPosSize(vector mySize)
469 panel = highlightedPanel;
470 HUD_Panel_UpdatePosSize();
471 vector resizeorigin = panel_click_resizeorigin;
474 // minimum panel size cap
475 mySize.x = max(0.025 * vid_conwidth, mySize.x);
476 mySize.y = max(0.025 * vid_conheight, mySize.y);
478 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.
480 mySize.x = max(17 * autocvar_con_chatsize, mySize.x);
481 mySize.y = max(2 * autocvar_con_chatsize + 2 * panel_bg_padding, mySize.y);
484 // collision testing|
485 // -----------------+
487 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
488 if(resizeCorner == 1) {
489 myPos.x = resizeorigin.x - mySize.x;
490 myPos.y = resizeorigin.y - mySize.y;
491 } else if(resizeCorner == 2) {
492 myPos.x = resizeorigin.x;
493 myPos.y = resizeorigin.y - mySize.y;
494 } else if(resizeCorner == 3) {
495 myPos.x = resizeorigin.x - mySize.x;
496 myPos.y = resizeorigin.y;
497 } else { // resizeCorner == 4
498 myPos.x = resizeorigin.x;
499 myPos.y = resizeorigin.y;
502 // left/top screen edges
504 mySize.x = mySize.x + myPos.x;
506 mySize.y = mySize.y + myPos.y;
508 // bottom/right screen edges
509 if(myPos.x + mySize.x > vid_conwidth)
510 mySize.x = vid_conwidth - myPos.x;
511 if(myPos.y + mySize.y > vid_conheight)
512 mySize.y = vid_conheight - myPos.y;
514 //if(cvar("hud_configure_checkcollisions_debug"))
515 //drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
517 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
518 if(autocvar_hud_configure_grid)
520 mySize.x = floor((mySize.x/vid_conwidth)/hud_configure_gridSize.x + 0.5) * hud_configure_realGridSize.x;
521 mySize.y = floor((mySize.y/vid_conheight)/hud_configure_gridSize.y + 0.5) * hud_configure_realGridSize.y;
524 if(hud_configure_checkcollisions)
525 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
527 // 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)
528 mySize.x = max(0.025 * vid_conwidth, mySize.x);
529 mySize.y = max(0.025 * vid_conheight, mySize.y);
531 // do another pos check, as size might have changed by now
532 if(resizeCorner == 1) {
533 myPos.x = resizeorigin.x - mySize.x;
534 myPos.y = resizeorigin.y - mySize.y;
535 } else if(resizeCorner == 2) {
536 myPos.x = resizeorigin.x;
537 myPos.y = resizeorigin.y - mySize.y;
538 } else if(resizeCorner == 3) {
539 myPos.x = resizeorigin.x - mySize.x;
540 myPos.y = resizeorigin.y;
541 } else { // resizeCorner == 4
542 myPos.x = resizeorigin.x;
543 myPos.y = resizeorigin.y;
546 //if(cvar("hud_configure_checkcollisions_debug"))
547 //drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
550 s = strcat(ftos(mySize.x/vid_conwidth), " ", ftos(mySize.y/vid_conheight));
551 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_size"), s);
553 s = strcat(ftos(myPos.x/vid_conwidth), " ", ftos(myPos.y/vid_conheight));
554 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_pos"), s);
557 float pressed_key_time;
558 vector highlightedPanel_initial_pos, highlightedPanel_initial_size;
559 void HUD_Panel_Arrow_Action(float nPrimary)
561 if(!highlightedPanel)
564 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
567 if(autocvar_hud_configure_grid)
569 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
571 if (hudShiftState & S_SHIFT)
572 step = hud_configure_realGridSize.y;
574 step = 2 * hud_configure_realGridSize.y;
578 if (hudShiftState & S_SHIFT)
579 step = hud_configure_realGridSize.x;
581 step = 2 * hud_configure_realGridSize.x;
586 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
587 step = vid_conheight;
590 if (hudShiftState & S_SHIFT)
591 step = (step / 256); // more precision
593 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
596 panel = highlightedPanel;
597 HUD_Panel_UpdatePosSize();
599 highlightedPanel_initial_pos = panel_pos;
600 highlightedPanel_initial_size = panel_size;
602 if (hudShiftState & S_ALT) // resize
604 if(nPrimary == K_UPARROW)
606 else if(nPrimary == K_RIGHTARROW)
608 else if(nPrimary == K_LEFTARROW)
610 else // if(nPrimary == K_DOWNARROW)
613 // ctrl+arrow reduces the size, instead of increasing it
614 // Note that ctrl disables collisions check too, but it's fine
615 // since we don't collide with anything reducing the size
616 if (hudShiftState & S_CTRL) {
618 resizeCorner = 5 - resizeCorner;
623 panel_click_resizeorigin = panel_pos;
624 if(resizeCorner == 1) {
625 panel_click_resizeorigin += mySize;
627 } else if(resizeCorner == 2) {
628 panel_click_resizeorigin.y += mySize.y;
630 } else if(resizeCorner == 3) {
631 panel_click_resizeorigin.x += mySize.x;
633 } else { // resizeCorner == 4
636 HUD_Panel_SetPosSize(mySize);
642 if(nPrimary == K_UPARROW)
644 else if(nPrimary == K_DOWNARROW)
646 else if(nPrimary == K_LEFTARROW)
648 else // if(nPrimary == K_RIGHTARROW)
651 HUD_Panel_SetPos(pos);
654 panel = highlightedPanel;
655 HUD_Panel_UpdatePosSize();
657 if (highlightedPanel_initial_pos != panel_pos || highlightedPanel_initial_size != panel_size)
660 panel_pos_backup = highlightedPanel_initial_pos;
661 panel_size_backup = highlightedPanel_initial_size;
662 highlightedPanel_backup = highlightedPanel;
666 entity tab_panels[hud_panels_MAX];
668 vector tab_panel_pos;
670 void reset_tab_panels()
672 for (int i = 0; i < hud_panels_COUNT; ++i)
673 tab_panels[i] = NULL;
675 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
682 if(!autocvar__hud_configure)
687 mousepos.x = nPrimary;
688 mousepos.y = nSecondary;
692 // block any input while a menu dialog is fading
693 // don't block mousepos read as it leads to cursor jumps in the interaction with the menu
694 if(autocvar__menu_alpha)
701 // allow console bind to work
702 string con_keys = findkeysforcommand("toggleconsole", 0);
703 int keys = tokenize(con_keys); // findkeysforcommand returns data for this
705 bool hit_con_bind = false;
707 for (i = 0; i < keys; ++i)
709 if(nPrimary == stof(argv(i)))
713 if(bInputType == 0) {
714 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
715 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
716 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
718 else if(bInputType == 1) {
719 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
720 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
721 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
724 if(nPrimary == K_CTRL)
726 if (bInputType == 1) //ctrl has been released
730 //switch to selected panel
731 highlightedPanel = tab_panel;
732 highlightedAction = 0;
733 HUD_Panel_FirstInDrawQ(highlightedPanel.panel_id);
740 if(nPrimary == K_MOUSE1)
742 if(bInputType == 0) // key pressed
743 mouseClicked |= S_MOUSE1;
744 else if(bInputType == 1) // key released
745 mouseClicked -= (mouseClicked & S_MOUSE1);
747 else if(nPrimary == K_MOUSE2)
749 if(bInputType == 0) // key pressed
750 mouseClicked |= S_MOUSE2;
751 else if(bInputType == 1) // key released
752 mouseClicked -= (mouseClicked & S_MOUSE2);
754 else if(nPrimary == K_ESCAPE)
758 hud_configure_menu_open = 1;
759 localcmd("menu_showhudexit\n");
761 else if(nPrimary == K_BACKSPACE && hudShiftState & S_CTRL)
765 if (!hud_configure_menu_open)
766 HUD_Configure_Exit_Force();
768 else if(nPrimary == K_TAB && hudShiftState & S_CTRL) // switch panel
770 if (bInputType == 1 || mouseClicked)
773 // FIXME minor bug: if a panel is highlighted, has the same pos_x and
774 // lays in the same level of another panel then the next consecutive
775 // CTRL TAB presses will reselect once more the highlighted panel
777 entity starting_panel;
778 entity old_tab_panel = tab_panel;
779 if (!tab_panel) //first press of TAB
781 if (highlightedPanel)
783 panel = highlightedPanel;
784 HUD_Panel_UpdatePosSize();
788 starting_panel = highlightedPanel;
789 tab_panel_pos = panel_pos; //to compute level
793 if ( ((!tab_backward) && (hudShiftState & S_SHIFT)) || (tab_backward && !(hudShiftState & S_SHIFT)) ) //tab direction changed?
795 starting_panel = tab_panel;
797 tab_backward = (hudShiftState & S_SHIFT);
799 float k, level = 0, start_posX;
800 vector candidate_pos = '0 0 0';
801 const float LEVELS_NUM = 4;
802 float level_height = vid_conheight / LEVELS_NUM;
803 LABEL(find_tab_panel)
804 level = floor(tab_panel_pos.y / level_height) * level_height; //starting level
805 candidate_pos.x = (!tab_backward) ? vid_conwidth : 0;
806 start_posX = tab_panel_pos.x;
811 for(i = 0; i < hud_panels_COUNT; ++i)
813 panel = hud_panels_from(i);
814 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN))
816 if (panel == tab_panels[i] || panel == starting_panel)
818 HUD_Panel_UpdatePosSize();
819 if (panel_pos.y >= level && (panel_pos.y - level) < level_height)
820 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)) )
821 || ( 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)) ) )
824 tab_panel_pos = candidate_pos = panel_pos;
829 if (k == LEVELS_NUM) //tab_panel not found
837 starting_panel = old_tab_panel;
838 old_tab_panel = NULL;
839 goto find_tab_panel; //u must find tab_panel!
843 level = (level + level_height) % vid_conheight;
845 candidate_pos.x = vid_conwidth;
849 level = (level - level_height) % vid_conheight;
850 start_posX = vid_conwidth;
855 tab_panels[tab_panel.panel_id] = tab_panel;
857 else if(nPrimary == K_SPACE && hudShiftState & S_CTRL) // enable/disable highlighted panel or dock
859 if (bInputType == 1 || mouseClicked)
862 if (highlightedPanel)
864 if(panel.panel_configflags & PANEL_CONFIG_CANBEOFF)
865 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name), ftos(!cvar(strcat("hud_panel_", highlightedPanel.panel_name))));
868 cvar_set(strcat("hud_dock"), (autocvar_hud_dock == "") ? "dock" : "");
870 else if(nPrimary == 'c' && hudShiftState & S_CTRL) // copy highlighted panel size
872 if (bInputType == 1 || mouseClicked)
875 if (highlightedPanel)
877 panel = highlightedPanel;
878 HUD_Panel_UpdatePosSize();
879 panel_size_copied = panel_size;
882 else if(nPrimary == 'v' && hudShiftState & S_CTRL) // past copied size on the highlighted panel
884 if (bInputType == 1 || mouseClicked)
887 if (panel_size_copied == '0 0 0' || !highlightedPanel)
890 panel = highlightedPanel;
891 HUD_Panel_UpdatePosSize();
893 // reduce size if it'd go beyond screen boundaries
894 vector tmp_size = panel_size_copied;
895 if (panel_pos.x + panel_size_copied.x > vid_conwidth)
896 tmp_size.x = vid_conwidth - panel_pos.x;
897 if (panel_pos.y + panel_size_copied.y > vid_conheight)
898 tmp_size.y = vid_conheight - panel_pos.y;
900 if (panel_size == tmp_size)
904 panel_pos_backup = panel_pos;
905 panel_size_backup = panel_size;
906 highlightedPanel_backup = highlightedPanel;
908 s = strcat(ftos(tmp_size.x/vid_conwidth), " ", ftos(tmp_size.y/vid_conheight));
909 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_size"), s);
911 else if(nPrimary == 'z' && hudShiftState & S_CTRL) // undo last action
913 if (bInputType == 1 || mouseClicked)
915 //restore previous values
916 if (highlightedPanel_backup)
918 s = strcat(ftos(panel_pos_backup.x/vid_conwidth), " ", ftos(panel_pos_backup.y/vid_conheight));
919 cvar_set(strcat("hud_panel_", highlightedPanel_backup.panel_name, "_pos"), s);
920 s = strcat(ftos(panel_size_backup.x/vid_conwidth), " ", ftos(panel_size_backup.y/vid_conheight));
921 cvar_set(strcat("hud_panel_", highlightedPanel_backup.panel_name, "_size"), s);
922 highlightedPanel_backup = NULL;
925 else if(nPrimary == 's' && hudShiftState & S_CTRL) // save config
927 if (bInputType == 1 || mouseClicked)
929 localcmd("hud save myconfig\n");
931 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
935 pressed_key_time = 0;
938 else if (pressed_key_time == 0)
939 pressed_key_time = time;
942 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
944 else if(nPrimary == K_ENTER || nPrimary == K_SPACE || nPrimary == K_KP_ENTER)
948 if (highlightedPanel)
949 HUD_Panel_EnableMenu();
951 else if(hit_con_bind || nPrimary == K_PAUSE)
957 int HUD_Panel_Check_Mouse_Pos(bool allow_move)
960 while(j < hud_panels_COUNT)
965 panel = hud_panels_from(i);
966 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
967 HUD_Panel_UpdatePosSize();
969 float border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
972 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)
976 // resize from topleft border
977 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)
979 return CURSOR_RESIZE;
981 // resize from topright border
982 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)
984 return CURSOR_RESIZE2;
986 // resize from bottomleft border
987 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)
989 return CURSOR_RESIZE2;
991 // resize from bottomright border
992 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)
994 return CURSOR_RESIZE;
997 return CURSOR_NORMAL;
1000 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1001 void HUD_Panel_FirstInDrawQ(float id)
1005 // find out where in the array our current id is, save into place
1006 for(i = 0; i < hud_panels_COUNT; ++i)
1008 if(panel_order[i] == id)
1014 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1016 place = hud_panels_COUNT - 1;
1018 // move all ids up by one step in the array until "place"
1019 for(i = place; i > 0; --i)
1021 panel_order[i] = panel_order[i-1];
1023 // now save the new top id
1024 panel_order[0] = id;
1026 // let's save them into the cvar by some strcat trickery
1028 for(i = 0; i < hud_panels_COUNT; ++i)
1030 s = strcat(s, ftos(panel_order[i]), " ");
1032 cvar_set("_hud_panelorder", s);
1033 strcpy(hud_panelorder_prev, autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1036 void HUD_Panel_Highlight(float allow_move)
1040 while(j < hud_panels_COUNT)
1045 panel = hud_panels_from(i);
1046 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN))
1048 HUD_Panel_UpdatePosSize();
1050 float border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1053 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)
1055 highlightedPanel = hud_panels_from(i);
1056 HUD_Panel_FirstInDrawQ(i);
1057 highlightedAction = 1;
1058 panel_click_distance = mousepos - panel_pos;
1061 // resize from topleft border
1062 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)
1064 highlightedPanel = hud_panels_from(i);
1065 HUD_Panel_FirstInDrawQ(i);
1066 highlightedAction = 2;
1068 panel_click_distance = mousepos - panel_pos;
1069 panel_click_resizeorigin = panel_pos + panel_size;
1072 // resize from topright border
1073 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)
1075 highlightedPanel = hud_panels_from(i);
1076 HUD_Panel_FirstInDrawQ(i);
1077 highlightedAction = 2;
1079 panel_click_distance.x = panel_size.x - mousepos.x + panel_pos.x;
1080 panel_click_distance.y = mousepos.y - panel_pos.y;
1081 panel_click_resizeorigin = panel_pos + eY * panel_size.y;
1084 // resize from bottomleft border
1085 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)
1087 highlightedPanel = hud_panels_from(i);
1088 HUD_Panel_FirstInDrawQ(i);
1089 highlightedAction = 2;
1091 panel_click_distance.x = mousepos.x - panel_pos.x;
1092 panel_click_distance.y = panel_size.y - mousepos.y + panel_pos.y;
1093 panel_click_resizeorigin = panel_pos + eX * panel_size.x;
1096 // resize from bottomright border
1097 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)
1099 highlightedPanel = hud_panels_from(i);
1100 HUD_Panel_FirstInDrawQ(i);
1101 highlightedAction = 2;
1103 panel_click_distance = panel_size - mousepos + panel_pos;
1104 panel_click_resizeorigin = panel_pos;
1108 highlightedPanel = NULL;
1109 highlightedAction = 0;
1112 void HUD_Panel_EnableMenu()
1114 hud_configure_menu_open = 2;
1115 localcmd("menu_showhudoptions ", highlightedPanel.panel_name, "\n");
1117 void HUD_Panel_Mouse()
1119 if(autocvar__menu_alpha == 1)
1124 if(prevMouseClicked == 0)
1128 //stop ctrl-tab selection
1132 HUD_Panel_Highlight(mouseClicked & S_MOUSE1); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1133 // and calls HUD_Panel_UpdatePosSize() for the highlighted panel
1134 if (highlightedPanel)
1136 highlightedPanel_initial_pos = panel_pos;
1137 highlightedPanel_initial_size = panel_size;
1139 // doubleclick check
1140 if ((mouseClicked & S_MOUSE1) && time - prevMouseClickedTime < 0.4 && highlightedPanel && prevMouseClickedPos == mousepos)
1142 mouseClicked = 0; // to prevent spam, I guess.
1143 HUD_Panel_EnableMenu();
1147 if (mouseClicked & S_MOUSE1)
1149 prevMouseClickedTime = time;
1150 prevMouseClickedPos = mousepos;
1152 cursor_type = HUD_Panel_Check_Mouse_Pos(mouseClicked & S_MOUSE1);
1157 panel = highlightedPanel;
1158 HUD_Panel_UpdatePosSize();
1161 if (highlightedPanel)
1163 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .1, DRAWFLAG_NORMAL);
1164 if (highlightedPanel_initial_pos != panel_pos || highlightedPanel_initial_size != panel_size)
1166 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1168 panel_pos_backup = highlightedPanel_initial_pos;
1169 panel_size_backup = highlightedPanel_initial_size;
1170 highlightedPanel_backup = highlightedPanel;
1173 // in case the clicked panel is inside another panel and we aren't
1174 // moving it, avoid the immediate "fix" of its position/size
1175 // (often unwanted and hateful) by disabling collisions check
1176 hud_configure_checkcollisions = false;
1179 if(highlightedAction == 1)
1180 HUD_Panel_SetPos(mousepos - panel_click_distance);
1181 else if(highlightedAction == 2)
1183 vector mySize = '0 0 0';
1184 if(resizeCorner == 1) {
1185 mySize.x = panel_click_resizeorigin.x - (mousepos.x - panel_click_distance.x);
1186 mySize.y = panel_click_resizeorigin.y - (mousepos.y - panel_click_distance.y);
1187 } else if(resizeCorner == 2) {
1188 mySize.x = mousepos.x + panel_click_distance.x - panel_click_resizeorigin.x;
1189 mySize.y = panel_click_distance.y + panel_click_resizeorigin.y - mousepos.y;
1190 } else if(resizeCorner == 3) {
1191 mySize.x = panel_click_resizeorigin.x + panel_click_distance.x - mousepos.x;
1192 mySize.y = mousepos.y + panel_click_distance.y - panel_click_resizeorigin.y;
1193 } else { // resizeCorner == 4
1194 mySize.x = mousepos.x - (panel_click_resizeorigin.x - panel_click_distance.x);
1195 mySize.y = mousepos.y - (panel_click_resizeorigin.y - panel_click_distance.y);
1197 HUD_Panel_SetPosSize(mySize);
1202 if(prevMouseClicked)
1203 highlightedAction = 0;
1204 if(hud_configure_menu_open == 2)
1205 cursor_type = CURSOR_NORMAL;
1207 cursor_type = HUD_Panel_Check_Mouse_Pos(true);
1208 if (cursor_type != CURSOR_NORMAL && !tab_panel) // mouse over a panel?
1209 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .1, DRAWFLAG_NORMAL);
1212 void HUD_Configure_DrawGrid()
1215 if(autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
1217 hud_configure_gridSize.x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
1218 hud_configure_gridSize.y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
1219 hud_configure_realGridSize.x = hud_configure_gridSize.x * vid_conwidth;
1220 hud_configure_realGridSize.y = hud_configure_gridSize.y * vid_conheight;
1223 s = vec2(1, vid_conheight);
1224 for(i = 1; i < 1/hud_configure_gridSize.x; ++i)
1225 drawfill(eX * i * hud_configure_realGridSize.x, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
1227 s = vec2(vid_conwidth, 1);
1228 for(i = 1; i < 1/hud_configure_gridSize.y; ++i)
1229 drawfill(eY * i * hud_configure_realGridSize.y, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
1233 float _menu_alpha_prev;
1234 void HUD_Configure_Frame()
1237 if(autocvar__hud_configure)
1239 if(isdemo() || intermission == 2 || scoreboard_active)
1241 HUD_Configure_Exit_Force();
1245 if(!hud_configure_prev)
1248 for(i = hud_panels_COUNT - 1; i >= 0; --i)
1249 hud_panels_from(panel_order[i]).update_time = time;
1252 // NOTE this check is necessary because _menu_alpha isn't updated the frame the menu gets enabled
1253 if(autocvar__menu_alpha != _menu_alpha_prev)
1255 if(autocvar__menu_alpha == 0)
1256 hud_configure_menu_open = 0;
1257 _menu_alpha_prev = autocvar__menu_alpha;
1260 HUD_Configure_DrawGrid();
1262 else if(hud_configure_prev)
1264 if(hud_configure_menu_open)
1265 hud_configure_menu_open = 0;
1266 hud_dynamic_shake_factor = -1;
1270 const float hlBorderSize = 2;
1271 const string hlBorder = "gfx/hud/default/border_highlighted";
1272 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
1273 void HUD_Panel_HlBorder(float myBorder, vector color, float theAlpha)
1275 vector pos = panel_pos - vec2(myBorder, myBorder);
1276 drawfill(pos, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * theAlpha, DRAWFLAG_NORMAL);
1277 drawpic_tiled(pos, hlBorder, '8 1 0' * hlBorderSize, vec2(panel_size.x + 2 * myBorder, hlBorderSize), color, theAlpha, DRAWFLAG_NORMAL);
1278 drawpic_tiled(pos + eY * (panel_size.y + 2 * myBorder - hlBorderSize), hlBorder, '8 1 0' * hlBorderSize, vec2(panel_size.x + 2 * myBorder, hlBorderSize), color, theAlpha, DRAWFLAG_NORMAL);
1279 pos.y += hlBorderSize;
1280 drawpic_tiled(pos, hlBorder2, '1 8 0' * hlBorderSize, vec2(hlBorderSize, panel_size.y + 2 * myBorder - 2 * hlBorderSize), color, theAlpha, DRAWFLAG_NORMAL);
1281 drawpic_tiled(pos + eX * (panel_size.x + 2 * myBorder - hlBorderSize), hlBorder2, '1 8 0' * hlBorderSize, vec2(hlBorderSize, panel_size.y + 2 * myBorder - 2 * hlBorderSize), color, theAlpha, DRAWFLAG_NORMAL);
1284 void HUD_Configure_PostDraw()
1286 if(autocvar__hud_configure)
1291 HUD_Panel_UpdatePosSize();
1292 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
1294 if(highlightedPanel)
1296 panel = highlightedPanel;
1297 HUD_Panel_UpdatePosSize();
1298 HUD_Panel_HlBorder(panel_bg_border * hlBorderSize, '0 0.5 1', 0.4 * (1 - autocvar__menu_alpha));