From 181ac60bd0ee57ec1109b6aa6de3c9d839a504a1 Mon Sep 17 00:00:00 2001 From: Stiffly Date: Thu, 24 Sep 2015 23:41:41 +0200 Subject: [PATCH] MasterVolume now working due to previous refactoring. TODO: Make it depend on individual volume value. --- src/game/Sound/SoundSystem.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/game/Sound/SoundSystem.cpp b/src/game/Sound/SoundSystem.cpp index d619ba5..8594d92 100644 --- a/src/game/Sound/SoundSystem.cpp +++ b/src/game/Sound/SoundSystem.cpp @@ -50,12 +50,12 @@ void dd::Systems::SoundSystem::Initialize() e.isAmbient = true; EventBroker->Publish(e); } - /*{ + { dd::Events::MasterVolume e; e.isAmbient = true; - e.gain = 0.001f; + e.gain = 1.f; EventBroker->Publish(e); - }*/ + } } void dd::Systems::SoundSystem::Update(double dt) @@ -151,13 +151,22 @@ bool dd::Systems::SoundSystem::OnStopSound(const dd::Events::StopSound &event) bool dd::Systems::SoundSystem::OnMasterVolume(const dd::Events::MasterVolume &event) { + //TODO: Make the volume depend on the value given when stored. + //TODO: .. now it ONLY uses the master volume if (event.isAmbient) { m_BGMMasterVolume = event.gain; + for (auto item : m_BGMSourcesToBuffers) + { + alSourcef(item.first, AL_GAIN, event.gain); + } } else if (!event.isAmbient) { m_SFXMasterVolume = event.gain; + for (auto item : m_SFXSourcesToBuffers) + { + alSourcef(item.first, AL_GAIN, event.gain); + } } - m_World->GetEntities(); } //On contact: play the sound given in the CCOllisionSound.