diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-03-26 23:04:14 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-03-26 23:04:14 -0600 |
commit | e64b5a25a54f56bc836af57223e37449a1daffe8 (patch) | |
tree | f14f80a0bdc5268a2c4e2c70b6afcac080242ac5 /src/net/tmwserv | |
parent | e03bd01fa02da71d41b85d3710a971da5a9c6c32 (diff) | |
download | mana-e64b5a25a54f56bc836af57223e37449a1daffe8.tar.gz mana-e64b5a25a54f56bc836af57223e37449a1daffe8.tar.bz2 mana-e64b5a25a54f56bc836af57223e37449a1daffe8.tar.xz mana-e64b5a25a54f56bc836af57223e37449a1daffe8.zip |
Major clean up of ChatTab handling
ChatTabs now manage their own adding/removal from the chat window, which
lost most of it's chat related messages. Whisper handling is stil done
by the ChatWindow, but it no longer manages any other tabs. ChannelTab
handling is now the sole responsability of the Channels they are
attached to. The general tab is handled by Game.
Diffstat (limited to 'src/net/tmwserv')
-rw-r--r-- | src/net/tmwserv/chathandler.cpp | 44 | ||||
-rw-r--r-- | src/net/tmwserv/guildhandler.cpp | 15 | ||||
-rw-r--r-- | src/net/tmwserv/partyhandler.cpp | 4 | ||||
-rw-r--r-- | src/net/tmwserv/playerhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/tmwserv/tradehandler.cpp | 8 |
5 files changed, 37 insertions, 36 deletions
diff --git a/src/net/tmwserv/chathandler.cpp b/src/net/tmwserv/chathandler.cpp index 65fd062c..2d151472 100644 --- a/src/net/tmwserv/chathandler.cpp +++ b/src/net/tmwserv/chathandler.cpp @@ -38,6 +38,8 @@ #include "../../gui/chat.h" #include "../../gui/guildwindow.h" +#include "utils/gettext.h" + extern Being *player_node; ChatHandler::ChatHandler() @@ -105,22 +107,22 @@ void ChatHandler::handleGameChatMessage(MessageIn &msg) if (id == 0) { - chatWindow->chatLog(chatMsg, BY_SERVER); + localChatTab->chatLog(chatMsg, BY_SERVER); return; } Being *being = beingManager->findBeing(id); + std::string mes; if (being) { - chatWindow->chatLog(being->getName() + " : " + chatMsg, - being == player_node ? BY_PLAYER : BY_OTHER, "General"); + mes = being->getName() + " : " + chatMsg; being->setSpeech(chatMsg, SPEECH_TIME); } else - { - chatWindow->chatLog("Unknown : " + chatMsg, BY_OTHER, "General"); - } + mes = "Unknown : " + chatMsg; + + localChatTab->chatLog(mes, being == player_node ? BY_PLAYER : BY_OTHER); } void ChatHandler::handleEnterChannelResponse(MessageIn &msg) @@ -132,12 +134,12 @@ void ChatHandler::handleEnterChannelResponse(MessageIn &msg) std::string announcement = msg.readString(); Channel *channel = new Channel(channelId, channelName, announcement); channelManager->addChannel(channel); - chatWindow->addTab(new ChannelTab(channel)); - chatWindow->chatLog("Topic: " + announcement, BY_CHANNEL, channelName); + ChatTab *tab = channel->getTab(); + tab->chatLog(_("Topic: ") + announcement, BY_CHANNEL); std::string user; std::string userModes; - chatWindow->chatLog("Players in this channel:", BY_CHANNEL, channelName); + tab->chatLog("Players in this channel:", BY_CHANNEL); while(msg.getUnreadLength()) { user = msg.readString(); @@ -148,19 +150,19 @@ void ChatHandler::handleEnterChannelResponse(MessageIn &msg) { user = "@" + user; } - chatWindow->chatLog(user, BY_CHANNEL, channelName); + tab->chatLog(user, BY_CHANNEL); } } else { - chatWindow->chatLog("Error joining channel", BY_SERVER); + localChatTab->chatLog("Error joining channel", BY_SERVER); } } void ChatHandler::handleListChannelsResponse(MessageIn &msg) { - chatWindow->chatLog("Listing Channels", BY_SERVER); + localChatTab->chatLog("Listing Channels", BY_SERVER); while(msg.getUnreadLength()) { std::string channelName = msg.readString(); @@ -170,9 +172,9 @@ void ChatHandler::handleListChannelsResponse(MessageIn &msg) numUsers << msg.readInt16(); channelName += " - "; channelName += numUsers.str(); - chatWindow->chatLog(channelName, BY_SERVER); + localChatTab->chatLog(channelName, BY_SERVER); } - chatWindow->chatLog("End of channel list", BY_SERVER); + localChatTab->chatLog("End of channel list", BY_SERVER); } void ChatHandler::handlePrivateMessage(MessageIn &msg) @@ -186,7 +188,7 @@ void ChatHandler::handlePrivateMessage(MessageIn &msg) void ChatHandler::handleAnnouncement(MessageIn &msg) { std::string chatMsg = msg.readString(); - chatWindow->chatLog(chatMsg, BY_GM); + localChatTab->chatLog(chatMsg, BY_GM); } void ChatHandler::handleChatMessage(MessageIn &msg) @@ -205,17 +207,17 @@ void ChatHandler::handleQuitChannelResponse(MessageIn &msg) { short channelId = msg.readInt16(); Channel *channel = channelManager->findById(channelId); - // remove the chat tab - chatWindow->removeTab(channel->getTab()); + channelManager->removeChannel(channel); } } void ChatHandler::handleListChannelUsersResponse(MessageIn &msg) { - std::string channel = msg.readString(); + std::string channelName = msg.readString(); std::string userNick; std::string userModes; - chatWindow->chatLog("Players in this channel:", BY_CHANNEL, channel); + Channel *channel = channelManager->findByName(channelName); + channel->getTab()->chatLog("Players in this channel:", BY_CHANNEL); while(msg.getUnreadLength()) { userNick = msg.readString(); @@ -228,7 +230,7 @@ void ChatHandler::handleListChannelUsersResponse(MessageIn &msg) { userNick = "@" + userNick; } - chatWindow->chatLog(userNick, BY_CHANNEL, channel); + localChatTab->chatLog(userNick, BY_CHANNEL, channel); } } @@ -277,7 +279,7 @@ void ChatHandler::handleChannelEvent(MessageIn &msg) line = "Unknown channel event."; } - chatWindow->chatLog(line, BY_CHANNEL, channel->getName()); + channel->getTab()->chatLog(line, BY_CHANNEL); } } diff --git a/src/net/tmwserv/guildhandler.cpp b/src/net/tmwserv/guildhandler.cpp index 5927f175..2127b730 100644 --- a/src/net/tmwserv/guildhandler.cpp +++ b/src/net/tmwserv/guildhandler.cpp @@ -64,12 +64,12 @@ void GuildHandler::handleMessage(MessageIn &msg) if(msg.readInt8() == ERRMSG_OK) { // TODO - Acknowledge guild was created - chatWindow->chatLog("Guild created."); + localChatTab->chatLog("Guild created."); joinedGuild(msg); } else { - chatWindow->chatLog("Error creating guild."); + localChatTab->chatLog("Error creating guild."); } } break; @@ -79,7 +79,7 @@ void GuildHandler::handleMessage(MessageIn &msg) if(msg.readInt8() == ERRMSG_OK) { // TODO - Acknowledge invite was sent - chatWindow->chatLog("Invite sent."); + localChatTab->chatLog("Invite sent."); } } break; @@ -181,12 +181,12 @@ void GuildHandler::handleMessage(MessageIn &msg) if (msg.readInt8() == ERRMSG_OK) { // promotion succeeded - chatWindow->chatLog("Member was promoted successfully"); + localChatTab->chatLog("Member was promoted successfully"); } else { // promotion failed - chatWindow->chatLog("Failed to promote member"); + localChatTab->chatLog("Failed to promote member"); } } @@ -210,7 +210,7 @@ void GuildHandler::handleMessage(MessageIn &msg) if (guild) { Channel *channel = channelManager->findByName(guild->getName()); - chatWindow->removeTab(channel->getTab()); + channelManager->removeChannel(channel); guildWindow->removeTab(guildId); player_node->removeGuild(guildId); } @@ -237,6 +237,5 @@ void GuildHandler::joinedGuild(MessageIn &msg) // COMMENT: Should this go here?? Channel *channel = new Channel(channelId, guildName, announcement); channelManager->addChannel(channel); - chatWindow->addTab(new ChannelTab(channel)); - chatWindow->chatLog("Topic: " + announcement, BY_CHANNEL, guildName); + channel->getTab()->chatLog("Topic: " + announcement, BY_CHANNEL); } diff --git a/src/net/tmwserv/partyhandler.cpp b/src/net/tmwserv/partyhandler.cpp index aa5ef0b8..880674d3 100644 --- a/src/net/tmwserv/partyhandler.cpp +++ b/src/net/tmwserv/partyhandler.cpp @@ -70,7 +70,7 @@ void PartyHandler::handleMessage(MessageIn &msg) if (msg.readInt8() == ERRMSG_OK) { player_node->setInParty(true); - chatWindow->chatLog("Joined party"); + localChatTab->chatLog("Joined party"); } } @@ -87,7 +87,7 @@ void PartyHandler::handleMessage(MessageIn &msg) msg.readInt16(); // being id std::string name = msg.readString(); - chatWindow->chatLog(name + " joined the party"); + localChatTab->chatLog(name + " joined the party"); if (!player_node->getInParty()) player_node->setInParty(true); diff --git a/src/net/tmwserv/playerhandler.cpp b/src/net/tmwserv/playerhandler.cpp index f5fbe784..e8efef52 100644 --- a/src/net/tmwserv/playerhandler.cpp +++ b/src/net/tmwserv/playerhandler.cpp @@ -280,7 +280,7 @@ void PlayerHandler::handleMessage(MessageIn &msg) switch (type) { case 0: - chatWindow->chatLog("Equip arrows first", + localChatTab->chatLog("Equip arrows first", BY_SERVER); break; default: diff --git a/src/net/tmwserv/tradehandler.cpp b/src/net/tmwserv/tradehandler.cpp index bfbdbdef..525d46f0 100644 --- a/src/net/tmwserv/tradehandler.cpp +++ b/src/net/tmwserv/tradehandler.cpp @@ -73,9 +73,9 @@ void TradeHandler::setAcceptTradeRequests(bool acceptTradeRequests) { mAcceptTradeRequests = acceptTradeRequests; if (mAcceptTradeRequests) { - chatWindow->chatLog("Accepting incoming trade requests", BY_SERVER); + localChatTab->chatLog("Accepting incoming trade requests", BY_SERVER); } else { - chatWindow->chatLog("Ignoring incoming trade requests", BY_SERVER); + localChatTab->chatLog("Ignoring incoming trade requests", BY_SERVER); } } @@ -121,14 +121,14 @@ void TradeHandler::handleMessage(MessageIn &msg) break; case GPMSG_TRADE_CANCEL: - chatWindow->chatLog("Trade canceled.", BY_SERVER); + localChatTab->chatLog("Trade canceled.", BY_SERVER); tradeWindow->setVisible(false); tradeWindow->reset(); player_node->setTrading(false); break; case GPMSG_TRADE_COMPLETE: - chatWindow->chatLog("Trade completed.", BY_SERVER); + localChatTab->chatLog("Trade completed.", BY_SERVER); tradeWindow->setVisible(false); tradeWindow->reset(); player_node->setTrading(false); |