1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-30 21:32:42 +00:00
OpenMW/apps/openmw/mwgui/containeritemmodel.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.6 KiB
C++
Raw Normal View History

2013-05-11 18:38:27 +02:00
#ifndef MWGUI_CONTAINER_ITEM_MODEL_H
#define MWGUI_CONTAINER_ITEM_MODEL_H
#include <utility>
#include <vector>
2013-05-11 18:38:27 +02:00
#include "itemmodel.hpp"
#include "../mwworld/containerstore.hpp"
2013-05-11 18:38:27 +02: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 02:18:36 +02:00
ContainerItemModel(const std::vector<MWWorld::Ptr>& itemSources, const std::vector<MWWorld::Ptr>& worldItems);
2013-05-11 18:38:27 +02: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 22:37:08 +04:00
bool onDropItem(const MWWorld::Ptr& item, int count) override;
bool onTakeItem(const MWWorld::Ptr& item, int count) override;
2017-10-04 22:37:08 +04:00
ItemStack getItem(ModelIndex index) override;
2021-08-15 19:50:28 +02:00
ModelIndex getIndex(const ItemStack& item) override;
size_t getItemCount() override;
2013-05-11 18:38:27 +02:00
MWWorld::Ptr addItem(const ItemStack& item, size_t count, bool allowAutoEquip = true) override;
void removeItem(const ItemStack& item, size_t count) override;
2013-05-11 18:38:27 +02:00
void update() override;
2013-05-11 18:38:27 +02:00
bool usesContainer(const MWWorld::Ptr& container) override;
2013-05-11 18:38:27 +02:00
private:
std::vector<std::pair<MWWorld::Ptr, MWWorld::ResolutionHandle>> mItemSources;
2013-05-27 02:18:36 +02:00
std::vector<MWWorld::Ptr> mWorldItems;
const bool mTrading;
2013-05-11 18:38:27 +02:00
std::vector<ItemStack> mItems;
};
}
#endif