From c85d939d9b3f6c10288dc86ffa7811408e349657 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 28 Feb 2012 02:14:15 +0300 Subject: Add different sound effects for different events. Can be configured in audio tab in settings. --- src/gui/widgets/setupitem.cpp | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'src/gui/widgets/setupitem.cpp') 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); + } +} -- cgit v1.2.3-60-g2f50