33 #include "gui/viewport.h"
94 const Item *
const item1 = pair1->mItem;
95 const Item *
const item2 = pair2->mItem;
96 if ((item1 ==
nullptr) || (item2 ==
nullptr))
108 return name1 < name2;
120 if ((pair1->mItem ==
nullptr) || (pair2->mItem ==
nullptr))
123 const int id1 = pair1->mItem->getId();
124 const int id2 = pair2->mItem->getId();
127 return pair1->mItem->getInvIndex() <
128 pair2->mItem->getInvIndex();
142 if ((pair1->mItem ==
nullptr) || (pair2->mItem ==
nullptr))
145 const int w1 = pair1->mItem->getInfo().getWeight();
146 const int w2 = pair2->mItem->getInfo().getWeight();
149 const std::string name1 =
150 pair1->mItem->getInfo().getName();
151 const std::string name2 =
152 pair2->mItem->getInfo().getName();
155 return pair1->mItem->getInvIndex() <
156 pair2->mItem->getInvIndex();
158 return name1 < name2;
172 if ((pair1->mItem ==
nullptr) || (pair2->mItem ==
nullptr))
175 const int c1 = pair1->mItem->getQuantity();
176 const int c2 = pair2->mItem->getQuantity();
179 const std::string name1 =
180 pair1->mItem->getInfo().getName();
181 const std::string name2 =
182 pair2->mItem->getInfo().getName();
185 return pair1->mItem->getInvIndex() <
186 pair2->mItem->getInvIndex();
188 return name1 < name2;
202 if ((pair1->mItem ==
nullptr) || (pair2->mItem ==
nullptr))
205 const ItemInfo &info1 = pair1->mItem->getInfo();
206 const ItemInfo &info2 = pair2->mItem->getInfo();
211 const std::string &name1 = info1.
getName();
212 const std::string &name2 = info2.
getName();
215 return pair1->mItem->getInvIndex() <
216 pair2->mItem->getInvIndex();
218 return name1 < name2;
227 const int maxColumns,
235 mSelImg(
Theme::getImageFromThemeXml(
"item_selection.xml",
"")),
236 mProtectedImg(
Theme::getImageFromTheme(
"lock.png")),
237 mCellBackgroundImg(
Theme::getImageFromThemeXml(
"inventory_cell.xml",
"")),
243 mEquipedColor(getThemeColor(
ThemeColorId::ITEM_EQUIPPED, 255U)),
244 mEquipedColor2(getThemeColor(
ThemeColorId::ITEM_EQUIPPED_OUTLINE, 255U)),
245 mUnEquipedColor(getThemeColor(
ThemeColorId::ITEM_NOT_EQUIPPED, 255U)),
246 mUnEquipedColor2(getThemeColor(
ThemeColorId::ITEM_NOT_EQUIPPED_OUTLINE,
248 mSelectionListeners(),
257 mBoxWidth(mSkin !=
nullptr ? mSkin->getOption(
"boxWidth", 35) : 35),
258 mBoxHeight(mSkin !=
nullptr ? mSkin->getOption(
"boxHeight", 43) : 43),
259 mEquippedTextPadding(mSkin !=
nullptr ? mSkin->getOption(
260 "equippedTextPadding", 29) : 29),
261 mPaddingItemX(mSkin !=
nullptr ? mSkin->getOption(
"paddingItemX", 0) : 0),
262 mPaddingItemY(mSkin !=
nullptr ? mSkin->getOption(
"paddingItemY", 0) : 0),
263 mMaxColumns(maxColumns),
264 mSelectionStatus(SEL_NONE),
265 mForceQuantity(forceQuantity),
266 mShowEmptyRows(showEmptyRows),
297 if (
theme !=
nullptr)
345 for (
int j = 0; j < maxRows; j++)
348 for (
int i = 0; i < maxColumns; i++)
376 if ((item ==
nullptr) || item->
getId() == 0)
380 if (image !=
nullptr)
389 image->setAlpha(1.0F);
419 if ((item ==
nullptr) || item->
getId() == 0)
471 for (
int j = 0; j < maxRows; j++)
474 for (
int i = 0; i < maxColumns; i++)
498 if ((item ==
nullptr) || item->
getId() == 0)
502 if (image !=
nullptr)
511 image->setAlpha(1.0F);
541 if ((item ==
nullptr) || item->
getId() == 0)
615 (*i)->valueChanged(event);
634 mClicks =
event.getClickCount();
689 else if ((item !=
nullptr) && (item->
getId() != 0))
798 bool checkProtection(
false);
859 checkProtection =
true;
866 if (inventory !=
nullptr)
883 if (inventory ==
nullptr)
927 if (inventory !=
nullptr)
945 if (item2 !=
nullptr)
951 if (inventory !=
nullptr)
968 if (inventory !=
nullptr)
1007 if (inventory !=
nullptr)
1019 if (inventory !=
nullptr)
1023 if (item !=
nullptr)
1042 if (inventory ==
nullptr)
1045 if (item ==
nullptr)
1053 if (inventory ==
nullptr)
1056 if (item ==
nullptr)
1063 if (inventory !=
nullptr)
1066 if (item !=
nullptr)
1096 if ((item !=
nullptr) && (
viewport !=
nullptr))
1177 STD_VECTOR<ItemIdPair*> sortedItems;
1181 std::string temp =
mName;
1185 for (
unsigned int idx = 0; idx < invSize; idx ++)
1189 if (item ==
nullptr ||
1190 item->
getId() == 0 ||
1195 sortedItems.push_back(
new ItemIdPair(idx,
nullptr));
1204 sortedItems.push_back(
new ItemIdPair(idx, item));
1209 if (name.find(temp) != std::string::npos)
1210 sortedItems.push_back(
new ItemIdPair(idx, item));
1219 std::sort(sortedItems.begin(), sortedItems.end(),
1226 std::sort(sortedItems.begin(), sortedItems.end(),
1230 std::sort(sortedItems.begin(), sortedItems.end(),
1234 std::sort(sortedItems.begin(), sortedItems.end(),
1241 FOR_EACH (STD_VECTOR<ItemIdPair*>::const_iterator, iter, sortedItems)
1243 if (jMult >= maxSize)
1257 for (
int idx = j *
mGridColumns + i; idx < maxSize; idx ++)
1260 const int num =
CAST_S32(sortedItems.size());
1261 for (
size_t idx = 0, sz = num; idx < sz; idx ++)
1262 delete sortedItems[idx];
void addItemText(const std::string &item)
void dragItem(const Item *const item, const DragDropSourceT source, const int tag)
DragDropSourceT getSource() const
void select(const Item *const item)
int getWidth(const std::string &text) const
void drawString(Graphics *const graphics, Color col, const Color &col2, const std::string &text, const int x, const int y)
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
virtual void drawTileCollection(const ImageCollection *const vertCol)=0
virtual void calcTileCollection(ImageCollection *const vertCol, const Image *const image, int x, int y)=0
virtual void finalize(ImageCollection *const col)
void removeDragged(const Widget *const widget)
void combineItems(const int index1, const int index2)
void virtualRemove(Item *const item, const int amount)
void removeItemAt(const int index)
Item * getItem(const int index) const
virtual bool addVirtualItem(const Item *const item, int index, const int amount)
void moveItem(const int index1, const int index2)
int getLastUsedSlot() const
static const int NO_SLOT_INDEX
InventoryTypeT getType() const
virtual void setItem(const int index, const int id, const ItemTypeT type, const int quantity, const uint8_t refine, const ItemColor color, const Identified identified, const Damaged damaged, const Favorite favorite, const Equipm equipment, const Equipped equipped)
void virtualRestore(const Item *const item, const int amount)
static void showWindow(const ItemAmountWindowUsageT usage, Window *const parent, Item *const item, int maxRange, const int tag)
Image * mCellBackgroundImg
SelectionListenerList::iterator SelectionListenerIterator
int getSlotIndex(int x, int y) const
void setFilter(const int tag)
void setSelectedIndex(const int index)
void keyReleased(KeyEvent &event)
SelectionState mSelectionStatus
void setCellBackgroundImage(const std::string &xmlName)
void mouseExited(MouseEvent &event)
void draw(Graphics *const graphics)
void keyPressed(KeyEvent &event)
ShowEmptyRows mShowEmptyRows
void widgetMoved(const Event &event)
void mouseReleased(MouseEvent &event)
int getSlotByXY(int x, int y) const
void safeDraw(Graphics *const graphics)
void setMaxColumns(const int maxColumns)
void widgetResized(const Event &event)
Item * getSelectedItem() const
ForceQuantity mForceQuantity
void distributeValueChangedEvent()
void setSortType(const int sortType)
void mousePressed(MouseEvent &event)
ImageCollection * mVertexes
ItemContainer(const Widget2 *const widget, Inventory *const inventory, const int maxColumns, const ShowEmptyRows showEmptyRows, const ForceQuantity forceQuantity)
void mouseDragged(MouseEvent &event)
SelectionListenerList mSelectionListeners
void mouseMoved(MouseEvent &event)
const std::string & getName() const
ItemDbTypeT getType() const
void setItemSelected(const int itemId)
Equipped isEquipped() const
bool isHaveTag(const int tagId) const
Favorite getFavorite() const
void setTag(const int tag)
ItemColor getColor() const
Identified getIdentified() const
ItemTypeT getType() const
Damaged getDamaged() const
const ItemInfo & getInfo() const
Inventory * getInventory() const
MouseEventTypeT getType() const
virtual void moveItem2(const InventoryTypeT source, const int slot, const int amount, const InventoryTypeT destination) const =0
virtual void moveItem(const int oldIndex, const int newIndex) const =0
virtual void addItem(const Item *const item, const int amount) const =0
virtual void removeItem(const int index, const int amount) const =0
virtual NpcDialog * getCurrentNpcDialog() const =0
virtual void addItem(const Item *const item, const int amount) const
void setItemSelected(const int id)
void unload(Skin *const skin)
static Image * getImageFromThemeXml(const std::string &name, const std::string &name2)
const unsigned int SHORTCUT_TABS
DragDropSource ::T DragDropSourceT
const bool Equipped_false
const bool ForceQuantity_true
#define FOR_EACH(type, iter, array)
Net::InventoryHandler * inventoryHandler
InventoryType ::T InventoryTypeT
InventoryWindow * inventoryWindow
ItemDbType ::T ItemDbTypeT
ItemShortcut * itemShortcut[SHORTCUT_TABS]
#define A_DELETE_COPY(func)
#define A_DEFAULT_COPY(func)
Net::Mail2Handler * mail2Handler
MailEditWindow * mailEditWindow
std::string toLower(std::string const &s)
std::string toString(T const &value)
converts any type to a string
ServerTypeT getNetworkType()
Inventory * getInventory()
Inventory * getStorageInventory()
Inventory * getCartInventory()
bool isItemProtected(const int id)
class anonymous_namespace{itemcontainer.cpp}::SortItemAmountFunctor itemAmountInvSorter
class anonymous_namespace{itemcontainer.cpp}::SortItemIdFunctor itemIdInvSorter
class anonymous_namespace{itemcontainer.cpp}::SortItemAlphaFunctor itemAlphaInvSorter
class anonymous_namespace{itemcontainer.cpp}::SortItemWeightFunctor itemWeightInvSorter
class anonymous_namespace{itemcontainer.cpp}::SortItemTypeFunctor itemTypeInvSorter
Net::TradeHandler * tradeHandler
Net::NpcHandler * npcHandler
#define BLOCK_START(name)
ShortcutWindow * itemShortcutWindow
const bool ShowEmptyRows_false
const bool ShowEmptyRows_true