Merge remote-tracking branch 'origin/master' into LevelSystemAndSuch
This commit is contained in:
@@ -552,15 +552,15 @@ private:
|
||||
//Todo: Move this
|
||||
{
|
||||
dd::Events::PlaySound e;
|
||||
e.path = "Sounds/BGM/under-the-sea-instrumental.wav";
|
||||
e.isAmbient = true;
|
||||
e.FilePath = "Sounds/BGM/under-the-sea-instrumental.wav";
|
||||
e.IsAmbient = true;
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
{
|
||||
dd::Events::PlaySound e;
|
||||
e.path = "Sounds/BGM/water-flowing.wav";
|
||||
e.volume = 0.3f;
|
||||
e.isAmbient = true;
|
||||
e.FilePath = "Sounds/BGM/water-flowing.wav";
|
||||
e.Gain = 0.3f;
|
||||
e.IsAmbient = true;
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -61,15 +61,15 @@ private:
|
||||
{
|
||||
if (event.Slider == m_SFXSlider) {
|
||||
Events::MasterVolume e;
|
||||
e.isAmbient = false;
|
||||
e.gain = event.Percentage;
|
||||
e.IsAmbient = false;
|
||||
e.Gain = event.Percentage;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
if (event.Slider == m_BGMSlider) {
|
||||
Events::MasterVolume e;
|
||||
e.isAmbient = true;
|
||||
e.gain = event.Percentage;
|
||||
e.IsAmbient = true;
|
||||
e.Gain = event.Percentage;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
//
|
||||
// Created by Adam on 2015-09-17.
|
||||
//
|
||||
|
||||
#ifndef COMPONENTS_CCOLLISIONSOUND_H__
|
||||
#define COMPONENTS_CCOLLISIONSOUND_H__
|
||||
|
||||
@@ -9,17 +5,15 @@
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct CollisionSound : public Component
|
||||
{
|
||||
std::string filePath;
|
||||
std::string FilePath;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
//
|
||||
// Created by Adam on 2015-09-24.
|
||||
//
|
||||
|
||||
#ifndef EVENTS_EMASTERVOLUME_H__
|
||||
#define EVENTS_EMASTERVOLUME_H__
|
||||
|
||||
@@ -9,19 +5,17 @@
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct MasterVolume : public Event
|
||||
{
|
||||
float gain = 1;
|
||||
float Gain = 1;
|
||||
//To determine what channel group to apply the change to.
|
||||
bool isAmbient = false;
|
||||
bool IsAmbient = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
#ifndef Events_PlaySFX_h__
|
||||
#define Events_PlaySFX_h__
|
||||
#ifndef EVENTS_PLAYSFX_H__
|
||||
#define EVENTS_PLAYSFX_H__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct PlaySound : Event
|
||||
{
|
||||
std::string path;
|
||||
float volume = 1.f;
|
||||
float pitch = 1.f;
|
||||
bool isAmbient = false;
|
||||
std::string FilePath;
|
||||
float Gain = 1.f;
|
||||
float Pitch = 1.f;
|
||||
bool IsAmbient = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -8,16 +8,12 @@ namespace dd
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct StopSound : public Event
|
||||
{
|
||||
std::string path;
|
||||
std::string FilePath;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,12 +12,20 @@ namespace dd
|
||||
class Sound : public Resource
|
||||
{
|
||||
friend class ResourceManager;
|
||||
|
||||
public:
|
||||
ALuint Buffer() { return m_Buffer; };
|
||||
std::string Path() { return m_Path; };
|
||||
float Gain() { return m_Gain; };
|
||||
void SetGain(const float Gain) { m_Gain = Gain; };
|
||||
|
||||
private:
|
||||
Sound(std::string path);
|
||||
|
||||
float m_Gain = 1;
|
||||
ALuint m_Buffer;
|
||||
std::string m_Path;
|
||||
|
||||
//File-info
|
||||
char m_Type[4];
|
||||
unsigned long m_Size, m_ChunkSize;
|
||||
@@ -27,12 +35,8 @@ private:
|
||||
unsigned long m_DataSize;
|
||||
std::map<std::string, ALuint> m_BufferCache;
|
||||
ALuint LoadFile(std::string path);
|
||||
|
||||
ALuint m_Buffer;
|
||||
std::string m_Path;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+20
-21
@@ -1,61 +1,60 @@
|
||||
#ifndef DAYDREAM_SOUND_H
|
||||
#define DAYDREAM_SOUND_H
|
||||
|
||||
#ifndef SYSTEMS_SOUNDSYSTEM_H__
|
||||
#define SYSTEMS_SOUNDSYSTEM_H__
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "Core/World.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Sound.h"
|
||||
#include "Sound/EPlaySound.h"
|
||||
#include "Sound/EStopSound.h"
|
||||
#include "Sound/EMasterVolume.h"
|
||||
#include "Sound/CCollisionSound.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/CPad.h"
|
||||
#include "Sound/CCollisionSound.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
|
||||
|
||||
namespace dd
|
||||
{
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
class SoundSystem : public System {
|
||||
public:
|
||||
SoundSystem(World *world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||
: System(world, eventBroker) { }
|
||||
|
||||
~SoundSystem();
|
||||
|
||||
void Initialize() override;
|
||||
void Update(double dt) override;
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
float m_BGMMasterVolume = 1.f;
|
||||
float m_SFXMasterVolume = 1.f;
|
||||
std::map<ALuint, Sound*> m_BGMSourcesToBuffers;
|
||||
std::map<ALuint, Sound*> m_SFXSourcesToBuffers;
|
||||
ALCdevice* m_Device = nullptr;
|
||||
|
||||
//Events
|
||||
dd::EventRelay<SoundSystem, dd::Events::PlaySound> m_EPlaySFX;
|
||||
dd::EventRelay<SoundSystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<SoundSystem, dd::Events::StopSound> m_EStopSound;
|
||||
dd::EventRelay<SoundSystem, dd::Events::MasterVolume> m_EMasterVolume;
|
||||
bool OnPlaySound(const dd::Events::PlaySound &event);
|
||||
//On contact: play the sound given in the CCOllisionSound.
|
||||
dd::EventRelay<SoundSystem, dd::Events::Contact> m_EContact;
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
dd::EventRelay<SoundSystem, dd::Events::StopSound> m_EStopSound;
|
||||
bool OnStopSound(const dd::Events::StopSound &event);
|
||||
dd::EventRelay<SoundSystem, dd::Events::MasterVolume> m_EMasterVolume;
|
||||
bool OnMasterVolume(const dd::Events::MasterVolume &event);
|
||||
|
||||
ALuint CreateSource();
|
||||
|
||||
std::map<ALuint, Sound*> m_BGMSourcesToBuffers;
|
||||
std::map<ALuint, Sound*> m_SFXSourcesToBuffers;
|
||||
|
||||
ALCdevice* m_Device;
|
||||
|
||||
float m_BGMMasterVolume, m_SFXMasterVolume;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_SOUND_H
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user