64 const char *key = SDL_GetKeyName(
68 state.
x + skin.padding + 2,
69 state.
y + skin.padding + 2,
79 if (
Image *image = item->getImage())
82 if (item->getQuantity() > 1)
83 caption =
toString(item->getQuantity());
84 else if (item->isEquipped())
87 image->setAlpha(1.0f);
88 g->drawImage(image, state.
x + skin.padding, state.
y + skin.padding);
89 if (item->isEquipped())
94 gcn::Graphics::CENTER);
104 const int tPosX =
mCursorPosX - (image->getWidth() / 2);
105 const int tPosY =
mCursorPosY - (image->getHeight() / 2);
107 g->drawImage(image, tPosX, tPosY);
110 gcn::Graphics::CENTER);
117 if (event.getButton() == gcn::MouseEvent::LEFT)
151 if (event.getButton() == gcn::MouseEvent::LEFT)
162 else if (event.getButton() == gcn::MouseEvent::RIGHT)
178 if (event.getButton() == gcn::MouseEvent::LEFT)
A central point of control for graphics.
void setColor(const gcn::Color &color) override
Theme * getTheme() const
The global GUI theme.
Defines a class for loading and storing images.
Item * findItem(int itemId) const
Searches for the specified item by it's id.
Item * getItemAt(int x, int y) const
void mousePressed(gcn::MouseEvent &event) override
Handles mouse when pressed.
void draw(gcn::Graphics *graphics) override
Draws the items.
void mouseReleased(gcn::MouseEvent &event) override
Handles mouse release.
void mouseMoved(gcn::MouseEvent &event) override
void mouseExited(gcn::MouseEvent &event) override
void mouseDragged(gcn::MouseEvent &event) override
Handles mouse when dragged.
std::unique_ptr< ItemPopup > mItemPopup
~ItemShortcutContainer() override
int getItemCount() const
Returns the amount of shortcut items.
void useItem(int index)
Try to use the item specified by the index.
int getItem(int index) const
Returns the shortcut item ID specified by the index.
void setItems(int index, int itemId)
Adds an item to the items store specified by the index.
void setItem(int index)
Adds the selected item ID to the items specified by the index.
void removeItem(int index)
Remove a item from the shortcut.
bool isItemSelected()
A flag to check if the item is selected.
void setItemSelected(int itemId)
Set the item that is selected.
Represents one or more instances of a certain item type.
int getQuantity() const
Returns the number of items.
int getId() const
Returns the item id.
Image * getImage() const
Returns the item image.
int getKeyValue(int index) const
Obtain the value stored in memory.
int getIndexFromGrid(int pointX, int pointY) const
Gets the index from the grid provided the point is in an item box.
const Skin & getSkin(SkinType skinType) const
static const gcn::Color & getThemeColor(int type)
Gets the color associated with the type in the default palette (0).
int getMouseY() const
Returns mouse y in pixels.
int getMouseX() const
Returns mouse x in pixels.
void showPopup(Window *parent, int x, int y, Item *item, bool isInventory=true, bool canDrop=true)
Shows a popup for an item.
InventoryWindow * inventoryWindow
Viewport * viewport
Viewport on the map.
ItemShortcut * itemShortcut
Inventory * getInventory()
Returns the player's inventory.
std::string toString(const T &arg)
Converts the given value to a string using std::stringstream.