49 mNpcId(npcId), mMoney(0), mAmountItems(0), mMaxItems(0)
63 mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
89 mSlider->setActionEventId(
"slider");
90 mSlider->addActionListener(
this);
156 if (event.getId() ==
"quit")
165 if (selectedItem < 0 ||
171 if (event.getId() ==
"slider")
188 else if (event.getId() ==
"max")
238 if (selectedItem > -1)
241 const int itemPrice = shopItem->
getPrice();
261 const int myFreeWeight = myMaxWeight - myTotalWeight;
262 const int canCarry = myFreeWeight / itemWeight;
void reset()
Resets the dialog, clearing shop inventory.
static DialogList instances
gcn::Button * mQuitButton
gcn::Label * mQuantityLabel
static void closeAll()
Closes all instances.
void action(const gcn::ActionEvent &event) override
Called when receiving actions from the widgets.
gcn::ScrollArea * mScrollArea
void addItem(int id, int amount, int price)
Adds an item to the shop inventory.
std::list< BuyDialog * > DialogList
gcn::Button * mDecreaseButton
gcn::Button * mAddMaxButton
gcn::Button * mIncreaseButton
void mouseClicked(gcn::MouseEvent &mouseEvent) override
Allows for quick-buying by extending double-click events.
void updateButtonsAndLabels()
Updates the state of buttons and labels.
ShopListBox * mShopItemList
void setVisible(bool visible) override
Sets the visibility of this window.
void valueChanged(const gcn::SelectionEvent &event) override
Updates the labels according to the selected item.
void setMoney(int amount)
Sets the amount of available money.
This class is a helper for adding widgets to nested tables in a window.
int weight
Weight in grams.
int getId() const
Returns the item id.
const ItemInfo & getInfo() const
Returns information about this item type.
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.
virtual void buyItem(int beingId, int itemId, int amount)=0
Represents an item in a shop inventory.
int getPrice() const
Gets the price of the item.
This class handles the list of items available in a shop.
void addItem(int id, int amount, int price)
Adds an item to the list.
ShopItem * at(int i) const
Returns the item number i in the shop.
int getNumberOfElements() override
Returns the number of items in the shop.
void clear()
Clears the list of items in the shop.
A list box, meant to be used inside a scroll area.
void setPlayersMoney(int money)
gives information about the current player's money
void adjustSize()
Adjust List draw size.
static std::string formatCurrency(int value)
Formats the given number in the correct currency format.
void center()
Positions the window in the center of it's parent.
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.
virtual void close()
Overrideable functionality for when the window is to close.
Layout & getLayout()
Gets the layout handler for this window.
void setWindowName(const std::string &name)
Sets the name of the window.
ContainerPlacer getPlacer(int x, int y)
Returns a proxy for adding widgets in an inner table of the layout.
void setResizable(bool resize)
Sets whether or not the window can be resized.
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 ...
NpcHandler * getNpcHandler()
void setBuySellState(BuySellState buySellState)
Sets which buy, sell, or related interaction the player is currently involved in.
BuySellState getBuySellState()
Returns the current buy, sell, or related interaction the player is involved in.
int getAttribute(int id)
Returns the value of the given attribute.
std::string strprintf(char const *format,...)
A safe version of sprintf that returns a std::string of the result.