Merge branch 'master' into LevelSystemAndSuch
This commit is contained in:
Binary file not shown.
Binary file not shown.
+11
-9
@@ -229,6 +229,8 @@ public:
|
|||||||
//ResourceManager::Update();
|
//ResourceManager::Update();
|
||||||
if (m_GameIsRunning) {
|
if (m_GameIsRunning) {
|
||||||
m_World->Update(dt);
|
m_World->Update(dt);
|
||||||
|
} else {
|
||||||
|
m_EventBroker->Process<Systems::SoundSystem>();
|
||||||
}
|
}
|
||||||
m_EventBroker->Process<GUI::Frame>();
|
m_EventBroker->Process<GUI::Frame>();
|
||||||
m_FrameStack->UpdateLayered(dt);
|
m_FrameStack->UpdateLayered(dt);
|
||||||
@@ -428,17 +430,17 @@ private:
|
|||||||
m_GameIsRunning = true;
|
m_GameIsRunning = true;
|
||||||
//Todo: Move this
|
//Todo: Move this
|
||||||
{
|
{
|
||||||
dd::Events::PlaySound e;
|
// dd::Events::PlaySound e;
|
||||||
e.FilePath = "Sounds/BGM/under-the-sea-instrumental.wav";
|
// e.FilePath = "Sounds/BGM/under-the-sea-instrumental.wav";
|
||||||
e.IsAmbient = true;
|
// e.IsAmbient = true;
|
||||||
m_EventBroker->Publish(e);
|
// m_EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
dd::Events::PlaySound e;
|
// dd::Events::PlaySound e;
|
||||||
e.FilePath = "Sounds/BGM/water-flowing.wav";
|
// e.FilePath = "Sounds/BGM/water-flowing.wav";
|
||||||
e.Gain = 0.3f;
|
// e.Gain = 0.3f;
|
||||||
e.IsAmbient = true;
|
// e.IsAmbient = true;
|
||||||
m_EventBroker->Publish(e);
|
// m_EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -75,6 +75,10 @@ protected:
|
|||||||
Events::ButtonEnter e;
|
Events::ButtonEnter e;
|
||||||
e.FrameName = m_Name;
|
e.FrameName = m_Name;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
|
Events::PlaySound soundEvent;
|
||||||
|
soundEvent.FilePath = "Sounds/GUI/hover.wav";
|
||||||
|
EventBroker->Publish(soundEvent);
|
||||||
|
|
||||||
} else if (!isOver && m_MouseIsOver) { // Leave
|
} else if (!isOver && m_MouseIsOver) { // Leave
|
||||||
if (!m_IsDown) {
|
if (!m_IsDown) {
|
||||||
if (!m_TextureReleased.empty()) {
|
if (!m_TextureReleased.empty()) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "GUI/EButtonRelease.h"
|
#include "GUI/EButtonRelease.h"
|
||||||
#include "GUI/ESliderUpdate.h"
|
#include "GUI/ESliderUpdate.h"
|
||||||
#include "Core/EMouseMove.h"
|
#include "Core/EMouseMove.h"
|
||||||
|
#include "Sound/EPlaySound.h"
|
||||||
|
|
||||||
namespace dd
|
namespace dd
|
||||||
{
|
{
|
||||||
@@ -79,6 +80,11 @@ private:
|
|||||||
if (event.Button == m_SliderButton) {
|
if (event.Button == m_SliderButton) {
|
||||||
m_IsGrabbed = true;
|
m_IsGrabbed = true;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Events::PlaySound e;
|
||||||
|
e.FilePath = "Sounds/GUI/click.wav";
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ public:
|
|||||||
if (m_Texture == nullptr) {
|
if (m_Texture == nullptr) {
|
||||||
m_Texture = ResourceManager::Load<dd::Texture>("Textures/Core/ErrorTexture.png");
|
m_Texture = ResourceManager::Load<dd::Texture>("Textures/Core/ErrorTexture.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
SizeToTexture();
|
SizeToTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
//
|
|
||||||
// Created by Adam on 2015-09-25.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef EVENTS_EGAMESTART_H__
|
#ifndef EVENTS_EGAMESTART_H__
|
||||||
#define EVENTS_EGAMESTART_H__
|
#define EVENTS_EGAMESTART_H__
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ class Sound : public Resource
|
|||||||
friend class ResourceManager;
|
friend class ResourceManager;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
~Sound();
|
||||||
ALuint Buffer() { return m_Buffer; };
|
ALuint Buffer() { return m_Buffer; };
|
||||||
std::string Path() { return m_Path; };
|
std::string Path() { return m_Path; };
|
||||||
float Gain() { return m_Gain; };
|
float Gain() { return m_Gain; };
|
||||||
|
|||||||
@@ -10,15 +10,17 @@
|
|||||||
#include "Core/ResourceManager.h"
|
#include "Core/ResourceManager.h"
|
||||||
#include "Core/ConfigFile.h"
|
#include "Core/ConfigFile.h"
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
#include "Sound/EPlaySound.h"
|
|
||||||
#include "Sound/EStopSound.h"
|
|
||||||
#include "Sound/EMasterVolume.h"
|
|
||||||
#include "Sound/CCollisionSound.h"
|
#include "Sound/CCollisionSound.h"
|
||||||
#include "Physics/EContact.h"
|
|
||||||
#include "Game/CBall.h"
|
#include "Game/CBall.h"
|
||||||
#include "Game/CBrick.h"
|
#include "Game/CBrick.h"
|
||||||
#include "Game/CPad.h"
|
#include "Game/CPad.h"
|
||||||
|
#include "Sound/EPlaySound.h"
|
||||||
|
#include "Sound/EStopSound.h"
|
||||||
|
#include "Sound/EMasterVolume.h"
|
||||||
#include "Physics/ECreateParticleSequence.h"
|
#include "Physics/ECreateParticleSequence.h"
|
||||||
|
#include "Physics/EContact.h"
|
||||||
|
#include "Game/EGameStart.h"
|
||||||
|
|
||||||
|
|
||||||
namespace dd
|
namespace dd
|
||||||
{
|
{
|
||||||
@@ -41,6 +43,7 @@ private:
|
|||||||
std::map<ALuint, Sound*> m_BGMSourcesToBuffers;
|
std::map<ALuint, Sound*> m_BGMSourcesToBuffers;
|
||||||
std::map<ALuint, Sound*> m_SFXSourcesToBuffers;
|
std::map<ALuint, Sound*> m_SFXSourcesToBuffers;
|
||||||
ALCdevice* m_Device = nullptr;
|
ALCdevice* m_Device = nullptr;
|
||||||
|
ALCcontext* m_Context = nullptr;
|
||||||
|
|
||||||
//Events
|
//Events
|
||||||
dd::EventRelay<SoundSystem, dd::Events::PlaySound> m_EPlaySFX;
|
dd::EventRelay<SoundSystem, dd::Events::PlaySound> m_EPlaySFX;
|
||||||
@@ -52,6 +55,9 @@ private:
|
|||||||
bool OnStopSound(const dd::Events::StopSound &event);
|
bool OnStopSound(const dd::Events::StopSound &event);
|
||||||
dd::EventRelay<SoundSystem, dd::Events::MasterVolume> m_EMasterVolume;
|
dd::EventRelay<SoundSystem, dd::Events::MasterVolume> m_EMasterVolume;
|
||||||
bool OnMasterVolume(const dd::Events::MasterVolume &event);
|
bool OnMasterVolume(const dd::Events::MasterVolume &event);
|
||||||
|
dd::EventRelay<SoundSystem, dd::Events::GameStart> m_EGameStart;
|
||||||
|
bool OnGameStart(const dd::Events::GameStart &event);
|
||||||
|
|
||||||
|
|
||||||
ALuint CreateSource();
|
ALuint CreateSource();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,6 +6,11 @@ dd::Sound::Sound(std::string path)
|
|||||||
m_Path = path;
|
m_Path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dd::Sound::~Sound()
|
||||||
|
{
|
||||||
|
alDeleteBuffers(1, &m_Buffer);
|
||||||
|
}
|
||||||
|
|
||||||
ALuint dd::Sound::LoadFile(std::string path)
|
ALuint dd::Sound::LoadFile(std::string path)
|
||||||
{
|
{
|
||||||
if (m_BufferCache.find(path) != m_BufferCache.end()) {
|
if (m_BufferCache.find(path) != m_BufferCache.end()) {
|
||||||
|
|||||||
@@ -3,6 +3,19 @@
|
|||||||
|
|
||||||
dd::Systems::SoundSystem::~SoundSystem()
|
dd::Systems::SoundSystem::~SoundSystem()
|
||||||
{
|
{
|
||||||
|
for (auto &bgm : m_BGMSourcesToBuffers) {
|
||||||
|
alSourceStop(bgm.first);
|
||||||
|
alDeleteSources(1, &bgm.first);
|
||||||
|
//bgm.second->~Sound();
|
||||||
|
}
|
||||||
|
for (auto &sfx : m_SFXSourcesToBuffers) {
|
||||||
|
alSourceStop(sfx.first);
|
||||||
|
alDeleteSources(1, &sfx.first);
|
||||||
|
//sfx.second->~Sound();
|
||||||
|
}
|
||||||
|
m_BGMSourcesToBuffers.clear();
|
||||||
|
m_SFXSourcesToBuffers.clear();
|
||||||
|
alcDestroyContext(m_Context);
|
||||||
alcCloseDevice(m_Device);
|
alcCloseDevice(m_Device);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -10,42 +23,26 @@ void dd::Systems::SoundSystem::Initialize()
|
|||||||
{
|
{
|
||||||
//initialize OpenAL
|
//initialize OpenAL
|
||||||
m_Device = alcOpenDevice(NULL);
|
m_Device = alcOpenDevice(NULL);
|
||||||
ALCcontext* context;
|
|
||||||
|
|
||||||
if (m_Device) {
|
if (m_Device) {
|
||||||
context = alcCreateContext(m_Device, NULL);
|
m_Context = alcCreateContext(m_Device, NULL);
|
||||||
alcMakeContextCurrent(context);
|
alcMakeContextCurrent(m_Context);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOG_ERROR("OpenAL failed to initialize.");
|
LOG_ERROR("OpenAL failed to initialize.");
|
||||||
}
|
}
|
||||||
alGetError();
|
//alGetError();
|
||||||
|
|
||||||
//Subscribe to events
|
//Subscribe to events
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EContact, &SoundSystem::OnContact);
|
EVENT_SUBSCRIBE_MEMBER(m_EContact, &SoundSystem::OnContact);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlaySFX, &SoundSystem::OnPlaySound);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlaySFX, &SoundSystem::OnPlaySound);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EStopSound, &SoundSystem::OnStopSound);
|
EVENT_SUBSCRIBE_MEMBER(m_EStopSound, &SoundSystem::OnStopSound);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EMasterVolume, &SoundSystem::OnMasterVolume);
|
EVENT_SUBSCRIBE_MEMBER(m_EMasterVolume, &SoundSystem::OnMasterVolume);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EGameStart, &SoundSystem::OnGameStart);
|
||||||
|
|
||||||
m_SFXMasterVolume = ResourceManager::Load<ConfigFile>("Config.ini")->GetValue<float>("Audio.SFXVolume", 1.f);
|
m_SFXMasterVolume = ResourceManager::Load<ConfigFile>("Config.ini")->GetValue<float>("Audio.SFXVolume", 1.f);
|
||||||
m_BGMMasterVolume = ResourceManager::Load<ConfigFile>("Config.ini")->GetValue<float>("Audio.BGMVolume", 1.f);
|
m_BGMMasterVolume = ResourceManager::Load<ConfigFile>("Config.ini")->GetValue<float>("Audio.BGMVolume", 1.f);
|
||||||
|
|
||||||
//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)
|
void dd::Systems::SoundSystem::Update(double dt)
|
||||||
@@ -63,7 +60,6 @@ void dd::Systems::SoundSystem::Update(double dt)
|
|||||||
|
|
||||||
for (int i = 0; i < deleteList.size(); i++) {
|
for (int i = 0; i < deleteList.size(); i++) {
|
||||||
alDeleteSources(1, &deleteList[i]);
|
alDeleteSources(1, &deleteList[i]);
|
||||||
//alDeleteBuffers(1, &m_SourcesToBuffers[deleteList[i]]);
|
|
||||||
m_SFXSourcesToBuffers.erase(deleteList[i]);
|
m_SFXSourcesToBuffers.erase(deleteList[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,11 +171,30 @@ bool dd::Systems::SoundSystem::OnContact(const dd::Events::Contact &event)
|
|||||||
dd::Events::PlaySound e;
|
dd::Events::PlaySound e;
|
||||||
e.FilePath = collisionSound->FilePath;
|
e.FilePath = collisionSound->FilePath;
|
||||||
e.IsAmbient = false;
|
e.IsAmbient = false;
|
||||||
|
e.Gain = 0.8f;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::SoundSystem::OnGameStart(const dd::Events::GameStart &event)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user