forked from teamnwah/openmw-tes3coop
Add items to player inventory upon drag start (Fixes #1507)
This commit is contained in:
parent
0aba1088a1
commit
4f73e8bb71
3 changed files with 32 additions and 0 deletions
|
@ -38,6 +38,32 @@ namespace MWGui
|
||||||
mIsOnDragAndDrop = true;
|
mIsOnDragAndDrop = true;
|
||||||
mDragAndDropWidget->setVisible(true);
|
mDragAndDropWidget->setVisible(true);
|
||||||
|
|
||||||
|
// If picking up an item that isn't from the player's inventory, the item gets added to player inventory backend
|
||||||
|
// immediately, even though it's still floating beneath the mouse cursor. A bit counterintuitive,
|
||||||
|
// but this is how it works in vanilla, and not doing so would break quests (BM_beasts for instance).
|
||||||
|
ItemModel* playerModel = MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getModel();
|
||||||
|
if (mSourceModel != playerModel)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr item = mSourceModel->moveItem(mItem, mDraggedCount, playerModel);
|
||||||
|
|
||||||
|
playerModel->update();
|
||||||
|
|
||||||
|
ItemModel::ModelIndex newIndex = -1;
|
||||||
|
for (unsigned int i=0; i<playerModel->getItemCount(); ++i)
|
||||||
|
{
|
||||||
|
if (playerModel->getItem(i).mBase == item)
|
||||||
|
{
|
||||||
|
newIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mItem = playerModel->getItem(newIndex);
|
||||||
|
mSourceModel = playerModel;
|
||||||
|
|
||||||
|
SortFilterItemModel* playerFilterModel = MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getSortFilterModel();
|
||||||
|
mSourceSortModel = playerFilterModel;
|
||||||
|
}
|
||||||
|
|
||||||
std::string sound = mItem.mBase.getClass().getUpSoundId(mItem.mBase);
|
std::string sound = mItem.mBase.getClass().getUpSoundId(mItem.mBase);
|
||||||
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,11 @@ namespace MWGui
|
||||||
adjustPanes();
|
adjustPanes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SortFilterItemModel* InventoryWindow::getSortFilterModel()
|
||||||
|
{
|
||||||
|
return mSortModel;
|
||||||
|
}
|
||||||
|
|
||||||
TradeItemModel* InventoryWindow::getTradeModel()
|
TradeItemModel* InventoryWindow::getTradeModel()
|
||||||
{
|
{
|
||||||
return mTradeModel;
|
return mTradeModel;
|
||||||
|
|
|
@ -37,6 +37,7 @@ namespace MWGui
|
||||||
mPreview->rebuild();
|
mPreview->rebuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SortFilterItemModel* getSortFilterModel();
|
||||||
TradeItemModel* getTradeModel();
|
TradeItemModel* getTradeModel();
|
||||||
ItemModel* getModel();
|
ItemModel* getModel();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue