diff options
Diffstat (limited to 'src/sound.cpp')
-rw-r--r-- | src/sound.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/sound.cpp b/src/sound.cpp index 913b55656..5b7f1201d 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -66,9 +66,7 @@ Sound::Sound(): Sound::~Sound() { - config.removeListener("playBattleSound", this); - config.removeListener("playGuiSound", this); - config.removeListener("playMusic", this); + config.removeListeners(this); // Unlink the callback function. Mix_HookMusicFinished(nullptr); @@ -82,6 +80,10 @@ void Sound::optionChanged(const std::string &value) mPlayGui = config.getBoolValue("playGuiSound"); else if (value == "playMusic") mPlayMusic = config.getBoolValue("playMusic"); + else if (value == "sfxVolume") + setSfxVolume(config.getIntValue("sfxVolume")); + else if (value == "musicVolume") + setMusicVolume(config.getIntValue("musicVolume")); } void Sound::init() @@ -98,6 +100,8 @@ void Sound::init() config.addListener("playBattleSound", this); config.addListener("playGuiSound", this); config.addListener("playMusic", this); + config.addListener("sfxVolume", this); + config.addListener("musicVolume", this); if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1) { @@ -317,6 +321,12 @@ void Sound::playSfx(const std::string &path, int x, int y) } } +void Sound::playGuiSound(const std::string &name) +{ + playGuiSfx(branding.getStringValue("systemsounds") + + config.getStringValue(name) + ".ogg"); +} + void Sound::playGuiSfx(const std::string &path) { if (!mInstalled || path.empty() || !mPlayGui) |