]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
HUD editor: find keys for toggleconsole only when needed
authorterencehill <piuntn@gmail.com>
Sat, 19 Mar 2022 11:35:31 +0000 (12:35 +0100)
committerterencehill <piuntn@gmail.com>
Sat, 19 Mar 2022 11:35:31 +0000 (12:35 +0100)
qcsrc/client/hud/hud_config.qc
qcsrc/client/hud/panel/quickmenu.qc

index 818ad0256c99771053a77f1917b865bf7a62bf51..78ed8442adecd81d685aaba6d2a183f6c47464bf 100644 (file)
@@ -537,18 +537,8 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
                return true;
        }
 
-       // allow console bind to work
-       string con_keys = findkeysforcommand("toggleconsole", 0);
-       int keys = tokenize(con_keys); // findkeysforcommand returns data for this
-
-       bool hit_con_bind = false;
-       int i;
-       for (i = 0; i < keys; ++i)
-       {
-               if(nPrimary == stof(argv(i)))
-                       hit_con_bind = true;
-       }
-
+       int hudShiftState_prev = hudShiftState;
+       int mouseClicked_prev = mouseClicked;
        if(key_pressed) {
                if(nPrimary == K_ALT) hudShiftState |= S_ALT;
                if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
@@ -629,7 +619,7 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
                vector candidate_pos = '0 0 0';
                const float LEVELS_NUM = 4;
                float level_height = vid_conheight / LEVELS_NUM;
-LABEL(find_tab_panel)
+               LABEL(find_tab_panel)
                level = floor(tab_panel_pos.y / level_height) * level_height; //starting level
                candidate_pos.x = (!tab_backward) ? vid_conwidth : 0;
                start_posX = tab_panel_pos.x;
@@ -637,7 +627,7 @@ LABEL(find_tab_panel)
                k=0;
                while(++k)
                {
-                       for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
+                       for(int i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
                        {
                                panel = REGISTRY_GET(hud_panels, i);
                                if(!(panel.panel_configflags & PANEL_CONFIG_MAIN))
@@ -777,8 +767,19 @@ LABEL(find_tab_panel)
                if (highlightedPanel)
                        HUD_Panel_EnableMenu();
        }
-       else if(hit_con_bind || nPrimary == K_PAUSE)
+       else if(nPrimary == K_PAUSE)
                return false;
+       else if (hudShiftState_prev == hudShiftState && mouseClicked_prev == mouseClicked)
+       {
+               // allow console bind to work
+               string con_keys = findkeysforcommand("toggleconsole", 0);
+               int keys = tokenize(con_keys); // findkeysforcommand returns data for this
+               for (int i = 0; i < keys; ++i)
+               {
+                       if(nPrimary == stof(argv(i)))
+                               return false; // hit console bind
+               }
+       }
 
        return true;
 }
index 51f1e7373f2186177779788513fb8cf8771782c3..245bdad1ba9b3d7178830fc470913ef4222bdc1d 100644 (file)
@@ -481,8 +481,7 @@ bool QuickMenu_InputEvent(int bInputType, float nPrimary, float nSecondary)
                // allow console bind to work
                string con_keys = findkeysforcommand("toggleconsole", 0);
                int keys = tokenize(con_keys); // findkeysforcommand returns data for this
-               int i;
-               for (i = 0; i < keys; ++i)
+               for (int i = 0; i < keys; ++i)
                {
                        if(nPrimary == stof(argv(i)))
                                return false; // hit console bind