mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-12 12:38:02 +00:00
Make sure the equipped weapon HUD icon is updated properly
This commit is contained in:
parent
b8c358df63
commit
2a11618ee7
@ -455,14 +455,6 @@ namespace MWGui
|
||||
if (MWBase::Environment::get().getWindowManager()->getSpellWindow())
|
||||
MWBase::Environment::get().getWindowManager()->getSpellWindow()->updateSpells();
|
||||
|
||||
// update selected weapon icon
|
||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
|
||||
MWWorld::ContainerStoreIterator weaponSlot = invStore.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
if (weaponSlot == invStore.end())
|
||||
MWBase::Environment::get().getWindowManager()->unsetSelectedWeapon();
|
||||
else
|
||||
MWBase::Environment::get().getWindowManager()->setSelectedWeapon(*weaponSlot);
|
||||
|
||||
mPreviewDirty = true;
|
||||
|
||||
mArmorRating->setCaptionWithReplacing ("#{sArmor}: "
|
||||
|
@ -284,8 +284,9 @@ namespace MWGui
|
||||
MWWorld::Ptr item = *button->getChildAt (0)->getUserData<MWWorld::Ptr>();
|
||||
|
||||
// make sure the item is available
|
||||
if (item.getRefData ().getCount() == 0)
|
||||
if (item.getRefData ().getCount() < 1)
|
||||
{
|
||||
// TODO: Try to find a replacement with the same ID?
|
||||
MWBase::Environment::get().getWindowManager ()->messageBox (
|
||||
"#{sQuickMenu5} " + MWWorld::Class::get(item).getName(item));
|
||||
return;
|
||||
|
@ -563,10 +563,8 @@ bool CharacterController::updateNpcState(bool onground, bool inwater, bool isrun
|
||||
if(!resultSound.empty())
|
||||
MWBase::Environment::get().getSoundManager()->playSound(resultSound, 1.0f, 1.0f);
|
||||
|
||||
// tool used up?
|
||||
if(!item.getRefData().getCount())
|
||||
MWBase::Environment::get().getWindowManager()->unsetSelectedWeapon();
|
||||
else
|
||||
// Set again, just to update the charge bar
|
||||
if(item.getRefData().getCount())
|
||||
MWBase::Environment::get().getWindowManager()->setSelectedWeapon(item);
|
||||
}
|
||||
else
|
||||
|
@ -159,7 +159,7 @@ namespace MWMechanics
|
||||
// auto-equip again. we need this for when the race is changed to a beast race
|
||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore(ptr);
|
||||
for (int i=0; i<MWWorld::InventoryStore::Slots; ++i)
|
||||
invStore.equip(i, invStore.end(), ptr);
|
||||
invStore.unequipAll(ptr);
|
||||
invStore.autoEquip(ptr);
|
||||
}
|
||||
|
||||
|
@ -92,6 +92,9 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::add(const Ptr& itemPtr,
|
||||
|
||||
void MWWorld::InventoryStore::equip (int slot, const ContainerStoreIterator& iterator, const Ptr& actor)
|
||||
{
|
||||
if (iterator == end())
|
||||
throw std::runtime_error ("can't equip end() iterator, use unequip function instead");
|
||||
|
||||
if (slot<0 || slot>=static_cast<int> (mSlots.size()))
|
||||
throw std::runtime_error ("slot number out of range");
|
||||
|
||||
@ -99,13 +102,11 @@ void MWWorld::InventoryStore::equip (int slot, const ContainerStoreIterator& ite
|
||||
throw std::runtime_error ("attempt to equip an item that is not in the inventory");
|
||||
|
||||
std::pair<std::vector<int>, bool> slots_;
|
||||
if (iterator!=end())
|
||||
{
|
||||
slots_ = Class::get (*iterator).getEquipmentSlots (*iterator);
|
||||
|
||||
if (std::find (slots_.first.begin(), slots_.first.end(), slot)==slots_.first.end())
|
||||
throw std::runtime_error ("invalid slot");
|
||||
}
|
||||
slots_ = Class::get (*iterator).getEquipmentSlots (*iterator);
|
||||
|
||||
if (std::find (slots_.first.begin(), slots_.first.end(), slot)==slots_.first.end())
|
||||
throw std::runtime_error ("invalid slot");
|
||||
|
||||
if (mSlots[slot] != end())
|
||||
unequipSlot(slot, actor);
|
||||
@ -126,6 +127,10 @@ void MWWorld::InventoryStore::equip (int slot, const ContainerStoreIterator& ite
|
||||
|
||||
fireEquipmentChangedEvent();
|
||||
updateMagicEffects(actor);
|
||||
|
||||
// Update HUD icon for player weapon
|
||||
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
|
||||
MWBase::Environment::get().getWindowManager()->setSelectedWeapon(*getSlot(slot));
|
||||
}
|
||||
|
||||
void MWWorld::InventoryStore::unequipAll(const MWWorld::Ptr& actor)
|
||||
@ -482,6 +487,7 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::unequipSlot(int slot, c
|
||||
if ((mSelectedEnchantItem != end()) && (mSelectedEnchantItem == it))
|
||||
{
|
||||
// enchanted item
|
||||
mSelectedEnchantItem = end();
|
||||
MWBase::Environment::get().getWindowManager()->unsetSelectedSpell();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user