mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 03:35:27 +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())
|
if (MWBase::Environment::get().getWindowManager()->getSpellWindow())
|
||||||
MWBase::Environment::get().getWindowManager()->getSpellWindow()->updateSpells();
|
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;
|
mPreviewDirty = true;
|
||||||
|
|
||||||
mArmorRating->setCaptionWithReplacing ("#{sArmor}: "
|
mArmorRating->setCaptionWithReplacing ("#{sArmor}: "
|
||||||
|
@ -284,8 +284,9 @@ namespace MWGui
|
|||||||
MWWorld::Ptr item = *button->getChildAt (0)->getUserData<MWWorld::Ptr>();
|
MWWorld::Ptr item = *button->getChildAt (0)->getUserData<MWWorld::Ptr>();
|
||||||
|
|
||||||
// make sure the item is available
|
// 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 (
|
MWBase::Environment::get().getWindowManager ()->messageBox (
|
||||||
"#{sQuickMenu5} " + MWWorld::Class::get(item).getName(item));
|
"#{sQuickMenu5} " + MWWorld::Class::get(item).getName(item));
|
||||||
return;
|
return;
|
||||||
|
@ -563,10 +563,8 @@ bool CharacterController::updateNpcState(bool onground, bool inwater, bool isrun
|
|||||||
if(!resultSound.empty())
|
if(!resultSound.empty())
|
||||||
MWBase::Environment::get().getSoundManager()->playSound(resultSound, 1.0f, 1.0f);
|
MWBase::Environment::get().getSoundManager()->playSound(resultSound, 1.0f, 1.0f);
|
||||||
|
|
||||||
// tool used up?
|
// Set again, just to update the charge bar
|
||||||
if(!item.getRefData().getCount())
|
if(item.getRefData().getCount())
|
||||||
MWBase::Environment::get().getWindowManager()->unsetSelectedWeapon();
|
|
||||||
else
|
|
||||||
MWBase::Environment::get().getWindowManager()->setSelectedWeapon(item);
|
MWBase::Environment::get().getWindowManager()->setSelectedWeapon(item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -159,7 +159,7 @@ namespace MWMechanics
|
|||||||
// auto-equip again. we need this for when the race is changed to a beast race
|
// 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);
|
MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore(ptr);
|
||||||
for (int i=0; i<MWWorld::InventoryStore::Slots; ++i)
|
for (int i=0; i<MWWorld::InventoryStore::Slots; ++i)
|
||||||
invStore.equip(i, invStore.end(), ptr);
|
invStore.unequipAll(ptr);
|
||||||
invStore.autoEquip(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)
|
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()))
|
if (slot<0 || slot>=static_cast<int> (mSlots.size()))
|
||||||
throw std::runtime_error ("slot number out of range");
|
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");
|
throw std::runtime_error ("attempt to equip an item that is not in the inventory");
|
||||||
|
|
||||||
std::pair<std::vector<int>, bool> slots_;
|
std::pair<std::vector<int>, bool> slots_;
|
||||||
if (iterator!=end())
|
|
||||||
{
|
|
||||||
slots_ = Class::get (*iterator).getEquipmentSlots (*iterator);
|
slots_ = Class::get (*iterator).getEquipmentSlots (*iterator);
|
||||||
|
|
||||||
if (std::find (slots_.first.begin(), slots_.first.end(), slot)==slots_.first.end())
|
if (std::find (slots_.first.begin(), slots_.first.end(), slot)==slots_.first.end())
|
||||||
throw std::runtime_error ("invalid slot");
|
throw std::runtime_error ("invalid slot");
|
||||||
}
|
|
||||||
|
|
||||||
if (mSlots[slot] != end())
|
if (mSlots[slot] != end())
|
||||||
unequipSlot(slot, actor);
|
unequipSlot(slot, actor);
|
||||||
@ -126,6 +127,10 @@ void MWWorld::InventoryStore::equip (int slot, const ContainerStoreIterator& ite
|
|||||||
|
|
||||||
fireEquipmentChangedEvent();
|
fireEquipmentChangedEvent();
|
||||||
updateMagicEffects(actor);
|
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)
|
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))
|
if ((mSelectedEnchantItem != end()) && (mSelectedEnchantItem == it))
|
||||||
{
|
{
|
||||||
// enchanted item
|
// enchanted item
|
||||||
|
mSelectedEnchantItem = end();
|
||||||
MWBase::Environment::get().getWindowManager()->unsetSelectedSpell();
|
MWBase::Environment::get().getWindowManager()->unsetSelectedSpell();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user