From 234903d93c04567c5f05d8878a5d42ce8beaa61b Mon Sep 17 00:00:00 2001 From: Rohit Nirmal Date: Fri, 22 Aug 2014 21:36:39 -0500 Subject: [PATCH 1/3] Change player draw state when quick-selecting weapon or spell. (Fixes #1828) --- apps/openmw/mwgui/quickkeysmenu.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index 12defc631..67b8db71d 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -7,6 +7,7 @@ #include "../mwworld/inventorystore.hpp" #include "../mwworld/class.hpp" +#include "../mwworld/player.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -293,12 +294,18 @@ namespace MWGui return; store.setSelectedEnchantItem(store.end()); MWBase::Environment::get().getWindowManager()->setSelectedSpell(spellId, int(MWMechanics::getSpellSuccessChance(spellId, player))); + MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Spell); } else if (type == Type_Item) { MWWorld::Ptr item = *button->getUserData(); - MWBase::Environment::get().getWindowManager()->getInventoryWindow()->useItem(item); + + // draw weapon only if the item *is* a weapon + if (item.getTypeName() == typeid(ESM::Weapon).name()) + { + MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Weapon); + } } else if (type == Type_MagicItem) { @@ -322,6 +329,7 @@ namespace MWGui } store.setSelectedEnchantItem(it); + MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Spell); } } From bf97fe7b35d078a8e97841fd263de4f5ecb8bbe2 Mon Sep 17 00:00:00 2001 From: Rohit Nirmal Date: Sat, 23 Aug 2014 10:31:10 -0500 Subject: [PATCH 2/3] Need to change draw state if use'd item is in player's right hand. --- apps/openmw/mwgui/quickkeysmenu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index 67b8db71d..8b3a75d61 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -300,9 +300,9 @@ namespace MWGui { MWWorld::Ptr item = *button->getUserData(); MWBase::Environment::get().getWindowManager()->getInventoryWindow()->useItem(item); - + MWWorld::ContainerStoreIterator rightHand = store.getSlot(MWWorld::InventoryStore::Slot_CarriedRight); // draw weapon only if the item *is* a weapon - if (item.getTypeName() == typeid(ESM::Weapon).name()) + if (rightHand != store.end() && item == *rightHand) { MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Weapon); } From 6ed4f530dfde03f71947e26874f730a68e055303 Mon Sep 17 00:00:00 2001 From: Rohit Nirmal Date: Sat, 23 Aug 2014 10:35:55 -0500 Subject: [PATCH 3/3] Forgot to update comment. --- apps/openmw/mwgui/quickkeysmenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index 8b3a75d61..1ff94616c 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -301,7 +301,7 @@ namespace MWGui MWWorld::Ptr item = *button->getUserData(); MWBase::Environment::get().getWindowManager()->getInventoryWindow()->useItem(item); MWWorld::ContainerStoreIterator rightHand = store.getSlot(MWWorld::InventoryStore::Slot_CarriedRight); - // draw weapon only if the item *is* a weapon + // change draw state only if the item is in player's right hand if (rightHand != store.end() && item == *rightHand) { MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Weapon);