diff options
author | Jan-Fabian Humann <malastare@gmx.net> | 2005-04-07 20:43:13 +0000 |
---|---|---|
committer | Jan-Fabian Humann <malastare@gmx.net> | 2005-04-07 20:43:13 +0000 |
commit | f0f9ef367f769b861748595b6e67991cea4b1613 (patch) | |
tree | dcf67ec60aa2bd1f3c776e155a3dae32d9143b24 /src/gui | |
parent | 0f25aa9db4ee635cd25d14b20e0c9cdee8c7702f (diff) | |
download | mana-client-f0f9ef367f769b861748595b6e67991cea4b1613.tar.gz mana-client-f0f9ef367f769b861748595b6e67991cea4b1613.tar.bz2 mana-client-f0f9ef367f769b861748595b6e67991cea4b1613.tar.xz mana-client-f0f9ef367f769b861748595b6e67991cea4b1613.zip |
trade updated: trade is now possible, but some bugs are still to be fixed by me and zeny and different amount trading will need to be implemented
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/trade.cpp | 63 | ||||
-rw-r--r-- | src/gui/trade.h | 13 |
2 files changed, 73 insertions, 3 deletions
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index d4c5e0f6..8da3ba1a 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -36,17 +36,31 @@ TradeWindow::TradeWindow(): setContentSize(322, 130); addButton = new Button("Add"); + okButton = new Button("Ok"); cancelButton = new Button("Cancel"); + tradeButton = new Button("Trade"); + addButton->setPosition(2, 105); - cancelButton->setPosition(200, 105); + okButton->setPosition(30, 105); + cancelButton->setPosition(270, 105); + tradeButton->setPosition(230,105); addButton->setEventId("add"); + okButton->setEventId("ok"); cancelButton->setEventId("cancel"); + tradeButton->setEventId("trade"); + addButton->addActionListener(this); + okButton->addActionListener(this); cancelButton->addActionListener(this); + tradeButton->addActionListener(this); + + tradeButton->setEnabled(false); add(addButton); + add(okButton); add(cancelButton); + add(tradeButton); nameLabel = new gcn::Label("Other one"); nameLabel->setPosition(2, 45); @@ -68,7 +82,9 @@ TradeWindow::TradeWindow(): TradeWindow::~TradeWindow() { delete addButton; + delete okButton; delete cancelButton; + delete tradeButton; delete nameLabel; } @@ -119,6 +135,38 @@ int TradeWindow::increaseQuantity(int index, bool own, int quantity) { int TradeWindow::reset() { my_items->resetItems(); trade_items->resetItems(); + tradeButton->setEnabled(false); + okButton->setEnabled(true); + ok_other = false; + ok_me = false; + return 0; +} + +int TradeWindow::setTradeButton(bool enabled) { + tradeButton->setEnabled(enabled); + return 0; +} + +int TradeWindow::receivedOk(bool own) { + if (own) { + ok_me = true; + if (ok_other) { + tradeButton->setEnabled(true); + okButton->setEnabled(false); + } else { + tradeButton->setEnabled(false); + okButton->setEnabled(false); + } + } else { + ok_other = true; + if (ok_me) { + tradeButton->setEnabled(true); + okButton->setEnabled(false); + } else { + tradeButton->setEnabled(false); + okButton->setEnabled(true); + } + } return 0; } @@ -161,6 +209,8 @@ void TradeWindow::action(const std::string &eventId) { if (eventId == "add") { + // This is still kinda buggy, when ok is clicked, will need to play + // RO a bit to review its trade behaviour if (inventoryWindow->items->getIndex() >= 0 && inventoryWindow->items->getIndex() <= INVENTORY_SIZE) { if (tradeWindow->my_items->getFreeSlot() >= 0) { @@ -169,14 +219,23 @@ void TradeWindow::action(const std::string &eventId) WFIFOW(2) = net_w_value(inventoryWindow->items->getIndex()); WFIFOL(4) = net_l_value(inventoryWindow->items->getQuantity()); WFIFOSET(8); + //chatWindow->chat_log("add packet sent", BY_SERVER); while ((out_size > 0)) flush(); - + } } } else if (eventId == "cancel") { WFIFOW(0) = net_w_value(0x00ed); WFIFOSET(2); while ((out_size > 0)) flush(); + } else if (eventId == "ok") { + WFIFOW(0) = net_w_value(0x00eb); + WFIFOSET(2); + while ((out_size > 0)) flush(); + } else if (eventId == "trade") { + WFIFOW(0) = net_w_value(0x00ef); + WFIFOSET(2); + while ((out_size > 0)) flush(); } //if(selectedItem >= 0 && selectedItem <= INVENTORY_SIZE) { diff --git a/src/gui/trade.h b/src/gui/trade.h index 256f051d..8eca64eb 100644 --- a/src/gui/trade.h +++ b/src/gui/trade.h @@ -77,6 +77,16 @@ class TradeWindow : public Window, gcn::ActionListener { * Increase quantity of an item. */ int increaseQuantity(int index, bool own, int quantity); + + /** + * Set trade Button disabled + */ + int setTradeButton(bool enabled); + + /** + * Player received ok message from server + */ + int receivedOk(bool own); /** * Called when receiving actions from the widgets. @@ -88,7 +98,8 @@ class TradeWindow : public Window, gcn::ActionListener { private: gcn::Label *nameLabel; - gcn::Button *addButton, *cancelButton; + gcn::Button *addButton, *okButton, *cancelButton, *tradeButton; + bool ok_other, ok_me; }; #endif |