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");
98 HUD_Write_Cvar("hud_panel_weapons_selection_radius");
99 HUD_Write_Cvar("hud_panel_weapons_selection_speed");
102 HUD_Write_Cvar("hud_panel_ammo_onlycurrent");
103 HUD_Write_Cvar("hud_panel_ammo_noncurrent_alpha");
104 HUD_Write_Cvar("hud_panel_ammo_noncurrent_scale");
105 HUD_Write_Cvar("hud_panel_ammo_iconalign");
106 HUD_Write_Cvar("hud_panel_ammo_progressbar");
107 HUD_Write_Cvar("hud_panel_ammo_progressbar_name");
108 HUD_Write_Cvar("hud_panel_ammo_progressbar_xoffset");
109 HUD_Write_Cvar("hud_panel_ammo_text");
111 case HUD_PANEL_POWERUPS:
112 HUD_Write_Cvar("hud_panel_powerups_iconalign");
113 HUD_Write_Cvar("hud_panel_powerups_baralign");
114 HUD_Write_Cvar("hud_panel_powerups_progressbar");
115 HUD_Write_Cvar("hud_panel_powerups_text");
117 case HUD_PANEL_HEALTHARMOR:
118 HUD_Write_Cvar("hud_panel_healtharmor_combined");
119 HUD_Write_Cvar("hud_panel_healtharmor_flip");
120 HUD_Write_Cvar("hud_panel_healtharmor_iconalign");
121 HUD_Write_Cvar("hud_panel_healtharmor_baralign");
122 HUD_Write_Cvar("hud_panel_healtharmor_progressbar");
123 HUD_Write_Cvar("hud_panel_healtharmor_progressbar_health");
124 HUD_Write_Cvar("hud_panel_healtharmor_progressbar_armor");
125 HUD_Write_Cvar("hud_panel_healtharmor_progressbar_gfx");
126 HUD_Write_Cvar("hud_panel_healtharmor_progressbar_gfx_smooth");
127 HUD_Write_Cvar("hud_panel_healtharmor_text");
129 case HUD_PANEL_NOTIFY:
130 HUD_Write_Cvar("hud_panel_notify_flip");
131 HUD_Write_Cvar("hud_panel_notify_fontsize");
132 HUD_Write_Cvar("hud_panel_notify_time");
133 HUD_Write_Cvar("hud_panel_notify_fadetime");
134 HUD_Write_Cvar("hud_panel_notify_icon_aspect");
136 case HUD_PANEL_TIMER:
138 case HUD_PANEL_RADAR:
139 HUD_Write_Cvar("hud_panel_radar_foreground_alpha");
140 HUD_Write_Cvar("hud_panel_radar_rotation");
141 HUD_Write_Cvar("hud_panel_radar_zoommode");
142 HUD_Write_Cvar("hud_panel_radar_scale");
143 HUD_Write_Cvar("hud_panel_radar_maximized_scale");
144 HUD_Write_Cvar("hud_panel_radar_maximized_size");
145 HUD_Write_Cvar("hud_panel_radar_maximized_rotation");
146 HUD_Write_Cvar("hud_panel_radar_maximized_zoommode");
148 case HUD_PANEL_SCORE:
149 HUD_Write_Cvar("hud_panel_score_rankings");
152 HUD_Write_Cvar("hud_panel_vote_alreadyvoted_alpha");
154 case HUD_PANEL_MODICONS:
155 HUD_Write_Cvar("hud_panel_modicons_ca_layout");
156 HUD_Write_Cvar("hud_panel_modicons_dom_layout");
157 HUD_Write_Cvar("hud_panel_modicons_freezetag_layout");
159 case HUD_PANEL_PRESSEDKEYS:
160 HUD_Write_Cvar("hud_panel_pressedkeys_aspect");
161 HUD_Write_Cvar("hud_panel_pressedkeys_attack");
163 case HUD_PANEL_ENGINEINFO:
164 HUD_Write_Cvar("hud_panel_engineinfo_framecounter_time");
165 HUD_Write_Cvar("hud_panel_engineinfo_framecounter_decimals");
167 case HUD_PANEL_INFOMESSAGES:
168 HUD_Write_Cvar("hud_panel_infomessages_flip");
170 case HUD_PANEL_PHYSICS:
171 HUD_Write_Cvar("hud_panel_physics_speed_unit_show");
172 HUD_Write_Cvar("hud_panel_physics_speed_max");
173 HUD_Write_Cvar("hud_panel_physics_speed_vertical");
174 HUD_Write_Cvar("hud_panel_physics_topspeed");
175 HUD_Write_Cvar("hud_panel_physics_topspeed_time");
176 HUD_Write_Cvar("hud_panel_physics_acceleration_max");
177 HUD_Write_Cvar("hud_panel_physics_acceleration_vertical");
178 HUD_Write_Cvar("hud_panel_physics_flip");
179 HUD_Write_Cvar("hud_panel_physics_baralign");
180 HUD_Write_Cvar("hud_panel_physics_progressbar");
181 HUD_Write_Cvar("hud_panel_physics_acceleration_progressbar_mode");
182 HUD_Write_Cvar("hud_panel_physics_acceleration_progressbar_scale");
183 HUD_Write_Cvar("hud_panel_physics_acceleration_progressbar_nonlinear");
184 HUD_Write_Cvar("hud_panel_physics_text");
185 HUD_Write_Cvar("hud_panel_physics_text_scale");
187 case HUD_PANEL_CENTERPRINT:
188 HUD_Write_Cvar("hud_panel_centerprint_align");
189 HUD_Write_Cvar("hud_panel_centerprint_flip");
190 HUD_Write_Cvar("hud_panel_centerprint_fontscale");
191 HUD_Write_Cvar("hud_panel_centerprint_time");
192 HUD_Write_Cvar("hud_panel_centerprint_fade_in");
193 HUD_Write_Cvar("hud_panel_centerprint_fade_out");
194 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent");
195 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent_passone");
196 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent_passone_minalpha");
197 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent_passtwo");
198 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent_passtwo_minalpha");
199 HUD_Write_Cvar("hud_panel_centerprint_fade_subsequent_minfontsize");
200 HUD_Write_Cvar("hud_panel_centerprint_fade_minfontsize");
202 case HUD_PANEL_ITEMSTIME:
203 HUD_Write_Cvar("hud_panel_itemstime_iconalign");
204 HUD_Write_Cvar("hud_panel_itemstime_progressbar");
205 HUD_Write_Cvar("hud_panel_itemstime_progressbar_name");
206 HUD_Write_Cvar("hud_panel_itemstime_progressbar_reduced");
207 HUD_Write_Cvar("hud_panel_itemstime_text");
208 HUD_Write_Cvar("hud_panel_itemstime_ratio");
209 HUD_Write_Cvar("hud_panel_itemstime_dynamicsize");
211 case HUD_PANEL_MAPVOTE:
212 HUD_Write_Cvar("hud_panel_mapvote_highlight_border");
214 case HUD_PANEL_QUICKMENU:
215 HUD_Write_Cvar("hud_panel_quickmenu_align");
217 case HUD_PANEL_SCOREBOARD:
218 HUD_Write_Cvar("hud_panel_scoreboard_fadeinspeed");
219 HUD_Write_Cvar("hud_panel_scoreboard_fadeoutspeed");
220 HUD_Write_Cvar("hud_panel_scoreboard_respawntime_decimals");
221 HUD_Write_Cvar("hud_panel_scoreboard_table_bg_alpha");
222 HUD_Write_Cvar("hud_panel_scoreboard_table_bg_scale");
223 HUD_Write_Cvar("hud_panel_scoreboard_table_fg_alpha");
224 HUD_Write_Cvar("hud_panel_scoreboard_table_fg_alpha_self");
225 HUD_Write_Cvar("hud_panel_scoreboard_table_highlight");
226 HUD_Write_Cvar("hud_panel_scoreboard_table_highlight_alpha");
227 HUD_Write_Cvar("hud_panel_scoreboard_table_highlight_alpha_self");
228 HUD_Write_Cvar("hud_panel_scoreboard_bg_teams_color_team");
229 HUD_Write_Cvar("hud_panel_scoreboard_accuracy_doublerows");
230 HUD_Write_Cvar("hud_panel_scoreboard_accuracy_nocolors");
235 MUTATOR_CALLHOOK(HUD_WriteCvars, fh);
237 HUD_Write("menu_sync\n"); // force the menu to reread the cvars, so that the dialogs are updated
239 LOG_INFOF(_("^2Successfully exported to %s! (Note: It's saved in data/data/)\n"), filename);
243 LOG_INFOF(_("^1Couldn't write to %s\n"), filename);
246 void HUD_Configure_Exit_Force()
248 if (hud_configure_menu_open)
250 hud_configure_menu_open = 0;
251 localcmd("togglemenu\n");
253 cvar_set("_hud_configure", "0");
256 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
257 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
259 vector myCenter, targCenter;
260 vector myTarget = myPos;
262 for (i = 0; i < hud_panels_COUNT; ++i) {
263 panel = hud_panels_from(i);
264 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
265 if(panel == highlightedPanel) continue;
266 HUD_Panel_UpdatePosSize();
267 if(!panel_enabled) continue;
269 panel_pos -= '1 1 0' * panel_bg_border;
270 panel_size += '2 2 0' * panel_bg_border;
272 if(myPos.y + mySize.y < panel_pos.y)
274 if(myPos.y > panel_pos.y + panel_size.y)
277 if(myPos.x + mySize.x < panel_pos.x)
279 if(myPos.x > panel_pos.x + panel_size.x)
282 // OK, there IS a collision.
284 myCenter.x = myPos.x + 0.5 * mySize.x;
285 myCenter.y = myPos.y + 0.5 * mySize.y;
287 targCenter.x = panel_pos.x + 0.5 * panel_size.x;
288 targCenter.y = panel_pos.y + 0.5 * panel_size.y;
290 if(myCenter.x < targCenter.x && myCenter.y < targCenter.y) // top left (of the target panel)
292 if(myPos.x + mySize.x - panel_pos.x < myPos.y + mySize.y - panel_pos.y) // push it to the side
293 myTarget.x = panel_pos.x - mySize.x;
294 else // push it upwards
295 myTarget.y = panel_pos.y - mySize.y;
297 else if(myCenter.x > targCenter.x && myCenter.y < targCenter.y) // top right
299 if(panel_pos.x + panel_size.x - myPos.x < myPos.y + mySize.y - panel_pos.y) // push it to the side
300 myTarget.x = panel_pos.x + panel_size.x;
301 else // push it upwards
302 myTarget.y = panel_pos.y - mySize.y;
304 else if(myCenter.x < targCenter.x && myCenter.y > targCenter.y) // bottom left
306 if(myPos.x + mySize.x - panel_pos.x < panel_pos.y + panel_size.y - myPos.y) // push it to the side
307 myTarget.x = panel_pos.x - mySize.x;
308 else // push it downwards
309 myTarget.y = panel_pos.y + panel_size.y;
311 else if(myCenter.x > targCenter.x && myCenter.y > targCenter.y) // bottom right
313 if(panel_pos.x + panel_size.x - myPos.x < panel_pos.y + panel_size.y - myPos.y) // push it to the side
314 myTarget.x = panel_pos.x + panel_size.x;
315 else // push it downwards
316 myTarget.y = panel_pos.y + panel_size.y;
318 //if(cvar("hud_configure_checkcollisions_debug"))
319 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
325 void HUD_Panel_SetPos(vector pos)
327 panel = highlightedPanel;
328 HUD_Panel_UpdatePosSize();
332 //if(cvar("hud_configure_checkcollisions_debug"))
333 //drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
335 if(autocvar_hud_configure_grid)
337 pos.x = floor((pos.x/vid_conwidth)/hud_configure_gridSize.x + 0.5) * hud_configure_realGridSize.x;
338 pos.y = floor((pos.y/vid_conheight)/hud_configure_gridSize.y + 0.5) * hud_configure_realGridSize.y;
341 if(hud_configure_checkcollisions)
342 pos = HUD_Panel_CheckMove(pos, mySize);
344 pos.x = bound(0, pos.x, vid_conwidth - mySize.x);
345 pos.y = bound(0, pos.y, vid_conheight - mySize.y);
348 s = strcat(ftos(pos.x/vid_conwidth), " ", ftos(pos.y/vid_conheight));
350 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_pos"), s);
353 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
354 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
357 float ratio = mySize.x/mySize.y;
359 for (i = 0; i < hud_panels_COUNT; ++i) {
360 panel = hud_panels_from(i);
361 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
362 if(panel == highlightedPanel) continue;
363 HUD_Panel_UpdatePosSize();
364 if(!panel_enabled) continue;
366 panel_pos -= '1 1 0' * panel_bg_border;
367 panel_size += '2 2 0' * panel_bg_border;
369 targEndPos = panel_pos + panel_size;
371 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
372 if(resizeorigin.x > panel_pos.x && resizeorigin.x < targEndPos.x && resizeorigin.y > panel_pos.y && resizeorigin.y < targEndPos.y)
375 if (resizeCorner == 1)
377 // check if this panel is on our way
378 if (resizeorigin.x <= panel_pos.x)
380 if (resizeorigin.y <= panel_pos.y)
382 if (targEndPos.x <= resizeorigin.x - mySize.x)
384 if (targEndPos.y <= resizeorigin.y - mySize.y)
387 // there is a collision:
388 // detect which side of the panel we are facing is actually limiting the resizing
389 // (which side the resize direction finds for first) and reduce the size up to there
391 // dist is the distance between resizeorigin and the "analogous" point of the panel
392 // in this case between resizeorigin (bottom-right point) and the bottom-right point of the panel
393 dist.x = resizeorigin.x - targEndPos.x;
394 dist.y = resizeorigin.y - targEndPos.y;
395 if (dist.y <= 0 || dist.x / dist.y > ratio)
396 mySize.x = min(mySize.x, dist.x);
398 mySize.y = min(mySize.y, dist.y);
400 else if (resizeCorner == 2)
402 if (resizeorigin.x >= targEndPos.x)
404 if (resizeorigin.y <= panel_pos.y)
406 if (panel_pos.x >= resizeorigin.x + mySize.x)
408 if (targEndPos.y <= resizeorigin.y - mySize.y)
411 dist.x = panel_pos.x - resizeorigin.x;
412 dist.y = resizeorigin.y - targEndPos.y;
413 if (dist.y <= 0 || dist.x / dist.y > ratio)
414 mySize.x = min(mySize.x, dist.x);
416 mySize.y = min(mySize.y, dist.y);
418 else if (resizeCorner == 3)
420 if (resizeorigin.x <= panel_pos.x)
422 if (resizeorigin.y >= targEndPos.y)
424 if (targEndPos.x <= resizeorigin.x - mySize.x)
426 if (panel_pos.y >= resizeorigin.y + mySize.y)
429 dist.x = resizeorigin.x - targEndPos.x;
430 dist.y = panel_pos.y - resizeorigin.y;
431 if (dist.y <= 0 || dist.x / dist.y > ratio)
432 mySize.x = min(mySize.x, dist.x);
434 mySize.y = min(mySize.y, dist.y);
436 else if (resizeCorner == 4)
438 if (resizeorigin.x >= targEndPos.x)
440 if (resizeorigin.y >= targEndPos.y)
442 if (panel_pos.x >= resizeorigin.x + mySize.x)
444 if (panel_pos.y >= resizeorigin.y + mySize.y)
447 dist.x = panel_pos.x - resizeorigin.x;
448 dist.y = panel_pos.y - resizeorigin.y;
449 if (dist.y <= 0 || dist.x / dist.y > ratio)
450 mySize.x = min(mySize.x, dist.x);
452 mySize.y = min(mySize.y, dist.y);
454 //if(cvar("hud_configure_checkcollisions_debug"))
455 //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
461 void HUD_Panel_SetPosSize(vector mySize)
463 panel = highlightedPanel;
464 HUD_Panel_UpdatePosSize();
465 vector resizeorigin = panel_click_resizeorigin;
468 // minimum panel size cap
469 mySize.x = max(0.025 * vid_conwidth, mySize.x);
470 mySize.y = max(0.025 * vid_conheight, mySize.y);
472 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.
474 mySize.x = max(17 * autocvar_con_chatsize, mySize.x);
475 mySize.y = max(2 * autocvar_con_chatsize + 2 * panel_bg_padding, mySize.y);
478 // collision testing|
479 // -----------------+
481 // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
482 if(resizeCorner == 1) {
483 myPos.x = resizeorigin.x - mySize.x;
484 myPos.y = resizeorigin.y - mySize.y;
485 } else if(resizeCorner == 2) {
486 myPos.x = resizeorigin.x;
487 myPos.y = resizeorigin.y - mySize.y;
488 } else if(resizeCorner == 3) {
489 myPos.x = resizeorigin.x - mySize.x;
490 myPos.y = resizeorigin.y;
491 } else { // resizeCorner == 4
492 myPos.x = resizeorigin.x;
493 myPos.y = resizeorigin.y;
496 // left/top screen edges
498 mySize.x = mySize.x + myPos.x;
500 mySize.y = mySize.y + myPos.y;
502 // bottom/right screen edges
503 if(myPos.x + mySize.x > vid_conwidth)
504 mySize.x = vid_conwidth - myPos.x;
505 if(myPos.y + mySize.y > vid_conheight)
506 mySize.y = vid_conheight - myPos.y;
508 //if(cvar("hud_configure_checkcollisions_debug"))
509 //drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
511 // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
512 if(autocvar_hud_configure_grid)
514 mySize.x = floor((mySize.x/vid_conwidth)/hud_configure_gridSize.x + 0.5) * hud_configure_realGridSize.x;
515 mySize.y = floor((mySize.y/vid_conheight)/hud_configure_gridSize.y + 0.5) * hud_configure_realGridSize.y;
518 if(hud_configure_checkcollisions)
519 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
521 // 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)
522 mySize.x = max(0.025 * vid_conwidth, mySize.x);
523 mySize.y = max(0.025 * vid_conheight, mySize.y);
525 // do another pos check, as size might have changed by now
526 if(resizeCorner == 1) {
527 myPos.x = resizeorigin.x - mySize.x;
528 myPos.y = resizeorigin.y - mySize.y;
529 } else if(resizeCorner == 2) {
530 myPos.x = resizeorigin.x;
531 myPos.y = resizeorigin.y - mySize.y;
532 } else if(resizeCorner == 3) {
533 myPos.x = resizeorigin.x - mySize.x;
534 myPos.y = resizeorigin.y;
535 } else { // resizeCorner == 4
536 myPos.x = resizeorigin.x;
537 myPos.y = resizeorigin.y;
540 //if(cvar("hud_configure_checkcollisions_debug"))
541 //drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
544 s = strcat(ftos(mySize.x/vid_conwidth), " ", ftos(mySize.y/vid_conheight));
545 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_size"), s);
547 s = strcat(ftos(myPos.x/vid_conwidth), " ", ftos(myPos.y/vid_conheight));
548 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_pos"), s);
551 float pressed_key_time;
552 vector highlightedPanel_initial_pos, highlightedPanel_initial_size;
553 void HUD_Panel_Arrow_Action(float nPrimary)
555 if(!highlightedPanel)
558 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
561 if(autocvar_hud_configure_grid)
563 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
565 if (hudShiftState & S_SHIFT)
566 step = hud_configure_realGridSize.y;
568 step = 2 * hud_configure_realGridSize.y;
572 if (hudShiftState & S_SHIFT)
573 step = hud_configure_realGridSize.x;
575 step = 2 * hud_configure_realGridSize.x;
580 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
581 step = vid_conheight;
584 if (hudShiftState & S_SHIFT)
585 step = (step / 256); // more precision
587 step = (step / 64) * (1 + 2 * (time - pressed_key_time));
590 panel = highlightedPanel;
591 HUD_Panel_UpdatePosSize();
593 highlightedPanel_initial_pos = panel_pos;
594 highlightedPanel_initial_size = panel_size;
596 if (hudShiftState & S_ALT) // resize
598 if(nPrimary == K_UPARROW)
600 else if(nPrimary == K_RIGHTARROW)
602 else if(nPrimary == K_LEFTARROW)
604 else // if(nPrimary == K_DOWNARROW)
607 // ctrl+arrow reduces the size, instead of increasing it
608 // Note that ctrl disables collisions check too, but it's fine
609 // since we don't collide with anything reducing the size
610 if (hudShiftState & S_CTRL) {
612 resizeCorner = 5 - resizeCorner;
617 panel_click_resizeorigin = panel_pos;
618 if(resizeCorner == 1) {
619 panel_click_resizeorigin += mySize;
621 } else if(resizeCorner == 2) {
622 panel_click_resizeorigin.y += mySize.y;
624 } else if(resizeCorner == 3) {
625 panel_click_resizeorigin.x += mySize.x;
627 } else { // resizeCorner == 4
630 HUD_Panel_SetPosSize(mySize);
636 if(nPrimary == K_UPARROW)
638 else if(nPrimary == K_DOWNARROW)
640 else if(nPrimary == K_LEFTARROW)
642 else // if(nPrimary == K_RIGHTARROW)
645 HUD_Panel_SetPos(pos);
648 panel = highlightedPanel;
649 HUD_Panel_UpdatePosSize();
651 if (highlightedPanel_initial_pos != panel_pos || highlightedPanel_initial_size != panel_size)
654 panel_pos_backup = highlightedPanel_initial_pos;
655 panel_size_backup = highlightedPanel_initial_size;
656 highlightedPanel_backup = highlightedPanel;
660 void HUD_Panel_EnableMenu();
661 entity tab_panels[hud_panels_MAX];
663 vector tab_panel_pos;
665 void HUD_Panel_FirstInDrawQ(float id);
666 void reset_tab_panels()
668 for (int i = 0; i < hud_panels_COUNT; ++i)
669 tab_panels[i] = NULL;
671 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
678 if(!autocvar__hud_configure)
683 mousepos.x = nPrimary;
684 mousepos.y = nSecondary;
688 // block any input while a menu dialog is fading
689 // don't block mousepos read as it leads to cursor jumps in the interaction with the menu
690 if(autocvar__menu_alpha)
697 // allow console bind to work
698 string con_keys = findkeysforcommand("toggleconsole", 0);
699 int keys = tokenize(con_keys); // findkeysforcommand returns data for this
701 bool hit_con_bind = false;
703 for (i = 0; i < keys; ++i)
705 if(nPrimary == stof(argv(i)))
709 if(bInputType == 0) {
710 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
711 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
712 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
714 else if(bInputType == 1) {
715 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
716 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
717 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
720 if(nPrimary == K_CTRL)
722 if (bInputType == 1) //ctrl has been released
726 //switch to selected panel
727 highlightedPanel = tab_panel;
728 highlightedAction = 0;
729 HUD_Panel_FirstInDrawQ(highlightedPanel.panel_id);
736 if(nPrimary == K_MOUSE1)
738 if(bInputType == 0) // key pressed
739 mouseClicked |= S_MOUSE1;
740 else if(bInputType == 1) // key released
741 mouseClicked -= (mouseClicked & S_MOUSE1);
743 else if(nPrimary == K_MOUSE2)
745 if(bInputType == 0) // key pressed
746 mouseClicked |= S_MOUSE2;
747 else if(bInputType == 1) // key released
748 mouseClicked -= (mouseClicked & S_MOUSE2);
750 else if(nPrimary == K_ESCAPE)
754 hud_configure_menu_open = 1;
755 localcmd("menu_showhudexit\n");
757 else if(nPrimary == K_BACKSPACE && hudShiftState & S_CTRL)
761 if (!hud_configure_menu_open)
762 cvar_set("_hud_configure", "0");
764 else if(nPrimary == K_TAB && hudShiftState & S_CTRL) // switch panel
766 if (bInputType == 1 || mouseClicked)
769 // FIXME minor bug: if a panel is highlighted, has the same pos_x and
770 // lays in the same level of another panel then the next consecutive
771 // CTRL TAB presses will reselect once more the highlighted panel
773 entity starting_panel;
774 entity old_tab_panel = tab_panel;
775 if (!tab_panel) //first press of TAB
777 if (highlightedPanel)
779 panel = highlightedPanel;
780 HUD_Panel_UpdatePosSize();
784 starting_panel = highlightedPanel;
785 tab_panel_pos = panel_pos; //to compute level
789 if ( ((!tab_backward) && (hudShiftState & S_SHIFT)) || (tab_backward && !(hudShiftState & S_SHIFT)) ) //tab direction changed?
791 starting_panel = tab_panel;
793 tab_backward = (hudShiftState & S_SHIFT);
795 float k, level = 0, start_posX;
796 vector candidate_pos = '0 0 0';
797 const float LEVELS_NUM = 4;
798 float level_height = vid_conheight / LEVELS_NUM;
799 LABEL(find_tab_panel)
800 level = floor(tab_panel_pos.y / level_height) * level_height; //starting level
801 candidate_pos.x = (!tab_backward) ? vid_conwidth : 0;
802 start_posX = tab_panel_pos.x;
807 for(i = 0; i < hud_panels_COUNT; ++i)
809 panel = hud_panels_from(i);
810 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN))
812 if (panel == tab_panels[i] || panel == starting_panel)
814 HUD_Panel_UpdatePosSize();
815 if (panel_pos.y >= level && (panel_pos.y - level) < level_height)
816 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)) )
817 || ( 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)) ) )
820 tab_panel_pos = candidate_pos = panel_pos;
825 if (k == LEVELS_NUM) //tab_panel not found
833 starting_panel = old_tab_panel;
834 old_tab_panel = NULL;
835 goto find_tab_panel; //u must find tab_panel!
839 level = (level + level_height) % vid_conheight;
841 candidate_pos.x = vid_conwidth;
845 level = (level - level_height) % vid_conheight;
846 start_posX = vid_conwidth;
851 tab_panels[tab_panel.panel_id] = tab_panel;
853 else if(nPrimary == K_SPACE && hudShiftState & S_CTRL) // enable/disable highlighted panel or dock
855 if (bInputType == 1 || mouseClicked)
858 if (highlightedPanel)
860 if(panel.panel_configflags & PANEL_CONFIG_CANBEOFF)
861 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name), ftos(!cvar(strcat("hud_panel_", highlightedPanel.panel_name))));
864 cvar_set(strcat("hud_dock"), (autocvar_hud_dock == "") ? "dock" : "");
866 else if(nPrimary == 'c' && hudShiftState & S_CTRL) // copy highlighted panel size
868 if (bInputType == 1 || mouseClicked)
871 if (highlightedPanel)
873 panel = highlightedPanel;
874 HUD_Panel_UpdatePosSize();
875 panel_size_copied = panel_size;
878 else if(nPrimary == 'v' && hudShiftState & S_CTRL) // past copied size on the highlighted panel
880 if (bInputType == 1 || mouseClicked)
883 if (panel_size_copied == '0 0 0' || !highlightedPanel)
886 panel = highlightedPanel;
887 HUD_Panel_UpdatePosSize();
889 // reduce size if it'd go beyond screen boundaries
890 vector tmp_size = panel_size_copied;
891 if (panel_pos.x + panel_size_copied.x > vid_conwidth)
892 tmp_size.x = vid_conwidth - panel_pos.x;
893 if (panel_pos.y + panel_size_copied.y > vid_conheight)
894 tmp_size.y = vid_conheight - panel_pos.y;
896 if (panel_size == tmp_size)
900 panel_pos_backup = panel_pos;
901 panel_size_backup = panel_size;
902 highlightedPanel_backup = highlightedPanel;
904 s = strcat(ftos(tmp_size.x/vid_conwidth), " ", ftos(tmp_size.y/vid_conheight));
905 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_size"), s);
907 else if(nPrimary == 'z' && hudShiftState & S_CTRL) // undo last action
909 if (bInputType == 1 || mouseClicked)
911 //restore previous values
912 if (highlightedPanel_backup)
914 s = strcat(ftos(panel_pos_backup.x/vid_conwidth), " ", ftos(panel_pos_backup.y/vid_conheight));
915 cvar_set(strcat("hud_panel_", highlightedPanel_backup.panel_name, "_pos"), s);
916 s = strcat(ftos(panel_size_backup.x/vid_conwidth), " ", ftos(panel_size_backup.y/vid_conheight));
917 cvar_set(strcat("hud_panel_", highlightedPanel_backup.panel_name, "_size"), s);
918 highlightedPanel_backup = NULL;
921 else if(nPrimary == 's' && hudShiftState & S_CTRL) // save config
923 if (bInputType == 1 || mouseClicked)
925 localcmd("hud save myconfig\n");
927 else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
931 pressed_key_time = 0;
934 else if (pressed_key_time == 0)
935 pressed_key_time = time;
938 HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
940 else if(nPrimary == K_ENTER || nPrimary == K_SPACE || nPrimary == K_KP_ENTER)
944 if (highlightedPanel)
945 HUD_Panel_EnableMenu();
947 else if(hit_con_bind || nPrimary == K_PAUSE)
953 float HUD_Panel_Check_Mouse_Pos(float allow_move)
956 while(j < hud_panels_COUNT)
961 panel = hud_panels_from(i);
962 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
963 HUD_Panel_UpdatePosSize();
965 float border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
968 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)
972 // resize from topleft border
973 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)
977 // resize from topright border
978 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)
982 // resize from bottomleft border
983 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)
987 // resize from bottomright border
988 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 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
997 void HUD_Panel_FirstInDrawQ(float id)
1001 // find out where in the array our current id is, save into place
1002 for(i = 0; i < hud_panels_COUNT; ++i)
1004 if(panel_order[i] == id)
1010 // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
1012 place = hud_panels_COUNT - 1;
1014 // move all ids up by one step in the array until "place"
1015 for(i = place; i > 0; --i)
1017 panel_order[i] = panel_order[i-1];
1019 // now save the new top id
1020 panel_order[0] = id;
1022 // let's save them into the cvar by some strcat trickery
1024 for(i = 0; i < hud_panels_COUNT; ++i)
1026 s = strcat(s, ftos(panel_order[i]), " ");
1028 cvar_set("_hud_panelorder", s);
1029 if(hud_panelorder_prev)
1030 strunzone(hud_panelorder_prev);
1031 hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
1034 void HUD_Panel_Highlight(float allow_move)
1038 while(j < hud_panels_COUNT)
1043 panel = hud_panels_from(i);
1044 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN))
1046 HUD_Panel_UpdatePosSize();
1048 float border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
1051 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)
1053 highlightedPanel = hud_panels_from(i);
1054 HUD_Panel_FirstInDrawQ(i);
1055 highlightedAction = 1;
1056 panel_click_distance = mousepos - panel_pos;
1059 // resize from topleft border
1060 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)
1062 highlightedPanel = hud_panels_from(i);
1063 HUD_Panel_FirstInDrawQ(i);
1064 highlightedAction = 2;
1066 panel_click_distance = mousepos - panel_pos;
1067 panel_click_resizeorigin = panel_pos + panel_size;
1070 // resize from topright border
1071 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)
1073 highlightedPanel = hud_panels_from(i);
1074 HUD_Panel_FirstInDrawQ(i);
1075 highlightedAction = 2;
1077 panel_click_distance.x = panel_size.x - mousepos.x + panel_pos.x;
1078 panel_click_distance.y = mousepos.y - panel_pos.y;
1079 panel_click_resizeorigin = panel_pos + eY * panel_size.y;
1082 // resize from bottomleft border
1083 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)
1085 highlightedPanel = hud_panels_from(i);
1086 HUD_Panel_FirstInDrawQ(i);
1087 highlightedAction = 2;
1089 panel_click_distance.x = mousepos.x - panel_pos.x;
1090 panel_click_distance.y = panel_size.y - mousepos.y + panel_pos.y;
1091 panel_click_resizeorigin = panel_pos + eX * panel_size.x;
1094 // resize from bottomright border
1095 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)
1097 highlightedPanel = hud_panels_from(i);
1098 HUD_Panel_FirstInDrawQ(i);
1099 highlightedAction = 2;
1101 panel_click_distance = panel_size - mousepos + panel_pos;
1102 panel_click_resizeorigin = panel_pos;
1106 highlightedPanel = NULL;
1107 highlightedAction = 0;
1110 void HUD_Panel_EnableMenu()
1112 hud_configure_menu_open = 2;
1113 localcmd("menu_showhudoptions ", highlightedPanel.panel_name, "\n");
1115 float mouse_over_panel;
1116 void HUD_Panel_Mouse()
1118 if(autocvar__menu_alpha == 1)
1121 if (!autocvar_hud_cursormode)
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 mouse_over_panel = 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 mouse_over_panel = 0;
1209 mouse_over_panel = HUD_Panel_Check_Mouse_Pos(true);
1210 if (mouse_over_panel && !tab_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);
1213 // draw cursor after performing move/resize to have the panel pos/size updated before mouse_over_panel
1214 float cursor_alpha = 1 - autocvar__menu_alpha;
1216 if(!mouse_over_panel)
1217 draw_cursor_normal(mousepos, '1 1 1', cursor_alpha);
1218 else if(mouse_over_panel == 1)
1219 draw_cursor(mousepos, '0.5 0.5 0', "/cursor_move", '1 1 1', cursor_alpha);
1220 else if(mouse_over_panel == 2)
1221 draw_cursor(mousepos, '0.5 0.5 0', "/cursor_resize", '1 1 1', cursor_alpha);
1223 draw_cursor(mousepos, '0.5 0.5 0', "/cursor_resize2", '1 1 1', cursor_alpha);
1225 prevMouseClicked = mouseClicked;
1227 void HUD_Configure_DrawGrid()
1230 if(autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
1232 hud_configure_gridSize.x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
1233 hud_configure_gridSize.y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
1234 hud_configure_realGridSize.x = hud_configure_gridSize.x * vid_conwidth;
1235 hud_configure_realGridSize.y = hud_configure_gridSize.y * vid_conheight;
1238 s = vec2(1, vid_conheight);
1239 for(i = 1; i < 1/hud_configure_gridSize.x; ++i)
1240 drawfill(eX * i * hud_configure_realGridSize.x, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
1242 s = vec2(vid_conwidth, 1);
1243 for(i = 1; i < 1/hud_configure_gridSize.y; ++i)
1244 drawfill(eY * i * hud_configure_realGridSize.y, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
1248 float _menu_alpha_prev;
1249 void HUD_Configure_Frame()
1252 if(autocvar__hud_configure)
1254 if(isdemo() || intermission == 2 || scoreboard_active)
1256 HUD_Configure_Exit_Force();
1260 if(!hud_configure_prev)
1262 if(autocvar_hud_cursormode)
1265 for(i = hud_panels_COUNT - 1; i >= 0; --i)
1266 hud_panels_from(panel_order[i]).update_time = time;
1269 // NOTE this check is necessary because _menu_alpha isn't updated the frame the menu gets enabled
1270 if(autocvar__menu_alpha != _menu_alpha_prev)
1272 if(autocvar__menu_alpha == 0)
1273 hud_configure_menu_open = 0;
1274 _menu_alpha_prev = autocvar__menu_alpha;
1277 HUD_Configure_DrawGrid();
1279 else if(hud_configure_prev)
1281 if(hud_configure_menu_open)
1282 hud_configure_menu_open = 0;
1283 if(autocvar_hud_cursormode)
1285 hud_dynamic_shake_factor = -1;
1289 const float hlBorderSize = 2;
1290 const string hlBorder = "gfx/hud/default/border_highlighted";
1291 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
1292 void HUD_Panel_HlBorder(float myBorder, vector color, float theAlpha)
1294 vector pos = panel_pos - vec2(myBorder, myBorder);
1295 drawfill(pos, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * theAlpha, DRAWFLAG_NORMAL);
1296 drawpic_tiled(pos, hlBorder, '8 1 0' * hlBorderSize, vec2(panel_size.x + 2 * myBorder, hlBorderSize), color, theAlpha, DRAWFLAG_NORMAL);
1297 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);
1298 pos.y += hlBorderSize;
1299 drawpic_tiled(pos, hlBorder2, '1 8 0' * hlBorderSize, vec2(hlBorderSize, panel_size.y + 2 * myBorder - 2 * hlBorderSize), color, theAlpha, DRAWFLAG_NORMAL);
1300 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);
1303 void HUD_Configure_PostDraw()
1305 if(autocvar__hud_configure)
1310 HUD_Panel_UpdatePosSize();
1311 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
1313 if(highlightedPanel)
1315 panel = highlightedPanel;
1316 HUD_Panel_UpdatePosSize();
1317 HUD_Panel_HlBorder(panel_bg_border * hlBorderSize, '0 0.5 1', 0.4 * (1 - autocvar__menu_alpha));