|
|
|
@ -176,35 +176,6 @@ namespace MWGui
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.mType == ItemStack::Type_Equipped)
|
|
|
|
|
{
|
|
|
|
|
MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
|
|
|
|
|
MWWorld::Ptr newStack = *invStore.unequipItem(item.mBase, mPtr);
|
|
|
|
|
|
|
|
|
|
// The unequipped item was re-stacked. We have to update the index
|
|
|
|
|
// since the item pointed does not exist anymore.
|
|
|
|
|
if (item.mBase != newStack)
|
|
|
|
|
{
|
|
|
|
|
// newIndex will store the index of the ItemStack the item was stacked on
|
|
|
|
|
int newIndex = -1;
|
|
|
|
|
for (size_t i=0; i < mTradeModel->getItemCount(); ++i)
|
|
|
|
|
{
|
|
|
|
|
if (mTradeModel->getItem(i).mBase == newStack)
|
|
|
|
|
{
|
|
|
|
|
newIndex = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (newIndex == -1)
|
|
|
|
|
throw std::runtime_error("Can't find restacked item");
|
|
|
|
|
|
|
|
|
|
index = newIndex;
|
|
|
|
|
object = mTradeModel->getItem(index).mBase;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool shift = MyGUI::InputManager::getInstance().isShiftPressed();
|
|
|
|
|
if (MyGUI::InputManager::getInstance().isControlPressed())
|
|
|
|
|
count = 1;
|
|
|
|
@ -247,13 +218,46 @@ namespace MWGui
|
|
|
|
|
notifyContentChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void InventoryWindow::ensureSelectedItemUnequipped()
|
|
|
|
|
{
|
|
|
|
|
const ItemStack& item = mTradeModel->getItem(mSelectedItem);
|
|
|
|
|
if (item.mType == ItemStack::Type_Equipped)
|
|
|
|
|
{
|
|
|
|
|
MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
|
|
|
|
|
MWWorld::Ptr newStack = *invStore.unequipItem(item.mBase, mPtr);
|
|
|
|
|
|
|
|
|
|
// The unequipped item was re-stacked. We have to update the index
|
|
|
|
|
// since the item pointed does not exist anymore.
|
|
|
|
|
if (item.mBase != newStack)
|
|
|
|
|
{
|
|
|
|
|
// newIndex will store the index of the ItemStack the item was stacked on
|
|
|
|
|
int newIndex = -1;
|
|
|
|
|
for (size_t i=0; i < mTradeModel->getItemCount(); ++i)
|
|
|
|
|
{
|
|
|
|
|
if (mTradeModel->getItem(i).mBase == newStack)
|
|
|
|
|
{
|
|
|
|
|
newIndex = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (newIndex == -1)
|
|
|
|
|
throw std::runtime_error("Can't find restacked item");
|
|
|
|
|
|
|
|
|
|
mSelectedItem = newIndex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void InventoryWindow::dragItem(MyGUI::Widget* sender, int count)
|
|
|
|
|
{
|
|
|
|
|
ensureSelectedItemUnequipped();
|
|
|
|
|
mDragAndDrop->startDrag(mSelectedItem, mSortModel, mTradeModel, mItemView, count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void InventoryWindow::sellItem(MyGUI::Widget* sender, int count)
|
|
|
|
|
{
|
|
|
|
|
ensureSelectedItemUnequipped();
|
|
|
|
|
const ItemStack& item = mTradeModel->getItem(mSelectedItem);
|
|
|
|
|
std::string sound = MWWorld::Class::get(item.mBase).getDownSoundId(item.mBase);
|
|
|
|
|
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
|
|
|
|