From 4490b8643f2449da159c9284503eb2c443aa2e9e Mon Sep 17 00:00:00 2001 From: Björn Steinbrink Date: Wed, 1 Feb 2006 12:24:10 +0000 Subject: Made the OkDialog and ConfirmDialog classes proxies for their buttons' events. Removed the RequestTradeWindow class, replaced with a plain ConfirmDialog. Fixed a memory leak along the way. --- src/net/tradehandler.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/net/tradehandler.cpp') diff --git a/src/net/tradehandler.cpp b/src/net/tradehandler.cpp index 6ed3bab2..5675fab8 100644 --- a/src/net/tradehandler.cpp +++ b/src/net/tradehandler.cpp @@ -30,11 +30,22 @@ #include "../localplayer.h" #include "../gui/chat.h" -#include "../gui/requesttrade.h" +#include "../gui/confirm_dialog.h" #include "../gui/trade.h" std::string tradePartnerName; +/** + * Listener for request trade dialogs + */ +struct RequestTradeListener : public gcn::ActionListener +{ + void action(const std::string& eventId) + { + player_node->tradeReply(eventId == "yes"); + }; +} requestTradeListener; + TradeHandler::TradeHandler() { static const Uint16 _messages[] = { @@ -69,7 +80,10 @@ void TradeHandler::handleMessage(MessageIn *msg) player_node->setTrading(true); tradePartnerName = msg->readString(24); - new RequestTradeDialog(tradePartnerName); + ConfirmDialog *dlg = new ConfirmDialog("Request for trade", + tradePartnerName + + " wants to trade with you, do you accept?"); + dlg->addActionListener(&requestTradeListener); break; case SMSG_TRADE_RESPONSE: -- cgit v1.2.3-70-g09d2