From ca83b9ee9079fd24524fbdf4a62f174bd38d17f4 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Fri, 8 Mar 2019 22:57:25 +0300 Subject: [PATCH] Refactor main menu and settings toggling again --- apps/openmw/mwinput/inputmanagerimp.cpp | 29 ++++++++----------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 32f79706d..6f615564c 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -1149,18 +1149,14 @@ namespace MWInput return; } - bool state = MWBase::Environment::get().getStateManager()->getState() == MWBase::StateManager::State_NoGame; + bool inGame = MWBase::Environment::get().getStateManager()->getState() != MWBase::StateManager::State_NoGame; MWGui::GuiMode mode = MWBase::Environment::get().getWindowManager()->getMode(); - if (mode == MWGui::GM_MainMenu || mode == MWGui::GM_Settings) - { + if ((inGame && mode == MWGui::GM_MainMenu) || mode == MWGui::GM_Settings) MWBase::Environment::get().getWindowManager()->popGuiMode(); - } - - if(state || mode == MWGui::GM_MainMenu) - return; - MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_MainMenu); + if (inGame && mode != MWGui::GM_MainMenu) + MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_MainMenu); } void InputManager::toggleOptionsMenu() @@ -1172,20 +1168,13 @@ namespace MWInput } MWGui::GuiMode mode = MWBase::Environment::get().getWindowManager()->getMode(); - bool state = MWBase::Environment::get().getStateManager()->getState() == MWBase::StateManager::State_NoGame; - if (mode == MWGui::GM_Settings) - { - MWBase::Environment::get().getWindowManager()->popGuiMode(); - return; - } - else if (mode == MWGui::GM_MainMenu && !state) - { + bool inGame = MWBase::Environment::get().getStateManager()->getState() != MWBase::StateManager::State_NoGame; + + if ((inGame && mode == MWGui::GM_MainMenu) || mode == MWGui::GM_Settings) MWBase::Environment::get().getWindowManager()->popGuiMode(); - } - else if (mode == MWGui::GM_MainMenu) - return; - MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Settings); + if (inGame && mode != MWGui::GM_Settings) + MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Settings); } void InputManager::quickLoad() {