summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-03-26 09:42:43 -0600
committerJared Adams <jaxad0127@gmail.com>2009-03-26 09:42:43 -0600
commit9e4a8ea095a1a0613d7b128f4e29c69643137b07 (patch)
tree82dfb0a17dfc3439554efc77a3d18bf5165cebc3 /src/gui
parentcdcadf6e99a6deaa5b929cdec9736ab1fb280f65 (diff)
downloadmana-9e4a8ea095a1a0613d7b128f4e29c69643137b07.tar.gz
mana-9e4a8ea095a1a0613d7b128f4e29c69643137b07.tar.bz2
mana-9e4a8ea095a1a0613d7b128f4e29c69643137b07.tar.xz
mana-9e4a8ea095a1a0613d7b128f4e29c69643137b07.zip
Add ChannelTab for chat channels
This fixes TMWServ compilation form the previous commit.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/chat.cpp12
-rw-r--r--src/gui/chat.h5
-rw-r--r--src/gui/widgets/channeltab.cpp70
-rw-r--r--src/gui/widgets/channeltab.h54
-rw-r--r--src/gui/widgets/chattab.cpp38
-rw-r--r--src/gui/widgets/chattab.h11
6 files changed, 164 insertions, 26 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 5c15580d..8961b704 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -34,6 +34,7 @@
#include "../configuration.h"
#include "../localplayer.h"
+#include "../utils/dtor.h"
#include "../utils/stringutils.h"
#ifdef TMWSERV_SUPPORT
@@ -94,6 +95,7 @@ ChatWindow::~ChatWindow()
config.setValue("ReturnToggles", mReturnToggles ? "1" : "0");
delete mRecorder;
#endif
+ delete_all(mTabs);
delete mItemLinkHandler;
}
@@ -140,13 +142,15 @@ void ChatWindow::logic()
void ChatWindow::chatLog(std::string line, int own, std::string channelName,
bool ignoreRecord)
{
- if(channelName.empty())
+ ChatTab *tab;
+ if(!channelName.empty())
+ tab = findTab(channelName);
+ else
#ifdef TMWSERV_SUPPORT
- channelName = getFocused();
+ tab = getFocused();
#else
- channelName = "General";
+ tab = findTab("General");
#endif
- ChatTab *tab = findTab(channelName);
tab->chatLog(line, own, ignoreRecord);
}
diff --git a/src/gui/chat.h b/src/gui/chat.h
index fa63cedd..89bb033e 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -178,11 +178,6 @@ class ChatWindow : public Window,
/** Add the tab to the window */
void addTab(ChatTab *tab);
- /** Called to output text to a specific channel */
- void sendToChannel(short channel,
- const std::string &user,
- const std::string &msg);
-
/**
* Passes the text to the current tab as input
*
diff --git a/src/gui/widgets/channeltab.cpp b/src/gui/widgets/channeltab.cpp
new file mode 100644
index 00000000..f8c92a6e
--- /dev/null
+++ b/src/gui/widgets/channeltab.cpp
@@ -0,0 +1,70 @@
+/*
+ * The Mana World
+ * Copyright (C) 2008 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <guichan/widgets/label.hpp>
+
+#include "channeltab.h"
+
+#include "../browserbox.h"
+#include "../chatinput.h"
+#include "../itemlinkhandler.h"
+#include "../recorder.h"
+#include "../scrollarea.h"
+
+#include "../../beingmanager.h"
+#include "../../commandhandler.h"
+#include "../../channel.h"
+#include "../../configuration.h"
+#include "../../game.h"
+#include "../../localplayer.h"
+
+#ifdef TMWSERV_SUPPORT
+#include "../../net/tmwserv/chatserver/chatserver.h"
+#include "../../net/tmwserv/gameserver/player.h"
+#else
+#include "../../party.h"
+#include "../../net/messageout.h"
+#include "../../net/ea/protocol.h"
+#endif
+
+#include "../../resources/iteminfo.h"
+#include "../../resources/itemdb.h"
+
+#include "../../utils/dtor.h"
+#include "../../utils/gettext.h"
+#include "../../utils/strprintf.h"
+#include "../../utils/stringutils.h"
+
+ChannelTab::ChannelTab(Channel *channel) : ChatTab(channel->getName()),
+ mChannel(channel)
+{
+ channel->setTab(this);
+}
+
+ChannelTab::~ChannelTab()
+{
+}
+
+void ChannelTab::sendChat(std::string &msg) {
+#ifdef TMSERV_SUPPORT
+ Net::ChatServer::chat(getId(), msg);
+#endif
+}
diff --git a/src/gui/widgets/channeltab.h b/src/gui/widgets/channeltab.h
new file mode 100644
index 00000000..149eb5ec
--- /dev/null
+++ b/src/gui/widgets/channeltab.h
@@ -0,0 +1,54 @@
+/*
+ * The Mana World
+ * Copyright (C) 2009 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef CHANNELTAB_H
+#define CHANNELTAB_H
+
+#include "chattab.h"
+
+class Channel;
+
+/**
+ * A tab for a chat channel.
+ */
+class ChannelTab : public ChatTab
+{
+ public:
+ /**
+ * Constructor.
+ */
+ ChannelTab(Channel *channel);
+
+ /**
+ * Destructor.
+ */
+ ~ChannelTab();
+
+ Channel *getChannel() { return mChannel; }
+
+ protected:
+ void sendChat(std::string &msg);
+
+ private:
+ Channel *mChannel;
+};
+
+#endif // CHANNELTAB_H
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 746518ad..ff856361 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -211,6 +211,11 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord)
chatWindow->mRecorder->record(line.substr(3));
}
+void ChatTab::chatLog(std::string &nick, std::string &msg)
+{
+ chatLog(nick + ": " + msg, nick == player_node->getName() ? BY_PLAYER : BY_OTHER, false);
+}
+
void ChatTab::chatSend(std::string &msg)
{
trim(msg);
@@ -273,23 +278,7 @@ void ChatTab::chatSend(std::string &msg)
// Prepare ordinary message
if (msg[0] != '/')
{
-#ifdef TMWSERV_SUPPORT
- Net::GameServer::Player::say(msg);
- /*Channel *channel = channelManager->findByName(getFocused());
- if (channel)
- {
- Net::ChatServer::chat(channel->getId(), msg);
- }*/
-#else
- msg = player_node->getName() + " : " + msg;
-
- MessageOut outMsg(chatWindow->mNetwork);
- outMsg.writeInt16(CMSG_CHAT_MESSAGE);
- // Added + 1 in order to let eAthena parse admin commands correctly
- outMsg.writeInt16(msg.length() + 4 + 1);
- outMsg.writeString(msg, msg.length() + 1);
- return;
-#endif
+ sendChat(msg);
}
else
{
@@ -310,3 +299,18 @@ void ChatTab::clearText()
{
mTextOutput->clearRows();
}
+
+void ChatTab::sendChat(std::string &msg) {
+#ifdef TMWSERV_SUPPORT
+ Net::GameServer::Player::say(msg);
+#else
+ msg = player_node->getName() + " : " + msg;
+
+ MessageOut outMsg(chatWindow->mNetwork);
+ outMsg.writeInt16(CMSG_CHAT_MESSAGE);
+ // Added + 1 in order to let eAthena parse admin commands correctly
+ outMsg.writeInt16(msg.length() + 4 + 1);
+ outMsg.writeString(msg, msg.length() + 1);
+ return;
+#endif
+}
diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h
index dd660884..d102d7a0 100644
--- a/src/gui/widgets/chattab.h
+++ b/src/gui/widgets/chattab.h
@@ -59,6 +59,14 @@ class ChatTab : public Tab
void chatLog(std::string line, int own, bool ignoreRecord);
/**
+ * Adds the text to the message list
+ *
+ * @param msg The message text which is to be sent.
+ *
+ */
+ void chatLog(std::string &nick, std::string &msg);
+
+ /**
* Determines whether the message is a command or message, then
* sends the given message to the game server to be said, or to the
* command handler
@@ -81,6 +89,9 @@ class ChatTab : public Tab
protected:
friend class ChatWindow;
+
+ void sendChat(std::string &msg);
+
ScrollArea *mScrollArea;
BrowserBox *mTextOutput;
//Recorder *mRecorder;