47#include <guichan/font.hpp>
49#define CAPTION_PROPOSE _("Propose trade")
50#define CAPTION_CONFIRMED _("Confirmed. Waiting...")
51#define CAPTION_ACCEPT _("Agree trade")
52#define CAPTION_ACCEPTED _("Agreed. Waiting...")
68 std::string longestName = getFont()->getWidth(
_(
"OK")) >
69 getFont()->getWidth(
_(
"Trade")) ?
86 myScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
92 partnerScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
95 gcn::Label *mMoneyLabel2 =
new Label(
_(
"You give:"));
106 place(0, 0, mMoneyLabel2);
113 layout.
extend(0, 2, 2, 1);
152 mMyInventory->getItem(index)->increaseQuantity(quantity);
212 mOkButton->setActionEventId(std::string());
220 mOkButton->setActionEventId(std::string());
233 if (event.getId() ==
"add")
253 "overlap one kind of item on the window."));
262 else if (event.getId() ==
"cancel")
269 else if (event.getId() ==
"ok")
278 else if (event.getId() ==
"trade")
284 else if (event.getId() ==
"money")
This class is a helper for adding widgets to nested tables in a window.
Item * getSelectedItem() const
Returns the selected 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 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.
void selectNone()
Sets selected item to NULL.
Represents one or more instances of a certain item type.
void setRowHeight(int n, int h)
LayoutCell & setPadding(int p)
Sets the padding around the cell content.
void setColWidth(int n, int w)
LayoutCell & setHAlign(Alignment a)
Sets the horizontal alignment of the cell content.
void extend(int x, int y, int w, int h)
This class is an helper for setting the position of widgets.
@ AUTO_SET
Uses the share as the new size.
virtual void setMoney(int amount)
void registerWindowForReset(Window *window)
Enables the Reset Windows button.
void addItem(int id, bool own, int quantity)
Add an item to the trade window.
void action(const gcn::ActionEvent &event) override
Called when receiving actions from the widgets.
void reset()
Reset both item containers.
@ PREPARING
Players are adding items.
@ ACCEPTED
Local player has accepted the trade.
@ ACCEPTING
Accepting the trade.
@ PROPOSING
Local player has confirmed the trade.
void receivedOk(bool own)
Player received ok message from server.
void valueChanged(const gcn::SelectionEvent &event) override
Updates the labels and makes sure only one item is selected in either my inventory or partner invento...
const std::unique_ptr< Inventory > mPartnerInventory
gcn::Button * mMoneyChangeButton
void setStatus(Status s)
Sets the current status of the trade.
ItemContainer * mPartnerItemContainer
void increaseQuantity(int index, bool own, int quantity)
Increase quantity of an item.
void changeQuantity(int index, bool own, int quantity)
Change quantity of an item.
ItemContainer * mMyItemContainer
const std::unique_ptr< Inventory > mMyInventory
gcn::TextField * mMoneyField
void setMoney(int quantity)
Displays expected money in the trade window.
void close() override
Closes the Trade Window, as well as telling the server that the window has been closed.
static std::string formatCurrency(int value)
Formats the given number in the correct currency format.
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.
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 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.
void serverNotice(const std::string &message)
InventoryWindow * inventoryWindow
TradeHandler * getTradeHandler()
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.
#define CAPTION_CONFIRMED