From 38251b112081c39783eb544fcf5a6dccf45964f3 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sat, 19 Mar 2022 12:35:31 +0100 Subject: [PATCH] HUD editor: find keys for toggleconsole only when needed --- qcsrc/client/hud/hud_config.qc | 31 +++++++++++++++-------------- qcsrc/client/hud/panel/quickmenu.qc | 3 +-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/qcsrc/client/hud/hud_config.qc b/qcsrc/client/hud/hud_config.qc index 818ad0256..78ed8442a 100644 --- a/qcsrc/client/hud/hud_config.qc +++ b/qcsrc/client/hud/hud_config.qc @@ -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; } diff --git a/qcsrc/client/hud/panel/quickmenu.qc b/qcsrc/client/hud/panel/quickmenu.qc index 51f1e7373..245bdad1b 100644 --- a/qcsrc/client/hud/panel/quickmenu.qc +++ b/qcsrc/client/hud/panel/quickmenu.qc @@ -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 -- 2.39.2