summaryrefslogtreecommitdiff
path: root/src/gui/widgets/setupitem.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-02-28 02:14:15 +0300
committerAndrei Karas <akaras@inbox.ru>2012-02-28 03:01:38 +0300
commitc85d939d9b3f6c10288dc86ffa7811408e349657 (patch)
treeb1ca825fde3bad322728df1c9133ec25b74b341e /src/gui/widgets/setupitem.cpp
parent5023a1d0b96071a35547dcc309ce45ba6a17eec1 (diff)
downloadplus-c85d939d9b3f6c10288dc86ffa7811408e349657.tar.gz
plus-c85d939d9b3f6c10288dc86ffa7811408e349657.tar.bz2
plus-c85d939d9b3f6c10288dc86ffa7811408e349657.tar.xz
plus-c85d939d9b3f6c10288dc86ffa7811408e349657.zip
Add different sound effects for different events.
Can be configured in audio tab in settings.
Diffstat (limited to 'src/gui/widgets/setupitem.cpp')
-rw-r--r--src/gui/widgets/setupitem.cpp40
1 files changed, 38 insertions, 2 deletions
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);
+ }
+}