summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-03-22 18:48:01 -0600
committerJared Adams <jaxad0127@gmail.com>2009-03-22 20:37:38 -0600
commit2303bb28359d18b8f23328376f800dc36e5c2f5f (patch)
treee3e94e716a0f9a8f39ce12d27be1c955296ef9e8 /src
parent9e0079918ed96b1b1f839b525146d14b1c794c52 (diff)
downloadmana-2303bb28359d18b8f23328376f800dc36e5c2f5f.tar.gz
mana-2303bb28359d18b8f23328376f800dc36e5c2f5f.tar.bz2
mana-2303bb28359d18b8f23328376f800dc36e5c2f5f.tar.xz
mana-2303bb28359d18b8f23328376f800dc36e5c2f5f.zip
Fix chat under eAthena
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp8
-rw-r--r--src/gui/chat.cpp119
-rw-r--r--src/gui/chat.h25
3 files changed, 73 insertions, 79 deletions
diff --git a/src/game.cpp b/src/game.cpp
index cf1aa220..ac18b7ce 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -27,8 +27,8 @@
#include <guichan/exception.hpp>
#include "beingmanager.h"
-#ifdef TMWSERV_SUPPORT
#include "channelmanager.h"
+#ifdef TMWSERV_SUPPORT
#include "commandhandler.h"
#endif
#include "configuration.h"
@@ -164,8 +164,8 @@ ShortcutWindow *emoteShortcutWindow;
BeingManager *beingManager = NULL;
FloorItemManager *floorItemManager = NULL;
-#ifdef TMWSERV_SUPPORT
ChannelManager *channelManager = NULL;
+#ifdef TMWSERV_SUPPORT
CommandHandler *commandHandler = NULL;
#endif
Particle* particleEngine = NULL;
@@ -370,8 +370,8 @@ Game::Game(Network *network):
#endif
floorItemManager = new FloorItemManager;
-#ifdef TMWSERV_SUPPORT
channelManager = new ChannelManager();
+#ifdef TMWSERV_SUPPORT
commandHandler = new CommandHandler();
#endif
effectManager = new EffectManager;
@@ -452,8 +452,8 @@ Game::~Game()
delete beingManager;
delete floorItemManager;
-#ifdef TMWSERV_SUPPORT
delete channelManager;
+#ifdef TMWSERV_SUPPORT
delete commandHandler;
#endif
delete joystick;
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 37250091..6408a61d 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -83,19 +83,8 @@ ChatWindow::ChatWindow(Network * network):
mChatInput->setActionEventId("chatinput");
mChatInput->addActionListener(this);
- BrowserBox *textOutput = new BrowserBox(BrowserBox::AUTO_WRAP);
- textOutput->setOpaque(false);
- textOutput->setMaxRow((int) config.getValue("ChatLogLength", 0));
- textOutput->setLinkHandler(mItemLinkHandler);
-
- ScrollArea *scrollArea = new ScrollArea(textOutput);
- scrollArea->setScrollPolicy(gcn::ScrollArea::SHOW_NEVER,
- gcn::ScrollArea::SHOW_ALWAYS);
- scrollArea->setScrollAmount(0, 1);
- scrollArea->setOpaque(false);
-
mChatTabs = new TabbedArea();
- mChatTabs->addTab("General", scrollArea);
+ createNewChannelTab("General");
place(0, 0, mChatTabs, 5, 5).setPadding(0);
place(0, 5, mChatInput, 5).setPadding(1);
@@ -182,7 +171,11 @@ void ChatWindow::chatLog(std::string line, int own, std::string channelName,
bool ignoreRecord)
{
if(channelName.empty())
+#ifdef TMWSERV_SUPPORT
channelName = getFocused();
+#else
+ channelName = "General";
+#endif
ChannelMap::const_iterator chan = mChannels.find(channelName);
if (chan == mChannels.end())
@@ -219,12 +212,12 @@ void ChatWindow::chatLog(std::string line, int own, std::string channelName,
// *implements actions in a backwards compatible way*
if (own == BY_PLAYER &&
- tmp.text.at(0) == '*' &&
- tmp.text.at(tmp.text.length()-1) == '*')
+ tmp.text.at(0) == '*' &&
+ tmp.text.at(tmp.text.length()-1) == '*')
{
- tmp.text[0] = ' ';
- tmp.text.erase(tmp.text.length() - 1);
- own = ACT_IS;
+ tmp.text[0] = ' ';
+ tmp.text.erase(tmp.text.length() - 1);
+ own = ACT_IS;
}
std::string lineColor = "##C";
@@ -462,52 +455,6 @@ void ChatWindow::whisper(const std::string &nick, std::string msg)
#endif
}
-#ifdef TMWSERV_SUPPORT
-
-void ChatWindow::chatSend(std::string &msg)
-{
- if (msg.empty()) return;
-
- // check for item link
- std::string::size_type start = msg.find('[');
- if (start != std::string::npos && msg[start+1] != '@')
- {
- std::string::size_type end = msg.find(']', start);
- if (end != std::string::npos)
- {
- std::string temp = msg.substr(start+1, end-1);
- ItemInfo itemInfo = ItemDB::get(temp);
- msg.insert(end, "@@");
- msg.insert(start+1, "|");
- msg.insert(start+1, toString(itemInfo.getId()));
- msg.insert(start+1, "@@");
-
- }
- }
-
-
- // Prepare ordinary message
- if (msg[0] != '/')
- {
- if (getFocused() == "General")
- {
- Net::GameServer::Player::say(msg);
- }
- else
- {
- Channel *channel = channelManager->findByName(getFocused());
- if (channel)
- {
- Net::ChatServer::chat(channel->getId(), msg);
- }
- }
- }
- else
- {
- commandHandler->handleCommand(std::string(msg, 1));
- }
-}
-
void ChatWindow::removeChannel(short channelId)
{
removeChannel(channelManager->findById(channelId));
@@ -574,6 +521,52 @@ void ChatWindow::sendToChannel(short channelId,
}
}
+#ifdef TMWSERV_SUPPORT
+
+void ChatWindow::chatSend(std::string &msg)
+{
+ if (msg.empty()) return;
+
+ // check for item link
+ std::string::size_type start = msg.find('[');
+ if (start != std::string::npos && msg[start+1] != '@')
+ {
+ std::string::size_type end = msg.find(']', start);
+ if (end != std::string::npos)
+ {
+ std::string temp = msg.substr(start+1, end-1);
+ ItemInfo itemInfo = ItemDB::get(temp);
+ msg.insert(end, "@@");
+ msg.insert(start+1, "|");
+ msg.insert(start+1, toString(itemInfo.getId()));
+ msg.insert(start+1, "@@");
+
+ }
+ }
+
+
+ // Prepare ordinary message
+ if (msg[0] != '/')
+ {
+ if (getFocused() == "General")
+ {
+ Net::GameServer::Player::say(msg);
+ }
+ else
+ {
+ Channel *channel = channelManager->findByName(getFocused());
+ if (channel)
+ {
+ Net::ChatServer::chat(channel->getId(), msg);
+ }
+ }
+ }
+ else
+ {
+ commandHandler->handleCommand(std::string(msg, 1));
+ }
+}
+
#else
void ChatWindow::chatSend(const std::string &nick, std::string msg)
diff --git a/src/gui/chat.h b/src/gui/chat.h
index bbca76ad..88a5d3e9 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -146,8 +146,9 @@ class ChatWindow : public Window,
* Adds a line of text to our message list. Parameters:
*
* @param line Text message.
- * @parem own Type of message (usually the owner-type).
+ * @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,
@@ -186,17 +187,6 @@ class ChatWindow : public Window,
*/
bool isInputFocused();
-#ifdef TMWSERV_SUPPORT
- /**
- * 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
- *
- * @param msg The message text which is to be sent.
- *
- */
- void chatSend(std::string &msg);
-
/** Called to remove the channel from the channel manager */
void removeChannel(short channelId);
@@ -211,6 +201,17 @@ class ChatWindow : public Window,
void sendToChannel(short channel,
const std::string &user,
const std::string &msg);
+
+#ifdef TMWSERV_SUPPORT
+ /**
+ * 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
+ *
+ * @param msg The message text which is to be sent.
+ *
+ */
+ void chatSend(std::string &msg);
#else
/**
* Determines whether to send a command or an ordinary message, then