diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-09-15 11:55:38 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-09-15 11:55:38 +0300 |
commit | be002b5d8b9137011e37df519ddc5d5174179103 (patch) | |
tree | 3b1f1bff7dbce4a73c923e557b8cdffaec96f31c | |
parent | 54d665ca2ff9244ef4b5a6dc48424d4a3364a40c (diff) | |
download | manaverse-be002b5d8b9137011e37df519ddc5d5174179103.tar.gz manaverse-be002b5d8b9137011e37df519ddc5d5174179103.tar.bz2 manaverse-be002b5d8b9137011e37df519ddc5d5174179103.tar.xz manaverse-be002b5d8b9137011e37df519ddc5d5174179103.zip |
add option to not unload sounds after using.
It configured by default for not unload sounds/music.
-rw-r--r-- | src/defaults.cpp | 1 | ||||
-rw-r--r-- | src/gui/setup_perfomance.cpp | 5 | ||||
-rw-r--r-- | src/soundmanager.cpp | 15 | ||||
-rw-r--r-- | src/soundmanager.h | 3 |
4 files changed, 20 insertions, 4 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp index bba066954..9a3313320 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -315,6 +315,7 @@ DefaultsData* getConfigDefaults() AddDEF("showAllLang", false); AddDEF("moveNames", false); AddDEF("uselonglivesprites", false); + AddDEF("uselonglivesounds", true); AddDEF("screenDensity", 0); AddDEF("cfgver", 0); AddDEF("enableDebugLog", false); diff --git a/src/gui/setup_perfomance.cpp b/src/gui/setup_perfomance.cpp index 079263a2d..8c8969335 100644 --- a/src/gui/setup_perfomance.cpp +++ b/src/gui/setup_perfomance.cpp @@ -148,6 +148,11 @@ Setup_Perfomance::Setup_Perfomance(const Widget2 *const widget) : "additinal memory)"), "", "uselonglivesprites", this, "uselonglivespritesEvent"); + // TRANSLATORS: settings option + new SetupItemCheckBox(_("Cache all sounds (can use additinal memory)"), + "", "uselonglivesounds", this, + "uselonglivesoundsEvent"); + setDimension(gcn::Rectangle(0, 0, 550, 350)); } diff --git a/src/soundmanager.cpp b/src/soundmanager.cpp index 2a3f362b7..83d42e108 100644 --- a/src/soundmanager.cpp +++ b/src/soundmanager.cpp @@ -56,11 +56,12 @@ SoundManager::SoundManager(): mMusicVolume(60), mCurrentMusicFile(), mMusic(nullptr), + mGuiChannel(-1), mPlayBattle(false), mPlayGui(false), mPlayMusic(false), mFadeoutMusic(true), - mGuiChannel(-1) + mCacheSounds(true) { // This set up our callback function used to // handle fade outs endings. @@ -94,6 +95,8 @@ void SoundManager::optionChanged(const std::string &value) setMusicVolume(config.getIntValue("musicVolume")); else if (value == "fadeoutmusic") mFadeoutMusic = config.getIntValue("fadeoutmusic"); + else if (value == "uselonglivesounds") + mCacheSounds = config.getIntValue("uselonglivesounds"); } void SoundManager::init() @@ -110,6 +113,7 @@ void SoundManager::init() mFadeoutMusic = config.getBoolValue("fadeoutmusic"); mMusicVolume = config.getIntValue("musicVolume"); mSfxVolume = config.getIntValue("sfxVolume"); + mCacheSounds = config.getIntValue("uselonglivesounds"); config.addListener("playBattleSound", this); config.addListener("playGuiSound", this); @@ -117,6 +121,7 @@ void SoundManager::init() config.addListener("sfxVolume", this); config.addListener("musicVolume", this); config.addListener("fadeoutmusic", this); + config.addListener("uselonglivesounds", this); if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1) { @@ -360,7 +365,7 @@ void SoundManager::playSfx(const std::string &path, else tmpPath = paths.getValue("sfx", "sfx/").append(path); ResourceManager *const resman = ResourceManager::getInstance(); - const SoundEffect *const sample = resman->getSoundEffect(tmpPath); + SoundEffect *const sample = resman->getSoundEffect(tmpPath); if (sample) { logger->log("SoundManager::playSfx() Playing: %s", path.c_str()); @@ -380,6 +385,8 @@ void SoundManager::playSfx(const std::string &path, vol -= dist * 8; } sample->play(0, vol); + if (!mCacheSounds) + sample->decRef(); } } @@ -400,13 +407,15 @@ void SoundManager::playGuiSfx(const std::string &path) else tmpPath = paths.getValue("sfx", "sfx/").append(path); ResourceManager *const resman = ResourceManager::getInstance(); - const SoundEffect *const sample = resman->getSoundEffect(tmpPath); + SoundEffect *const sample = resman->getSoundEffect(tmpPath); if (sample) { logger->log("SoundManager::playGuiSfx() Playing: %s", path.c_str()); const int ret = sample->play(0, 120, mGuiChannel); if (ret != -1) mGuiChannel = ret; + if (!mCacheSounds) + sample->decRef(); } } diff --git a/src/soundmanager.h b/src/soundmanager.h index b66520ab1..e4398029e 100644 --- a/src/soundmanager.h +++ b/src/soundmanager.h @@ -156,11 +156,12 @@ class SoundManager final : public ConfigListener std::string mCurrentMusicFile; SDLMusic *mMusic; + int mGuiChannel; bool mPlayBattle; bool mPlayGui; bool mPlayMusic; bool mFadeoutMusic; - int mGuiChannel; + bool mCacheSounds; }; extern SoundManager soundManager; |