]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/hud/hud_config.qc
HUD: allow panels to define in their own files their own saved cvars
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / hud_config.qc
1 #include "hud_config.qh"
2
3 #include "hud.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>
9
10 // Save the config
11 void HUD_Panel_ExportCfg(string cfgname)
12 {
13         float fh;
14         string filename = strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg");
15         string str = "";
16         fh = fopen(filename, FILE_WRITE);
17         if(fh >= 0)
18         {
19                 HUD_Write("//title \n");
20                 HUD_Write("//author \n");
21                 HUD_Write("\n");
22                 HUD_Write_Cvar("hud_skin");
23                 HUD_Write_Cvar("hud_panel_bg");
24                 HUD_Write_Cvar("hud_panel_bg_color");
25                 HUD_Write_Cvar("hud_panel_bg_color_team");
26                 HUD_Write_Cvar("hud_panel_bg_alpha");
27                 HUD_Write_Cvar("hud_panel_bg_border");
28                 HUD_Write_Cvar("hud_panel_bg_padding");
29                 HUD_Write_Cvar("hud_panel_fg_alpha");
30                 HUD_Write("\n");
31
32                 HUD_Write_Cvar("hud_dock");
33                 HUD_Write_Cvar("hud_dock_color");
34                 HUD_Write_Cvar("hud_dock_color_team");
35                 HUD_Write_Cvar("hud_dock_alpha");
36                 HUD_Write("\n");
37
38                 HUD_Write_Cvar("hud_progressbar_alpha");
39                 HUD_Write_Cvar("hud_progressbar_strength_color");
40                 HUD_Write_Cvar("hud_progressbar_superweapons_color");
41                 HUD_Write_Cvar("hud_progressbar_shield_color");
42                 HUD_Write_Cvar("hud_progressbar_health_color");
43                 HUD_Write_Cvar("hud_progressbar_armor_color");
44                 HUD_Write_Cvar("hud_progressbar_fuel_color");
45                 HUD_Write_Cvar("hud_progressbar_oxygen_color");
46                 HUD_Write_Cvar("hud_progressbar_nexball_color");
47                 HUD_Write_Cvar("hud_progressbar_speed_color");
48                 HUD_Write_Cvar("hud_progressbar_acceleration_color");
49                 HUD_Write_Cvar("hud_progressbar_acceleration_neg_color");
50                 HUD_Write_Cvar("hud_progressbar_vehicles_ammo1_color");
51                 HUD_Write_Cvar("hud_progressbar_vehicles_ammo2_color");
52                 HUD_Write("\n");
53
54                 HUD_Write_Cvar("_hud_panelorder");
55                 HUD_Write("\n");
56
57                 HUD_Write_Cvar("hud_configure_grid");
58                 HUD_Write_Cvar("hud_configure_grid_xsize");
59                 HUD_Write_Cvar("hud_configure_grid_ysize");
60                 HUD_Write("\n");
61
62                 // common cvars for all panels
63                 for (int i = 0; i < hud_panels_COUNT; ++i)
64                 {
65                         panel = hud_panels_from(i);
66
67                         HUD_Write_PanelCvar("_pos");
68                         HUD_Write_PanelCvar("_size");
69                         HUD_Write_PanelCvar("_bg");
70                         HUD_Write_PanelCvar("_bg_color");
71                         HUD_Write_PanelCvar("_bg_color_team");
72                         HUD_Write_PanelCvar("_bg_alpha");
73                         HUD_Write_PanelCvar("_bg_border");
74                         HUD_Write_PanelCvar("_bg_padding");
75                         panel.panel_export(panel, fh);
76                         HUD_Write("\n");
77                 }
78                 MUTATOR_CALLHOOK(HUD_WriteCvars, fh);
79
80                 HUD_Write("menu_sync\n"); // force the menu to reread the cvars, so that the dialogs are updated
81
82                 LOG_INFOF(_("^2Successfully exported to %s! (Note: It's saved in data/data/)"), filename);
83                 fclose(fh);
84         }
85         else
86                 LOG_INFOF(_("^1Couldn't write to %s"), filename);
87 }
88
89 void HUD_Configure_Exit_Force()
90 {
91         if (hud_configure_menu_open)
92         {
93                 hud_configure_menu_open = 0;
94                 localcmd("togglemenu\n");
95         }
96         cursor_type = CURSOR_NORMAL;
97         cvar_set("_hud_configure", "0");
98 }
99
100 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
101 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
102 {
103         vector myCenter, targCenter;
104         vector myTarget = myPos;
105         int i;
106         for (i = 0; i < hud_panels_COUNT; ++i) {
107                 panel = hud_panels_from(i);
108                 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
109                 if(panel == highlightedPanel) continue;
110                 HUD_Panel_UpdatePosSize();
111                 if(!panel_enabled) continue;
112
113                 panel_pos -= '1 1 0' * panel_bg_border;
114                 panel_size += '2 2 0' * panel_bg_border;
115
116                 if(myPos.y + mySize.y < panel_pos.y)
117                         continue;
118                 if(myPos.y > panel_pos.y + panel_size.y)
119                         continue;
120
121                 if(myPos.x + mySize.x < panel_pos.x)
122                         continue;
123                 if(myPos.x > panel_pos.x + panel_size.x)
124                         continue;
125
126                 // OK, there IS a collision.
127
128                 myCenter.x = myPos.x + 0.5 * mySize.x;
129                 myCenter.y = myPos.y + 0.5 * mySize.y;
130
131                 targCenter.x = panel_pos.x + 0.5 * panel_size.x;
132                 targCenter.y = panel_pos.y + 0.5 * panel_size.y;
133
134                 if(myCenter.x < targCenter.x && myCenter.y < targCenter.y) // top left (of the target panel)
135                 {
136                         if(myPos.x + mySize.x - panel_pos.x < myPos.y + mySize.y - panel_pos.y) // push it to the side
137                                 myTarget.x = panel_pos.x - mySize.x;
138                         else // push it upwards
139                                 myTarget.y = panel_pos.y - mySize.y;
140                 }
141                 else if(myCenter.x > targCenter.x && myCenter.y < targCenter.y) // top right
142                 {
143                         if(panel_pos.x + panel_size.x - myPos.x < myPos.y + mySize.y - panel_pos.y) // push it to the side
144                                 myTarget.x = panel_pos.x + panel_size.x;
145                         else // push it upwards
146                                 myTarget.y = panel_pos.y - mySize.y;
147                 }
148                 else if(myCenter.x < targCenter.x && myCenter.y > targCenter.y) // bottom left
149                 {
150                         if(myPos.x + mySize.x - panel_pos.x < panel_pos.y + panel_size.y - myPos.y) // push it to the side
151                                 myTarget.x = panel_pos.x - mySize.x;
152                         else // push it downwards
153                                 myTarget.y = panel_pos.y + panel_size.y;
154                 }
155                 else if(myCenter.x > targCenter.x && myCenter.y > targCenter.y) // bottom right
156                 {
157                         if(panel_pos.x + panel_size.x - myPos.x < panel_pos.y + panel_size.y - myPos.y) // push it to the side
158                                 myTarget.x = panel_pos.x + panel_size.x;
159                         else // push it downwards
160                                 myTarget.y = panel_pos.y + panel_size.y;
161                 }
162                 //if(cvar("hud_configure_checkcollisions_debug"))
163                         //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
164         }
165
166         return myTarget;
167 }
168
169 void HUD_Panel_SetPos(vector pos)
170 {
171         panel = highlightedPanel;
172         HUD_Panel_UpdatePosSize();
173         vector mySize;
174         mySize = panel_size;
175
176         //if(cvar("hud_configure_checkcollisions_debug"))
177                 //drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
178
179         if(autocvar_hud_configure_grid)
180         {
181                 pos.x = floor((pos.x/vid_conwidth)/hud_configure_gridSize.x + 0.5) * hud_configure_realGridSize.x;
182                 pos.y = floor((pos.y/vid_conheight)/hud_configure_gridSize.y + 0.5) * hud_configure_realGridSize.y;
183         }
184
185         if(hud_configure_checkcollisions)
186                 pos = HUD_Panel_CheckMove(pos, mySize);
187
188         pos.x = bound(0, pos.x, vid_conwidth - mySize.x);
189         pos.y = bound(0, pos.y, vid_conheight - mySize.y);
190
191         string s;
192         s = strcat(ftos(pos.x/vid_conwidth), " ", ftos(pos.y/vid_conheight));
193
194         cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_pos"), s);
195 }
196
197 // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
198 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
199         vector targEndPos;
200         vector dist;
201         float ratio = mySize.x/mySize.y;
202         int i;
203         for (i = 0; i < hud_panels_COUNT; ++i) {
204                 panel = hud_panels_from(i);
205                 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
206                 if(panel == highlightedPanel) continue;
207                 HUD_Panel_UpdatePosSize();
208                 if(!panel_enabled) continue;
209
210                 panel_pos -= '1 1 0' * panel_bg_border;
211                 panel_size += '2 2 0' * panel_bg_border;
212
213                 targEndPos = panel_pos + panel_size;
214
215                 // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
216                 if(resizeorigin.x > panel_pos.x && resizeorigin.x < targEndPos.x && resizeorigin.y > panel_pos.y && resizeorigin.y < targEndPos.y)
217                         continue;
218
219                 if (resizeCorner == 1)
220                 {
221                         // check if this panel is on our way
222                         if (resizeorigin.x <= panel_pos.x)
223                                 continue;
224                         if (resizeorigin.y <= panel_pos.y)
225                                 continue;
226                         if (targEndPos.x <= resizeorigin.x - mySize.x)
227                                 continue;
228                         if (targEndPos.y <= resizeorigin.y - mySize.y)
229                                 continue;
230
231                         // there is a collision:
232                         // detect which side of the panel we are facing is actually limiting the resizing
233                         // (which side the resize direction finds for first) and reduce the size up to there
234                         //
235                         // dist is the distance between resizeorigin and the "analogous" point of the panel
236                         // in this case between resizeorigin (bottom-right point) and the bottom-right point of the panel
237                         dist.x = resizeorigin.x - targEndPos.x;
238                         dist.y = resizeorigin.y - targEndPos.y;
239                         if (dist.y <= 0 || dist.x / dist.y > ratio)
240                                 mySize.x = min(mySize.x, dist.x);
241                         else
242                                 mySize.y = min(mySize.y, dist.y);
243                 }
244                 else if (resizeCorner == 2)
245                 {
246                         if (resizeorigin.x >= targEndPos.x)
247                                 continue;
248                         if (resizeorigin.y <= panel_pos.y)
249                                 continue;
250                         if (panel_pos.x >= resizeorigin.x + mySize.x)
251                                 continue;
252                         if (targEndPos.y <= resizeorigin.y - mySize.y)
253                                 continue;
254
255                         dist.x = panel_pos.x - resizeorigin.x;
256                         dist.y = resizeorigin.y - targEndPos.y;
257                         if (dist.y <= 0 || dist.x / dist.y > ratio)
258                                 mySize.x = min(mySize.x, dist.x);
259                         else
260                                 mySize.y = min(mySize.y, dist.y);
261                 }
262                 else if (resizeCorner == 3)
263                 {
264                         if (resizeorigin.x <= panel_pos.x)
265                                 continue;
266                         if (resizeorigin.y >= targEndPos.y)
267                                 continue;
268                         if (targEndPos.x <= resizeorigin.x - mySize.x)
269                                 continue;
270                         if (panel_pos.y >= resizeorigin.y + mySize.y)
271                                 continue;
272
273                         dist.x = resizeorigin.x - targEndPos.x;
274                         dist.y = panel_pos.y - resizeorigin.y;
275                         if (dist.y <= 0 || dist.x / dist.y > ratio)
276                                 mySize.x = min(mySize.x, dist.x);
277                         else
278                                 mySize.y = min(mySize.y, dist.y);
279                 }
280                 else if (resizeCorner == 4)
281                 {
282                         if (resizeorigin.x >= targEndPos.x)
283                                 continue;
284                         if (resizeorigin.y >= targEndPos.y)
285                                 continue;
286                         if (panel_pos.x >= resizeorigin.x + mySize.x)
287                                 continue;
288                         if (panel_pos.y >= resizeorigin.y + mySize.y)
289                                 continue;
290
291                         dist.x = panel_pos.x - resizeorigin.x;
292                         dist.y = panel_pos.y - resizeorigin.y;
293                         if (dist.y <= 0 || dist.x / dist.y > ratio)
294                                 mySize.x = min(mySize.x, dist.x);
295                         else
296                                 mySize.y = min(mySize.y, dist.y);
297                 }
298                 //if(cvar("hud_configure_checkcollisions_debug"))
299                         //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
300         }
301
302         return mySize;
303 }
304
305 void HUD_Panel_SetPosSize(vector mySize)
306 {
307         panel = highlightedPanel;
308         HUD_Panel_UpdatePosSize();
309         vector resizeorigin = panel_click_resizeorigin;
310         vector myPos;
311
312         // minimum panel size cap
313         mySize.x = max(0.025 * vid_conwidth, mySize.x);
314         mySize.y = max(0.025 * vid_conheight, mySize.y);
315
316         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.
317         {
318                 mySize.x = max(17 * autocvar_con_chatsize, mySize.x);
319                 mySize.y = max(2 * autocvar_con_chatsize + 2 * panel_bg_padding, mySize.y);
320         }
321
322         // collision testing|
323         // -----------------+
324
325         // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
326         if(resizeCorner == 1) {
327                 myPos.x = resizeorigin.x - mySize.x;
328                 myPos.y = resizeorigin.y - mySize.y;
329         } else if(resizeCorner == 2) {
330                 myPos.x = resizeorigin.x;
331                 myPos.y = resizeorigin.y - mySize.y;
332         } else if(resizeCorner == 3) {
333                 myPos.x = resizeorigin.x - mySize.x;
334                 myPos.y = resizeorigin.y;
335         } else { // resizeCorner == 4
336                 myPos.x = resizeorigin.x;
337                 myPos.y = resizeorigin.y;
338         }
339
340         // left/top screen edges
341         if(myPos.x < 0)
342                 mySize.x = mySize.x + myPos.x;
343         if(myPos.y < 0)
344                 mySize.y = mySize.y + myPos.y;
345
346         // bottom/right screen edges
347         if(myPos.x + mySize.x > vid_conwidth)
348                 mySize.x = vid_conwidth - myPos.x;
349         if(myPos.y + mySize.y > vid_conheight)
350                 mySize.y = vid_conheight - myPos.y;
351
352         //if(cvar("hud_configure_checkcollisions_debug"))
353                 //drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
354
355         // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
356         if(autocvar_hud_configure_grid)
357         {
358                 mySize.x = floor((mySize.x/vid_conwidth)/hud_configure_gridSize.x + 0.5) * hud_configure_realGridSize.x;
359                 mySize.y = floor((mySize.y/vid_conheight)/hud_configure_gridSize.y + 0.5) * hud_configure_realGridSize.y;
360         }
361
362         if(hud_configure_checkcollisions)
363                 mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
364
365         // 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)
366         mySize.x = max(0.025 * vid_conwidth, mySize.x);
367         mySize.y = max(0.025 * vid_conheight, mySize.y);
368
369         // do another pos check, as size might have changed by now
370         if(resizeCorner == 1) {
371                 myPos.x = resizeorigin.x - mySize.x;
372                 myPos.y = resizeorigin.y - mySize.y;
373         } else if(resizeCorner == 2) {
374                 myPos.x = resizeorigin.x;
375                 myPos.y = resizeorigin.y - mySize.y;
376         } else if(resizeCorner == 3) {
377                 myPos.x = resizeorigin.x - mySize.x;
378                 myPos.y = resizeorigin.y;
379         } else { // resizeCorner == 4
380                 myPos.x = resizeorigin.x;
381                 myPos.y = resizeorigin.y;
382         }
383
384         //if(cvar("hud_configure_checkcollisions_debug"))
385                 //drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
386
387         string s;
388         s = strcat(ftos(mySize.x/vid_conwidth), " ", ftos(mySize.y/vid_conheight));
389         cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_size"), s);
390
391         s = strcat(ftos(myPos.x/vid_conwidth), " ", ftos(myPos.y/vid_conheight));
392         cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_pos"), s);
393 }
394
395 float pressed_key_time;
396 vector highlightedPanel_initial_pos, highlightedPanel_initial_size;
397 void HUD_Panel_Arrow_Action(float nPrimary)
398 {
399         if(!highlightedPanel)
400                 return;
401
402         hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
403
404         float step;
405         if(autocvar_hud_configure_grid)
406         {
407                 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
408                 {
409                         if (hudShiftState & S_SHIFT)
410                                 step = hud_configure_realGridSize.y;
411                         else
412                                 step = 2 * hud_configure_realGridSize.y;
413                 }
414                 else
415                 {
416                         if (hudShiftState & S_SHIFT)
417                                 step = hud_configure_realGridSize.x;
418                         else
419                                 step = 2 * hud_configure_realGridSize.x;
420                 }
421         }
422         else
423         {
424                 if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
425                         step = vid_conheight;
426                 else
427                         step = vid_conwidth;
428                 if (hudShiftState & S_SHIFT)
429                         step = (step / 256); // more precision
430                 else
431                         step = (step / 64) * (1 + 2 * (time - pressed_key_time));
432         }
433
434         panel = highlightedPanel;
435         HUD_Panel_UpdatePosSize();
436
437         highlightedPanel_initial_pos = panel_pos;
438         highlightedPanel_initial_size = panel_size;
439
440         if (hudShiftState & S_ALT) // resize
441         {
442                 if(nPrimary == K_UPARROW)
443                         resizeCorner = 1;
444                 else if(nPrimary == K_RIGHTARROW)
445                         resizeCorner = 2;
446                 else if(nPrimary == K_LEFTARROW)
447                         resizeCorner = 3;
448                 else // if(nPrimary == K_DOWNARROW)
449                         resizeCorner = 4;
450
451                 // ctrl+arrow reduces the size, instead of increasing it
452                 // Note that ctrl disables collisions check too, but it's fine
453                 // since we don't collide with anything reducing the size
454                 if (hudShiftState & S_CTRL) {
455                         step = -step;
456                         resizeCorner = 5 - resizeCorner;
457                 }
458
459                 vector mySize;
460                 mySize = panel_size;
461                 panel_click_resizeorigin = panel_pos;
462                 if(resizeCorner == 1) {
463                         panel_click_resizeorigin += mySize;
464                         mySize.y += step;
465                 } else if(resizeCorner == 2) {
466                         panel_click_resizeorigin.y += mySize.y;
467                         mySize.x += step;
468                 } else if(resizeCorner == 3) {
469                         panel_click_resizeorigin.x += mySize.x;
470                         mySize.x += step;
471                 } else { // resizeCorner == 4
472                         mySize.y += step;
473                 }
474                 HUD_Panel_SetPosSize(mySize);
475         }
476         else // move
477         {
478                 vector pos;
479                 pos = panel_pos;
480                 if(nPrimary == K_UPARROW)
481                         pos.y -= step;
482                 else if(nPrimary == K_DOWNARROW)
483                         pos.y += step;
484                 else if(nPrimary == K_LEFTARROW)
485                         pos.x -= step;
486                 else // if(nPrimary == K_RIGHTARROW)
487                         pos.x += step;
488
489                 HUD_Panel_SetPos(pos);
490         }
491
492         panel = highlightedPanel;
493         HUD_Panel_UpdatePosSize();
494
495         if (highlightedPanel_initial_pos != panel_pos || highlightedPanel_initial_size != panel_size)
496         {
497                 // backup!
498                 panel_pos_backup = highlightedPanel_initial_pos;
499                 panel_size_backup = highlightedPanel_initial_size;
500                 highlightedPanel_backup = highlightedPanel;
501         }
502 }
503
504 entity tab_panels[hud_panels_MAX];
505 entity tab_panel;
506 vector tab_panel_pos;
507 float tab_backward;
508 void reset_tab_panels()
509 {
510         for (int i = 0; i < hud_panels_COUNT; ++i)
511                 tab_panels[i] = NULL;
512 }
513 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
514 {
515         string s;
516
517         if(bInputType == 2)
518                 return false;
519
520         if(!autocvar__hud_configure)
521                 return false;
522
523         if(bInputType == 3)
524         {
525                 mousepos.x = nPrimary;
526                 mousepos.y = nSecondary;
527                 return true;
528         }
529
530         // block any input while a menu dialog is fading
531         // don't block mousepos read as it leads to cursor jumps in the interaction with the menu
532         if(autocvar__menu_alpha)
533         {
534                 hudShiftState = 0;
535                 mouseClicked = 0;
536                 return true;
537         }
538
539         // allow console bind to work
540         string con_keys = findkeysforcommand("toggleconsole", 0);
541         int keys = tokenize(con_keys); // findkeysforcommand returns data for this
542
543         bool hit_con_bind = false;
544         int i;
545         for (i = 0; i < keys; ++i)
546         {
547                 if(nPrimary == stof(argv(i)))
548                         hit_con_bind = true;
549         }
550
551         if(bInputType == 0) {
552                 if(nPrimary == K_ALT) hudShiftState |= S_ALT;
553                 if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
554                 if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
555         }
556         else if(bInputType == 1) {
557                 if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
558                 if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
559                 if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
560         }
561
562         if(nPrimary == K_CTRL)
563         {
564                 if (bInputType == 1) //ctrl has been released
565                 {
566                         if (tab_panel)
567                         {
568                                 //switch to selected panel
569                                 highlightedPanel = tab_panel;
570                                 highlightedAction = 0;
571                                 HUD_Panel_FirstInDrawQ(highlightedPanel.panel_id);
572                         }
573                         tab_panel = NULL;
574                         reset_tab_panels();
575                 }
576         }
577
578         if(nPrimary == K_MOUSE1)
579         {
580                 if(bInputType == 0) // key pressed
581                         mouseClicked |= S_MOUSE1;
582                 else if(bInputType == 1) // key released
583                         mouseClicked -= (mouseClicked & S_MOUSE1);
584         }
585         else if(nPrimary == K_MOUSE2)
586         {
587                 if(bInputType == 0) // key pressed
588                         mouseClicked |= S_MOUSE2;
589                 else if(bInputType == 1) // key released
590                         mouseClicked -= (mouseClicked & S_MOUSE2);
591         }
592         else if(nPrimary == K_ESCAPE)
593         {
594                 if (bInputType == 1)
595                         return true;
596                 hud_configure_menu_open = 1;
597                 localcmd("menu_showhudexit\n");
598         }
599         else if(nPrimary == K_BACKSPACE && hudShiftState & S_CTRL)
600         {
601                 if (bInputType == 1)
602                         return true;
603                 if (!hud_configure_menu_open)
604                         HUD_Configure_Exit_Force();
605         }
606         else if(nPrimary == K_TAB && hudShiftState & S_CTRL) // switch panel
607         {
608                 if (bInputType == 1 || mouseClicked)
609                         return true;
610
611                 // FIXME minor bug: if a panel is highlighted, has the same pos_x and
612                 // lays in the same level of another panel then the next consecutive
613                 // CTRL TAB presses will reselect once more the highlighted panel
614
615                 entity starting_panel;
616                 entity old_tab_panel = tab_panel;
617                 if (!tab_panel) //first press of TAB
618                 {
619                         if (highlightedPanel)
620                         {
621                                 panel = highlightedPanel;
622                                 HUD_Panel_UpdatePosSize();
623                         }
624                         else
625                                 panel_pos = '0 0 0';
626                         starting_panel = highlightedPanel;
627                         tab_panel_pos = panel_pos; //to compute level
628                 }
629                 else
630                 {
631                         if ( ((!tab_backward) && (hudShiftState & S_SHIFT)) || (tab_backward && !(hudShiftState & S_SHIFT)) ) //tab direction changed?
632                                 reset_tab_panels();
633                         starting_panel = tab_panel;
634                 }
635                 tab_backward = (hudShiftState & S_SHIFT);
636
637                 float k, level = 0, start_posX;
638                 vector candidate_pos = '0 0 0';
639                 const float LEVELS_NUM = 4;
640                 float level_height = vid_conheight / LEVELS_NUM;
641 LABEL(find_tab_panel)
642                 level = floor(tab_panel_pos.y / level_height) * level_height; //starting level
643                 candidate_pos.x = (!tab_backward) ? vid_conwidth : 0;
644                 start_posX = tab_panel_pos.x;
645                 tab_panel = NULL;
646                 k=0;
647                 while(++k)
648                 {
649                         for(i = 0; i < hud_panels_COUNT; ++i)
650                         {
651                                 panel = hud_panels_from(i);
652                                 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN))
653                                         continue;
654                                 if (panel == tab_panels[i] || panel == starting_panel)
655                                         continue;
656                                 HUD_Panel_UpdatePosSize();
657                                 if (panel_pos.y >= level && (panel_pos.y - level) < level_height)
658                                 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)) )
659                                         || ( 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)) )  )
660                                 {
661                                         tab_panel = panel;
662                                         tab_panel_pos = candidate_pos = panel_pos;
663                                 }
664                         }
665                         if (tab_panel)
666                                 break;
667                         if (k == LEVELS_NUM) //tab_panel not found
668                         {
669                                 reset_tab_panels();
670                                 if (!old_tab_panel)
671                                 {
672                                         tab_panel = NULL;
673                                         return true;
674                                 }
675                                 starting_panel = old_tab_panel;
676                                 old_tab_panel = NULL;
677                                 goto find_tab_panel; //u must find tab_panel!
678                         }
679                         if (!tab_backward)
680                         {
681                                 level = (level + level_height) % vid_conheight;
682                                 start_posX = 0;
683                                 candidate_pos.x = vid_conwidth;
684                         }
685                         else
686                         {
687                                 level = (level - level_height) % vid_conheight;
688                                 start_posX = vid_conwidth;
689                                 candidate_pos.x = 0;
690                         }
691                 }
692
693                 tab_panels[tab_panel.panel_id] = tab_panel;
694         }
695         else if(nPrimary == K_SPACE && hudShiftState & S_CTRL) // enable/disable highlighted panel or dock
696         {
697                 if (bInputType == 1 || mouseClicked)
698                         return true;
699
700                 if (highlightedPanel)
701                 {
702                         if(panel.panel_configflags & PANEL_CONFIG_CANBEOFF)
703                                 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name), ftos(!cvar(strcat("hud_panel_", highlightedPanel.panel_name))));
704                 }
705                 else
706                         cvar_set(strcat("hud_dock"), (autocvar_hud_dock == "") ? "dock" : "");
707         }
708         else if(nPrimary == 'c' && hudShiftState & S_CTRL) // copy highlighted panel size
709         {
710                 if (bInputType == 1 || mouseClicked)
711                         return true;
712
713                 if (highlightedPanel)
714                 {
715                         panel = highlightedPanel;
716                         HUD_Panel_UpdatePosSize();
717                         panel_size_copied = panel_size;
718                 }
719         }
720         else if(nPrimary == 'v' && hudShiftState & S_CTRL) // past copied size on the highlighted panel
721         {
722                 if (bInputType == 1 || mouseClicked)
723                         return true;
724
725                 if (panel_size_copied == '0 0 0' || !highlightedPanel)
726                         return true;
727
728                 panel = highlightedPanel;
729                 HUD_Panel_UpdatePosSize();
730
731                 // reduce size if it'd go beyond screen boundaries
732                 vector tmp_size = panel_size_copied;
733                 if (panel_pos.x + panel_size_copied.x > vid_conwidth)
734                         tmp_size.x = vid_conwidth - panel_pos.x;
735                 if (panel_pos.y + panel_size_copied.y > vid_conheight)
736                         tmp_size.y = vid_conheight - panel_pos.y;
737
738                 if (panel_size == tmp_size)
739                         return true;
740
741                 // backup first!
742                 panel_pos_backup = panel_pos;
743                 panel_size_backup = panel_size;
744                 highlightedPanel_backup = highlightedPanel;
745
746                 s = strcat(ftos(tmp_size.x/vid_conwidth), " ", ftos(tmp_size.y/vid_conheight));
747                 cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_size"), s);
748         }
749         else if(nPrimary == 'z' && hudShiftState & S_CTRL) // undo last action
750         {
751                 if (bInputType == 1 || mouseClicked)
752                         return true;
753                 //restore previous values
754                 if (highlightedPanel_backup)
755                 {
756                         s = strcat(ftos(panel_pos_backup.x/vid_conwidth), " ", ftos(panel_pos_backup.y/vid_conheight));
757                         cvar_set(strcat("hud_panel_", highlightedPanel_backup.panel_name, "_pos"), s);
758                         s = strcat(ftos(panel_size_backup.x/vid_conwidth), " ", ftos(panel_size_backup.y/vid_conheight));
759                         cvar_set(strcat("hud_panel_", highlightedPanel_backup.panel_name, "_size"), s);
760                         highlightedPanel_backup = NULL;
761                 }
762         }
763         else if(nPrimary == 's' && hudShiftState & S_CTRL) // save config
764         {
765                 if (bInputType == 1 || mouseClicked)
766                         return true;
767                 localcmd("hud save myconfig\n");
768         }
769         else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
770         {
771                 if (bInputType == 1)
772                 {
773                         pressed_key_time = 0;
774                         return true;
775                 }
776                 else if (pressed_key_time == 0)
777                         pressed_key_time = time;
778
779                 if (!mouseClicked)
780                         HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
781         }
782         else if(nPrimary == K_ENTER || nPrimary == K_SPACE || nPrimary == K_KP_ENTER)
783         {
784                 if (bInputType == 1)
785                         return true;
786                 if (highlightedPanel)
787                         HUD_Panel_EnableMenu();
788         }
789         else if(hit_con_bind || nPrimary == K_PAUSE)
790                 return false;
791
792         return true;
793 }
794
795 int HUD_Panel_Check_Mouse_Pos(bool allow_move)
796 {
797         int i, j = 0;
798         while(j < hud_panels_COUNT)
799         {
800                 i = panel_order[j];
801                 j += 1;
802
803                 panel = hud_panels_from(i);
804                 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
805                 HUD_Panel_UpdatePosSize();
806
807                 float border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
808
809                 // move
810                 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)
811                 {
812                         return CURSOR_MOVE;
813                 }
814                 // resize from topleft border
815                 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)
816                 {
817                         return CURSOR_RESIZE;
818                 }
819                 // resize from topright border
820                 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)
821                 {
822                         return CURSOR_RESIZE2;
823                 }
824                 // resize from bottomleft border
825                 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)
826                 {
827                         return CURSOR_RESIZE2;
828                 }
829                 // resize from bottomright border
830                 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)
831                 {
832                         return CURSOR_RESIZE;
833                 }
834         }
835         return CURSOR_NORMAL;
836 }
837
838 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
839 void HUD_Panel_FirstInDrawQ(float id)
840 {
841         int i;
842         int place = -1;
843         // find out where in the array our current id is, save into place
844         for(i = 0; i < hud_panels_COUNT; ++i)
845         {
846                 if(panel_order[i] == id)
847                 {
848                         place = i;
849                         break;
850                 }
851         }
852         // place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
853         if(place == -1)
854                 place = hud_panels_COUNT - 1;
855
856         // move all ids up by one step in the array until "place"
857         for(i = place; i > 0; --i)
858         {
859                 panel_order[i] = panel_order[i-1];
860         }
861         // now save the new top id
862         panel_order[0] = id;
863
864         // let's save them into the cvar by some strcat trickery
865         string s = "";
866         for(i = 0; i < hud_panels_COUNT; ++i)
867         {
868                 s = strcat(s, ftos(panel_order[i]), " ");
869         }
870         cvar_set("_hud_panelorder", s);
871         strcpy(hud_panelorder_prev, autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
872 }
873
874 void HUD_Panel_Highlight(float allow_move)
875 {
876         int i, j = 0;
877
878         while(j < hud_panels_COUNT)
879         {
880                 i = panel_order[j];
881                 j += 1;
882
883                 panel = hud_panels_from(i);
884                 if(!(panel.panel_configflags & PANEL_CONFIG_MAIN))
885                         continue;
886                 HUD_Panel_UpdatePosSize();
887
888                 float border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
889
890                 // move
891                 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)
892                 {
893                         highlightedPanel = hud_panels_from(i);
894                         HUD_Panel_FirstInDrawQ(i);
895                         highlightedAction = 1;
896                         panel_click_distance = mousepos - panel_pos;
897                         return;
898                 }
899                 // resize from topleft border
900                 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)
901                 {
902                         highlightedPanel = hud_panels_from(i);
903                         HUD_Panel_FirstInDrawQ(i);
904                         highlightedAction = 2;
905                         resizeCorner = 1;
906                         panel_click_distance = mousepos - panel_pos;
907                         panel_click_resizeorigin = panel_pos + panel_size;
908                         return;
909                 }
910                 // resize from topright border
911                 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)
912                 {
913                         highlightedPanel = hud_panels_from(i);
914                         HUD_Panel_FirstInDrawQ(i);
915                         highlightedAction = 2;
916                         resizeCorner = 2;
917                         panel_click_distance.x = panel_size.x - mousepos.x + panel_pos.x;
918                         panel_click_distance.y = mousepos.y - panel_pos.y;
919                         panel_click_resizeorigin = panel_pos + eY * panel_size.y;
920                         return;
921                 }
922                 // resize from bottomleft border
923                 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)
924                 {
925                         highlightedPanel = hud_panels_from(i);
926                         HUD_Panel_FirstInDrawQ(i);
927                         highlightedAction = 2;
928                         resizeCorner = 3;
929                         panel_click_distance.x = mousepos.x - panel_pos.x;
930                         panel_click_distance.y = panel_size.y - mousepos.y + panel_pos.y;
931                         panel_click_resizeorigin = panel_pos + eX * panel_size.x;
932                         return;
933                 }
934                 // resize from bottomright border
935                 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)
936                 {
937                         highlightedPanel = hud_panels_from(i);
938                         HUD_Panel_FirstInDrawQ(i);
939                         highlightedAction = 2;
940                         resizeCorner = 4;
941                         panel_click_distance = panel_size - mousepos + panel_pos;
942                         panel_click_resizeorigin = panel_pos;
943                         return;
944                 }
945         }
946         highlightedPanel = NULL;
947         highlightedAction = 0;
948 }
949
950 void HUD_Panel_EnableMenu()
951 {
952         hud_configure_menu_open = 2;
953         localcmd("menu_showhudoptions ", highlightedPanel.panel_name, "\n");
954 }
955 void HUD_Panel_Mouse()
956 {
957         if(autocvar__menu_alpha == 1)
958                 return;
959
960         if(mouseClicked)
961         {
962                 if(prevMouseClicked == 0)
963                 {
964                         if (tab_panel)
965                         {
966                                 //stop ctrl-tab selection
967                                 tab_panel = NULL;
968                                 reset_tab_panels();
969                         }
970                         HUD_Panel_Highlight(mouseClicked & S_MOUSE1); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
971                                                                         // and calls HUD_Panel_UpdatePosSize() for the highlighted panel
972                         if (highlightedPanel)
973                         {
974                                 highlightedPanel_initial_pos = panel_pos;
975                                 highlightedPanel_initial_size = panel_size;
976                         }
977                         // doubleclick check
978                         if ((mouseClicked & S_MOUSE1) && time - prevMouseClickedTime < 0.4 && highlightedPanel && prevMouseClickedPos == mousepos)
979                         {
980                                 mouseClicked = 0; // to prevent spam, I guess.
981                                 HUD_Panel_EnableMenu();
982                         }
983                         else
984                         {
985                                 if (mouseClicked & S_MOUSE1)
986                                 {
987                                         prevMouseClickedTime = time;
988                                         prevMouseClickedPos = mousepos;
989                                 }
990                                 cursor_type = HUD_Panel_Check_Mouse_Pos(mouseClicked & S_MOUSE1);
991                         }
992                 }
993                 else
994                 {
995                         panel = highlightedPanel;
996                         HUD_Panel_UpdatePosSize();
997                 }
998
999                 if (highlightedPanel)
1000                 {
1001                         drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .1, DRAWFLAG_NORMAL);
1002                         if (highlightedPanel_initial_pos != panel_pos || highlightedPanel_initial_size != panel_size)
1003                         {
1004                                 hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
1005                                 // backup!
1006                                 panel_pos_backup = highlightedPanel_initial_pos;
1007                                 panel_size_backup = highlightedPanel_initial_size;
1008                                 highlightedPanel_backup = highlightedPanel;
1009                         }
1010                         else
1011                                 // in case the clicked panel is inside another panel and we aren't
1012                                 // moving it, avoid the immediate "fix" of its position/size
1013                                 // (often unwanted and hateful) by disabling collisions check
1014                                 hud_configure_checkcollisions = false;
1015                 }
1016
1017                 if(highlightedAction == 1)
1018                         HUD_Panel_SetPos(mousepos - panel_click_distance);
1019                 else if(highlightedAction == 2)
1020                 {
1021                         vector mySize = '0 0 0';
1022                         if(resizeCorner == 1) {
1023                                 mySize.x = panel_click_resizeorigin.x - (mousepos.x - panel_click_distance.x);
1024                                 mySize.y = panel_click_resizeorigin.y - (mousepos.y - panel_click_distance.y);
1025                         } else if(resizeCorner == 2) {
1026                                 mySize.x = mousepos.x + panel_click_distance.x - panel_click_resizeorigin.x;
1027                                 mySize.y = panel_click_distance.y + panel_click_resizeorigin.y - mousepos.y;
1028                         } else if(resizeCorner == 3) {
1029                                 mySize.x = panel_click_resizeorigin.x + panel_click_distance.x - mousepos.x;
1030                                 mySize.y = mousepos.y + panel_click_distance.y - panel_click_resizeorigin.y;
1031                         } else { // resizeCorner == 4
1032                                 mySize.x = mousepos.x - (panel_click_resizeorigin.x - panel_click_distance.x);
1033                                 mySize.y = mousepos.y - (panel_click_resizeorigin.y - panel_click_distance.y);
1034                         }
1035                         HUD_Panel_SetPosSize(mySize);
1036                 }
1037         }
1038         else
1039         {
1040                 if(prevMouseClicked)
1041                         highlightedAction = 0;
1042                 if(hud_configure_menu_open == 2)
1043                         cursor_type = CURSOR_NORMAL;
1044                 else
1045                         cursor_type = HUD_Panel_Check_Mouse_Pos(true);
1046                 if (cursor_type != CURSOR_NORMAL && !tab_panel) // mouse over a panel?
1047                         drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .1, DRAWFLAG_NORMAL);
1048         }
1049 }
1050 void HUD_Configure_DrawGrid()
1051 {
1052         float i;
1053         if(autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
1054         {
1055                 hud_configure_gridSize.x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
1056                 hud_configure_gridSize.y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
1057                 hud_configure_realGridSize.x = hud_configure_gridSize.x * vid_conwidth;
1058                 hud_configure_realGridSize.y = hud_configure_gridSize.y * vid_conheight;
1059                 vector s;
1060                 // x-axis
1061                 s = vec2(1, vid_conheight);
1062                 for(i = 1; i < 1/hud_configure_gridSize.x; ++i)
1063                         drawfill(eX * i * hud_configure_realGridSize.x, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
1064                 // y-axis
1065                 s = vec2(vid_conwidth, 1);
1066                 for(i = 1; i < 1/hud_configure_gridSize.y; ++i)
1067                         drawfill(eY * i * hud_configure_realGridSize.y, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
1068         }
1069 }
1070
1071 float _menu_alpha_prev;
1072 void HUD_Configure_Frame()
1073 {
1074         int i;
1075         if(autocvar__hud_configure)
1076         {
1077                 if(isdemo() || intermission == 2 || scoreboard_active)
1078                 {
1079                         HUD_Configure_Exit_Force();
1080                         return;
1081                 }
1082
1083                 if(!hud_configure_prev)
1084                 {
1085                         hudShiftState = 0;
1086                         for(i = hud_panels_COUNT - 1; i >= 0; --i)
1087                                 hud_panels_from(panel_order[i]).update_time = time;
1088                 }
1089
1090                 // NOTE this check is necessary because _menu_alpha isn't updated the frame the menu gets enabled
1091                 if(autocvar__menu_alpha != _menu_alpha_prev)
1092                 {
1093                         if(autocvar__menu_alpha == 0)
1094                                 hud_configure_menu_open = 0;
1095                         _menu_alpha_prev = autocvar__menu_alpha;
1096                 }
1097
1098                 HUD_Configure_DrawGrid();
1099         }
1100         else if(hud_configure_prev)
1101         {
1102                 if(hud_configure_menu_open)
1103                         hud_configure_menu_open = 0;
1104                 hud_dynamic_shake_factor = -1;
1105         }
1106 }
1107
1108 const float hlBorderSize = 2;
1109 const string hlBorder = "gfx/hud/default/border_highlighted";
1110 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
1111 void HUD_Panel_HlBorder(float myBorder, vector color, float theAlpha)
1112 {
1113         vector pos = panel_pos - vec2(myBorder, myBorder);
1114         drawfill(pos, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * theAlpha, DRAWFLAG_NORMAL);
1115         drawpic_tiled(pos, hlBorder, '8 1 0' * hlBorderSize, vec2(panel_size.x + 2 * myBorder, hlBorderSize), color, theAlpha, DRAWFLAG_NORMAL);
1116         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);
1117         pos.y += hlBorderSize;
1118         drawpic_tiled(pos, hlBorder2, '1 8 0' * hlBorderSize, vec2(hlBorderSize, panel_size.y + 2 * myBorder - 2 * hlBorderSize), color, theAlpha, DRAWFLAG_NORMAL);
1119         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);
1120 }
1121
1122 void HUD_Configure_PostDraw()
1123 {
1124         if(autocvar__hud_configure)
1125         {
1126                 if(tab_panel)
1127                 {
1128                         panel = tab_panel;
1129                         HUD_Panel_UpdatePosSize();
1130                         drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
1131                 }
1132                 if(highlightedPanel)
1133                 {
1134                         panel = highlightedPanel;
1135                         HUD_Panel_UpdatePosSize();
1136                         HUD_Panel_HlBorder(panel_bg_border * hlBorderSize, '0 0.5 1', 0.4 * (1 - autocvar__menu_alpha));
1137                 }
1138         }
1139 }