40#include <guichan/mouseinput.hpp>
41#include <guichan/selectionlistener.hpp>
53 addMouseListener(
this);
54 addWidgetListener(
this);
79 g->setFont(getFont());
90 if (!item || item->
getId() == 0)
115 int itemX = i * slotSkin.
width;
116 int itemY = j * slotSkin.height;
130 itemX =
mDragPosX - (slotSkin.width / 2);
131 itemY =
mDragPosY - (slotSkin.height / 2);
135 slotSkin.draw(g, slotState);
139 if (!item || item->
getId() == 0)
144 image->setAlpha(1.0f);
145 g->drawImage(image, itemX + slotSkin.padding, itemY + slotSkin.padding);
160 g->drawText(caption, itemX + slotSkin.width / 2,
161 itemY + slotSkin.height - 14, gcn::Graphics::CENTER);
170 g->setColor(gcn::Color(255, 128, 0));
171 g->drawRectangle(gcn::Rectangle(itemX, itemY, slotSkin.width, slotSkin.height));
211 gcn::SelectionEvent event(
this);
212 listener->valueChanged(event);
266 const int button =
event.getButton();
267 if (button == gcn::MouseEvent::LEFT || button == gcn::MouseEvent::RIGHT)
269 const int index =
getSlotIndex(event.getX(), event.getY());
294 else if (item && item->
getId())
346 event.setItem(
"item", item);
347 event.setInt(
"newIndex", index);
378 mGridColumns = std::max(1, getWidth() / slotSkin.width);
395 if (x >= getWidth() || y >= getHeight())
399 const auto row = y / slotSkin.
height;
400 const auto column = x / slotSkin.width;
426 event.setItem(
"item", item);
442 event.setItem(
"item", item);
void addItemText(const std::string &item)
Called to add item to chat.
A central point of control for graphics.
Theme * getTheme() const
The global GUI theme.
Defines a class for loading and storing images.
int getLastUsedSlot() const
Returns the index of the last occupied slot or 0 if none occupied.
Item * getItem(int index) const
Returns the item at the specified index.
static const int NO_SLOT_INDEX
Slot has no index.
int getSlotIndex(int x, int y) const
Gets the slot index based on the cursor position.
void widgetResized(const gcn::Event &event) override
void setSelectedIndex(int index)
Sets the currently selected item.
SelectionState mSelectionStatus
void mouseExited(gcn::MouseEvent &event) override
void setFilter(const std::string &filter)
Sets item filter.
void mouseMoved(gcn::MouseEvent &event) override
Item * getItemAt(int) const
void keyReleased(gcn::KeyEvent &event) override
void keyPressed(gcn::KeyEvent &event) override
~ItemContainer() override
void logic() override
Necessary for checking how full the inventory is.
std::list< gcn::SelectionListener * > mSelectionListeners
void mousePressed(gcn::MouseEvent &event) override
void mouseReleased(gcn::MouseEvent &event) override
Item * getSelectedItem() const
Returns the selected item.
void selectNone()
Sets selected item to NULL.
void moveHighlight(Direction direction)
Moves the highlight in the direction specified.
void distributeValueChangedEvent()
Sends out selection events to the list of selection listeners.
void draw(gcn::Graphics *graphics) override
Draws the items.
void adjustHeight()
Determine and set the height of the container.
ItemContainer(Inventory *inventory)
Constructor.
void keyAction()
Execute all the functionality associated with the action key.
std::map< int, Item * > mFilteredMap
void mouseDragged(gcn::MouseEvent &event) override
void setItemSelected(int itemId)
Set the item that is selected.
Represents one or more instances of a certain item type.
bool isEquipped() const
Returns whether this item is equipped.
int getQuantity() const
Returns the number of items.
int getId() const
Returns the item id.
Image * getImage() const
Returns the item image.
bool isEquippable() const
Returns whether this item is equippable.
const ItemInfo & getInfo() const
Returns information about this item type.
void setItemSelected(int itemId)
const Skin & getSkin(SkinType skinType) const
int getMouseY() const
Returns mouse y in pixels.
int getMouseX() const
Returns mouse x in pixels.
OutfitWindow * outfitWindow
Viewport * viewport
Viewport on the map.
ItemShortcut * itemShortcut
std::string normalize(const std::string &name)
Normalize a string, which means lowercase and trim it.
std::string toString(const T &arg)
Converts the given value to a string using std::stringstream.