summaryrefslogtreecommitdiff
path: root/src/gui/chat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/chat.cpp')
-rw-r--r--src/gui/chat.cpp66
1 files changed, 54 insertions, 12 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index f87a8a3d..b1d4b131 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -21,10 +21,11 @@
#include "chat.h"
-#include "beingmanager.h"
+#include "actorspritemanager.h"
#include "configuration.h"
#include "localplayer.h"
#include "party.h"
+#include "playerrelations.h"
#include "gui/recorder.h"
#include "gui/setup.h"
@@ -77,6 +78,9 @@ ChatWindow::ChatWindow():
Window(_("Chat")),
mTmpVisible(false)
{
+ listen("Chat");
+ listen("Notices");
+
setWindowName("Chat");
setupWindow->registerWindowForReset(this);
@@ -108,7 +112,7 @@ ChatWindow::ChatWindow():
mChatInput->addKeyListener(this);
mCurHist = mHistory.end();
- mReturnToggles = config.getValue("ReturnToggles", "0") == "1";
+ mReturnToggles = config.getBoolValue("ReturnToggles");
mRecorder = new Recorder(this);
}
@@ -281,20 +285,20 @@ void ChatWindow::chatInput(const std::string &msg)
void ChatWindow::doPresent()
{
- const Beings &beings = beingManager->getAll();
+ const ActorSprites &actors = actorSpriteManager->getAll();
std::string response = "";
int playercount = 0;
- for (Beings::const_iterator bi = beings.begin(), be = beings.end();
- bi != be; ++bi)
+ for (ActorSpritesConstIterator it = actors.begin(), it_end = actors.end();
+ it != it_end; it++)
{
- if ((*bi)->getType() == Being::PLAYER)
+ if ((*it)->getType() == ActorSprite::PLAYER)
{
if (!response.empty())
{
response += ", ";
}
- response += (*bi)->getName();
+ response += static_cast<Being*>(*it)->getName();
++playercount;
}
}
@@ -408,6 +412,40 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event)
}
}
+void ChatWindow::event(const std::string &channel, const Mana::Event &event)
+{
+ if (channel == "Notices")
+ {
+ if (event.getName() == "ServerNotice")
+ localChatTab->chatLog(event.getString("message"), BY_SERVER);
+ }
+ else if (channel == "Chat")
+ {
+ if (event.getName() == "Whisper")
+ {
+ whisper(event.getString("nick"), event.getString("message"));
+ }
+ else if (event.getName() == "WhisperError")
+ {
+ whisper(event.getString("nick"),
+ event.getString("error"), BY_SERVER);
+ }
+ else if (event.getName() == "Player")
+ {
+ localChatTab->chatLog(event.getString("message"), BY_PLAYER);
+ }
+ else if (event.getName() == "Announcement")
+ {
+ localChatTab->chatLog(event.getString("message"), BY_GM);
+ }
+ else if (event.getName() == "Being")
+ {
+ if (event.getInt("permissions") & PlayerRelation::SPEECH_LOG)
+ localChatTab->chatLog(event.getString("message"), BY_OTHER);
+ }
+ }
+}
+
void ChatWindow::addInputText(const std::string &text)
{
const int caretPos = mChatInput->getCaretPosition();
@@ -446,7 +484,7 @@ void ChatWindow::setRecordingFile(const std::string &msg)
}
void ChatWindow::whisper(const std::string &nick,
- const std::string &mes, bool own)
+ const std::string &mes, Own own)
{
if (mes.empty())
return;
@@ -465,15 +503,19 @@ void ChatWindow::whisper(const std::string &nick,
if (i != mWhispers.end())
tab = i->second;
- else if (config.getValue("whispertab", true))
+ else if (config.getBoolValue("whispertab"))
tab = addWhisperTab(nick);
if (tab)
{
- if (own)
+ if (own == BY_PLAYER)
{
tab->chatInput(mes);
}
+ else if (own == BY_SERVER)
+ {
+ tab->chatLog(mes);
+ }
else
{
tab->chatLog(nick, mes);
@@ -482,7 +524,7 @@ void ChatWindow::whisper(const std::string &nick,
}
else
{
- if (own)
+ if (own == BY_PLAYER)
{
Net::getChatHandler()->privateMessage(nick, mes);
@@ -546,7 +588,7 @@ void ChatWindow::autoComplete()
if (newName == "")
{
- beingManager->getPlayerNames(nameList, true);
+ actorSpriteManager->getPlayerNames(nameList, true);
newName = autoComplete(nameList, name);
}
if (newName == "")