From 64f903a6b6abe7b582f8bcaa0295ca53321cb8ac Mon Sep 17 00:00:00 2001 From: Stiffly Date: Thu, 15 Oct 2015 13:48:05 +0200 Subject: [PATCH] WIP --- include/Core/Engine.h | 20 +++++++++------- include/GUI/Button.h | 4 ++++ include/GUI/Slider.h | 6 +++++ include/GUI/TextureFrame.h | 1 + src/game/Sound/SoundSystem.cpp | 44 ++++++++++++++++------------------ 5 files changed, 43 insertions(+), 32 deletions(-) diff --git a/include/Core/Engine.h b/include/Core/Engine.h index 905eea4..b31458f 100755 --- a/include/Core/Engine.h +++ b/include/Core/Engine.h @@ -391,6 +391,8 @@ public: // I apologize about this. ScreenShakeUpdate(dt); + } else { + m_EventBroker->Process(); } m_EventBroker->Process(); m_FrameStack->UpdateLayered(dt); @@ -610,17 +612,17 @@ private: m_GameIsRunning = true; //Todo: Move this { - dd::Events::PlaySound e; - e.FilePath = "Sounds/BGM/under-the-sea-instrumental.wav"; - e.IsAmbient = true; - m_EventBroker->Publish(e); +// dd::Events::PlaySound e; +// e.FilePath = "Sounds/BGM/under-the-sea-instrumental.wav"; +// e.IsAmbient = true; +// m_EventBroker->Publish(e); } { - dd::Events::PlaySound e; - e.FilePath = "Sounds/BGM/water-flowing.wav"; - e.Gain = 0.3f; - e.IsAmbient = true; - m_EventBroker->Publish(e); +// dd::Events::PlaySound e; +// e.FilePath = "Sounds/BGM/water-flowing.wav"; +// e.Gain = 0.3f; +// e.IsAmbient = true; +// m_EventBroker->Publish(e); } return true; diff --git a/include/GUI/Button.h b/include/GUI/Button.h index dcfdae6..e25f8c0 100644 --- a/include/GUI/Button.h +++ b/include/GUI/Button.h @@ -75,6 +75,10 @@ protected: Events::ButtonEnter e; e.FrameName = m_Name; EventBroker->Publish(e); + Events::PlaySound soundEvent; + soundEvent.FilePath = "Sounds/GUI/hover.wav"; + EventBroker->Publish(soundEvent); + } else if (!isOver && m_MouseIsOver) { // Leave if (!m_IsDown) { if (!m_TextureReleased.empty()) { diff --git a/include/GUI/Slider.h b/include/GUI/Slider.h index de53245..a4987a6 100644 --- a/include/GUI/Slider.h +++ b/include/GUI/Slider.h @@ -7,6 +7,7 @@ #include "GUI/EButtonRelease.h" #include "GUI/ESliderUpdate.h" #include "Core/EMouseMove.h" +#include "Sound/EPlaySound.h" namespace dd { @@ -79,6 +80,11 @@ private: if (event.Button == m_SliderButton) { m_IsGrabbed = true; } + else { + Events::PlaySound e; + e.FilePath = "Sounds/GUI/click.wav"; + EventBroker->Publish(e); + } return true; } diff --git a/include/GUI/TextureFrame.h b/include/GUI/TextureFrame.h index 5db574c..1bc340d 100644 --- a/include/GUI/TextureFrame.h +++ b/include/GUI/TextureFrame.h @@ -62,6 +62,7 @@ public: if (m_Texture == nullptr) { m_Texture = ResourceManager::Load("Textures/Core/ErrorTexture.png"); } + SizeToTexture(); } diff --git a/src/game/Sound/SoundSystem.cpp b/src/game/Sound/SoundSystem.cpp index 65465e3..1e12456 100644 --- a/src/game/Sound/SoundSystem.cpp +++ b/src/game/Sound/SoundSystem.cpp @@ -6,12 +6,12 @@ dd::Systems::SoundSystem::~SoundSystem() for (auto &bgm : m_BGMSourcesToBuffers) { alSourceStop(bgm.first); alDeleteSources(1, &bgm.first); - bgm.second->~Sound(); + //bgm.second->~Sound(); } for (auto &sfx : m_SFXSourcesToBuffers) { alSourceStop(sfx.first); alDeleteSources(1, &sfx.first); - sfx.second->~Sound(); + //sfx.second->~Sound(); } m_BGMSourcesToBuffers.clear(); m_SFXSourcesToBuffers.clear(); @@ -40,22 +40,20 @@ void dd::Systems::SoundSystem::Initialize() EVENT_SUBSCRIBE_MEMBER(m_EStopSound, &SoundSystem::OnStopSound); EVENT_SUBSCRIBE_MEMBER(m_EMasterVolume, &SoundSystem::OnMasterVolume); - //Todo: Move this - { - dd::Events::PlaySound e; - e.FilePath = "Sounds/BGM/under-the-sea-instrumental.wav"; - e.IsAmbient = true; - EventBroker->Publish(e); - } - { - dd::Events::PlaySound e; - e.FilePath = "Sounds/BGM/water-flowing.wav"; - e.Gain = 0.3f; - e.IsAmbient = true; - EventBroker->Publish(e); - } - - +// //Todo: Move this +// { +// dd::Events::PlaySound e; +// e.FilePath = "Sounds/BGM/under-the-sea-instrumental.wav"; +// e.IsAmbient = true; +// EventBroker->Publish(e); +// } +// { +// dd::Events::PlaySound e; +// e.FilePath = "Sounds/BGM/water-flowing.wav"; +// e.Gain = 0.3f; +// e.IsAmbient = true; +// EventBroker->Publish(e); +// } } void dd::Systems::SoundSystem::Update(double dt) @@ -88,7 +86,7 @@ ALuint dd::Systems::SoundSystem::CreateSource() bool dd::Systems::SoundSystem::OnPlaySound(const dd::Events::PlaySound &event) { //Loading and binding sound buffer to source - Sound *sound = ResourceManager::Load(event.FilePath); + Sound *sound = ResourceManager::Load(event.FilePath); if (sound == nullptr) { return false; } @@ -181,10 +179,10 @@ bool dd::Systems::SoundSystem::OnContact(const dd::Events::Contact &event) //Send play-sound event { - dd::Events::PlaySound e; - e.FilePath = collisionSound->FilePath; - e.IsAmbient = false; - EventBroker->Publish(e); +// dd::Events::PlaySound e; +// e.FilePath = collisionSound->FilePath; +// e.IsAmbient = false; +// EventBroker->Publish(e); } return true;