summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2006-01-31 03:09:23 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2006-01-31 03:09:23 +0000
commitbe1f90d40f50eb67fa641bd55e109af8338239c7 (patch)
treef7776993ec2fd8934bddb2e148aa407f15d28ce3
parentefbf5fa72206086a7563ccfeddd601d324c7912f (diff)
downloadmana-be1f90d40f50eb67fa641bd55e109af8338239c7.tar.gz
mana-be1f90d40f50eb67fa641bd55e109af8338239c7.tar.bz2
mana-be1f90d40f50eb67fa641bd55e109af8338239c7.tar.xz
mana-be1f90d40f50eb67fa641bd55e109af8338239c7.zip
Made RequestTradeDialog inherit from ConfirmDialog.
-rw-r--r--ChangeLog2
-rw-r--r--src/gui/requesttrade.cpp58
-rw-r--r--src/gui/requesttrade.h17
3 files changed, 12 insertions, 65 deletions
diff --git a/ChangeLog b/ChangeLog
index 15ee1542..da605661 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2006-01-31 Björn Steinbrink <B.Steinbrink@gmx.de>
+ * src/gui/requesttrade.cpp, src/gui/requesttrade.h: Made
+ RequestTradeDialog inherit from ConfirmDialog.
* src/Makefile.am, src/gui/buy.cpp, src/gui/buy.h, src/gui/sell.cpp,
src/gui/sell.h, src/gui/shop.cpp, src/gui/shop.h: Created a ListModel
for ShopItems.
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