SDK/Lua: Rework LuaBinding classes to try to improve compile time and binary size
This commit is contained in:
parent
057de1544b
commit
7f143e41f8
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NDK_SERVER
|
||||||
#ifndef NDK_CONSOLE_HPP
|
#ifndef NDK_CONSOLE_HPP
|
||||||
#define NDK_CONSOLE_HPP
|
#define NDK_CONSOLE_HPP
|
||||||
|
|
||||||
|
|
@ -99,3 +100,4 @@ namespace Ndk
|
||||||
#include <NDK/Console.inl>
|
#include <NDK/Console.inl>
|
||||||
|
|
||||||
#endif // NDK_CONSOLE_HPP
|
#endif // NDK_CONSOLE_HPP
|
||||||
|
#endif // NDK_SERVER
|
||||||
|
|
|
||||||
|
|
@ -7,28 +7,17 @@
|
||||||
#ifndef NDK_LUABINDING_HPP
|
#ifndef NDK_LUABINDING_HPP
|
||||||
#define NDK_LUABINDING_HPP
|
#define NDK_LUABINDING_HPP
|
||||||
|
|
||||||
#include <Nazara/Core.hpp>
|
#include <NDK/BaseComponent.hpp>
|
||||||
#include <Nazara/Lua.hpp>
|
|
||||||
#include <Nazara/Math.hpp>
|
|
||||||
#include <Nazara/Network.hpp>
|
|
||||||
#include <Nazara/Utility.hpp>
|
|
||||||
#include <NDK/Application.hpp>
|
|
||||||
#include <NDK/Components.hpp>
|
|
||||||
#include <NDK/Entity.hpp>
|
#include <NDK/Entity.hpp>
|
||||||
#include <NDK/Systems.hpp>
|
#include <NDK/LuaBinding_Base.hpp>
|
||||||
#include <NDK/World.hpp>
|
#include <memory>
|
||||||
|
|
||||||
#ifndef NDK_SERVER
|
|
||||||
#include <Nazara/Audio.hpp>
|
|
||||||
#include <Nazara/Graphics.hpp>
|
|
||||||
#include <Nazara/Renderer.hpp>
|
|
||||||
#include <NDK/Console.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
class NDK_API LuaBinding
|
class NDK_API LuaBinding
|
||||||
{
|
{
|
||||||
|
friend class LuaBinding_SDK;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LuaBinding();
|
LuaBinding();
|
||||||
~LuaBinding() = default;
|
~LuaBinding() = default;
|
||||||
|
|
@ -37,86 +26,24 @@ namespace Ndk
|
||||||
|
|
||||||
void RegisterClasses(Nz::LuaInstance& instance);
|
void RegisterClasses(Nz::LuaInstance& instance);
|
||||||
|
|
||||||
// Core
|
std::unique_ptr<LuaBinding_Base> core;
|
||||||
Nz::LuaClass<Nz::Clock> clock;
|
std::unique_ptr<LuaBinding_Base> math;
|
||||||
Nz::LuaClass<Nz::Directory> directory;
|
std::unique_ptr<LuaBinding_Base> network;
|
||||||
Nz::LuaClass<Nz::File> file;
|
std::unique_ptr<LuaBinding_Base> sdk;
|
||||||
Nz::LuaClass<Nz::Stream> stream;
|
std::unique_ptr<LuaBinding_Base> utility;
|
||||||
|
|
||||||
// Math
|
|
||||||
Nz::LuaClass<Nz::EulerAnglesd> eulerAngles;
|
|
||||||
Nz::LuaClass<Nz::Matrix4d> matrix4d;
|
|
||||||
Nz::LuaClass<Nz::Quaterniond> quaternion;
|
|
||||||
Nz::LuaClass<Nz::Rectd> rect;
|
|
||||||
Nz::LuaClass<Nz::Vector2d> vector2d;
|
|
||||||
Nz::LuaClass<Nz::Vector3d> vector3d;
|
|
||||||
|
|
||||||
// Network
|
|
||||||
Nz::LuaClass<Nz::AbstractSocket> abstractSocket;
|
|
||||||
Nz::LuaClass<Nz::IpAddress> ipAddress;
|
|
||||||
|
|
||||||
// Utility
|
|
||||||
Nz::LuaClass<Nz::AbstractImageRef> abstractImage;
|
|
||||||
Nz::LuaClass<Nz::FontRef> font;
|
|
||||||
Nz::LuaClass<Nz::Keyboard> keyboard;
|
|
||||||
Nz::LuaClass<Nz::Node> node;
|
|
||||||
|
|
||||||
// SDK
|
|
||||||
Nz::LuaClass<Application*> application;
|
|
||||||
Nz::LuaClass<EntityHandle> entity;
|
|
||||||
Nz::LuaClass<NodeComponentHandle> nodeComponent;
|
|
||||||
Nz::LuaClass<VelocityComponentHandle> velocityComponent;
|
|
||||||
Nz::LuaClass<WorldHandle> world;
|
|
||||||
|
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
// Audio
|
std::unique_ptr<LuaBinding_Base> audio;
|
||||||
Nz::LuaClass<Nz::Music> music;
|
std::unique_ptr<LuaBinding_Base> graphics;
|
||||||
Nz::LuaClass<Nz::Sound> sound;
|
std::unique_ptr<LuaBinding_Base> renderer;
|
||||||
Nz::LuaClass<Nz::SoundBufferRef> soundBuffer;
|
|
||||||
Nz::LuaClass<Nz::SoundEmitter> soundEmitter;
|
|
||||||
|
|
||||||
// Graphics
|
|
||||||
Nz::LuaClass<Nz::AbstractViewer> abstractViewer;
|
|
||||||
Nz::LuaClass<Nz::InstancedRenderableRef> instancedRenderable;
|
|
||||||
Nz::LuaClass<Nz::MaterialRef> material;
|
|
||||||
Nz::LuaClass<Nz::ModelRef> model;
|
|
||||||
Nz::LuaClass<Nz::SpriteRef> sprite;
|
|
||||||
Nz::LuaClass<Nz::SpriteLibrary> spriteLibrary;
|
|
||||||
Nz::LuaClass<Nz::TextureLibrary> textureLibrary;
|
|
||||||
Nz::LuaClass<Nz::TextureManager> textureManager;
|
|
||||||
|
|
||||||
// Renderer
|
|
||||||
Nz::LuaClass<Nz::TextureRef> texture;
|
|
||||||
|
|
||||||
// SDK
|
|
||||||
Nz::LuaClass<CameraComponentHandle> cameraComponent;
|
|
||||||
Nz::LuaClass<ConsoleHandle> console;
|
|
||||||
Nz::LuaClass<GraphicsComponentHandle> graphicsComponent;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void BindCore();
|
template<typename T>
|
||||||
void BindMath();
|
static int AddComponentOfType(Nz::LuaInstance& lua, EntityHandle& handle);
|
||||||
void BindNetwork();
|
|
||||||
void BindSDK();
|
|
||||||
void BindUtility();
|
|
||||||
|
|
||||||
void RegisterCore(Nz::LuaInstance& instance);
|
|
||||||
void RegisterMath(Nz::LuaInstance& instance);
|
|
||||||
void RegisterNetwork(Nz::LuaInstance& instance);
|
|
||||||
void RegisterSDK(Nz::LuaInstance& instance);
|
|
||||||
void RegisterUtility(Nz::LuaInstance& instance);
|
|
||||||
|
|
||||||
#ifndef NDK_SERVER
|
|
||||||
void BindAudio();
|
|
||||||
void BindGraphics();
|
|
||||||
void BindRenderer();
|
|
||||||
|
|
||||||
void RegisterAudio(Nz::LuaInstance& instance);
|
|
||||||
void RegisterGraphics(Nz::LuaInstance& instance);
|
|
||||||
void RegisterRenderer(Nz::LuaInstance& instance);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
static int PushComponentOfType(Nz::LuaInstance& lua, BaseComponent& component);
|
||||||
|
|
||||||
using AddComponentFunc = int(*)(Nz::LuaInstance&, EntityHandle&);
|
using AddComponentFunc = int(*)(Nz::LuaInstance&, EntityHandle&);
|
||||||
using GetComponentFunc = int(*)(Nz::LuaInstance&, BaseComponent&);
|
using GetComponentFunc = int(*)(Nz::LuaInstance&, BaseComponent&);
|
||||||
|
|
@ -134,12 +61,6 @@ namespace Ndk
|
||||||
std::vector<ComponentBinding> m_componentBinding;
|
std::vector<ComponentBinding> m_componentBinding;
|
||||||
std::unordered_map<Nz::String, ComponentIndex> m_componentBindingByName;
|
std::unordered_map<Nz::String, ComponentIndex> m_componentBindingByName;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
int AddComponentOfType(Nz::LuaInstance& lua, EntityHandle& handle);
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
int PushComponentOfType(Nz::LuaInstance& lua, BaseComponent& component);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <NDK/LuaBinding.inl>
|
#include <NDK/LuaBinding.inl>
|
||||||
|
|
|
||||||
|
|
@ -32,18 +32,8 @@ namespace Ndk
|
||||||
m_componentBindingByName[name] = T::componentIndex;
|
m_componentBindingByName[name] = T::componentIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Adds a component to an entity
|
|
||||||
* \return 1 in case of success
|
|
||||||
*
|
|
||||||
* \param instance Lua instance that will interact with the component
|
|
||||||
* \param handle Entity which component will be added to
|
|
||||||
*
|
|
||||||
* \remark T must be a subtype of BaseComponent
|
|
||||||
*/
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
int AddComponentOfType(Nz::LuaInstance& lua, EntityHandle& handle)
|
int LuaBinding::AddComponentOfType(Nz::LuaInstance& lua, EntityHandle& handle)
|
||||||
{
|
{
|
||||||
static_assert(std::is_base_of<BaseComponent, T>::value, "ComponentType must inherit BaseComponent");
|
static_assert(std::is_base_of<BaseComponent, T>::value, "ComponentType must inherit BaseComponent");
|
||||||
|
|
||||||
|
|
@ -52,18 +42,8 @@ namespace Ndk
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Pushes a component
|
|
||||||
* \return 1 in case of success
|
|
||||||
*
|
|
||||||
* \param instance Lua instance that will interact with the component
|
|
||||||
* \param component Component that will be pushed
|
|
||||||
*
|
|
||||||
* \remark T must be a subtype of BaseComponent
|
|
||||||
*/
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
int PushComponentOfType(Nz::LuaInstance& lua, BaseComponent& component)
|
int LuaBinding::PushComponentOfType(Nz::LuaInstance& lua, BaseComponent& component)
|
||||||
{
|
{
|
||||||
static_assert(std::is_base_of<BaseComponent, T>::value, "ComponentType must inherit BaseComponent");
|
static_assert(std::is_base_of<BaseComponent, T>::value, "ComponentType must inherit BaseComponent");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NDK_LUABINDING_AUDIO_HPP
|
||||||
|
#define NDK_LUABINDING_AUDIO_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Audio/Music.hpp>
|
||||||
|
#include <Nazara/Audio/Sound.hpp>
|
||||||
|
#include <Nazara/Audio/SoundBuffer.hpp>
|
||||||
|
#include <Nazara/Audio/SoundEmitter.hpp>
|
||||||
|
#include <NDK/LuaBinding_Base.hpp>
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
class NDK_API LuaBinding_Audio : public LuaBinding_Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LuaBinding_Audio(LuaBinding& binding);
|
||||||
|
~LuaBinding_Audio() = default;
|
||||||
|
|
||||||
|
void Register(Nz::LuaInstance& instance) override;
|
||||||
|
|
||||||
|
Nz::LuaClass<Nz::Music> music;
|
||||||
|
Nz::LuaClass<Nz::Sound> sound;
|
||||||
|
Nz::LuaClass<Nz::SoundBufferRef> soundBuffer;
|
||||||
|
Nz::LuaClass<Nz::SoundEmitter> soundEmitter;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // NDK_LUABINDING_CORE_HPP
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NDK_LUABINDING_BASE_HPP
|
||||||
|
#define NDK_LUABINDING_BASE_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Lua/LuaClass.hpp>
|
||||||
|
#include <Nazara/Lua/LuaInstance.hpp>
|
||||||
|
#include <NDK/Prerequesites.hpp>
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
class LuaBinding;
|
||||||
|
|
||||||
|
class LuaBinding_Audio;
|
||||||
|
class LuaBinding_Core;
|
||||||
|
class LuaBinding_Graphics;
|
||||||
|
class LuaBinding_Math;
|
||||||
|
class LuaBinding_Network;
|
||||||
|
class LuaBinding_Renderer;
|
||||||
|
class LuaBinding_SDK;
|
||||||
|
class LuaBinding_Utility;
|
||||||
|
|
||||||
|
class NDK_API LuaBinding_Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LuaBinding_Base(LuaBinding& binding);
|
||||||
|
virtual ~LuaBinding_Base();
|
||||||
|
|
||||||
|
virtual void Register(Nz::LuaInstance& instance) = 0;
|
||||||
|
|
||||||
|
// Implementation lies in the respective .cpp files (still searching for a cleaner way..)
|
||||||
|
static std::unique_ptr<LuaBinding_Base> BindCore(LuaBinding& binding);
|
||||||
|
static std::unique_ptr<LuaBinding_Base> BindMath(LuaBinding& binding);
|
||||||
|
static std::unique_ptr<LuaBinding_Base> BindNetwork(LuaBinding& binding);
|
||||||
|
static std::unique_ptr<LuaBinding_Base> BindSDK(LuaBinding& binding);
|
||||||
|
static std::unique_ptr<LuaBinding_Base> BindUtility(LuaBinding& binding);
|
||||||
|
|
||||||
|
#ifndef NDK_SERVER
|
||||||
|
static std::unique_ptr<LuaBinding_Base> BindAudio(LuaBinding& binding);
|
||||||
|
static std::unique_ptr<LuaBinding_Base> BindGraphics(LuaBinding& binding);
|
||||||
|
static std::unique_ptr<LuaBinding_Base> BindRenderer(LuaBinding& binding);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
protected:
|
||||||
|
LuaBinding& m_binding;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // NDK_LUABINDING_BASE_HPP
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NDK_LUABINDING_CORE_HPP
|
||||||
|
#define NDK_LUABINDING_CORE_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Core/Clock.hpp>
|
||||||
|
#include <Nazara/Core/Directory.hpp>
|
||||||
|
#include <Nazara/Core/File.hpp>
|
||||||
|
#include <Nazara/Core/Stream.hpp>
|
||||||
|
#include <NDK/LuaBinding_Base.hpp>
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
class NDK_API LuaBinding_Core : public LuaBinding_Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LuaBinding_Core(LuaBinding& binding);
|
||||||
|
~LuaBinding_Core() = default;
|
||||||
|
|
||||||
|
void Register(Nz::LuaInstance& instance) override;
|
||||||
|
|
||||||
|
Nz::LuaClass<Nz::Clock> clock;
|
||||||
|
Nz::LuaClass<Nz::Directory> directory;
|
||||||
|
Nz::LuaClass<Nz::File> file;
|
||||||
|
Nz::LuaClass<Nz::Stream> stream;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // NDK_LUABINDING_CORE_HPP
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NDK_LUABINDING_GRAPHICS_HPP
|
||||||
|
#define NDK_LUABINDING_GRAPHICS_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Graphics/AbstractViewer.hpp>
|
||||||
|
#include <Nazara/Graphics/InstancedRenderable.hpp>
|
||||||
|
#include <Nazara/Graphics/Material.hpp>
|
||||||
|
#include <Nazara/Graphics/Model.hpp>
|
||||||
|
#include <Nazara/Graphics/Sprite.hpp>
|
||||||
|
#include <NDK/LuaBinding_Base.hpp>
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
class NDK_API LuaBinding_Graphics : public LuaBinding_Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LuaBinding_Graphics(LuaBinding& binding);
|
||||||
|
~LuaBinding_Graphics() = default;
|
||||||
|
|
||||||
|
void Register(Nz::LuaInstance& instance) override;
|
||||||
|
|
||||||
|
Nz::LuaClass<Nz::AbstractViewer> abstractViewer;
|
||||||
|
Nz::LuaClass<Nz::InstancedRenderableRef> instancedRenderable;
|
||||||
|
Nz::LuaClass<Nz::MaterialRef> material;
|
||||||
|
Nz::LuaClass<Nz::ModelRef> model;
|
||||||
|
Nz::LuaClass<Nz::SpriteRef> sprite;
|
||||||
|
Nz::LuaClass<Nz::SpriteLibrary> spriteLibrary;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // NDK_LUABINDING_GRAPHICS_HPP
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NDK_LUABINDING_MATH_HPP
|
||||||
|
#define NDK_LUABINDING_MATH_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Math/EulerAngles.hpp>
|
||||||
|
#include <Nazara/Math/Matrix4.hpp>
|
||||||
|
#include <Nazara/Math/Quaternion.hpp>
|
||||||
|
#include <Nazara/Math/Rect.hpp>
|
||||||
|
#include <Nazara/Math/Vector2.hpp>
|
||||||
|
#include <Nazara/Math/Vector3.hpp>
|
||||||
|
#include <NDK/LuaBinding_Base.hpp>
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
class NDK_API LuaBinding_Math : public LuaBinding_Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LuaBinding_Math(LuaBinding& binding);
|
||||||
|
~LuaBinding_Math() = default;
|
||||||
|
|
||||||
|
void Register(Nz::LuaInstance& instance) override;
|
||||||
|
|
||||||
|
Nz::LuaClass<Nz::EulerAnglesd> eulerAngles;
|
||||||
|
Nz::LuaClass<Nz::Matrix4d> matrix4d;
|
||||||
|
Nz::LuaClass<Nz::Quaterniond> quaternion;
|
||||||
|
Nz::LuaClass<Nz::Rectd> rect;
|
||||||
|
Nz::LuaClass<Nz::Vector2d> vector2d;
|
||||||
|
Nz::LuaClass<Nz::Vector3d> vector3d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // NDK_LUABINDING_MATH_HPP
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NDK_LUABINDING_NETWORK_HPP
|
||||||
|
#define NDK_LUABINDING_NETWORK_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Network/AbstractSocket.hpp>
|
||||||
|
#include <Nazara/Network/IpAddress.hpp>
|
||||||
|
#include <NDK/LuaBinding_Base.hpp>
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
class NDK_API LuaBinding_Network : public LuaBinding_Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LuaBinding_Network(LuaBinding& binding);
|
||||||
|
~LuaBinding_Network() = default;
|
||||||
|
|
||||||
|
void Register(Nz::LuaInstance& instance) override;
|
||||||
|
|
||||||
|
Nz::LuaClass<Nz::AbstractSocket> abstractSocket;
|
||||||
|
Nz::LuaClass<Nz::IpAddress> ipAddress;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // NDK_LUABINDING_NETWORK_HPP
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NDK_LUABINDING_RENDERER_HPP
|
||||||
|
#define NDK_LUABINDING_RENDERER_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Renderer/Texture.hpp>
|
||||||
|
#include <NDK/LuaBinding_Base.hpp>
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
class NDK_API LuaBinding_Renderer : public LuaBinding_Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LuaBinding_Renderer(LuaBinding& binding);
|
||||||
|
~LuaBinding_Renderer() = default;
|
||||||
|
|
||||||
|
void Register(Nz::LuaInstance& instance) override;
|
||||||
|
|
||||||
|
Nz::LuaClass<Nz::TextureRef> texture;
|
||||||
|
Nz::LuaClass<Nz::TextureLibrary> textureLibrary;
|
||||||
|
Nz::LuaClass<Nz::TextureManager> textureManager;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // NDK_LUABINDING_RENDERER_HPP
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NDK_LUABINDING_SDK_HPP
|
||||||
|
#define NDK_LUABINDING_SDK_HPP
|
||||||
|
|
||||||
|
#include <NDK/LuaBinding_Base.hpp>
|
||||||
|
#include <NDK/Components.hpp>
|
||||||
|
#include <NDK/Console.hpp>
|
||||||
|
#include <NDK/Entity.hpp>
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
class Application;
|
||||||
|
|
||||||
|
class NDK_API LuaBinding_SDK : public LuaBinding_Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LuaBinding_SDK(LuaBinding& binding);
|
||||||
|
~LuaBinding_SDK() = default;
|
||||||
|
|
||||||
|
void Register(Nz::LuaInstance& instance) override;
|
||||||
|
|
||||||
|
Nz::LuaClass<Application*> application;
|
||||||
|
Nz::LuaClass<EntityHandle> entity;
|
||||||
|
Nz::LuaClass<NodeComponentHandle> nodeComponent;
|
||||||
|
Nz::LuaClass<VelocityComponentHandle> velocityComponent;
|
||||||
|
Nz::LuaClass<WorldHandle> world;
|
||||||
|
|
||||||
|
#ifndef NDK_SERVER
|
||||||
|
Nz::LuaClass<CameraComponentHandle> cameraComponent;
|
||||||
|
Nz::LuaClass<ConsoleHandle> console;
|
||||||
|
Nz::LuaClass<GraphicsComponentHandle> graphicsComponent;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // NDK_LUABINDING_SDK_HPP
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NDK_LUABINDING_UTILITY_HPP
|
||||||
|
#define NDK_LUABINDING_UTILITY_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Utility/AbstractImage.hpp>
|
||||||
|
#include <Nazara/Utility/Font.hpp>
|
||||||
|
#include <Nazara/Utility/Keyboard.hpp>
|
||||||
|
#include <Nazara/Utility/Node.hpp>
|
||||||
|
#include <NDK/LuaBinding_Base.hpp>
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
class NDK_API LuaBinding_Utility : public LuaBinding_Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LuaBinding_Utility(LuaBinding& binding);
|
||||||
|
~LuaBinding_Utility() = default;
|
||||||
|
|
||||||
|
void Register(Nz::LuaInstance& instance) override;
|
||||||
|
|
||||||
|
// Utility
|
||||||
|
Nz::LuaClass<Nz::AbstractImageRef> abstractImage;
|
||||||
|
Nz::LuaClass<Nz::FontRef> font;
|
||||||
|
Nz::LuaClass<Nz::Keyboard> keyboard;
|
||||||
|
Nz::LuaClass<Nz::Node> node;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // NDK_LUABINDING_UTILITY_HPP
|
||||||
|
|
@ -14,76 +14,18 @@ namespace Ndk
|
||||||
* \brief Binds modules to Lua
|
* \brief Binds modules to Lua
|
||||||
*/
|
*/
|
||||||
|
|
||||||
LuaBinding::LuaBinding() :
|
LuaBinding::LuaBinding()
|
||||||
// Core
|
|
||||||
clock("Clock"),
|
|
||||||
directory("Directory"),
|
|
||||||
file("File"),
|
|
||||||
stream("Stream"),
|
|
||||||
|
|
||||||
// Math
|
|
||||||
eulerAngles("EulerAngles"),
|
|
||||||
matrix4d("Matrix4"),
|
|
||||||
quaternion("Quaternion"),
|
|
||||||
rect("Rect"),
|
|
||||||
vector2d("Vector2"),
|
|
||||||
vector3d("Vector3"),
|
|
||||||
|
|
||||||
// Network
|
|
||||||
abstractSocket("AbstractSocket"),
|
|
||||||
ipAddress("IpAddress"),
|
|
||||||
|
|
||||||
// Utility
|
|
||||||
abstractImage("AbstractImage"),
|
|
||||||
font("Font"),
|
|
||||||
keyboard("Keyboard"),
|
|
||||||
node("Node"),
|
|
||||||
|
|
||||||
// SDK
|
|
||||||
application("Application"),
|
|
||||||
entity("Entity"),
|
|
||||||
nodeComponent("NodeComponent"),
|
|
||||||
velocityComponent("VelocityComponent"),
|
|
||||||
world("World")
|
|
||||||
|
|
||||||
#ifndef NDK_SERVER
|
|
||||||
,
|
|
||||||
|
|
||||||
// Audio
|
|
||||||
music("Music"),
|
|
||||||
sound("Sound"),
|
|
||||||
soundBuffer("SoundBuffer"),
|
|
||||||
soundEmitter("SoundEmitter"),
|
|
||||||
|
|
||||||
// Graphics
|
|
||||||
abstractViewer("AbstractViewer"),
|
|
||||||
instancedRenderable("InstancedRenderable"),
|
|
||||||
material("Material"),
|
|
||||||
model("Model"),
|
|
||||||
sprite("Sprite"),
|
|
||||||
spriteLibrary("SpriteLibrary"),
|
|
||||||
textureLibrary("TextureLibrary"),
|
|
||||||
textureManager("TextureManager"),
|
|
||||||
|
|
||||||
// Renderer
|
|
||||||
texture("Texture"),
|
|
||||||
|
|
||||||
// SDK
|
|
||||||
cameraComponent("CameraComponent"),
|
|
||||||
console("Console"),
|
|
||||||
graphicsComponent("GraphicsComponent")
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
BindCore();
|
core = LuaBinding_Base::BindCore(*this);
|
||||||
BindMath();
|
math = LuaBinding_Base::BindMath(*this);
|
||||||
BindNetwork();
|
network = LuaBinding_Base::BindNetwork(*this);
|
||||||
BindSDK();
|
sdk = LuaBinding_Base::BindSDK(*this);
|
||||||
BindUtility();
|
utility = LuaBinding_Base::BindUtility(*this);
|
||||||
|
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
BindAudio();
|
audio = LuaBinding_Base::BindAudio(*this);
|
||||||
BindGraphics();
|
graphics = LuaBinding_Base::BindGraphics(*this);
|
||||||
BindRenderer();
|
renderer = LuaBinding_Base::BindRenderer(*this);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,16 +37,29 @@ namespace Ndk
|
||||||
|
|
||||||
void LuaBinding::RegisterClasses(Nz::LuaInstance& instance)
|
void LuaBinding::RegisterClasses(Nz::LuaInstance& instance)
|
||||||
{
|
{
|
||||||
RegisterCore(instance);
|
core->Register(instance);
|
||||||
RegisterMath(instance);
|
math->Register(instance);
|
||||||
RegisterNetwork(instance);
|
network->Register(instance);
|
||||||
RegisterSDK(instance);
|
sdk->Register(instance);
|
||||||
RegisterUtility(instance);
|
utility->Register(instance);
|
||||||
|
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
RegisterAudio(instance);
|
audio->Register(instance);
|
||||||
RegisterGraphics(instance);
|
graphics->Register(instance);
|
||||||
RegisterRenderer(instance);
|
renderer->Register(instance);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ComponentType (fake enumeration to expose component indexes)
|
||||||
|
instance.PushTable(0, m_componentBinding.size());
|
||||||
|
{
|
||||||
|
for (const ComponentBinding& entry : m_componentBinding)
|
||||||
|
{
|
||||||
|
if (entry.name.IsEmpty())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
instance.PushField(entry.name, entry.index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
instance.SetGlobal("ComponentType");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,172 +1,186 @@
|
||||||
// This file was automatically generated on 26 May 2014 at 01:05:31
|
// This file was automatically generated on 26 May 2014 at 01:05:31
|
||||||
|
|
||||||
#include <NDK/LuaBinding.hpp>
|
#include <NDK/LuaBinding_Audio.hpp>
|
||||||
#include <Nazara/Core/MemoryHelper.hpp>
|
#include <Nazara/Core/MemoryHelper.hpp>
|
||||||
#include <NDK/LuaAPI.hpp>
|
#include <NDK/LuaAPI.hpp>
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
/*!
|
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindAudio(LuaBinding& binding)
|
||||||
* \brief Binds Audio module to Lua
|
{
|
||||||
*/
|
return std::make_unique<LuaBinding_Audio>(binding);
|
||||||
|
}
|
||||||
|
|
||||||
void LuaBinding::BindAudio()
|
LuaBinding_Audio::LuaBinding_Audio(LuaBinding& binding) :
|
||||||
|
LuaBinding_Base(binding)
|
||||||
{
|
{
|
||||||
/*********************************** Nz::Music **********************************/
|
/*********************************** Nz::Music **********************************/
|
||||||
music.Inherit(soundEmitter);
|
music.Reset("Music");
|
||||||
|
|
||||||
music.BindDefaultConstructor();
|
|
||||||
|
|
||||||
//musicClass.SetMethod("Create", &Nz::Music::Create);
|
|
||||||
//musicClass.SetMethod("Destroy", &Nz::Music::Destroy);
|
|
||||||
|
|
||||||
music.BindMethod("EnableLooping", &Nz::Music::EnableLooping);
|
|
||||||
|
|
||||||
music.BindMethod("GetDuration", &Nz::Music::GetDuration);
|
|
||||||
music.BindMethod("GetFormat", &Nz::Music::GetFormat);
|
|
||||||
music.BindMethod("GetPlayingOffset", &Nz::Music::GetPlayingOffset);
|
|
||||||
music.BindMethod("GetSampleCount", &Nz::Music::GetSampleCount);
|
|
||||||
music.BindMethod("GetSampleRate", &Nz::Music::GetSampleRate);
|
|
||||||
music.BindMethod("GetStatus", &Nz::Music::GetStatus);
|
|
||||||
|
|
||||||
music.BindMethod("IsLooping", &Nz::Music::IsLooping);
|
|
||||||
|
|
||||||
music.BindMethod("OpenFromFile", &Nz::Music::OpenFromFile, Nz::MusicParams());
|
|
||||||
|
|
||||||
music.BindMethod("Pause", &Nz::Music::Pause);
|
|
||||||
music.BindMethod("Play", &Nz::Music::Play);
|
|
||||||
|
|
||||||
music.BindMethod("SetPlayingOffset", &Nz::Music::SetPlayingOffset);
|
|
||||||
|
|
||||||
music.BindMethod("Stop", &Nz::Music::Stop);
|
|
||||||
|
|
||||||
// Manual
|
|
||||||
music.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Music& instance, std::size_t /*argumentCount*/) -> int
|
|
||||||
{
|
{
|
||||||
Nz::StringStream ss("Music(");
|
music.Inherit(soundEmitter);
|
||||||
ss << instance.GetFilePath() << ')';
|
|
||||||
|
|
||||||
lua.PushString(ss);
|
music.BindDefaultConstructor();
|
||||||
return 1;
|
|
||||||
});
|
//musicClass.SetMethod("Create", &Nz::Music::Create);
|
||||||
|
//musicClass.SetMethod("Destroy", &Nz::Music::Destroy);
|
||||||
|
|
||||||
|
music.BindMethod("EnableLooping", &Nz::Music::EnableLooping);
|
||||||
|
|
||||||
|
music.BindMethod("GetDuration", &Nz::Music::GetDuration);
|
||||||
|
music.BindMethod("GetFormat", &Nz::Music::GetFormat);
|
||||||
|
music.BindMethod("GetPlayingOffset", &Nz::Music::GetPlayingOffset);
|
||||||
|
music.BindMethod("GetSampleCount", &Nz::Music::GetSampleCount);
|
||||||
|
music.BindMethod("GetSampleRate", &Nz::Music::GetSampleRate);
|
||||||
|
music.BindMethod("GetStatus", &Nz::Music::GetStatus);
|
||||||
|
|
||||||
|
music.BindMethod("IsLooping", &Nz::Music::IsLooping);
|
||||||
|
|
||||||
|
music.BindMethod("OpenFromFile", &Nz::Music::OpenFromFile, Nz::MusicParams());
|
||||||
|
|
||||||
|
music.BindMethod("Pause", &Nz::Music::Pause);
|
||||||
|
music.BindMethod("Play", &Nz::Music::Play);
|
||||||
|
|
||||||
|
music.BindMethod("SetPlayingOffset", &Nz::Music::SetPlayingOffset);
|
||||||
|
|
||||||
|
music.BindMethod("Stop", &Nz::Music::Stop);
|
||||||
|
|
||||||
|
// Manual
|
||||||
|
music.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Music& instance, std::size_t /*argumentCount*/) -> int
|
||||||
|
{
|
||||||
|
Nz::StringStream ss("Music(");
|
||||||
|
ss << instance.GetFilePath() << ')';
|
||||||
|
|
||||||
|
lua.PushString(ss);
|
||||||
|
return 1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************** Nz::Sound **********************************/
|
/*********************************** Nz::Sound **********************************/
|
||||||
sound.Inherit(soundEmitter);
|
sound.Reset("Sound");
|
||||||
|
|
||||||
sound.BindDefaultConstructor();
|
|
||||||
|
|
||||||
sound.BindMethod("GetBuffer", &Nz::Sound::GetBuffer);
|
|
||||||
|
|
||||||
sound.BindMethod("IsPlayable", &Nz::Sound::IsPlayable);
|
|
||||||
sound.BindMethod("IsPlaying", &Nz::Sound::IsPlaying);
|
|
||||||
|
|
||||||
sound.BindMethod("LoadFromFile", &Nz::Sound::LoadFromFile, Nz::SoundBufferParams());
|
|
||||||
|
|
||||||
sound.BindMethod("SetPlayingOffset", &Nz::Sound::SetPlayingOffset);
|
|
||||||
|
|
||||||
// Manual
|
|
||||||
sound.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Sound& instance, std::size_t /*argumentCount*/) -> int
|
|
||||||
{
|
{
|
||||||
Nz::StringStream ss("Sound(");
|
sound.Inherit(soundEmitter);
|
||||||
if (const Nz::SoundBuffer* buffer = instance.GetBuffer())
|
|
||||||
ss << buffer;
|
|
||||||
|
|
||||||
ss << ')';
|
sound.BindDefaultConstructor();
|
||||||
|
|
||||||
lua.PushString(ss);
|
sound.BindMethod("GetBuffer", &Nz::Sound::GetBuffer);
|
||||||
return 1;
|
|
||||||
});
|
sound.BindMethod("IsPlayable", &Nz::Sound::IsPlayable);
|
||||||
|
sound.BindMethod("IsPlaying", &Nz::Sound::IsPlaying);
|
||||||
|
|
||||||
|
sound.BindMethod("LoadFromFile", &Nz::Sound::LoadFromFile, Nz::SoundBufferParams());
|
||||||
|
|
||||||
|
sound.BindMethod("SetPlayingOffset", &Nz::Sound::SetPlayingOffset);
|
||||||
|
|
||||||
|
// Manual
|
||||||
|
sound.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Sound& instance, std::size_t /*argumentCount*/) -> int
|
||||||
|
{
|
||||||
|
Nz::StringStream ss("Sound(");
|
||||||
|
if (const Nz::SoundBuffer* buffer = instance.GetBuffer())
|
||||||
|
ss << buffer;
|
||||||
|
|
||||||
|
ss << ')';
|
||||||
|
|
||||||
|
lua.PushString(ss);
|
||||||
|
return 1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************** Nz::SoundBuffer **********************************/
|
/*********************************** Nz::SoundBuffer **********************************/
|
||||||
soundBuffer.SetConstructor([] (Nz::LuaInstance& lua, Nz::SoundBufferRef* instance, std::size_t argumentCount)
|
soundBuffer.Reset("SoundBuffer");
|
||||||
{
|
{
|
||||||
NazaraUnused(lua);
|
soundBuffer.SetConstructor([] (Nz::LuaInstance& lua, Nz::SoundBufferRef* instance, std::size_t argumentCount)
|
||||||
NazaraUnused(argumentCount);
|
|
||||||
|
|
||||||
Nz::PlacementNew(instance, Nz::SoundBuffer::New());
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
soundBuffer.BindMethod("Destroy", &Nz::SoundBuffer::Destroy);
|
|
||||||
|
|
||||||
soundBuffer.BindMethod("GetDuration", &Nz::SoundBuffer::GetDuration);
|
|
||||||
soundBuffer.BindMethod("GetFormat", &Nz::SoundBuffer::GetFormat);
|
|
||||||
soundBuffer.BindMethod("GetSampleCount", &Nz::SoundBuffer::GetSampleCount);
|
|
||||||
soundBuffer.BindMethod("GetSampleRate", &Nz::SoundBuffer::GetSampleRate);
|
|
||||||
|
|
||||||
soundBuffer.BindMethod("IsValid", &Nz::SoundBuffer::IsValid);
|
|
||||||
|
|
||||||
soundBuffer.BindMethod("LoadFromFile", &Nz::SoundBuffer::LoadFromFile, Nz::SoundBufferParams());
|
|
||||||
|
|
||||||
soundBuffer.BindStaticMethod("IsFormatSupported", &Nz::SoundBuffer::IsFormatSupported);
|
|
||||||
|
|
||||||
// Manual
|
|
||||||
soundBuffer.BindMethod("Create", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance, std::size_t /*argumentCount*/) -> int
|
|
||||||
{
|
|
||||||
int index = 2;
|
|
||||||
Nz::AudioFormat format = lua.Check<Nz::AudioFormat>(&index);
|
|
||||||
unsigned int sampleCount = lua.Check<unsigned int>(&index);
|
|
||||||
unsigned int sampleRate = lua.Check<unsigned int>(&index);
|
|
||||||
|
|
||||||
std::size_t bufferSize = 0;
|
|
||||||
const char* buffer = lua.CheckString(index, &bufferSize);
|
|
||||||
lua.ArgCheck(buffer && bufferSize >= sampleCount * sizeof(Nz::Int16), index, "Invalid buffer");
|
|
||||||
|
|
||||||
lua.PushBoolean(instance->Create(format, sampleCount, sampleRate, reinterpret_cast<const Nz::Int16*>(buffer)));
|
|
||||||
return 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
soundBuffer.BindMethod("GetSamples", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance, std::size_t /*argumentCount*/) -> int
|
|
||||||
{
|
|
||||||
lua.PushString(reinterpret_cast<const char*>(instance->GetSamples()), instance->GetSampleCount() * sizeof(Nz::Int16));
|
|
||||||
return 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
soundBuffer.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance, std::size_t /*argumentCount*/) -> int
|
|
||||||
{
|
|
||||||
Nz::StringStream ss("SoundBuffer(");
|
|
||||||
if (instance->IsValid())
|
|
||||||
{
|
{
|
||||||
Nz::String filePath = instance->GetFilePath();
|
NazaraUnused(lua);
|
||||||
if (!filePath.IsEmpty())
|
NazaraUnused(argumentCount);
|
||||||
ss << "File: " << filePath << ", ";
|
|
||||||
|
|
||||||
ss << "Duration: " << instance->GetDuration() / 1000.f << "s";
|
Nz::PlacementNew(instance, Nz::SoundBuffer::New());
|
||||||
}
|
return true;
|
||||||
ss << ')';
|
});
|
||||||
|
|
||||||
lua.PushString(ss);
|
soundBuffer.BindMethod("Destroy", &Nz::SoundBuffer::Destroy);
|
||||||
return 1;
|
|
||||||
});
|
soundBuffer.BindMethod("GetDuration", &Nz::SoundBuffer::GetDuration);
|
||||||
|
soundBuffer.BindMethod("GetFormat", &Nz::SoundBuffer::GetFormat);
|
||||||
|
soundBuffer.BindMethod("GetSampleCount", &Nz::SoundBuffer::GetSampleCount);
|
||||||
|
soundBuffer.BindMethod("GetSampleRate", &Nz::SoundBuffer::GetSampleRate);
|
||||||
|
|
||||||
|
soundBuffer.BindMethod("IsValid", &Nz::SoundBuffer::IsValid);
|
||||||
|
|
||||||
|
soundBuffer.BindMethod("LoadFromFile", &Nz::SoundBuffer::LoadFromFile, Nz::SoundBufferParams());
|
||||||
|
|
||||||
|
soundBuffer.BindStaticMethod("IsFormatSupported", &Nz::SoundBuffer::IsFormatSupported);
|
||||||
|
|
||||||
|
// Manual
|
||||||
|
soundBuffer.BindMethod("Create", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance, std::size_t /*argumentCount*/) -> int
|
||||||
|
{
|
||||||
|
int index = 2;
|
||||||
|
Nz::AudioFormat format = lua.Check<Nz::AudioFormat>(&index);
|
||||||
|
unsigned int sampleCount = lua.Check<unsigned int>(&index);
|
||||||
|
unsigned int sampleRate = lua.Check<unsigned int>(&index);
|
||||||
|
|
||||||
|
std::size_t bufferSize = 0;
|
||||||
|
const char* buffer = lua.CheckString(index, &bufferSize);
|
||||||
|
lua.ArgCheck(buffer && bufferSize >= sampleCount * sizeof(Nz::Int16), index, "Invalid buffer");
|
||||||
|
|
||||||
|
lua.PushBoolean(instance->Create(format, sampleCount, sampleRate, reinterpret_cast<const Nz::Int16*>(buffer)));
|
||||||
|
return 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
soundBuffer.BindMethod("GetSamples", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance, std::size_t /*argumentCount*/) -> int
|
||||||
|
{
|
||||||
|
lua.PushString(reinterpret_cast<const char*>(instance->GetSamples()), instance->GetSampleCount() * sizeof(Nz::Int16));
|
||||||
|
return 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
soundBuffer.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance, std::size_t /*argumentCount*/) -> int
|
||||||
|
{
|
||||||
|
Nz::StringStream ss("SoundBuffer(");
|
||||||
|
if (instance->IsValid())
|
||||||
|
{
|
||||||
|
Nz::String filePath = instance->GetFilePath();
|
||||||
|
if (!filePath.IsEmpty())
|
||||||
|
ss << "File: " << filePath << ", ";
|
||||||
|
|
||||||
|
ss << "Duration: " << instance->GetDuration() / 1000.f << "s";
|
||||||
|
}
|
||||||
|
ss << ')';
|
||||||
|
|
||||||
|
lua.PushString(ss);
|
||||||
|
return 1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************** Nz::SoundEmitter **********************************/
|
/*********************************** Nz::SoundEmitter **********************************/
|
||||||
soundEmitter.BindMethod("EnableLooping", &Nz::SoundEmitter::EnableLooping);
|
soundEmitter.Reset("SoundEmitter");
|
||||||
soundEmitter.BindMethod("EnableSpatialization", &Nz::SoundEmitter::EnableSpatialization);
|
{
|
||||||
|
soundEmitter.BindMethod("EnableLooping", &Nz::SoundEmitter::EnableLooping);
|
||||||
|
soundEmitter.BindMethod("EnableSpatialization", &Nz::SoundEmitter::EnableSpatialization);
|
||||||
|
|
||||||
soundEmitter.BindMethod("GetAttenuation", &Nz::SoundEmitter::GetAttenuation);
|
soundEmitter.BindMethod("GetAttenuation", &Nz::SoundEmitter::GetAttenuation);
|
||||||
soundEmitter.BindMethod("GetDuration", &Nz::SoundEmitter::GetDuration);
|
soundEmitter.BindMethod("GetDuration", &Nz::SoundEmitter::GetDuration);
|
||||||
soundEmitter.BindMethod("GetMinDistance", &Nz::SoundEmitter::GetMinDistance);
|
soundEmitter.BindMethod("GetMinDistance", &Nz::SoundEmitter::GetMinDistance);
|
||||||
soundEmitter.BindMethod("GetPitch", &Nz::SoundEmitter::GetPitch);
|
soundEmitter.BindMethod("GetPitch", &Nz::SoundEmitter::GetPitch);
|
||||||
soundEmitter.BindMethod("GetPlayingOffset", &Nz::SoundEmitter::GetPlayingOffset);
|
soundEmitter.BindMethod("GetPlayingOffset", &Nz::SoundEmitter::GetPlayingOffset);
|
||||||
soundEmitter.BindMethod("GetPosition", &Nz::Sound::GetPosition);
|
soundEmitter.BindMethod("GetPosition", &Nz::Sound::GetPosition);
|
||||||
soundEmitter.BindMethod("GetStatus", &Nz::SoundEmitter::GetStatus);
|
soundEmitter.BindMethod("GetStatus", &Nz::SoundEmitter::GetStatus);
|
||||||
soundEmitter.BindMethod("GetVelocity", &Nz::Sound::GetVelocity);
|
soundEmitter.BindMethod("GetVelocity", &Nz::Sound::GetVelocity);
|
||||||
soundEmitter.BindMethod("GetVolume", &Nz::SoundEmitter::GetVolume);
|
soundEmitter.BindMethod("GetVolume", &Nz::SoundEmitter::GetVolume);
|
||||||
|
|
||||||
soundEmitter.BindMethod("IsLooping", &Nz::SoundEmitter::IsLooping);
|
soundEmitter.BindMethod("IsLooping", &Nz::SoundEmitter::IsLooping);
|
||||||
soundEmitter.BindMethod("IsSpatialized", &Nz::SoundEmitter::IsSpatialized);
|
soundEmitter.BindMethod("IsSpatialized", &Nz::SoundEmitter::IsSpatialized);
|
||||||
|
|
||||||
soundEmitter.BindMethod("Pause", &Nz::SoundEmitter::Pause);
|
soundEmitter.BindMethod("Pause", &Nz::SoundEmitter::Pause);
|
||||||
soundEmitter.BindMethod("Play", &Nz::SoundEmitter::Play);
|
soundEmitter.BindMethod("Play", &Nz::SoundEmitter::Play);
|
||||||
|
|
||||||
soundEmitter.BindMethod("SetAttenuation", &Nz::SoundEmitter::SetAttenuation);
|
soundEmitter.BindMethod("SetAttenuation", &Nz::SoundEmitter::SetAttenuation);
|
||||||
soundEmitter.BindMethod("SetMinDistance", &Nz::SoundEmitter::SetMinDistance);
|
soundEmitter.BindMethod("SetMinDistance", &Nz::SoundEmitter::SetMinDistance);
|
||||||
soundEmitter.BindMethod("SetPitch", &Nz::SoundEmitter::SetPitch);
|
soundEmitter.BindMethod("SetPitch", &Nz::SoundEmitter::SetPitch);
|
||||||
soundEmitter.BindMethod("SetPosition", (void(Nz::SoundEmitter::*)(const Nz::Vector3f&)) &Nz::SoundEmitter::SetPosition);
|
soundEmitter.BindMethod("SetPosition", (void(Nz::SoundEmitter::*)(const Nz::Vector3f&)) &Nz::SoundEmitter::SetPosition);
|
||||||
soundEmitter.BindMethod("SetVelocity", (void(Nz::SoundEmitter::*)(const Nz::Vector3f&)) &Nz::SoundEmitter::SetVelocity);
|
soundEmitter.BindMethod("SetVelocity", (void(Nz::SoundEmitter::*)(const Nz::Vector3f&)) &Nz::SoundEmitter::SetVelocity);
|
||||||
soundEmitter.BindMethod("SetVolume", &Nz::SoundEmitter::SetVolume);
|
soundEmitter.BindMethod("SetVolume", &Nz::SoundEmitter::SetVolume);
|
||||||
|
|
||||||
soundEmitter.BindMethod("Stop", &Nz::SoundEmitter::Stop);
|
soundEmitter.BindMethod("Stop", &Nz::SoundEmitter::Stop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -174,8 +188,7 @@ namespace Ndk
|
||||||
*
|
*
|
||||||
* \param instance Lua instance that will interact with the Audio classes
|
* \param instance Lua instance that will interact with the Audio classes
|
||||||
*/
|
*/
|
||||||
|
void LuaBinding_Audio::Register(Nz::LuaInstance& instance)
|
||||||
void LuaBinding::RegisterAudio(Nz::LuaInstance& instance)
|
|
||||||
{
|
{
|
||||||
music.Register(instance);
|
music.Register(instance);
|
||||||
sound.Register(instance);
|
sound.Register(instance);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
// This file was automatically generated on 26 May 2014 at 01:05:31
|
||||||
|
|
||||||
|
#include <NDK/LuaBinding_Base.hpp>
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
LuaBinding_Base::LuaBinding_Base(LuaBinding& binding) :
|
||||||
|
m_binding(binding)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
LuaBinding_Base::~LuaBinding_Base() = default;
|
||||||
|
}
|
||||||
|
|
@ -1,284 +1,298 @@
|
||||||
// This file was automatically generated on 26 May 2014 at 01:05:31
|
// This file was automatically generated on 26 May 2014 at 01:05:31
|
||||||
|
|
||||||
#include <NDK/LuaBinding.hpp>
|
#include <NDK/LuaBinding_Core.hpp>
|
||||||
#include <Nazara/Core/MemoryHelper.hpp>
|
#include <Nazara/Core/MemoryHelper.hpp>
|
||||||
#include <NDK/LuaAPI.hpp>
|
#include <NDK/LuaAPI.hpp>
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
/*!
|
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindCore(LuaBinding& binding)
|
||||||
* \brief Binds Core module to Lua
|
{
|
||||||
*/
|
return std::make_unique<LuaBinding_Core>(binding);
|
||||||
|
}
|
||||||
|
|
||||||
void LuaBinding::BindCore()
|
LuaBinding_Core::LuaBinding_Core(LuaBinding& binding) :
|
||||||
|
LuaBinding_Base(binding)
|
||||||
{
|
{
|
||||||
/*********************************** Nz::Clock **********************************/
|
/*********************************** Nz::Clock **********************************/
|
||||||
clock.SetConstructor([](Nz::LuaInstance& lua, Nz::Clock* instance, std::size_t argumentCount)
|
clock.Reset("Clock");
|
||||||
{
|
{
|
||||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 2U);
|
clock.SetConstructor([] (Nz::LuaInstance& lua, Nz::Clock* instance, std::size_t argumentCount)
|
||||||
|
|
||||||
int argIndex = 2;
|
|
||||||
switch (argCount)
|
|
||||||
{
|
{
|
||||||
case 0:
|
std::size_t argCount = std::min<std::size_t>(argumentCount, 2U);
|
||||||
Nz::PlacementNew(instance);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 1:
|
int argIndex = 2;
|
||||||
|
switch (argCount)
|
||||||
{
|
{
|
||||||
Nz::Int64 startingValue = lua.Check<Nz::Int64>(&argIndex, 0);
|
case 0:
|
||||||
|
Nz::PlacementNew(instance);
|
||||||
|
return true;
|
||||||
|
|
||||||
Nz::PlacementNew(instance, startingValue);
|
case 1:
|
||||||
return true;
|
{
|
||||||
|
Nz::Int64 startingValue = lua.Check<Nz::Int64>(&argIndex, 0);
|
||||||
|
|
||||||
|
Nz::PlacementNew(instance, startingValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
Nz::Int64 startingValue = lua.Check<Nz::Int64>(&argIndex, 0);
|
||||||
|
bool paused = lua.Check<bool>(&argIndex, false);
|
||||||
|
|
||||||
|
Nz::PlacementNew(instance, startingValue, paused);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case 2:
|
lua.Error("No matching overload for Clock constructor");
|
||||||
{
|
return false;
|
||||||
Nz::Int64 startingValue = lua.Check<Nz::Int64>(&argIndex, 0);
|
});
|
||||||
bool paused = lua.Check<bool>(&argIndex, false);
|
|
||||||
|
|
||||||
Nz::PlacementNew(instance, startingValue, paused);
|
clock.BindMethod("GetMicroseconds", &Nz::Clock::GetMicroseconds);
|
||||||
return true;
|
clock.BindMethod("GetMilliseconds", &Nz::Clock::GetMilliseconds);
|
||||||
}
|
clock.BindMethod("GetSeconds", &Nz::Clock::GetSeconds);
|
||||||
}
|
clock.BindMethod("IsPaused", &Nz::Clock::IsPaused);
|
||||||
|
clock.BindMethod("Pause", &Nz::Clock::Pause);
|
||||||
|
clock.BindMethod("Restart", &Nz::Clock::Restart);
|
||||||
|
clock.BindMethod("Unpause", &Nz::Clock::Unpause);
|
||||||
|
|
||||||
lua.Error("No matching overload for Clock constructor");
|
// Manual
|
||||||
return false;
|
clock.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Clock& instance, std::size_t /*argumentCount*/) -> int {
|
||||||
});
|
Nz::StringStream ss("Clock(Elapsed: ");
|
||||||
|
ss << instance.GetSeconds();
|
||||||
|
ss << "s, Paused: ";
|
||||||
|
ss << instance.IsPaused();
|
||||||
|
ss << ')';
|
||||||
|
|
||||||
clock.BindMethod("GetMicroseconds", &Nz::Clock::GetMicroseconds);
|
lua.PushString(ss);
|
||||||
clock.BindMethod("GetMilliseconds", &Nz::Clock::GetMilliseconds);
|
return 1;
|
||||||
clock.BindMethod("GetSeconds", &Nz::Clock::GetSeconds);
|
});
|
||||||
clock.BindMethod("IsPaused", &Nz::Clock::IsPaused);
|
}
|
||||||
clock.BindMethod("Pause", &Nz::Clock::Pause);
|
|
||||||
clock.BindMethod("Restart", &Nz::Clock::Restart);
|
|
||||||
clock.BindMethod("Unpause", &Nz::Clock::Unpause);
|
|
||||||
|
|
||||||
// Manual
|
|
||||||
clock.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Clock& instance, std::size_t /*argumentCount*/) -> int {
|
|
||||||
Nz::StringStream ss("Clock(Elapsed: ");
|
|
||||||
ss << instance.GetSeconds();
|
|
||||||
ss << "s, Paused: ";
|
|
||||||
ss << instance.IsPaused();
|
|
||||||
ss << ')';
|
|
||||||
|
|
||||||
lua.PushString(ss);
|
|
||||||
return 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
/********************************* Nz::Directory ********************************/
|
/********************************* Nz::Directory ********************************/
|
||||||
directory.SetConstructor([](Nz::LuaInstance& lua, Nz::Directory* instance, std::size_t argumentCount)
|
directory.Reset("Directory");
|
||||||
{
|
{
|
||||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 1U);
|
directory.SetConstructor([] (Nz::LuaInstance& lua, Nz::Directory* instance, std::size_t argumentCount)
|
||||||
|
|
||||||
int argIndex = 2;
|
|
||||||
switch (argCount)
|
|
||||||
{
|
{
|
||||||
case 0:
|
std::size_t argCount = std::min<std::size_t>(argumentCount, 1U);
|
||||||
Nz::PlacementNew(instance);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 1:
|
int argIndex = 2;
|
||||||
Nz::PlacementNew(instance, lua.Check<Nz::String>(&argIndex));
|
switch (argCount)
|
||||||
return true;
|
{
|
||||||
}
|
case 0:
|
||||||
|
Nz::PlacementNew(instance);
|
||||||
|
return true;
|
||||||
|
|
||||||
return false;
|
case 1:
|
||||||
});
|
Nz::PlacementNew(instance, lua.Check<Nz::String>(&argIndex));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
directory.BindMethod("Close", &Nz::Directory::Close);
|
return false;
|
||||||
directory.BindMethod("Exists", &Nz::Directory::Exists);
|
});
|
||||||
directory.BindMethod("GetPath", &Nz::Directory::GetPath);
|
|
||||||
directory.BindMethod("GetPattern", &Nz::Directory::GetPattern);
|
|
||||||
directory.BindMethod("GetResultName", &Nz::Directory::GetResultName);
|
|
||||||
directory.BindMethod("GetResultPath", &Nz::Directory::GetResultPath);
|
|
||||||
directory.BindMethod("GetResultSize", &Nz::Directory::GetResultSize);
|
|
||||||
directory.BindMethod("IsOpen", &Nz::Directory::IsOpen);
|
|
||||||
directory.BindMethod("IsResultDirectory", &Nz::Directory::IsResultDirectory);
|
|
||||||
directory.BindMethod("NextResult", &Nz::Directory::NextResult, true);
|
|
||||||
directory.BindMethod("Open", &Nz::Directory::Open);
|
|
||||||
directory.BindMethod("SetPath", &Nz::Directory::SetPath);
|
|
||||||
directory.BindMethod("SetPattern", &Nz::Directory::SetPattern);
|
|
||||||
|
|
||||||
directory.BindStaticMethod("Copy", Nz::Directory::Copy);
|
directory.BindMethod("Close", &Nz::Directory::Close);
|
||||||
directory.BindStaticMethod("Create", Nz::Directory::Create);
|
directory.BindMethod("Exists", &Nz::Directory::Exists);
|
||||||
directory.BindStaticMethod("Exists", Nz::Directory::Exists);
|
directory.BindMethod("GetPath", &Nz::Directory::GetPath);
|
||||||
directory.BindStaticMethod("GetCurrent", Nz::Directory::GetCurrent);
|
directory.BindMethod("GetPattern", &Nz::Directory::GetPattern);
|
||||||
directory.BindStaticMethod("Remove", Nz::Directory::Remove);
|
directory.BindMethod("GetResultName", &Nz::Directory::GetResultName);
|
||||||
directory.BindStaticMethod("SetCurrent", Nz::Directory::SetCurrent);
|
directory.BindMethod("GetResultPath", &Nz::Directory::GetResultPath);
|
||||||
|
directory.BindMethod("GetResultSize", &Nz::Directory::GetResultSize);
|
||||||
|
directory.BindMethod("IsOpen", &Nz::Directory::IsOpen);
|
||||||
|
directory.BindMethod("IsResultDirectory", &Nz::Directory::IsResultDirectory);
|
||||||
|
directory.BindMethod("NextResult", &Nz::Directory::NextResult, true);
|
||||||
|
directory.BindMethod("Open", &Nz::Directory::Open);
|
||||||
|
directory.BindMethod("SetPath", &Nz::Directory::SetPath);
|
||||||
|
directory.BindMethod("SetPattern", &Nz::Directory::SetPattern);
|
||||||
|
|
||||||
// Manual
|
directory.BindStaticMethod("Copy", Nz::Directory::Copy);
|
||||||
directory.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Directory& instance, std::size_t /*argumentCount*/) -> int {
|
directory.BindStaticMethod("Create", Nz::Directory::Create);
|
||||||
Nz::StringStream ss("Directory(");
|
directory.BindStaticMethod("Exists", Nz::Directory::Exists);
|
||||||
ss << instance.GetPath();
|
directory.BindStaticMethod("GetCurrent", Nz::Directory::GetCurrent);
|
||||||
ss << ')';
|
directory.BindStaticMethod("Remove", Nz::Directory::Remove);
|
||||||
|
directory.BindStaticMethod("SetCurrent", Nz::Directory::SetCurrent);
|
||||||
|
|
||||||
lua.PushString(ss);
|
// Manual
|
||||||
return 1;
|
directory.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Directory& instance, std::size_t /*argumentCount*/) -> int {
|
||||||
});
|
Nz::StringStream ss("Directory(");
|
||||||
|
ss << instance.GetPath();
|
||||||
|
ss << ')';
|
||||||
|
|
||||||
/*********************************** Nz::Stream ***********************************/
|
lua.PushString(ss);
|
||||||
stream.BindMethod("EnableTextMode", &Nz::Stream::EnableTextMode);
|
return 1;
|
||||||
stream.BindMethod("Flush", &Nz::Stream::Flush);
|
});
|
||||||
stream.BindMethod("GetCursorPos", &Nz::Stream::GetCursorPos);
|
}
|
||||||
stream.BindMethod("GetDirectory", &Nz::Stream::GetDirectory);
|
|
||||||
stream.BindMethod("GetPath", &Nz::Stream::GetPath);
|
|
||||||
stream.BindMethod("GetOpenMode", &Nz::Stream::GetOpenMode);
|
|
||||||
stream.BindMethod("GetStreamOptions", &Nz::Stream::GetStreamOptions);
|
|
||||||
stream.BindMethod("GetSize", &Nz::Stream::GetSize);
|
|
||||||
stream.BindMethod("ReadLine", &Nz::Stream::ReadLine, 0U);
|
|
||||||
stream.BindMethod("IsReadable", &Nz::Stream::IsReadable);
|
|
||||||
stream.BindMethod("IsSequential", &Nz::Stream::IsSequential);
|
|
||||||
stream.BindMethod("IsTextModeEnabled", &Nz::Stream::IsTextModeEnabled);
|
|
||||||
stream.BindMethod("IsWritable", &Nz::Stream::IsWritable);
|
|
||||||
stream.BindMethod("SetCursorPos", &Nz::Stream::SetCursorPos);
|
|
||||||
|
|
||||||
stream.BindMethod("Read", [] (Nz::LuaInstance& 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 = instance.Read(buffer.get(), length);
|
|
||||||
|
|
||||||
lua.PushString(Nz::String(buffer.get(), readLength));
|
|
||||||
return 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
stream.BindMethod("Write", [] (Nz::LuaInstance& 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 (instance.IsTextModeEnabled())
|
|
||||||
lua.Push(instance.Write(Nz::String(buffer, bufferSize)));
|
|
||||||
else
|
|
||||||
lua.Push(instance.Write(buffer, bufferSize));
|
|
||||||
return 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
/*********************************** Nz::File ***********************************/
|
/*********************************** Nz::File ***********************************/
|
||||||
file.Inherit(stream);
|
file.Reset("Stream");
|
||||||
|
|
||||||
file.SetConstructor([] (Nz::LuaInstance& lua, Nz::File* instance, std::size_t argumentCount)
|
|
||||||
{
|
{
|
||||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 1U);
|
file.Inherit(stream);
|
||||||
|
|
||||||
int argIndex = 2;
|
file.SetConstructor([] (Nz::LuaInstance& lua, Nz::File* instance, std::size_t argumentCount)
|
||||||
switch (argCount)
|
|
||||||
{
|
{
|
||||||
case 0:
|
std::size_t argCount = std::min<std::size_t>(argumentCount, 1U);
|
||||||
Nz::PlacementNew(instance);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 1:
|
int argIndex = 2;
|
||||||
|
switch (argCount)
|
||||||
{
|
{
|
||||||
Nz::String filePath = lua.Check<Nz::String>(&argIndex);
|
case 0:
|
||||||
|
Nz::PlacementNew(instance);
|
||||||
|
return true;
|
||||||
|
|
||||||
Nz::PlacementNew(instance, filePath);
|
case 1:
|
||||||
return true;
|
{
|
||||||
|
Nz::String filePath = lua.Check<Nz::String>(&argIndex);
|
||||||
|
|
||||||
|
Nz::PlacementNew(instance, filePath);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
Nz::String filePath = lua.Check<Nz::String>(&argIndex);
|
||||||
|
Nz::UInt32 openMode = lua.Check<Nz::UInt32>(&argIndex);
|
||||||
|
|
||||||
|
Nz::PlacementNew(instance, filePath, openMode);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case 2:
|
lua.Error("No matching overload for File constructor");
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
file.BindMethod("Close", &Nz::File::Close);
|
||||||
|
file.BindMethod("Copy", &Nz::File::Copy);
|
||||||
|
file.BindMethod("Delete", &Nz::File::Delete);
|
||||||
|
file.BindMethod("EndOfFile", &Nz::File::EndOfFile);
|
||||||
|
file.BindMethod("Exists", &Nz::File::Exists);
|
||||||
|
file.BindMethod("GetCreationTime", &Nz::File::GetCreationTime);
|
||||||
|
file.BindMethod("GetFileName", &Nz::File::GetFileName);
|
||||||
|
file.BindMethod("GetLastAccessTime", &Nz::File::GetLastAccessTime);
|
||||||
|
file.BindMethod("GetLastWriteTime", &Nz::File::GetLastWriteTime);
|
||||||
|
file.BindMethod("IsOpen", &Nz::File::IsOpen);
|
||||||
|
file.BindMethod("Rename", &Nz::File::GetLastWriteTime);
|
||||||
|
file.BindMethod("GetLastWriteTime", &Nz::File::GetLastWriteTime);
|
||||||
|
file.BindMethod("SetFile", &Nz::File::GetLastWriteTime);
|
||||||
|
|
||||||
|
file.BindStaticMethod("AbsolutePath", &Nz::File::AbsolutePath);
|
||||||
|
file.BindStaticMethod("ComputeHash", (Nz::ByteArray(*)(Nz::HashType, const Nz::String&)) &Nz::File::ComputeHash);
|
||||||
|
file.BindStaticMethod("Copy", &Nz::File::Copy);
|
||||||
|
file.BindStaticMethod("Delete", &Nz::File::Delete);
|
||||||
|
file.BindStaticMethod("Exists", &Nz::File::Exists);
|
||||||
|
//fileClass.SetStaticMethod("GetCreationTime", &Nz::File::GetCreationTime);
|
||||||
|
file.BindStaticMethod("GetDirectory", &Nz::File::GetDirectory);
|
||||||
|
//fileClass.SetStaticMethod("GetLastAccessTime", &Nz::File::GetLastAccessTime);
|
||||||
|
//fileClass.SetStaticMethod("GetLastWriteTime", &Nz::File::GetLastWriteTime);
|
||||||
|
file.BindStaticMethod("GetSize", &Nz::File::GetSize);
|
||||||
|
file.BindStaticMethod("IsAbsolute", &Nz::File::IsAbsolute);
|
||||||
|
file.BindStaticMethod("NormalizePath", &Nz::File::NormalizePath);
|
||||||
|
file.BindStaticMethod("NormalizeSeparators", &Nz::File::NormalizeSeparators);
|
||||||
|
file.BindStaticMethod("Rename", &Nz::File::Rename);
|
||||||
|
|
||||||
|
// Manual
|
||||||
|
file.BindMethod("Open", [] (Nz::LuaInstance& lua, Nz::File& instance, std::size_t argumentCount) -> int
|
||||||
|
{
|
||||||
|
std::size_t argCount = std::min<std::size_t>(argumentCount, 2U);
|
||||||
|
|
||||||
|
int argIndex = 2;
|
||||||
|
switch (argCount)
|
||||||
{
|
{
|
||||||
Nz::String filePath = lua.Check<Nz::String>(&argIndex);
|
case 0:
|
||||||
Nz::UInt32 openMode = lua.Check<Nz::UInt32>(&argIndex);
|
case 1:
|
||||||
|
return lua.Push(instance.Open(lua.Check<Nz::UInt32>(&argIndex, Nz::OpenMode_NotOpen)));
|
||||||
|
|
||||||
Nz::PlacementNew(instance, filePath, openMode);
|
case 2:
|
||||||
return true;
|
{
|
||||||
|
Nz::String filePath = lua.Check<Nz::String>(&argIndex);
|
||||||
|
Nz::UInt32 openMode = lua.Check<Nz::UInt32>(&argIndex, Nz::OpenMode_NotOpen);
|
||||||
|
return lua.Push(instance.Open(filePath, openMode));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
lua.Error("No matching overload for File constructor");
|
lua.Error("No matching overload for method Open");
|
||||||
return false;
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
file.BindMethod("Close", &Nz::File::Close);
|
file.BindMethod("SetCursorPos", [] (Nz::LuaInstance& lua, Nz::File& instance, std::size_t argumentCount) -> int
|
||||||
file.BindMethod("Copy", &Nz::File::Copy);
|
{
|
||||||
file.BindMethod("Delete", &Nz::File::Delete);
|
std::size_t argCount = std::min<std::size_t>(argumentCount, 2U);
|
||||||
file.BindMethod("EndOfFile", &Nz::File::EndOfFile);
|
|
||||||
file.BindMethod("Exists", &Nz::File::Exists);
|
|
||||||
file.BindMethod("GetCreationTime", &Nz::File::GetCreationTime);
|
|
||||||
file.BindMethod("GetFileName", &Nz::File::GetFileName);
|
|
||||||
file.BindMethod("GetLastAccessTime", &Nz::File::GetLastAccessTime);
|
|
||||||
file.BindMethod("GetLastWriteTime", &Nz::File::GetLastWriteTime);
|
|
||||||
file.BindMethod("IsOpen", &Nz::File::IsOpen);
|
|
||||||
file.BindMethod("Rename", &Nz::File::GetLastWriteTime);
|
|
||||||
file.BindMethod("GetLastWriteTime", &Nz::File::GetLastWriteTime);
|
|
||||||
file.BindMethod("SetFile", &Nz::File::GetLastWriteTime);
|
|
||||||
|
|
||||||
file.BindStaticMethod("AbsolutePath", &Nz::File::AbsolutePath);
|
int argIndex = 2;
|
||||||
file.BindStaticMethod("ComputeHash", (Nz::ByteArray (*)(Nz::HashType, const Nz::String&)) &Nz::File::ComputeHash);
|
switch (argCount)
|
||||||
file.BindStaticMethod("Copy", &Nz::File::Copy);
|
{
|
||||||
file.BindStaticMethod("Delete", &Nz::File::Delete);
|
case 1:
|
||||||
file.BindStaticMethod("Exists", &Nz::File::Exists);
|
return lua.Push(instance.SetCursorPos(lua.Check<Nz::UInt64>(&argIndex)));
|
||||||
//fileClass.SetStaticMethod("GetCreationTime", &Nz::File::GetCreationTime);
|
|
||||||
file.BindStaticMethod("GetDirectory", &Nz::File::GetDirectory);
|
|
||||||
//fileClass.SetStaticMethod("GetLastAccessTime", &Nz::File::GetLastAccessTime);
|
|
||||||
//fileClass.SetStaticMethod("GetLastWriteTime", &Nz::File::GetLastWriteTime);
|
|
||||||
file.BindStaticMethod("GetSize", &Nz::File::GetSize);
|
|
||||||
file.BindStaticMethod("IsAbsolute", &Nz::File::IsAbsolute);
|
|
||||||
file.BindStaticMethod("NormalizePath", &Nz::File::NormalizePath);
|
|
||||||
file.BindStaticMethod("NormalizeSeparators", &Nz::File::NormalizeSeparators);
|
|
||||||
file.BindStaticMethod("Rename", &Nz::File::Rename);
|
|
||||||
|
|
||||||
// Manual
|
case 2:
|
||||||
file.BindMethod("Open", [] (Nz::LuaInstance& lua, Nz::File& instance, std::size_t argumentCount) -> int
|
{
|
||||||
|
Nz::CursorPosition curPos = lua.Check<Nz::CursorPosition>(&argIndex);
|
||||||
|
Nz::Int64 offset = lua.Check<Nz::Int64>(&argIndex);
|
||||||
|
return lua.Push(instance.SetCursorPos(curPos, offset));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lua.Error("No matching overload for method SetCursorPos");
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
file.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::File& instance, std::size_t /*argumentCount*/) -> int {
|
||||||
|
Nz::StringStream ss("File(");
|
||||||
|
if (instance.IsOpen())
|
||||||
|
ss << "Path: " << instance.GetPath();
|
||||||
|
|
||||||
|
ss << ')';
|
||||||
|
|
||||||
|
lua.PushString(ss);
|
||||||
|
return 1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************************** Nz::Stream ***********************************/
|
||||||
|
stream.Reset("Stream");
|
||||||
{
|
{
|
||||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 2U);
|
stream.BindMethod("EnableTextMode", &Nz::Stream::EnableTextMode);
|
||||||
|
stream.BindMethod("Flush", &Nz::Stream::Flush);
|
||||||
|
stream.BindMethod("GetCursorPos", &Nz::Stream::GetCursorPos);
|
||||||
|
stream.BindMethod("GetDirectory", &Nz::Stream::GetDirectory);
|
||||||
|
stream.BindMethod("GetPath", &Nz::Stream::GetPath);
|
||||||
|
stream.BindMethod("GetOpenMode", &Nz::Stream::GetOpenMode);
|
||||||
|
stream.BindMethod("GetStreamOptions", &Nz::Stream::GetStreamOptions);
|
||||||
|
stream.BindMethod("GetSize", &Nz::Stream::GetSize);
|
||||||
|
stream.BindMethod("ReadLine", &Nz::Stream::ReadLine, 0U);
|
||||||
|
stream.BindMethod("IsReadable", &Nz::Stream::IsReadable);
|
||||||
|
stream.BindMethod("IsSequential", &Nz::Stream::IsSequential);
|
||||||
|
stream.BindMethod("IsTextModeEnabled", &Nz::Stream::IsTextModeEnabled);
|
||||||
|
stream.BindMethod("IsWritable", &Nz::Stream::IsWritable);
|
||||||
|
stream.BindMethod("SetCursorPos", &Nz::Stream::SetCursorPos);
|
||||||
|
|
||||||
int argIndex = 2;
|
stream.BindMethod("Read", [] (Nz::LuaInstance& lua, Nz::Stream& instance, std::size_t /*argumentCount*/) -> int {
|
||||||
switch (argCount)
|
int argIndex = 2;
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
return lua.Push(instance.Open(lua.Check<Nz::UInt32>(&argIndex, Nz::OpenMode_NotOpen)));
|
|
||||||
|
|
||||||
case 2:
|
std::size_t length = lua.Check<std::size_t>(&argIndex);
|
||||||
{
|
|
||||||
Nz::String filePath = lua.Check<Nz::String>(&argIndex);
|
|
||||||
Nz::UInt32 openMode = lua.Check<Nz::UInt32>(&argIndex, Nz::OpenMode_NotOpen);
|
|
||||||
return lua.Push(instance.Open(filePath, openMode));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lua.Error("No matching overload for method Open");
|
std::unique_ptr<char[]> buffer(new char[length]);
|
||||||
return 0;
|
std::size_t readLength = instance.Read(buffer.get(), length);
|
||||||
});
|
|
||||||
|
|
||||||
file.BindMethod("SetCursorPos", [] (Nz::LuaInstance& lua, Nz::File& instance, std::size_t argumentCount) -> int
|
lua.PushString(Nz::String(buffer.get(), readLength));
|
||||||
{
|
return 1;
|
||||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 2U);
|
});
|
||||||
|
|
||||||
int argIndex = 2;
|
stream.BindMethod("Write", [] (Nz::LuaInstance& lua, Nz::Stream& instance, std::size_t /*argumentCount*/) -> int {
|
||||||
switch (argCount)
|
int argIndex = 2;
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
return lua.Push(instance.SetCursorPos(lua.Check<Nz::UInt64>(&argIndex)));
|
|
||||||
|
|
||||||
case 2:
|
std::size_t bufferSize = 0;
|
||||||
{
|
const char* buffer = lua.CheckString(argIndex, &bufferSize);
|
||||||
Nz::CursorPosition curPos = lua.Check<Nz::CursorPosition>(&argIndex);
|
|
||||||
Nz::Int64 offset = lua.Check<Nz::Int64>(&argIndex);
|
|
||||||
return lua.Push(instance.SetCursorPos(curPos, offset));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lua.Error("No matching overload for method SetCursorPos");
|
if (instance.IsTextModeEnabled())
|
||||||
return 0;
|
lua.Push(instance.Write(Nz::String(buffer, bufferSize)));
|
||||||
});
|
else
|
||||||
|
lua.Push(instance.Write(buffer, bufferSize));
|
||||||
file.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::File& instance, std::size_t /*argumentCount*/) -> int {
|
return 1;
|
||||||
Nz::StringStream ss("File(");
|
});
|
||||||
if (instance.IsOpen())
|
}
|
||||||
ss << "Path: " << instance.GetPath();
|
|
||||||
|
|
||||||
ss << ')';
|
|
||||||
|
|
||||||
lua.PushString(ss);
|
|
||||||
return 1;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -286,8 +300,7 @@ namespace Ndk
|
||||||
*
|
*
|
||||||
* \param instance Lua instance that will interact with the Core classes
|
* \param instance Lua instance that will interact with the Core classes
|
||||||
*/
|
*/
|
||||||
|
void LuaBinding_Core::Register(Nz::LuaInstance& instance)
|
||||||
void LuaBinding::RegisterCore(Nz::LuaInstance& instance)
|
|
||||||
{
|
{
|
||||||
// Classes
|
// Classes
|
||||||
clock.Register(instance);
|
clock.Register(instance);
|
||||||
|
|
|
||||||
|
|
@ -1,354 +1,355 @@
|
||||||
// This file is part of the "Nazara Development Kit"
|
// This file is part of the "Nazara Development Kit"
|
||||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
#include <NDK/LuaBinding.hpp>
|
#include <NDK/LuaBinding_Graphics.hpp>
|
||||||
#include <NDK/LuaAPI.hpp>
|
#include <NDK/LuaAPI.hpp>
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
/*!
|
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindGraphics(LuaBinding& binding)
|
||||||
* \brief Binds Graphics module to Lua
|
{
|
||||||
*/
|
return std::make_unique<LuaBinding_Graphics>(binding);
|
||||||
|
}
|
||||||
|
|
||||||
void LuaBinding::BindGraphics()
|
LuaBinding_Graphics::LuaBinding_Graphics(LuaBinding& binding) :
|
||||||
|
LuaBinding_Base(binding)
|
||||||
{
|
{
|
||||||
/*********************************** Nz::AbstractViewer ***********************************/
|
/*********************************** Nz::AbstractViewer ***********************************/
|
||||||
abstractViewer.BindMethod("GetAspectRatio", &Nz::AbstractViewer::GetAspectRatio);
|
abstractViewer.Reset("AbstractViewer");
|
||||||
abstractViewer.BindMethod("GetEyePosition", &Nz::AbstractViewer::GetEyePosition);
|
{
|
||||||
abstractViewer.BindMethod("GetForward", &Nz::AbstractViewer::GetForward);
|
abstractViewer.BindMethod("GetAspectRatio", &Nz::AbstractViewer::GetAspectRatio);
|
||||||
//abstractViewer.BindMethod("GetFrustum", &Nz::AbstractViewer::GetFrustum);
|
abstractViewer.BindMethod("GetEyePosition", &Nz::AbstractViewer::GetEyePosition);
|
||||||
abstractViewer.BindMethod("GetProjectionMatrix", &Nz::AbstractViewer::GetProjectionMatrix);
|
abstractViewer.BindMethod("GetForward", &Nz::AbstractViewer::GetForward);
|
||||||
//abstractViewer.BindMethod("GetTarget", &Nz::AbstractViewer::GetTarget);
|
//abstractViewer.BindMethod("GetFrustum", &Nz::AbstractViewer::GetFrustum);
|
||||||
abstractViewer.BindMethod("GetViewMatrix", &Nz::AbstractViewer::GetViewMatrix);
|
abstractViewer.BindMethod("GetProjectionMatrix", &Nz::AbstractViewer::GetProjectionMatrix);
|
||||||
abstractViewer.BindMethod("GetViewport", &Nz::AbstractViewer::GetViewport);
|
//abstractViewer.BindMethod("GetTarget", &Nz::AbstractViewer::GetTarget);
|
||||||
abstractViewer.BindMethod("GetZFar", &Nz::AbstractViewer::GetZFar);
|
abstractViewer.BindMethod("GetViewMatrix", &Nz::AbstractViewer::GetViewMatrix);
|
||||||
abstractViewer.BindMethod("GetZNear", &Nz::AbstractViewer::GetZNear);
|
abstractViewer.BindMethod("GetViewport", &Nz::AbstractViewer::GetViewport);
|
||||||
|
abstractViewer.BindMethod("GetZFar", &Nz::AbstractViewer::GetZFar);
|
||||||
|
abstractViewer.BindMethod("GetZNear", &Nz::AbstractViewer::GetZNear);
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************** Nz::InstancedRenderable ***********************************/
|
/*********************************** Nz::InstancedRenderable ***********************************/
|
||||||
|
instancedRenderable.Reset("InstancedRenderable");
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************** Nz::Material ***********************************/
|
/*********************************** Nz::Material ***********************************/
|
||||||
material.SetConstructor([] (Nz::LuaInstance& lua, Nz::MaterialRef* instance, std::size_t argumentCount)
|
material.Reset("Material");
|
||||||
{
|
{
|
||||||
switch (argumentCount)
|
material.SetConstructor([] (Nz::LuaInstance& lua, Nz::MaterialRef* instance, std::size_t argumentCount)
|
||||||
{
|
{
|
||||||
case 0:
|
switch (argumentCount)
|
||||||
Nz::PlacementNew(instance, Nz::Material::New());
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
{
|
{
|
||||||
int argIndex = 1;
|
case 0:
|
||||||
if (lua.IsOfType(argIndex, "MaterialPipeline"))
|
Nz::PlacementNew(instance, Nz::Material::New());
|
||||||
{
|
|
||||||
Nz::PlacementNew(instance, Nz::Material::New(*static_cast<Nz::MaterialPipelineRef*>(lua.ToUserdata(argIndex))));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
else if (lua.IsOfType(argIndex, "Material"))
|
case 1:
|
||||||
{
|
{
|
||||||
Nz::PlacementNew(instance, Nz::Material::New(**static_cast<Nz::MaterialRef*>(lua.ToUserdata(argIndex))));
|
int argIndex = 1;
|
||||||
return true;
|
if (lua.IsOfType(argIndex, "MaterialPipeline"))
|
||||||
}
|
{
|
||||||
else
|
Nz::PlacementNew(instance, Nz::Material::New(*static_cast<Nz::MaterialPipelineRef*>(lua.ToUserdata(argIndex))));
|
||||||
{
|
return true;
|
||||||
Nz::PlacementNew(instance, Nz::Material::New(lua.Check<Nz::String>(&argIndex)));
|
}
|
||||||
return true;
|
else if (lua.IsOfType(argIndex, "Material"))
|
||||||
|
{
|
||||||
|
Nz::PlacementNew(instance, Nz::Material::New(**static_cast<Nz::MaterialRef*>(lua.ToUserdata(argIndex))));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Nz::PlacementNew(instance, Nz::Material::New(lua.Check<Nz::String>(&argIndex)));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
lua.Error("No matching overload for constructor");
|
lua.Error("No matching overload for constructor");
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
material.BindMethod("Configure", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
material.BindMethod("Configure", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
||||||
{
|
|
||||||
int argIndex = 2;
|
|
||||||
if (lua.IsOfType(argIndex, "MaterialPipeline"))
|
|
||||||
{
|
{
|
||||||
instance->Configure(*static_cast<Nz::MaterialPipelineRef*>(lua.ToUserdata(argIndex)));
|
int argIndex = 2;
|
||||||
return 0;
|
if (lua.IsOfType(argIndex, "MaterialPipeline"))
|
||||||
}
|
{
|
||||||
else
|
instance->Configure(*static_cast<Nz::MaterialPipelineRef*>(lua.ToUserdata(argIndex)));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lua.Push(instance->Configure(lua.Check<Nz::String>(&argIndex)));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
material.BindMethod("EnableAlphaTest", &Nz::Material::EnableAlphaTest);
|
||||||
|
material.BindMethod("EnableBlending", &Nz::Material::EnableBlending);
|
||||||
|
material.BindMethod("EnableColorWrite", &Nz::Material::EnableColorWrite);
|
||||||
|
material.BindMethod("EnableDepthBuffer", &Nz::Material::EnableDepthBuffer);
|
||||||
|
material.BindMethod("EnableDepthSorting", &Nz::Material::EnableDepthSorting);
|
||||||
|
material.BindMethod("EnableDepthWrite", &Nz::Material::EnableDepthWrite);
|
||||||
|
material.BindMethod("EnableFaceCulling", &Nz::Material::EnableFaceCulling);
|
||||||
|
material.BindMethod("EnableScissorTest", &Nz::Material::EnableScissorTest);
|
||||||
|
material.BindMethod("EnableShadowCasting", &Nz::Material::EnableShadowCasting);
|
||||||
|
material.BindMethod("EnableShadowReceive", &Nz::Material::EnableShadowReceive);
|
||||||
|
material.BindMethod("EnableStencilTest", &Nz::Material::EnableStencilTest);
|
||||||
|
|
||||||
|
material.BindMethod("EnsurePipelineUpdate", &Nz::Material::EnsurePipelineUpdate);
|
||||||
|
|
||||||
|
material.BindMethod("GetAlphaMap", &Nz::Material::GetAlphaMap);
|
||||||
|
material.BindMethod("GetAlphaThreshold", &Nz::Material::GetAlphaThreshold);
|
||||||
|
material.BindMethod("GetAmbientColor", &Nz::Material::GetAmbientColor);
|
||||||
|
material.BindMethod("GetDepthFunc", &Nz::Material::GetDepthFunc);
|
||||||
|
material.BindMethod("GetDepthMaterial", &Nz::Material::GetDepthMaterial);
|
||||||
|
material.BindMethod("GetDiffuseColor", &Nz::Material::GetDiffuseColor);
|
||||||
|
material.BindMethod("GetDiffuseMap", &Nz::Material::GetDiffuseMap);
|
||||||
|
//material.BindMethod("GetDiffuseSampler", &Nz::Material::GetDiffuseSampler);
|
||||||
|
material.BindMethod("GetDstBlend", &Nz::Material::GetDstBlend);
|
||||||
|
material.BindMethod("GetEmissiveMap", &Nz::Material::GetEmissiveMap);
|
||||||
|
material.BindMethod("GetFaceCulling", &Nz::Material::GetFaceCulling);
|
||||||
|
material.BindMethod("GetFaceFilling", &Nz::Material::GetFaceFilling);
|
||||||
|
material.BindMethod("GetHeightMap", &Nz::Material::GetHeightMap);
|
||||||
|
material.BindMethod("GetLineWidth", &Nz::Material::GetLineWidth);
|
||||||
|
material.BindMethod("GetNormalMap", &Nz::Material::GetNormalMap);
|
||||||
|
//material.BindMethod("GetPipeline", &Nz::Material::GetPipeline);
|
||||||
|
//material.BindMethod("GetPipelineInfo", &Nz::Material::GetPipelineInfo);
|
||||||
|
material.BindMethod("GetPointSize", &Nz::Material::GetPointSize);
|
||||||
|
//material.BindMethod("GetShader", &Nz::Material::GetShader);
|
||||||
|
material.BindMethod("GetShininess", &Nz::Material::GetShininess);
|
||||||
|
material.BindMethod("GetSpecularColor", &Nz::Material::GetSpecularColor);
|
||||||
|
material.BindMethod("GetSpecularMap", &Nz::Material::GetSpecularMap);
|
||||||
|
//material.BindMethod("GetSpecularSampler", &Nz::Material::GetSpecularSampler);
|
||||||
|
material.BindMethod("GetSrcBlend", &Nz::Material::GetSrcBlend);
|
||||||
|
|
||||||
|
material.BindMethod("HasAlphaMap", &Nz::Material::HasAlphaMap);
|
||||||
|
material.BindMethod("HasDepthMaterial", &Nz::Material::HasDepthMaterial);
|
||||||
|
material.BindMethod("HasDiffuseMap", &Nz::Material::HasDiffuseMap);
|
||||||
|
material.BindMethod("HasEmissiveMap", &Nz::Material::HasEmissiveMap);
|
||||||
|
material.BindMethod("HasHeightMap", &Nz::Material::HasHeightMap);
|
||||||
|
material.BindMethod("HasNormalMap", &Nz::Material::HasNormalMap);
|
||||||
|
material.BindMethod("HasSpecularMap", &Nz::Material::HasSpecularMap);
|
||||||
|
|
||||||
|
material.BindMethod("IsAlphaTestEnabled", &Nz::Material::IsAlphaTestEnabled);
|
||||||
|
material.BindMethod("IsBlendingEnabled", &Nz::Material::IsBlendingEnabled);
|
||||||
|
material.BindMethod("IsColorWriteEnabled", &Nz::Material::IsColorWriteEnabled);
|
||||||
|
material.BindMethod("IsDepthBufferEnabled", &Nz::Material::IsDepthBufferEnabled);
|
||||||
|
material.BindMethod("IsDepthSortingEnabled", &Nz::Material::IsDepthSortingEnabled);
|
||||||
|
material.BindMethod("IsDepthWriteEnabled", &Nz::Material::IsDepthWriteEnabled);
|
||||||
|
material.BindMethod("IsFaceCullingEnabled", &Nz::Material::IsFaceCullingEnabled);
|
||||||
|
material.BindMethod("IsScissorTestEnabled", &Nz::Material::IsScissorTestEnabled);
|
||||||
|
material.BindMethod("IsStencilTestEnabled", &Nz::Material::IsStencilTestEnabled);
|
||||||
|
material.BindMethod("IsShadowCastingEnabled", &Nz::Material::IsShadowCastingEnabled);
|
||||||
|
material.BindMethod("IsShadowReceiveEnabled", &Nz::Material::IsShadowReceiveEnabled);
|
||||||
|
|
||||||
|
material.BindMethod("LoadFromFile", &Nz::Material::LoadFromFile, Nz::MaterialParams());
|
||||||
|
|
||||||
|
material.BindMethod("Reset", &Nz::Material::Reset);
|
||||||
|
|
||||||
|
material.BindMethod("SetAlphaThreshold", &Nz::Material::SetAlphaThreshold);
|
||||||
|
material.BindMethod("SetAmbientColor", &Nz::Material::SetAmbientColor);
|
||||||
|
material.BindMethod("SetDepthFunc", &Nz::Material::SetDepthFunc);
|
||||||
|
material.BindMethod("SetDepthFunc", &Nz::Material::SetDepthFunc);
|
||||||
|
material.BindMethod("SetDepthMaterial", &Nz::Material::SetDepthMaterial);
|
||||||
|
material.BindMethod("SetDiffuseColor", &Nz::Material::SetDiffuseColor);
|
||||||
|
//material.BindMethod("SetDiffuseSampler", &Nz::Material::SetDiffuseSampler);
|
||||||
|
material.BindMethod("SetDstBlend", &Nz::Material::SetDstBlend);
|
||||||
|
material.BindMethod("SetFaceCulling", &Nz::Material::SetFaceCulling);
|
||||||
|
material.BindMethod("SetFaceFilling", &Nz::Material::SetFaceFilling);
|
||||||
|
material.BindMethod("SetLineWidth", &Nz::Material::SetLineWidth);
|
||||||
|
material.BindMethod("SetPointSize", &Nz::Material::SetPointSize);
|
||||||
|
material.BindMethod("SetShininess", &Nz::Material::SetShininess);
|
||||||
|
material.BindMethod("SetSpecularColor", &Nz::Material::SetSpecularColor);
|
||||||
|
material.BindMethod("SetSpecularColor", &Nz::Material::SetSpecularColor);
|
||||||
|
//material.BindMethod("SetSpecularSampler", &Nz::Material::SetSpecularSampler);
|
||||||
|
material.BindMethod("SetSrcBlend", &Nz::Material::SetSrcBlend);
|
||||||
|
|
||||||
|
material.BindStaticMethod("GetDefault", &Nz::Material::GetDefault);
|
||||||
|
|
||||||
|
material.BindMethod("SetAlphaMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
||||||
{
|
{
|
||||||
lua.Push(instance->Configure(lua.Check<Nz::String>(&argIndex)));
|
int argIndex = 2;
|
||||||
return 1;
|
if (lua.IsOfType(argIndex, "Texture"))
|
||||||
}
|
{
|
||||||
});
|
instance->SetAlphaMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return lua.Push(instance->SetAlphaMap(lua.Check<Nz::String>(&argIndex)));
|
||||||
|
});
|
||||||
|
|
||||||
material.BindMethod("EnableAlphaTest", &Nz::Material::EnableAlphaTest);
|
material.BindMethod("SetDiffuseMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
||||||
material.BindMethod("EnableBlending", &Nz::Material::EnableBlending);
|
|
||||||
material.BindMethod("EnableColorWrite", &Nz::Material::EnableColorWrite);
|
|
||||||
material.BindMethod("EnableDepthBuffer", &Nz::Material::EnableDepthBuffer);
|
|
||||||
material.BindMethod("EnableDepthSorting", &Nz::Material::EnableDepthSorting);
|
|
||||||
material.BindMethod("EnableDepthWrite", &Nz::Material::EnableDepthWrite);
|
|
||||||
material.BindMethod("EnableFaceCulling", &Nz::Material::EnableFaceCulling);
|
|
||||||
material.BindMethod("EnableScissorTest", &Nz::Material::EnableScissorTest);
|
|
||||||
material.BindMethod("EnableShadowCasting", &Nz::Material::EnableShadowCasting);
|
|
||||||
material.BindMethod("EnableShadowReceive", &Nz::Material::EnableShadowReceive);
|
|
||||||
material.BindMethod("EnableStencilTest", &Nz::Material::EnableStencilTest);
|
|
||||||
|
|
||||||
material.BindMethod("EnsurePipelineUpdate", &Nz::Material::EnsurePipelineUpdate);
|
|
||||||
|
|
||||||
material.BindMethod("GetAlphaMap", &Nz::Material::GetAlphaMap);
|
|
||||||
material.BindMethod("GetAlphaThreshold", &Nz::Material::GetAlphaThreshold);
|
|
||||||
material.BindMethod("GetAmbientColor", &Nz::Material::GetAmbientColor);
|
|
||||||
material.BindMethod("GetDepthFunc", &Nz::Material::GetDepthFunc);
|
|
||||||
material.BindMethod("GetDepthMaterial", &Nz::Material::GetDepthMaterial);
|
|
||||||
material.BindMethod("GetDiffuseColor", &Nz::Material::GetDiffuseColor);
|
|
||||||
material.BindMethod("GetDiffuseMap", &Nz::Material::GetDiffuseMap);
|
|
||||||
//material.BindMethod("GetDiffuseSampler", &Nz::Material::GetDiffuseSampler);
|
|
||||||
material.BindMethod("GetDstBlend", &Nz::Material::GetDstBlend);
|
|
||||||
material.BindMethod("GetEmissiveMap", &Nz::Material::GetEmissiveMap);
|
|
||||||
material.BindMethod("GetFaceCulling", &Nz::Material::GetFaceCulling);
|
|
||||||
material.BindMethod("GetFaceFilling", &Nz::Material::GetFaceFilling);
|
|
||||||
material.BindMethod("GetHeightMap", &Nz::Material::GetHeightMap);
|
|
||||||
material.BindMethod("GetLineWidth", &Nz::Material::GetLineWidth);
|
|
||||||
material.BindMethod("GetNormalMap", &Nz::Material::GetNormalMap);
|
|
||||||
//material.BindMethod("GetPipeline", &Nz::Material::GetPipeline);
|
|
||||||
//material.BindMethod("GetPipelineInfo", &Nz::Material::GetPipelineInfo);
|
|
||||||
material.BindMethod("GetPointSize", &Nz::Material::GetPointSize);
|
|
||||||
//material.BindMethod("GetShader", &Nz::Material::GetShader);
|
|
||||||
material.BindMethod("GetShininess", &Nz::Material::GetShininess);
|
|
||||||
material.BindMethod("GetSpecularColor", &Nz::Material::GetSpecularColor);
|
|
||||||
material.BindMethod("GetSpecularMap", &Nz::Material::GetSpecularMap);
|
|
||||||
//material.BindMethod("GetSpecularSampler", &Nz::Material::GetSpecularSampler);
|
|
||||||
material.BindMethod("GetSrcBlend", &Nz::Material::GetSrcBlend);
|
|
||||||
|
|
||||||
material.BindMethod("HasAlphaMap", &Nz::Material::HasAlphaMap);
|
|
||||||
material.BindMethod("HasDepthMaterial", &Nz::Material::HasDepthMaterial);
|
|
||||||
material.BindMethod("HasDiffuseMap", &Nz::Material::HasDiffuseMap);
|
|
||||||
material.BindMethod("HasEmissiveMap", &Nz::Material::HasEmissiveMap);
|
|
||||||
material.BindMethod("HasHeightMap", &Nz::Material::HasHeightMap);
|
|
||||||
material.BindMethod("HasNormalMap", &Nz::Material::HasNormalMap);
|
|
||||||
material.BindMethod("HasSpecularMap", &Nz::Material::HasSpecularMap);
|
|
||||||
|
|
||||||
material.BindMethod("IsAlphaTestEnabled", &Nz::Material::IsAlphaTestEnabled);
|
|
||||||
material.BindMethod("IsBlendingEnabled", &Nz::Material::IsBlendingEnabled);
|
|
||||||
material.BindMethod("IsColorWriteEnabled", &Nz::Material::IsColorWriteEnabled);
|
|
||||||
material.BindMethod("IsDepthBufferEnabled", &Nz::Material::IsDepthBufferEnabled);
|
|
||||||
material.BindMethod("IsDepthSortingEnabled", &Nz::Material::IsDepthSortingEnabled);
|
|
||||||
material.BindMethod("IsDepthWriteEnabled", &Nz::Material::IsDepthWriteEnabled);
|
|
||||||
material.BindMethod("IsFaceCullingEnabled", &Nz::Material::IsFaceCullingEnabled);
|
|
||||||
material.BindMethod("IsScissorTestEnabled", &Nz::Material::IsScissorTestEnabled);
|
|
||||||
material.BindMethod("IsStencilTestEnabled", &Nz::Material::IsStencilTestEnabled);
|
|
||||||
material.BindMethod("IsShadowCastingEnabled", &Nz::Material::IsShadowCastingEnabled);
|
|
||||||
material.BindMethod("IsShadowReceiveEnabled", &Nz::Material::IsShadowReceiveEnabled);
|
|
||||||
|
|
||||||
material.BindMethod("LoadFromFile", &Nz::Material::LoadFromFile, Nz::MaterialParams());
|
|
||||||
|
|
||||||
material.BindMethod("Reset", &Nz::Material::Reset);
|
|
||||||
|
|
||||||
material.BindMethod("SetAlphaThreshold", &Nz::Material::SetAlphaThreshold);
|
|
||||||
material.BindMethod("SetAmbientColor", &Nz::Material::SetAmbientColor);
|
|
||||||
material.BindMethod("SetDepthFunc", &Nz::Material::SetDepthFunc);
|
|
||||||
material.BindMethod("SetDepthFunc", &Nz::Material::SetDepthFunc);
|
|
||||||
material.BindMethod("SetDepthMaterial", &Nz::Material::SetDepthMaterial);
|
|
||||||
material.BindMethod("SetDiffuseColor", &Nz::Material::SetDiffuseColor);
|
|
||||||
//material.BindMethod("SetDiffuseSampler", &Nz::Material::SetDiffuseSampler);
|
|
||||||
material.BindMethod("SetDstBlend", &Nz::Material::SetDstBlend);
|
|
||||||
material.BindMethod("SetFaceCulling", &Nz::Material::SetFaceCulling);
|
|
||||||
material.BindMethod("SetFaceFilling", &Nz::Material::SetFaceFilling);
|
|
||||||
material.BindMethod("SetLineWidth", &Nz::Material::SetLineWidth);
|
|
||||||
material.BindMethod("SetPointSize", &Nz::Material::SetPointSize);
|
|
||||||
material.BindMethod("SetShininess", &Nz::Material::SetShininess);
|
|
||||||
material.BindMethod("SetSpecularColor", &Nz::Material::SetSpecularColor);
|
|
||||||
material.BindMethod("SetSpecularColor", &Nz::Material::SetSpecularColor);
|
|
||||||
//material.BindMethod("SetSpecularSampler", &Nz::Material::SetSpecularSampler);
|
|
||||||
material.BindMethod("SetSrcBlend", &Nz::Material::SetSrcBlend);
|
|
||||||
|
|
||||||
material.BindStaticMethod("GetDefault", &Nz::Material::GetDefault);
|
|
||||||
|
|
||||||
material.BindMethod("SetAlphaMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
|
||||||
{
|
|
||||||
int argIndex = 2;
|
|
||||||
if (lua.IsOfType(argIndex, "Texture"))
|
|
||||||
{
|
{
|
||||||
instance->SetAlphaMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)));
|
int argIndex = 2;
|
||||||
return 0;
|
if (lua.IsOfType(argIndex, "Texture"))
|
||||||
}
|
{
|
||||||
else
|
instance->SetDiffuseMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)));
|
||||||
return lua.Push(instance->SetAlphaMap(lua.Check<Nz::String>(&argIndex)));
|
return 0;
|
||||||
});
|
}
|
||||||
|
else
|
||||||
|
return lua.Push(instance->SetDiffuseMap(lua.Check<Nz::String>(&argIndex)));
|
||||||
|
});
|
||||||
|
|
||||||
material.BindMethod("SetDiffuseMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
material.BindMethod("SetEmissiveMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
||||||
{
|
|
||||||
int argIndex = 2;
|
|
||||||
if (lua.IsOfType(argIndex, "Texture"))
|
|
||||||
{
|
{
|
||||||
instance->SetDiffuseMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)));
|
int argIndex = 2;
|
||||||
return 0;
|
if (lua.IsOfType(argIndex, "Texture"))
|
||||||
}
|
{
|
||||||
else
|
instance->SetEmissiveMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)));
|
||||||
return lua.Push(instance->SetDiffuseMap(lua.Check<Nz::String>(&argIndex)));
|
return 0;
|
||||||
});
|
}
|
||||||
|
else
|
||||||
|
return lua.Push(instance->SetEmissiveMap(lua.Check<Nz::String>(&argIndex)));
|
||||||
|
});
|
||||||
|
|
||||||
material.BindMethod("SetEmissiveMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
material.BindMethod("SetHeightMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
||||||
{
|
|
||||||
int argIndex = 2;
|
|
||||||
if (lua.IsOfType(argIndex, "Texture"))
|
|
||||||
{
|
{
|
||||||
instance->SetEmissiveMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)));
|
int argIndex = 2;
|
||||||
return 0;
|
if (lua.IsOfType(argIndex, "Texture"))
|
||||||
}
|
{
|
||||||
else
|
instance->SetHeightMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)));
|
||||||
return lua.Push(instance->SetEmissiveMap(lua.Check<Nz::String>(&argIndex)));
|
return 0;
|
||||||
});
|
}
|
||||||
|
else
|
||||||
|
return lua.Push(instance->SetHeightMap(lua.Check<Nz::String>(&argIndex)));
|
||||||
|
});
|
||||||
|
|
||||||
material.BindMethod("SetHeightMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
material.BindMethod("SetNormalMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
||||||
{
|
|
||||||
int argIndex = 2;
|
|
||||||
if (lua.IsOfType(argIndex, "Texture"))
|
|
||||||
{
|
{
|
||||||
instance->SetHeightMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)));
|
int argIndex = 2;
|
||||||
return 0;
|
if (lua.IsOfType(argIndex, "Texture"))
|
||||||
}
|
{
|
||||||
else
|
instance->SetNormalMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)));
|
||||||
return lua.Push(instance->SetHeightMap(lua.Check<Nz::String>(&argIndex)));
|
return 0;
|
||||||
});
|
}
|
||||||
|
else
|
||||||
|
return lua.Push(instance->SetNormalMap(lua.Check<Nz::String>(&argIndex)));
|
||||||
|
});
|
||||||
|
|
||||||
material.BindMethod("SetNormalMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
material.BindMethod("SetShader", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
||||||
{
|
|
||||||
int argIndex = 2;
|
|
||||||
if (lua.IsOfType(argIndex, "Texture"))
|
|
||||||
{
|
{
|
||||||
instance->SetNormalMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)));
|
int argIndex = 2;
|
||||||
return 0;
|
if (lua.IsOfType(argIndex, "UberShader"))
|
||||||
}
|
{
|
||||||
else
|
instance->SetShader(*static_cast<Nz::UberShaderRef*>(lua.ToUserdata(argIndex)));
|
||||||
return lua.Push(instance->SetNormalMap(lua.Check<Nz::String>(&argIndex)));
|
return 0;
|
||||||
});
|
}
|
||||||
|
else
|
||||||
|
return lua.Push(instance->SetShader(lua.Check<Nz::String>(&argIndex)));
|
||||||
|
});
|
||||||
|
|
||||||
material.BindMethod("SetShader", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
material.BindMethod("SetSpecularMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
||||||
{
|
|
||||||
int argIndex = 2;
|
|
||||||
if (lua.IsOfType(argIndex, "UberShader"))
|
|
||||||
{
|
{
|
||||||
instance->SetShader(*static_cast<Nz::UberShaderRef*>(lua.ToUserdata(argIndex)));
|
int argIndex = 2;
|
||||||
return 0;
|
if (lua.IsOfType(argIndex, "Texture"))
|
||||||
}
|
{
|
||||||
else
|
instance->SetSpecularMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)));
|
||||||
return lua.Push(instance->SetShader(lua.Check<Nz::String>(&argIndex)));
|
return 0;
|
||||||
});
|
}
|
||||||
|
else
|
||||||
material.BindMethod("SetSpecularMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
return lua.Push(instance->SetSpecularMap(lua.Check<Nz::String>(&argIndex)));
|
||||||
{
|
});
|
||||||
int argIndex = 2;
|
}
|
||||||
if (lua.IsOfType(argIndex, "Texture"))
|
|
||||||
{
|
|
||||||
instance->SetSpecularMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return lua.Push(instance->SetSpecularMap(lua.Check<Nz::String>(&argIndex)));
|
|
||||||
});
|
|
||||||
|
|
||||||
/*********************************** Nz::Model ***********************************/
|
/*********************************** Nz::Model ***********************************/
|
||||||
model.Inherit<Nz::InstancedRenderableRef>(instancedRenderable, [] (Nz::ModelRef* modelRef) -> Nz::InstancedRenderableRef*
|
model.Reset("Model");
|
||||||
{
|
{
|
||||||
return reinterpret_cast<Nz::InstancedRenderableRef*>(modelRef); //TODO: Make a ObjectRefCast
|
model.Inherit<Nz::InstancedRenderableRef>(instancedRenderable, [] (Nz::ModelRef* modelRef) -> Nz::InstancedRenderableRef*
|
||||||
});
|
{
|
||||||
|
return reinterpret_cast<Nz::InstancedRenderableRef*>(modelRef); //TODO: Make a ObjectRefCast
|
||||||
|
});
|
||||||
|
|
||||||
model.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::ModelRef* instance, std::size_t /*argumentCount*/)
|
model.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::ModelRef* instance, std::size_t /*argumentCount*/)
|
||||||
{
|
{
|
||||||
Nz::PlacementNew(instance, Nz::Model::New());
|
Nz::PlacementNew(instance, Nz::Model::New());
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
//model.BindMethod("GetMaterial", &Nz::Model::GetMaterial);
|
//model.BindMethod("GetMaterial", &Nz::Model::GetMaterial);
|
||||||
model.BindMethod("GetMaterialCount", &Nz::Model::GetMaterialCount);
|
model.BindMethod("GetMaterialCount", &Nz::Model::GetMaterialCount);
|
||||||
//modelClass.SetMethod("GetMesh", &Nz::Model::GetMesh);
|
//modelClass.SetMethod("GetMesh", &Nz::Model::GetMesh);
|
||||||
model.BindMethod("GetSkin", &Nz::Model::GetSkin);
|
model.BindMethod("GetSkin", &Nz::Model::GetSkin);
|
||||||
model.BindMethod("GetSkinCount", &Nz::Model::GetSkinCount);
|
model.BindMethod("GetSkinCount", &Nz::Model::GetSkinCount);
|
||||||
|
|
||||||
model.BindMethod("IsAnimated", &Nz::Model::IsAnimated);
|
model.BindMethod("IsAnimated", &Nz::Model::IsAnimated);
|
||||||
model.BindMethod("LoadFromFile", &Nz::Model::LoadFromFile, Nz::ModelParameters());
|
model.BindMethod("LoadFromFile", &Nz::Model::LoadFromFile, Nz::ModelParameters());
|
||||||
|
|
||||||
model.BindMethod("Reset", &Nz::Model::Reset);
|
model.BindMethod("Reset", &Nz::Model::Reset);
|
||||||
|
|
||||||
//model.BindMethod("SetMaterial", &Nz::Model::SetMaterial);
|
//model.BindMethod("SetMaterial", &Nz::Model::SetMaterial);
|
||||||
//modelClass.SetMethod("SetMesh", &Nz::Model::SetMesh);
|
//modelClass.SetMethod("SetMesh", &Nz::Model::SetMesh);
|
||||||
//modelClass.SetMethod("SetSequence", &Nz::Model::SetSequence);
|
//modelClass.SetMethod("SetSequence", &Nz::Model::SetSequence);
|
||||||
model.BindMethod("SetSkin", &Nz::Model::SetSkin);
|
model.BindMethod("SetSkin", &Nz::Model::SetSkin);
|
||||||
model.BindMethod("SetSkinCount", &Nz::Model::SetSkinCount);
|
model.BindMethod("SetSkinCount", &Nz::Model::SetSkinCount);
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************** Nz::Sprite ***********************************/
|
/*********************************** Nz::Sprite ***********************************/
|
||||||
sprite.Inherit<Nz::InstancedRenderableRef>(instancedRenderable, [] (Nz::SpriteRef* spriteRef) -> Nz::InstancedRenderableRef*
|
sprite.Reset("Sprite");
|
||||||
{
|
{
|
||||||
return reinterpret_cast<Nz::InstancedRenderableRef*>(spriteRef); //TODO: Make a ObjectRefCast
|
sprite.Inherit<Nz::InstancedRenderableRef>(instancedRenderable, [] (Nz::SpriteRef* spriteRef) -> Nz::InstancedRenderableRef*
|
||||||
});
|
{
|
||||||
|
return reinterpret_cast<Nz::InstancedRenderableRef*>(spriteRef); //TODO: Make a ObjectRefCast
|
||||||
|
});
|
||||||
|
|
||||||
sprite.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::SpriteRef* instance, std::size_t /*argumentCount*/)
|
sprite.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::SpriteRef* instance, std::size_t /*argumentCount*/)
|
||||||
{
|
{
|
||||||
Nz::PlacementNew(instance, Nz::Sprite::New());
|
Nz::PlacementNew(instance, Nz::Sprite::New());
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
sprite.BindMethod("GetColor", &Nz::Sprite::GetColor);
|
sprite.BindMethod("GetColor", &Nz::Sprite::GetColor);
|
||||||
sprite.BindMethod("GetCornerColor", &Nz::Sprite::GetCornerColor);
|
sprite.BindMethod("GetCornerColor", &Nz::Sprite::GetCornerColor);
|
||||||
sprite.BindMethod("GetMaterial", &Nz::Sprite::GetMaterial);
|
sprite.BindMethod("GetMaterial", &Nz::Sprite::GetMaterial);
|
||||||
sprite.BindMethod("GetOrigin", &Nz::Sprite::GetOrigin);
|
sprite.BindMethod("GetOrigin", &Nz::Sprite::GetOrigin);
|
||||||
sprite.BindMethod("GetSize", &Nz::Sprite::GetSize);
|
sprite.BindMethod("GetSize", &Nz::Sprite::GetSize);
|
||||||
sprite.BindMethod("GetTextureCoords", &Nz::Sprite::GetTextureCoords);
|
sprite.BindMethod("GetTextureCoords", &Nz::Sprite::GetTextureCoords);
|
||||||
|
|
||||||
sprite.BindMethod("SetColor", &Nz::Sprite::SetColor);
|
sprite.BindMethod("SetColor", &Nz::Sprite::SetColor);
|
||||||
sprite.BindMethod("SetCornerColor", &Nz::Sprite::SetCornerColor);
|
sprite.BindMethod("SetCornerColor", &Nz::Sprite::SetCornerColor);
|
||||||
sprite.BindMethod("SetDefaultMaterial", &Nz::Sprite::SetDefaultMaterial);
|
sprite.BindMethod("SetDefaultMaterial", &Nz::Sprite::SetDefaultMaterial);
|
||||||
sprite.BindMethod("SetOrigin", &Nz::Sprite::SetOrigin);
|
sprite.BindMethod("SetOrigin", &Nz::Sprite::SetOrigin);
|
||||||
sprite.BindMethod("SetSize", (void(Nz::Sprite::*)(const Nz::Vector2f&)) &Nz::Sprite::SetSize);
|
sprite.BindMethod("SetSize", (void(Nz::Sprite::*)(const Nz::Vector2f&)) &Nz::Sprite::SetSize);
|
||||||
sprite.BindMethod("SetTextureCoords", &Nz::Sprite::SetTextureCoords);
|
sprite.BindMethod("SetTextureCoords", &Nz::Sprite::SetTextureCoords);
|
||||||
sprite.BindMethod("SetTextureRect", &Nz::Sprite::SetTextureRect);
|
sprite.BindMethod("SetTextureRect", &Nz::Sprite::SetTextureRect);
|
||||||
|
|
||||||
sprite.BindMethod("SetMaterial", [] (Nz::LuaInstance& lua, Nz::SpriteRef& instance, std::size_t /*argumentCount*/) -> int
|
sprite.BindMethod("SetMaterial", [] (Nz::LuaInstance& lua, Nz::SpriteRef& instance, std::size_t /*argumentCount*/) -> int
|
||||||
{
|
{
|
||||||
int argIndex = 2;
|
int argIndex = 2;
|
||||||
bool resizeSprite = lua.CheckBoolean(argIndex + 1, true);
|
bool resizeSprite = lua.CheckBoolean(argIndex + 1, true);
|
||||||
|
|
||||||
if (lua.IsOfType(argIndex, "Material"))
|
if (lua.IsOfType(argIndex, "Material"))
|
||||||
instance->SetMaterial(*static_cast<Nz::MaterialRef*>(lua.ToUserdata(argIndex)), resizeSprite);
|
instance->SetMaterial(*static_cast<Nz::MaterialRef*>(lua.ToUserdata(argIndex)), resizeSprite);
|
||||||
else
|
else
|
||||||
instance->SetMaterial(lua.Check<Nz::String>(&argIndex), resizeSprite);
|
instance->SetMaterial(lua.Check<Nz::String>(&argIndex), resizeSprite);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
sprite.BindMethod("SetTexture", [] (Nz::LuaInstance& lua, Nz::SpriteRef& instance, std::size_t /*argumentCount*/) -> int
|
sprite.BindMethod("SetTexture", [] (Nz::LuaInstance& lua, Nz::SpriteRef& instance, std::size_t /*argumentCount*/) -> int
|
||||||
{
|
{
|
||||||
int argIndex = 2;
|
int argIndex = 2;
|
||||||
bool resizeSprite = lua.CheckBoolean(argIndex + 1, true);
|
bool resizeSprite = lua.CheckBoolean(argIndex + 1, true);
|
||||||
|
|
||||||
if (lua.IsOfType(argIndex, "Texture"))
|
if (lua.IsOfType(argIndex, "Texture"))
|
||||||
instance->SetTexture(*static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)), resizeSprite);
|
instance->SetTexture(*static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)), resizeSprite);
|
||||||
else
|
else
|
||||||
instance->SetTexture(lua.Check<Nz::String>(&argIndex), resizeSprite);
|
instance->SetTexture(lua.Check<Nz::String>(&argIndex), resizeSprite);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************** Nz::SpriteLibrary ***********************************/
|
/*********************************** Nz::SpriteLibrary ***********************************/
|
||||||
|
spriteLibrary.Reset("SpriteLibrary");
|
||||||
spriteLibrary.BindStaticMethod("Get", &Nz::SpriteLibrary::Get);
|
{
|
||||||
spriteLibrary.BindStaticMethod("Has", &Nz::SpriteLibrary::Has);
|
spriteLibrary.BindStaticMethod("Get", &Nz::SpriteLibrary::Get);
|
||||||
spriteLibrary.BindStaticMethod("Register", &Nz::SpriteLibrary::Register);
|
spriteLibrary.BindStaticMethod("Has", &Nz::SpriteLibrary::Has);
|
||||||
spriteLibrary.BindStaticMethod("Query", &Nz::SpriteLibrary::Query);
|
spriteLibrary.BindStaticMethod("Register", &Nz::SpriteLibrary::Register);
|
||||||
spriteLibrary.BindStaticMethod("Unregister", &Nz::SpriteLibrary::Unregister);
|
spriteLibrary.BindStaticMethod("Query", &Nz::SpriteLibrary::Query);
|
||||||
|
spriteLibrary.BindStaticMethod("Unregister", &Nz::SpriteLibrary::Unregister);
|
||||||
/*********************************** Nz::TextureLibrary ***********************************/
|
}
|
||||||
|
|
||||||
textureLibrary.BindStaticMethod("Get", &Nz::TextureLibrary::Get);
|
|
||||||
textureLibrary.BindStaticMethod("Has", &Nz::TextureLibrary::Has);
|
|
||||||
textureLibrary.BindStaticMethod("Register", &Nz::TextureLibrary::Register);
|
|
||||||
textureLibrary.BindStaticMethod("Query", &Nz::TextureLibrary::Query);
|
|
||||||
textureLibrary.BindStaticMethod("Unregister", &Nz::TextureLibrary::Unregister);
|
|
||||||
|
|
||||||
/*********************************** Nz::TextureManager ***********************************/
|
|
||||||
|
|
||||||
textureManager.BindStaticMethod("Clear", &Nz::TextureManager::Clear);
|
|
||||||
textureManager.BindStaticMethod("Get", &Nz::TextureManager::Get);
|
|
||||||
textureManager.BindStaticMethod("GetDefaultParameters", &Nz::TextureManager::GetDefaultParameters);
|
|
||||||
textureManager.BindStaticMethod("Purge", &Nz::TextureManager::Purge);
|
|
||||||
textureManager.BindStaticMethod("Register", &Nz::TextureManager::Register);
|
|
||||||
textureManager.BindStaticMethod("SetDefaultParameters", &Nz::TextureManager::SetDefaultParameters);
|
|
||||||
textureManager.BindStaticMethod("Unregister", &Nz::TextureManager::Unregister);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -357,7 +358,7 @@ namespace Ndk
|
||||||
* \param instance Lua instance that will interact with the Graphics classes
|
* \param instance Lua instance that will interact with the Graphics classes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void LuaBinding::RegisterGraphics(Nz::LuaInstance& instance)
|
void LuaBinding_Graphics::Register(Nz::LuaInstance& instance)
|
||||||
{
|
{
|
||||||
abstractViewer.Register(instance);
|
abstractViewer.Register(instance);
|
||||||
instancedRenderable.Register(instance);
|
instancedRenderable.Register(instance);
|
||||||
|
|
@ -365,7 +366,5 @@ namespace Ndk
|
||||||
model.Register(instance);
|
model.Register(instance);
|
||||||
sprite.Register(instance);
|
sprite.Register(instance);
|
||||||
spriteLibrary.Register(instance);
|
spriteLibrary.Register(instance);
|
||||||
textureLibrary.Register(instance);
|
|
||||||
textureManager.Register(instance);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,139 +1,147 @@
|
||||||
// This file was automatically generated on 26 May 2014 at 01:05:31
|
// This file was automatically generated on 26 May 2014 at 01:05:31
|
||||||
|
|
||||||
#include <NDK/LuaBinding.hpp>
|
#include <NDK/LuaBinding_Network.hpp>
|
||||||
#include <NDK/LuaAPI.hpp>
|
#include <NDK/LuaAPI.hpp>
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
/*!
|
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindNetwork(LuaBinding& binding)
|
||||||
* \brief Binds Network module to Lua
|
{
|
||||||
*/
|
return std::make_unique<LuaBinding_Network>(binding);
|
||||||
|
}
|
||||||
|
|
||||||
void LuaBinding::BindNetwork()
|
LuaBinding_Network::LuaBinding_Network(LuaBinding& binding) :
|
||||||
|
LuaBinding_Base(binding)
|
||||||
{
|
{
|
||||||
/*********************************** Nz::AbstractSocket **********************************/
|
/*********************************** Nz::AbstractSocket **********************************/
|
||||||
abstractSocket.BindMethod("Close", &Nz::AbstractSocket::Close);
|
abstractSocket.Reset("AbstractSocket");
|
||||||
abstractSocket.BindMethod("EnableBlocking", &Nz::AbstractSocket::EnableBlocking);
|
{
|
||||||
abstractSocket.BindMethod("GetLastError", &Nz::AbstractSocket::GetLastError);
|
abstractSocket.BindMethod("Close", &Nz::AbstractSocket::Close);
|
||||||
abstractSocket.BindMethod("GetState", &Nz::AbstractSocket::GetState);
|
abstractSocket.BindMethod("EnableBlocking", &Nz::AbstractSocket::EnableBlocking);
|
||||||
abstractSocket.BindMethod("GetType", &Nz::AbstractSocket::GetType);
|
abstractSocket.BindMethod("GetLastError", &Nz::AbstractSocket::GetLastError);
|
||||||
abstractSocket.BindMethod("IsBlockingEnabled", &Nz::AbstractSocket::IsBlockingEnabled);
|
abstractSocket.BindMethod("GetState", &Nz::AbstractSocket::GetState);
|
||||||
abstractSocket.BindMethod("QueryAvailableBytes", &Nz::AbstractSocket::QueryAvailableBytes);
|
abstractSocket.BindMethod("GetType", &Nz::AbstractSocket::GetType);
|
||||||
|
abstractSocket.BindMethod("IsBlockingEnabled", &Nz::AbstractSocket::IsBlockingEnabled);
|
||||||
|
abstractSocket.BindMethod("QueryAvailableBytes", &Nz::AbstractSocket::QueryAvailableBytes);
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************** Nz::IpAddress **********************************/
|
/*********************************** Nz::IpAddress **********************************/
|
||||||
ipAddress.SetConstructor([] (Nz::LuaInstance& lua, Nz::IpAddress* instance, std::size_t argumentCount)
|
ipAddress.Reset("IpAddress");
|
||||||
{
|
{
|
||||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 9U);
|
ipAddress.SetConstructor([] (Nz::LuaInstance& lua, Nz::IpAddress* instance, std::size_t argumentCount)
|
||||||
|
|
||||||
int argIndex = 2;
|
|
||||||
switch (argCount)
|
|
||||||
{
|
{
|
||||||
case 0:
|
std::size_t argCount = std::min<std::size_t>(argumentCount, 9U);
|
||||||
Nz::PlacementNew(instance);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 1:
|
int argIndex = 2;
|
||||||
Nz::PlacementNew(instance, lua.CheckString(argIndex));
|
switch (argCount)
|
||||||
return true;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
{
|
{
|
||||||
Nz::UInt8 a = lua.Check<Nz::UInt8>(&argIndex);
|
case 0:
|
||||||
Nz::UInt8 b = lua.Check<Nz::UInt8>(&argIndex);
|
Nz::PlacementNew(instance);
|
||||||
Nz::UInt8 c = lua.Check<Nz::UInt8>(&argIndex);
|
return true;
|
||||||
Nz::UInt8 d = lua.Check<Nz::UInt8>(&argIndex);
|
|
||||||
Nz::UInt16 port = lua.Check<Nz::UInt16>(&argIndex, 0);
|
|
||||||
|
|
||||||
Nz::PlacementNew(instance, a, b, c, d, port);
|
case 1:
|
||||||
return true;
|
Nz::PlacementNew(instance, lua.CheckString(argIndex));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
{
|
||||||
|
Nz::UInt8 a = lua.Check<Nz::UInt8>(&argIndex);
|
||||||
|
Nz::UInt8 b = lua.Check<Nz::UInt8>(&argIndex);
|
||||||
|
Nz::UInt8 c = lua.Check<Nz::UInt8>(&argIndex);
|
||||||
|
Nz::UInt8 d = lua.Check<Nz::UInt8>(&argIndex);
|
||||||
|
Nz::UInt16 port = lua.Check<Nz::UInt16>(&argIndex, 0);
|
||||||
|
|
||||||
|
Nz::PlacementNew(instance, a, b, c, d, port);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 8:
|
||||||
|
case 9:
|
||||||
|
{
|
||||||
|
Nz::UInt16 a = lua.Check<Nz::UInt16>(&argIndex);
|
||||||
|
Nz::UInt16 b = lua.Check<Nz::UInt16>(&argIndex);
|
||||||
|
Nz::UInt16 c = lua.Check<Nz::UInt16>(&argIndex);
|
||||||
|
Nz::UInt16 d = lua.Check<Nz::UInt16>(&argIndex);
|
||||||
|
Nz::UInt16 e = lua.Check<Nz::UInt16>(&argIndex);
|
||||||
|
Nz::UInt16 f = lua.Check<Nz::UInt16>(&argIndex);
|
||||||
|
Nz::UInt16 g = lua.Check<Nz::UInt16>(&argIndex);
|
||||||
|
Nz::UInt16 h = lua.Check<Nz::UInt16>(&argIndex);
|
||||||
|
Nz::UInt16 port = lua.Check<Nz::UInt16>(&argIndex, 0);
|
||||||
|
|
||||||
|
Nz::PlacementNew(instance, a, b, c, d, e, f, g, h, port);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case 8:
|
lua.Error("No matching overload for constructor");
|
||||||
case 9:
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
ipAddress.BindMethod("GetPort", &Nz::IpAddress::GetPort);
|
||||||
|
ipAddress.BindMethod("GetProtocol", &Nz::IpAddress::GetProtocol);
|
||||||
|
ipAddress.BindMethod("IsLoopback", &Nz::IpAddress::IsLoopback);
|
||||||
|
ipAddress.BindMethod("IsValid", &Nz::IpAddress::IsValid);
|
||||||
|
ipAddress.BindMethod("ToUInt32", &Nz::IpAddress::ToUInt32);
|
||||||
|
ipAddress.BindMethod("__tostring", &Nz::IpAddress::ToString);
|
||||||
|
|
||||||
|
ipAddress.BindStaticMethod("ResolveAddress", [] (Nz::LuaInstance& instance) -> int
|
||||||
|
{
|
||||||
|
Nz::String service;
|
||||||
|
Nz::ResolveError error = Nz::ResolveError_Unknown;
|
||||||
|
|
||||||
|
int argIndex = 2;
|
||||||
|
Nz::String hostName = Nz::IpAddress::ResolveAddress(instance.Check<Nz::IpAddress>(&argIndex), &service, &error);
|
||||||
|
|
||||||
|
if (error == Nz::ResolveError_NoError)
|
||||||
{
|
{
|
||||||
Nz::UInt16 a = lua.Check<Nz::UInt16>(&argIndex);
|
instance.Push(hostName);
|
||||||
Nz::UInt16 b = lua.Check<Nz::UInt16>(&argIndex);
|
instance.Push(service);
|
||||||
Nz::UInt16 c = lua.Check<Nz::UInt16>(&argIndex);
|
return 2;
|
||||||
Nz::UInt16 d = lua.Check<Nz::UInt16>(&argIndex);
|
|
||||||
Nz::UInt16 e = lua.Check<Nz::UInt16>(&argIndex);
|
|
||||||
Nz::UInt16 f = lua.Check<Nz::UInt16>(&argIndex);
|
|
||||||
Nz::UInt16 g = lua.Check<Nz::UInt16>(&argIndex);
|
|
||||||
Nz::UInt16 h = lua.Check<Nz::UInt16>(&argIndex);
|
|
||||||
Nz::UInt16 port = lua.Check<Nz::UInt16>(&argIndex, 0);
|
|
||||||
|
|
||||||
Nz::PlacementNew(instance, a, b, c, d, e, f, g, h, port);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
lua.Error("No matching overload for constructor");
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
ipAddress.BindMethod("GetPort", &Nz::IpAddress::GetPort);
|
|
||||||
ipAddress.BindMethod("GetProtocol", &Nz::IpAddress::GetProtocol);
|
|
||||||
ipAddress.BindMethod("IsLoopback", &Nz::IpAddress::IsLoopback);
|
|
||||||
ipAddress.BindMethod("IsValid", &Nz::IpAddress::IsValid);
|
|
||||||
ipAddress.BindMethod("ToUInt32", &Nz::IpAddress::ToUInt32);
|
|
||||||
ipAddress.BindMethod("__tostring", &Nz::IpAddress::ToString);
|
|
||||||
|
|
||||||
ipAddress.BindStaticMethod("ResolveAddress", [] (Nz::LuaInstance& instance) -> int
|
|
||||||
{
|
|
||||||
Nz::String service;
|
|
||||||
Nz::ResolveError error = Nz::ResolveError_Unknown;
|
|
||||||
|
|
||||||
int argIndex = 2;
|
|
||||||
Nz::String hostName = Nz::IpAddress::ResolveAddress(instance.Check<Nz::IpAddress>(&argIndex), &service, &error);
|
|
||||||
|
|
||||||
if (error == Nz::ResolveError_NoError)
|
|
||||||
{
|
|
||||||
instance.Push(hostName);
|
|
||||||
instance.Push(service);
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
instance.PushBoolean(false);
|
|
||||||
instance.Push(error);
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ipAddress.BindStaticMethod("ResolveHostname", [] (Nz::LuaInstance& instance) -> int
|
|
||||||
{
|
|
||||||
Nz::ResolveError error = Nz::ResolveError_Unknown;
|
|
||||||
|
|
||||||
int argIndex = 2;
|
|
||||||
Nz::NetProtocol protocol = instance.Check<Nz::NetProtocol>(&argIndex);
|
|
||||||
Nz::String hostname = instance.Check<Nz::String>(&argIndex);
|
|
||||||
Nz::String service = instance.Check<Nz::String>(&argIndex, "http");
|
|
||||||
|
|
||||||
std::vector<Nz::HostnameInfo> addresses = Nz::IpAddress::ResolveHostname(protocol, hostname, service, &error);
|
|
||||||
if (error == Nz::ResolveError_NoError)
|
|
||||||
{
|
|
||||||
int index = 1;
|
|
||||||
instance.PushTable(addresses.size());
|
|
||||||
for (Nz::HostnameInfo& info : addresses)
|
|
||||||
{
|
{
|
||||||
instance.PushInteger(index++);
|
instance.PushBoolean(false);
|
||||||
instance.PushTable(0, 4);
|
instance.Push(error);
|
||||||
instance.PushField("Address", std::move(info.address));
|
return 2;
|
||||||
instance.PushField("CanonicalName", std::move(info.canonicalName));
|
|
||||||
instance.PushField("Protocol", std::move(info.protocol));
|
|
||||||
instance.PushField("SocketType", std::move(info.socketType));
|
|
||||||
instance.SetTable();
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return 1;
|
ipAddress.BindStaticMethod("ResolveHostname", [] (Nz::LuaInstance& instance) -> int
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
instance.PushBoolean(false);
|
Nz::ResolveError error = Nz::ResolveError_Unknown;
|
||||||
instance.Push(error);
|
|
||||||
return 2;
|
int argIndex = 2;
|
||||||
}
|
Nz::NetProtocol protocol = instance.Check<Nz::NetProtocol>(&argIndex);
|
||||||
});
|
Nz::String hostname = instance.Check<Nz::String>(&argIndex);
|
||||||
|
Nz::String service = instance.Check<Nz::String>(&argIndex, "http");
|
||||||
|
|
||||||
|
std::vector<Nz::HostnameInfo> addresses = Nz::IpAddress::ResolveHostname(protocol, hostname, service, &error);
|
||||||
|
if (error == Nz::ResolveError_NoError)
|
||||||
|
{
|
||||||
|
int index = 1;
|
||||||
|
instance.PushTable(addresses.size());
|
||||||
|
for (Nz::HostnameInfo& info : addresses)
|
||||||
|
{
|
||||||
|
instance.PushInteger(index++);
|
||||||
|
instance.PushTable(0, 4);
|
||||||
|
instance.PushField("Address", std::move(info.address));
|
||||||
|
instance.PushField("CanonicalName", std::move(info.canonicalName));
|
||||||
|
instance.PushField("Protocol", std::move(info.protocol));
|
||||||
|
instance.PushField("SocketType", std::move(info.socketType));
|
||||||
|
instance.SetTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
instance.PushBoolean(false);
|
||||||
|
instance.Push(error);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -141,8 +149,7 @@ namespace Ndk
|
||||||
*
|
*
|
||||||
* \param instance Lua instance that will interact with the Network classes
|
* \param instance Lua instance that will interact with the Network classes
|
||||||
*/
|
*/
|
||||||
|
void LuaBinding_Network::Register(Nz::LuaInstance& instance)
|
||||||
void LuaBinding::RegisterNetwork(Nz::LuaInstance& instance)
|
|
||||||
{
|
{
|
||||||
// Classes
|
// Classes
|
||||||
abstractSocket.Register(instance);
|
abstractSocket.Register(instance);
|
||||||
|
|
|
||||||
|
|
@ -1,67 +1,99 @@
|
||||||
// Copyright (C) 2016 Jérôme Leclercq, Arnaud Cadot
|
// Copyright (C) 2016 Jérôme Leclercq, Arnaud Cadot
|
||||||
// This file is part of the "Nazara Development Kit"
|
// This file is part of the "Nazara Development Kit"
|
||||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
#include <NDK/LuaBinding.hpp>
|
#include <NDK/LuaBinding_Renderer.hpp>
|
||||||
#include <NDK/LuaAPI.hpp>
|
#include <NDK/LuaAPI.hpp>
|
||||||
|
#include <NDK/LuaBinding.hpp>
|
||||||
|
#include <NDK/LuaBinding_Utility.hpp>
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
/*!
|
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindRenderer(LuaBinding& binding)
|
||||||
* \brief Binds Renderer module to Lua
|
|
||||||
*/
|
|
||||||
void LuaBinding::BindRenderer()
|
|
||||||
{
|
{
|
||||||
|
return std::make_unique<LuaBinding_Renderer>(binding);
|
||||||
|
}
|
||||||
|
|
||||||
|
LuaBinding_Renderer::LuaBinding_Renderer(LuaBinding& binding) :
|
||||||
|
LuaBinding_Base(binding)
|
||||||
|
{
|
||||||
|
LuaBinding_Utility& utility = static_cast<LuaBinding_Utility&>(*m_binding.utility);
|
||||||
|
|
||||||
/*********************************** Nz::Texture ***********************************/
|
/*********************************** Nz::Texture ***********************************/
|
||||||
texture.Inherit<Nz::AbstractImageRef>(abstractImage, [] (Nz::TextureRef* textureRef) -> Nz::AbstractImageRef*
|
texture.Reset("Texture");
|
||||||
{
|
{
|
||||||
return reinterpret_cast<Nz::AbstractImageRef*>(textureRef); //TODO: Make a ObjectRefCast
|
texture.Inherit<Nz::AbstractImageRef>(utility.abstractImage, [] (Nz::TextureRef* textureRef) -> Nz::AbstractImageRef*
|
||||||
});
|
{
|
||||||
|
return reinterpret_cast<Nz::AbstractImageRef*>(textureRef); //TODO: Make a ObjectRefCast
|
||||||
|
});
|
||||||
|
|
||||||
texture.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::TextureRef* instance, std::size_t /*argumentCount*/)
|
texture.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::TextureRef* instance, std::size_t /*argumentCount*/)
|
||||||
|
{
|
||||||
|
Nz::PlacementNew(instance, Nz::Texture::New());
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
texture.BindMethod("Create", &Nz::Texture::Create, static_cast<Nz::UInt8>(1), 1U);
|
||||||
|
texture.BindMethod("Destroy", &Nz::Texture::Destroy);
|
||||||
|
|
||||||
|
//texture.BindMethod("Download", &Nz::Texture::Download);
|
||||||
|
|
||||||
|
texture.BindMethod("EnableMipmapping", &Nz::Texture::EnableMipmapping);
|
||||||
|
texture.BindMethod("EnsureMipmapsUpdate", &Nz::Texture::EnsureMipmapsUpdate);
|
||||||
|
texture.BindMethod("HasMipmaps", &Nz::Texture::HasMipmaps);
|
||||||
|
texture.BindMethod("InvalidateMipmaps", &Nz::Texture::InvalidateMipmaps);
|
||||||
|
texture.BindMethod("IsValid", &Nz::Texture::IsValid);
|
||||||
|
|
||||||
|
texture.BindMethod("LoadFromFile", &Nz::Texture::LoadFromFile, true, Nz::ImageParams());
|
||||||
|
//bool LoadFromImage(const Image& image, bool generateMipmaps = true);
|
||||||
|
//bool LoadFromMemory(const void* data, std::size_t size, const ImageParams& params = ImageParams(), bool generateMipmaps = true);
|
||||||
|
//bool LoadFromStream(Stream& stream, const ImageParams& params = ImageParams(), bool generateMipmaps = true);
|
||||||
|
|
||||||
|
texture.BindMethod("LoadArrayFromFile", &Nz::Texture::LoadArrayFromFile, Nz::Vector2ui(2, 2), true, Nz::ImageParams());
|
||||||
|
//bool LoadArrayFromImage(const Image& image, bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
||||||
|
//bool LoadArrayFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
||||||
|
//bool LoadArrayFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
||||||
|
|
||||||
|
//bool LoadCubemapFromFile(const String& filePath, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
|
||||||
|
//bool LoadCubemapFromImage(const Image& image, bool generateMipmaps = true, const CubemapParams& params = CubemapParams());
|
||||||
|
//bool LoadCubemapFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
|
||||||
|
//bool LoadCubemapFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
|
||||||
|
|
||||||
|
texture.BindMethod("LoadFaceFromFile", &Nz::Texture::LoadFaceFromFile, Nz::ImageParams());
|
||||||
|
//bool LoadFaceFromMemory(CubemapFace face, const void* data, std::size_t size, const ImageParams& params = ImageParams());
|
||||||
|
//bool LoadFaceFromStream(CubemapFace face, Stream& stream, const ImageParams& params = ImageParams());
|
||||||
|
|
||||||
|
texture.BindMethod("SaveToFile", &Nz::Texture::SaveToFile, Nz::ImageParams());
|
||||||
|
//bool SaveToStream(Stream& stream, const String& format, const ImageParams& params = ImageParams());
|
||||||
|
|
||||||
|
texture.BindMethod("SetMipmapRange", &Nz::Texture::SetMipmapRange);
|
||||||
|
|
||||||
|
texture.BindStaticMethod("IsFormatSupported", &Nz::Texture::IsFormatSupported);
|
||||||
|
texture.BindStaticMethod("IsMipmappingSupported", &Nz::Texture::IsMipmappingSupported);
|
||||||
|
texture.BindStaticMethod("IsTypeSupported", &Nz::Texture::IsTypeSupported);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************************** Nz::TextureLibrary ***********************************/
|
||||||
|
textureLibrary.Reset("TextureLibrary");
|
||||||
{
|
{
|
||||||
Nz::PlacementNew(instance, Nz::Texture::New());
|
textureLibrary.BindStaticMethod("Get", &Nz::TextureLibrary::Get);
|
||||||
return true;
|
textureLibrary.BindStaticMethod("Has", &Nz::TextureLibrary::Has);
|
||||||
});
|
textureLibrary.BindStaticMethod("Register", &Nz::TextureLibrary::Register);
|
||||||
|
textureLibrary.BindStaticMethod("Query", &Nz::TextureLibrary::Query);
|
||||||
|
textureLibrary.BindStaticMethod("Unregister", &Nz::TextureLibrary::Unregister);
|
||||||
|
}
|
||||||
|
|
||||||
texture.BindMethod("Create", &Nz::Texture::Create, static_cast<Nz::UInt8>(1), 1U);
|
/*********************************** Nz::TextureManager ***********************************/
|
||||||
texture.BindMethod("Destroy", &Nz::Texture::Destroy);
|
textureManager.Reset("textureManager");
|
||||||
|
{
|
||||||
//texture.BindMethod("Download", &Nz::Texture::Download);
|
textureManager.BindStaticMethod("Clear", &Nz::TextureManager::Clear);
|
||||||
|
textureManager.BindStaticMethod("Get", &Nz::TextureManager::Get);
|
||||||
texture.BindMethod("EnableMipmapping", &Nz::Texture::EnableMipmapping);
|
textureManager.BindStaticMethod("GetDefaultParameters", &Nz::TextureManager::GetDefaultParameters);
|
||||||
texture.BindMethod("EnsureMipmapsUpdate", &Nz::Texture::EnsureMipmapsUpdate);
|
textureManager.BindStaticMethod("Purge", &Nz::TextureManager::Purge);
|
||||||
texture.BindMethod("HasMipmaps", &Nz::Texture::HasMipmaps);
|
textureManager.BindStaticMethod("Register", &Nz::TextureManager::Register);
|
||||||
texture.BindMethod("InvalidateMipmaps", &Nz::Texture::InvalidateMipmaps);
|
textureManager.BindStaticMethod("SetDefaultParameters", &Nz::TextureManager::SetDefaultParameters);
|
||||||
texture.BindMethod("IsValid", &Nz::Texture::IsValid);
|
textureManager.BindStaticMethod("Unregister", &Nz::TextureManager::Unregister);
|
||||||
|
}
|
||||||
texture.BindMethod("LoadFromFile", &Nz::Texture::LoadFromFile, true, Nz::ImageParams());
|
|
||||||
//bool LoadFromImage(const Image& image, bool generateMipmaps = true);
|
|
||||||
//bool LoadFromMemory(const void* data, std::size_t size, const ImageParams& params = ImageParams(), bool generateMipmaps = true);
|
|
||||||
//bool LoadFromStream(Stream& stream, const ImageParams& params = ImageParams(), bool generateMipmaps = true);
|
|
||||||
|
|
||||||
texture.BindMethod("LoadArrayFromFile", &Nz::Texture::LoadArrayFromFile, Nz::Vector2ui(2, 2), true, Nz::ImageParams());
|
|
||||||
//bool LoadArrayFromImage(const Image& image, bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
|
||||||
//bool LoadArrayFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
|
||||||
//bool LoadArrayFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
|
||||||
|
|
||||||
//bool LoadCubemapFromFile(const String& filePath, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
|
|
||||||
//bool LoadCubemapFromImage(const Image& image, bool generateMipmaps = true, const CubemapParams& params = CubemapParams());
|
|
||||||
//bool LoadCubemapFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
|
|
||||||
//bool LoadCubemapFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
|
|
||||||
|
|
||||||
texture.BindMethod("LoadFaceFromFile", &Nz::Texture::LoadFaceFromFile, Nz::ImageParams());
|
|
||||||
//bool LoadFaceFromMemory(CubemapFace face, const void* data, std::size_t size, const ImageParams& params = ImageParams());
|
|
||||||
//bool LoadFaceFromStream(CubemapFace face, Stream& stream, const ImageParams& params = ImageParams());
|
|
||||||
|
|
||||||
texture.BindMethod("SaveToFile", &Nz::Texture::SaveToFile, Nz::ImageParams());
|
|
||||||
//bool SaveToStream(Stream& stream, const String& format, const ImageParams& params = ImageParams());
|
|
||||||
|
|
||||||
texture.BindMethod("SetMipmapRange", &Nz::Texture::SetMipmapRange);
|
|
||||||
|
|
||||||
texture.BindStaticMethod("IsFormatSupported", &Nz::Texture::IsFormatSupported);
|
|
||||||
texture.BindStaticMethod("IsMipmappingSupported", &Nz::Texture::IsMipmappingSupported);
|
|
||||||
texture.BindStaticMethod("IsTypeSupported", &Nz::Texture::IsTypeSupported);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -69,8 +101,10 @@ namespace Ndk
|
||||||
*
|
*
|
||||||
* \param instance Lua instance that will interact with the Renderer classes
|
* \param instance Lua instance that will interact with the Renderer classes
|
||||||
*/
|
*/
|
||||||
void LuaBinding::RegisterRenderer(Nz::LuaInstance& instance)
|
void LuaBinding_Renderer::Register(Nz::LuaInstance& instance)
|
||||||
{
|
{
|
||||||
texture.Register(instance);
|
texture.Register(instance);
|
||||||
|
textureLibrary.Register(instance);
|
||||||
|
textureManager.Register(instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,230 +2,263 @@
|
||||||
// This file is part of the "Nazara Development Kit"
|
// This file is part of the "Nazara Development Kit"
|
||||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
#include <NDK/LuaBinding.hpp>
|
#include <NDK/LuaBinding_SDK.hpp>
|
||||||
#include <NDK/LuaAPI.hpp>
|
#include <NDK/LuaAPI.hpp>
|
||||||
|
#include <NDK/LuaBinding.hpp>
|
||||||
|
#include <NDK/LuaBinding_Utility.hpp>
|
||||||
|
|
||||||
|
#ifndef NDK_SERVER
|
||||||
|
#include <NDK/LuaBinding_Graphics.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
/*!
|
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindSDK(LuaBinding& binding)
|
||||||
* \brief Binds SDK module to Lua
|
|
||||||
*/
|
|
||||||
|
|
||||||
void LuaBinding::BindSDK()
|
|
||||||
{
|
{
|
||||||
/*********************************** Ndk::Application **********************************/
|
return std::make_unique<LuaBinding_SDK>(binding);
|
||||||
|
}
|
||||||
|
|
||||||
|
LuaBinding_SDK::LuaBinding_SDK(LuaBinding& binding) :
|
||||||
|
LuaBinding_Base(binding)
|
||||||
|
{
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
//application.SetMethod("AddWindow", &Application::AddWindow);
|
LuaBinding_Graphics& graphics = static_cast<LuaBinding_Graphics&>(*m_binding.graphics);
|
||||||
|
|
||||||
application.BindMethod("EnableConsole", &Application::EnableConsole);
|
|
||||||
application.BindMethod("EnableFPSCounter", &Application::EnableFPSCounter);
|
|
||||||
|
|
||||||
application.BindMethod("IsConsoleEnabled", &Application::IsConsoleEnabled);
|
|
||||||
application.BindMethod("IsFPSCounterEnabled", &Application::IsFPSCounterEnabled);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
application.BindMethod("AddWorld", [] (Nz::LuaInstance& lua, Application* instance, std::size_t /*argumentCount*/) -> int
|
LuaBinding_Utility& utility = static_cast<LuaBinding_Utility&>(*m_binding.utility);
|
||||||
{
|
|
||||||
lua.Push(instance->AddWorld().CreateHandle());
|
|
||||||
return 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
application.BindMethod("GetUpdateTime", &Application::GetUpdateTime);
|
/*********************************** Ndk::Application **********************************/
|
||||||
application.BindMethod("Quit", &Application::Quit);
|
application.Reset("Application");
|
||||||
|
{
|
||||||
|
#ifndef NDK_SERVER
|
||||||
|
//application.SetMethod("AddWindow", &Application::AddWindow);
|
||||||
|
|
||||||
|
application.BindMethod("EnableConsole", &Application::EnableConsole);
|
||||||
|
application.BindMethod("EnableFPSCounter", &Application::EnableFPSCounter);
|
||||||
|
|
||||||
|
application.BindMethod("IsConsoleEnabled", &Application::IsConsoleEnabled);
|
||||||
|
application.BindMethod("IsFPSCounterEnabled", &Application::IsFPSCounterEnabled);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
application.BindMethod("AddWorld", [] (Nz::LuaInstance& lua, Application* instance, std::size_t /*argumentCount*/) -> int
|
||||||
|
{
|
||||||
|
lua.Push(instance->AddWorld().CreateHandle());
|
||||||
|
return 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
application.BindMethod("GetUpdateTime", &Application::GetUpdateTime);
|
||||||
|
application.BindMethod("Quit", &Application::Quit);
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************** Ndk::Console **********************************/
|
/*********************************** Ndk::Console **********************************/
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
console.Inherit<Nz::Node>(node, [] (ConsoleHandle* handle) -> Nz::Node*
|
console.Reset("Console");
|
||||||
{
|
{
|
||||||
return handle->GetObject();
|
console.Inherit<Nz::Node>(utility.node, [] (ConsoleHandle* handle) -> Nz::Node*
|
||||||
});
|
{
|
||||||
|
return handle->GetObject();
|
||||||
|
});
|
||||||
|
|
||||||
console.BindMethod("AddLine", &Console::AddLine, Nz::Color::White);
|
console.BindMethod("AddLine", &Console::AddLine, Nz::Color::White);
|
||||||
console.BindMethod("Clear", &Console::Clear);
|
console.BindMethod("Clear", &Console::Clear);
|
||||||
console.BindMethod("GetCharacterSize", &Console::GetCharacterSize);
|
console.BindMethod("GetCharacterSize", &Console::GetCharacterSize);
|
||||||
console.BindMethod("GetHistory", &Console::GetHistory);
|
console.BindMethod("GetHistory", &Console::GetHistory);
|
||||||
console.BindMethod("GetHistoryBackground", &Console::GetHistoryBackground);
|
console.BindMethod("GetHistoryBackground", &Console::GetHistoryBackground);
|
||||||
console.BindMethod("GetInput", &Console::GetInput);
|
console.BindMethod("GetInput", &Console::GetInput);
|
||||||
console.BindMethod("GetInputBackground", &Console::GetInputBackground);
|
console.BindMethod("GetInputBackground", &Console::GetInputBackground);
|
||||||
console.BindMethod("GetSize", &Console::GetSize);
|
console.BindMethod("GetSize", &Console::GetSize);
|
||||||
console.BindMethod("GetTextFont", &Console::GetTextFont);
|
console.BindMethod("GetTextFont", &Console::GetTextFont);
|
||||||
|
|
||||||
console.BindMethod("IsVisible", &Console::IsVisible);
|
console.BindMethod("IsVisible", &Console::IsVisible);
|
||||||
|
|
||||||
console.BindMethod("SendCharacter", &Console::SendCharacter);
|
console.BindMethod("SendCharacter", &Console::SendCharacter);
|
||||||
//consoleClass.SetMethod("SendEvent", &Console::SendEvent);
|
//consoleClass.SetMethod("SendEvent", &Console::SendEvent);
|
||||||
|
|
||||||
console.BindMethod("SetCharacterSize", &Console::SetCharacterSize);
|
console.BindMethod("SetCharacterSize", &Console::SetCharacterSize);
|
||||||
console.BindMethod("SetSize", &Console::SetSize);
|
console.BindMethod("SetSize", &Console::SetSize);
|
||||||
console.BindMethod("SetTextFont", &Console::SetTextFont);
|
console.BindMethod("SetTextFont", &Console::SetTextFont);
|
||||||
|
|
||||||
console.BindMethod("Show", &Console::Show, true);
|
console.BindMethod("Show", &Console::Show, true);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*********************************** Ndk::Entity **********************************/
|
/*********************************** Ndk::Entity **********************************/
|
||||||
entity.BindMethod("Enable", &Entity::Enable, true);
|
entity.Reset("Entity");
|
||||||
entity.BindMethod("GetId", &Entity::GetId);
|
|
||||||
entity.BindMethod("GetWorld", &Entity::GetWorld);
|
|
||||||
entity.BindMethod("Kill", &Entity::Kill);
|
|
||||||
entity.BindMethod("IsEnabled", &Entity::IsEnabled);
|
|
||||||
entity.BindMethod("IsValid", &Entity::IsValid);
|
|
||||||
entity.BindMethod("RemoveAllComponents", &Entity::RemoveAllComponents);
|
|
||||||
entity.BindMethod("__tostring", &EntityHandle::ToString);
|
|
||||||
|
|
||||||
entity.BindMethod("AddComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle, std::size_t /*argumentCount*/) -> int
|
|
||||||
{
|
{
|
||||||
ComponentBinding* binding = QueryComponentIndex(instance);
|
entity.BindMethod("Enable", &Entity::Enable, true);
|
||||||
|
entity.BindMethod("GetId", &Entity::GetId);
|
||||||
|
entity.BindMethod("GetWorld", &Entity::GetWorld);
|
||||||
|
entity.BindMethod("Kill", &Entity::Kill);
|
||||||
|
entity.BindMethod("IsEnabled", &Entity::IsEnabled);
|
||||||
|
entity.BindMethod("IsValid", &Entity::IsValid);
|
||||||
|
entity.BindMethod("RemoveAllComponents", &Entity::RemoveAllComponents);
|
||||||
|
entity.BindMethod("__tostring", &EntityHandle::ToString);
|
||||||
|
|
||||||
return binding->adder(instance, handle);
|
entity.BindMethod("AddComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle, std::size_t /*argumentCount*/) -> int
|
||||||
});
|
{
|
||||||
|
LuaBinding::ComponentBinding* binding = m_binding.QueryComponentIndex(instance);
|
||||||
|
|
||||||
entity.BindMethod("GetComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle, std::size_t /*argumentCount*/) -> int
|
return binding->adder(instance, handle);
|
||||||
{
|
});
|
||||||
ComponentBinding* binding = QueryComponentIndex(instance);
|
|
||||||
|
|
||||||
return binding->getter(instance, handle->GetComponent(binding->index));
|
entity.BindMethod("GetComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle, std::size_t /*argumentCount*/) -> int
|
||||||
});
|
{
|
||||||
|
LuaBinding::ComponentBinding* binding = m_binding.QueryComponentIndex(instance);
|
||||||
|
|
||||||
entity.BindMethod("RemoveComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle, std::size_t /*argumentCount*/) -> int
|
return binding->getter(instance, handle->GetComponent(binding->index));
|
||||||
{
|
});
|
||||||
ComponentBinding* binding = QueryComponentIndex(instance);
|
|
||||||
|
|
||||||
handle->RemoveComponent(binding->index);
|
entity.BindMethod("RemoveComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle, std::size_t /*argumentCount*/) -> int
|
||||||
return 0;
|
{
|
||||||
});
|
LuaBinding::ComponentBinding* binding = m_binding.QueryComponentIndex(instance);
|
||||||
|
|
||||||
|
handle->RemoveComponent(binding->index);
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************** Ndk::NodeComponent **********************************/
|
/*********************************** Ndk::NodeComponent **********************************/
|
||||||
nodeComponent.Inherit<Nz::Node>(node, [] (NodeComponentHandle* handle) -> Nz::Node*
|
nodeComponent.Reset("NodeComponent");
|
||||||
{
|
{
|
||||||
return handle->GetObject();
|
nodeComponent.Inherit<Nz::Node>(utility.node, [] (NodeComponentHandle* handle) -> Nz::Node*
|
||||||
});
|
{
|
||||||
|
return handle->GetObject();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************** Ndk::VelocityComponent **********************************/
|
/*********************************** Ndk::VelocityComponent **********************************/
|
||||||
velocityComponent.SetGetter([] (Nz::LuaInstance& lua, VelocityComponentHandle& instance)
|
velocityComponent.Reset("VelocityComponent");
|
||||||
{
|
{
|
||||||
std::size_t length;
|
velocityComponent.SetGetter([] (Nz::LuaInstance& lua, VelocityComponentHandle& instance)
|
||||||
const char* member = lua.CheckString(2, &length);
|
|
||||||
|
|
||||||
if (std::strcmp(member, "Linear") == 0)
|
|
||||||
{
|
{
|
||||||
lua.Push(instance->linearVelocity);
|
std::size_t length;
|
||||||
return true;
|
const char* member = lua.CheckString(2, &length);
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
if (std::strcmp(member, "Linear") == 0)
|
||||||
});
|
{
|
||||||
|
lua.Push(instance->linearVelocity);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
velocityComponent.SetSetter([] (Nz::LuaInstance& lua, VelocityComponentHandle& instance)
|
return false;
|
||||||
{
|
});
|
||||||
std::size_t length;
|
|
||||||
const char* member = lua.CheckString(2, &length);
|
|
||||||
|
|
||||||
int argIndex = 3;
|
velocityComponent.SetSetter([] (Nz::LuaInstance& lua, VelocityComponentHandle& instance)
|
||||||
if (std::strcmp(member, "Linear") == 0)
|
|
||||||
{
|
{
|
||||||
instance->linearVelocity = lua.Check<Nz::Vector3f>(&argIndex);
|
std::size_t length;
|
||||||
return true;
|
const char* member = lua.CheckString(2, &length);
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
int argIndex = 3;
|
||||||
});
|
if (std::strcmp(member, "Linear") == 0)
|
||||||
|
{
|
||||||
|
instance->linearVelocity = lua.Check<Nz::Vector3f>(&argIndex);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************** Ndk::World **********************************/
|
/*********************************** Ndk::World **********************************/
|
||||||
world.BindMethod("CreateEntity", &World::CreateEntity);
|
world.Reset("World");
|
||||||
world.BindMethod("CreateEntities", &World::CreateEntities);
|
{
|
||||||
world.BindMethod("Clear", &World::Clear);
|
world.BindMethod("CreateEntity", &World::CreateEntity);
|
||||||
|
world.BindMethod("CreateEntities", &World::CreateEntities);
|
||||||
|
world.BindMethod("Clear", &World::Clear);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
/*********************************** Ndk::CameraComponent **********************************/
|
/*********************************** Ndk::CameraComponent **********************************/
|
||||||
cameraComponent.Inherit<Nz::AbstractViewer>(abstractViewer, [] (CameraComponentHandle* handle) -> Nz::AbstractViewer*
|
cameraComponent.Reset("CameraComponent");
|
||||||
{
|
{
|
||||||
return handle->GetObject();
|
cameraComponent.Inherit<Nz::AbstractViewer>(graphics.abstractViewer, [] (CameraComponentHandle* handle) -> Nz::AbstractViewer*
|
||||||
});
|
{
|
||||||
|
return handle->GetObject();
|
||||||
|
});
|
||||||
|
|
||||||
cameraComponent.BindMethod("GetFOV", &Ndk::CameraComponent::GetFOV);
|
cameraComponent.BindMethod("GetFOV", &Ndk::CameraComponent::GetFOV);
|
||||||
cameraComponent.BindMethod("GetLayer", &Ndk::CameraComponent::GetLayer);
|
cameraComponent.BindMethod("GetLayer", &Ndk::CameraComponent::GetLayer);
|
||||||
|
|
||||||
cameraComponent.BindMethod("SetFOV", &Ndk::CameraComponent::SetFOV);
|
cameraComponent.BindMethod("SetFOV", &Ndk::CameraComponent::SetFOV);
|
||||||
cameraComponent.BindMethod("SetLayer", &Ndk::CameraComponent::SetLayer);
|
cameraComponent.BindMethod("SetLayer", &Ndk::CameraComponent::SetLayer);
|
||||||
cameraComponent.BindMethod("SetProjectionType", &Ndk::CameraComponent::SetProjectionType);
|
cameraComponent.BindMethod("SetProjectionType", &Ndk::CameraComponent::SetProjectionType);
|
||||||
cameraComponent.BindMethod("SetSize", (void(Ndk::CameraComponent::*)(const Nz::Vector2f&)) &Ndk::CameraComponent::SetSize);
|
cameraComponent.BindMethod("SetSize", (void(Ndk::CameraComponent::*)(const Nz::Vector2f&)) &Ndk::CameraComponent::SetSize);
|
||||||
//cameraComponent.BindMethod("SetTarget", &Ndk::CameraComponent::SetTarget);
|
//cameraComponent.BindMethod("SetTarget", &Ndk::CameraComponent::SetTarget);
|
||||||
cameraComponent.BindMethod("SetTargetRegion", &Ndk::CameraComponent::SetTargetRegion);
|
cameraComponent.BindMethod("SetTargetRegion", &Ndk::CameraComponent::SetTargetRegion);
|
||||||
cameraComponent.BindMethod("SetViewport", &Ndk::CameraComponent::SetViewport);
|
cameraComponent.BindMethod("SetViewport", &Ndk::CameraComponent::SetViewport);
|
||||||
cameraComponent.BindMethod("SetZFar", &Ndk::CameraComponent::SetZFar);
|
cameraComponent.BindMethod("SetZFar", &Ndk::CameraComponent::SetZFar);
|
||||||
cameraComponent.BindMethod("SetZNear", &Ndk::CameraComponent::SetZNear);
|
cameraComponent.BindMethod("SetZNear", &Ndk::CameraComponent::SetZNear);
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************** Ndk::GraphicsComponent **********************************/
|
/*********************************** Ndk::GraphicsComponent **********************************/
|
||||||
graphicsComponent.BindMethod("Attach", [] (Nz::LuaInstance& lua, Ndk::GraphicsComponent* instance, std::size_t argumentCount) -> int
|
graphicsComponent.Reset("GraphicsComponent");
|
||||||
{
|
{
|
||||||
/*
|
graphicsComponent.BindMethod("Attach", [] (Nz::LuaInstance& lua, Ndk::GraphicsComponent* instance, std::size_t argumentCount) -> int
|
||||||
void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0);
|
|
||||||
void Attach(Nz::InstancedRenderableRef renderable, const Nz::Matrix4f& localMatrix, int renderOrder = 0);
|
|
||||||
*/
|
|
||||||
|
|
||||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 3U);
|
|
||||||
|
|
||||||
switch (argCount)
|
|
||||||
{
|
{
|
||||||
case 1:
|
/*
|
||||||
{
|
void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0);
|
||||||
int argIndex = 2;
|
void Attach(Nz::InstancedRenderableRef renderable, const Nz::Matrix4f& localMatrix, int renderOrder = 0);
|
||||||
instance->Attach(lua.Check<Nz::InstancedRenderableRef>(&argIndex));
|
*/
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 2:
|
std::size_t argCount = std::min<std::size_t>(argumentCount, 3U);
|
||||||
{
|
|
||||||
int argIndex = 2;
|
|
||||||
Nz::InstancedRenderableRef renderable = lua.Check<Nz::InstancedRenderableRef>(&argIndex);
|
|
||||||
|
|
||||||
if (lua.IsOfType(argIndex, Nz::LuaType_Number))
|
switch (argCount)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
{
|
{
|
||||||
|
int argIndex = 2;
|
||||||
|
instance->Attach(lua.Check<Nz::InstancedRenderableRef>(&argIndex));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
int argIndex = 2;
|
||||||
|
Nz::InstancedRenderableRef renderable = lua.Check<Nz::InstancedRenderableRef>(&argIndex);
|
||||||
|
|
||||||
|
if (lua.IsOfType(argIndex, Nz::LuaType_Number))
|
||||||
|
{
|
||||||
|
int renderOrder = lua.Check<int>(&argIndex);
|
||||||
|
|
||||||
|
instance->Attach(renderable, renderOrder);
|
||||||
|
}
|
||||||
|
else if (lua.IsOfType(argIndex, "Matrix4"))
|
||||||
|
{
|
||||||
|
Nz::Matrix4f localMatrix = lua.Check<Nz::Matrix4f>(&argIndex);
|
||||||
|
|
||||||
|
instance->Attach(renderable, localMatrix);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
int argIndex = 2;
|
||||||
|
Nz::InstancedRenderableRef renderable = lua.Check<Nz::InstancedRenderableRef>(&argIndex);
|
||||||
|
Nz::Matrix4f localMatrix = lua.Check<Nz::Matrix4f>(&argIndex);
|
||||||
int renderOrder = lua.Check<int>(&argIndex);
|
int renderOrder = lua.Check<int>(&argIndex);
|
||||||
|
|
||||||
instance->Attach(renderable, renderOrder);
|
instance->Attach(renderable, localMatrix, renderOrder);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
else if (lua.IsOfType(argIndex, "Matrix4"))
|
|
||||||
{
|
|
||||||
Nz::Matrix4f localMatrix = lua.Check<Nz::Matrix4f>(&argIndex);
|
|
||||||
|
|
||||||
instance->Attach(renderable, localMatrix);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case 3:
|
lua.Error("No matching overload for method GetMemoryUsage");
|
||||||
{
|
return 0;
|
||||||
int argIndex = 2;
|
});
|
||||||
Nz::InstancedRenderableRef renderable = lua.Check<Nz::InstancedRenderableRef>(&argIndex);
|
}
|
||||||
Nz::Matrix4f localMatrix = lua.Check<Nz::Matrix4f>(&argIndex);
|
|
||||||
int renderOrder = lua.Check<int>(&argIndex);
|
|
||||||
|
|
||||||
instance->Attach(renderable, localMatrix, renderOrder);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lua.Error("No matching overload for method GetMemoryUsage");
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Components functions
|
// Components functions
|
||||||
m_componentBinding.resize(BaseComponent::GetMaxComponentIndex());
|
m_binding.BindComponent<NodeComponent>("Node");
|
||||||
|
m_binding.BindComponent<VelocityComponent>("Velocity");
|
||||||
BindComponent<NodeComponent>("Node");
|
|
||||||
BindComponent<VelocityComponent>("Velocity");
|
|
||||||
|
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
BindComponent<CameraComponent>("Camera");
|
m_binding.BindComponent<CameraComponent>("Camera");
|
||||||
BindComponent<GraphicsComponent>("Graphics");
|
m_binding.BindComponent<GraphicsComponent>("Graphics");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -234,8 +267,7 @@ namespace Ndk
|
||||||
*
|
*
|
||||||
* \param instance Lua instance that will interact with the SDK classes
|
* \param instance Lua instance that will interact with the SDK classes
|
||||||
*/
|
*/
|
||||||
|
void LuaBinding_SDK::Register(Nz::LuaInstance& instance)
|
||||||
void LuaBinding::RegisterSDK(Nz::LuaInstance& instance)
|
|
||||||
{
|
{
|
||||||
// Classes
|
// Classes
|
||||||
application.Register(instance);
|
application.Register(instance);
|
||||||
|
|
@ -251,19 +283,6 @@ namespace Ndk
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Enums
|
// Enums
|
||||||
|
|
||||||
// ComponentType (fake enumeration to expose component indexes)
|
|
||||||
instance.PushTable(0, m_componentBinding.size());
|
|
||||||
{
|
|
||||||
for (const ComponentBinding& entry : m_componentBinding)
|
|
||||||
{
|
|
||||||
if (entry.name.IsEmpty())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
instance.PushField(entry.name, entry.index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
instance.SetGlobal("ComponentType");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -273,7 +292,6 @@ namespace Ndk
|
||||||
* \param instance Lua instance that will interact with the component
|
* \param instance Lua instance that will interact with the component
|
||||||
* \param argIndex Index of the component
|
* \param argIndex Index of the component
|
||||||
*/
|
*/
|
||||||
|
|
||||||
LuaBinding::ComponentBinding* LuaBinding::QueryComponentIndex(Nz::LuaInstance& instance, int argIndex)
|
LuaBinding::ComponentBinding* LuaBinding::QueryComponentIndex(Nz::LuaInstance& instance, int argIndex)
|
||||||
{
|
{
|
||||||
switch (instance.GetType(argIndex))
|
switch (instance.GetType(argIndex))
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,18 @@
|
||||||
// This file is part of the "Nazara Development Kit"
|
// This file is part of the "Nazara Development Kit"
|
||||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
#include <NDK/LuaBinding.hpp>
|
#include <NDK/LuaBinding_Utility.hpp>
|
||||||
#include <NDK/LuaAPI.hpp>
|
#include <NDK/LuaAPI.hpp>
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
/*!
|
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindUtility(LuaBinding& binding)
|
||||||
* \brief Binds Utility module to Lua
|
{
|
||||||
*/
|
return std::make_unique<LuaBinding_Utility>(binding);
|
||||||
|
}
|
||||||
|
|
||||||
void LuaBinding::BindUtility()
|
LuaBinding_Utility::LuaBinding_Utility(LuaBinding& binding) :
|
||||||
|
LuaBinding_Base(binding)
|
||||||
{
|
{
|
||||||
/*********************************** Nz::AbstractImage **********************************/
|
/*********************************** Nz::AbstractImage **********************************/
|
||||||
abstractImage.BindMethod("GetBytesPerPixel", &Nz::AbstractImage::GetBytesPerPixel);
|
abstractImage.BindMethod("GetBytesPerPixel", &Nz::AbstractImage::GetBytesPerPixel);
|
||||||
|
|
@ -321,8 +323,7 @@ namespace Ndk
|
||||||
*
|
*
|
||||||
* \param instance Lua instance that will interact with the Utility classes
|
* \param instance Lua instance that will interact with the Utility classes
|
||||||
*/
|
*/
|
||||||
|
void LuaBinding_Utility::Register(Nz::LuaInstance& instance)
|
||||||
void LuaBinding::RegisterUtility(Nz::LuaInstance& instance)
|
|
||||||
{
|
{
|
||||||
abstractImage.Register(instance);
|
abstractImage.Register(instance);
|
||||||
font.Register(instance);
|
font.Register(instance);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue