diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-01-22 13:31:13 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-01-22 13:31:13 +0000 |
commit | bd56bf8afdab16383ed8ad08412a8c807f84af85 (patch) | |
tree | 0e963ada63bcbe3c50dd77986aaa15b9ba49816a /src/gui/requesttrade.cpp | |
parent | 5359640b6f271af31f6423df9d661433eff89a3e (diff) | |
download | mana-bd56bf8afdab16383ed8ad08412a8c807f84af85.tar.gz mana-bd56bf8afdab16383ed8ad08412a8c807f84af85.tar.bz2 mana-bd56bf8afdab16383ed8ad08412a8c807f84af85.tar.xz mana-bd56bf8afdab16383ed8ad08412a8c807f84af85.zip |
Merged NETWORK branch (includes BEING_OVERHAUL).
Diffstat (limited to 'src/gui/requesttrade.cpp')
-rw-r--r-- | src/gui/requesttrade.cpp | 54 |
1 files changed, 21 insertions, 33 deletions
diff --git a/src/gui/requesttrade.cpp b/src/gui/requesttrade.cpp index 075567af..54f7c208 100644 --- a/src/gui/requesttrade.cpp +++ b/src/gui/requesttrade.cpp @@ -23,53 +23,46 @@ #include "requesttrade.h" -#include <sstream> #include <guichan/widgets/label.hpp> #include "button.h" -#include "../net/messageout.h" -#include "../net/protocol.h" - -bool requestTradeDialogOpen = false; +#include "../localplayer.h" RequestTradeDialog::RequestTradeDialog(const std::string &name): Window("Request for Trade", true) { + gcn::Label *nameLabel[2]; nameLabel[0] = new gcn::Label(""); nameLabel[1] = new gcn::Label(""); - acceptButton = new Button("Accept"); - cancelButton = new Button("Cancel"); + mAcceptButton = new Button("Accept"); + mCancelButton = new Button("Cancel"); setContentSize(260, 75); nameLabel[0]->setPosition(5, 30); nameLabel[1]->setPosition(5, 40); - cancelButton->setPosition( - 260 - 5 - cancelButton->getWidth(), - 75 - 5 - cancelButton->getHeight()); - acceptButton->setPosition( - cancelButton->getX() - 5 - acceptButton->getWidth(), - cancelButton->getY()); + mCancelButton->setPosition( + 260 - 5 - mCancelButton->getWidth(), + 75 - 5 - mCancelButton->getHeight()); + mAcceptButton->setPosition( + mCancelButton->getX() - 5 - mAcceptButton->getWidth(), + mCancelButton->getY()); - acceptButton->setEventId("accept"); - cancelButton->setEventId("cancel"); + mAcceptButton->setEventId("accept"); + mCancelButton->setEventId("cancel"); - acceptButton->addActionListener(this); - cancelButton->addActionListener(this); + mAcceptButton->addActionListener(this); + mCancelButton->addActionListener(this); add(nameLabel[0]); add(nameLabel[1]); - add(acceptButton); - add(cancelButton); - - std::stringstream cap[2]; - cap[0] << name << " wants to trade with you."; - cap[1] << "Do you want to accept?"; + add(mAcceptButton); + add(mCancelButton); - nameLabel[0]->setCaption(cap[0].str()); + nameLabel[0]->setCaption(name + " wants to trade with you."); nameLabel[0]->adjustSize(); - nameLabel[1]->setCaption(cap[1].str()); + nameLabel[1]->setCaption("Do you want to accept?"); nameLabel[1]->adjustSize(); setLocationRelativeTo(getParent()); @@ -77,17 +70,12 @@ RequestTradeDialog::RequestTradeDialog(const std::string &name): void RequestTradeDialog::action(const std::string& eventId) { - int choice = 4; // 4 means trade canceled + bool accept = false; if (eventId == "accept") { - choice = 3; // ok to trade - } - else if (eventId == "cancel") { - requestTradeDialogOpen = false; + accept = true; } - MessageOut outMsg; - outMsg.writeInt16(CMSG_TRADE_RESPONSE); - outMsg.writeInt8(choice); + player_node->tradeReply(accept); scheduleDelete(); } |