26 Container::Container(
int id,
int capacity,
const std::string& name,
const ItemPtr& containerItem,
bool hasParent,
bool isUnlocked,
bool hasPages,
int containerSize,
int firstIndex)
29 m_capacity = capacity;
31 m_containerItem = containerItem;
36 m_size = containerSize;
37 m_firstIndex = firstIndex;
42 if(slot < 0 || slot >=
static_cast<int>(m_items.size()))
64 if(m_hasPages && slot > m_capacity) {
70 m_items.push_front(item);
72 m_items.push_back(item);
73 updateItemsPositions();
81 for(
const ItemPtr& item : m_items)
82 if(item->getId() == itemId && (subType == -1 || item->getSubType() == subType))
89 for(
const ItemPtr& item : items)
90 m_items.push_back(item);
91 updateItemsPositions();
97 if(slot < 0 || slot >=
static_cast<int>(m_items.size())) {
98 g_logger.traceError(
"slot not found");
102 const ItemPtr oldItem = m_items[slot];
103 m_items[slot] = item;
111 slot -= m_firstIndex;
112 if(m_hasPages && slot >=
static_cast<int>(m_items.size())) {
118 if(slot < 0 || slot >=
static_cast<int>(m_items.size())) {
119 g_logger.traceError(
"slot not found");
123 const ItemPtr item = m_items[slot];
124 m_items.erase(m_items.begin() + slot);
128 onAddItem(lastItem, m_firstIndex + m_capacity - 1);
134 updateItemsPositions();
140 void Container::updateItemsPositions()
142 for(
int slot = 0; slot < static_cast<int>(m_items.size()); ++slot)