00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef TRADE_H
00023 #define TRADE_H
00024
00025 #include "gui/widgets/window.h"
00026
00027 #include "guichanfwd.h"
00028
00029 #include <guichan/actionlistener.hpp>
00030 #include <guichan/selectionlistener.hpp>
00031
00032 #include <memory>
00033
00034 class Inventory;
00035 class Item;
00036 class ItemContainer;
00037 class ScrollArea;
00038
00044 class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener
00045 {
00046 public:
00050 TradeWindow();
00051
00055 ~TradeWindow();
00056
00060 void setMoney(int quantity);
00061
00065 void addItem(int id, bool own, int quantity);
00066
00070 void reset();
00071
00075 void addItem(int id, bool own, int quantity, bool equipment);
00076
00080 void changeQuantity(int index, bool own, int quantity);
00081
00085 void increaseQuantity(int index, bool own, int quantity);
00086
00090 void receivedOk(bool own);
00091
00095 void tradeItem(Item *item, int quantity);
00096
00101 void valueChanged(const gcn::SelectionEvent &event);
00102
00106 void action(const gcn::ActionEvent &event);
00107
00112 void close();
00113
00114 private:
00115 enum Status
00116 {
00117 PREPARING,
00118 PROPOSING,
00119 ACCEPTING,
00120 ACCEPTED
00121 };
00122
00126 void setStatus(Status s);
00127
00128 typedef const std::auto_ptr<Inventory> InventoryPtr;
00129 InventoryPtr mMyInventory;
00130 InventoryPtr mPartnerInventory;
00131
00132 ItemContainer *mMyItemContainer;
00133 ItemContainer *mPartnerItemContainer;
00134
00135 gcn::Label *mMoneyLabel;
00136 gcn::Button *mAddButton;
00137 gcn::Button *mOkButton;
00138 gcn::Button *mMoneyChangeButton;
00139 gcn::TextField *mMoneyField;
00140
00141 Status mStatus;
00142 bool mOkOther, mOkMe;
00143 };
00144
00145 extern TradeWindow *tradeWindow;
00146
00147 #endif