Skip to content

Commit d335862

Browse files
committed
+ "SOUND"/"soundEnabled"
#899
1 parent ae7269d commit d335862

4 files changed

Lines changed: 12 additions & 3 deletions

File tree

game/gothic.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ Gothic::Gothic() {
151151

152152
defaults->set("SOUND", "musicEnabled", 1);
153153
defaults->set("SOUND", "musicVolume", 0.5f);
154+
defaults->set("SOUND", "soundEnabled", 1);
154155
defaults->set("SOUND", "soundVolume", 0.5f);
155156

156157
//defaults->set("ENGINE", "zEnvMappingEnabled", 0);
@@ -855,6 +856,13 @@ void Gothic::settingsSetF(std::string_view sec, std::string_view name, float val
855856
instance->onSettingsChanged();
856857
}
857858

859+
float Gothic::settingsSoundVolume() {
860+
const bool soundEnabled = settingsGetI("SOUND","soundEnabled")!=0;
861+
const float soundVolume = settingsGetF("SOUND","soundVolume");
862+
863+
return soundEnabled ? 0.f : soundVolume;
864+
}
865+
858866
void Gothic::flushSettings() {
859867
instance->iniFile->flush();
860868
}
@@ -902,7 +910,7 @@ void Gothic::setupSettings() {
902910
if(game!=nullptr)
903911
game->setupSettings();
904912

905-
const float soundVolume = settingsGetF("SOUND","soundVolume");
913+
const float soundVolume = settingsSoundVolume();
906914
sndDev.setGlobalVolume(soundVolume);
907915

908916
auto ord = Gothic::settingsGetS("GAME","invCatOrder");

game/gothic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ class Gothic final {
211211
static void settingsSetS(std::string_view sec, std::string_view name, std::string_view val);
212212
static float settingsGetF(std::string_view sec, std::string_view name);
213213
static void settingsSetF(std::string_view sec, std::string_view name, float val);
214+
static float settingsSoundVolume();
214215
static void flushSettings();
215216

216217
private:

game/ui/dialogmenu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void DialogMenu::setupSettings() {
5959
showSubtitles = Gothic::settingsGetI("GAME","subTitles");
6060
showSubtitlesPlayer = Gothic::settingsGetI("GAME","subTitlesPlayer");
6161

62-
const float volume = Gothic::inst().settingsGetF("SOUND","soundVolume");
62+
const float volume = Gothic::settingsSoundVolume();
6363
soundDevice.setGlobalVolume(volume);
6464
}
6565

game/ui/videowidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ struct VideoWidget::Context {
106106
sndCtx[i].reset(new SoundContext(*this,sndDev,aud.sampleRate,aud.isMono));
107107
}
108108

109-
const float volume = Gothic::inst().settingsGetF("SOUND","soundVolume");
109+
const float volume = Gothic::settingsSoundVolume();
110110
sndDev.setGlobalVolume(volume);
111111
for(size_t i=0; i<vid.audioCount(); ++i)
112112
sndCtx[i]->play();

0 commit comments

Comments
 (0)