summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/channel.cpp7
-rw-r--r--src/channel.h2
-rw-r--r--src/commandhandler.cpp193
-rw-r--r--src/game.cpp20
-rw-r--r--src/gui/chat.cpp56
-rw-r--r--src/gui/chat.h55
-rw-r--r--src/gui/guildwindow.cpp8
-rw-r--r--src/gui/npcpostdialog.cpp2
-rw-r--r--src/gui/partywindow.cpp6
-rw-r--r--src/gui/recorder.cpp11
-rw-r--r--src/gui/trade.cpp2
-rw-r--r--src/gui/widgets/channeltab.h9
-rw-r--r--src/gui/widgets/chattab.cpp10
-rw-r--r--src/gui/widgets/chattab.h20
-rw-r--r--src/gui/widgets/whispertab.h8
-rw-r--r--src/log.cpp2
-rw-r--r--src/net/ea/buysellhandler.cpp10
-rw-r--r--src/net/ea/chathandler.cpp18
-rw-r--r--src/net/ea/equipmenthandler.cpp4
-rw-r--r--src/net/ea/inventoryhandler.cpp6
-rw-r--r--src/net/ea/playerhandler.cpp4
-rw-r--r--src/net/ea/skillhandler.cpp2
-rw-r--r--src/net/ea/tradehandler.cpp20
-rw-r--r--src/net/tmwserv/chathandler.cpp44
-rw-r--r--src/net/tmwserv/guildhandler.cpp15
-rw-r--r--src/net/tmwserv/partyhandler.cpp4
-rw-r--r--src/net/tmwserv/playerhandler.cpp2
-rw-r--r--src/net/tmwserv/tradehandler.cpp8
-rw-r--r--src/party.cpp67
-rw-r--r--src/statuseffect.cpp4
30 files changed, 291 insertions, 328 deletions
diff --git a/src/channel.cpp b/src/channel.cpp
index 0cd850a9..3e4646fb 100644
--- a/src/channel.cpp
+++ b/src/channel.cpp
@@ -34,7 +34,12 @@ Channel::Channel(short id,
const std::string &announcement) :
mId(id),
mName(name),
- mAnnouncement(announcement)
+ mAnnouncement(announcement),
+ mTab(new ChannelTab(this))
{
+}
+Channel::~Channel()
+{
+ delete mTab;
}
diff --git a/src/channel.h b/src/channel.h
index d9f72c12..b2080d4a 100644
--- a/src/channel.h
+++ b/src/channel.h
@@ -40,6 +40,8 @@ class Channel
const std::string &name,
const std::string &announcement = std::string());
+ ~Channel();
+
/**
* Get the id associated witht his channel
*/
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index 833ce718..f875fd85 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -27,6 +27,7 @@
#include "localplayer.h"
#include "gui/widgets/channeltab.h"
+#include "gui/widgets/chattab.h"
#include "gui/chat.h"
#ifdef TMWSERV_SUPPORT
@@ -132,7 +133,7 @@ void CommandHandler::handleCommand(const std::string &command)
}
else
{
- chatWindow->chatLog("Unknown command");
+ localChatTab->chatLog("Unknown command");
}
}
@@ -152,106 +153,106 @@ void CommandHandler::handleHelp(const std::string &args)
{
if (args == "")
{
- chatWindow->chatLog(_("-- Help --"));
- chatWindow->chatLog(_("/help > Display this help."));
+ localChatTab->chatLog(_("-- Help --"));
+ localChatTab->chatLog(_("/help > Display this help."));
- chatWindow->chatLog(_("/where > Display map name"));
- chatWindow->chatLog(_("/who > Display number of online users"));
- chatWindow->chatLog(_("/me > Tell something about yourself"));
+ localChatTab->chatLog(_("/where > Display map name"));
+ localChatTab->chatLog(_("/who > Display number of online users"));
+ localChatTab->chatLog(_("/me > Tell something about yourself"));
- chatWindow->chatLog(_("/msg > Send a private message to a user"));
- chatWindow->chatLog(_("/whisper > Alias of msg"));
- chatWindow->chatLog(_("/w > Alias of msg"));
+ localChatTab->chatLog(_("/msg > Send a private message to a user"));
+ localChatTab->chatLog(_("/whisper > Alias of msg"));
+ localChatTab->chatLog(_("/w > Alias of msg"));
#ifdef TMWSERV_SUPPORT
- chatWindow->chatLog(_("/list > Display all public channels"));
- chatWindow->chatLog(_("/users > Lists the users in the current channel"));
- chatWindow->chatLog(_("/join > Join or create a channel"));
- chatWindow->chatLog(_("/topic > Set the topic of the current channel"));
- chatWindow->chatLog(_("/quit > Leave a channel"));
- chatWindow->chatLog(_("/clear > Clears this window"));
- chatWindow->chatLog(_("/op > Make a user a channel operator"));
- chatWindow->chatLog(_("/kick > Kick a user from the channel"));
-
- chatWindow->chatLog(_("/party > Invite a user to party"));
+ localChatTab->chatLog(_("/list > Display all public channels"));
+ localChatTab->chatLog(_("/users > Lists the users in the current channel"));
+ localChatTab->chatLog(_("/join > Join or create a channel"));
+ localChatTab->chatLog(_("/topic > Set the topic of the current channel"));
+ localChatTab->chatLog(_("/quit > Leave a channel"));
+ localChatTab->chatLog(_("/clear > Clears this window"));
+ localChatTab->chatLog(_("/op > Make a user a channel operator"));
+ localChatTab->chatLog(_("/kick > Kick a user from the channel"));
+
+ localChatTab->chatLog(_("/party > Invite a user to party"));
#else
- chatWindow->chatLog(_("/party > Party-related commands"));
+ localChatTab->chatLog(_("/party > Party-related commands"));
#endif
- chatWindow->chatLog(_("/record > Start recording the chat to an external file"));
- chatWindow->chatLog(_("/toggle > Determine whether <return> toggles the chat log"));
- chatWindow->chatLog(_("/present > Get list of players present (sent to chat log, if logging)"));
+ localChatTab->chatLog(_("/record > Start recording the chat to an external file"));
+ localChatTab->chatLog(_("/toggle > Determine whether <return> toggles the chat log"));
+ localChatTab->chatLog(_("/present > Get list of players present (sent to chat log, if logging)"));
- chatWindow->chatLog(_("/announce > Global announcement (GM only)"));
+ localChatTab->chatLog(_("/announce > Global announcement (GM only)"));
- chatWindow->chatLog(_("For more information, type /help <command>"));
+ localChatTab->chatLog(_("For more information, type /help <command>"));
}
else if (args == "announce")
{
- chatWindow->chatLog(_("Command: /announce <msg>"));
- chatWindow->chatLog(_("*** only available to a GM ***"));
- chatWindow->chatLog(_("This command sends the message <msg> to "
+ localChatTab->chatLog(_("Command: /announce <msg>"));
+ localChatTab->chatLog(_("*** only available to a GM ***"));
+ localChatTab->chatLog(_("This command sends the message <msg> to "
"all players currently online."));
}
else if (args == "clear")
{
- chatWindow->chatLog(_("Command: /clear"));
- chatWindow->chatLog(_("This command clears the chat log of previous chat."));
+ localChatTab->chatLog(_("Command: /clear"));
+ localChatTab->chatLog(_("This command clears the chat log of previous chat."));
}
else if (args == "help")
{
- chatWindow->chatLog(_("Command: /help"));
- chatWindow->chatLog(_("This command displays a list of all commands available."));
- chatWindow->chatLog(_("Command: /help <command>"));
- chatWindow->chatLog(_("This command displays help on <command>."));
+ localChatTab->chatLog(_("Command: /help"));
+ localChatTab->chatLog(_("This command displays a list of all commands available."));
+ localChatTab->chatLog(_("Command: /help <command>"));
+ localChatTab->chatLog(_("This command displays help on <command>."));
}
else if (args == "join")
{
- chatWindow->chatLog(_("Command: /join <channel>"));
- chatWindow->chatLog(_("This command makes you enter <channel>."));
- chatWindow->chatLog(_("If <channel> doesn't exist, it's created."));
+ localChatTab->chatLog(_("Command: /join <channel>"));
+ localChatTab->chatLog(_("This command makes you enter <channel>."));
+ localChatTab->chatLog(_("If <channel> doesn't exist, it's created."));
}
else if (args == "kick")
{
- chatWindow->chatLog(_("Command: /kick <nick>"));
- chatWindow->chatLog(_("This command makes <nick> leave the channel."));
- chatWindow->chatLog(_("If the <nick> has spaces in it, enclose it in "
+ localChatTab->chatLog(_("Command: /kick <nick>"));
+ localChatTab->chatLog(_("This command makes <nick> leave the channel."));
+ localChatTab->chatLog(_("If the <nick> has spaces in it, enclose it in "
"double quotes (\")."));
}
else if (args == "list")
{
- chatWindow->chatLog(_("Command: /list"));
- chatWindow->chatLog(_("This command shows a list of all channels."));
+ localChatTab->chatLog(_("Command: /list"));
+ localChatTab->chatLog(_("This command shows a list of all channels."));
}
else if (args == "me")
{
- chatWindow->chatLog(_("Command: /me <message>"));
- chatWindow->chatLog(_("This command tell others you are (doing) <msg>."));
+ localChatTab->chatLog(_("Command: /me <message>"));
+ localChatTab->chatLog(_("This command tell others you are (doing) <msg>."));
}
else if (args == "msg" || args == "whisper" || args == "w")
{
- chatWindow->chatLog(_("Command: /msg <nick> <message>"));
- chatWindow->chatLog(_("Command: /whisper <nick> <message>"));
- chatWindow->chatLog(_("Command: /w <nick> <message>"));
- chatWindow->chatLog(_("This command sends the text <message> to <nick>."));
- chatWindow->chatLog(_("If the <nick> has spaces in it, enclose it in "
+ localChatTab->chatLog(_("Command: /msg <nick> <message>"));
+ localChatTab->chatLog(_("Command: /whisper <nick> <message>"));
+ localChatTab->chatLog(_("Command: /w <nick> <message>"));
+ localChatTab->chatLog(_("This command sends the text <message> to <nick>."));
+ localChatTab->chatLog(_("If the <nick> has spaces in it, enclose it in "
"double quotes (\")."));
}
else if (args == "op")
{
- chatWindow->chatLog(_("Command: /op <nick>"));
- chatWindow->chatLog(_("This command makes <nick> a channel operator."));
- chatWindow->chatLog(_("If the <nick> has spaces in it, enclose it in "
+ localChatTab->chatLog(_("Command: /op <nick>"));
+ localChatTab->chatLog(_("This command makes <nick> a channel operator."));
+ localChatTab->chatLog(_("If the <nick> has spaces in it, enclose it in "
"double quotes (\")."));
- chatWindow->chatLog(_("Channel operators can kick and op other users "
+ localChatTab->chatLog(_("Channel operators can kick and op other users "
"from the channel."));
}
#ifdef TMWSERV_SUPPORT
else if (args == "party")
{
- chatWindow->chatLog(_("Command: /party <nick>"));
- chatWindow->chatLog(_("This command invites <nick> to party with you."));
- chatWindow->chatLog(_("If the <nick> has spaces in it, enclose it in "
+ localChatTab->chatLog(_("Command: /party <nick>"));
+ localChatTab->chatLog(_("This command invites <nick> to party with you."));
+ localChatTab->chatLog(_("If the <nick> has spaces in it, enclose it in "
"double quotes (\")."));
#else
else if (args.substr(0, 5) == "party")
@@ -261,68 +262,68 @@ void CommandHandler::handleHelp(const std::string &args)
}
else if (args == "present")
{
- chatWindow->chatLog(_("Command: /present"));
- chatWindow->chatLog(_("This command gets a list of players within hearing and "
+ localChatTab->chatLog(_("Command: /present"));
+ localChatTab->chatLog(_("This command gets a list of players within hearing and "
"sends it to either the record log if recording, or the chat "
"log otherwise."));
}
else if (args == "quit")
{
- chatWindow->chatLog(_("Command: /quit"));
- chatWindow->chatLog(_("This command leaves the current channel."));
- chatWindow->chatLog(_("If you're the last person in the channel, it will be deleted."));
+ localChatTab->chatLog(_("Command: /quit"));
+ localChatTab->chatLog(_("This command leaves the current channel."));
+ localChatTab->chatLog(_("If you're the last person in the channel, it will be deleted."));
}
else if (args == "record")
{
- chatWindow->chatLog(_("Command: /record <filename>"));
- chatWindow->chatLog(_("This command starts recording the chat log to the file "
+ localChatTab->chatLog(_("Command: /record <filename>"));
+ localChatTab->chatLog(_("This command starts recording the chat log to the file "
"<filename>."));
- chatWindow->chatLog(_("Command: /record"));
- chatWindow->chatLog(_("This command finishes a recording session."));
+ localChatTab->chatLog(_("Command: /record"));
+ localChatTab->chatLog(_("This command finishes a recording session."));
}
else if (args == "toggle")
{
- chatWindow->chatLog(_("Command: /toggle <state>"));
- chatWindow->chatLog(_("This command sets whether the return key should toggle the "
+ localChatTab->chatLog(_("Command: /toggle <state>"));
+ localChatTab->chatLog(_("This command sets whether the return key should toggle the "
"chat log, or whether the chat log turns off automatically."));
- chatWindow->chatLog(_("<state> can be one of \"1\", \"yes\", \"true\" to "
+ localChatTab->chatLog(_("<state> can be one of \"1\", \"yes\", \"true\" to "
"turn the toggle on, or \"0\", \"no\", \"false\" to turn the "
"toggle off."));
- chatWindow->chatLog(_("Command: /toggle"));
- chatWindow->chatLog(_("This command displays the return toggle status."));
+ localChatTab->chatLog(_("Command: /toggle"));
+ localChatTab->chatLog(_("This command displays the return toggle status."));
}
else if (args == "topic")
{
- chatWindow->chatLog(_("Command: /topic <message>"));
- chatWindow->chatLog(_("This command sets the topic to <message>."));
+ localChatTab->chatLog(_("Command: /topic <message>"));
+ localChatTab->chatLog(_("This command sets the topic to <message>."));
}
else if (args == "users")
{
- chatWindow->chatLog(_("Command: /users <channel>"));
- chatWindow->chatLog(_("This command shows the users in <channel>."));
+ localChatTab->chatLog(_("Command: /users <channel>"));
+ localChatTab->chatLog(_("This command shows the users in <channel>."));
}
else if (args == "where")
{
- chatWindow->chatLog(_("Command: /where"));
- chatWindow->chatLog(_("This command displays the name of the current map."));
+ localChatTab->chatLog(_("Command: /where"));
+ localChatTab->chatLog(_("This command displays the name of the current map."));
}
else if (args == "who")
{
- chatWindow->chatLog(_("Command: /who"));
- chatWindow->chatLog(_("This command displays the number of players currently "
+ localChatTab->chatLog(_("Command: /who"));
+ localChatTab->chatLog(_("This command displays the number of players currently "
"online."));
}
else
{
- chatWindow->chatLog(_("Unknown command."));
- chatWindow->chatLog(_("Type /help for a list of commands."));
+ localChatTab->chatLog(_("Unknown command."));
+ localChatTab->chatLog(_("Type /help for a list of commands."));
}
}
void CommandHandler::handleWhere()
{
// TODO: add position
- chatWindow->chatLog(map_path, BY_SERVER);
+ localChatTab->chatLog(map_path, BY_SERVER);
}
void CommandHandler::handleWho()
@@ -386,7 +387,7 @@ void CommandHandler::handleMsg(const std::string &args)
chatWindow->whisper(recvnick, msg, true);
}
else
- chatWindow->chatLog("Cannont send empty whispers!");
+ localChatTab->chatLog("Cannont send empty whispers!");
#endif
}
@@ -402,7 +403,7 @@ void CommandHandler::handleJoin(const std::string &args)
std::string::size_type pos = args.find(' ');
std::string name(args, 0, pos);
std::string password(args, pos+1);
- chatWindow->chatLog("Requesting to join channel " + name);
+ localChatTab->chatLog("Requesting to join channel " + name);
Net::ChatServer::enterChannel(name, password);
}
@@ -426,7 +427,7 @@ void CommandHandler::handleTopic(const std::string &args)
}
else
{
- chatWindow->chatLog("Unable to set this channel's topic", BY_CHANNEL);
+ localChatTab->chatLog("Unable to set this channel's topic", BY_CHANNEL);
}
}
@@ -440,7 +441,7 @@ void CommandHandler::handleQuit()
}
else
{
- chatWindow->chatLog("Unable to quit this channel", BY_CHANNEL);
+ localChatTab->chatLog("Unable to quit this channel", BY_CHANNEL);
}
}
@@ -458,7 +459,7 @@ void CommandHandler::handleOp(const std::string &args)
}
else
{
- chatWindow->chatLog("Unable to set this user's mode", BY_CHANNEL);
+ localChatTab->chatLog("Unable to set this user's mode", BY_CHANNEL);
}
}
@@ -475,7 +476,7 @@ void CommandHandler::handleKick(const std::string &args)
}
else
{
- chatWindow->chatLog("Unable to kick user", BY_CHANNEL);
+ localChatTab->chatLog("Unable to kick user", BY_CHANNEL);
}
}
@@ -491,7 +492,7 @@ void CommandHandler::handleParty(const std::string &args)
#else
if (args.empty())
{
- chatWindow->chatLog(_("Unknown party command... Type \"/help\" party for more "
+ localChatTab->chatLog(_("Unknown party command... Type \"/help\" party for more "
"information."), BY_SERVER);
return;
}
@@ -516,22 +517,22 @@ void CommandHandler::handleParty(const std::string &args)
{
char temp[2] = ".";
*temp = chatWindow->getPartyPrefix();
- chatWindow->chatLog(_("The current party prefix is ") + std::string(temp));
+ localChatTab->chatLog(_("The current party prefix is ") + std::string(temp));
}
else if (rest.length() != 1)
{
- chatWindow->chatLog(_("Party prefix must be one character long."));
+ localChatTab->chatLog(_("Party prefix must be one character long."));
}
else
{
if (rest == "/")
{
- chatWindow->chatLog(_("Cannot use a '/' as the prefix."));
+ localChatTab->chatLog(_("Cannot use a '/' as the prefix."));
}
else
{
chatWindow->setPartyPrefix(rest.at(0));
- chatWindow->chatLog(_("Changing prefix to ") + rest);
+ localChatTab->chatLog(_("Changing prefix to ") + rest);
}
}
}
@@ -558,7 +559,7 @@ void CommandHandler::handleToggle(const std::string &args)
{
if (args.empty())
{
- chatWindow->chatLog(chatWindow->getReturnTogglesChat() ?
+ localChatTab->chatLog(chatWindow->getReturnTogglesChat() ?
_("Return toggles chat.") : _("Message closes chat."));
return;
}
@@ -569,7 +570,7 @@ void CommandHandler::handleToggle(const std::string &args)
opt == "y" || opt == "Y" ||
opt == "t" || opt == "T")
{
- chatWindow->chatLog(_("Return now toggles chat."));
+ localChatTab->chatLog(_("Return now toggles chat."));
chatWindow->setReturnTogglesChat(true);
return;
}
@@ -577,12 +578,12 @@ void CommandHandler::handleToggle(const std::string &args)
opt == "n" || opt == "N" ||
opt == "f" || opt == "F")
{
- chatWindow->chatLog(_("Message now closes chat."));
+ localChatTab->chatLog(_("Message now closes chat."));
chatWindow->setReturnTogglesChat(false);
return;
}
else
- chatWindow->chatLog(_("Options to /toggle are \"yes\", \"no\", \"true\", "
+ localChatTab->chatLog(_("Options to /toggle are \"yes\", \"no\", \"true\", "
"\"false\", \"1\", \"0\"."));
}
diff --git a/src/game.cpp b/src/game.cpp
index d45387fd..91d8fa3a 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -181,6 +181,7 @@ CommandHandler *commandHandler = NULL;
Particle *particleEngine = NULL;
EffectManager *effectManager = NULL;
+ChatTab *localChatTab = NULL;
#ifdef EATHENA_SUPPORT
Party *playerParty = NULL;
#endif
@@ -287,7 +288,7 @@ void createGuiWindows(Network *network)
emoteShortcutWindow = new ShortcutWindow("emoteShortcut",
new EmoteShortcutContainer);
- chatWindow->addTab(new ChatTab(std::string("General")));
+ localChatTab = new ChatTab(_("General"));
// Set initial window visibility
chatWindow->setVisible((bool) config.getValue(
@@ -330,6 +331,7 @@ void createGuiWindows(Network *network)
void destroyGuiWindows()
{
logger->setChatWindow(NULL);
+ delete localChatTab; // Need to do this first, so it can remove itself
delete chatWindow;
delete statusWindow;
delete miniStatusWindow;
@@ -540,11 +542,11 @@ static bool saveScreenshot()
{
std::stringstream chatlogentry;
chatlogentry << _("Screenshot saved to ~/") << filenameSuffix.str();
- chatWindow->chatLog(chatlogentry.str(), BY_SERVER);
+ localChatTab->chatLog(chatlogentry.str(), BY_SERVER);
}
else
{
- chatWindow->chatLog(_("Saving screenshot failed!"), BY_SERVER);
+ localChatTab->chatLog(_("Saving screenshot failed!"), BY_SERVER);
logger->log("Error: could not save screenshot.");
}
@@ -936,16 +938,16 @@ void Game::handleInput()
unsigned int deflt = player_relations.getDefault();
if (deflt & PlayerRelation::TRADE)
{
- chatWindow->chatLog(
- _("Ignoring incoming trade requests"),
- BY_SERVER);
+ localChatTab->chatLog(
+ _("Ignoring incoming trade requests"),
+ BY_SERVER);
deflt &= ~PlayerRelation::TRADE;
}
else
{
- chatWindow->chatLog(
- _("Accepting incoming trade requests"),
- BY_SERVER);
+ localChatTab->chatLog(
+ _("Accepting incoming trade requests"),
+ BY_SERVER);
deflt |= PlayerRelation::TRADE;
}
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 174285c9..8baf702e 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -96,7 +96,6 @@ ChatWindow::~ChatWindow()
config.setValue("ReturnToggles", mReturnToggles ? "1" : "0");
delete mRecorder;
#endif
- delete_all(mTabs);
delete_all(mWhispers);
delete mItemLinkHandler;
}
@@ -147,22 +146,6 @@ void ChatWindow::logic()
}
}
-void ChatWindow::chatLog(std::string line, int own, std::string channelName,
- bool ignoreRecord)
-{
- ChatTab *tab;
- if(!channelName.empty())
- tab = findTab(channelName);
- else
-#ifdef TMWSERV_SUPPORT
- tab = getFocused();
-#else
- tab = findTab("General");
-#endif
-
- tab->chatLog(line, own, ignoreRecord);
-}
-
ChatTab* ChatWindow::getFocused() const
{
return dynamic_cast<ChatTab*>(mChatTabs->getSelectedTab());
@@ -173,11 +156,6 @@ void ChatWindow::clearTab(ChatTab* tab)
if (tab) tab->clearText();
}
-void ChatWindow::clearTab(const std::string &tab)
-{
- clearTab(findTab(tab));
-}
-
void ChatWindow::clearTab()
{
clearTab(getFocused());
@@ -249,33 +227,21 @@ bool ChatWindow::isInputFocused()
return mChatInput->isFocused();
}
-ChatTab* ChatWindow::findTab(const std::string &tabName)
-{
- return mTabs[tabName];
-}
-
void ChatWindow::removeTab(ChatTab *tab)
{
- mTabs.erase(tab->getCaption());
- mChatTabs->removeTab(tab);
-}
-
-void ChatWindow::removeTab(const std::string &tabName)
-{
- ChatTab *tab = findTab(tabName);
- if (tab) removeTab(tab);
+ // Prevent removal of the local chat tab
+ if (tab != localChatTab) mChatTabs->removeTab(tab);
}
void ChatWindow::addTab(ChatTab *tab)
{
// Make sure we don't end up with duplicates in the gui
- removeTab(tab->getCaption());
-
- mTabs[tab->getCaption()] = tab;
+ // TODO
mChatTabs->addTab(tab, tab->mScrollArea);
- if (mTabs.size() == 1)
+ // Fix for layout issues when adding the first tab
+ if (tab == localChatTab)
adjustTabSize();
// Update UI
@@ -322,11 +288,12 @@ void ChatWindow::doPresent()
mRecorder->record(timeStr.str() + _("Present: ") + response + ".");
- chatLog(_("Attendance written to record log."), BY_SERVER, std::string(), true);
+ localChatTab->chatLog(_("Attendance written to record log."),
+ BY_SERVER, true);
}
else
{
- chatLog(_("Present: ") + response, BY_SERVER);
+ localChatTab->chatLog(_("Present: ") + response, BY_SERVER);
}
}
@@ -392,12 +359,6 @@ void ChatWindow::setVisible(bool isVisible)
mTmpVisible = false;
}
-bool ChatWindow::tabExists(const std::string &tabName)
-{
- Tab *tab = mChatTabs->getTab(tabName);
- return tab != 0;
-}
-
void ChatWindow::setRecordingFile(const std::string &msg)
{
mRecorder->setRecordingFile(msg);
@@ -424,7 +385,6 @@ void ChatWindow::whisper(std::string nick, std::string mes, bool own)
{
tab = new WhisperTab(tempNick);
mWhispers[tempNick] = tab;
- mChatTabs->addTab(tab, tab->mScrollArea);
}
if (own)
diff --git a/src/gui/chat.h b/src/gui/chat.h
index 46358268..736f9284 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -47,21 +47,6 @@ class Network;
#endif
class WhisperTab;
-enum
-{
- BY_GM,
-#ifdef EATHENA_SUPPORT
- BY_PARTY,
-#endif
- BY_PLAYER,
- BY_OTHER,
- BY_SERVER,
- BY_CHANNEL,
- ACT_WHISPER, // getting whispered at
- ACT_IS, // equivalent to "/me" on IRC
- BY_LOGGER
-};
-
/**
* gets in between usernick and message text depending on
* message type
@@ -119,29 +104,11 @@ class ChatWindow : public Window,
void resetToDefaultSize();
/**
- * Adds a line of text to our message list. Parameters:
- *
- * @param line Text message.
- * @param own Type of message (usually the owner-type).
- * @param channelName which channel to send the message to.
- * @param ignoreRecord should this not be recorded?
- */
- void chatLog(std::string line,
- int own = BY_SERVER,
- std::string channelName = "",
- bool ignoreRecord = false);
-
- /**
* Gets the focused tab.
*/
ChatTab* getFocused() const;
/**
- * Clear the tab with the given name.
- */
- void clearTab(const std::string &tab);
-
- /**
* Clear the given tab.
*/
void clearTab(ChatTab* tab);
@@ -169,16 +136,6 @@ class ChatWindow : public Window,
*/
bool isInputFocused();
- ChatTab* findTab(const std::string &tabName);
-
- /** Remove the given tab from the window */
- void removeTab(ChatTab *tab);
-
- void removeTab(const std::string &tabName);
-
- /** Add the tab to the window */
- void addTab(ChatTab *tab);
-
/**
* Passes the text to the current tab as input
*
@@ -199,9 +156,6 @@ class ChatWindow : public Window,
/** Override to reset mTmpVisible */
void setVisible(bool visible);
- /** Check if tab with that name already exists */
- bool tabExists(const std::string &tabName);
-
/**
* Scrolls the chat window
*
@@ -234,6 +188,12 @@ class ChatWindow : public Window,
friend class ChatTab;
friend class WhisperTab;
+ /** Remove the given tab from the window */
+ void removeTab(ChatTab *tab);
+
+ /** Add the tab to the window */
+ void addTab(ChatTab *tab);
+
void adjustTabSize();
#ifdef EATHENA_SUPPORT
@@ -256,8 +216,7 @@ class ChatWindow : public Window,
Tab *currentTab;
typedef std::map<const std::string, ChatTab*> TabMap;
- /** Map each tab to its browser and scroll area. */
- TabMap mTabs;
+ /** Manage whisper tabs */
TabMap mWhispers;
typedef std::list<std::string> History;
diff --git a/src/gui/guildwindow.cpp b/src/gui/guildwindow.cpp
index 263b8181..c8a1872f 100644
--- a/src/gui/guildwindow.cpp
+++ b/src/gui/guildwindow.cpp
@@ -127,7 +127,7 @@ void GuildWindow::action(const gcn::ActionEvent &event)
if (guild)
{
Net::ChatServer::Guild::quitGuild(guild);
- chatWindow->chatLog("Guild " + mGuildTabs->getSelectedTab()->getCaption() + " quit", BY_SERVER);
+ localChatTab->chatLog("Guild " + mGuildTabs->getSelectedTab()->getCaption() + " quit", BY_SERVER);
}
}
else if (eventId == "CREATE_GUILD_OK")
@@ -143,7 +143,7 @@ void GuildWindow::action(const gcn::ActionEvent &event)
// Defocus dialog
mFocus = false;
- chatWindow->chatLog("Creating Guild called " + name, BY_SERVER);
+ localChatTab->chatLog("Creating Guild called " + name, BY_SERVER);
guildDialog->scheduleDelete();
}
else if (eventId == "INVITE_USER_OK")
@@ -156,7 +156,7 @@ void GuildWindow::action(const gcn::ActionEvent &event)
// Defocus dialog
mFocus = false;
- chatWindow->chatLog("Invited user " + name, BY_SERVER);
+ localChatTab->chatLog("Invited user " + name, BY_SERVER);
inviteDialog->scheduleDelete();
}
else if (eventId == "yes")
@@ -233,7 +233,7 @@ void GuildWindow::openAcceptDialog(const std::string &inviterName,
const std::string &guildName)
{
std::string msg = inviterName + " has invited you to join the guild " + guildName;
- chatWindow->chatLog(msg, BY_SERVER);
+ localChatTab->chatLog(msg, BY_SERVER);
acceptDialog = new ConfirmDialog("Accept Guild Invite", msg, this);
acceptDialog->addActionListener(this);
diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp
index 9bda8a4c..278bc397 100644
--- a/src/gui/npcpostdialog.cpp
+++ b/src/gui/npcpostdialog.cpp
@@ -78,7 +78,7 @@ void NpcPostDialog::action(const gcn::ActionEvent &event)
{
if (mSender->getText().empty() || mText->getText().empty())
{
- chatWindow->chatLog("Failed to send as sender or letter invalid");
+ localChatTab->chatLog("Failed to send as sender or letter invalid");
}
else
{
diff --git a/src/gui/partywindow.cpp b/src/gui/partywindow.cpp
index ae2a5196..3f857b5c 100644
--- a/src/gui/partywindow.cpp
+++ b/src/gui/partywindow.cpp
@@ -111,14 +111,14 @@ void PartyWindow::showPartyInvite(const std::string &inviter)
// check there isnt already an invite showing
if (mPartyInviter != "")
{
- chatWindow->chatLog("Received party request, but one already exists",
+ localChatTab->chatLog("Received party request, but one already exists",
BY_SERVER);
return;
}
// log invite
std::string msg = inviter + " has invited you to join their party";
- chatWindow->chatLog(msg, BY_SERVER);
+ localChatTab->chatLog(msg, BY_SERVER);
// show invite
acceptDialog = new ConfirmDialog("Accept Party Invite", msg, this);
@@ -134,7 +134,7 @@ void PartyWindow::action(const gcn::ActionEvent &event)
// check if they accepted the invite
if (eventId == "yes")
{
- chatWindow->chatLog("Accepted invite from " + mPartyInviter);
+ localChatTab->chatLog("Accepted invite from " + mPartyInviter);
Net::ChatServer::Party::acceptInvite(mPartyInviter);
mPartyInviter = "";
}
diff --git a/src/gui/recorder.cpp b/src/gui/recorder.cpp
index 0536188c..4f919bef 100644
--- a/src/gui/recorder.cpp
+++ b/src/gui/recorder.cpp
@@ -26,6 +26,7 @@
#include "recorder.h"
#include "windowcontainer.h"
+#include "widgets/chattab.h"
#include "widgets/layout.h"
#include "../utils/stringutils.h"
@@ -82,16 +83,16 @@ void Recorder::setRecordingFile(const std::string &msg)
* Message should go after mStream is closed so that it isn't
* recorded.
*/
- mChat->chatLog(_("Finishing recording."), BY_SERVER);
+ localChatTab->chatLog(_("Finishing recording."), BY_SERVER);
}
else
{
- mChat->chatLog(_("Not currently recording."), BY_SERVER);
+ localChatTab->chatLog(_("Not currently recording."), BY_SERVER);
}
}
else if (mStream.is_open())
{
- mChat->chatLog(_("Already recording."), BY_SERVER);
+ localChatTab->chatLog(_("Already recording."), BY_SERVER);
}
else
{
@@ -99,7 +100,7 @@ void Recorder::setRecordingFile(const std::string &msg)
* Message should go before mStream is opened so that it isn't
* recorded.
*/
- mChat->chatLog(_("Starting to record..."), BY_SERVER);
+ localChatTab->chatLog(_("Starting to record..."), BY_SERVER);
const std::string file =
std::string(PHYSFS_getUserDir()) + "/.tmw/" + msgCopy;
@@ -108,7 +109,7 @@ void Recorder::setRecordingFile(const std::string &msg)
if (mStream.is_open())
setVisible(true);
else
- mChat->chatLog(_("Failed to start recording."), BY_SERVER);
+ localChatTab->chatLog(_("Failed to start recording."), BY_SERVER);
}
}
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index a95e1d43..2d80d12d 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -309,7 +309,7 @@ void TradeWindow::action(const gcn::ActionEvent &event)
if (mMyInventory->contains(item))
{
- chatWindow->chatLog(_("Failed adding item. You can not "
+ localChatTab->chatLog(_("Failed adding item. You can not "
"overlap one kind of item on the window."),
BY_SERVER);
return;
diff --git a/src/gui/widgets/channeltab.h b/src/gui/widgets/channeltab.h
index 149eb5ec..91b4f7c6 100644
--- a/src/gui/widgets/channeltab.h
+++ b/src/gui/widgets/channeltab.h
@@ -32,6 +32,12 @@ class Channel;
class ChannelTab : public ChatTab
{
public:
+
+ Channel *getChannel() { return mChannel; }
+
+ protected:
+ friend class Channel;
+
/**
* Constructor.
*/
@@ -42,9 +48,6 @@ class ChannelTab : public ChatTab
*/
~ChannelTab();
- Channel *getChannel() { return mChannel; }
-
- protected:
void sendChat(std::string &msg);
private:
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index ff856361..120d4e21 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -62,15 +62,23 @@ ChatTab::ChatTab(const std::string &name) : Tab()
gcn::ScrollArea::SHOW_ALWAYS);
mScrollArea->setScrollAmount(0, 1);
mScrollArea->setOpaque(false);
+
+ chatWindow->addTab(this);
}
ChatTab::~ChatTab()
{
+ chatWindow->removeTab(this);
delete mTextOutput;
delete mScrollArea;
}
-void ChatTab::chatLog(std::string line, int own, bool ignoreRecord)
+void ChatTab::chatLog(const char* line, int own, bool ignoreRecord)
+{
+ chatLog(std::string(line), own, ignoreRecord);
+}
+
+void ChatTab::chatLog(std::string line, int own, bool ignoreRecord)
{
// Trim whitespace
trim(line);
diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h
index 9e2aff6b..a478abeb 100644
--- a/src/gui/widgets/chattab.h
+++ b/src/gui/widgets/chattab.h
@@ -32,6 +32,21 @@ class BrowserBox;
class Recorder;
class ScrollArea;
+enum
+{
+ BY_GM,
+#ifdef EATHENA_SUPPORT
+ BY_PARTY,
+#endif
+ BY_PLAYER,
+ BY_OTHER,
+ BY_SERVER,
+ BY_CHANNEL,
+ ACT_WHISPER, // getting whispered at
+ ACT_IS, // equivalent to "/me" on IRC
+ BY_LOGGER
+};
+
/**
* A tab for the chat window. This is special to ease chat handling.
*/
@@ -56,7 +71,8 @@ class ChatTab : public Tab
* @param channelName which channel to send the message to.
* @param ignoreRecord should this not be recorded?
*/
- void chatLog(std::string line, int own, bool ignoreRecord);
+ void chatLog(std::string line, int own = BY_SERVER, bool ignoreRecord = false);
+ void chatLog(const char* line, int own = BY_SERVER, bool ignoreRecord = false);
/**
* Adds the text to the message list
@@ -97,4 +113,6 @@ class ChatTab : public Tab
//Recorder *mRecorder;
};
+extern ChatTab *localChatTab;
+
#endif // CHATTAB_H
diff --git a/src/gui/widgets/whispertab.h b/src/gui/widgets/whispertab.h
index 66ec2720..059346fa 100644
--- a/src/gui/widgets/whispertab.h
+++ b/src/gui/widgets/whispertab.h
@@ -32,6 +32,11 @@ class Channel;
class WhisperTab : public ChatTab
{
public:
+ std::string getNick() { return mNick; }
+
+ protected:
+ friend class ChatWindow;
+
/**
* Constructor.
*/
@@ -42,9 +47,6 @@ class WhisperTab : public ChatTab
*/
~WhisperTab();
- std::string getNick() { return mNick; }
-
- protected:
void sendChat(std::string &msg);
private:
diff --git a/src/log.cpp b/src/log.cpp
index b0024f80..75b015da 100644
--- a/src/log.cpp
+++ b/src/log.cpp
@@ -103,7 +103,7 @@ void Logger::log(const char *log_text, ...)
if (mChatWindow)
{
- mChatWindow->chatLog(buf, BY_LOGGER);
+ localChatTab->chatLog(buf, BY_LOGGER);
}
// Delete temporary buffer
diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp
index 8dbc2953..d60cb0e2 100644
--- a/src/net/ea/buysellhandler.cpp
+++ b/src/net/ea/buysellhandler.cpp
@@ -105,7 +105,7 @@ void BuySellHandler::handleMessage(MessageIn &msg)
}
else
{
- chatWindow->chatLog(_("Nothing to sell"), BY_SERVER);
+ localChatTab->chatLog(_("Nothing to sell"), BY_SERVER);
current_npc = 0;
}
break;
@@ -113,22 +113,22 @@ void BuySellHandler::handleMessage(MessageIn &msg)
case SMSG_NPC_BUY_RESPONSE:
if (msg.readInt8() == 0)
{
- chatWindow->chatLog(_("Thanks for buying"), BY_SERVER);
+ localChatTab->chatLog(_("Thanks for buying"), BY_SERVER);
}
else
{
// Reset player money since buy dialog already assumed purchase
// would go fine
buyDialog->setMoney(player_node->getMoney());
- chatWindow->chatLog(_("Unable to buy"), BY_SERVER);
+ localChatTab->chatLog(_("Unable to buy"), BY_SERVER);
}
break;
case SMSG_NPC_SELL_RESPONSE:
if (msg.readInt8() == 0)
- chatWindow->chatLog(_("Thanks for selling"), BY_SERVER);
+ localChatTab->chatLog(_("Thanks for selling"), BY_SERVER);
else
- chatWindow->chatLog(_("Unable to sell"), BY_SERVER);
+ localChatTab->chatLog(_("Unable to sell"), BY_SERVER);
break;
}
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp
index aaf56555..c4743ff2 100644
--- a/src/net/ea/chathandler.cpp
+++ b/src/net/ea/chathandler.cpp
@@ -69,13 +69,13 @@ void ChatHandler::handleMessage(MessageIn &msg)
{
case 0x00:
// comment out since we'll local echo in chat.cpp instead, then only report failures
- //chatWindow->chatLog("Whisper sent", BY_SERVER);
+ //localChatTab->chatLog("Whisper sent", BY_SERVER);
break;
case 0x01:
- chatWindow->chatLog(_("Whisper could not be sent, user is offline"), BY_SERVER);
+ localChatTab->chatLog(_("Whisper could not be sent, user is offline"), BY_SERVER);
break;
case 0x02:
- chatWindow->chatLog(_("Whisper could not be sent, ignored by user"), BY_SERVER);
+ localChatTab->chatLog(_("Whisper could not be sent, ignored by user"), BY_SERVER);
break;
}
break;
@@ -94,7 +94,7 @@ void ChatHandler::handleMessage(MessageIn &msg)
if (player_relations.hasPermission(nick, PlayerRelation::WHISPER))
chatWindow->whisper(nick, chatMsg);
else
- chatWindow->chatLog(chatMsg, BY_SERVER);
+ localChatTab->chatLog(chatMsg, BY_SERVER);
break;
@@ -118,7 +118,7 @@ void ChatHandler::handleMessage(MessageIn &msg)
// We use getIgnorePlayer instead of ignoringPlayer here because ignorePlayer' side
// effects are triggered right below for Being::IGNORE_SPEECH_FLOAT.
if (player_relations.checkPermissionSilently(sender_name, PlayerRelation::SPEECH_LOG))
- chatWindow->chatLog(chatMsg, BY_OTHER);
+ localChatTab->chatLog(chatMsg, BY_OTHER);
chatMsg.erase(0, pos + 3);
trim(chatMsg);
@@ -142,7 +142,7 @@ void ChatHandler::handleMessage(MessageIn &msg)
if (msg.getId() == SMSG_PLAYER_CHAT)
{
- chatWindow->chatLog(chatMsg, BY_PLAYER);
+ localChatTab->chatLog(chatMsg, BY_PLAYER);
if (pos != std::string::npos)
chatMsg.erase(0, pos + 3);
@@ -153,20 +153,20 @@ void ChatHandler::handleMessage(MessageIn &msg)
}
else
{
- chatWindow->chatLog(chatMsg, BY_GM);
+ localChatTab->chatLog(chatMsg, BY_GM);
}
break;
}
case SMSG_WHO_ANSWER:
- chatWindow->chatLog("Online users: " + toString(msg.readInt32()),
+ localChatTab->chatLog("Online users: " + toString(msg.readInt32()),
BY_SERVER);
break;
case 0x010c:
// Display MVP player
msg.readInt32(); // id
- chatWindow->chatLog("MVP player", BY_SERVER);
+ localChatTab->chatLog("MVP player", BY_SERVER);
break;
}
}
diff --git a/src/net/ea/equipmenthandler.cpp b/src/net/ea/equipmenthandler.cpp
index f5377cf2..d1e51900 100644
--- a/src/net/ea/equipmenthandler.cpp
+++ b/src/net/ea/equipmenthandler.cpp
@@ -98,7 +98,7 @@ void EquipmentHandler::handleMessage(MessageIn &msg)
logger->log("Equipping: %i %i %i", index, equipPoint, type);
if (!type) {
- chatWindow->chatLog(_("Unable to equip."), BY_SERVER);
+ localChatTab->chatLog(_("Unable to equip."), BY_SERVER);
break;
}
@@ -136,7 +136,7 @@ void EquipmentHandler::handleMessage(MessageIn &msg)
type = msg.readInt8();
if (!type) {
- chatWindow->chatLog(_("Unable to unequip."), BY_SERVER);
+ localChatTab->chatLog(_("Unable to unequip."), BY_SERVER);
break;
}
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index addcb06f..ce2e22e7 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -156,14 +156,14 @@ void InventoryHandler::handleMessage(MessageIn &msg)
if (msg.readInt8() > 0) {
if (config.getValue("showpickupchat", true)) {
- chatWindow->chatLog(_("Unable to pick up item"), BY_SERVER);
+ localChatTab->chatLog(_("Unable to pick up item"), BY_SERVER);
}
} else {
const ItemInfo &itemInfo = ItemDB::get(itemId);
const std::string amountStr =
(amount > 1) ? toString(amount) : "a";
if (config.getValue("showpickupchat", true)) {
- chatWindow->chatLog(strprintf(_("You picked up %s [%s]"),
+ localChatTab->chatLog(strprintf(_("You picked up %s [%s]"),
amountStr.c_str(), itemInfo.getName().c_str()),
BY_SERVER);
}
@@ -206,7 +206,7 @@ void InventoryHandler::handleMessage(MessageIn &msg)
amount = msg.readInt16();
if (msg.readInt8() == 0) {
- chatWindow->chatLog(_("Failed to use item"), BY_SERVER);
+ localChatTab->chatLog(_("Failed to use item"), BY_SERVER);
} else {
if (Item *item = inventory->getItem(index))
item->setQuantity(amount);
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index fcc44cb0..60f0de79 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -284,7 +284,7 @@ void PlayerHandler::handleMessage(MessageIn &msg)
int curGp = player_node->getMoney();
player_node->setMoney(msg.readInt32());
if (player_node->getMoney() > curGp)
- chatWindow->chatLog(_("You picked up ") +
+ localChatTab->chatLog(_("You picked up ") +
Units::formatCurrency(player_node->getMoney()
- curGp), BY_SERVER);
}
@@ -407,7 +407,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/ea/skillhandler.cpp b/src/net/ea/skillhandler.cpp
index c3f4ffec..ac474adc 100644
--- a/src/net/ea/skillhandler.cpp
+++ b/src/net/ea/skillhandler.cpp
@@ -200,7 +200,7 @@ void SkillHandler::handleMessage(MessageIn &msg)
}
}
- chatWindow->chatLog(msg);
+ localChatTab->chatLog(msg);
break;
}
}
diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp
index 78472083..0a44d995 100644
--- a/src/net/ea/tradehandler.cpp
+++ b/src/net/ea/tradehandler.cpp
@@ -104,15 +104,15 @@ void TradeHandler::handleMessage(MessageIn &msg)
switch (msg.readInt8())
{
case 0: // Too far away
- chatWindow->chatLog(_("Trading isn't possible. Trade partner is too far away."),
+ localChatTab->chatLog(_("Trading isn't possible. Trade partner is too far away."),
BY_SERVER);
break;
case 1: // Character doesn't exist
- chatWindow->chatLog(_("Trading isn't possible. Character doesn't exist."),
+ localChatTab->chatLog(_("Trading isn't possible. Character doesn't exist."),
BY_SERVER);
break;
case 2: // Invite request check failed...
- chatWindow->chatLog(_("Trade cancelled due to an unknown reason."),
+ localChatTab->chatLog(_("Trade cancelled due to an unknown reason."),
BY_SERVER);
break;
case 3: // Trade accepted
@@ -124,7 +124,7 @@ void TradeHandler::handleMessage(MessageIn &msg)
case 4: // Trade cancelled
if (player_relations.hasPermission(tradePartnerName,
PlayerRelation::SPEECH_LOG))
- chatWindow->chatLog(_("Trade with ") + tradePartnerName +
+ localChatTab->chatLog(_("Trade with ") + tradePartnerName +
_(" cancelled"), BY_SERVER);
// otherwise ignore silently
@@ -132,7 +132,7 @@ void TradeHandler::handleMessage(MessageIn &msg)
player_node->setTrading(false);
break;
default: // Shouldn't happen as well, but to be sure
- chatWindow->chatLog(_("Unhandled trade cancel packet"),
+ localChatTab->chatLog(_("Unhandled trade cancel packet"),
BY_SERVER);
break;
}
@@ -182,16 +182,16 @@ void TradeHandler::handleMessage(MessageIn &msg)
break;
case 1:
// Add item failed - player overweighted
- chatWindow->chatLog(_("Failed adding item. Trade partner is over weighted."),
+ localChatTab->chatLog(_("Failed adding item. Trade partner is over weighted."),
BY_SERVER);
break;
case 2:
// Add item failed - player has no free slot
- chatWindow->chatLog(_("Failed adding item. Trade partner has no free slot."),
+ localChatTab->chatLog(_("Failed adding item. Trade partner has no free slot."),
BY_SERVER);
break;
default:
- chatWindow->chatLog(_("Failed adding item for unknown reason."),
+ localChatTab->chatLog(_("Failed adding item for unknown reason."),
BY_SERVER);
break;
}
@@ -204,14 +204,14 @@ void TradeHandler::handleMessage(MessageIn &msg)
break;
case SMSG_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 SMSG_TRADE_COMPLETE:
- chatWindow->chatLog(_("Trade completed."), BY_SERVER);
+ localChatTab->chatLog(_("Trade completed."), BY_SERVER);
tradeWindow->setVisible(false);
tradeWindow->reset();
player_node->setTrading(false);
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);
diff --git a/src/party.cpp b/src/party.cpp
index 33336eb8..51a86360 100644
--- a/src/party.cpp
+++ b/src/party.cpp
@@ -23,6 +23,7 @@
#include "localplayer.h"
#include "party.h"
+#include "gui/widgets/chattab.h"
#include "gui/chat.h"
#include "gui/confirm_dialog.h"
@@ -52,7 +53,7 @@ void Party::respond(const std::string &command, const std::string &args)
}
if (command == "settings")
{
- chatWindow->chatLog(_("Not yet implemented!"), BY_SERVER);
+ localChatTab->chatLog(_("Not yet implemented!"), BY_SERVER);
return;
/*
MessageOut outMsg(mNetwork);
@@ -61,14 +62,14 @@ void Party::respond(const std::string &command, const std::string &args)
outMsg.writeInt16(0); // Item
*/
}
- chatWindow->chatLog(_("Party command not known."), BY_SERVER);
+ localChatTab->chatLog(_("Party command not known."), BY_SERVER);
}
void Party::create(const std::string &party)
{
if (party.empty())
{
- chatWindow->chatLog(_("Party name is missing."), BY_SERVER);
+ localChatTab->chatLog(_("Party name is missing."), BY_SERVER);
return;
}
MessageOut outMsg(mNetwork);
@@ -81,7 +82,7 @@ void Party::leave(const std::string &args)
{
MessageOut outMsg(mNetwork);
outMsg.writeInt16(CMSG_PARTY_LEAVE);
- chatWindow->chatLog(_("Left party."), BY_SERVER);
+ localChatTab->chatLog(_("Left party."), BY_SERVER);
mInParty = false;
}
@@ -89,12 +90,12 @@ void Party::createResponse(bool ok)
{
if (ok)
{
- chatWindow->chatLog(_("Party successfully created."), BY_SERVER);
+ localChatTab->chatLog(_("Party successfully created."), BY_SERVER);
mInParty = true;
}
else
{
- chatWindow->chatLog(_("Could not create party."), BY_SERVER);
+ localChatTab->chatLog(_("Could not create party."), BY_SERVER);
}
}
@@ -103,15 +104,15 @@ void Party::inviteResponse(const std::string &nick, int status)
switch (status)
{
case 0:
- chatWindow->chatLog(strprintf(_("%s is already a member of a party."),
+ localChatTab->chatLog(strprintf(_("%s is already a member of a party."),
nick.c_str()), BY_SERVER);
break;
case 1:
- chatWindow->chatLog(strprintf(_("%s refused your invitation."),
+ localChatTab->chatLog(strprintf(_("%s refused your invitation."),
nick.c_str()), BY_SERVER);
break;
case 2:
- chatWindow->chatLog(strprintf(_("%s is now a member of your party."),
+ localChatTab->chatLog(strprintf(_("%s is now a member of your party."),
nick.c_str()), BY_SERVER);
break;
}
@@ -123,7 +124,7 @@ void Party::invitedAsk(const std::string &nick, int gender,
mPartyName = partyName; /* Quick and nasty - needs redoing */
if (nick.empty())
{
- chatWindow->chatLog(_("You can\'t have a blank party name!"), BY_SERVER);
+ localChatTab->chatLog(_("You can\'t have a blank party name!"), BY_SERVER);
return;
}
mCreating = false;
@@ -146,7 +147,7 @@ void Party::InviteListener::action(const gcn::ActionEvent &event)
void Party::leftResponse(const std::string &nick)
{
- chatWindow->chatLog(strprintf(_("%s has left your party."), nick.c_str()),
+ localChatTab->chatLog(strprintf(_("%s has left your party."), nick.c_str()),
BY_SERVER);
}
@@ -158,12 +159,12 @@ void Party::receiveChat(Being *being, const std::string &msg)
}
if (being->getType() != Being::PLAYER)
{
- chatWindow->chatLog(_("Party chat received, but being is not a player"),
+ localChatTab->chatLog(_("Party chat received, but being is not a player"),
BY_SERVER);
return;
}
being->setSpeech(msg, SPEECH_TIME);
- chatWindow->chatLog(being->getName() + " : " + msg, BY_PARTY);
+ localChatTab->chatLog(being->getName() + " : " + msg, BY_PARTY);
}
void Party::help(const std::string &args)
@@ -173,35 +174,35 @@ void Party::help(const std::string &args)
if (msg.empty())
{
- chatWindow->chatLog(_("Command: /party <command> <args>"), BY_SERVER);
- chatWindow->chatLog(_("where <command> can be one of:"), BY_SERVER);
- chatWindow->chatLog(_(" /new"), BY_SERVER);
- chatWindow->chatLog(_(" /create"), BY_SERVER);
- chatWindow->chatLog(_(" /prefix"), BY_SERVER);
- chatWindow->chatLog(_(" /leave"), BY_SERVER);
- chatWindow->chatLog(_("This command implements the partying function."),
+ localChatTab->chatLog(_("Command: /party <command> <args>"), BY_SERVER);
+ localChatTab->chatLog(_("where <command> can be one of:"), BY_SERVER);
+ localChatTab->chatLog(_(" /new"), BY_SERVER);
+ localChatTab->chatLog(_(" /create"), BY_SERVER);
+ localChatTab->chatLog(_(" /prefix"), BY_SERVER);
+ localChatTab->chatLog(_(" /leave"), BY_SERVER);
+ localChatTab->chatLog(_("This command implements the partying function."),
BY_SERVER);
- chatWindow->chatLog(_("Type /help party <command> for further help."),
+ localChatTab->chatLog(_("Type /help party <command> for further help."),
BY_SERVER);
return;
}
if (msg == "new" || msg == "create")
{
- chatWindow->chatLog(_("Command: /party new <party-name>"), BY_SERVER);
- chatWindow->chatLog(_("Command: /party create <party-name>"), BY_SERVER);
- chatWindow->chatLog(_("These commands create a new party <party-name."),
+ localChatTab->chatLog(_("Command: /party new <party-name>"), BY_SERVER);
+ localChatTab->chatLog(_("Command: /party create <party-name>"), BY_SERVER);
+ localChatTab->chatLog(_("These commands create a new party <party-name."),
BY_SERVER);
return;
}
if (msg == "prefix")
{
- chatWindow->chatLog(_("Command: /party prefix <prefix-char>"), BY_SERVER);
- chatWindow->chatLog(_("This command sets the party prefix character."),
+ localChatTab->chatLog(_("Command: /party prefix <prefix-char>"), BY_SERVER);
+ localChatTab->chatLog(_("This command sets the party prefix character."),
BY_SERVER);
- chatWindow->chatLog(_("Any message preceded by <prefix-char> is sent to "
+ localChatTab->chatLog(_("Any message preceded by <prefix-char> is sent to "
"the party instead of everyone."), BY_SERVER);
- chatWindow->chatLog(_("Command: /party prefix"), BY_SERVER);
- chatWindow->chatLog(_("This command reports the current party prefix "
+ localChatTab->chatLog(_("Command: /party prefix"), BY_SERVER);
+ localChatTab->chatLog(_("This command reports the current party prefix "
"character."), BY_SERVER);
return;
}
@@ -209,11 +210,11 @@ void Party::help(const std::string &args)
//if (msg == "info")
if (msg == "leave")
{
- chatWindow->chatLog(_("Command: /party leave"), BY_SERVER);
- chatWindow->chatLog(_("This command causes the player to leave the party."),
+ localChatTab->chatLog(_("Command: /party leave"), BY_SERVER);
+ localChatTab->chatLog(_("This command causes the player to leave the party."),
BY_SERVER);
return;
}
- chatWindow->chatLog(_("Unknown /party command."), BY_SERVER);
- chatWindow->chatLog(_("Type /help party for a list of options."), BY_SERVER);
+ localChatTab->chatLog(_("Unknown /party command."), BY_SERVER);
+ localChatTab->chatLog(_("Type /help party for a list of options."), BY_SERVER);
}
diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp
index 70e8d59f..077fbb63 100644
--- a/src/statuseffect.cpp
+++ b/src/statuseffect.cpp
@@ -46,7 +46,7 @@ void StatusEffect::playSFX()
void StatusEffect::deliverMessage()
{
if (!mMessage.empty())
- chatWindow->chatLog(mMessage, BY_SERVER);
+ localChatTab->chatLog(mMessage, BY_SERVER);
}
Particle *StatusEffect::getParticle()
@@ -171,4 +171,4 @@ void StatusEffect::unload()
unloadMap(statusEffects[1]);
unloadMap(stunEffects[0]);
unloadMap(stunEffects[1]);
-} \ No newline at end of file
+}