1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 18:35:20 +00:00

equipping items in the inventorywindow (there is no visual indication yet)

This commit is contained in:
scrawl 2012-05-15 18:20:32 +02:00
parent ab6336b745
commit 765881a61d

View File

@ -144,6 +144,11 @@ namespace MWGui
{
MWWorld::Ptr ptr = *mDragAndDrop->mStore.begin();
// can the object be equipped?
std::pair<std::vector<int>, bool> slots = MWWorld::Class::get(ptr).getEquipmentSlots(ptr);
if (slots.first.empty())
{
// can't be equipped, try to use instead
boost::shared_ptr<MWWorld::Action> action = MWWorld::Class::get(ptr).use(ptr);
// execute action and script
@ -162,6 +167,26 @@ namespace MWGui
// put back in inventory
MWWorld::ContainerStore& containerStore = MWWorld::Class::get(mContainer).getContainerStore(mContainer);
containerStore.add(ptr);
}
else
{
// put back in inventory
MWWorld::InventoryStore& invStore = static_cast<MWWorld::InventoryStore&>(MWWorld::Class::get(mContainer).getContainerStore(mContainer));
invStore.add(ptr);
// get a ContainerStoreIterator to the item we just re-added into the inventory
MWWorld::ContainerStoreIterator it = invStore.begin();
MWWorld::ContainerStoreIterator nextIt = ++it;
while (nextIt != invStore.end())
{
++it;
++nextIt;
}
// equip the item in the first available slot
invStore.equip(slots.first.front(), it);
}
drawItems();
mDragAndDrop->mStore.clear();