summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/equipmentwindow.cpp2
-rw-r--r--src/gui/equipmentwindow.h2
-rw-r--r--src/gui/gui.cpp3
-rw-r--r--src/gui/setup_audio.cpp32
-rw-r--r--src/gui/setup_audio.h18
-rw-r--r--src/gui/truetypefont.cpp4
-rw-r--r--src/gui/widgets/chattab.cpp23
-rw-r--r--src/gui/widgets/chattab.h9
-rw-r--r--src/gui/widgets/whispertab.h3
9 files changed, 75 insertions, 21 deletions
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 4aa76c2f..85a4c766 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -197,7 +197,7 @@ Item *EquipmentWindow::getItem(int x, int y) const
return 0;
}
-const std::string EquipmentWindow::getSlotName(int x, int y) const
+std::string EquipmentWindow::getSlotName(int x, int y) const
{
for (int i = 0; i < mBoxesNumber; ++i)
{
diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h
index 0f1d19fa..29814dc5 100644
--- a/src/gui/equipmentwindow.h
+++ b/src/gui/equipmentwindow.h
@@ -93,7 +93,7 @@ class EquipmentWindow : public Window, public gcn::ActionListener
void mouseMoved(gcn::MouseEvent &event);
Item *getItem(int x, int y) const;
- const std::string getSlotName(int x, int y) const;
+ std::string getSlotName(int x, int y) const;
void setSelected(int index);
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 2f24d009..78fc42fb 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -29,6 +29,7 @@
#include "gui/widgets/window.h"
#include "gui/widgets/windowcontainer.h"
+#include "client.h"
#include "configuration.h"
#include "eventlistener.h"
#include "graphics.h"
@@ -204,7 +205,7 @@ void Gui::draw()
int mouseX, mouseY;
Uint8 button = SDL_GetMouseState(&mouseX, &mouseY);
- if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS || button & SDL_BUTTON(1))
+ if ((Client::hasMouseFocus() || button & SDL_BUTTON(1))
&& mCustomCursor
&& mMouseCursorAlpha > 0.0f)
{
diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp
index c43210d0..69ee3dc3 100644
--- a/src/gui/setup_audio.cpp
+++ b/src/gui/setup_audio.cpp
@@ -37,31 +37,38 @@
Setup_Audio::Setup_Audio():
mMusicVolume(config.getIntValue("musicVolume")),
mSfxVolume(config.getIntValue("sfxVolume")),
+ mNotificationsVolume(config.getIntValue("notificationsVolume")),
mSoundEnabled(config.getBoolValue("sound")),
mDownloadEnabled(config.getBoolValue("download-music")),
mSoundCheckBox(new CheckBox(_("Sound"), mSoundEnabled)),
mDownloadMusicCheckBox(new CheckBox(_("Download music"), mDownloadEnabled)),
mSfxSlider(new Slider(0, sound.getMaxVolume())),
+ mNotificationsSlider(new Slider(0, sound.getMaxVolume())),
mMusicSlider(new Slider(0, sound.getMaxVolume()))
{
setName(_("Audio"));
setDimension(gcn::Rectangle(0, 0, 250, 200));
gcn::Label *sfxLabel = new Label(_("Sfx volume"));
+ gcn::Label *notificationsLabel = new Label(_("Notifications volume"));
gcn::Label *musicLabel = new Label(_("Music volume"));
mSfxSlider->setActionEventId("sfx");
+ mNotificationsSlider->setActionEventId("notifications");
mMusicSlider->setActionEventId("music");
mSfxSlider->addActionListener(this);
+ mNotificationsSlider->addActionListener(this);
mMusicSlider->addActionListener(this);
mSoundCheckBox->setPosition(10, 10);
mSfxSlider->setValue(mSfxVolume);
+ mNotificationsSlider->setValue(mNotificationsVolume);
mMusicSlider->setValue(mMusicVolume);
mSfxSlider->setWidth(90);
+ mNotificationsSlider->setWidth(90);
mMusicSlider->setWidth(90);
// Do the layout
@@ -71,9 +78,11 @@ Setup_Audio::Setup_Audio():
place(0, 0, mSoundCheckBox);
place(0, 1, mSfxSlider);
place(1, 1, sfxLabel);
- place(0, 2, mMusicSlider);
- place(1, 2, musicLabel);
- place(0, 3, mDownloadMusicCheckBox);
+ place(0, 2, mNotificationsSlider);
+ place(1, 2, notificationsLabel);
+ place(0, 3, mMusicSlider);
+ place(1, 3, musicLabel);
+ place(0, 4, mDownloadMusicCheckBox);
setDimension(gcn::Rectangle(0, 0, 370, 280));
}
@@ -83,6 +92,7 @@ void Setup_Audio::apply()
mSoundEnabled = mSoundCheckBox->isSelected();
mDownloadEnabled = mDownloadMusicCheckBox->isSelected();
mSfxVolume = config.getIntValue("sfxVolume");
+ mNotificationsVolume = config.getIntValue("sfxVolume");
mMusicVolume = config.getIntValue("musicVolume");
config.setValue("sound", mSoundEnabled);
@@ -134,12 +144,20 @@ void Setup_Audio::action(const gcn::ActionEvent &event)
{
if (event.getId() == "sfx")
{
- config.setValue("sfxVolume", (int) mSfxSlider->getValue());
- sound.setSfxVolume((int) mSfxSlider->getValue());
+ int volume = (int) mSfxSlider->getValue();
+ config.setValue("sfxVolume", volume);
+ sound.setSfxVolume(volume);
+ }
+ else if (event.getId() == "notifications")
+ {
+ int volume = (int) mNotificationsSlider->getValue();
+ config.setValue("notificationsVolume", volume);
+ sound.setNotificationsVolume(volume);
}
else if (event.getId() == "music")
{
- config.setValue("musicVolume", (int) mMusicSlider->getValue());
- sound.setMusicVolume((int) mMusicSlider->getValue());
+ int volume = (int) mMusicSlider->getValue();
+ config.setValue("musicVolume", volume);
+ sound.setMusicVolume(volume);
}
}
diff --git a/src/gui/setup_audio.h b/src/gui/setup_audio.h
index 5477eaad..ac81bdb7 100644
--- a/src/gui/setup_audio.h
+++ b/src/gui/setup_audio.h
@@ -39,11 +39,17 @@ class Setup_Audio : public SetupTab, public gcn::ActionListener
void action(const gcn::ActionEvent &event);
private:
- int mMusicVolume, mSfxVolume;
- bool mSoundEnabled, mDownloadEnabled;
-
- gcn::CheckBox *mSoundCheckBox, *mDownloadMusicCheckBox;
- gcn::Slider *mSfxSlider, *mMusicSlider;
+ int mMusicVolume;
+ int mSfxVolume;
+ int mNotificationsVolume;
+ bool mSoundEnabled;
+ bool mDownloadEnabled;
+
+ gcn::CheckBox *mSoundCheckBox;
+ gcn::CheckBox *mDownloadMusicCheckBox;
+ gcn::Slider *mSfxSlider;
+ gcn::Slider *mNotificationsSlider;
+ gcn::Slider *mMusicSlider;
};
-#endif
+#endif // GUI_SETUP_AUDIO_H
diff --git a/src/gui/truetypefont.cpp b/src/gui/truetypefont.cpp
index 5f85ea68..620ba191 100644
--- a/src/gui/truetypefont.cpp
+++ b/src/gui/truetypefont.cpp
@@ -57,7 +57,7 @@ class TextChunk
sdlCol.r = color.r;
sdlCol.g = color.g;
- const char* str = getSafeUtf8String(text);
+ const char *str = getSafeUtf8String(text);
SDL_Surface *surface = TTF_RenderUTF8_Blended(
font, str, sdlCol);
delete[] str;
@@ -179,7 +179,7 @@ int TrueTypeFont::getWidth(const std::string &text) const
}
int w, h;
- const char* str = getSafeUtf8String(text);
+ const char *str = getSafeUtf8String(text);
TTF_SizeUTF8(mFont, str, &w, &h);
delete[] str;
return w;
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;
};