Add ItemModel::allowedToInsertItems

move
scrawl 9 years ago
parent 373c1e7602
commit 763f647412

@ -57,7 +57,7 @@ namespace MWGui
{ {
if (mDragAndDrop->mIsOnDragAndDrop) if (mDragAndDrop->mIsOnDragAndDrop)
{ {
if (!dynamic_cast<PickpocketItemModel*>(mModel)) if (mModel && mModel->allowedToInsertItems())
dropItem(); dropItem();
return; return;
} }
@ -126,7 +126,7 @@ namespace MWGui
void ContainerWindow::onBackgroundSelected() void ContainerWindow::onBackgroundSelected()
{ {
if (mDragAndDrop->mIsOnDragAndDrop && !dynamic_cast<PickpocketItemModel*>(mModel)) if (mDragAndDrop->mIsOnDragAndDrop && mModel && mModel->allowedToInsertItems())
dropItem(); dropItem();
} }

@ -119,6 +119,11 @@ namespace MWGui
return ret; return ret;
} }
bool ItemModel::allowedToInsertItems() const
{
return true;
}
ProxyItemModel::ProxyItemModel() ProxyItemModel::ProxyItemModel()
: mSourceModel(NULL) : mSourceModel(NULL)

@ -70,6 +70,9 @@ namespace MWGui
virtual MWWorld::Ptr copyItem (const ItemStack& item, size_t count, bool setNewOwner=false) = 0; virtual MWWorld::Ptr copyItem (const ItemStack& item, size_t count, bool setNewOwner=false) = 0;
virtual void removeItem (const ItemStack& item, size_t count) = 0; virtual void removeItem (const ItemStack& item, size_t count) = 0;
/// Is the player allowed to insert items into this model? (default true)
virtual bool allowedToInsertItems() const;
private: private:
ItemModel(const ItemModel&); ItemModel(const ItemModel&);
ItemModel& operator=(const ItemModel&); ItemModel& operator=(const ItemModel&);

@ -64,4 +64,10 @@ namespace MWGui
/// \todo check if player is detected /// \todo check if player is detected
} }
bool PickpocketItemModel::allowedToInsertItems() const
{
// don't allow "reverse pickpocket" (yet)
return false;
}
} }

@ -15,6 +15,7 @@ namespace MWGui
virtual size_t getItemCount(); virtual size_t getItemCount();
virtual void update(); virtual void update();
virtual void removeItem (const ItemStack& item, size_t count); virtual void removeItem (const ItemStack& item, size_t count);
virtual bool allowedToInsertItems() const;
private: private:
std::vector<ItemStack> mHiddenItems; std::vector<ItemStack> mHiddenItems;

Loading…
Cancel
Save