diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-02-28 02:14:15 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-02-28 03:01:38 +0300 |
commit | c85d939d9b3f6c10288dc86ffa7811408e349657 (patch) | |
tree | b1ca825fde3bad322728df1c9133ec25b74b341e /src/gui/widgets | |
parent | 5023a1d0b96071a35547dcc309ce45ba6a17eec1 (diff) | |
download | manaplus-c85d939d9b3f6c10288dc86ffa7811408e349657.tar.gz manaplus-c85d939d9b3f6c10288dc86ffa7811408e349657.tar.bz2 manaplus-c85d939d9b3f6c10288dc86ffa7811408e349657.tar.xz manaplus-c85d939d9b3f6c10288dc86ffa7811408e349657.zip |
Add different sound effects for different events.
Can be configured in audio tab in settings.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/chattab.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/setupitem.cpp | 40 | ||||
-rw-r--r-- | src/gui/widgets/setupitem.h | 21 | ||||
-rw-r--r-- | src/gui/widgets/sliderlist.h | 3 |
4 files changed, 62 insertions, 4 deletions
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 018e35030..53842e887 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -301,7 +301,7 @@ void ChatTab::chatLog(std::string line, Own own, && !Client::getInputFocused())))) { if (own != BY_SERVER) - sound.playGuiSfx("system/newmessage.ogg"); + sound.playGuiSound("soundwhisper"); } } } diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 581002a58..9eedfd58d 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -23,6 +23,7 @@ #include "configuration.h" #include "main.h" #include "logger.h" +#include "sound.h" #include "gui/editdialog.h" #include "gui/gui.h" @@ -872,7 +873,7 @@ SetupItemSliderList::SetupItemSliderList(std::string text, mOnTheFly(onTheFly) { mValueType = VSTR; - createControls(); +// createControls(); } SetupItemSliderList::SetupItemSliderList(std::string text, @@ -892,7 +893,7 @@ SetupItemSliderList::SetupItemSliderList(std::string text, mOnTheFly(onTheFly) { mValueType = VSTR; - createControls(); +// createControls(); } SetupItemSliderList::~SetupItemSliderList() @@ -917,6 +918,8 @@ void SetupItemSliderList::createControls() mHorizont->add(mLabel, 5); mHorizont->add(mSlider); + addMoreControls(); + mParent->getContainer()->add2(mHorizont, true, 4); mParent->addControl(this); mParent->addActionListener(this); @@ -954,3 +957,36 @@ void SetupItemSliderList::apply(std::string eventName) fromWidget(); save(); } + +SetupItemSound::SetupItemSound(std::string text, std::string description, + std::string keyName, SetupTabScroll *parent, + std::string eventName, gcn::ListModel *model, + int width, bool onTheFly, bool mainConfig) : + SetupItemSliderList(text, description, keyName, parent, eventName, + model, width, onTheFly, mainConfig), + mButton(nullptr) +{ + createControls(); +} + +void SetupItemSound::addMoreControls() +{ + mButton = new Button(_("Play"), mEventName + "_PLAY", this); + mHorizont->add(mButton); +} + +void SetupItemSound::action(const gcn::ActionEvent &event) +{ + if (event.getId() == mEventName + "_PLAY") + { + if (mSlider->getSelected()) + { + sound.playGuiSfx(branding.getStringValue("systemsounds") + + mSlider->getSelectedString() + ".ogg"); + } + } + else + { + SetupItemSliderList::action(event); + } +} diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index f883a5b94..38dec929e 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -377,10 +377,12 @@ class SetupItemSliderList : public SetupItem void toWidget(); - void action(const gcn::ActionEvent &event); + virtual void action(const gcn::ActionEvent &event); void apply(std::string eventName); + virtual void addMoreControls() = 0; + protected: HorizontContainer *mHorizont; Label *mLabel; @@ -390,4 +392,21 @@ class SetupItemSliderList : public SetupItem bool mOnTheFly; }; +class SetupItemSound : public SetupItemSliderList +{ + public: + SetupItemSound(std::string text, std::string description, + std::string keyName, SetupTabScroll *parent, + std::string eventName, gcn::ListModel *model, + int width = 150, bool onTheFly = false, + bool mainConfig = true); + + void action(const gcn::ActionEvent &event); + + void addMoreControls(); + + protected: + Button *mButton; +}; + #endif diff --git a/src/gui/widgets/sliderlist.h b/src/gui/widgets/sliderlist.h index a7b1a564c..b2239834d 100644 --- a/src/gui/widgets/sliderlist.h +++ b/src/gui/widgets/sliderlist.h @@ -63,6 +63,9 @@ class SliderList : public Container, void adjustSize(); + int getSelected() + { return mSelectedIndex; } + protected: void updateLabel(); |