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 >= (
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 >= (
int)m_items.size()) {
98 g_logger.traceError(
"slot not found");
102 ItemPtr oldItem = m_items[slot];
103 m_items[slot] = item;
111 slot -= m_firstIndex;
112 if(m_hasPages && slot >= (
int)m_items.size()) {
118 if(slot < 0 || slot >= (
int)m_items.size()) {
119 g_logger.traceError(
"slot not found");
124 m_items.erase(m_items.begin() + slot);
128 onAddItem(lastItem, m_firstIndex + m_capacity - 1);
133 updateItemsPositions();
139 void Container::updateItemsPositions()
141 for(
int slot = 0; slot < (int)m_items.size(); ++slot)