48#include <guichan/font.hpp>
49#include <guichan/mouseinput.hpp>
56 Window(inventory->isMainInventory() ?
_(
"Inventory") :
_(
"Storage")),
57 mInventory(inventory),
80 invenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
88 std::string equip =
_(
"Equip");
89 std::string use =
_(
"Use");
90 std::string unequip =
_(
"Unequip");
92 std::string longestUseString = getFont()->getWidth(equip) >
93 getFont()->getWidth(use) ? equip : use;
95 if (getFont()->getWidth(longestUseString) <
96 getFont()->getWidth(unequip))
98 longestUseString = unequip;
132 place(0, 2, invenScroll, 4, 4);
165 if (
event.getId() ==
"outfit")
174 else if (
event.getId() ==
"store")
189 if (
event.getId() ==
"activate")
193 else if (
event.getId() ==
"equip")
207 else if (
event.getId() ==
"drop")
211 else if (
event.getId() ==
"retrieve")
235 Window::mouseClicked(
event);
257 if (
event.getButton() == gcn::MouseEvent::RIGHT)
262 const int mx =
event.getX() + getX();
263 const int my =
event.getY() + getY();
267 if (
event.getButton() == gcn::MouseEvent::LEFT)
274 event.setItem(
"item", item);
283 event.setItem(
"item", item);
350 const int id =
event.getInt(
"id");
381 if (instance->isInputFocused())
void listen(Event::Channel channel)
gcn::Button * mRetrieveButton
void updateButtons()
Updates the buttons.
void mouseClicked(gcn::MouseEvent &event) override
Handles the mouse clicks.
InventoryWindow(Inventory *inventory)
static WindowList instances
gcn::Label * mWeightLabel
void keyReleased(gcn::KeyEvent &event) override
Handles the key releases.
~InventoryWindow() override
gcn::Button * mStoreButton
gcn::Button * mEquipButton
void valueChanged(const gcn::SelectionEvent &event) override
Updates labels to currently selected item.
void widgetHidden(const gcn::Event &event) override
Handles closing of the window.
bool isMainInventory() const
bool isInputFocused() const
static bool isAnyInputFocused()
void event(Event::Channel channel, const Event &event) override
gcn::Button * mDropButton
gcn::Button * mOutfitButton
void updateWeight()
Updates the weight bar.
void action(const gcn::ActionEvent &event) override
Called when receiving actions from the widgets.
void slotsChanged(Inventory *inventory) override
std::list< InventoryWindow * > WindowList
gcn::Label * mFilterLabel
void close() override
Closes the Storage Window, as well as telling the server that the window has been closed.
Item * getSelectedItem() const
Returns the selected item.
bool isMainInventory() const
void removeInventoryListener(InventoryListener *listener)
void addInventoryListener(InventoryListener *listener)
int getSize() const
Returns the size that this instance is configured for.
int getNumberOfSlotsUsed() const
Get the number of slots filled with an item.
static void showWindow(Usage usage, Window *parent, Item *item, int maxRange=0)
Creates the dialog, or bypass it if there aren't enough items.
void setFilter(const std::string &filter)
Sets item filter.
void addSelectionListener(gcn::SelectionListener *listener)
Adds a listener to the list that's notified each time a change to the selection occurs.
Item * getSelectedItem() const
Returns the selected item.
bool activatable
Whether this item can be activated.
Represents one or more instances of a certain item type.
void doEvent(Event::Type eventType)
bool isEquipped() const
Returns whether this item is equipped.
int getQuantity() const
Returns the number of items.
int getInvIndex() const
Returns the inventory index of this item.
bool isEquippable() const
Returns whether this item is equippable.
const ItemInfo & getInfo() const
Returns information about this item type.
bool isKeyActive(int index) const
Checks if the key is active, by providing the key function index.
void setRowHeight(int n, int h)
LayoutCell & setPadding(int p)
Sets the padding around the cell content.
This class is an helper for setting the position of widgets.
@ AUTO_SET
Uses the share as the new size.
void setProgress(float progress)
Sets the current progress.
void setText(const std::string &text)
Sets the text shown on the progress bar.
void registerWindowForReset(Window *window)
Enables the Reset Windows button.
static std::string formatWeight(int value)
Formats the given number in the correct weight/mass format.
void showPopup(Window *parent, int x, int y, Item *item, bool isInventory=true, bool canDrop=true)
Shows a popup for an item.
virtual void setVisible(bool visible)
Overloads window setVisible by Guichan to allow sticky window handling.
void setMinHeight(int height)
Sets the minimum height of the window.
Layout & getLayout()
Gets the layout handler for this window.
void setWindowName(const std::string &name)
Sets the name of the window.
void setResizable(bool resize)
Sets whether or not the window can be resized.
void widgetHidden(const gcn::Event &event) override
Called whenever the widget is hidden.
void setSaveVisible(bool save)
Sets whether the window will save it's visibility.
LayoutCell & place(int x, int y, gcn::Widget *, int w=1, int h=1)
Adds a widget to the window and sets it at given cell.
void scheduleDelete()
Schedule this window for deletion.
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 setMinWidth(int width)
Sets the minimum width of the window.
bool isDoubleClick(int selected)
Returns whether this call and the last call were done for the same selected index and within a short ...
OutfitWindow * outfitWindow
Viewport * viewport
Viewport on the map.
InventoryWindow * inventoryWindow
int getStorageCount()
Returns the number of currently open storage windows.
int getAttribute(int id)
Returns the value of the given attribute.
void setStorageCount(int count)
Sets the number of currently open storage windows.
std::string strprintf(char const *format,...)
A safe version of sprintf that returns a std::string of the result.