Made a Sound folder. Rename class Sound to SoundSystem.

Also awesome Cmakeness.
This commit is contained in:
Stiffly
2015-09-17 14:42:33 +02:00
parent 250e70ff50
commit 6671136a08
8 changed files with 37 additions and 32 deletions
-39
View File
@@ -1,39 +0,0 @@
/*
This file is part of Daydream Engine.
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
Daydream Engine is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Daydream Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef Events_PlaySFX_h__
#define Events_PlaySFX_h__
#include "Core/EventBroker.h"
namespace dd
{
namespace Events
{
struct PlaySFX : Event
{
std::string path;
};
}
}
#endif // Events_PlaySFX_h__
+3 -5
View File
@@ -36,7 +36,7 @@
#include "CTemplate.h"
#include "Rendering/CPointLight.h"
#include "Transform/TransformSystem.h"
#include "Core/Sound.h"
#include "Sound/SoundSystem.h"
#include "Game/LevelSystem.h"
#include "Game/PadSystem.h"
#include "Game/CBall.h"
@@ -76,8 +76,8 @@ public:
m_World->ComponentFactory.Register<Components::Model>();
m_World->ComponentFactory.Register<Components::Template>();
m_World->SystemFactory.Register<Systems::Sound>([this]() { return new Systems::Sound(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::Sound>();
m_World->SystemFactory.Register<Systems::SoundSystem>([this]() { return new Systems::SoundSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::SoundSystem>();
m_World->ComponentFactory.Register<Components::Sprite>();
@@ -416,8 +416,6 @@ private:
std::shared_ptr<InputManager> m_InputManager;
std::shared_ptr<World> m_World;
//TODO: Delete this please
std::shared_ptr<dd::Systems::Sound> m_Sound;
double m_LastTime;
};
-87
View File
@@ -1,87 +0,0 @@
/*
This file is part of Daydream Engine.
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
Daydream Engine is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Daydream Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DAYDREAM_SOUND_H
#define DAYDREAM_SOUND_H
#include "AL/al.h"
#include "AL/alc.h"
#include "Core/System.h"
#include "Core/World.h"
#include "Core/EKeyDown.h"
#include "Core/EPlaySFX.h"
#include "Physics/EContact.h"
#include "Core/EventBroker.h"
namespace dd
{
namespace Systems
{
class Sound : public System {
public:
Sound(World *world, std::shared_ptr<dd::EventBroker> eventBroker)
: System(world, eventBroker) { }
~Sound();
void Initialize() override;
//void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
void Update(double dt) override;
//void OnComponentCreated(std::string type, std::shared_ptr<Component> component) override;
//void OnComponentRemoved(std::string type, Component* component) override;
//void PlaySound(Components::SoundEmitter* emitter, std::string path); // Use if you want to play a temporary .wav file not from component
//void PlaySound(std::shared_ptr<Components::SoundEmitter> emitter); // Use if you want to play .wav file from component
//void StopSound(std::shared_ptr<Components::SoundEmitter> emitter);
private:
//Events
dd::EventRelay<Sound, dd::Events::KeyDown> m_EKeyDown;
dd::EventRelay<Sound, dd::Events::PlaySFX> m_EPlaySFX;
dd::EventRelay<Sound, dd::Events::Contact> m_EContact;
bool OnKeyDown(const dd::Events::KeyDown &event);
bool OnPlaySFX(const dd::Events::PlaySFX &event);
bool OnContact(const dd::Events::Contact &event);
ALuint LoadFile(std::string fileName);
ALuint CreateSource();
//File-info
char m_Type[4];
unsigned long m_Size, m_ChunkSize;
short m_FormatType, m_Channels;
unsigned long m_SampleRate, m_AvgBytesPerSec;
short m_BytesPerSample, m_BitsPerSample;
unsigned long m_DataSize;
//std::map<Component*, ALuint> m_Sources;
std::map<std::string, ALuint> m_BufferCache;
//Temp
ALuint m_Source;
};
}
}
#endif //DAYDREAM_SOUND_H
-1
View File
@@ -36,7 +36,6 @@
#include "EventBroker.h"
#include "EComponentCreated.h"
#include "ResourceManager.h"
#include "Sound.h"
namespace dd
{