diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index f071baaba8..e875064080 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -289,6 +289,9 @@ namespace MWInput case A_GameMenu: toggleMainMenu (); break; + case A_OptionsMenu: + toggleOptionsMenu(); + break; case A_Screenshot: screenshot(); break; @@ -1042,19 +1045,29 @@ namespace MWInput void InputManager::toggleMainMenu() { - if (MyGUI::InputManager::getInstance().isModalAny()) { - MWBase::Environment::get().getWindowManager()->exitCurrentModal(); + bool state = MWBase::Environment::get().getStateManager()->getState() == MWBase::StateManager::State_NoGame; + MWGui::GuiMode mode = MWBase::Environment::get().getWindowManager()->getMode(); + + if (mode == MWGui::GM_Settings || (!state && mode == MWGui::GM_MainMenu)) + MWBase::Environment::get().getWindowManager()->popGuiMode(); + if(state || mode == MWGui::GM_MainMenu) + return; + + MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_MainMenu); + } + + void InputManager::toggleOptionsMenu() + { + MWGui::GuiMode mode = MWBase::Environment::get().getWindowManager()->getMode(); + if (mode == MWGui::GM_Settings) + { + MWBase::Environment::get().getWindowManager()->popGuiMode(); return; } + else if (mode == MWGui::GM_MainMenu && !(MWBase::Environment::get().getStateManager()->getState() == MWBase::StateManager::State_NoGame)) + MWBase::Environment::get().getWindowManager()->popGuiMode(); - if(!MWBase::Environment::get().getWindowManager()->isGuiMode()) //No open GUIs, open up the MainMenu - { - MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu); - } - else //Close current GUI - { - MWBase::Environment::get().getWindowManager()->exitCurrentGuiMode(); - } + MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Settings); } void InputManager::quickLoad() { @@ -1415,12 +1428,12 @@ namespace MWInput defaultButtonBindings[A_TogglePOV] = SDL_CONTROLLER_BUTTON_RIGHTSTICK; defaultButtonBindings[A_Inventory] = SDL_CONTROLLER_BUTTON_B; defaultButtonBindings[A_GameMenu] = SDL_CONTROLLER_BUTTON_START; - defaultButtonBindings[A_QuickKeysMenu] = SDL_CONTROLLER_BUTTON_BACK; // Ideally a new menu, A_QuickButtonsMenu should be implemented with only 4 quick keys. + defaultButtonBindings[A_OptionsMenu] = SDL_CONTROLLER_BUTTON_BACK; defaultButtonBindings[A_QuickSave] = SDL_CONTROLLER_BUTTON_GUIDE; - defaultButtonBindings[A_QuickKey1] = SDL_CONTROLLER_BUTTON_DPAD_UP; - defaultButtonBindings[A_QuickKey2] = SDL_CONTROLLER_BUTTON_DPAD_LEFT; - defaultButtonBindings[A_QuickKey3] = SDL_CONTROLLER_BUTTON_DPAD_DOWN; - defaultButtonBindings[A_QuickKey4] = SDL_CONTROLLER_BUTTON_DPAD_RIGHT; + defaultButtonBindings[A_MoveForward] = SDL_CONTROLLER_BUTTON_DPAD_UP; + defaultButtonBindings[A_MoveLeft] = SDL_CONTROLLER_BUTTON_DPAD_LEFT; + defaultButtonBindings[A_MoveBackward] = SDL_CONTROLLER_BUTTON_DPAD_DOWN; + defaultButtonBindings[A_MoveRight] = SDL_CONTROLLER_BUTTON_DPAD_RIGHT; std::map defaultAxisBindings; defaultAxisBindings[A_MoveForwardBackward] = SDL_CONTROLLER_AXIS_LEFTY; diff --git a/apps/openmw/mwinput/inputmanagerimp.hpp b/apps/openmw/mwinput/inputmanagerimp.hpp index c383e544df..9ac331a6ae 100644 --- a/apps/openmw/mwinput/inputmanagerimp.hpp +++ b/apps/openmw/mwinput/inputmanagerimp.hpp @@ -229,6 +229,7 @@ namespace MWInput private: void toggleMainMenu(); + void toggleOptionsMenu(); void toggleSpell(); void toggleWeapon(); void toggleInventory(); @@ -321,6 +322,8 @@ namespace MWInput A_MoveForwardBackward, A_MoveLeftRight, + A_OptionsMenu, + A_Last // Marker for the last item }; };