48#include <guichan/font.hpp>
59 playerBox->setDimension(gcn::Rectangle(50, 80, 74, 123));
70 const gcn::Rectangle &area = getChildrenArea();
72 area.height -
mUnequip->getHeight() - getPadding());
95 for (
int i = 0; i < boxCount; ++i)
98 boxPos.
x += getPadding();
99 boxPos.
y += getTitleBarHeight();
101 WidgetState boxState(gcn::Rectangle(boxPos.
x, boxPos.
y, boxSkin.width, boxSkin.height));
105 boxSkin.draw(g, boxState);
109 if (
Image *image = item->getImage())
111 image->setAlpha(1.0f);
113 boxPos.
x + boxSkin.padding,
114 boxPos.
y + boxSkin.padding);
121 boxPos.
x + boxSkin.width / 2,
122 boxPos.
y - getFont()->getHeight(),
123 gcn::Graphics::CENTER);
130 if (
auto image = theme->getIcon(icon))
131 g->drawImage(image, boxPos.
x + boxSkin.padding, boxPos.
y + boxSkin.padding);
138 if (event.getId() ==
"unequip" &&
mSelected > -1)
154 const auto childrenArea =
const_cast<EquipmentWindow*
>(
this)->getChildrenArea();
159 for (
int i = 0; i < boxCount; ++i)
162 const gcn::Rectangle tRect(boxPos.
x, boxPos.
y, boxSkin.width, boxSkin.height);
163 if (tRect.isPointInRect(x, y))
186 const int x = mouseEvent.getX();
187 const int y = mouseEvent.getY();
188 Item *item =
nullptr;
198 if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT)
205 const int mx = x + getX();
206 const int my = y + getY();
216 const int x =
event.getX();
217 const int y =
event.getY();
221 if (!slotName.empty())
EquipmentWindow(Equipment *equipment)
~EquipmentWindow() override
void setSelected(int index)
void action(const gcn::ActionEvent &event) override
void mouseMoved(gcn::MouseEvent &event) override
int mSelected
Index of selected item.
Item * getItem(int x, int y) const
void mouseExited(gcn::MouseEvent &event) override
int getBoxIndex(int x, int y) const
Returns an index of an equipment box at the given position, or -1 if there is no box.
std::string getSlotName(int x, int y) const
void draw(gcn::Graphics *graphics) override
Draws the equipment window.
void mousePressed(gcn::MouseEvent &mouseEvent) override
void triggerUnequip(int slotIndex) const
Item * getEquipment(int slotIndex) const
Get equipment at the given slot.
int getSlotNumber() const
std::string getSlotName(int slotIndex) const
A central point of control for graphics.
void drawText(const std::string &text, int x, int y, gcn::Graphics::Alignment alignment, const gcn::Color &color, gcn::Font *font, bool outline=false, bool shadow=false, const std::optional< gcn::Color > &outlineColor={}, const std::optional< gcn::Color > &shadowColor={})
Theme * getTheme() const
The global GUI theme.
Defines a class for loading and storing images.
Represents one or more instances of a certain item type.
virtual Position getBoxPosition(unsigned int slotIndex) const
virtual const std::string & getBoxIcon(unsigned int slotIndex) const
A box showing a player character.
void setPlayer(const Being *being)
Sets a new player character to be displayed by this box.
void registerWindowForReset(Window *window)
Enables the Reset Windows button.
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).
void showPopup(Window *parent, int x, int y, Item *item, bool isInventory=true, bool canDrop=true)
Shows a popup for an item.
void draw(gcn::Graphics *graphics) override
Draws the window contents.
void setContentSize(int width, int height)
Sets the size of this window.
void setWindowName(const std::string &name)
Sets the name of the window.
void mouseMoved(gcn::MouseEvent &event) override
Implements custom cursor image changing context, based on mouse relative position.
void setSaveVisible(bool save)
Sets whether the window will save it's visibility.
void mouseExited(gcn::MouseEvent &event) override
When the mouse leaves the window this ensures that the custom cursor is restored back to it's standar...
void setCloseButton(bool flag)
Sets whether or not the window has a close button.
void setDefaultSize()
Set the default win pos and size to the current ones.
void loadWindowState()
Reads the position (and the size for resizable windows) in the configuration based on the given strin...
void mousePressed(gcn::MouseEvent &event) override
Starts window resizing when appropriate.
Viewport * viewport
Viewport on the map.
LocalPlayer * local_player
InventoryHandler * getInventoryHandler()
std::string toString(const T &arg)
Converts the given value to a string using std::stringstream.
A position along a being's path.