diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-02-18 22:47:30 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-02-18 23:24:03 +0100 |
commit | 20afba1adc84dd0e859605250c5a44a111045c2b (patch) | |
tree | 304f34e96403215a8e1d9a3cf880a6a28f5a4721 /src/gui/widgets | |
parent | 6fd1246735010bccd0d75e9e7969431b963b7858 (diff) | |
download | mana-client-20afba1adc84dd0e859605250c5a44a111045c2b.tar.gz mana-client-20afba1adc84dd0e859605250c5a44a111045c2b.tar.bz2 mana-client-20afba1adc84dd0e859605250c5a44a111045c2b.tar.xz mana-client-20afba1adc84dd0e859605250c5a44a111045c2b.zip |
Added notification sound on receiving whisper
One of the sound channels is reserved for notification sounds, of which the
volume can be configured separately. Currently, the only notification sound
that is played is for receiving whispers. That can be extended later.
The newmessage.ogg sound used currently is the one for receiving a message
with the Psi instant messenger.
Parts of this patch are based on the new message notification in ManaPlus.
Reviewed-by: Erik Schilling
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; }; |