From 53334d08a2559a0426d3e6b34409b62054b29ce5 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 26 Dec 2015 18:15:57 +0100 Subject: [PATCH] Disable Ready Magic and Cycle Weapon/Spell hotkeys for werewolves (Fixes #3100) --- apps/openmw/mwinput/inputmanagerimp.cpp | 41 +++++++++++++++---------- apps/openmw/mwinput/inputmanagerimp.hpp | 2 ++ 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 71938dfb0..a46f1778b 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -302,16 +302,20 @@ namespace MWInput quickLoad(); break; case A_CycleSpellLeft: - MWBase::Environment::get().getWindowManager()->cycleSpell(false); + if (checkAllowedToUseItems()) + MWBase::Environment::get().getWindowManager()->cycleSpell(false); break; case A_CycleSpellRight: - MWBase::Environment::get().getWindowManager()->cycleSpell(true); + if (checkAllowedToUseItems()) + MWBase::Environment::get().getWindowManager()->cycleSpell(true); break; case A_CycleWeaponLeft: - MWBase::Environment::get().getWindowManager()->cycleWeapon(false); + if (checkAllowedToUseItems()) + MWBase::Environment::get().getWindowManager()->cycleWeapon(false); break; case A_CycleWeaponRight: - MWBase::Environment::get().getWindowManager()->cycleWeapon(true); + if (checkAllowedToUseItems()) + MWBase::Environment::get().getWindowManager()->cycleWeapon(true); break; case A_Sneak: if (mSneakToggles) @@ -346,6 +350,18 @@ namespace MWInput } } + bool InputManager::checkAllowedToUseItems() const + { + MWWorld::Ptr player = MWMechanics::getPlayer(); + if (player.getClass().getNpcStats(player).isWerewolf()) + { + // Cannot use items or spells while in werewolf form + MWBase::Environment::get().getWindowManager()->messageBox("#{sWerewolfRefusal}"); + return false; + } + return true; + } + void InputManager::update(float dt, bool disableControls, bool disableEvents) { mControlsDisabled = disableControls; @@ -902,6 +918,9 @@ namespace MWInput if (!mControlSwitch["playermagic"] || !mControlSwitch["playercontrols"]) return; + if (!checkAllowedToUseItems()) + return; + // Not allowed if no spell selected MWWorld::InventoryStore& inventory = mPlayer->getPlayer().getClass().getInventoryStore(mPlayer->getPlayer()); if (MWBase::Environment::get().getWindowManager()->getSelectedSpell().empty() && @@ -1016,13 +1035,8 @@ namespace MWInput { if (!mControlSwitch["playercontrols"]) return; - MWWorld::Ptr player = MWMechanics::getPlayer(); - if (player.getClass().getNpcStats(player).isWerewolf()) - { - // Cannot use items or spells while in werewolf form - MWBase::Environment::get().getWindowManager()->messageBox("#{sWerewolfRefusal}"); + if (!checkAllowedToUseItems()) return; - } if (!MWBase::Environment::get().getWindowManager()->isGuiMode()) MWBase::Environment::get().getWindowManager()->activateQuickKey (index); @@ -1033,13 +1047,8 @@ namespace MWInput if (!MWBase::Environment::get().getWindowManager()->isGuiMode () && MWBase::Environment::get().getWorld()->getGlobalFloat ("chargenstate")==-1) { - MWWorld::Ptr player = MWMechanics::getPlayer(); - if (player.getClass().getNpcStats(player).isWerewolf()) - { - // Cannot use items or spells while in werewolf form - MWBase::Environment::get().getWindowManager()->messageBox("#{sWerewolfRefusal}"); + if (!checkAllowedToUseItems()) return; - } MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_QuickKeysMenu); diff --git a/apps/openmw/mwinput/inputmanagerimp.hpp b/apps/openmw/mwinput/inputmanagerimp.hpp index 3b11e04c0..644391688 100644 --- a/apps/openmw/mwinput/inputmanagerimp.hpp +++ b/apps/openmw/mwinput/inputmanagerimp.hpp @@ -213,6 +213,8 @@ namespace MWInput void updateCursorMode(); + bool checkAllowedToUseItems() const; + private: void toggleMainMenu(); void toggleSpell();