added a PlaySound Event.

This commit is contained in:
Stiffly
2015-09-15 18:16:32 +02:00
parent aec694359c
commit 450a73f498
3 changed files with 94 additions and 10 deletions
+23 -5
View File
@@ -1,17 +1,31 @@
//
// Created by Adam on 2015-09-09.
//
/*
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 <fstream>
#include "AL/al.h"
#include "AL/alc.h"
#include "Core/System.h"
#include "Core/World.h"
#include "Core/EKeyDown.h"
#include "Core/EPlaySound.h"
#include "Core/EventBroker.h"
namespace dd
@@ -30,16 +44,20 @@ public:
//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 // imon no hate plx T.T
//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;
bool OnKeyDown(const dd::Events::KeyDown &event);
//dd::EventRelay<Sound, dd::Events::PlaySound> m_EPlaySound;
//bool PlayASound(const dd::Events::PlaySound &event);
ALuint LoadFile(std::string fileName);
ALuint CreateSource();
+40
View File
@@ -0,0 +1,40 @@
/*
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_EPLAYSOUND_H
#define DAYDREAM_EPLAYSOUND_H
#include "Core/EventBroker.h"
namespace dd
{
namespace Events
{
struct PlaySound : Event
{
float volume;
std::string path;
};
}
}
#endif //DAYDREAM_EPLAYSOUND_H