diff --git a/SDK/src/NDK/LuaBinding.cpp b/SDK/src/NDK/LuaBinding.cpp index ffbbf27c3..ab99eb101 100644 --- a/SDK/src/NDK/LuaBinding.cpp +++ b/SDK/src/NDK/LuaBinding.cpp @@ -36,6 +36,7 @@ namespace Ndk , // Audio + musicClass("Music"), soundBuffer("SoundBuffer"), soundEmitter("SoundEmitter"), soundClass("Sound"), diff --git a/SDK/src/NDK/LuaBinding.hpp b/SDK/src/NDK/LuaBinding.hpp index c1803a201..93363f7fb 100644 --- a/SDK/src/NDK/LuaBinding.hpp +++ b/SDK/src/NDK/LuaBinding.hpp @@ -101,6 +101,7 @@ namespace Ndk #ifndef NDK_SERVER // Audio + Nz::LuaClass musicClass; Nz::LuaClass soundClass; Nz::LuaClass soundBuffer; Nz::LuaClass soundEmitter; diff --git a/SDK/src/NDK/LuaBinding_Audio.cpp b/SDK/src/NDK/LuaBinding_Audio.cpp index b10aa6206..542c6b716 100644 --- a/SDK/src/NDK/LuaBinding_Audio.cpp +++ b/SDK/src/NDK/LuaBinding_Audio.cpp @@ -7,6 +7,77 @@ namespace Ndk { 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 **********************************/ soundBuffer.SetConstructor([] (Nz::LuaInstance& lua) -> Nz::SoundBufferRef* { @@ -14,11 +85,14 @@ namespace Ndk }); soundBuffer.SetMethod("Destroy", &Nz::SoundBuffer::Destroy); + soundBuffer.SetMethod("GetDuration", &Nz::SoundBuffer::GetDuration); soundBuffer.SetMethod("GetFormat", &Nz::SoundBuffer::GetFormat); soundBuffer.SetMethod("GetSampleCount", &Nz::SoundBuffer::GetSampleCount); soundBuffer.SetMethod("GetSampleRate", &Nz::SoundBuffer::GetSampleRate); + soundBuffer.SetMethod("IsValid", &Nz::SoundBuffer::IsValid); + soundBuffer.SetMethod("LoadFromFile", &Nz::SoundBuffer::LoadFromFile, Nz::SoundBufferParams()); soundBuffer.SetStaticMethod("IsFormatSupported", &Nz::SoundBuffer::IsFormatSupported); @@ -65,6 +139,7 @@ namespace Ndk /*********************************** Nz::SoundEmitter **********************************/ soundEmitter.SetMethod("EnableLooping", &Nz::SoundEmitter::EnableLooping); soundEmitter.SetMethod("EnableSpatialization", &Nz::SoundEmitter::EnableSpatialization); + soundEmitter.SetMethod("GetAttenuation", &Nz::SoundEmitter::GetAttenuation); soundEmitter.SetMethod("GetDuration", &Nz::SoundEmitter::GetDuration); soundEmitter.SetMethod("GetMinDistance", &Nz::SoundEmitter::GetMinDistance); @@ -74,48 +149,26 @@ namespace Ndk soundEmitter.SetMethod("GetStatus", &Nz::SoundEmitter::GetStatus); soundEmitter.SetMethod("GetVelocity", &Nz::Sound::GetVelocity); soundEmitter.SetMethod("GetVolume", &Nz::SoundEmitter::GetVolume); + soundEmitter.SetMethod("IsLooping", &Nz::SoundEmitter::IsLooping); soundEmitter.SetMethod("IsSpatialized", &Nz::SoundEmitter::IsSpatialized); + soundEmitter.SetMethod("Pause", &Nz::SoundEmitter::Pause); soundEmitter.SetMethod("Play", &Nz::SoundEmitter::Play); + soundEmitter.SetMethod("SetAttenuation", &Nz::SoundEmitter::SetAttenuation); soundEmitter.SetMethod("SetMinDistance", &Nz::SoundEmitter::SetMinDistance); soundEmitter.SetMethod("SetPitch", &Nz::SoundEmitter::SetPitch); 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("SetVolume", &Nz::SoundEmitter::SetVolume); + 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) { + musicClass.Register(instance); soundClass.Register(instance); soundBuffer.Register(instance); soundEmitter.Register(instance);