diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-01-31 03:09:23 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-01-31 03:09:23 +0000 |
commit | be1f90d40f50eb67fa641bd55e109af8338239c7 (patch) | |
tree | f7776993ec2fd8934bddb2e148aa407f15d28ce3 /src/gui/requesttrade.cpp | |
parent | efbf5fa72206086a7563ccfeddd601d324c7912f (diff) | |
download | mana-be1f90d40f50eb67fa641bd55e109af8338239c7.tar.gz mana-be1f90d40f50eb67fa641bd55e109af8338239c7.tar.bz2 mana-be1f90d40f50eb67fa641bd55e109af8338239c7.tar.xz mana-be1f90d40f50eb67fa641bd55e109af8338239c7.zip |
Made RequestTradeDialog inherit from ConfirmDialog.
Diffstat (limited to 'src/gui/requesttrade.cpp')
-rw-r--r-- | src/gui/requesttrade.cpp | 58 |
1 files changed, 8 insertions, 50 deletions
diff --git a/src/gui/requesttrade.cpp b/src/gui/requesttrade.cpp index 54f7c208..9d61e860 100644 --- a/src/gui/requesttrade.cpp +++ b/src/gui/requesttrade.cpp @@ -23,59 +23,17 @@ #include "requesttrade.h" -#include <guichan/widgets/label.hpp> - -#include "button.h" - #include "../localplayer.h" -RequestTradeDialog::RequestTradeDialog(const std::string &name): - Window("Request for Trade", true) +struct RequestTradeListener : public gcn::ActionListener { - gcn::Label *nameLabel[2]; - nameLabel[0] = new gcn::Label(""); - nameLabel[1] = new gcn::Label(""); - mAcceptButton = new Button("Accept"); - mCancelButton = new Button("Cancel"); - - setContentSize(260, 75); - - nameLabel[0]->setPosition(5, 30); - nameLabel[1]->setPosition(5, 40); - mCancelButton->setPosition( - 260 - 5 - mCancelButton->getWidth(), - 75 - 5 - mCancelButton->getHeight()); - mAcceptButton->setPosition( - mCancelButton->getX() - 5 - mAcceptButton->getWidth(), - mCancelButton->getY()); - - mAcceptButton->setEventId("accept"); - mCancelButton->setEventId("cancel"); - - mAcceptButton->addActionListener(this); - mCancelButton->addActionListener(this); + void action(const std::string& eventId) + { + player_node->tradeReply(eventId == "yes"); + }; +} requestTradeListener; - add(nameLabel[0]); - add(nameLabel[1]); - add(mAcceptButton); - add(mCancelButton); - - nameLabel[0]->setCaption(name + " wants to trade with you."); - nameLabel[0]->adjustSize(); - nameLabel[1]->setCaption("Do you want to accept?"); - nameLabel[1]->adjustSize(); - - setLocationRelativeTo(getParent()); -} - -void RequestTradeDialog::action(const std::string& eventId) +RequestTradeDialog::RequestTradeDialog(const std::string &name): + ConfirmDialog("Request for Trade", name + " wants to trade with you, do you accept?", &requestTradeListener) { - bool accept = false; - - if (eventId == "accept") { - accept = true; - } - - player_node->tradeReply(accept); - scheduleDelete(); } |