Sdk/LuaAPI: Bind class music
Former-commit-id: 713c12b5a6e64debff2a6822d1aacece0d9e76cb
This commit is contained in:
parent
de8f8e0743
commit
f8a716aa84
|
|
@ -36,6 +36,7 @@ namespace Ndk
|
||||||
,
|
,
|
||||||
|
|
||||||
// Audio
|
// Audio
|
||||||
|
musicClass("Music"),
|
||||||
soundBuffer("SoundBuffer"),
|
soundBuffer("SoundBuffer"),
|
||||||
soundEmitter("SoundEmitter"),
|
soundEmitter("SoundEmitter"),
|
||||||
soundClass("Sound"),
|
soundClass("Sound"),
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,7 @@ namespace Ndk
|
||||||
|
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
// Audio
|
// Audio
|
||||||
|
Nz::LuaClass<Nz::Music> musicClass;
|
||||||
Nz::LuaClass<Nz::Sound> soundClass;
|
Nz::LuaClass<Nz::Sound> soundClass;
|
||||||
Nz::LuaClass<Nz::SoundBufferRef> soundBuffer;
|
Nz::LuaClass<Nz::SoundBufferRef> soundBuffer;
|
||||||
Nz::LuaClass<Nz::SoundEmitter> soundEmitter;
|
Nz::LuaClass<Nz::SoundEmitter> soundEmitter;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,77 @@ namespace Ndk
|
||||||
{
|
{
|
||||||
void LuaBinding::BindAudio()
|
void LuaBinding::BindAudio()
|
||||||
{
|
{
|
||||||
|
/*********************************** Nz::Music **********************************/
|
||||||
|
musicClass.Inherit(soundEmitter);
|
||||||
|
|
||||||
|
musicClass.SetConstructor([] (Nz::LuaInstance& lua) -> Nz::Music*
|
||||||
|
{
|
||||||
|
return new Nz::Music;
|
||||||
|
});
|
||||||
|
|
||||||
|
//musicClass.SetMethod("Create", &Nz::Music::Create);
|
||||||
|
//musicClass.SetMethod("Destroy", &Nz::Music::Destroy);
|
||||||
|
|
||||||
|
musicClass.SetMethod("EnableLooping", &Nz::Music::EnableLooping);
|
||||||
|
|
||||||
|
musicClass.SetMethod("GetDuration", &Nz::Music::GetDuration);
|
||||||
|
musicClass.SetMethod("GetFormat", &Nz::Music::GetFormat);
|
||||||
|
musicClass.SetMethod("GetPlayingOffset", &Nz::Music::GetPlayingOffset);
|
||||||
|
musicClass.SetMethod("GetSampleCount", &Nz::Music::GetSampleCount);
|
||||||
|
musicClass.SetMethod("GetSampleRate", &Nz::Music::GetSampleRate);
|
||||||
|
musicClass.SetMethod("GetStatus", &Nz::Music::GetStatus);
|
||||||
|
|
||||||
|
musicClass.SetMethod("IsLooping", &Nz::Music::IsLooping);
|
||||||
|
|
||||||
|
musicClass.SetMethod("OpenFromFile", &Nz::Music::OpenFromFile, Nz::MusicParams());
|
||||||
|
|
||||||
|
musicClass.SetMethod("Pause", &Nz::Music::Pause);
|
||||||
|
musicClass.SetMethod("Play", &Nz::Music::Play);
|
||||||
|
|
||||||
|
musicClass.SetMethod("SetPlayingOffset", &Nz::Music::SetPlayingOffset);
|
||||||
|
|
||||||
|
musicClass.SetMethod("Stop", &Nz::Music::Stop);
|
||||||
|
|
||||||
|
// Manual
|
||||||
|
musicClass.SetMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Music& music) -> int
|
||||||
|
{
|
||||||
|
Nz::StringStream stream("Music(");
|
||||||
|
stream << music.GetFilePath() << ')';
|
||||||
|
|
||||||
|
lua.PushString(stream);
|
||||||
|
return 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
/*********************************** Nz::Sound **********************************/
|
||||||
|
soundClass.Inherit(soundEmitter);
|
||||||
|
|
||||||
|
soundClass.SetConstructor([] (Nz::LuaInstance& lua) -> Nz::Sound*
|
||||||
|
{
|
||||||
|
return new Nz::Sound;
|
||||||
|
});
|
||||||
|
|
||||||
|
soundClass.SetMethod("GetBuffer", &Nz::Sound::GetBuffer);
|
||||||
|
|
||||||
|
soundClass.SetMethod("IsPlayable", &Nz::Sound::IsPlayable);
|
||||||
|
soundClass.SetMethod("IsPlaying", &Nz::Sound::IsPlaying);
|
||||||
|
|
||||||
|
soundClass.SetMethod("LoadFromFile", &Nz::Sound::LoadFromFile, Nz::SoundBufferParams());
|
||||||
|
|
||||||
|
soundClass.SetMethod("SetPlayingOffset", &Nz::Sound::SetPlayingOffset);
|
||||||
|
|
||||||
|
// Manual
|
||||||
|
soundClass.SetMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Sound& sound) -> int
|
||||||
|
{
|
||||||
|
Nz::StringStream stream("Sound(");
|
||||||
|
if (const Nz::SoundBuffer* buffer = sound.GetBuffer())
|
||||||
|
stream << buffer;
|
||||||
|
|
||||||
|
stream << ')';
|
||||||
|
|
||||||
|
lua.PushString(stream);
|
||||||
|
return 1;
|
||||||
|
});
|
||||||
|
|
||||||
/*********************************** Nz::SoundBuffer **********************************/
|
/*********************************** Nz::SoundBuffer **********************************/
|
||||||
soundBuffer.SetConstructor([] (Nz::LuaInstance& lua) -> Nz::SoundBufferRef*
|
soundBuffer.SetConstructor([] (Nz::LuaInstance& lua) -> Nz::SoundBufferRef*
|
||||||
{
|
{
|
||||||
|
|
@ -14,11 +85,14 @@ namespace Ndk
|
||||||
});
|
});
|
||||||
|
|
||||||
soundBuffer.SetMethod("Destroy", &Nz::SoundBuffer::Destroy);
|
soundBuffer.SetMethod("Destroy", &Nz::SoundBuffer::Destroy);
|
||||||
|
|
||||||
soundBuffer.SetMethod("GetDuration", &Nz::SoundBuffer::GetDuration);
|
soundBuffer.SetMethod("GetDuration", &Nz::SoundBuffer::GetDuration);
|
||||||
soundBuffer.SetMethod("GetFormat", &Nz::SoundBuffer::GetFormat);
|
soundBuffer.SetMethod("GetFormat", &Nz::SoundBuffer::GetFormat);
|
||||||
soundBuffer.SetMethod("GetSampleCount", &Nz::SoundBuffer::GetSampleCount);
|
soundBuffer.SetMethod("GetSampleCount", &Nz::SoundBuffer::GetSampleCount);
|
||||||
soundBuffer.SetMethod("GetSampleRate", &Nz::SoundBuffer::GetSampleRate);
|
soundBuffer.SetMethod("GetSampleRate", &Nz::SoundBuffer::GetSampleRate);
|
||||||
|
|
||||||
soundBuffer.SetMethod("IsValid", &Nz::SoundBuffer::IsValid);
|
soundBuffer.SetMethod("IsValid", &Nz::SoundBuffer::IsValid);
|
||||||
|
|
||||||
soundBuffer.SetMethod("LoadFromFile", &Nz::SoundBuffer::LoadFromFile, Nz::SoundBufferParams());
|
soundBuffer.SetMethod("LoadFromFile", &Nz::SoundBuffer::LoadFromFile, Nz::SoundBufferParams());
|
||||||
|
|
||||||
soundBuffer.SetStaticMethod("IsFormatSupported", &Nz::SoundBuffer::IsFormatSupported);
|
soundBuffer.SetStaticMethod("IsFormatSupported", &Nz::SoundBuffer::IsFormatSupported);
|
||||||
|
|
@ -65,6 +139,7 @@ namespace Ndk
|
||||||
/*********************************** Nz::SoundEmitter **********************************/
|
/*********************************** Nz::SoundEmitter **********************************/
|
||||||
soundEmitter.SetMethod("EnableLooping", &Nz::SoundEmitter::EnableLooping);
|
soundEmitter.SetMethod("EnableLooping", &Nz::SoundEmitter::EnableLooping);
|
||||||
soundEmitter.SetMethod("EnableSpatialization", &Nz::SoundEmitter::EnableSpatialization);
|
soundEmitter.SetMethod("EnableSpatialization", &Nz::SoundEmitter::EnableSpatialization);
|
||||||
|
|
||||||
soundEmitter.SetMethod("GetAttenuation", &Nz::SoundEmitter::GetAttenuation);
|
soundEmitter.SetMethod("GetAttenuation", &Nz::SoundEmitter::GetAttenuation);
|
||||||
soundEmitter.SetMethod("GetDuration", &Nz::SoundEmitter::GetDuration);
|
soundEmitter.SetMethod("GetDuration", &Nz::SoundEmitter::GetDuration);
|
||||||
soundEmitter.SetMethod("GetMinDistance", &Nz::SoundEmitter::GetMinDistance);
|
soundEmitter.SetMethod("GetMinDistance", &Nz::SoundEmitter::GetMinDistance);
|
||||||
|
|
@ -74,48 +149,26 @@ namespace Ndk
|
||||||
soundEmitter.SetMethod("GetStatus", &Nz::SoundEmitter::GetStatus);
|
soundEmitter.SetMethod("GetStatus", &Nz::SoundEmitter::GetStatus);
|
||||||
soundEmitter.SetMethod("GetVelocity", &Nz::Sound::GetVelocity);
|
soundEmitter.SetMethod("GetVelocity", &Nz::Sound::GetVelocity);
|
||||||
soundEmitter.SetMethod("GetVolume", &Nz::SoundEmitter::GetVolume);
|
soundEmitter.SetMethod("GetVolume", &Nz::SoundEmitter::GetVolume);
|
||||||
|
|
||||||
soundEmitter.SetMethod("IsLooping", &Nz::SoundEmitter::IsLooping);
|
soundEmitter.SetMethod("IsLooping", &Nz::SoundEmitter::IsLooping);
|
||||||
soundEmitter.SetMethod("IsSpatialized", &Nz::SoundEmitter::IsSpatialized);
|
soundEmitter.SetMethod("IsSpatialized", &Nz::SoundEmitter::IsSpatialized);
|
||||||
|
|
||||||
soundEmitter.SetMethod("Pause", &Nz::SoundEmitter::Pause);
|
soundEmitter.SetMethod("Pause", &Nz::SoundEmitter::Pause);
|
||||||
soundEmitter.SetMethod("Play", &Nz::SoundEmitter::Play);
|
soundEmitter.SetMethod("Play", &Nz::SoundEmitter::Play);
|
||||||
|
|
||||||
soundEmitter.SetMethod("SetAttenuation", &Nz::SoundEmitter::SetAttenuation);
|
soundEmitter.SetMethod("SetAttenuation", &Nz::SoundEmitter::SetAttenuation);
|
||||||
soundEmitter.SetMethod("SetMinDistance", &Nz::SoundEmitter::SetMinDistance);
|
soundEmitter.SetMethod("SetMinDistance", &Nz::SoundEmitter::SetMinDistance);
|
||||||
soundEmitter.SetMethod("SetPitch", &Nz::SoundEmitter::SetPitch);
|
soundEmitter.SetMethod("SetPitch", &Nz::SoundEmitter::SetPitch);
|
||||||
soundEmitter.SetMethod("SetPosition", (void(Nz::SoundEmitter::*)(const Nz::Vector3f&)) &Nz::SoundEmitter::SetPosition);
|
soundEmitter.SetMethod("SetPosition", (void(Nz::SoundEmitter::*)(const Nz::Vector3f&)) &Nz::SoundEmitter::SetPosition);
|
||||||
soundEmitter.SetMethod("SetVelocity", (void(Nz::SoundEmitter::*)(const Nz::Vector3f&)) &Nz::SoundEmitter::SetVelocity);
|
soundEmitter.SetMethod("SetVelocity", (void(Nz::SoundEmitter::*)(const Nz::Vector3f&)) &Nz::SoundEmitter::SetVelocity);
|
||||||
soundEmitter.SetMethod("SetVolume", &Nz::SoundEmitter::SetVolume);
|
soundEmitter.SetMethod("SetVolume", &Nz::SoundEmitter::SetVolume);
|
||||||
|
|
||||||
soundEmitter.SetMethod("Stop", &Nz::SoundEmitter::Stop);
|
soundEmitter.SetMethod("Stop", &Nz::SoundEmitter::Stop);
|
||||||
|
|
||||||
/*********************************** Nz::Sound **********************************/
|
|
||||||
soundClass.Inherit(soundEmitter);
|
|
||||||
|
|
||||||
soundClass.SetConstructor([] (Nz::LuaInstance& lua) -> Nz::Sound*
|
|
||||||
{
|
|
||||||
return new Nz::Sound;
|
|
||||||
});
|
|
||||||
|
|
||||||
soundClass.SetMethod("GetBuffer", &Nz::Sound::GetBuffer);
|
|
||||||
soundClass.SetMethod("IsPlayable", &Nz::Sound::IsPlayable);
|
|
||||||
soundClass.SetMethod("IsPlaying", &Nz::Sound::IsPlaying);
|
|
||||||
soundClass.SetMethod("LoadFromFile", &Nz::Sound::LoadFromFile, Nz::SoundBufferParams());
|
|
||||||
soundClass.SetMethod("SetPlayingOffset", &Nz::Sound::SetPlayingOffset);
|
|
||||||
|
|
||||||
// Manual
|
|
||||||
soundClass.SetMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Sound& sound) -> int
|
|
||||||
{
|
|
||||||
Nz::StringStream stream("Sound(");
|
|
||||||
if (const Nz::SoundBuffer* buffer = sound.GetBuffer())
|
|
||||||
stream << buffer;
|
|
||||||
|
|
||||||
stream << ')';
|
|
||||||
|
|
||||||
lua.PushString(stream);
|
|
||||||
return 1;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LuaBinding::RegisterAudio(Nz::LuaInstance& instance)
|
void LuaBinding::RegisterAudio(Nz::LuaInstance& instance)
|
||||||
{
|
{
|
||||||
|
musicClass.Register(instance);
|
||||||
soundClass.Register(instance);
|
soundClass.Register(instance);
|
||||||
soundBuffer.Register(instance);
|
soundBuffer.Register(instance);
|
||||||
soundEmitter.Register(instance);
|
soundEmitter.Register(instance);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue