]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
HUD config: improve code to detect if a panel dialog has been closed and put it in...
authorterencehill <piuntn@gmail.com>
Sun, 12 May 2013 22:42:45 +0000 (00:42 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 12 May 2013 22:42:45 +0000 (00:42 +0200)
qcsrc/client/hud.qh
qcsrc/client/hud_config.qc

index dba8712f7d01e17903c4126b4d8ee81e3a06491d..39ecc823f44099775233ae19ad506b0bfb0cdfdc 100644 (file)
@@ -47,7 +47,6 @@ const float S_CTRL = 2;
 const float S_ALT = 4;
 
 float menu_enabled; // 1 showing the entire HUD, 2 showing only the clicked panel
-float menu_enabled_time;
 
 float hud_fade_alpha;
 
index f91fd0a8c6773eb0355f57251511714e917d7707..82866b07f7855c128c4f99f3f5f5ef398bbff9e6 100644 (file)
@@ -721,7 +721,6 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
                if (bInputType == 1)
                        return true;
                menu_enabled = 1;
-               menu_enabled_time = time;
                localcmd("menu_showhudexit\n");
        }
        else if(nPrimary == K_BACKSPACE && hudShiftState & S_CTRL)
@@ -1068,22 +1067,11 @@ void HUD_Panel_Highlight(float allow_move)
 void HUD_Panel_EnableMenu()
 {
        menu_enabled = 2;
-       menu_enabled_time = time;
        localcmd("menu_showhudoptions ", highlightedPanel.panel_name, "\n");
 }
 float mouse_over_panel;
 void HUD_Panel_Mouse()
 {
-       // TODO: needs better check... is there any float that contains the current state of the menu? _menu_alpha isn't apparently updated the frame the menu gets enabled
-       if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
-               menu_enabled = 0;
-
-       /*
-       print("menu_enabled: ", ftos(menu_enabled), "\n");
-       print("Highlighted: ", ftos(highlightedPanel), "\n");
-       print("Menu theAlpha: ", ftos(autocvar__menu_alpha), "\n");
-       */
-
        if(autocvar__menu_alpha == 1)
                return;
 
@@ -1218,6 +1206,7 @@ void HUD_Configure_DrawGrid()
        }
 }
 
+float _menu_alpha_prev;
 void HUD_Configure_Frame()
 {
        float i;
@@ -1228,6 +1217,7 @@ void HUD_Configure_Frame()
                        HUD_Configure_Exit_Force();
                        return;
                }
+
                if(!hud_configure_prev || hud_configure_prev == -1)
                {
                        if(autocvar_hud_cursormode)
@@ -1236,6 +1226,15 @@ void HUD_Configure_Frame()
                        for(i = HUD_PANEL_NUM - 1; i >= 0; --i)
                                hud_panel[panel_order[i]].update_time = time;
                }
+
+               // NOTE this check is necessary because _menu_alpha isn't updated the frame the menu gets enabled
+               if(autocvar__menu_alpha != _menu_alpha_prev)
+               {
+                       if(autocvar__menu_alpha == 0)
+                               menu_enabled = 0;
+                       _menu_alpha_prev = autocvar__menu_alpha;
+               }
+
                HUD_Configure_DrawGrid();
        }
        else if(hud_configure_prev)