1 #include "hud_config.qh"
4 #include "panel/scoreboard.qh"
6 #define HUD_Write(s) fputs(fh, s)
7 #define HUD_Write_Cvar(cvar) HUD_Write(strcat("seta ", cvar, " \"", cvar_string(cvar), "\"\n"))
8 #define HUD_Write_PanelCvar(cvar_suf) str = strcat("hud_panel_", panel.panel_name, cvar_suf), HUD_Write_Cvar(str)
10 void HUD_Panel_ExportCfg(string cfgname)
13 string filename = strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg");
15 fh = fopen(filename, FILE_WRITE);
18 HUD_Write("//title \n");
19 HUD_Write("//author \n");
21 HUD_Write_Cvar("hud_skin");
22 HUD_Write_Cvar("hud_panel_bg");
23 HUD_Write_Cvar("hud_panel_bg_color");
24 HUD_Write_Cvar("hud_panel_bg_color_team");
25 HUD_Write_Cvar("hud_panel_bg_alpha");
26 HUD_Write_Cvar("hud_panel_bg_border");
27 HUD_Write_Cvar("hud_panel_bg_padding");
28 HUD_Write_Cvar("hud_panel_fg_alpha");
31 HUD_Write_Cvar("hud_dock");
32 HUD_Write_Cvar("hud_dock_color");
33 HUD_Write_Cvar("hud_dock_color_team");
34 HUD_Write_Cvar("hud_dock_alpha");
37 HUD_Write_Cvar("hud_progressbar_alpha");
38 HUD_Write_Cvar("hud_progressbar_strength_color");
39 HUD_Write_Cvar("hud_progressbar_superweapons_color");
40 HUD_Write_Cvar("hud_progressbar_shield_color");
41 HUD_Write_Cvar("hud_progressbar_health_color");
42 HUD_Write_Cvar("hud_progressbar_armor_color");
43 HUD_Write_Cvar("hud_progressbar_fuel_color");
44 HUD_Write_Cvar("hud_progressbar_nexball_color");
45 HUD_Write_Cvar("hud_progressbar_speed_color");
46 HUD_Write_Cvar("hud_progressbar_acceleration_color");
47 HUD_Write_Cvar("hud_progressbar_acceleration_neg_color");
48 HUD_Write_Cvar("hud_progressbar_vehicles_ammo1_color");
49 HUD_Write_Cvar("hud_progressbar_vehicles_ammo2_color");
52 HUD_Write_Cvar("_hud_panelorder");
55 HUD_Write_Cvar("hud_configure_grid");
56 HUD_Write_Cvar("hud_configure_grid_xsize");
57 HUD_Write_Cvar("hud_configure_grid_ysize");
60 // common cvars for all panels
61 for (int i = 0; i < hud_panels_COUNT; ++i)
63 panel = hud_panels_from(i);
65 HUD_Write_PanelCvar("_pos");
66 HUD_Write_PanelCvar("_size");
67 HUD_Write_PanelCvar("_bg");
68 HUD_Write_PanelCvar("_bg_color");
69 HUD_Write_PanelCvar("_bg_color_team");
70 HUD_Write_PanelCvar("_bg_alpha");
71 HUD_Write_PanelCvar("_bg_border");
72 HUD_Write_PanelCvar("_bg_padding");
74 case HUD_PANEL_WEAPONS:
75 HUD_Write_Cvar("hud_panel_weapons_accuracy");
76 HUD_Write_Cvar("hud_panel_weapons_label");
77 HUD_Write_Cvar("hud_panel_weapons_label_scale");
78 HUD_Write_Cvar("hud_panel_weapons_complainbubble");
79 HUD_Write_Cvar("hud_panel_weapons_complainbubble_padding");
80 HUD_Write_Cvar("hud_panel_weapons_complainbubble_time");
81 HUD_Write_Cvar("hud_panel_weapons_complainbubble_fadetime");
82 HUD_Write_Cvar("hud_panel_weapons_complainbubble_color_outofammo");
83 HUD_Write_Cvar("hud_panel_weapons_complainbubble_color_donthave");
84 HUD_Write_Cvar("hud_panel_weapons_complainbubble_color_unavailable");
85 HUD_Write_Cvar("hud_panel_weapons_ammo");
86 HUD_Write_Cvar("hud_panel_weapons_ammo_color");
87 HUD_Write_Cvar("hud_panel_weapons_ammo_alpha");
88 HUD_Write_Cvar("hud_panel_weapons_aspect");
89 HUD_Write_Cvar("hud_panel_weapons_timeout");
90 HUD_Write_Cvar("hud_panel_weapons_timeout_effect");
91 HUD_Write_Cvar("hud_panel_weapons_timeout_fadebgmin");
92 HUD_Write_Cvar("hud_panel_weapons_timeout_fadefgmin");
93 HUD_Write_Cvar("hud_panel_weapons_timeout_speed_in");
94 HUD_Write_Cvar("hud_panel_weapons_timeout_speed_out");
95 HUD_Write_Cvar("hud_panel_weapons_onlyowned");
96 HUD_Write_Cvar("hud_panel_weapons_noncurrent_alpha");
97 HUD_Write_Cvar("hud_panel_weapons_noncurrent_scale");
100 HUD_Write_Cvar("hud_panel_ammo_onlycurrent");
101 HUD_Write_Cvar("hud_panel_ammo_noncurrent_alpha");
102 HUD_Write_Cvar("hud_panel_ammo_noncurrent_scale");
103 HUD_Write_Cvar("hud_panel_ammo_iconalign");
104 HUD_Write_Cvar("hud_panel_ammo_progressbar");
105 HUD_Write_Cvar("hud_panel_ammo_progressbar_name");
106 HUD_Write_Cvar("hud_panel_ammo_progressbar_xoffset");
107 HUD_Write_Cvar("hud_panel_ammo_text");
109 case HUD_PANEL_POWERUPS:
110 HUD_Write_Cvar("hud_panel_powerups_iconalign");
111 HUD_Write_Cvar("hud_panel_powerups_baralign");
112 HUD_Write_Cvar("hud_panel_powerups_progressbar");
113 HUD_Write_Cvar("hud_panel_powerups_text");
115 case HUD_PANEL_HEALTHARMOR:
116 HUD_Write_Cvar("hud_panel_healtharmor_flip");
117 HUD_Write_Cvar("hud_panel_healtharmor_iconalign");
118 HUD_Write_Cvar("hud_panel_healtharmor_baralign");
119 HUD_Write_Cvar("hud_panel_healtharmor_progressbar");
120 HUD_Write_Cvar("hud_panel_healtharmor_progressbar_health");
121 HUD_Write_Cvar("hud_panel_healtharmor_progressbar_armor");
122 HUD_Write_Cvar("hud_panel_healtharmor_progressbar_gfx");
123 HUD_Write_Cvar("hud_panel_healtharmor_progressbar_gfx_smooth");
124 HUD_Write_Cvar("hud_panel_healtharmor_combined");
125 HUD_Write_Cvar("hud_panel_healtharmor_text");
127 case HUD_PANEL_NOTIFY:
128 HUD_Write_Cvar("hud_panel_notify_flip");
129 HUD_Write_Cvar("hud_panel_notify_fontsize");
130 HUD_Write_Cvar("hud_panel_notify_time");
131 HUD_Write_Cvar("hud_panel_notify_fadetime");
132 HUD_Write_Cvar("hud_panel_notify_icon_aspect");
134 case HUD_PANEL_TIMER:
136 case HUD_PANEL_RADAR:
137 HUD_Write_Cvar("hud_panel_radar_foreground_alpha");
138 HUD_Write_Cvar("hud_panel_radar_rotation");
139 HUD_Write_Cvar("hud_panel_radar_zoommode");
140 HUD_Write_Cvar("hud_panel_radar_scale");
141 HUD_Write_Cvar("hud_panel_radar_maximized_scale");
142 HUD_Write_Cvar("hud_panel_radar_maximized_size");
143 HUD_Write_Cvar("hud_panel_radar_maximized_rotation");
144 HUD_Write_Cvar("hud_panel_radar_maximized_zoommode");
146 case HUD_PANEL_SCORE:
147 HUD_Write_Cvar("hud_panel_score_rankings");
150 HUD_Write_Cvar("hud_panel_vote_alreadyvoted_alpha");
152 case HUD_PANEL_MODICONS:
153 HUD_Write_Cvar("hud_panel_modicons_ca_layout");
154 HUD_Write_Cvar("hud_panel_modicons_dom_layout");
155 HUD_Write_Cvar("hud_panel_modicons_freezetag_layout");
157 case HUD_PANEL_PRESSEDKEYS:
158 HUD_Write_Cvar("hud_panel_pressedkeys_aspect");
159 HUD_Write_Cvar("hud_panel_pressedkeys_attack");
161 case HUD_PANEL_ENGINEINFO:
162 HUD_Write_Cvar("hud_panel_engineinfo_framecounter_time");
163 HUD_Write_Cvar("hud_panel_engineinfo_framecounter_decimals");
165 case HUD_PANEL_INFOMESSAGES:
166 HUD_Write_Cvar("hud_panel_infomessages_flip");
168 case HUD_PANEL_PHYSICS:
169 HUD_Write_Cvar("hud_panel_physics_speed_unit_show");
170 HUD_Write_Cvar("hud_panel_physics_speed_max");
171 HUD_Write_Cvar("hud_panel_physics_speed_vertical");
172 HUD_Write_Cvar("hud_panel_physics_topspeed");
173 HUD_Write_Cvar("hud_panel_physics_topspeed_time");
174 HUD_Write_Cvar("hud_panel_physics_acceleration_max");
175 HUD_Write_Cvar("hud_panel_physics_acceleration_vertical");
176 HUD_Write_Cvar("hud_panel_physics_flip");
177 HUD_Write_Cvar("hud_panel_physics_baralign");
178 HUD_Write_Cvar("hud_panel_physics_progressbar");
179 HUD_Write_Cvar("hud_panel_physics_acceleration_progressbar_mode");
180 HUD_Write_Cvar("hud_panel_physics_acceleration_progressbar_scale");
181 HUD_Write_Cvar("hud_panel_physics_acceleration_progressbar_nonlinear");
182 HUD_Write_Cvar("hud_panel_physics_text");
183 HUD_Write_Cvar("hud_panel_physics_text_scale");
185 case HUD_PANEL_CENTERPRINT:
186 HUD_Write_Cvar("hud_panel_centerprint_align");
187 HUD_Write_Cvar("hud_panel_centerprint_flip");
188 HUD_Write_Cvar("hud_panel_centerprint_fontscale");
189 HUD_Write_Cvar("hud_panel_centerprint_time");
190 HUD_Write_Cvar("hud_panel_centerprint_fade_in");
191 HUD_Write_Cvar("hud_panel_centerprint_fade_out");
192 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent");
193 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent_passone");
194 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent_passone_minalpha");
195 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent_passtwo");
196 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent_passtwo_minalpha");
197 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent_minfontsize");
198 HUD_Write_Cvar("hud_panel_centerprint_fade_minfontsize");
200 case HUD_PANEL_ITEMSTIME:
201 HUD_Write_Cvar("hud_panel_itemstime_iconalign");
202 HUD_Write_Cvar("hud_panel_itemstime_progressbar");
203 HUD_Write_Cvar("hud_panel_itemstime_progressbar_name");
204 HUD_Write_Cvar("hud_panel_itemstime_progressbar_reduced");
205 HUD_Write_Cvar("hud_panel_itemstime_text");
206 HUD_Write_Cvar("hud_panel_itemstime_ratio");
207 HUD_Write_Cvar("hud_panel_itemstime_dynamicsize");
209 case HUD_PANEL_QUICKMENU:
210 HUD_Write_Cvar("hud_panel_quickmenu_align");
212 case HUD_PANEL_SCOREBOARD:
213 HUD_Write_Cvar("hud_panel_scoreboard_fadeinspeed");
214 HUD_Write_Cvar("hud_panel_scoreboard_fadeoutspeed");
215 HUD_Write_Cvar("hud_panel_scoreboard_respawntime_decimals");
216 HUD_Write_Cvar("hud_panel_scoreboard_table_bg_alpha");
217 HUD_Write_Cvar("hud_panel_scoreboard_table_bg_scale");
218 HUD_Write_Cvar("hud_panel_scoreboard_table_fg_alpha");
219 HUD_Write_Cvar("hud_panel_scoreboard_table_fg_alpha_self");
220 HUD_Write_Cvar("hud_panel_scoreboard_table_highlight");
221 HUD_Write_Cvar("hud_panel_scoreboard_table_highlight_alpha");
222 HUD_Write_Cvar("hud_panel_scoreboard_table_highlight_alpha_self");
223 HUD_Write_Cvar("hud_panel_scoreboard_bg_teams_color_team");
224 HUD_Write_Cvar("hud_panel_scoreboard_accuracy_doublerows");
225 HUD_Write_Cvar("hud_panel_scoreboard_accuracy_nocolors");
230 MUTATOR_CALLHOOK(HUD_WriteCvars, fh);
232 HUD_Write("menu_sync\n"); // force the menu to reread the cvars, so that the dialogs are updated
234 LOG_INFOF(_("^2Successfully exported to %s! (Note: It's saved in data/data/)\n"), filename);
238 LOG_INFOF(_("^1Couldn't write to %s\n"), filename);
241 void HUD_Configure_Exit_Force()
243 if (hud_configure_menu_open)
245 hud_configure_menu_open = 0;
246 localcmd("togglemenu\n");
248 cvar_set("_hud_configure", "0");
251 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
252 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
254 vector myCenter, targCenter;
255 vector myTarget = myPos;
257 for (i = 0; i < hud_panels_COUNT; ++i) {
258 panel = hud_panels_from(i);
259 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
260 if(panel == highlightedPanel) continue;
261 HUD_Panel_UpdatePosSize();
262 if(!panel_enabled) continue;
264 panel_pos -= '1 1 0' * panel_bg_border;
265 panel_size += '2 2 0' * panel_bg_border;
267 if(myPos.y + mySize.y < panel_pos.y)
269 if(myPos.y > panel_pos.y + panel_size.y)
272 if(myPos.x + mySize.x < panel_pos.x)
274 if(myPos.x > panel_pos.x + panel_size.x)
277 // OK, there IS a collision.
279 myCenter.x = myPos.x + 0.5 * mySize.x;
280 myCenter.y = myPos.y + 0.5 * mySize.y;
282 targCenter.x = panel_pos.x + 0.5 * panel_size.x;
283 targCenter.y = panel_pos.y + 0.5 * panel_size.y;
285 if(myCenter.x < targCenter.x && myCenter.y < targCenter.y) // top left (of the target panel)
287 if(myPos.x + mySize.x - panel_pos.x < myPos.y + mySize.y - panel_pos.y) // push it to the side
288 myTarget.x = panel_pos.x - mySize.x;
289 else // push it upwards
290 myTarget.y = panel_pos.y - mySize.y;
292 else if(myCenter.x > targCenter.x && myCenter.y < targCenter.y) // top right
294 if(panel_pos.x + panel_size.x - myPos.x < myPos.y + mySize.y - panel_pos.y) // push it to the side
295 myTarget.x = panel_pos.x + panel_size.x;
296 else // push it upwards
297 myTarget.y = panel_pos.y - mySize.y;
299 else if(myCenter.x < targCenter.x && myCenter.y > targCenter.y) // bottom left
301 if(myPos.x + mySize.x - panel_pos.x < panel_pos.y + panel_size.y - myPos.y) // push it to the side
302 myTarget.x = panel_pos.x - mySize.x;
303 else // push it downwards
304 myTarget.y = panel_pos.y + panel_size.y;
306 else if(myCenter.x > targCenter.x && myCenter.y > targCenter.y) // bottom right
308 if(panel_pos.x + panel_size.x - myPos.x < panel_pos.y + panel_size.y - myPos.y) // push it to the side
309 myTarget.x = panel_pos.x + panel_size.x;
310 else // push it downwards
311 myTarget.y = panel_pos.y + panel_size.y;
313 //if(cvar("hud_configure_checkcollisions_debug"))
314 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
320 void HUD_Panel_SetPos(vector pos)
322 panel = highlightedPanel;
323 HUD_Panel_UpdatePosSize();
327 //if(cvar("hud_configure_checkcollisions_debug"))
328 //drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
330 if(autocvar_hud_configure_grid)
332 pos.x = floor((pos.x/vid_conwidth)/hud_configure_gridSize.x + 0.5) * hud_configure_realGridSize.x;
333 pos.y = floor((pos.y/vid_conheight)/hud_configure_gridSize.y + 0.5) * hud_configure_realGridSize.y;
336 if(hud_configure_checkcollisions)
337 pos = HUD_Panel_CheckMove(pos, mySize);
339 pos.x = bound(0, pos.x, vid_conwidth - mySize.x);
340 pos.y = bound(0, pos.y, vid_conheight - mySize.y);
343 s = strcat(ftos(pos.x/vid_conwidth), " ", ftos(pos.y/vid_conheight));
345 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_pos"), s);
348 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
349 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
352 float ratio = mySize.x/mySize.y;
354 for (i = 0; i < hud_panels_COUNT; ++i) {
355 panel = hud_panels_from(i);
356 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
357 if(panel == highlightedPanel) continue;
358 HUD_Panel_UpdatePosSize();
359 if(!panel_enabled) continue;
361 panel_pos -= '1 1 0' * panel_bg_border;
362 panel_size += '2 2 0' * panel_bg_border;
364 targEndPos = panel_pos + panel_size;
366 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
367 if(resizeorigin.x > panel_pos.x && resizeorigin.x < targEndPos.x && resizeorigin.y > panel_pos.y && resizeorigin.y < targEndPos.y)
370 if (resizeCorner == 1)
372 // check if this panel is on our way
373 if (resizeorigin.x <= panel_pos.x)
375 if (resizeorigin.y <= panel_pos.y)
377 if (targEndPos.x <= resizeorigin.x - mySize.x)
379 if (targEndPos.y <= resizeorigin.y - mySize.y)
382 // there is a collision:
383 // detect which side of the panel we are facing is actually limiting the resizing
384 // (which side the resize direction finds for first) and reduce the size up to there
386 // dist is the distance between resizeorigin and the "analogous" point of the panel
387 // in this case between resizeorigin (bottom-right point) and the bottom-right point of the panel
388 dist.x = resizeorigin.x - targEndPos.x;
389 dist.y = resizeorigin.y - targEndPos.y;
390 if (dist.y <= 0 || dist.x / dist.y > ratio)
391 mySize.x = min(mySize.x, dist.x);
393 mySize.y = min(mySize.y, dist.y);
395 else if (resizeCorner == 2)
397 if (resizeorigin.x >= targEndPos.x)
399 if (resizeorigin.y <= panel_pos.y)
401 if (panel_pos.x >= resizeorigin.x + mySize.x)
403 if (targEndPos.y <= resizeorigin.y - mySize.y)
406 dist.x = panel_pos.x - resizeorigin.x;
407 dist.y = resizeorigin.y - targEndPos.y;
408 if (dist.y <= 0 || dist.x / dist.y > ratio)
409 mySize.x = min(mySize.x, dist.x);
411 mySize.y = min(mySize.y, dist.y);
413 else if (resizeCorner == 3)
415 if (resizeorigin.x <= panel_pos.x)
417 if (resizeorigin.y >= targEndPos.y)
419 if (targEndPos.x <= resizeorigin.x - mySize.x)
421 if (panel_pos.y >= resizeorigin.y + mySize.y)
424 dist.x = resizeorigin.x - targEndPos.x;
425 dist.y = panel_pos.y - resizeorigin.y;
426 if (dist.y <= 0 || dist.x / dist.y > ratio)
427 mySize.x = min(mySize.x, dist.x);
429 mySize.y = min(mySize.y, dist.y);
431 else if (resizeCorner == 4)
433 if (resizeorigin.x >= targEndPos.x)
435 if (resizeorigin.y >= targEndPos.y)
437 if (panel_pos.x >= resizeorigin.x + mySize.x)
439 if (panel_pos.y >= resizeorigin.y + mySize.y)
442 dist.x = panel_pos.x - resizeorigin.x;
443 dist.y = panel_pos.y - resizeorigin.y;
444 if (dist.y <= 0 || dist.x / dist.y > ratio)
445 mySize.x = min(mySize.x, dist.x);
447 mySize.y = min(mySize.y, dist.y);
449 //if(cvar("hud_configure_checkcollisions_debug"))
450 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
456 void HUD_Panel_SetPosSize(vector mySize)
458 panel = highlightedPanel;
459 HUD_Panel_UpdatePosSize();
460 vector resizeorigin = panel_click_resizeorigin;
463 // minimum panel size cap
464 mySize.x = max(0.025 * vid_conwidth, mySize.x);
465 mySize.y = max(0.025 * vid_conheight, mySize.y);
467 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.
469 mySize.x = max(17 * autocvar_con_chatsize, mySize.x);
470 mySize.y = max(2 * autocvar_con_chatsize + 2 * panel_bg_padding, mySize.y);
473 // collision testing|
474 // -----------------+
476 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
477 if(resizeCorner == 1) {
478 myPos.x = resizeorigin.x - mySize.x;
479 myPos.y = resizeorigin.y - mySize.y;
480 } else if(resizeCorner == 2) {
481 myPos.x = resizeorigin.x;
482 myPos.y = resizeorigin.y - mySize.y;
483 } else if(resizeCorner == 3) {
484 myPos.x = resizeorigin.x - mySize.x;
485 myPos.y = resizeorigin.y;
486 } else { // resizeCorner == 4
487 myPos.x = resizeorigin.x;
488 myPos.y = resizeorigin.y;
491 // left/top screen edges
493 mySize.x = mySize.x + myPos.x;
495 mySize.y = mySize.y + myPos.y;
497 // bottom/right screen edges
498 if(myPos.x + mySize.x > vid_conwidth)
499 mySize.x = vid_conwidth - myPos.x;
500 if(myPos.y + mySize.y > vid_conheight)
501 mySize.y = vid_conheight - myPos.y;
503 //if(cvar("hud_configure_checkcollisions_debug"))
504 //drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
506 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
507 if(autocvar_hud_configure_grid)
509 mySize.x = floor((mySize.x/vid_conwidth)/hud_configure_gridSize.x + 0.5) * hud_configure_realGridSize.x;
510 mySize.y = floor((mySize.y/vid_conheight)/hud_configure_gridSize.y + 0.5) * hud_configure_realGridSize.y;
513 if(hud_configure_checkcollisions)
514 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
516 // 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)
517 mySize.x = max(0.025 * vid_conwidth, mySize.x);
518 mySize.y = max(0.025 * vid_conheight, mySize.y);
520 // do another pos check, as size might have changed by now
521 if(resizeCorner == 1) {
522 myPos.x = resizeorigin.x - mySize.x;
523 myPos.y = resizeorigin.y - mySize.y;
524 } else if(resizeCorner == 2) {
525 myPos.x = resizeorigin.x;
526 myPos.y = resizeorigin.y - mySize.y;
527 } else if(resizeCorner == 3) {
528 myPos.x = resizeorigin.x - mySize.x;
529 myPos.y = resizeorigin.y;
530 } else { // resizeCorner == 4
531 myPos.x = resizeorigin.x;
532 myPos.y = resizeorigin.y;
535 //if(cvar("hud_configure_checkcollisions_debug"))
536 //drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
539 s = strcat(ftos(mySize.x/vid_conwidth), " ", ftos(mySize.y/vid_conheight));
540 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_size"), s);
542 s = strcat(ftos(myPos.x/vid_conwidth), " ", ftos(myPos.y/vid_conheight));
543 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_pos"), s);
546 float pressed_key_time;
547 vector highlightedPanel_initial_pos, highlightedPanel_initial_size;
548 void HUD_Panel_Arrow_Action(float nPrimary)
550 if(!highlightedPanel)
553 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
556 if(autocvar_hud_configure_grid)
558 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
560 if (hudShiftState & S_SHIFT)
561 step = hud_configure_realGridSize.y;
563 step = 2 * hud_configure_realGridSize.y;
567 if (hudShiftState & S_SHIFT)
568 step = hud_configure_realGridSize.x;
570 step = 2 * hud_configure_realGridSize.x;
575 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
576 step = vid_conheight;
579 if (hudShiftState & S_SHIFT)
580 step = (step / 256); // more precision
582 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
585 panel = highlightedPanel;
586 HUD_Panel_UpdatePosSize();
588 highlightedPanel_initial_pos = panel_pos;
589 highlightedPanel_initial_size = panel_size;
591 if (hudShiftState & S_ALT) // resize
593 if(nPrimary == K_UPARROW)
595 else if(nPrimary == K_RIGHTARROW)
597 else if(nPrimary == K_LEFTARROW)
599 else // if(nPrimary == K_DOWNARROW)
602 // ctrl+arrow reduces the size, instead of increasing it
603 // Note that ctrl disables collisions check too, but it's fine
604 // since we don't collide with anything reducing the size
605 if (hudShiftState & S_CTRL) {
607 resizeCorner = 5 - resizeCorner;
612 panel_click_resizeorigin = panel_pos;
613 if(resizeCorner == 1) {
614 panel_click_resizeorigin += mySize;
616 } else if(resizeCorner == 2) {
617 panel_click_resizeorigin.y += mySize.y;
619 } else if(resizeCorner == 3) {
620 panel_click_resizeorigin.x += mySize.x;
622 } else { // resizeCorner == 4
625 HUD_Panel_SetPosSize(mySize);
631 if(nPrimary == K_UPARROW)
633 else if(nPrimary == K_DOWNARROW)
635 else if(nPrimary == K_LEFTARROW)
637 else // if(nPrimary == K_RIGHTARROW)
640 HUD_Panel_SetPos(pos);
643 panel = highlightedPanel;
644 HUD_Panel_UpdatePosSize();
646 if (highlightedPanel_initial_pos != panel_pos || highlightedPanel_initial_size != panel_size)
649 panel_pos_backup = highlightedPanel_initial_pos;
650 panel_size_backup = highlightedPanel_initial_size;
651 highlightedPanel_backup = highlightedPanel;
655 void HUD_Panel_EnableMenu();
656 entity tab_panels[hud_panels_MAX];
658 vector tab_panel_pos;
660 void HUD_Panel_FirstInDrawQ(float id);
661 void reset_tab_panels()
663 for (int i = 0; i < hud_panels_COUNT; ++i)
664 tab_panels[i] = NULL;
666 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
673 if(!autocvar__hud_configure)
678 mousepos.x = nPrimary;
679 mousepos.y = nSecondary;
683 // block any input while a menu dialog is fading
684 // don't block mousepos read as it leads to cursor jumps in the interaction with the menu
685 if(autocvar__menu_alpha)
692 // allow console bind to work
693 string con_keys = findkeysforcommand("toggleconsole", 0);
694 int keys = tokenize(con_keys); // findkeysforcommand returns data for this
696 bool hit_con_bind = false;
698 for (i = 0; i < keys; ++i)
700 if(nPrimary == stof(argv(i)))
704 if(bInputType == 0) {
705 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
706 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
707 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
709 else if(bInputType == 1) {
710 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
711 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
712 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
715 if(nPrimary == K_CTRL)
717 if (bInputType == 1) //ctrl has been released
721 //switch to selected panel
722 highlightedPanel = tab_panel;
723 highlightedAction = 0;
724 HUD_Panel_FirstInDrawQ(highlightedPanel.panel_id);
731 if(nPrimary == K_MOUSE1)
733 if(bInputType == 0) // key pressed
734 mouseClicked |= S_MOUSE1;
735 else if(bInputType == 1) // key released
736 mouseClicked -= (mouseClicked & S_MOUSE1);
738 else if(nPrimary == K_MOUSE2)
740 if(bInputType == 0) // key pressed
741 mouseClicked |= S_MOUSE2;
742 else if(bInputType == 1) // key released
743 mouseClicked -= (mouseClicked & S_MOUSE2);
745 else if(nPrimary == K_ESCAPE)
749 hud_configure_menu_open = 1;
750 localcmd("menu_showhudexit\n");
752 else if(nPrimary == K_BACKSPACE && hudShiftState & S_CTRL)
756 if (!hud_configure_menu_open)
757 cvar_set("_hud_configure", "0");
759 else if(nPrimary == K_TAB && hudShiftState & S_CTRL) // switch panel
761 if (bInputType == 1 || mouseClicked)
764 // FIXME minor bug: if a panel is highlighted, has the same pos_x and
765 // lays in the same level of another panel then the next consecutive
766 // CTRL TAB presses will reselect once more the highlighted panel
768 entity starting_panel;
769 entity old_tab_panel = tab_panel;
770 if (!tab_panel) //first press of TAB
772 if (highlightedPanel)
774 panel = highlightedPanel;
775 HUD_Panel_UpdatePosSize();
779 starting_panel = highlightedPanel;
780 tab_panel_pos = panel_pos; //to compute level
784 if ( ((!tab_backward) && (hudShiftState & S_SHIFT)) || (tab_backward && !(hudShiftState & S_SHIFT)) ) //tab direction changed?
786 starting_panel = tab_panel;
788 tab_backward = (hudShiftState & S_SHIFT);
790 float k, level = 0, start_posX;
791 vector candidate_pos = '0 0 0';
792 const float LEVELS_NUM = 4;
793 float level_height = vid_conheight / LEVELS_NUM;
794 LABEL(find_tab_panel)
795 level = floor(tab_panel_pos.y / level_height) * level_height; //starting level
796 candidate_pos.x = (!tab_backward) ? vid_conwidth : 0;
797 start_posX = tab_panel_pos.x;
802 for(i = 0; i < hud_panels_COUNT; ++i)
804 panel = hud_panels_from(i);
805 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN))
807 if (panel == tab_panels[i] || panel == starting_panel)
809 HUD_Panel_UpdatePosSize();
810 if (panel_pos.y >= level && (panel_pos.y - level) < level_height)
811 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)) )
812 || ( 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)) ) )
815 tab_panel_pos = candidate_pos = panel_pos;
820 if (k == LEVELS_NUM) //tab_panel not found
828 starting_panel = old_tab_panel;
829 old_tab_panel = NULL;
830 goto find_tab_panel; //u must find tab_panel!
834 level = (level + level_height) % vid_conheight;
836 candidate_pos.x = vid_conwidth;
840 level = (level - level_height) % vid_conheight;
841 start_posX = vid_conwidth;
846 tab_panels[tab_panel.panel_id] = tab_panel;
848 else if(nPrimary == K_SPACE && hudShiftState & S_CTRL) // enable/disable highlighted panel or dock
850 if (bInputType == 1 || mouseClicked)
853 if (highlightedPanel)
855 if(panel.panel_configflags & PANEL_CONFIG_CANBEOFF)
856 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name), ftos(!cvar(strcat("hud_panel_", highlightedPanel.panel_name))));
859 cvar_set(strcat("hud_dock"), (autocvar_hud_dock == "") ? "dock" : "");
861 else if(nPrimary == 'c' && hudShiftState & S_CTRL) // copy highlighted panel size
863 if (bInputType == 1 || mouseClicked)
866 if (highlightedPanel)
868 panel = highlightedPanel;
869 HUD_Panel_UpdatePosSize();
870 panel_size_copied = panel_size;
873 else if(nPrimary == 'v' && hudShiftState & S_CTRL) // past copied size on the highlighted panel
875 if (bInputType == 1 || mouseClicked)
878 if (panel_size_copied == '0 0 0' || !highlightedPanel)
881 panel = highlightedPanel;
882 HUD_Panel_UpdatePosSize();
884 // reduce size if it'd go beyond screen boundaries
885 vector tmp_size = panel_size_copied;
886 if (panel_pos.x + panel_size_copied.x > vid_conwidth)
887 tmp_size.x = vid_conwidth - panel_pos.x;
888 if (panel_pos.y + panel_size_copied.y > vid_conheight)
889 tmp_size.y = vid_conheight - panel_pos.y;
891 if (panel_size == tmp_size)
895 panel_pos_backup = panel_pos;
896 panel_size_backup = panel_size;
897 highlightedPanel_backup = highlightedPanel;
899 s = strcat(ftos(tmp_size.x/vid_conwidth), " ", ftos(tmp_size.y/vid_conheight));
900 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_size"), s);
902 else if(nPrimary == 'z' && hudShiftState & S_CTRL) // undo last action
904 if (bInputType == 1 || mouseClicked)
906 //restore previous values
907 if (highlightedPanel_backup)
909 s = strcat(ftos(panel_pos_backup.x/vid_conwidth), " ", ftos(panel_pos_backup.y/vid_conheight));
910 cvar_set(strcat("hud_panel_", highlightedPanel_backup.panel_name, "_pos"), s);
911 s = strcat(ftos(panel_size_backup.x/vid_conwidth), " ", ftos(panel_size_backup.y/vid_conheight));
912 cvar_set(strcat("hud_panel_", highlightedPanel_backup.panel_name, "_size"), s);
913 highlightedPanel_backup = NULL;
916 else if(nPrimary == 's' && hudShiftState & S_CTRL) // save config
918 if (bInputType == 1 || mouseClicked)
920 localcmd("hud save myconfig\n");
922 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
926 pressed_key_time = 0;
929 else if (pressed_key_time == 0)
930 pressed_key_time = time;
933 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
935 else if(nPrimary == K_ENTER || nPrimary == K_SPACE || nPrimary == K_KP_ENTER)
939 if (highlightedPanel)
940 HUD_Panel_EnableMenu();
942 else if(hit_con_bind || nPrimary == K_PAUSE)
948 float HUD_Panel_Check_Mouse_Pos(float allow_move)
951 while(j < hud_panels_COUNT)
956 panel = hud_panels_from(i);
957 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
958 HUD_Panel_UpdatePosSize();
960 float border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
963 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)
967 // resize from topleft border
968 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)
972 // resize from topright border
973 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)
977 // resize from bottomleft border
978 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)
982 // resize from bottomright border
983 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)
991 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
992 void HUD_Panel_FirstInDrawQ(float id)
996 // find out where in the array our current id is, save into place
997 for(i = 0; i < hud_panels_COUNT; ++i)
999 if(panel_order[i] == id)
1005 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1007 place = hud_panels_COUNT - 1;
1009 // move all ids up by one step in the array until "place"
1010 for(i = place; i > 0; --i)
1012 panel_order[i] = panel_order[i-1];
1014 // now save the new top id
1015 panel_order[0] = id;
1017 // let's save them into the cvar by some strcat trickery
1019 for(i = 0; i < hud_panels_COUNT; ++i)
1021 s = strcat(s, ftos(panel_order[i]), " ");
1023 cvar_set("_hud_panelorder", s);
1024 if(hud_panelorder_prev)
1025 strunzone(hud_panelorder_prev);
1026 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1029 void HUD_Panel_Highlight(float allow_move)
1033 while(j < hud_panels_COUNT)
1038 panel = hud_panels_from(i);
1039 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN))
1041 HUD_Panel_UpdatePosSize();
1043 float border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1046 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)
1048 highlightedPanel = hud_panels_from(i);
1049 HUD_Panel_FirstInDrawQ(i);
1050 highlightedAction = 1;
1051 panel_click_distance = mousepos - panel_pos;
1054 // resize from topleft border
1055 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)
1057 highlightedPanel = hud_panels_from(i);
1058 HUD_Panel_FirstInDrawQ(i);
1059 highlightedAction = 2;
1061 panel_click_distance = mousepos - panel_pos;
1062 panel_click_resizeorigin = panel_pos + panel_size;
1065 // resize from topright border
1066 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)
1068 highlightedPanel = hud_panels_from(i);
1069 HUD_Panel_FirstInDrawQ(i);
1070 highlightedAction = 2;
1072 panel_click_distance.x = panel_size.x - mousepos.x + panel_pos.x;
1073 panel_click_distance.y = mousepos.y - panel_pos.y;
1074 panel_click_resizeorigin = panel_pos + eY * panel_size.y;
1077 // resize from bottomleft border
1078 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)
1080 highlightedPanel = hud_panels_from(i);
1081 HUD_Panel_FirstInDrawQ(i);
1082 highlightedAction = 2;
1084 panel_click_distance.x = mousepos.x - panel_pos.x;
1085 panel_click_distance.y = panel_size.y - mousepos.y + panel_pos.y;
1086 panel_click_resizeorigin = panel_pos + eX * panel_size.x;
1089 // resize from bottomright border
1090 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)
1092 highlightedPanel = hud_panels_from(i);
1093 HUD_Panel_FirstInDrawQ(i);
1094 highlightedAction = 2;
1096 panel_click_distance = panel_size - mousepos + panel_pos;
1097 panel_click_resizeorigin = panel_pos;
1101 highlightedPanel = NULL;
1102 highlightedAction = 0;
1105 void HUD_Panel_EnableMenu()
1107 hud_configure_menu_open = 2;
1108 localcmd("menu_showhudoptions ", highlightedPanel.panel_name, "\n");
1110 float mouse_over_panel;
1111 void HUD_Panel_Mouse()
1113 if(autocvar__menu_alpha == 1)
1116 if (!autocvar_hud_cursormode)
1121 if(prevMouseClicked == 0)
1125 //stop ctrl-tab selection
1129 HUD_Panel_Highlight(mouseClicked & S_MOUSE1); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
1130 // and calls HUD_Panel_UpdatePosSize() for the highlighted panel
1131 if (highlightedPanel)
1133 highlightedPanel_initial_pos = panel_pos;
1134 highlightedPanel_initial_size = panel_size;
1136 // doubleclick check
1137 if ((mouseClicked & S_MOUSE1) && time - prevMouseClickedTime < 0.4 && highlightedPanel && prevMouseClickedPos == mousepos)
1139 mouseClicked = 0; // to prevent spam, I guess.
1140 HUD_Panel_EnableMenu();
1144 if (mouseClicked & S_MOUSE1)
1146 prevMouseClickedTime = time;
1147 prevMouseClickedPos = mousepos;
1149 mouse_over_panel = HUD_Panel_Check_Mouse_Pos(mouseClicked & S_MOUSE1);
1154 panel = highlightedPanel;
1155 HUD_Panel_UpdatePosSize();
1158 if (highlightedPanel)
1160 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .1, DRAWFLAG_NORMAL);
1161 if (highlightedPanel_initial_pos != panel_pos || highlightedPanel_initial_size != panel_size)
1163 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1165 panel_pos_backup = highlightedPanel_initial_pos;
1166 panel_size_backup = highlightedPanel_initial_size;
1167 highlightedPanel_backup = highlightedPanel;
1170 // in case the clicked panel is inside another panel and we aren't
1171 // moving it, avoid the immediate "fix" of its position/size
1172 // (often unwanted and hateful) by disabling collisions check
1173 hud_configure_checkcollisions = false;
1176 if(highlightedAction == 1)
1177 HUD_Panel_SetPos(mousepos - panel_click_distance);
1178 else if(highlightedAction == 2)
1180 vector mySize = '0 0 0';
1181 if(resizeCorner == 1) {
1182 mySize.x = panel_click_resizeorigin.x - (mousepos.x - panel_click_distance.x);
1183 mySize.y = panel_click_resizeorigin.y - (mousepos.y - panel_click_distance.y);
1184 } else if(resizeCorner == 2) {
1185 mySize.x = mousepos.x + panel_click_distance.x - panel_click_resizeorigin.x;
1186 mySize.y = panel_click_distance.y + panel_click_resizeorigin.y - mousepos.y;
1187 } else if(resizeCorner == 3) {
1188 mySize.x = panel_click_resizeorigin.x + panel_click_distance.x - mousepos.x;
1189 mySize.y = mousepos.y + panel_click_distance.y - panel_click_resizeorigin.y;
1190 } else { // resizeCorner == 4
1191 mySize.x = mousepos.x - (panel_click_resizeorigin.x - panel_click_distance.x);
1192 mySize.y = mousepos.y - (panel_click_resizeorigin.y - panel_click_distance.y);
1194 HUD_Panel_SetPosSize(mySize);
1199 if(prevMouseClicked)
1200 highlightedAction = 0;
1201 if(hud_configure_menu_open == 2)
1202 mouse_over_panel = 0;
1204 mouse_over_panel = HUD_Panel_Check_Mouse_Pos(true);
1205 if (mouse_over_panel && !tab_panel)
1206 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .1, DRAWFLAG_NORMAL);
1208 // draw cursor after performing move/resize to have the panel pos/size updated before mouse_over_panel
1209 float cursor_alpha = 1 - autocvar__menu_alpha;
1211 if(!mouse_over_panel)
1212 draw_cursor_normal(mousepos, '1 1 1', cursor_alpha);
1213 else if(mouse_over_panel == 1)
1214 draw_cursor(mousepos, '0.5 0.5 0', "/cursor_move", '1 1 1', cursor_alpha);
1215 else if(mouse_over_panel == 2)
1216 draw_cursor(mousepos, '0.5 0.5 0', "/cursor_resize", '1 1 1', cursor_alpha);
1218 draw_cursor(mousepos, '0.5 0.5 0', "/cursor_resize2", '1 1 1', cursor_alpha);
1220 prevMouseClicked = mouseClicked;
1222 void HUD_Configure_DrawGrid()
1225 if(autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
1227 hud_configure_gridSize.x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
1228 hud_configure_gridSize.y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
1229 hud_configure_realGridSize.x = hud_configure_gridSize.x * vid_conwidth;
1230 hud_configure_realGridSize.y = hud_configure_gridSize.y * vid_conheight;
1233 s = vec2(1, vid_conheight);
1234 for(i = 1; i < 1/hud_configure_gridSize.x; ++i)
1235 drawfill(eX * i * hud_configure_realGridSize.x, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
1237 s = vec2(vid_conwidth, 1);
1238 for(i = 1; i < 1/hud_configure_gridSize.y; ++i)
1239 drawfill(eY * i * hud_configure_realGridSize.y, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
1243 float _menu_alpha_prev;
1244 void HUD_Configure_Frame()
1247 if(autocvar__hud_configure)
1249 if(isdemo() || intermission == 2 || scoreboard_active)
1251 HUD_Configure_Exit_Force();
1255 if(!hud_configure_prev)
1257 if(autocvar_hud_cursormode)
1260 for(i = hud_panels_COUNT - 1; i >= 0; --i)
1261 hud_panels_from(panel_order[i]).update_time = time;
1264 // NOTE this check is necessary because _menu_alpha isn't updated the frame the menu gets enabled
1265 if(autocvar__menu_alpha != _menu_alpha_prev)
1267 if(autocvar__menu_alpha == 0)
1268 hud_configure_menu_open = 0;
1269 _menu_alpha_prev = autocvar__menu_alpha;
1272 HUD_Configure_DrawGrid();
1274 else if(hud_configure_prev)
1276 if(hud_configure_menu_open)
1277 hud_configure_menu_open = 0;
1278 if(autocvar_hud_cursormode)
1280 hud_dynamic_shake_factor = -1;
1284 const float hlBorderSize = 2;
1285 const string hlBorder = "gfx/hud/default/border_highlighted";
1286 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
1287 void HUD_Panel_HlBorder(float myBorder, vector color, float theAlpha)
1289 vector pos = panel_pos - vec2(myBorder, myBorder);
1290 drawfill(pos, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * theAlpha, DRAWFLAG_NORMAL);
1291 drawpic_tiled(pos, hlBorder, '8 1 0' * hlBorderSize, vec2(panel_size.x + 2 * myBorder, hlBorderSize), color, theAlpha, DRAWFLAG_NORMAL);
1292 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);
1293 pos.y += hlBorderSize;
1294 drawpic_tiled(pos, hlBorder2, '1 8 0' * hlBorderSize, vec2(hlBorderSize, panel_size.y + 2 * myBorder - 2 * hlBorderSize), color, theAlpha, DRAWFLAG_NORMAL);
1295 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);
1298 void HUD_Configure_PostDraw()
1300 if(autocvar__hud_configure)
1305 HUD_Panel_UpdatePosSize();
1306 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
1308 if(highlightedPanel)
1310 panel = highlightedPanel;
1311 HUD_Panel_UpdatePosSize();
1312 HUD_Panel_HlBorder(panel_bg_border * hlBorderSize, '0 0.5 1', 0.4 * (1 - autocvar__menu_alpha));