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.cpp64
1 files changed, 53 insertions, 11 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 6d900e98..491542a8 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"
@@ -89,6 +90,9 @@ ChatWindow::ChatWindow():
mAutoComplete(new ChatAutoComplete),
mTmpVisible(false)
{
+ listen(Event::ChatChannel);
+ listen(Event::NoticesChannel);
+
setWindowName("Chat");
setupWindow->registerWindowForReset(this);
@@ -119,7 +123,7 @@ ChatWindow::ChatWindow():
mChatInput->setHistory(mHistory);
mChatInput->setAutoComplete(mAutoComplete);
- mReturnToggles = config.getValue("ReturnToggles", "0") == "1";
+ mReturnToggles = config.getBoolValue("ReturnToggles");
mRecorder = new Recorder(this);
}
@@ -286,20 +290,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;
}
}
@@ -371,6 +375,40 @@ void ChatWindow::mouseDragged(gcn::MouseEvent &event)
}
}
+void ChatWindow::event(Event::Channel channel, const Event &event)
+{
+ if (channel == Event::NoticesChannel)
+ {
+ if (event.getType() == Event::ServerNotice)
+ localChatTab->chatLog(event.getString("message"), BY_SERVER);
+ }
+ else if (channel == Event::ChatChannel)
+ {
+ if (event.getType() == Event::Whisper)
+ {
+ whisper(event.getString("nick"), event.getString("message"));
+ }
+ else if (event.getType() == Event::WhisperError)
+ {
+ whisper(event.getString("nick"),
+ event.getString("error"), BY_SERVER);
+ }
+ else if (event.getType() == Event::Player)
+ {
+ localChatTab->chatLog(event.getString("message"), BY_PLAYER);
+ }
+ else if (event.getType() == Event::Announcement)
+ {
+ localChatTab->chatLog(event.getString("message"), BY_GM);
+ }
+ else if (event.getType() == Event::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();
@@ -409,7 +447,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;
@@ -428,15 +466,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);
@@ -445,7 +487,7 @@ void ChatWindow::whisper(const std::string &nick,
}
else
{
- if (own)
+ if (own == BY_PLAYER)
{
Net::getChatHandler()->privateMessage(nick, mes);