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_oxygen_color");
49 HUD_Write_Cvar("hud_progressbar_nexball_color");
50 HUD_Write_Cvar("hud_progressbar_speed_color");
51 HUD_Write_Cvar("hud_progressbar_acceleration_color");
52 HUD_Write_Cvar("hud_progressbar_acceleration_neg_color");
53 HUD_Write_Cvar("hud_progressbar_vehicles_ammo1_color");
54 HUD_Write_Cvar("hud_progressbar_vehicles_ammo2_color");
57 HUD_Write_Cvar("_hud_panelorder");
60 HUD_Write_Cvar("hud_configure_grid");
61 HUD_Write_Cvar("hud_configure_grid_xsize");
62 HUD_Write_Cvar("hud_configure_grid_ysize");
65 // common cvars for all panels
66 for (int i = 0; i < hud_panels_COUNT; ++i)
68 panel = hud_panels_from(i);
70 HUD_Write_PanelCvar("_pos");
71 HUD_Write_PanelCvar("_size");
72 HUD_Write_PanelCvar("_bg");
73 HUD_Write_PanelCvar("_bg_color");
74 HUD_Write_PanelCvar("_bg_color_team");
75 HUD_Write_PanelCvar("_bg_alpha");
76 HUD_Write_PanelCvar("_bg_border");
77 HUD_Write_PanelCvar("_bg_padding");
79 case HUD_PANEL_WEAPONS:
80 HUD_Write_Cvar("hud_panel_weapons_accuracy");
81 HUD_Write_Cvar("hud_panel_weapons_label");
82 HUD_Write_Cvar("hud_panel_weapons_label_scale");
83 HUD_Write_Cvar("hud_panel_weapons_complainbubble");
84 HUD_Write_Cvar("hud_panel_weapons_complainbubble_padding");
85 HUD_Write_Cvar("hud_panel_weapons_complainbubble_time");
86 HUD_Write_Cvar("hud_panel_weapons_complainbubble_fadetime");
87 HUD_Write_Cvar("hud_panel_weapons_complainbubble_color_outofammo");
88 HUD_Write_Cvar("hud_panel_weapons_complainbubble_color_donthave");
89 HUD_Write_Cvar("hud_panel_weapons_complainbubble_color_unavailable");
90 HUD_Write_Cvar("hud_panel_weapons_ammo");
91 HUD_Write_Cvar("hud_panel_weapons_ammo_color");
92 HUD_Write_Cvar("hud_panel_weapons_ammo_alpha");
93 HUD_Write_Cvar("hud_panel_weapons_aspect");
94 HUD_Write_Cvar("hud_panel_weapons_timeout");
95 HUD_Write_Cvar("hud_panel_weapons_timeout_effect");
96 HUD_Write_Cvar("hud_panel_weapons_timeout_fadebgmin");
97 HUD_Write_Cvar("hud_panel_weapons_timeout_fadefgmin");
98 HUD_Write_Cvar("hud_panel_weapons_timeout_speed_in");
99 HUD_Write_Cvar("hud_panel_weapons_timeout_speed_out");
100 HUD_Write_Cvar("hud_panel_weapons_onlyowned");
101 HUD_Write_Cvar("hud_panel_weapons_orderbyimpulse");
102 HUD_Write_Cvar("hud_panel_weapons_noncurrent_alpha");
103 HUD_Write_Cvar("hud_panel_weapons_noncurrent_scale");
104 HUD_Write_Cvar("hud_panel_weapons_selection_radius");
105 HUD_Write_Cvar("hud_panel_weapons_selection_speed");
108 HUD_Write_Cvar("hud_panel_ammo_onlycurrent");
109 HUD_Write_Cvar("hud_panel_ammo_noncurrent_alpha");
110 HUD_Write_Cvar("hud_panel_ammo_noncurrent_scale");
111 HUD_Write_Cvar("hud_panel_ammo_iconalign");
112 HUD_Write_Cvar("hud_panel_ammo_progressbar");
113 HUD_Write_Cvar("hud_panel_ammo_progressbar_name");
114 HUD_Write_Cvar("hud_panel_ammo_progressbar_xoffset");
115 HUD_Write_Cvar("hud_panel_ammo_text");
117 case HUD_PANEL_POWERUPS:
118 HUD_Write_Cvar("hud_panel_powerups_iconalign");
119 HUD_Write_Cvar("hud_panel_powerups_baralign");
120 HUD_Write_Cvar("hud_panel_powerups_progressbar");
121 HUD_Write_Cvar("hud_panel_powerups_text");
123 case HUD_PANEL_HEALTHARMOR:
124 HUD_Write_Cvar("hud_panel_healtharmor_combined");
125 HUD_Write_Cvar("hud_panel_healtharmor_flip");
126 HUD_Write_Cvar("hud_panel_healtharmor_iconalign");
127 HUD_Write_Cvar("hud_panel_healtharmor_baralign");
128 HUD_Write_Cvar("hud_panel_healtharmor_progressbar");
129 HUD_Write_Cvar("hud_panel_healtharmor_progressbar_health");
130 HUD_Write_Cvar("hud_panel_healtharmor_progressbar_armor");
131 HUD_Write_Cvar("hud_panel_healtharmor_progressbar_gfx");
132 HUD_Write_Cvar("hud_panel_healtharmor_progressbar_gfx_smooth");
133 HUD_Write_Cvar("hud_panel_healtharmor_text");
135 case HUD_PANEL_NOTIFY:
136 HUD_Write_Cvar("hud_panel_notify_flip");
137 HUD_Write_Cvar("hud_panel_notify_fontsize");
138 HUD_Write_Cvar("hud_panel_notify_time");
139 HUD_Write_Cvar("hud_panel_notify_fadetime");
140 HUD_Write_Cvar("hud_panel_notify_icon_aspect");
142 case HUD_PANEL_TIMER:
144 case HUD_PANEL_RADAR:
145 HUD_Write_Cvar("hud_panel_radar_foreground_alpha");
146 HUD_Write_Cvar("hud_panel_radar_rotation");
147 HUD_Write_Cvar("hud_panel_radar_zoommode");
148 HUD_Write_Cvar("hud_panel_radar_scale");
149 HUD_Write_Cvar("hud_panel_radar_maximized_scale");
150 HUD_Write_Cvar("hud_panel_radar_maximized_size");
151 HUD_Write_Cvar("hud_panel_radar_maximized_rotation");
152 HUD_Write_Cvar("hud_panel_radar_maximized_zoommode");
154 case HUD_PANEL_SCORE:
155 HUD_Write_Cvar("hud_panel_score_rankings");
158 HUD_Write_Cvar("hud_panel_vote_alreadyvoted_alpha");
160 case HUD_PANEL_MODICONS:
161 HUD_Write_Cvar("hud_panel_modicons_ca_layout");
162 HUD_Write_Cvar("hud_panel_modicons_dom_layout");
163 HUD_Write_Cvar("hud_panel_modicons_freezetag_layout");
165 case HUD_PANEL_PRESSEDKEYS:
166 HUD_Write_Cvar("hud_panel_pressedkeys_aspect");
167 HUD_Write_Cvar("hud_panel_pressedkeys_attack");
169 case HUD_PANEL_ENGINEINFO:
170 HUD_Write_Cvar("hud_panel_engineinfo_framecounter_time");
171 HUD_Write_Cvar("hud_panel_engineinfo_framecounter_decimals");
173 case HUD_PANEL_INFOMESSAGES:
174 HUD_Write_Cvar("hud_panel_infomessages_flip");
176 case HUD_PANEL_PHYSICS:
177 HUD_Write_Cvar("hud_panel_physics_speed_unit_show");
178 HUD_Write_Cvar("hud_panel_physics_speed_max");
179 HUD_Write_Cvar("hud_panel_physics_speed_vertical");
180 HUD_Write_Cvar("hud_panel_physics_topspeed");
181 HUD_Write_Cvar("hud_panel_physics_topspeed_time");
182 HUD_Write_Cvar("hud_panel_physics_acceleration_max");
183 HUD_Write_Cvar("hud_panel_physics_acceleration_vertical");
184 HUD_Write_Cvar("hud_panel_physics_flip");
185 HUD_Write_Cvar("hud_panel_physics_baralign");
186 HUD_Write_Cvar("hud_panel_physics_progressbar");
187 HUD_Write_Cvar("hud_panel_physics_acceleration_progressbar_mode");
188 HUD_Write_Cvar("hud_panel_physics_acceleration_progressbar_scale");
189 HUD_Write_Cvar("hud_panel_physics_acceleration_progressbar_nonlinear");
190 HUD_Write_Cvar("hud_panel_physics_text");
191 HUD_Write_Cvar("hud_panel_physics_text_scale");
193 case HUD_PANEL_CENTERPRINT:
194 HUD_Write_Cvar("hud_panel_centerprint_align");
195 HUD_Write_Cvar("hud_panel_centerprint_flip");
196 HUD_Write_Cvar("hud_panel_centerprint_fontscale");
197 HUD_Write_Cvar("hud_panel_centerprint_fontscale_bold");
198 HUD_Write_Cvar("hud_panel_centerprint_time");
199 HUD_Write_Cvar("hud_panel_centerprint_fade_in");
200 HUD_Write_Cvar("hud_panel_centerprint_fade_out");
201 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent");
202 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent_passone");
203 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent_passone_minalpha");
204 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent_passtwo");
205 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent_passtwo_minalpha");
206 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent_minfontsize");
207 HUD_Write_Cvar("hud_panel_centerprint_fade_minfontsize");
209 case HUD_PANEL_ITEMSTIME:
210 HUD_Write_Cvar("hud_panel_itemstime_iconalign");
211 HUD_Write_Cvar("hud_panel_itemstime_progressbar");
212 HUD_Write_Cvar("hud_panel_itemstime_progressbar_name");
213 HUD_Write_Cvar("hud_panel_itemstime_progressbar_reduced");
214 HUD_Write_Cvar("hud_panel_itemstime_text");
215 HUD_Write_Cvar("hud_panel_itemstime_ratio");
216 HUD_Write_Cvar("hud_panel_itemstime_dynamicsize");
218 case HUD_PANEL_MAPVOTE:
219 HUD_Write_Cvar("hud_panel_mapvote_highlight_border");
221 case HUD_PANEL_QUICKMENU:
222 HUD_Write_Cvar("hud_panel_quickmenu_align");
224 case HUD_PANEL_SCOREBOARD:
225 HUD_Write_Cvar("hud_panel_scoreboard_fadeinspeed");
226 HUD_Write_Cvar("hud_panel_scoreboard_fadeoutspeed");
227 HUD_Write_Cvar("hud_panel_scoreboard_respawntime_decimals");
228 HUD_Write_Cvar("hud_panel_scoreboard_table_bg_alpha");
229 HUD_Write_Cvar("hud_panel_scoreboard_table_bg_scale");
230 HUD_Write_Cvar("hud_panel_scoreboard_table_fg_alpha");
231 HUD_Write_Cvar("hud_panel_scoreboard_table_fg_alpha_self");
232 HUD_Write_Cvar("hud_panel_scoreboard_table_highlight");
233 HUD_Write_Cvar("hud_panel_scoreboard_table_highlight_alpha");
234 HUD_Write_Cvar("hud_panel_scoreboard_table_highlight_alpha_self");
235 HUD_Write_Cvar("hud_panel_scoreboard_bg_teams_color_team");
236 HUD_Write_Cvar("hud_panel_scoreboard_accuracy_doublerows");
237 HUD_Write_Cvar("hud_panel_scoreboard_accuracy_nocolors");
242 MUTATOR_CALLHOOK(HUD_WriteCvars, fh);
244 HUD_Write("menu_sync\n"); // force the menu to reread the cvars, so that the dialogs are updated
246 LOG_INFOF(_("^2Successfully exported to %s! (Note: It's saved in data/data/)"), filename);
250 LOG_INFOF(_("^1Couldn't write to %s"), filename);
253 void HUD_Configure_Exit_Force()
255 if (hud_configure_menu_open)
257 hud_configure_menu_open = 0;
258 localcmd("togglemenu\n");
260 cursor_type = CURSOR_NORMAL;
261 cvar_set("_hud_configure", "0");
264 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
265 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
267 vector myCenter, targCenter;
268 vector myTarget = myPos;
270 for (i = 0; i < hud_panels_COUNT; ++i) {
271 panel = hud_panels_from(i);
272 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
273 if(panel == highlightedPanel) continue;
274 HUD_Panel_UpdatePosSize();
275 if(!panel_enabled) continue;
277 panel_pos -= '1 1 0' * panel_bg_border;
278 panel_size += '2 2 0' * panel_bg_border;
280 if(myPos.y + mySize.y < panel_pos.y)
282 if(myPos.y > panel_pos.y + panel_size.y)
285 if(myPos.x + mySize.x < panel_pos.x)
287 if(myPos.x > panel_pos.x + panel_size.x)
290 // OK, there IS a collision.
292 myCenter.x = myPos.x + 0.5 * mySize.x;
293 myCenter.y = myPos.y + 0.5 * mySize.y;
295 targCenter.x = panel_pos.x + 0.5 * panel_size.x;
296 targCenter.y = panel_pos.y + 0.5 * panel_size.y;
298 if(myCenter.x < targCenter.x && myCenter.y < targCenter.y) // top left (of the target panel)
300 if(myPos.x + mySize.x - panel_pos.x < myPos.y + mySize.y - panel_pos.y) // push it to the side
301 myTarget.x = panel_pos.x - mySize.x;
302 else // push it upwards
303 myTarget.y = panel_pos.y - mySize.y;
305 else if(myCenter.x > targCenter.x && myCenter.y < targCenter.y) // top right
307 if(panel_pos.x + panel_size.x - myPos.x < myPos.y + mySize.y - panel_pos.y) // push it to the side
308 myTarget.x = panel_pos.x + panel_size.x;
309 else // push it upwards
310 myTarget.y = panel_pos.y - mySize.y;
312 else if(myCenter.x < targCenter.x && myCenter.y > targCenter.y) // bottom left
314 if(myPos.x + mySize.x - panel_pos.x < panel_pos.y + panel_size.y - myPos.y) // push it to the side
315 myTarget.x = panel_pos.x - mySize.x;
316 else // push it downwards
317 myTarget.y = panel_pos.y + panel_size.y;
319 else if(myCenter.x > targCenter.x && myCenter.y > targCenter.y) // bottom right
321 if(panel_pos.x + panel_size.x - myPos.x < panel_pos.y + panel_size.y - myPos.y) // push it to the side
322 myTarget.x = panel_pos.x + panel_size.x;
323 else // push it downwards
324 myTarget.y = panel_pos.y + panel_size.y;
326 //if(cvar("hud_configure_checkcollisions_debug"))
327 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
333 void HUD_Panel_SetPos(vector pos)
335 panel = highlightedPanel;
336 HUD_Panel_UpdatePosSize();
340 //if(cvar("hud_configure_checkcollisions_debug"))
341 //drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
343 if(autocvar_hud_configure_grid)
345 pos.x = floor((pos.x/vid_conwidth)/hud_configure_gridSize.x + 0.5) * hud_configure_realGridSize.x;
346 pos.y = floor((pos.y/vid_conheight)/hud_configure_gridSize.y + 0.5) * hud_configure_realGridSize.y;
349 if(hud_configure_checkcollisions)
350 pos = HUD_Panel_CheckMove(pos, mySize);
352 pos.x = bound(0, pos.x, vid_conwidth - mySize.x);
353 pos.y = bound(0, pos.y, vid_conheight - mySize.y);
356 s = strcat(ftos(pos.x/vid_conwidth), " ", ftos(pos.y/vid_conheight));
358 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_pos"), s);
361 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
362 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
365 float ratio = mySize.x/mySize.y;
367 for (i = 0; i < hud_panels_COUNT; ++i) {
368 panel = hud_panels_from(i);
369 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
370 if(panel == highlightedPanel) continue;
371 HUD_Panel_UpdatePosSize();
372 if(!panel_enabled) continue;
374 panel_pos -= '1 1 0' * panel_bg_border;
375 panel_size += '2 2 0' * panel_bg_border;
377 targEndPos = panel_pos + panel_size;
379 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
380 if(resizeorigin.x > panel_pos.x && resizeorigin.x < targEndPos.x && resizeorigin.y > panel_pos.y && resizeorigin.y < targEndPos.y)
383 if (resizeCorner == 1)
385 // check if this panel is on our way
386 if (resizeorigin.x <= panel_pos.x)
388 if (resizeorigin.y <= panel_pos.y)
390 if (targEndPos.x <= resizeorigin.x - mySize.x)
392 if (targEndPos.y <= resizeorigin.y - mySize.y)
395 // there is a collision:
396 // detect which side of the panel we are facing is actually limiting the resizing
397 // (which side the resize direction finds for first) and reduce the size up to there
399 // dist is the distance between resizeorigin and the "analogous" point of the panel
400 // in this case between resizeorigin (bottom-right point) and the bottom-right point of the panel
401 dist.x = resizeorigin.x - targEndPos.x;
402 dist.y = resizeorigin.y - targEndPos.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 == 2)
410 if (resizeorigin.x >= targEndPos.x)
412 if (resizeorigin.y <= panel_pos.y)
414 if (panel_pos.x >= resizeorigin.x + mySize.x)
416 if (targEndPos.y <= resizeorigin.y - mySize.y)
419 dist.x = panel_pos.x - resizeorigin.x;
420 dist.y = resizeorigin.y - targEndPos.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 else if (resizeCorner == 3)
428 if (resizeorigin.x <= panel_pos.x)
430 if (resizeorigin.y >= targEndPos.y)
432 if (targEndPos.x <= resizeorigin.x - mySize.x)
434 if (panel_pos.y >= resizeorigin.y + mySize.y)
437 dist.x = resizeorigin.x - targEndPos.x;
438 dist.y = panel_pos.y - resizeorigin.y;
439 if (dist.y <= 0 || dist.x / dist.y > ratio)
440 mySize.x = min(mySize.x, dist.x);
442 mySize.y = min(mySize.y, dist.y);
444 else if (resizeCorner == 4)
446 if (resizeorigin.x >= targEndPos.x)
448 if (resizeorigin.y >= targEndPos.y)
450 if (panel_pos.x >= resizeorigin.x + mySize.x)
452 if (panel_pos.y >= resizeorigin.y + mySize.y)
455 dist.x = panel_pos.x - resizeorigin.x;
456 dist.y = panel_pos.y - resizeorigin.y;
457 if (dist.y <= 0 || dist.x / dist.y > ratio)
458 mySize.x = min(mySize.x, dist.x);
460 mySize.y = min(mySize.y, dist.y);
462 //if(cvar("hud_configure_checkcollisions_debug"))
463 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
469 void HUD_Panel_SetPosSize(vector mySize)
471 panel = highlightedPanel;
472 HUD_Panel_UpdatePosSize();
473 vector resizeorigin = panel_click_resizeorigin;
476 // minimum panel size cap
477 mySize.x = max(0.025 * vid_conwidth, mySize.x);
478 mySize.y = max(0.025 * vid_conheight, mySize.y);
480 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.
482 mySize.x = max(17 * autocvar_con_chatsize, mySize.x);
483 mySize.y = max(2 * autocvar_con_chatsize + 2 * panel_bg_padding, mySize.y);
486 // collision testing|
487 // -----------------+
489 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
490 if(resizeCorner == 1) {
491 myPos.x = resizeorigin.x - mySize.x;
492 myPos.y = resizeorigin.y - mySize.y;
493 } else if(resizeCorner == 2) {
494 myPos.x = resizeorigin.x;
495 myPos.y = resizeorigin.y - mySize.y;
496 } else if(resizeCorner == 3) {
497 myPos.x = resizeorigin.x - mySize.x;
498 myPos.y = resizeorigin.y;
499 } else { // resizeCorner == 4
500 myPos.x = resizeorigin.x;
501 myPos.y = resizeorigin.y;
504 // left/top screen edges
506 mySize.x = mySize.x + myPos.x;
508 mySize.y = mySize.y + myPos.y;
510 // bottom/right screen edges
511 if(myPos.x + mySize.x > vid_conwidth)
512 mySize.x = vid_conwidth - myPos.x;
513 if(myPos.y + mySize.y > vid_conheight)
514 mySize.y = vid_conheight - myPos.y;
516 //if(cvar("hud_configure_checkcollisions_debug"))
517 //drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
519 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
520 if(autocvar_hud_configure_grid)
522 mySize.x = floor((mySize.x/vid_conwidth)/hud_configure_gridSize.x + 0.5) * hud_configure_realGridSize.x;
523 mySize.y = floor((mySize.y/vid_conheight)/hud_configure_gridSize.y + 0.5) * hud_configure_realGridSize.y;
526 if(hud_configure_checkcollisions)
527 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
529 // 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)
530 mySize.x = max(0.025 * vid_conwidth, mySize.x);
531 mySize.y = max(0.025 * vid_conheight, mySize.y);
533 // do another pos check, as size might have changed by now
534 if(resizeCorner == 1) {
535 myPos.x = resizeorigin.x - mySize.x;
536 myPos.y = resizeorigin.y - mySize.y;
537 } else if(resizeCorner == 2) {
538 myPos.x = resizeorigin.x;
539 myPos.y = resizeorigin.y - mySize.y;
540 } else if(resizeCorner == 3) {
541 myPos.x = resizeorigin.x - mySize.x;
542 myPos.y = resizeorigin.y;
543 } else { // resizeCorner == 4
544 myPos.x = resizeorigin.x;
545 myPos.y = resizeorigin.y;
548 //if(cvar("hud_configure_checkcollisions_debug"))
549 //drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
552 s = strcat(ftos(mySize.x/vid_conwidth), " ", ftos(mySize.y/vid_conheight));
553 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_size"), s);
555 s = strcat(ftos(myPos.x/vid_conwidth), " ", ftos(myPos.y/vid_conheight));
556 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_pos"), s);
559 float pressed_key_time;
560 vector highlightedPanel_initial_pos, highlightedPanel_initial_size;
561 void HUD_Panel_Arrow_Action(float nPrimary)
563 if(!highlightedPanel)
566 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
569 if(autocvar_hud_configure_grid)
571 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
573 if (hudShiftState & S_SHIFT)
574 step = hud_configure_realGridSize.y;
576 step = 2 * hud_configure_realGridSize.y;
580 if (hudShiftState & S_SHIFT)
581 step = hud_configure_realGridSize.x;
583 step = 2 * hud_configure_realGridSize.x;
588 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
589 step = vid_conheight;
592 if (hudShiftState & S_SHIFT)
593 step = (step / 256); // more precision
595 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
598 panel = highlightedPanel;
599 HUD_Panel_UpdatePosSize();
601 highlightedPanel_initial_pos = panel_pos;
602 highlightedPanel_initial_size = panel_size;
604 if (hudShiftState & S_ALT) // resize
606 if(nPrimary == K_UPARROW)
608 else if(nPrimary == K_RIGHTARROW)
610 else if(nPrimary == K_LEFTARROW)
612 else // if(nPrimary == K_DOWNARROW)
615 // ctrl+arrow reduces the size, instead of increasing it
616 // Note that ctrl disables collisions check too, but it's fine
617 // since we don't collide with anything reducing the size
618 if (hudShiftState & S_CTRL) {
620 resizeCorner = 5 - resizeCorner;
625 panel_click_resizeorigin = panel_pos;
626 if(resizeCorner == 1) {
627 panel_click_resizeorigin += mySize;
629 } else if(resizeCorner == 2) {
630 panel_click_resizeorigin.y += mySize.y;
632 } else if(resizeCorner == 3) {
633 panel_click_resizeorigin.x += mySize.x;
635 } else { // resizeCorner == 4
638 HUD_Panel_SetPosSize(mySize);
644 if(nPrimary == K_UPARROW)
646 else if(nPrimary == K_DOWNARROW)
648 else if(nPrimary == K_LEFTARROW)
650 else // if(nPrimary == K_RIGHTARROW)
653 HUD_Panel_SetPos(pos);
656 panel = highlightedPanel;
657 HUD_Panel_UpdatePosSize();
659 if (highlightedPanel_initial_pos != panel_pos || highlightedPanel_initial_size != panel_size)
662 panel_pos_backup = highlightedPanel_initial_pos;
663 panel_size_backup = highlightedPanel_initial_size;
664 highlightedPanel_backup = highlightedPanel;
668 entity tab_panels[hud_panels_MAX];
670 vector tab_panel_pos;
672 void reset_tab_panels()
674 for (int i = 0; i < hud_panels_COUNT; ++i)
675 tab_panels[i] = NULL;
677 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
684 if(!autocvar__hud_configure)
689 mousepos.x = nPrimary;
690 mousepos.y = nSecondary;
694 // block any input while a menu dialog is fading
695 // don't block mousepos read as it leads to cursor jumps in the interaction with the menu
696 if(autocvar__menu_alpha)
703 // allow console bind to work
704 string con_keys = findkeysforcommand("toggleconsole", 0);
705 int keys = tokenize(con_keys); // findkeysforcommand returns data for this
707 bool hit_con_bind = false;
709 for (i = 0; i < keys; ++i)
711 if(nPrimary == stof(argv(i)))
715 if(bInputType == 0) {
716 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
717 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
718 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
720 else if(bInputType == 1) {
721 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
722 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
723 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
726 if(nPrimary == K_CTRL)
728 if (bInputType == 1) //ctrl has been released
732 //switch to selected panel
733 highlightedPanel = tab_panel;
734 highlightedAction = 0;
735 HUD_Panel_FirstInDrawQ(highlightedPanel.panel_id);
742 if(nPrimary == K_MOUSE1)
744 if(bInputType == 0) // key pressed
745 mouseClicked |= S_MOUSE1;
746 else if(bInputType == 1) // key released
747 mouseClicked -= (mouseClicked & S_MOUSE1);
749 else if(nPrimary == K_MOUSE2)
751 if(bInputType == 0) // key pressed
752 mouseClicked |= S_MOUSE2;
753 else if(bInputType == 1) // key released
754 mouseClicked -= (mouseClicked & S_MOUSE2);
756 else if(nPrimary == K_ESCAPE)
760 hud_configure_menu_open = 1;
761 localcmd("menu_showhudexit\n");
763 else if(nPrimary == K_BACKSPACE && hudShiftState & S_CTRL)
767 if (!hud_configure_menu_open)
768 HUD_Configure_Exit_Force();
770 else if(nPrimary == K_TAB && hudShiftState & S_CTRL) // switch panel
772 if (bInputType == 1 || mouseClicked)
775 // FIXME minor bug: if a panel is highlighted, has the same pos_x and
776 // lays in the same level of another panel then the next consecutive
777 // CTRL TAB presses will reselect once more the highlighted panel
779 entity starting_panel;
780 entity old_tab_panel = tab_panel;
781 if (!tab_panel) //first press of TAB
783 if (highlightedPanel)
785 panel = highlightedPanel;
786 HUD_Panel_UpdatePosSize();
790 starting_panel = highlightedPanel;
791 tab_panel_pos = panel_pos; //to compute level
795 if ( ((!tab_backward) && (hudShiftState & S_SHIFT)) || (tab_backward && !(hudShiftState & S_SHIFT)) ) //tab direction changed?
797 starting_panel = tab_panel;
799 tab_backward = (hudShiftState & S_SHIFT);
801 float k, level = 0, start_posX;
802 vector candidate_pos = '0 0 0';
803 const float LEVELS_NUM = 4;
804 float level_height = vid_conheight / LEVELS_NUM;
805 LABEL(find_tab_panel)
806 level = floor(tab_panel_pos.y / level_height) * level_height; //starting level
807 candidate_pos.x = (!tab_backward) ? vid_conwidth : 0;
808 start_posX = tab_panel_pos.x;
813 for(i = 0; i < hud_panels_COUNT; ++i)
815 panel = hud_panels_from(i);
816 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN))
818 if (panel == tab_panels[i] || panel == starting_panel)
820 HUD_Panel_UpdatePosSize();
821 if (panel_pos.y >= level && (panel_pos.y - level) < level_height)
822 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)) )
823 || ( 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)) ) )
826 tab_panel_pos = candidate_pos = panel_pos;
831 if (k == LEVELS_NUM) //tab_panel not found
839 starting_panel = old_tab_panel;
840 old_tab_panel = NULL;
841 goto find_tab_panel; //u must find tab_panel!
845 level = (level + level_height) % vid_conheight;
847 candidate_pos.x = vid_conwidth;
851 level = (level - level_height) % vid_conheight;
852 start_posX = vid_conwidth;
857 tab_panels[tab_panel.panel_id] = tab_panel;
859 else if(nPrimary == K_SPACE && hudShiftState & S_CTRL) // enable/disable highlighted panel or dock
861 if (bInputType == 1 || mouseClicked)
864 if (highlightedPanel)
866 if(panel.panel_configflags & PANEL_CONFIG_CANBEOFF)
867 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name), ftos(!cvar(strcat("hud_panel_", highlightedPanel.panel_name))));
870 cvar_set(strcat("hud_dock"), (autocvar_hud_dock == "") ? "dock" : "");
872 else if(nPrimary == 'c' && hudShiftState & S_CTRL) // copy highlighted panel size
874 if (bInputType == 1 || mouseClicked)
877 if (highlightedPanel)
879 panel = highlightedPanel;
880 HUD_Panel_UpdatePosSize();
881 panel_size_copied = panel_size;
884 else if(nPrimary == 'v' && hudShiftState & S_CTRL) // past copied size on the highlighted panel
886 if (bInputType == 1 || mouseClicked)
889 if (panel_size_copied == '0 0 0' || !highlightedPanel)
892 panel = highlightedPanel;
893 HUD_Panel_UpdatePosSize();
895 // reduce size if it'd go beyond screen boundaries
896 vector tmp_size = panel_size_copied;
897 if (panel_pos.x + panel_size_copied.x > vid_conwidth)
898 tmp_size.x = vid_conwidth - panel_pos.x;
899 if (panel_pos.y + panel_size_copied.y > vid_conheight)
900 tmp_size.y = vid_conheight - panel_pos.y;
902 if (panel_size == tmp_size)
906 panel_pos_backup = panel_pos;
907 panel_size_backup = panel_size;
908 highlightedPanel_backup = highlightedPanel;
910 s = strcat(ftos(tmp_size.x/vid_conwidth), " ", ftos(tmp_size.y/vid_conheight));
911 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_size"), s);
913 else if(nPrimary == 'z' && hudShiftState & S_CTRL) // undo last action
915 if (bInputType == 1 || mouseClicked)
917 //restore previous values
918 if (highlightedPanel_backup)
920 s = strcat(ftos(panel_pos_backup.x/vid_conwidth), " ", ftos(panel_pos_backup.y/vid_conheight));
921 cvar_set(strcat("hud_panel_", highlightedPanel_backup.panel_name, "_pos"), s);
922 s = strcat(ftos(panel_size_backup.x/vid_conwidth), " ", ftos(panel_size_backup.y/vid_conheight));
923 cvar_set(strcat("hud_panel_", highlightedPanel_backup.panel_name, "_size"), s);
924 highlightedPanel_backup = NULL;
927 else if(nPrimary == 's' && hudShiftState & S_CTRL) // save config
929 if (bInputType == 1 || mouseClicked)
931 localcmd("hud save myconfig\n");
933 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
937 pressed_key_time = 0;
940 else if (pressed_key_time == 0)
941 pressed_key_time = time;
944 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
946 else if(nPrimary == K_ENTER || nPrimary == K_SPACE || nPrimary == K_KP_ENTER)
950 if (highlightedPanel)
951 HUD_Panel_EnableMenu();
953 else if(hit_con_bind || nPrimary == K_PAUSE)
959 int HUD_Panel_Check_Mouse_Pos(bool allow_move)
962 while(j < hud_panels_COUNT)
967 panel = hud_panels_from(i);
968 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
969 HUD_Panel_UpdatePosSize();
971 float border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
974 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)
978 // resize from topleft border
979 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)
981 return CURSOR_RESIZE;
983 // resize from topright border
984 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)
986 return CURSOR_RESIZE2;
988 // resize from bottomleft border
989 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)
991 return CURSOR_RESIZE2;
993 // resize from bottomright border
994 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)
996 return CURSOR_RESIZE;
999 return CURSOR_NORMAL;
1002 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
1003 void HUD_Panel_FirstInDrawQ(float id)
1007 // find out where in the array our current id is, save into place
1008 for(i = 0; i < hud_panels_COUNT; ++i)
1010 if(panel_order[i] == id)
1016 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1018 place = hud_panels_COUNT - 1;
1020 // move all ids up by one step in the array until "place"
1021 for(i = place; i > 0; --i)
1023 panel_order[i] = panel_order[i-1];
1025 // now save the new top id
1026 panel_order[0] = id;
1028 // let's save them into the cvar by some strcat trickery
1030 for(i = 0; i < hud_panels_COUNT; ++i)
1032 s = strcat(s, ftos(panel_order[i]), " ");
1034 cvar_set("_hud_panelorder", s);
1035 strcpy(hud_panelorder_prev, autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1038 void HUD_Panel_Highlight(float allow_move)
1042 while(j < hud_panels_COUNT)
1047 panel = hud_panels_from(i);
1048 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN))
1050 HUD_Panel_UpdatePosSize();
1052 float border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1055 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)
1057 highlightedPanel = hud_panels_from(i);
1058 HUD_Panel_FirstInDrawQ(i);
1059 highlightedAction = 1;
1060 panel_click_distance = mousepos - panel_pos;
1063 // resize from topleft border
1064 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)
1066 highlightedPanel = hud_panels_from(i);
1067 HUD_Panel_FirstInDrawQ(i);
1068 highlightedAction = 2;
1070 panel_click_distance = mousepos - panel_pos;
1071 panel_click_resizeorigin = panel_pos + panel_size;
1074 // resize from topright border
1075 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)
1077 highlightedPanel = hud_panels_from(i);
1078 HUD_Panel_FirstInDrawQ(i);
1079 highlightedAction = 2;
1081 panel_click_distance.x = panel_size.x - mousepos.x + panel_pos.x;
1082 panel_click_distance.y = mousepos.y - panel_pos.y;
1083 panel_click_resizeorigin = panel_pos + eY * panel_size.y;
1086 // resize from bottomleft border
1087 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)
1089 highlightedPanel = hud_panels_from(i);
1090 HUD_Panel_FirstInDrawQ(i);
1091 highlightedAction = 2;
1093 panel_click_distance.x = mousepos.x - panel_pos.x;
1094 panel_click_distance.y = panel_size.y - mousepos.y + panel_pos.y;
1095 panel_click_resizeorigin = panel_pos + eX * panel_size.x;
1098 // resize from bottomright border
1099 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)
1101 highlightedPanel = hud_panels_from(i);
1102 HUD_Panel_FirstInDrawQ(i);
1103 highlightedAction = 2;
1105 panel_click_distance = panel_size - mousepos + panel_pos;
1106 panel_click_resizeorigin = panel_pos;
1110 highlightedPanel = NULL;
1111 highlightedAction = 0;
1114 void HUD_Panel_EnableMenu()
1116 hud_configure_menu_open = 2;
1117 localcmd("menu_showhudoptions ", highlightedPanel.panel_name, "\n");
1119 void HUD_Panel_Mouse()
1121 if(autocvar__menu_alpha == 1)
1126 if(prevMouseClicked == 0)
1130 //stop ctrl-tab selection
1134 HUD_Panel_Highlight(mouseClicked & S_MOUSE1); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1135 // and calls HUD_Panel_UpdatePosSize() for the highlighted panel
1136 if (highlightedPanel)
1138 highlightedPanel_initial_pos = panel_pos;
1139 highlightedPanel_initial_size = panel_size;
1141 // doubleclick check
1142 if ((mouseClicked & S_MOUSE1) && time - prevMouseClickedTime < 0.4 && highlightedPanel && prevMouseClickedPos == mousepos)
1144 mouseClicked = 0; // to prevent spam, I guess.
1145 HUD_Panel_EnableMenu();
1149 if (mouseClicked & S_MOUSE1)
1151 prevMouseClickedTime = time;
1152 prevMouseClickedPos = mousepos;
1154 cursor_type = HUD_Panel_Check_Mouse_Pos(mouseClicked & S_MOUSE1);
1159 panel = highlightedPanel;
1160 HUD_Panel_UpdatePosSize();
1163 if (highlightedPanel)
1165 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .1, DRAWFLAG_NORMAL);
1166 if (highlightedPanel_initial_pos != panel_pos || highlightedPanel_initial_size != panel_size)
1168 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1170 panel_pos_backup = highlightedPanel_initial_pos;
1171 panel_size_backup = highlightedPanel_initial_size;
1172 highlightedPanel_backup = highlightedPanel;
1175 // in case the clicked panel is inside another panel and we aren't
1176 // moving it, avoid the immediate "fix" of its position/size
1177 // (often unwanted and hateful) by disabling collisions check
1178 hud_configure_checkcollisions = false;
1181 if(highlightedAction == 1)
1182 HUD_Panel_SetPos(mousepos - panel_click_distance);
1183 else if(highlightedAction == 2)
1185 vector mySize = '0 0 0';
1186 if(resizeCorner == 1) {
1187 mySize.x = panel_click_resizeorigin.x - (mousepos.x - panel_click_distance.x);
1188 mySize.y = panel_click_resizeorigin.y - (mousepos.y - panel_click_distance.y);
1189 } else if(resizeCorner == 2) {
1190 mySize.x = mousepos.x + panel_click_distance.x - panel_click_resizeorigin.x;
1191 mySize.y = panel_click_distance.y + panel_click_resizeorigin.y - mousepos.y;
1192 } else if(resizeCorner == 3) {
1193 mySize.x = panel_click_resizeorigin.x + panel_click_distance.x - mousepos.x;
1194 mySize.y = mousepos.y + panel_click_distance.y - panel_click_resizeorigin.y;
1195 } else { // resizeCorner == 4
1196 mySize.x = mousepos.x - (panel_click_resizeorigin.x - panel_click_distance.x);
1197 mySize.y = mousepos.y - (panel_click_resizeorigin.y - panel_click_distance.y);
1199 HUD_Panel_SetPosSize(mySize);
1204 if(prevMouseClicked)
1205 highlightedAction = 0;
1206 if(hud_configure_menu_open == 2)
1207 cursor_type = CURSOR_NORMAL;
1209 cursor_type = HUD_Panel_Check_Mouse_Pos(true);
1210 if (cursor_type != CURSOR_NORMAL && !tab_panel) // mouse over a panel?
1211 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .1, DRAWFLAG_NORMAL);
1214 void HUD_Configure_DrawGrid()
1217 if(autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
1219 hud_configure_gridSize.x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
1220 hud_configure_gridSize.y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
1221 hud_configure_realGridSize.x = hud_configure_gridSize.x * vid_conwidth;
1222 hud_configure_realGridSize.y = hud_configure_gridSize.y * vid_conheight;
1225 s = vec2(1, vid_conheight);
1226 for(i = 1; i < 1/hud_configure_gridSize.x; ++i)
1227 drawfill(eX * i * hud_configure_realGridSize.x, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
1229 s = vec2(vid_conwidth, 1);
1230 for(i = 1; i < 1/hud_configure_gridSize.y; ++i)
1231 drawfill(eY * i * hud_configure_realGridSize.y, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
1235 float _menu_alpha_prev;
1236 void HUD_Configure_Frame()
1239 if(autocvar__hud_configure)
1241 if(isdemo() || intermission == 2 || scoreboard_active)
1243 HUD_Configure_Exit_Force();
1247 if(!hud_configure_prev)
1250 for(i = hud_panels_COUNT - 1; i >= 0; --i)
1251 hud_panels_from(panel_order[i]).update_time = time;
1254 // NOTE this check is necessary because _menu_alpha isn't updated the frame the menu gets enabled
1255 if(autocvar__menu_alpha != _menu_alpha_prev)
1257 if(autocvar__menu_alpha == 0)
1258 hud_configure_menu_open = 0;
1259 _menu_alpha_prev = autocvar__menu_alpha;
1262 HUD_Configure_DrawGrid();
1264 else if(hud_configure_prev)
1266 if(hud_configure_menu_open)
1267 hud_configure_menu_open = 0;
1268 hud_dynamic_shake_factor = -1;
1272 const float hlBorderSize = 2;
1273 const string hlBorder = "gfx/hud/default/border_highlighted";
1274 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
1275 void HUD_Panel_HlBorder(float myBorder, vector color, float theAlpha)
1277 vector pos = panel_pos - vec2(myBorder, myBorder);
1278 drawfill(pos, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * theAlpha, DRAWFLAG_NORMAL);
1279 drawpic_tiled(pos, hlBorder, '8 1 0' * hlBorderSize, vec2(panel_size.x + 2 * myBorder, hlBorderSize), color, theAlpha, DRAWFLAG_NORMAL);
1280 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);
1281 pos.y += hlBorderSize;
1282 drawpic_tiled(pos, hlBorder2, '1 8 0' * hlBorderSize, vec2(hlBorderSize, panel_size.y + 2 * myBorder - 2 * hlBorderSize), color, theAlpha, DRAWFLAG_NORMAL);
1283 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);
1286 void HUD_Configure_PostDraw()
1288 if(autocvar__hud_configure)
1293 HUD_Panel_UpdatePosSize();
1294 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
1296 if(highlightedPanel)
1298 panel = highlightedPanel;
1299 HUD_Panel_UpdatePosSize();
1300 HUD_Panel_HlBorder(panel_bg_border * hlBorderSize, '0 0.5 1', 0.4 * (1 - autocvar__menu_alpha));