From aa5878d6dfe8453a69c0e287c11cae53cfa7abb0 Mon Sep 17 00:00:00 2001 From: stiffly Date: Mon, 8 Feb 2016 16:40:13 +0100 Subject: [PATCH] Used config for soundsystem properties. --- assets | 2 +- include/Engine/Sound/SoundManager.h | 2 ++ include/Game/Systems/SoundSystem.h | 2 ++ resources/DefaultConfig.ini | 5 +++++ src/Engine/Sound/SoundManager.cpp | 4 +++- src/Game/Systems/SoundSystem.cpp | 8 +++++--- 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/assets b/assets index cfeeb1f8..88b1b9f0 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit cfeeb1f880e19356477a703da92204eede09db5d +Subproject commit 88b1b9f047c2cf02c1d39da39dff472cadfb93e7 diff --git a/include/Engine/Sound/SoundManager.h b/include/Engine/Sound/SoundManager.h index 3923a17b..2c07578c 100644 --- a/include/Engine/Sound/SoundManager.h +++ b/include/Engine/Sound/SoundManager.h @@ -13,6 +13,8 @@ #include "Core/World.h" #include "Core/EventBroker.h" +#include "../Engine/Core/ResourceManager.h" +#include "../Engine/Core/ConfigFile.h" #include "Core/Transform.h" // Absolute transform #include "Sound/Sound.h" #include "../Engine/Sound/EPlayQueueOnEntity.h" diff --git a/include/Game/Systems/SoundSystem.h b/include/Game/Systems/SoundSystem.h index c69f7296..0f7f5102 100644 --- a/include/Game/Systems/SoundSystem.h +++ b/include/Game/Systems/SoundSystem.h @@ -5,6 +5,7 @@ #include "../Engine/Core/System.h" #include "../Engine/Core/ResourceManager.h" +#include "../Engine/Core/ConfigFile.h" #include "../Engine/Sound/Sound.h" #include "../Engine/Sound/EPlayQueueOnEntity.h" #include "../Engine/Core/EPlayerSpawned.h" @@ -34,6 +35,7 @@ private: World* m_World = nullptr; EventBroker* m_EventBroker = nullptr; + std::string m_Announcer = ""; // Logic for playing a sound when a player jumps void playerJumps(); diff --git a/resources/DefaultConfig.ini b/resources/DefaultConfig.ini index 86dc735c..12ec06c8 100644 --- a/resources/DefaultConfig.ini +++ b/resources/DefaultConfig.ini @@ -29,3 +29,8 @@ TimeoutMs=15000 [Multithreading] ResourceLoading=true + +[Sound] +BGMVolume=1.0 +SFXVolume=1.0 +Announcer=female \ No newline at end of file diff --git a/src/Engine/Sound/SoundManager.cpp b/src/Engine/Sound/SoundManager.cpp index b952426c..972a38bb 100644 --- a/src/Engine/Sound/SoundManager.cpp +++ b/src/Engine/Sound/SoundManager.cpp @@ -2,12 +2,14 @@ SoundManager::SoundManager(World* world, EventBroker* eventBroker, bool editorMode) { + ConfigFile* config = ResourceManager::Load("Config.ini"); m_EventBroker = eventBroker; m_World = world; m_EditorEnabled = editorMode; + m_BGMVolumeChannel = config->Get("Sound.BGMVolume", 1.f); + m_SFXVolumeChannel = config->Get("Sound.SFXVolume", 1.f); initOpenAL(); - alSpeedOfSound(340.29f); alDistanceModel(AL_LINEAR_DISTANCE); alDopplerFactor(1); diff --git a/src/Game/Systems/SoundSystem.cpp b/src/Game/Systems/SoundSystem.cpp index b218e6c1..06e7d67a 100644 --- a/src/Game/Systems/SoundSystem.cpp +++ b/src/Game/Systems/SoundSystem.cpp @@ -5,6 +5,8 @@ SoundSystem::SoundSystem(World* world, EventBroker* eventbroker) , PureSystem("SoundEmitter") //, ImpureSystem() { + ConfigFile* config = ResourceManager::Load("Config.ini"); + m_Announcer = ResourceManager::Load("Config.ini")->Get("Sound.Announcer", "female"); m_World = world; m_EventBroker = eventbroker; EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &SoundSystem::OnPlayerSpawned); @@ -30,7 +32,7 @@ bool SoundSystem::OnPlayerSpawned(const Events::PlayerSpawned &e) m_LocalPlayer = e.Player; Events::PlaySoundOnEntity go; go.EmitterID = createChildEmitter(m_LocalPlayer); - go.FilePath = "Audio/announcer/go.wav"; + go.FilePath = "Audio/announcer/" + m_Announcer + "/go.wav"; m_EventBroker->Publish(go); // TEMP: starts bgm { @@ -86,9 +88,9 @@ bool SoundSystem::OnCaptured(const Events::Captured & e) int team = (int)m_World->GetComponent(m_LocalPlayer.ID, "Team")["Team"]; Events::PlaySoundOnEntity ev; if (team == homeTeam) { - ev.FilePath = "Audio/announcer/objective_achieved.wav"; + ev.FilePath = "Audio/announcer/" + m_Announcer + "/objective_achieved.wav"; } else { - ev.FilePath = "Audio/announcer/objective_failed.wav"; // have not been tested + ev.FilePath = "Audio/announcer/" + m_Announcer + "/objective_failed.wav"; // have not been tested } ev.EmitterID = createChildEmitter(m_LocalPlayer); m_EventBroker->Publish(ev);