mirror of
https://github.com/OpenMW/openmw.git
synced 2025-12-15 23:13:18 +00:00
cleanup 2
This commit is contained in:
parent
e4f0723a90
commit
ede768532c
4 changed files with 16 additions and 22 deletions
|
|
@ -550,7 +550,7 @@ namespace MWGui
|
|||
}
|
||||
|
||||
std::unique_ptr<MWWorld::Action> action = ptr.getClass().use(ptr, force);
|
||||
action->execute(player);
|
||||
action->execute(player, !canEquip);
|
||||
|
||||
// Handles partial equipping (final part)
|
||||
if (mEquippedStackableCount.has_value())
|
||||
|
|
@ -581,11 +581,11 @@ namespace MWGui
|
|||
{
|
||||
MWWorld::Ptr ptr = mDragAndDrop->mItem.mBase;
|
||||
|
||||
auto canEquip = ptr.getClass().canBeEquipped(ptr, mPtr);
|
||||
if (canEquip.first == 0) // cannot equip
|
||||
auto [canEquipRes, canEquipMsg] = ptr.getClass().canBeEquipped(ptr, mPtr);
|
||||
if (canEquipRes == 0) // cannot equip
|
||||
{
|
||||
mDragAndDrop->drop(mTradeModel, mItemView); // also plays down sound
|
||||
MWBase::Environment::get().getWindowManager()->messageBox(canEquip.second);
|
||||
MWBase::Environment::get().getWindowManager()->messageBox(canEquipMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -388,26 +388,9 @@ namespace MWGui
|
|||
return;
|
||||
}
|
||||
|
||||
// check the quickkey item is not broken
|
||||
if (item.getClass().hasItemHealth(item) && item.getClass().getItemHealth(item) <= 0)
|
||||
{
|
||||
const std::vector<int>& equipmentSlots = item.getClass().getEquipmentSlots(item).first;
|
||||
if (!equipmentSlots.empty())
|
||||
{
|
||||
const auto& itSlot = store.getSlot(equipmentSlots.front());
|
||||
// Morrowind.exe behavior:
|
||||
// Only display the "item is broken" message if:
|
||||
// - There is no item in the target equipment slot, or
|
||||
// - The quickkey item is broken and the currently equipped item has a different ID
|
||||
if (itSlot == store.end() || (item.getCellRef().getRefId() != itSlot->getCellRef().getRefId()))
|
||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sInventoryMessage1}");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (key->type == ESM::QuickKeys::Type::Item)
|
||||
{
|
||||
if (!store.isEquipped(item))
|
||||
if (!store.isEquipped(item.getCellRef().getRefId()))
|
||||
MWBase::Environment::get().getWindowManager()->useItem(item);
|
||||
MWWorld::ConstContainerStoreIterator rightHand
|
||||
= store.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
|
|
|
|||
|
|
@ -754,6 +754,16 @@ bool MWWorld::InventoryStore::isEquipped(const MWWorld::ConstPtr& item)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool MWWorld::InventoryStore::isEquipped(const ESM::RefId& id)
|
||||
{
|
||||
for (int i = 0; i < MWWorld::InventoryStore::Slots; ++i)
|
||||
{
|
||||
if (getSlot(i) != end() && getSlot(i)->getCellRef().getRefId() == id)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MWWorld::InventoryStore::isFirstEquip()
|
||||
{
|
||||
bool first = mFirstAutoEquip;
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ namespace MWWorld
|
|||
///< \warning \a iterator can not be an end()-iterator, use unequip function instead
|
||||
|
||||
bool isEquipped(const MWWorld::ConstPtr& item);
|
||||
bool isEquipped(const ESM::RefId& id);
|
||||
///< Utility function, returns true if the given item is equipped in any slot
|
||||
|
||||
void setSelectedEnchantItem(const ContainerStoreIterator& iterator);
|
||||
|
|
|
|||
Loading…
Reference in a new issue