mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-04-10 19:15:13 +00:00
Add a "disable sounds" option to the settings menu.
This commit is contained in:
parent
742cd4eac4
commit
4f416d13a0
|
@ -31,6 +31,7 @@ void Settings::setDefaults()
|
||||||
mBoolMap["DONTSHOWEXIT"] = false;
|
mBoolMap["DONTSHOWEXIT"] = false;
|
||||||
mBoolMap["DEBUG"] = false;
|
mBoolMap["DEBUG"] = false;
|
||||||
mBoolMap["WINDOWED"] = false;
|
mBoolMap["WINDOWED"] = false;
|
||||||
|
mBoolMap["DISABLESOUNDS"] = false;
|
||||||
|
|
||||||
mIntMap["DIMTIME"] = 30*1000;
|
mIntMap["DIMTIME"] = 30*1000;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
#include "AudioManager.h"
|
#include "AudioManager.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
#include "Settings.h"
|
||||||
|
|
||||||
Sound::Sound(const std::string & path) : mSampleData(NULL), mSamplePos(0), mSampleLength(0), playing(false)
|
Sound::Sound(const std::string & path) : mSampleData(NULL), mSamplePos(0), mSampleLength(0), playing(false)
|
||||||
{
|
{
|
||||||
|
@ -82,6 +82,9 @@ void Sound::play()
|
||||||
if(mSampleData == NULL)
|
if(mSampleData == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(Settings::getInstance()->getBool("DISABLESOUNDS"))
|
||||||
|
return;
|
||||||
|
|
||||||
SDL_LockAudio();
|
SDL_LockAudio();
|
||||||
if (playing)
|
if (playing)
|
||||||
{
|
{
|
||||||
|
|
|
@ -229,6 +229,7 @@ void ComponentListComponent::moveCursor(Eigen::Vector2i dir)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mCursor += searchAxis;
|
mCursor += searchAxis;
|
||||||
|
LOG(LogInfo) << "checking " << mCursor.x() << ", " << mCursor.y();
|
||||||
}
|
}
|
||||||
|
|
||||||
//now again on search axis-
|
//now again on search axis-
|
||||||
|
@ -239,7 +240,10 @@ void ComponentListComponent::moveCursor(Eigen::Vector2i dir)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mCursor -= searchAxis;
|
mCursor -= searchAxis;
|
||||||
|
LOG(LogInfo) << "checking " << mCursor.x() << ", " << mCursor.y();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mCursor = curDirPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
//failed to find another focusable element in this direction
|
//failed to find another focusable element in this direction
|
||||||
|
|
|
@ -4,9 +4,10 @@
|
||||||
#include "../VolumeControl.h"
|
#include "../VolumeControl.h"
|
||||||
|
|
||||||
GuiSettingsMenu::GuiSettingsMenu(Window* window) : GuiComponent(window),
|
GuiSettingsMenu::GuiSettingsMenu(Window* window) : GuiComponent(window),
|
||||||
mList(window, Eigen::Vector2i(2, 3)),
|
mList(window, Eigen::Vector2i(2, 4)),
|
||||||
mDrawFramerateSwitch(window),
|
mDrawFramerateSwitch(window),
|
||||||
mVolumeSlider(window, 0, 100, 1),
|
mVolumeSlider(window, 0, 100, 1),
|
||||||
|
mDisableSoundsSwitch(window, false),
|
||||||
mSaveLabel(window)
|
mSaveLabel(window)
|
||||||
{
|
{
|
||||||
loadStates();
|
loadStates();
|
||||||
|
@ -26,19 +27,32 @@ GuiSettingsMenu::GuiSettingsMenu(Window* window) : GuiComponent(window),
|
||||||
//drawFramerate switch
|
//drawFramerate switch
|
||||||
mList.setEntry(Vector2i(1, 0), Vector2i(1, 1), &mDrawFramerateSwitch, true, ComponentListComponent::AlignCenter, Matrix<bool, 1, 2>(true, true));
|
mList.setEntry(Vector2i(1, 0), Vector2i(1, 1), &mDrawFramerateSwitch, true, ComponentListComponent::AlignCenter, Matrix<bool, 1, 2>(true, true));
|
||||||
|
|
||||||
|
//volume label
|
||||||
label = new TextComponent(mWindow);
|
label = new TextComponent(mWindow);
|
||||||
label->setText("System volume: ");
|
label->setText("System volume: ");
|
||||||
label->setColor(0x0000FFFF);
|
label->setColor(0x0000FFFF);
|
||||||
|
mLabels.push_back(label);
|
||||||
mList.setEntry(Vector2i(0, 1), Vector2i(1, 1), label, false, ComponentListComponent::AlignRight, Matrix<bool, 1, 2>(true, true));
|
mList.setEntry(Vector2i(0, 1), Vector2i(1, 1), label, false, ComponentListComponent::AlignRight, Matrix<bool, 1, 2>(true, true));
|
||||||
|
|
||||||
//volume slider
|
//volume slider
|
||||||
mList.setEntry(Vector2i(1, 1), Vector2i(1, 1), &mVolumeSlider, true, ComponentListComponent::AlignCenter, Matrix<bool, 1, 2>(true, true));
|
mList.setEntry(Vector2i(1, 1), Vector2i(1, 1), &mVolumeSlider, true, ComponentListComponent::AlignCenter, Matrix<bool, 1, 2>(true, true));
|
||||||
|
|
||||||
|
//disable sounds
|
||||||
|
label = new TextComponent(mWindow);
|
||||||
|
label->setText("Disable sounds: ");
|
||||||
|
label->setColor(0x0000FFFF);
|
||||||
|
mLabels.push_back(label);
|
||||||
|
mList.setEntry(Vector2i(0, 2), Vector2i(1, 1), label, false, ComponentListComponent::AlignRight, Matrix<bool, 1, 2>(true, true));
|
||||||
|
|
||||||
|
mList.setEntry(Vector2i(1, 2), Vector2i(1, 1), &mDisableSoundsSwitch, true, ComponentListComponent::AlignCenter, Matrix<bool, 1, 2>(true, true));
|
||||||
|
|
||||||
|
|
||||||
//save label
|
//save label
|
||||||
mSaveLabel.setText("SAVE");
|
mSaveLabel.setText("SAVE");
|
||||||
mSaveLabel.setColor(0x000000FF);
|
mSaveLabel.setColor(0x000000FF);
|
||||||
mList.setEntry(Vector2i(0, 2), Vector2i(2, 1), &mSaveLabel, true, ComponentListComponent::AlignCenter, Matrix<bool, 1, 2>(false, true));
|
mList.setEntry(Vector2i(0, 3), Vector2i(2, 1), &mSaveLabel, true, ComponentListComponent::AlignCenter, Matrix<bool, 1, 2>(false, true));
|
||||||
|
|
||||||
|
//center list
|
||||||
mList.setPosition(Renderer::getScreenWidth() / 2 - mList.getSize().x() / 2, 0);
|
mList.setPosition(Renderer::getScreenWidth() / 2 - mList.getSize().x() / 2, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +92,8 @@ void GuiSettingsMenu::loadStates()
|
||||||
mDrawFramerateSwitch.setState(s->getBool("DRAWFRAMERATE"));
|
mDrawFramerateSwitch.setState(s->getBool("DRAWFRAMERATE"));
|
||||||
|
|
||||||
mVolumeSlider.setValue((float)VolumeControl::getInstance()->getVolume());
|
mVolumeSlider.setValue((float)VolumeControl::getInstance()->getVolume());
|
||||||
|
|
||||||
|
mDisableSoundsSwitch.setState(s->getBool("DISABLESOUNDS"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiSettingsMenu::applyStates()
|
void GuiSettingsMenu::applyStates()
|
||||||
|
@ -87,5 +103,7 @@ void GuiSettingsMenu::applyStates()
|
||||||
|
|
||||||
VolumeControl::getInstance()->setVolume((int)mVolumeSlider.getValue());
|
VolumeControl::getInstance()->setVolume((int)mVolumeSlider.getValue());
|
||||||
|
|
||||||
|
s->setBool("DISABLESOUNDS", mDisableSoundsSwitch.getState());
|
||||||
|
|
||||||
s->saveFile();
|
s->saveFile();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ private:
|
||||||
|
|
||||||
SwitchComponent mDrawFramerateSwitch;
|
SwitchComponent mDrawFramerateSwitch;
|
||||||
SliderComponent mVolumeSlider;
|
SliderComponent mVolumeSlider;
|
||||||
|
SwitchComponent mDisableSoundsSwitch;
|
||||||
TextComponent mSaveLabel;
|
TextComponent mSaveLabel;
|
||||||
|
|
||||||
std::vector<GuiComponent*> mLabels;
|
std::vector<GuiComponent*> mLabels;
|
||||||
|
|
Loading…
Reference in a new issue