diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-02-01 12:24:10 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-02-01 12:24:10 +0000 |
commit | 4490b8643f2449da159c9284503eb2c443aa2e9e (patch) | |
tree | d859ebeb3ee69b89c471793b76f9df7fe9546137 /src/net | |
parent | 6bff53b318937999a70d775bb6ecea2b18576e0f (diff) | |
download | mana-4490b8643f2449da159c9284503eb2c443aa2e9e.tar.gz mana-4490b8643f2449da159c9284503eb2c443aa2e9e.tar.bz2 mana-4490b8643f2449da159c9284503eb2c443aa2e9e.tar.xz mana-4490b8643f2449da159c9284503eb2c443aa2e9e.zip |
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.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/playerhandler.cpp | 8 | ||||
-rw-r--r-- | src/net/tradehandler.cpp | 18 |
2 files changed, 20 insertions, 6 deletions
diff --git a/src/net/playerhandler.cpp b/src/net/playerhandler.cpp index 1a255e0b..7bf97b5f 100644 --- a/src/net/playerhandler.cpp +++ b/src/net/playerhandler.cpp @@ -141,8 +141,8 @@ void PlayerHandler::handleMessage(MessageIn *msg) weightNotice = new OkDialog("Message", "You are carrying more then half your " "weight. You are unable to regain " - "health.", - &weightNoticeListener); + "health."); + weightNotice->addActionListener(&weightNoticeListener); } player_node->totalWeight = value; break; @@ -163,8 +163,8 @@ void PlayerHandler::handleMessage(MessageIn *msg) if (player_node->hp == 0 && deathNotice == NULL) { deathNotice = new OkDialog("Message", - "You're now dead, press ok to restart", - &deathNoticeListener); + "You're now dead, press ok to restart"); + deathNotice->addActionListener(&deathNoticeListener); player_node->action = Being::DEAD; } } 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: |