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 | |
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')
-rw-r--r-- | src/gui/requesttrade.cpp | 58 | ||||
-rw-r--r-- | src/gui/requesttrade.h | 17 |
2 files changed, 10 insertions, 65 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(); } diff --git a/src/gui/requesttrade.h b/src/gui/requesttrade.h index d9ea67ed..5aa41ddb 100644 --- a/src/gui/requesttrade.h +++ b/src/gui/requesttrade.h @@ -24,18 +24,14 @@ #ifndef _TMW_REQUESTTRADE_ #define _TMW_REQUESTTRADE_ -#include <iosfwd> -#include <guichan/actionlistener.hpp> - -#include "window.h" -#include "../guichanfwd.h" +#include "confirm_dialog.h" /** * The request trade dialog. * * \ingroup Interface */ -class RequestTradeDialog : public Window, public gcn::ActionListener +class RequestTradeDialog : public ConfirmDialog { public: /** @@ -44,15 +40,6 @@ class RequestTradeDialog : public Window, public gcn::ActionListener * @see Window::Window */ RequestTradeDialog(const std::string &name); - - /** - * Called when receiving actions from the widgets. - */ - void action(const std::string& eventId); - - private: - gcn::Button *mAcceptButton; - gcn::Button *mCancelButton; }; #endif |