From f3443dc32e1c9bb9eb14d12a3722aa1c7a117e9b Mon Sep 17 00:00:00 2001 From: Azumgi <4zumgi@gmail.com> Date: Thu, 1 Nov 2018 12:08:58 +0300 Subject: [PATCH] [Custom Views] More checks for transition handling --- .../mods/vmf/modules/core/keybindings.lua | 2 +- .../mods/vmf/modules/gui/custom_views.lua | 28 +++++++++++-------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/vmf/scripts/mods/vmf/modules/core/keybindings.lua b/vmf/scripts/mods/vmf/modules/core/keybindings.lua index ed3ffcd..9212bc7 100644 --- a/vmf/scripts/mods/vmf/modules/core/keybindings.lua +++ b/vmf/scripts/mods/vmf/modules/core/keybindings.lua @@ -215,7 +215,7 @@ local function perform_keybind_action(data, is_pressed) call_function(data.mod, data.function_name, is_pressed) return true elseif data.type == "view_toggle" and data.mod:is_enabled() then - vmf.keybind_toggle_view(data.view_name, can_perform_action) + vmf.keybind_toggle_view(data.view_name, can_perform_action, is_pressed) return true end end diff --git a/vmf/scripts/mods/vmf/modules/gui/custom_views.lua b/vmf/scripts/mods/vmf/modules/gui/custom_views.lua index eb64089..4e0d19c 100644 --- a/vmf/scripts/mods/vmf/modules/gui/custom_views.lua +++ b/vmf/scripts/mods/vmf/modules/gui/custom_views.lua @@ -101,12 +101,13 @@ end -- ##### VMFMod ######################################################################################################## -- ##################################################################################################################### -function VMFMod:handle_transition(transition_name, transition_params, fade) +function VMFMod:handle_transition(transition_name, transition_params, fade, ignore_active_menu) if _ingame_ui and not _ingame_ui:pending_transition() and not _ingame_ui:end_screen_active() - and not _ingame_ui.menu_active + and (not _ingame_ui.menu_active or ignore_active_menu) and not _ingame_ui.leave_game + and not _ingame_ui.menu_suspended and not _ingame_ui.return_to_title_screen and ( VT1 @@ -178,21 +179,24 @@ function vmf.remove_custom_views() end -function vmf.keybind_toggle_view(view_name, can_be_opened) +function vmf.keybind_toggle_view(view_name, can_be_opened, is_keybind_pressed) --@TODO: check if there's the custom view at all. If not, show error. if _ingame_ui then local mod = _views_data[view_name].mod local keybind_transitions = _views_data[view_name].view_settings.keybind_transitions - if not _ingame_ui.menu_suspended then - if _ingame_ui.current_view == view_name then - if keybind_transitions.close_view_transition then - mod:handle_transition(keybind_transitions.close_view_transition, keybind_transitions.close_view_transition_params, keybind_transitions.transition_fade) - end - elseif can_be_opened then - if keybind_transitions.open_view_transition then - mod:handle_transition(keybind_transitions.open_view_transition, keybind_transitions.close_view_transition_params, keybind_transitions.transition_fade) - end + if _ingame_ui.current_view == view_name then + if keybind_transitions.close_view_transition then + mod:handle_transition(keybind_transitions.close_view_transition, + keybind_transitions.close_view_transition_params, + keybind_transitions.transition_fade, true) + end + -- Can open views only when keybind is pressed. + elseif can_be_opened and is_keybind_pressed then + if keybind_transitions.open_view_transition then + mod:handle_transition(keybind_transitions.open_view_transition, + keybind_transitions.close_view_transition_params, + keybind_transitions.transition_fade, true) end end end