diff options
Diffstat (limited to 'src/gui/chat.cpp')
-rw-r--r-- | src/gui/chat.cpp | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index f87a8a3d..103a2647 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -21,7 +21,7 @@ #include "chat.h" -#include "beingmanager.h" +#include "actorspritemanager.h" #include "configuration.h" #include "localplayer.h" #include "party.h" @@ -77,6 +77,8 @@ ChatWindow::ChatWindow(): Window(_("Chat")), mTmpVisible(false) { + listen("Notices"); + setWindowName("Chat"); setupWindow->registerWindowForReset(this); @@ -281,20 +283,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 +410,17 @@ 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); + } + } +} + void ChatWindow::addInputText(const std::string &text) { const int caretPos = mChatInput->getCaretPosition(); @@ -446,7 +459,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; @@ -470,10 +483,14 @@ void ChatWindow::whisper(const std::string &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 +499,7 @@ void ChatWindow::whisper(const std::string &nick, } else { - if (own) + if (own == BY_PLAYER) { Net::getChatHandler()->privateMessage(nick, mes); @@ -546,7 +563,7 @@ void ChatWindow::autoComplete() if (newName == "") { - beingManager->getPlayerNames(nameList, true); + actorSpriteManager->getPlayerNames(nameList, true); newName = autoComplete(nameList, name); } if (newName == "") |