Merge branch 'master' into reflection-mapping
This commit is contained in:
@@ -25,6 +25,7 @@ namespace Ndk
|
||||
audio = LuaBinding_Base::BindAudio(*this);
|
||||
renderer = LuaBinding_Base::BindRenderer(*this);
|
||||
graphics = LuaBinding_Base::BindGraphics(*this);
|
||||
platform = LuaBinding_Base::BindPlatform(*this);
|
||||
#endif
|
||||
|
||||
sdk = LuaBinding_Base::BindSDK(*this);
|
||||
@@ -48,6 +49,7 @@ namespace Ndk
|
||||
audio->Register(state);
|
||||
graphics->Register(state);
|
||||
renderer->Register(state);
|
||||
platform->Register(state);
|
||||
#endif
|
||||
|
||||
// ComponentType (fake enumeration to expose component indexes)
|
||||
|
||||
@@ -32,28 +32,28 @@ namespace Ndk
|
||||
stream.BindMethod("IsWritable", &Nz::Stream::IsWritable);
|
||||
stream.BindMethod("SetCursorPos", &Nz::Stream::SetCursorPos);
|
||||
|
||||
stream.BindMethod("Read", [] (Nz::LuaState& lua, Nz::Stream& stream, std::size_t /*argumentCount*/) -> int {
|
||||
stream.BindMethod("Read", [] (Nz::LuaState& lua, Nz::Stream& instance, std::size_t /*argumentCount*/) -> int {
|
||||
int argIndex = 2;
|
||||
|
||||
std::size_t length = lua.Check<std::size_t>(&argIndex);
|
||||
|
||||
std::unique_ptr<char[]> buffer(new char[length]);
|
||||
std::size_t readLength = stream.Read(buffer.get(), length);
|
||||
std::size_t readLength = instance.Read(buffer.get(), length);
|
||||
|
||||
lua.PushString(Nz::String(buffer.get(), readLength));
|
||||
return 1;
|
||||
});
|
||||
|
||||
stream.BindMethod("Write", [] (Nz::LuaState& lua, Nz::Stream& stream, std::size_t /*argumentCount*/) -> int {
|
||||
stream.BindMethod("Write", [] (Nz::LuaState& lua, Nz::Stream& instance, std::size_t /*argumentCount*/) -> int {
|
||||
int argIndex = 2;
|
||||
|
||||
std::size_t bufferSize = 0;
|
||||
const char* buffer = lua.CheckString(argIndex, &bufferSize);
|
||||
|
||||
if (stream.IsTextModeEnabled())
|
||||
lua.Push(stream.Write(Nz::String(buffer, bufferSize)));
|
||||
if (instance.IsTextModeEnabled())
|
||||
lua.Push(instance.Write(Nz::String(buffer, bufferSize)));
|
||||
else
|
||||
lua.Push(stream.Write(buffer, bufferSize));
|
||||
lua.Push(instance.Write(buffer, bufferSize));
|
||||
return 1;
|
||||
});
|
||||
}
|
||||
@@ -103,11 +103,11 @@ namespace Ndk
|
||||
clock.BindMethod("Unpause", &Nz::Clock::Unpause);
|
||||
|
||||
// Manual
|
||||
clock.BindMethod("__tostring", [] (Nz::LuaState& lua, Nz::Clock& clock, std::size_t /*argumentCount*/) -> int {
|
||||
clock.BindMethod("__tostring", [] (Nz::LuaState& lua, Nz::Clock& instance, std::size_t /*argumentCount*/) -> int {
|
||||
Nz::StringStream ss("Clock(Elapsed: ");
|
||||
ss << clock.GetSeconds();
|
||||
ss << instance.GetSeconds();
|
||||
ss << "s, Paused: ";
|
||||
ss << clock.IsPaused();
|
||||
ss << instance.IsPaused();
|
||||
ss << ')';
|
||||
|
||||
lua.PushString(ss);
|
||||
@@ -159,9 +159,9 @@ namespace Ndk
|
||||
directory.BindStaticMethod("SetCurrent", Nz::Directory::SetCurrent);
|
||||
|
||||
// Manual
|
||||
directory.BindMethod("__tostring", [] (Nz::LuaState& lua, Nz::Directory& dir, std::size_t /*argumentCount*/) -> int {
|
||||
directory.BindMethod("__tostring", [] (Nz::LuaState& lua, Nz::Directory& instance, std::size_t /*argumentCount*/) -> int {
|
||||
Nz::StringStream ss("Directory(");
|
||||
ss << dir.GetPath();
|
||||
ss << instance.GetPath();
|
||||
ss << ')';
|
||||
|
||||
lua.PushString(ss);
|
||||
@@ -237,7 +237,7 @@ namespace Ndk
|
||||
file.BindStaticMethod("Rename", &Nz::File::Rename);
|
||||
|
||||
// Manual
|
||||
file.BindMethod("Open", [] (Nz::LuaState& lua, Nz::File& file, std::size_t argumentCount) -> int
|
||||
file.BindMethod("Open", [] (Nz::LuaState& lua, Nz::File& instance, std::size_t argumentCount) -> int
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 2U);
|
||||
|
||||
@@ -246,13 +246,13 @@ namespace Ndk
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
return lua.Push(file.Open(lua.Check<Nz::UInt32>(&argIndex, Nz::OpenMode_NotOpen)));
|
||||
return lua.Push(instance.Open(lua.Check<Nz::UInt32>(&argIndex, Nz::OpenMode_NotOpen)));
|
||||
|
||||
case 2:
|
||||
{
|
||||
Nz::String filePath = lua.Check<Nz::String>(&argIndex);
|
||||
Nz::UInt32 openMode = lua.Check<Nz::UInt32>(&argIndex, Nz::OpenMode_NotOpen);
|
||||
return lua.Push(file.Open(filePath, openMode));
|
||||
return lua.Push(instance.Open(filePath, openMode));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ namespace Ndk
|
||||
return 0;
|
||||
});
|
||||
|
||||
file.BindMethod("SetCursorPos", [] (Nz::LuaState& lua, Nz::File& file, std::size_t argumentCount) -> int
|
||||
file.BindMethod("SetCursorPos", [] (Nz::LuaState& lua, Nz::File& instance, std::size_t argumentCount) -> int
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 2U);
|
||||
|
||||
@@ -268,13 +268,13 @@ namespace Ndk
|
||||
switch (argCount)
|
||||
{
|
||||
case 1:
|
||||
return lua.Push(file.SetCursorPos(lua.Check<Nz::UInt64>(&argIndex)));
|
||||
return lua.Push(instance.SetCursorPos(lua.Check<Nz::UInt64>(&argIndex)));
|
||||
|
||||
case 2:
|
||||
{
|
||||
Nz::CursorPosition curPos = lua.Check<Nz::CursorPosition>(&argIndex);
|
||||
Nz::Int64 offset = lua.Check<Nz::Int64>(&argIndex);
|
||||
return lua.Push(file.SetCursorPos(curPos, offset));
|
||||
return lua.Push(instance.SetCursorPos(curPos, offset));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,10 +282,10 @@ namespace Ndk
|
||||
return 0;
|
||||
});
|
||||
|
||||
file.BindMethod("__tostring", [] (Nz::LuaState& lua, Nz::File& file, std::size_t /*argumentCount*/) -> int {
|
||||
file.BindMethod("__tostring", [] (Nz::LuaState& lua, Nz::File& instance, std::size_t /*argumentCount*/) -> int {
|
||||
Nz::StringStream ss("File(");
|
||||
if (file.IsOpen())
|
||||
ss << "Path: " << file.GetPath();
|
||||
if (instance.IsOpen())
|
||||
ss << "Path: " << instance.GetPath();
|
||||
|
||||
ss << ')';
|
||||
|
||||
@@ -321,10 +321,11 @@ namespace Ndk
|
||||
state.SetGlobal("CursorPosition");
|
||||
|
||||
// Nz::HashType
|
||||
static_assert(Nz::HashType_Max + 1 == 9, "Nz::HashType has been updated but change was not reflected to Lua binding");
|
||||
state.PushTable(0, 9);
|
||||
static_assert(Nz::HashType_Max + 1 == 10, "Nz::HashType has been updated but change was not reflected to Lua binding");
|
||||
state.PushTable(0, 10);
|
||||
{
|
||||
state.PushField("CRC32", Nz::HashType_CRC32);
|
||||
state.PushField("CRC64", Nz::HashType_CRC64);
|
||||
state.PushField("Fletcher16", Nz::HashType_Fletcher16);
|
||||
state.PushField("MD5", Nz::HashType_MD5);
|
||||
state.PushField("SHA1", Nz::HashType_SHA1);
|
||||
|
||||
133
SDK/src/NDK/Lua/LuaBinding_Platform.cpp
Normal file
133
SDK/src/NDK/Lua/LuaBinding_Platform.cpp
Normal file
@@ -0,0 +1,133 @@
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/Lua/LuaBinding_Platform.hpp>
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindPlatform(LuaBinding& binding)
|
||||
{
|
||||
return std::make_unique<LuaBinding_Platform>(binding);
|
||||
}
|
||||
|
||||
LuaBinding_Platform::LuaBinding_Platform(LuaBinding& binding) :
|
||||
LuaBinding_Base(binding)
|
||||
{
|
||||
/*********************************** Nz::Keyboard **********************************/
|
||||
keyboard.Reset("Keyboard");
|
||||
{
|
||||
keyboard.BindStaticMethod("GetKeyName", &Nz::Keyboard::GetKeyName);
|
||||
keyboard.BindStaticMethod("IsKeyPressed", &Nz::Keyboard::IsKeyPressed);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Registers the classes that will be used by the Lua instance
|
||||
*
|
||||
* \param instance Lua instance that will interact with the Utility classes
|
||||
*/
|
||||
void LuaBinding_Platform::Register(Nz::LuaState& state)
|
||||
{
|
||||
keyboard.Register(state);
|
||||
|
||||
keyboard.PushGlobalTable(state);
|
||||
{
|
||||
static_assert(Nz::Keyboard::Count == 121, "Nz::Keyboard::Key has been updated but change was not reflected to Lua binding");
|
||||
|
||||
state.PushField("Undefined", Nz::Keyboard::Undefined);
|
||||
|
||||
// A-Z
|
||||
for (std::size_t i = 0; i < 26; ++i)
|
||||
state.PushField(Nz::String('A' + char(i)), Nz::Keyboard::A + i);
|
||||
|
||||
// Numerical
|
||||
for (std::size_t i = 0; i < 10; ++i)
|
||||
{
|
||||
state.PushField("Num" + Nz::String::Number(i), Nz::Keyboard::Num0 + i);
|
||||
state.PushField("Numpad" + Nz::String::Number(i), Nz::Keyboard::Numpad0 + i);
|
||||
}
|
||||
|
||||
// F1-F15
|
||||
for (std::size_t i = 0; i < 15; ++i)
|
||||
state.PushField('F' + Nz::String::Number(i+1), Nz::Keyboard::F1 + i);
|
||||
|
||||
// And all the others...
|
||||
state.PushField("Down", Nz::Keyboard::Down);
|
||||
state.PushField("Left", Nz::Keyboard::Left);
|
||||
state.PushField("Right", Nz::Keyboard::Right);
|
||||
state.PushField("Up", Nz::Keyboard::Up);
|
||||
|
||||
state.PushField("Add", Nz::Keyboard::Add);
|
||||
state.PushField("Decimal", Nz::Keyboard::Decimal);
|
||||
state.PushField("Divide", Nz::Keyboard::Divide);
|
||||
state.PushField("Multiply", Nz::Keyboard::Multiply);
|
||||
state.PushField("Subtract", Nz::Keyboard::Subtract);
|
||||
|
||||
state.PushField("Backslash", Nz::Keyboard::Backslash);
|
||||
state.PushField("Backspace", Nz::Keyboard::Backspace);
|
||||
state.PushField("Clear", Nz::Keyboard::Clear);
|
||||
state.PushField("Comma", Nz::Keyboard::Comma);
|
||||
state.PushField("Dash", Nz::Keyboard::Dash);
|
||||
state.PushField("Delete", Nz::Keyboard::Delete);
|
||||
state.PushField("End", Nz::Keyboard::End);
|
||||
state.PushField("Equal", Nz::Keyboard::Equal);
|
||||
state.PushField("Escape", Nz::Keyboard::Escape);
|
||||
state.PushField("Home", Nz::Keyboard::Home);
|
||||
state.PushField("Insert", Nz::Keyboard::Insert);
|
||||
state.PushField("LAlt", Nz::Keyboard::LAlt);
|
||||
state.PushField("LBracket", Nz::Keyboard::LBracket);
|
||||
state.PushField("LControl", Nz::Keyboard::LControl);
|
||||
state.PushField("LShift", Nz::Keyboard::LShift);
|
||||
state.PushField("LSystem", Nz::Keyboard::LSystem);
|
||||
state.PushField("PageDown", Nz::Keyboard::PageDown);
|
||||
state.PushField("PageUp", Nz::Keyboard::PageUp);
|
||||
state.PushField("Pause", Nz::Keyboard::Pause);
|
||||
state.PushField("Period", Nz::Keyboard::Period);
|
||||
state.PushField("Print", Nz::Keyboard::Print);
|
||||
state.PushField("PrintScreen", Nz::Keyboard::PrintScreen);
|
||||
state.PushField("Quote", Nz::Keyboard::Quote);
|
||||
state.PushField("RAlt", Nz::Keyboard::RAlt);
|
||||
state.PushField("RBracket", Nz::Keyboard::RBracket);
|
||||
state.PushField("RControl", Nz::Keyboard::RControl);
|
||||
state.PushField("Return", Nz::Keyboard::Return);
|
||||
state.PushField("RShift", Nz::Keyboard::RShift);
|
||||
state.PushField("RSystem", Nz::Keyboard::RSystem);
|
||||
state.PushField("Semicolon", Nz::Keyboard::Semicolon);
|
||||
state.PushField("Slash", Nz::Keyboard::Slash);
|
||||
state.PushField("Space", Nz::Keyboard::Space);
|
||||
state.PushField("Tab", Nz::Keyboard::Tab);
|
||||
state.PushField("Tilde", Nz::Keyboard::Tilde);
|
||||
state.PushField("Browser_Back", Nz::Keyboard::Browser_Back);
|
||||
state.PushField("Browser_Favorites", Nz::Keyboard::Browser_Favorites);
|
||||
state.PushField("Browser_Forward", Nz::Keyboard::Browser_Forward);
|
||||
state.PushField("Browser_Home", Nz::Keyboard::Browser_Home);
|
||||
state.PushField("Browser_Refresh", Nz::Keyboard::Browser_Refresh);
|
||||
state.PushField("Browser_Search", Nz::Keyboard::Browser_Search);
|
||||
state.PushField("Browser_Stop", Nz::Keyboard::Browser_Stop);
|
||||
state.PushField("Media_Next", Nz::Keyboard::Media_Next);
|
||||
state.PushField("Media_Play", Nz::Keyboard::Media_Play);
|
||||
state.PushField("Media_Previous", Nz::Keyboard::Media_Previous);
|
||||
state.PushField("Media_Stop", Nz::Keyboard::Media_Stop);
|
||||
state.PushField("Volume_Down", Nz::Keyboard::Volume_Down);
|
||||
state.PushField("Volume_Mute", Nz::Keyboard::Volume_Mute);
|
||||
state.PushField("Volume_Up", Nz::Keyboard::Volume_Up);
|
||||
state.PushField("CapsLock", Nz::Keyboard::CapsLock);
|
||||
state.PushField("NumLock", Nz::Keyboard::NumLock);
|
||||
state.PushField("ScrollLock", Nz::Keyboard::ScrollLock);
|
||||
}
|
||||
state.Pop();
|
||||
|
||||
static_assert(Nz::WindowStyle_Max + 1 == 6, "Nz::WindowStyle has been updated but change was not reflected to Lua binding");
|
||||
state.PushTable(0, Nz::WindowStyle_Max + 1);
|
||||
{
|
||||
state.PushField("None", Nz::WindowStyle_None);
|
||||
state.PushField("Fullscreen", Nz::WindowStyle_Fullscreen);
|
||||
state.PushField("Closable", Nz::WindowStyle_Closable);
|
||||
state.PushField("Resizable", Nz::WindowStyle_Resizable);
|
||||
state.PushField("Titlebar", Nz::WindowStyle_Titlebar);
|
||||
state.PushField("Threaded", Nz::WindowStyle_Threaded);
|
||||
}
|
||||
state.SetGlobal("WindowStyle");
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@ namespace Ndk
|
||||
}
|
||||
|
||||
/*********************************** Nz::TextureManager ***********************************/
|
||||
textureManager.Reset("textureManager");
|
||||
textureManager.Reset("TextureManager");
|
||||
{
|
||||
textureManager.BindStaticMethod("Clear", &Nz::TextureManager::Clear);
|
||||
textureManager.BindStaticMethod("Get", &Nz::TextureManager::Get);
|
||||
|
||||
@@ -69,6 +69,7 @@ namespace Ndk
|
||||
console.BindMethod("GetSize", &Console::GetSize);
|
||||
console.BindMethod("GetTextFont", &Console::GetTextFont);
|
||||
|
||||
console.BindMethod("IsValidHandle", &ConsoleHandle::IsValid);
|
||||
console.BindMethod("IsVisible", &Console::IsVisible);
|
||||
|
||||
console.BindMethod("SendCharacter", &Console::SendCharacter);
|
||||
@@ -91,6 +92,7 @@ namespace Ndk
|
||||
entity.BindMethod("Kill", &Entity::Kill);
|
||||
entity.BindMethod("IsEnabled", &Entity::IsEnabled);
|
||||
entity.BindMethod("IsValid", &Entity::IsValid);
|
||||
entity.BindMethod("IsValidHandle", &EntityHandle::IsValid);
|
||||
entity.BindMethod("RemoveAllComponents", &Entity::RemoveAllComponents);
|
||||
entity.BindMethod("__tostring", &EntityHandle::ToString);
|
||||
|
||||
@@ -101,6 +103,14 @@ namespace Ndk
|
||||
return bindingComponent->adder(state, handle);
|
||||
});
|
||||
|
||||
entity.BindMethod("HasComponent", [this](Nz::LuaState& state, EntityHandle& handle, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
LuaBinding::ComponentBinding* bindingComponent = m_binding.QueryComponentIndex(state);
|
||||
|
||||
state.PushBoolean(handle->HasComponent(bindingComponent->index));
|
||||
return 1;
|
||||
});
|
||||
|
||||
entity.BindMethod("GetComponent", [this] (Nz::LuaState& state, EntityHandle& handle, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
LuaBinding::ComponentBinding* bindingComponent = m_binding.QueryComponentIndex(state);
|
||||
@@ -120,6 +130,8 @@ namespace Ndk
|
||||
/*********************************** Ndk::NodeComponent **********************************/
|
||||
nodeComponent.Reset("NodeComponent");
|
||||
{
|
||||
nodeComponent.BindMethod("IsValidHandle", &NodeComponentHandle::IsValid);
|
||||
|
||||
nodeComponent.Inherit<Nz::Node>(utility.node, [] (NodeComponentHandle* handle) -> Nz::Node*
|
||||
{
|
||||
return handle->GetObject();
|
||||
@@ -129,6 +141,8 @@ namespace Ndk
|
||||
/*********************************** Ndk::VelocityComponent **********************************/
|
||||
velocityComponent.Reset("VelocityComponent");
|
||||
{
|
||||
velocityComponent.BindMethod("IsValidHandle", &VelocityComponentHandle::IsValid);
|
||||
|
||||
velocityComponent.SetGetter([] (Nz::LuaState& lua, VelocityComponentHandle& instance)
|
||||
{
|
||||
std::size_t length;
|
||||
@@ -165,6 +179,8 @@ namespace Ndk
|
||||
world.BindMethod("CreateEntity", &World::CreateEntity);
|
||||
world.BindMethod("CreateEntities", &World::CreateEntities);
|
||||
world.BindMethod("Clear", &World::Clear);
|
||||
|
||||
world.BindMethod("IsValidHandle", &WorldHandle::IsValid);
|
||||
}
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
@@ -176,18 +192,20 @@ namespace Ndk
|
||||
return handle->GetObject();
|
||||
});
|
||||
|
||||
cameraComponent.BindMethod("GetFOV", &Ndk::CameraComponent::GetFOV);
|
||||
cameraComponent.BindMethod("GetLayer", &Ndk::CameraComponent::GetLayer);
|
||||
cameraComponent.BindMethod("GetFOV", &CameraComponent::GetFOV);
|
||||
cameraComponent.BindMethod("GetLayer", &CameraComponent::GetLayer);
|
||||
|
||||
cameraComponent.BindMethod("SetFOV", &Ndk::CameraComponent::SetFOV);
|
||||
cameraComponent.BindMethod("SetLayer", &Ndk::CameraComponent::SetLayer);
|
||||
cameraComponent.BindMethod("SetProjectionType", &Ndk::CameraComponent::SetProjectionType);
|
||||
cameraComponent.BindMethod("SetSize", (void(Ndk::CameraComponent::*)(const Nz::Vector2f&)) &Ndk::CameraComponent::SetSize);
|
||||
//cameraComponent.BindMethod("SetTarget", &Ndk::CameraComponent::SetTarget);
|
||||
cameraComponent.BindMethod("SetTargetRegion", &Ndk::CameraComponent::SetTargetRegion);
|
||||
cameraComponent.BindMethod("SetViewport", &Ndk::CameraComponent::SetViewport);
|
||||
cameraComponent.BindMethod("SetZFar", &Ndk::CameraComponent::SetZFar);
|
||||
cameraComponent.BindMethod("SetZNear", &Ndk::CameraComponent::SetZNear);
|
||||
cameraComponent.BindMethod("IsValidHandle", &CameraComponentHandle::IsValid);
|
||||
|
||||
cameraComponent.BindMethod("SetFOV", &CameraComponent::SetFOV);
|
||||
cameraComponent.BindMethod("SetLayer", &CameraComponent::SetLayer);
|
||||
cameraComponent.BindMethod("SetProjectionType", &CameraComponent::SetProjectionType);
|
||||
cameraComponent.BindMethod("SetSize", (void(CameraComponent::*)(const Nz::Vector2f&)) &CameraComponent::SetSize);
|
||||
//cameraComponent.BindMethod("SetTarget", &CameraComponent::SetTarget);
|
||||
cameraComponent.BindMethod("SetTargetRegion", &CameraComponent::SetTargetRegion);
|
||||
cameraComponent.BindMethod("SetViewport", &CameraComponent::SetViewport);
|
||||
cameraComponent.BindMethod("SetZFar", &CameraComponent::SetZFar);
|
||||
cameraComponent.BindMethod("SetZNear", &CameraComponent::SetZNear);
|
||||
}
|
||||
|
||||
/*********************************** Ndk::GraphicsComponent **********************************/
|
||||
@@ -249,6 +267,8 @@ namespace Ndk
|
||||
lua.Error("No matching overload for method GetMemoryUsage");
|
||||
return 0;
|
||||
});
|
||||
|
||||
graphicsComponent.BindMethod("IsValidHandle", &GraphicsComponentHandle::IsValid);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -161,13 +161,6 @@ namespace Ndk
|
||||
font.BindStaticMethod("SetDefaultMinimumStepSize", &Nz::Font::SetDefaultMinimumStepSize);
|
||||
}
|
||||
|
||||
/*********************************** Nz::Keyboard **********************************/
|
||||
keyboard.Reset("Keyboard");
|
||||
{
|
||||
keyboard.BindStaticMethod("GetKeyName", &Nz::Keyboard::GetKeyName);
|
||||
keyboard.BindStaticMethod("IsKeyPressed", &Nz::Keyboard::IsKeyPressed);
|
||||
}
|
||||
|
||||
/*********************************** Nz::Node **********************************/
|
||||
node.Reset("Node");
|
||||
{
|
||||
@@ -216,29 +209,29 @@ namespace Ndk
|
||||
node.BindMethod("SetPosition", (void(Nz::Node::*)(const Nz::Vector3f&, Nz::CoordSys)) &Nz::Node::SetPosition, Nz::CoordSys_Local);
|
||||
node.BindMethod("SetRotation", (void(Nz::Node::*)(const Nz::Quaternionf&, Nz::CoordSys)) &Nz::Node::SetRotation, Nz::CoordSys_Local);
|
||||
|
||||
node.BindMethod("Move", [] (Nz::LuaState& lua, Nz::Node& node, std::size_t /*argumentCount*/) -> int
|
||||
node.BindMethod("Move", [] (Nz::LuaState& lua, Nz::Node& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
int argIndex = 2;
|
||||
|
||||
Nz::Vector3f offset = lua.Check<Nz::Vector3f>(&argIndex);
|
||||
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&argIndex, Nz::CoordSys_Local);
|
||||
node.Move(offset, coordSys);
|
||||
instance.Move(offset, coordSys);
|
||||
|
||||
return 0;
|
||||
});
|
||||
|
||||
node.BindMethod("Rotate", [] (Nz::LuaState& lua, Nz::Node& node, std::size_t /*argumentCount*/) -> int
|
||||
node.BindMethod("Rotate", [] (Nz::LuaState& lua, Nz::Node& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
int argIndex = 2;
|
||||
|
||||
Nz::Quaternionf rotation = lua.Check<Nz::Quaternionf>(&argIndex);
|
||||
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&argIndex, Nz::CoordSys_Local);
|
||||
node.Rotate(rotation, coordSys);
|
||||
instance.Rotate(rotation, coordSys);
|
||||
|
||||
return 0;
|
||||
});
|
||||
|
||||
node.BindMethod("Scale", [] (Nz::LuaState& lua, Nz::Node& node, std::size_t argumentCount) -> int
|
||||
node.BindMethod("Scale", [] (Nz::LuaState& lua, Nz::Node& instance, std::size_t argumentCount) -> int
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 4U);
|
||||
|
||||
@@ -248,15 +241,15 @@ namespace Ndk
|
||||
case 1:
|
||||
{
|
||||
if (lua.IsOfType(argIndex, Nz::LuaType_Number))
|
||||
node.Scale(lua.Check<float>(&argIndex));
|
||||
instance.Scale(lua.Check<float>(&argIndex));
|
||||
else
|
||||
node.Scale(lua.Check<Nz::Vector3f>(&argIndex));
|
||||
instance.Scale(lua.Check<Nz::Vector3f>(&argIndex));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
case 3:
|
||||
node.Scale(lua.Check<Nz::Vector3f>(&argIndex));
|
||||
instance.Scale(lua.Check<Nz::Vector3f>(&argIndex));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -264,7 +257,7 @@ namespace Ndk
|
||||
return 0;
|
||||
});
|
||||
|
||||
node.BindMethod("SetScale", [] (Nz::LuaState& lua, Nz::Node& node, std::size_t argumentCount) -> int
|
||||
node.BindMethod("SetScale", [] (Nz::LuaState& lua, Nz::Node& instance, std::size_t argumentCount) -> int
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 4U);
|
||||
|
||||
@@ -278,10 +271,10 @@ namespace Ndk
|
||||
{
|
||||
float scale = lua.Check<float>(&argIndex);
|
||||
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&argIndex, Nz::CoordSys_Local);
|
||||
node.SetScale(scale, coordSys);
|
||||
instance.SetScale(scale, coordSys);
|
||||
}
|
||||
else
|
||||
node.SetScale(lua.Check<Nz::Vector3f>(&argIndex));
|
||||
instance.SetScale(lua.Check<Nz::Vector3f>(&argIndex));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -292,7 +285,7 @@ namespace Ndk
|
||||
Nz::Vector3f scale = lua.Check<Nz::Vector3f>(&argIndex);
|
||||
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&argIndex, Nz::CoordSys_Local);
|
||||
|
||||
node.SetScale(scale, coordSys);
|
||||
instance.SetScale(scale, coordSys);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -301,7 +294,7 @@ namespace Ndk
|
||||
return 0;
|
||||
});
|
||||
|
||||
node.BindMethod("SetInitialScale", [] (Nz::LuaState& lua, Nz::Node& node, std::size_t argumentCount) -> int
|
||||
node.BindMethod("SetInitialScale", [] (Nz::LuaState& lua, Nz::Node& instance, std::size_t argumentCount) -> int
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 4U);
|
||||
|
||||
@@ -311,16 +304,16 @@ namespace Ndk
|
||||
case 1:
|
||||
{
|
||||
if (lua.IsOfType(argIndex, Nz::LuaType_Number))
|
||||
node.SetInitialScale(lua.Check<float>(&argIndex));
|
||||
instance.SetInitialScale(lua.Check<float>(&argIndex));
|
||||
else
|
||||
node.SetInitialScale(lua.Check<Nz::Vector2f>(&argIndex));
|
||||
instance.SetInitialScale(lua.Check<Nz::Vector2f>(&argIndex));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
node.SetInitialScale(lua.Check<Nz::Vector3f>(&argIndex));
|
||||
instance.SetInitialScale(lua.Check<Nz::Vector3f>(&argIndex));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -339,106 +332,6 @@ namespace Ndk
|
||||
{
|
||||
abstractImage.Register(state);
|
||||
font.Register(state);
|
||||
keyboard.Register(state);
|
||||
node.Register(state);
|
||||
|
||||
keyboard.PushGlobalTable(state);
|
||||
{
|
||||
static_assert(Nz::Keyboard::Count == 121, "Nz::Keyboard::Key has been updated but change was not reflected to Lua binding");
|
||||
|
||||
state.PushField("Undefined", Nz::Keyboard::Undefined);
|
||||
|
||||
// A-Z
|
||||
for (std::size_t i = 0; i < 26; ++i)
|
||||
state.PushField(Nz::String('A' + char(i)), Nz::Keyboard::A + i);
|
||||
|
||||
// Numerical
|
||||
for (std::size_t i = 0; i < 10; ++i)
|
||||
{
|
||||
state.PushField("Num" + Nz::String::Number(i), Nz::Keyboard::Num0 + i);
|
||||
state.PushField("Numpad" + Nz::String::Number(i), Nz::Keyboard::Numpad0 + i);
|
||||
}
|
||||
|
||||
// F1-F15
|
||||
for (std::size_t i = 0; i < 15; ++i)
|
||||
state.PushField('F' + Nz::String::Number(i+1), Nz::Keyboard::F1 + i);
|
||||
|
||||
// And all the others...
|
||||
state.PushField("Down", Nz::Keyboard::Down);
|
||||
state.PushField("Left", Nz::Keyboard::Left);
|
||||
state.PushField("Right", Nz::Keyboard::Right);
|
||||
state.PushField("Up", Nz::Keyboard::Up);
|
||||
|
||||
state.PushField("Add", Nz::Keyboard::Add);
|
||||
state.PushField("Decimal", Nz::Keyboard::Decimal);
|
||||
state.PushField("Divide", Nz::Keyboard::Divide);
|
||||
state.PushField("Multiply", Nz::Keyboard::Multiply);
|
||||
state.PushField("Subtract", Nz::Keyboard::Subtract);
|
||||
|
||||
state.PushField("Backslash", Nz::Keyboard::Backslash);
|
||||
state.PushField("Backspace", Nz::Keyboard::Backspace);
|
||||
state.PushField("Clear", Nz::Keyboard::Clear);
|
||||
state.PushField("Comma", Nz::Keyboard::Comma);
|
||||
state.PushField("Dash", Nz::Keyboard::Dash);
|
||||
state.PushField("Delete", Nz::Keyboard::Delete);
|
||||
state.PushField("End", Nz::Keyboard::End);
|
||||
state.PushField("Equal", Nz::Keyboard::Equal);
|
||||
state.PushField("Escape", Nz::Keyboard::Escape);
|
||||
state.PushField("Home", Nz::Keyboard::Home);
|
||||
state.PushField("Insert", Nz::Keyboard::Insert);
|
||||
state.PushField("LAlt", Nz::Keyboard::LAlt);
|
||||
state.PushField("LBracket", Nz::Keyboard::LBracket);
|
||||
state.PushField("LControl", Nz::Keyboard::LControl);
|
||||
state.PushField("LShift", Nz::Keyboard::LShift);
|
||||
state.PushField("LSystem", Nz::Keyboard::LSystem);
|
||||
state.PushField("PageDown", Nz::Keyboard::PageDown);
|
||||
state.PushField("PageUp", Nz::Keyboard::PageUp);
|
||||
state.PushField("Pause", Nz::Keyboard::Pause);
|
||||
state.PushField("Period", Nz::Keyboard::Period);
|
||||
state.PushField("Print", Nz::Keyboard::Print);
|
||||
state.PushField("PrintScreen", Nz::Keyboard::PrintScreen);
|
||||
state.PushField("Quote", Nz::Keyboard::Quote);
|
||||
state.PushField("RAlt", Nz::Keyboard::RAlt);
|
||||
state.PushField("RBracket", Nz::Keyboard::RBracket);
|
||||
state.PushField("RControl", Nz::Keyboard::RControl);
|
||||
state.PushField("Return", Nz::Keyboard::Return);
|
||||
state.PushField("RShift", Nz::Keyboard::RShift);
|
||||
state.PushField("RSystem", Nz::Keyboard::RSystem);
|
||||
state.PushField("Semicolon", Nz::Keyboard::Semicolon);
|
||||
state.PushField("Slash", Nz::Keyboard::Slash);
|
||||
state.PushField("Space", Nz::Keyboard::Space);
|
||||
state.PushField("Tab", Nz::Keyboard::Tab);
|
||||
state.PushField("Tilde", Nz::Keyboard::Tilde);
|
||||
state.PushField("Browser_Back", Nz::Keyboard::Browser_Back);
|
||||
state.PushField("Browser_Favorites", Nz::Keyboard::Browser_Favorites);
|
||||
state.PushField("Browser_Forward", Nz::Keyboard::Browser_Forward);
|
||||
state.PushField("Browser_Home", Nz::Keyboard::Browser_Home);
|
||||
state.PushField("Browser_Refresh", Nz::Keyboard::Browser_Refresh);
|
||||
state.PushField("Browser_Search", Nz::Keyboard::Browser_Search);
|
||||
state.PushField("Browser_Stop", Nz::Keyboard::Browser_Stop);
|
||||
state.PushField("Media_Next", Nz::Keyboard::Media_Next);
|
||||
state.PushField("Media_Play", Nz::Keyboard::Media_Play);
|
||||
state.PushField("Media_Previous", Nz::Keyboard::Media_Previous);
|
||||
state.PushField("Media_Stop", Nz::Keyboard::Media_Stop);
|
||||
state.PushField("Volume_Down", Nz::Keyboard::Volume_Down);
|
||||
state.PushField("Volume_Mute", Nz::Keyboard::Volume_Mute);
|
||||
state.PushField("Volume_Up", Nz::Keyboard::Volume_Up);
|
||||
state.PushField("CapsLock", Nz::Keyboard::CapsLock);
|
||||
state.PushField("NumLock", Nz::Keyboard::NumLock);
|
||||
state.PushField("ScrollLock", Nz::Keyboard::ScrollLock);
|
||||
}
|
||||
state.Pop();
|
||||
|
||||
static_assert(Nz::WindowStyle_Max + 1 == 6, "Nz::WindowStyle has been updated but change was not reflected to Lua binding");
|
||||
state.PushTable(0, Nz::WindowStyle_Max + 1);
|
||||
{
|
||||
state.PushField("None", Nz::WindowStyle_None);
|
||||
state.PushField("Fullscreen", Nz::WindowStyle_Fullscreen);
|
||||
state.PushField("Closable", Nz::WindowStyle_Closable);
|
||||
state.PushField("Resizable", Nz::WindowStyle_Resizable);
|
||||
state.PushField("Titlebar", Nz::WindowStyle_Titlebar);
|
||||
state.PushField("Threaded", Nz::WindowStyle_Threaded);
|
||||
}
|
||||
state.SetGlobal("WindowStyle");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user