1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 16:49:55 +00:00
openmw-tes3mp/apps/openmw/mwgui/containeritemmodel.hpp

49 lines
1.5 KiB
C++
Raw Normal View History

2013-05-11 16:38:27 +00:00
#ifndef MWGUI_CONTAINER_ITEM_MODEL_H
#define MWGUI_CONTAINER_ITEM_MODEL_H
#include <utility>
#include <vector>
2013-05-11 16:38:27 +00:00
#include "itemmodel.hpp"
#include "../mwworld/containerstore.hpp"
2013-05-11 16:38:27 +00:00
namespace MWGui
{
/// @brief The container item model supports multiple item sources, which are needed for
/// making NPCs sell items from containers owned by them
class ContainerItemModel : public ItemModel
{
public:
2013-05-27 00:18:36 +00:00
ContainerItemModel (const std::vector<MWWorld::Ptr>& itemSources, const std::vector<MWWorld::Ptr>& worldItems);
2013-05-11 16:38:27 +00:00
///< @note The order of elements \a itemSources matters here. The first element has the highest priority for removal,
/// while the last element will be used to add new items to.
ContainerItemModel (const MWWorld::Ptr& source);
bool allowedToUseItems() const override;
2017-10-04 18:37:08 +00:00
bool onDropItem(const MWWorld::Ptr &item, int count) override;
bool onTakeItem(const MWWorld::Ptr &item, int count) override;
2017-10-04 18:37:08 +00:00
ItemStack getItem (ModelIndex index) override;
ModelIndex getIndex (ItemStack item) override;
size_t getItemCount() override;
2013-05-11 16:38:27 +00:00
MWWorld::Ptr copyItem (const ItemStack& item, size_t count, bool allowAutoEquip = true) override;
void removeItem (const ItemStack& item, size_t count) override;
2013-05-11 16:38:27 +00:00
void update() override;
2013-05-11 16:38:27 +00:00
private:
std::vector<std::pair<MWWorld::Ptr, MWWorld::ResolutionHandle>> mItemSources;
2013-05-27 00:18:36 +00:00
std::vector<MWWorld::Ptr> mWorldItems;
const bool mTrading;
2013-05-11 16:38:27 +00:00
std::vector<ItemStack> mItems;
};
}
#endif