diff options
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/chattab.cpp | 23 | ||||
-rw-r--r-- | src/gui/widgets/chattab.h | 9 | ||||
-rw-r--r-- | src/gui/widgets/whispertab.h | 3 |
3 files changed, 32 insertions, 3 deletions
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 8642be69..1979ecbd 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -23,9 +23,11 @@ #include "actorspritemanager.h" #include "chatlogger.h" +#include "client.h" #include "commandhandler.h" #include "configuration.h" #include "localplayer.h" +#include "sound.h" #include "gui/gui.h" #include "gui/recorder.h" @@ -237,10 +239,20 @@ void ChatTab::chatLog(std::string line, Own own, bool ignoreRecord) } mScrollArea->logic(); + chatWindow->mRecorder->record(line.substr(3)); - if (this != getTabbedArea()->getSelectedTab() && - own != BY_PLAYER) - setFlash(true); + + if (own != BY_PLAYER) + { + bool currentTab = getTabbedArea()->getSelectedTab() == this; + + if (!currentTab) + setFlash(true); + + if (!(currentTab && Client::hasInputFocus()) && own != BY_SERVER) + if (checkNotify(own)) + sound.playNotification("system/newmessage.ogg"); + } } void ChatTab::chatLog(const std::string &nick, const std::string &msg) @@ -318,6 +330,11 @@ void ChatTab::handleCommand(const std::string &msg) commandHandler->handleCommand(msg, this); } +bool ChatTab::checkNotify(Own own) const +{ + return own == ACT_WHISPER; +} + void ChatTab::getAutoCompleteList(std::vector<std::string> &names) const { actorSpriteManager->getPlayerNPCNameLister()->getAutoCompleteList(names); diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h index 3796c37b..200ad55a 100644 --- a/src/gui/widgets/chattab.h +++ b/src/gui/widgets/chattab.h @@ -115,6 +115,15 @@ class ChatTab : public Tab, public AutoCompleteLister, public EventListener virtual void handleCommand(const std::string &msg); /** + * Returns whether a notify sound may be played for the given type of + * message. By default, only returns true for inline whispers. + * + * Is never called for server-messages or when the window has focus + * and this is the current tab. + */ + virtual bool checkNotify(Own own) const; + + /** * Adapts the text format to the current gui opacity, * for better readability. */ diff --git a/src/gui/widgets/whispertab.h b/src/gui/widgets/whispertab.h index e88d084b..a0dcfc14 100644 --- a/src/gui/widgets/whispertab.h +++ b/src/gui/widgets/whispertab.h @@ -57,6 +57,9 @@ class WhisperTab : public ChatTab void handleCommand(const std::string &msg); + bool checkNotify(Own) const + { return true; } + private: std::string mNick; }; |