mirror of
https://github.com/OpenMW/openmw.git
synced 2026-01-04 15:13:08 +00:00
play down sound when equip fails
This commit is contained in:
parent
abbbeefdbd
commit
40e9b2d707
2 changed files with 46 additions and 49 deletions
|
|
@ -522,33 +522,15 @@ namespace MWGui
|
|||
}
|
||||
|
||||
MWWorld::Ptr player = MWMechanics::getPlayer();
|
||||
bool canUse = true;
|
||||
|
||||
// early-out for items that need to be equipped, but can't be equipped: we don't want to set OnPcEquip in that
|
||||
// case
|
||||
if (!ptr.getClass().getEquipmentSlots(ptr).first.empty())
|
||||
{
|
||||
if (ptr.getClass().hasItemHealth(ptr) && ptr.getCellRef().getCharge() == 0)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sInventoryMessage1}");
|
||||
updateItemView();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!force)
|
||||
{
|
||||
auto canEquip = ptr.getClass().canBeEquipped(ptr, player);
|
||||
|
||||
if (canEquip.first == 0)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->messageBox(canEquip.second);
|
||||
updateItemView();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// We don't want to set OnPcEquip for items that need to be equipped; but cannot be equipped;
|
||||
if (!ptr.getClass().getEquipmentSlots(ptr).first.empty()
|
||||
&& ptr.getClass().canBeEquipped(ptr, player).first == 0)
|
||||
canUse = force && ptr.getClass().hasItemHealth(ptr) && ptr.getCellRef().getCharge() != 0;
|
||||
|
||||
// If the item has a script, set OnPCEquip or PCSkipEquip to 1
|
||||
if (!script.empty())
|
||||
if (!script.empty() && canUse)
|
||||
{
|
||||
// Ingredients, books and repair hammers must not have OnPCEquip set to 1 here
|
||||
auto type = ptr.getType();
|
||||
|
|
@ -561,7 +543,25 @@ namespace MWGui
|
|||
}
|
||||
|
||||
std::unique_ptr<MWWorld::Action> action = ptr.getClass().use(ptr, force);
|
||||
action->execute(player);
|
||||
|
||||
action->execute(player, !canUse);
|
||||
|
||||
if (mDragAndDrop->mIsOnDragAndDrop && mDragAndDrop->mItem.mBase == ptr)
|
||||
{
|
||||
if (canUse)
|
||||
{
|
||||
mDragAndDrop->finish();
|
||||
// If item is ingredient or potion don't stop drag and drop
|
||||
if ((ptr.getType() == ESM::Potion::sRecordId || ptr.getType() == ESM::Ingredient::sRecordId)
|
||||
&& mDragAndDrop->mDraggedCount > 1)
|
||||
{
|
||||
mSelectedItem = getModel()->getIndex(mDragAndDrop->mItem);
|
||||
dragItem(nullptr, mDragAndDrop->mDraggedCount - 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
mDragAndDrop->drop(mTradeModel, mItemView);
|
||||
}
|
||||
|
||||
// Handles partial equipping (final part)
|
||||
if (mEquippedStackableCount.has_value())
|
||||
|
|
@ -592,8 +592,6 @@ namespace MWGui
|
|||
{
|
||||
MWWorld::Ptr ptr = mDragAndDrop->mItem.mBase;
|
||||
|
||||
mDragAndDrop->finish();
|
||||
|
||||
if (mDragAndDrop->mSourceModel != mTradeModel)
|
||||
{
|
||||
// Move item to the player's inventory
|
||||
|
|
@ -617,17 +615,6 @@ namespace MWGui
|
|||
}
|
||||
|
||||
MWBase::Environment::get().getLuaManager()->useItem(ptr, MWMechanics::getPlayer(), false);
|
||||
|
||||
// If item is ingredient or potion don't stop drag and drop to simplify action of taking more than one 1
|
||||
// item
|
||||
if ((ptr.getType() == ESM::Potion::sRecordId || ptr.getType() == ESM::Ingredient::sRecordId)
|
||||
&& mDragAndDrop->mDraggedCount > 1)
|
||||
{
|
||||
// Item can be provided from other window for example container.
|
||||
// But after DragAndDrop::startDrag item automaticly always gets to player inventory.
|
||||
mSelectedItem = getModel()->getIndex(mDragAndDrop->mItem);
|
||||
dragItem(nullptr, mDragAndDrop->mDraggedCount - 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -84,9 +84,8 @@ namespace MWGui
|
|||
case ESM::QuickKeys::Type::MagicItem:
|
||||
{
|
||||
MWWorld::Ptr item = *mKey[index].button->getUserData<MWWorld::Ptr>();
|
||||
// Make sure the item is available and is not broken
|
||||
if (item.isEmpty() || item.getCellRef().getCount() < 1
|
||||
|| (item.getClass().hasItemHealth(item) && item.getClass().getItemHealth(item) <= 0))
|
||||
// Make sure the item is available
|
||||
if (item.isEmpty() || item.getCellRef().getCount() < 1)
|
||||
{
|
||||
// Try searching for a compatible replacement
|
||||
item = store.findReplacement(mKey[index].id);
|
||||
|
|
@ -382,18 +381,29 @@ namespace MWGui
|
|||
if (it == store.end())
|
||||
item = nullptr;
|
||||
|
||||
// check the item is available and not broken
|
||||
if (item.isEmpty() || item.getCellRef().getCount() < 1
|
||||
|| (item.getClass().hasItemHealth(item) && item.getClass().getItemHealth(item) <= 0))
|
||||
// check the quickkey item is available
|
||||
if (item.isEmpty() || item.getCellRef().getCount() < 1)
|
||||
{
|
||||
item = store.findReplacement(key->id);
|
||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sQuickMenu5} " + key->name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.isEmpty() || item.getCellRef().getCount() < 1)
|
||||
// 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())
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sQuickMenu5} " + key->name);
|
||||
|
||||
return;
|
||||
const auto& itSlot = store.getSlot(equipmentSlots.front());
|
||||
// Morrowind.exe behaviour:
|
||||
// Only display item broken message if;
|
||||
// no item in the to-be-equipped slot
|
||||
// or broken quickkey item and currently equipped item id is different
|
||||
// It doesn't find a replacement
|
||||
if (itSlot == store.end() || (item.getCellRef().getRefId() != itSlot->getCellRef().getRefId()))
|
||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sInventoryMessage1}");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (key->type == ESM::QuickKeys::Type::Item)
|
||||
|
|
|
|||
Loading…
Reference in a new issue