Merge branch 'nazara-next' into vulkan
This commit is contained in:
commit
cb66dddd45
|
|
@ -1,4 +1,4 @@
|
|||
FROM debian:stretch
|
||||
FROM debian:buster
|
||||
|
||||
RUN apt-get update && apt-get install -y build-essential clang libopenal-dev libsndfile1-dev libxcb-cursor-dev libxcb-ewmh-dev libxcb-randr0-dev libxcb-icccm4-dev libxcb-keysyms1-dev libx11-dev libfreetype6-dev mesa-common-dev libgl1-mesa-dev libassimp-dev
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
// This file was automatically generated
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_COMPONENTS_GLOBAL_HPP
|
||||
#define NDK_COMPONENTS_GLOBAL_HPP
|
||||
|
||||
#include <NDK/Components/CameraComponent.hpp>
|
||||
#include <NDK/Components/CollisionComponent2D.hpp>
|
||||
#include <NDK/Components/CollisionComponent3D.hpp>
|
||||
#include <NDK/Components/ConstraintComponent2D.hpp>
|
||||
#include <NDK/Components/DebugComponent.hpp>
|
||||
#include <NDK/Components/GraphicsComponent.hpp>
|
||||
#include <NDK/Components/LifetimeComponent.hpp>
|
||||
#include <NDK/Components/LightComponent.hpp>
|
||||
#include <NDK/Components/ListenerComponent.hpp>
|
||||
#include <NDK/Components/NodeComponent.hpp>
|
||||
#include <NDK/Components/ParticleEmitterComponent.hpp>
|
||||
#include <NDK/Components/ParticleGroupComponent.hpp>
|
||||
#include <NDK/Components/PhysicsComponent2D.hpp>
|
||||
#include <NDK/Components/PhysicsComponent3D.hpp>
|
||||
#include <NDK/Components/VelocityComponent.hpp>
|
||||
|
||||
#endif // NDK_COMPONENTS_GLOBAL_HPP
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_LUABINDING_HPP
|
||||
#define NDK_LUABINDING_HPP
|
||||
|
||||
#include <NDK/Entity.hpp>
|
||||
#include <NDK/Lua/LuaBinding_Base.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding
|
||||
{
|
||||
friend class LuaBinding_SDK;
|
||||
|
||||
public:
|
||||
LuaBinding();
|
||||
~LuaBinding() = default;
|
||||
|
||||
template<typename T> void BindComponent(const Nz::String& name);
|
||||
|
||||
void RegisterClasses(Nz::LuaState& state);
|
||||
|
||||
std::unique_ptr<LuaBinding_Base> core;
|
||||
std::unique_ptr<LuaBinding_Base> math;
|
||||
std::unique_ptr<LuaBinding_Base> network;
|
||||
std::unique_ptr<LuaBinding_Base> sdk;
|
||||
std::unique_ptr<LuaBinding_Base> utility;
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
std::unique_ptr<LuaBinding_Base> audio;
|
||||
std::unique_ptr<LuaBinding_Base> graphics;
|
||||
std::unique_ptr<LuaBinding_Base> renderer;
|
||||
std::unique_ptr<LuaBinding_Base> platform;
|
||||
#endif
|
||||
|
||||
private:
|
||||
template<typename T>
|
||||
static int AddComponentOfType(Nz::LuaState& lua, EntityHandle& handle);
|
||||
|
||||
template<typename T>
|
||||
static int PushComponentOfType(Nz::LuaState& lua, BaseComponent& component);
|
||||
|
||||
using AddComponentFunc = int(*)(Nz::LuaState&, EntityHandle&);
|
||||
using GetComponentFunc = int(*)(Nz::LuaState&, BaseComponent&);
|
||||
|
||||
struct ComponentBinding
|
||||
{
|
||||
AddComponentFunc adder;
|
||||
ComponentIndex index;
|
||||
GetComponentFunc getter;
|
||||
Nz::String name;
|
||||
};
|
||||
|
||||
ComponentBinding* QueryComponentIndex(Nz::LuaState& lua, int argIndex = 2);
|
||||
|
||||
std::vector<ComponentBinding> m_componentBinding;
|
||||
std::unordered_map<Nz::String, ComponentIndex> m_componentBindingByName;
|
||||
};
|
||||
}
|
||||
|
||||
#include <NDK/Lua/LuaBinding.inl>
|
||||
|
||||
#endif // NDK_LUABINDING_HPP
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
namespace Detail
|
||||
{
|
||||
template<bool HasDefaultConstructor>
|
||||
struct AddComponentIf;
|
||||
|
||||
template<>
|
||||
struct AddComponentIf<true>
|
||||
{
|
||||
template<typename T>
|
||||
static int AddComponent(Nz::LuaState& lua, EntityHandle& handle)
|
||||
{
|
||||
T& component = handle->AddComponent<T>();
|
||||
lua.Push(component.CreateHandle());
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct AddComponentIf<false>
|
||||
{
|
||||
template<typename T>
|
||||
static int AddComponent(Nz::LuaState& lua, EntityHandle& /*handle*/)
|
||||
{
|
||||
lua.Error("Component has no default constructor and cannot be created from Lua yet");
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Binds a component to a name
|
||||
*
|
||||
* \param name Name used to retrieve the component
|
||||
*
|
||||
* \remark Produces a NazaraAssert if name is empty
|
||||
*/
|
||||
template<typename T>
|
||||
void LuaBinding::BindComponent(const Nz::String& name)
|
||||
{
|
||||
NazaraAssert(!name.IsEmpty(), "Component name cannot be empty");
|
||||
|
||||
static_assert(std::is_base_of<BaseComponent, T>::value, "ComponentType must inherit BaseComponent");
|
||||
|
||||
ComponentBinding binding;
|
||||
binding.adder = &Detail::AddComponentIf<std::is_default_constructible<T>::value>::template AddComponent<T>;
|
||||
binding.getter = &PushComponentOfType<T>;
|
||||
binding.index = T::componentIndex;
|
||||
binding.name = name;
|
||||
|
||||
if (m_componentBinding.size() <= T::componentIndex)
|
||||
m_componentBinding.resize(T::componentIndex + 1);
|
||||
|
||||
m_componentBinding[T::componentIndex] = std::move(binding);
|
||||
m_componentBindingByName[name] = T::componentIndex;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
int LuaBinding::PushComponentOfType(Nz::LuaState& lua, BaseComponent& component)
|
||||
{
|
||||
T& rightComponent = static_cast<T&>(component);
|
||||
lua.Push(rightComponent.CreateHandle());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.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/Lua/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Audio : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Audio(LuaBinding& binding);
|
||||
~LuaBinding_Audio() = default;
|
||||
|
||||
void Register(Nz::LuaState& state) 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
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.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/Prerequisites.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 LuaBinding_Platform;
|
||||
|
||||
class NDK_API LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Base(LuaBinding& binding);
|
||||
virtual ~LuaBinding_Base();
|
||||
|
||||
virtual void Register(Nz::LuaState& state) = 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);
|
||||
static std::unique_ptr<LuaBinding_Base> BindPlatform(LuaBinding& binding);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
LuaBinding& m_binding;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_BASE_HPP
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.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/Lua/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Core : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Core(LuaBinding& binding);
|
||||
~LuaBinding_Core() = default;
|
||||
|
||||
void Register(Nz::LuaState& state) 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
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.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/Lua/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Graphics : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Graphics(LuaBinding& binding);
|
||||
~LuaBinding_Graphics() = default;
|
||||
|
||||
void Register(Nz::LuaState& state) 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
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.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/Lua/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Math : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Math(LuaBinding& binding);
|
||||
~LuaBinding_Math() = default;
|
||||
|
||||
void Register(Nz::LuaState& state) 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
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_LUABINDING_NETWORK_HPP
|
||||
#define NDK_LUABINDING_NETWORK_HPP
|
||||
|
||||
#include <Nazara/Network/AbstractSocket.hpp>
|
||||
#include <Nazara/Network/IpAddress.hpp>
|
||||
#include <Nazara/Network/UdpSocket.hpp>
|
||||
#include <NDK/Lua/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Network : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Network(LuaBinding& binding);
|
||||
~LuaBinding_Network() = default;
|
||||
|
||||
void Register(Nz::LuaState& state) override;
|
||||
|
||||
Nz::LuaClass<Nz::AbstractSocket> abstractSocket;
|
||||
Nz::LuaClass<Nz::IpAddress> ipAddress;
|
||||
Nz::LuaClass<Nz::UdpSocket> udpSocket;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_NETWORK_HPP
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_LUABINDING_SYSTEM_HPP
|
||||
#define NDK_LUABINDING_SYSTEM_HPP
|
||||
|
||||
#include <Nazara/Platform/Keyboard.hpp>
|
||||
#include <NDK/Lua/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Platform : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Platform(LuaBinding& binding);
|
||||
~LuaBinding_Platform() = default;
|
||||
|
||||
void Register(Nz::LuaState& state) override;
|
||||
|
||||
// Platform
|
||||
Nz::LuaClass<Nz::Keyboard> keyboard;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_SYSTEM_HPP
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_LUABINDING_RENDERER_HPP
|
||||
#define NDK_LUABINDING_RENDERER_HPP
|
||||
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
#include <NDK/Lua/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Renderer : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Renderer(LuaBinding& binding);
|
||||
~LuaBinding_Renderer() = default;
|
||||
|
||||
void Register(Nz::LuaState& state) override;
|
||||
|
||||
Nz::LuaClass<Nz::TextureRef> texture;
|
||||
Nz::LuaClass<Nz::TextureLibrary> textureLibrary;
|
||||
Nz::LuaClass<Nz::TextureManager> textureManager;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_RENDERER_HPP
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_LUABINDING_SDK_HPP
|
||||
#define NDK_LUABINDING_SDK_HPP
|
||||
|
||||
#include <NDK/Lua/LuaBinding_Base.hpp>
|
||||
#include <NDK/Components.hpp>
|
||||
#include <NDK/Console.hpp>
|
||||
#include <NDK/Entity.hpp>
|
||||
#include <NDK/World.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class Application;
|
||||
|
||||
class NDK_API LuaBinding_SDK : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_SDK(LuaBinding& binding);
|
||||
~LuaBinding_SDK() = default;
|
||||
|
||||
void Register(Nz::LuaState& state) 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
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.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/Node.hpp>
|
||||
#include <NDK/Lua/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Utility : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Utility(LuaBinding& binding);
|
||||
~LuaBinding_Utility() = default;
|
||||
|
||||
void Register(Nz::LuaState& state) override;
|
||||
|
||||
// Utility
|
||||
Nz::LuaClass<Nz::AbstractImageRef> abstractImage;
|
||||
Nz::LuaClass<Nz::FontRef> font;
|
||||
Nz::LuaClass<Nz::Node> node;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_UTILITY_HPP
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_LUAINTERFACE_HPP
|
||||
#define NDK_LUAINTERFACE_HPP
|
||||
|
||||
#include <NDK/Prerequisites.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class LuaState;
|
||||
}
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class LuaBinding;
|
||||
|
||||
class NDK_API LuaAPI
|
||||
{
|
||||
public:
|
||||
LuaAPI() = delete;
|
||||
~LuaAPI() = delete;
|
||||
|
||||
static LuaBinding* GetBinding();
|
||||
|
||||
static bool Initialize();
|
||||
|
||||
static void RegisterClasses(Nz::LuaState& state);
|
||||
|
||||
static void Uninitialize();
|
||||
|
||||
private:
|
||||
static LuaBinding* s_binding;
|
||||
};
|
||||
}
|
||||
|
||||
#include <NDK/LuaAPI.inl>
|
||||
|
||||
#endif // NDK_LUAINTERFACE_HPP
|
||||
|
|
@ -1,687 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Lua/LuaState.hpp>
|
||||
#include <Nazara/Math/EulerAngles.hpp>
|
||||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Network/IpAddress.hpp>
|
||||
#include <Nazara/Utility/Font.hpp>
|
||||
#include <Nazara/Utility/Image.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
#include <NDK/Application.hpp>
|
||||
#include <NDK/Components.hpp>
|
||||
#include <NDK/Entity.hpp>
|
||||
#include <NDK/World.hpp>
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
#include <Nazara/Audio/Music.hpp>
|
||||
#include <Nazara/Audio/SoundBuffer.hpp>
|
||||
#include <Nazara/Graphics/Model.hpp>
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
#include <NDK/Console.hpp>
|
||||
#endif
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Color* color, TypeTag<Color>)
|
||||
{
|
||||
state.CheckType(index, Nz::LuaType_Table);
|
||||
|
||||
color->r = state.CheckField<UInt8>("r", index);
|
||||
color->g = state.CheckField<UInt8>("g", index);
|
||||
color->b = state.CheckField<UInt8>("b", index);
|
||||
color->a = state.CheckField<UInt8>("a", 255, index);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, EulerAnglesd* angles, TypeTag<EulerAnglesd>)
|
||||
{
|
||||
switch (state.GetType(index))
|
||||
{
|
||||
case Nz::LuaType_Table:
|
||||
angles->Set(state.CheckField<double>("pitch", index), state.CheckField<double>("yaw", index), state.CheckField<double>("roll", index));
|
||||
return 1;
|
||||
|
||||
default:
|
||||
{
|
||||
if (state.IsOfType(index, "EulerAngles"))
|
||||
angles->Set(*static_cast<EulerAnglesd*>(state.ToUserdata(index)));
|
||||
else
|
||||
angles->Set(*static_cast<Quaterniond*>(state.CheckUserdata(index, "Quaternion")));
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, EulerAnglesf* angles, TypeTag<EulerAnglesf>)
|
||||
{
|
||||
EulerAnglesd anglesDouble;
|
||||
unsigned int ret = LuaImplQueryArg(state, index, &anglesDouble, TypeTag<EulerAnglesd>());
|
||||
|
||||
angles->Set(anglesDouble);
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, FontRef* fontRef, TypeTag<FontRef>)
|
||||
{
|
||||
*fontRef = *static_cast<FontRef*>(state.CheckUserdata(index, "Font"));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, FontParams* params, TypeTag<FontParams>)
|
||||
{
|
||||
NazaraUnused(params);
|
||||
|
||||
state.CheckType(index, Nz::LuaType_Table);
|
||||
|
||||
// Structure is empty for now
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, ImageParams* params, TypeTag<ImageParams>)
|
||||
{
|
||||
state.CheckType(index, Nz::LuaType_Table);
|
||||
|
||||
params->levelCount = state.CheckField<Nz::UInt8>("LevelCount");
|
||||
params->loadFormat = state.CheckField<Nz::PixelFormatType>("LoadFormat");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, IpAddress* address, TypeTag<IpAddress>)
|
||||
{
|
||||
switch (state.GetType(index))
|
||||
{
|
||||
case Nz::LuaType_String:
|
||||
address->BuildFromAddress(state.CheckString(index));
|
||||
return 1;
|
||||
|
||||
default:
|
||||
*address = *static_cast<IpAddress*>(state.CheckUserdata(index, "IpAddress"));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Matrix4d* mat, TypeTag<Matrix4d>)
|
||||
{
|
||||
switch (state.GetType(index))
|
||||
{
|
||||
case Nz::LuaType_Table:
|
||||
{
|
||||
double values[16];
|
||||
for (std::size_t i = 0; i < 16; ++i)
|
||||
{
|
||||
state.PushInteger(i + 1);
|
||||
state.GetTable();
|
||||
|
||||
values[i] = state.CheckNumber(-1);
|
||||
state.Pop();
|
||||
}
|
||||
|
||||
*mat = Matrix4d(values);
|
||||
return 1;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
if (state.IsOfType(index, "Matrix4"))
|
||||
*mat = *static_cast<Matrix4d*>(state.ToUserdata(index));
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Matrix4f* mat, TypeTag<Matrix4f>)
|
||||
{
|
||||
Matrix4d matDouble = Matrix4d::Identity();
|
||||
unsigned int ret = LuaImplQueryArg(state, index, &matDouble, TypeTag<Matrix4d>());
|
||||
|
||||
mat->Set(matDouble);
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, MeshParams* params, TypeTag<MeshParams>)
|
||||
{
|
||||
state.CheckType(index, Nz::LuaType_Table);
|
||||
|
||||
params->animated = state.CheckField<bool>("Animated", params->animated);
|
||||
params->center = state.CheckField<bool>("Center", params->center);
|
||||
params->matrix = state.CheckField<Matrix4f>("Matrix", params->matrix);
|
||||
params->optimizeIndexBuffers = state.CheckField<bool>("OptimizeIndexBuffers", params->optimizeIndexBuffers);
|
||||
params->texCoordOffset = state.CheckField<Vector2f>("TexCoordOffset", params->texCoordOffset);
|
||||
params->texCoordScale = state.CheckField<Vector2f>("TexCoordScale", params->texCoordScale);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Quaterniond* quat, TypeTag<Quaterniond>)
|
||||
{
|
||||
switch (state.GetType(index))
|
||||
{
|
||||
case Nz::LuaType_Table:
|
||||
quat->Set(state.CheckField<double>("w", index), state.CheckField<double>("x", index), state.CheckField<double>("y", index), state.CheckField<double>("z", index));
|
||||
return 1;
|
||||
|
||||
default:
|
||||
{
|
||||
if (state.IsOfType(index, "EulerAngles"))
|
||||
quat->Set(*static_cast<EulerAnglesd*>(state.ToUserdata(index)));
|
||||
else
|
||||
quat->Set(*static_cast<Quaterniond*>(state.CheckUserdata(index, "Quaternion")));
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Quaternionf* quat, TypeTag<Quaternionf>)
|
||||
{
|
||||
Quaterniond quatDouble;
|
||||
unsigned int ret = LuaImplQueryArg(state, index, &quatDouble, TypeTag<Quaterniond>());
|
||||
|
||||
quat->Set(quatDouble);
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Rectd* rect, TypeTag<Rectd>)
|
||||
{
|
||||
state.CheckType(index, LuaType_Table);
|
||||
|
||||
rect->x = state.CheckField<double>("x", index);
|
||||
rect->y = state.CheckField<double>("y", index);
|
||||
rect->width = state.CheckField<double>("width", index);
|
||||
rect->height = state.CheckField<double>("height", index);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Rectf* rect, TypeTag<Rectf>)
|
||||
{
|
||||
Rectd rectDouble;
|
||||
unsigned int ret = LuaImplQueryArg(state, index, &rectDouble, TypeTag<Rectd>());
|
||||
|
||||
rect->Set(rectDouble);
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Recti* rect, TypeTag<Recti>)
|
||||
{
|
||||
Rectd rectDouble;
|
||||
unsigned int ret = LuaImplQueryArg(state, index, &rectDouble, TypeTag<Rectd>());
|
||||
|
||||
rect->Set(rectDouble);
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Rectui* rect, TypeTag<Rectui>)
|
||||
{
|
||||
Rectd rectDouble;
|
||||
unsigned int ret = LuaImplQueryArg(state, index, &rectDouble, TypeTag<Rectd>());
|
||||
|
||||
rect->Set(rectDouble);
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector2d* vec, TypeTag<Vector2d>)
|
||||
{
|
||||
switch (state.GetType(index))
|
||||
{
|
||||
case Nz::LuaType_Number:
|
||||
if (index < 0 && index > -2)
|
||||
state.Error("Vector2 expected, two numbers are required to convert it");
|
||||
|
||||
vec->Set(state.CheckNumber(index), state.CheckNumber(index + 1));
|
||||
return 2;
|
||||
|
||||
case Nz::LuaType_Table:
|
||||
vec->Set(state.CheckField<double>("x", index), state.CheckField<double>("y", index));
|
||||
return 1;
|
||||
|
||||
default:
|
||||
vec->Set(*static_cast<Vector2d*>(state.CheckUserdata(index, "Vector2")));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector2f* vec, TypeTag<Vector2f>)
|
||||
{
|
||||
Vector2d vecDouble;
|
||||
unsigned int ret = LuaImplQueryArg(state, index, &vecDouble, TypeTag<Vector2d>());
|
||||
|
||||
vec->Set(vecDouble);
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector2ui* vec, TypeTag<Vector2ui>)
|
||||
{
|
||||
Vector2d vecDouble;
|
||||
unsigned int ret = LuaImplQueryArg(state, index, &vecDouble, TypeTag<Vector2d>());
|
||||
|
||||
vec->Set(vecDouble);
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector2i* vec, TypeTag<Vector2i>)
|
||||
{
|
||||
Vector2d vecDouble;
|
||||
unsigned int ret = LuaImplQueryArg(state, index, &vecDouble, TypeTag<Vector2d>());
|
||||
|
||||
vec->Set(vecDouble);
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector3d* vec, TypeTag<Vector3d>)
|
||||
{
|
||||
switch (state.GetType(index))
|
||||
{
|
||||
case Nz::LuaType_Number:
|
||||
if (index < 0 && index > -3)
|
||||
state.Error("Vector3 expected, three numbers are required to convert it");
|
||||
|
||||
vec->Set(state.CheckNumber(index), state.CheckNumber(index + 1), state.CheckNumber(index + 2, 0.0));
|
||||
return 3;
|
||||
|
||||
case Nz::LuaType_Table:
|
||||
vec->Set(state.CheckField<double>("x", index), state.CheckField<double>("y", index), state.CheckField<double>("z", 0.0, index));
|
||||
return 1;
|
||||
|
||||
default:
|
||||
vec->Set(*static_cast<Vector3d*>(state.CheckUserdata(index, "Vector3")));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector3f* vec, TypeTag<Vector3f>)
|
||||
{
|
||||
Vector3d vecDouble;
|
||||
unsigned int ret = LuaImplQueryArg(state, index, &vecDouble, TypeTag<Vector3d>());
|
||||
|
||||
vec->Set(vecDouble);
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector3ui* vec, TypeTag<Vector3ui>)
|
||||
{
|
||||
Vector3d vecDouble;
|
||||
unsigned int ret = LuaImplQueryArg(state, index, &vecDouble, TypeTag<Vector3d>());
|
||||
|
||||
vec->Set(vecDouble);
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector3i* vec, TypeTag<Vector3i>)
|
||||
{
|
||||
Vector3d vecDouble;
|
||||
unsigned int ret = LuaImplQueryArg(state, index, &vecDouble, TypeTag<Vector3d>());
|
||||
|
||||
vec->Set(vecDouble);
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Ndk::Entity** handle, TypeTag<Ndk::Entity*>)
|
||||
{
|
||||
if (!state.IsOfType(index, LuaType_Nil))
|
||||
*handle = *static_cast<Ndk::EntityHandle*>(state.CheckUserdata(index, "Entity"));
|
||||
else
|
||||
*handle = nullptr;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Ndk::EntityHandle* handle, TypeTag<Ndk::EntityHandle>)
|
||||
{
|
||||
if (!state.IsOfType(index, LuaType_Nil))
|
||||
*handle = *static_cast<Ndk::EntityHandle*>(state.CheckUserdata(index, "Entity"));
|
||||
else
|
||||
handle->Reset();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Ndk::WorldHandle* handle, TypeTag<Ndk::WorldHandle>)
|
||||
{
|
||||
*handle = *static_cast<Ndk::WorldHandle*>(state.CheckUserdata(index, "World"));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, InstancedRenderableRef* renderable, TypeTag<InstancedRenderableRef>)
|
||||
{
|
||||
if (state.IsOfType(index, "InstancedRenderable") ||
|
||||
state.IsOfType(index, "Model") ||
|
||||
state.IsOfType(index, "Sprite"))
|
||||
{
|
||||
*renderable = *static_cast<InstancedRenderableRef*>(state.ToUserdata(index));
|
||||
}
|
||||
else
|
||||
state.ArgError(index, "is not a InstancedRenderable instance");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, MaterialRef* materialRef, TypeTag<MaterialRef>)
|
||||
{
|
||||
*materialRef = *static_cast<MaterialRef*>(state.CheckUserdata(index, "Material"));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, MaterialParams* params, TypeTag<MaterialParams>)
|
||||
{
|
||||
state.CheckType(index, Nz::LuaType_Table);
|
||||
|
||||
params->loadAlphaMap = state.CheckField<bool>("LoadAlphaMap", params->loadAlphaMap);
|
||||
params->loadDiffuseMap = state.CheckField<bool>("LoadDiffuseMap", params->loadDiffuseMap);
|
||||
params->loadEmissiveMap = state.CheckField<bool>("LoadEmissiveMap", params->loadEmissiveMap);
|
||||
params->loadHeightMap = state.CheckField<bool>("LoadHeightMap", params->loadHeightMap);
|
||||
params->loadNormalMap = state.CheckField<bool>("LoadNormalMap", params->loadNormalMap);
|
||||
params->loadSpecularMap = state.CheckField<bool>("LoadSpecularMap", params->loadSpecularMap);
|
||||
params->shaderName = state.CheckField<String>("ShaderName", params->shaderName);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, ModelParameters* params, TypeTag<ModelParameters>)
|
||||
{
|
||||
state.CheckType(index, Nz::LuaType_Table);
|
||||
|
||||
params->loadMaterials = state.CheckField<bool>("LoadMaterials", params->loadMaterials);
|
||||
|
||||
LuaImplQueryArg(state, -1, ¶ms->material, TypeTag<MaterialParams>());
|
||||
LuaImplQueryArg(state, -1, ¶ms->mesh, TypeTag<MeshParams>());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, SoundBufferParams* params, TypeTag<SoundBufferParams>)
|
||||
{
|
||||
state.CheckType(index, Nz::LuaType_Table);
|
||||
|
||||
params->forceMono = state.CheckField<bool>("ForceMono", params->forceMono);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, SoundStreamParams* params, TypeTag<SoundStreamParams>)
|
||||
{
|
||||
state.CheckType(index, Nz::LuaType_Table);
|
||||
|
||||
params->forceMono = state.CheckField<bool>("ForceMono", params->forceMono);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, SpriteRef* spriteRef, TypeTag<SpriteRef>)
|
||||
{
|
||||
*spriteRef = *static_cast<SpriteRef*>(state.CheckUserdata(index, "Sprite"));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, TextureRef* textureRef, TypeTag<TextureRef>)
|
||||
{
|
||||
*textureRef = *static_cast<TextureRef*>(state.CheckUserdata(index, "Texture"));
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Color&& val, TypeTag<Color>)
|
||||
{
|
||||
state.PushTable();
|
||||
state.PushField("r", val.r);
|
||||
state.PushField("g", val.g);
|
||||
state.PushField("b", val.b);
|
||||
state.PushField("a", val.a);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, EulerAnglesd&& val, TypeTag<EulerAnglesd>)
|
||||
{
|
||||
state.PushInstance<EulerAnglesd>("EulerAngles", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, EulerAnglesf&& val, TypeTag<EulerAnglesf>)
|
||||
{
|
||||
state.PushInstance<EulerAnglesd>("EulerAngles", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, FontRef&& val, TypeTag<FontRef>)
|
||||
{
|
||||
state.PushInstance<FontRef>("Font", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Font::SizeInfo&& val, TypeTag<Font::SizeInfo>)
|
||||
{
|
||||
state.PushTable();
|
||||
state.PushField("LineHeight", val.lineHeight);
|
||||
state.PushField("SpaceAdvance", val.spaceAdvance);
|
||||
state.PushField("UnderlinePosition", val.underlinePosition);
|
||||
state.PushField("UnderlineThickness", val.underlineThickness);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, ImageParams&& val, TypeTag<ImageParams>)
|
||||
{
|
||||
state.PushTable(0, 2);
|
||||
state.PushField("LevelCount", val.levelCount);
|
||||
state.PushField("LoadFormat", val.loadFormat);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, IpAddress&& val, TypeTag<IpAddress>)
|
||||
{
|
||||
state.PushInstance<IpAddress>("IpAddress", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Matrix4d&& val, TypeTag<Matrix4d>)
|
||||
{
|
||||
state.PushInstance<Matrix4d>("Matrix4", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Matrix4f&& val, TypeTag<Matrix4f>)
|
||||
{
|
||||
state.PushInstance<Matrix4d>("Matrix4", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Quaterniond&& val, TypeTag<Quaterniond>)
|
||||
{
|
||||
state.PushInstance<Quaterniond>("Quaternion", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Quaternionf&& val, TypeTag<Quaternionf>)
|
||||
{
|
||||
state.PushInstance<Quaterniond>("Quaternion", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Rectd&& val, TypeTag<Rectd>)
|
||||
{
|
||||
state.PushInstance<Rectd>("Rect", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Rectf&& val, TypeTag<Rectf>)
|
||||
{
|
||||
state.PushInstance<Rectd>("Rect", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Recti&& val, TypeTag<Recti>)
|
||||
{
|
||||
state.PushInstance<Rectd>("Rect", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Rectui&& val, TypeTag<Rectui>)
|
||||
{
|
||||
state.PushInstance<Rectd>("Rect", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Vector2d&& val, TypeTag<Vector2d>)
|
||||
{
|
||||
state.PushInstance<Vector2d>("Vector2", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Vector2f&& val, TypeTag<Vector2f>)
|
||||
{
|
||||
state.PushInstance<Vector2d>("Vector2", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Vector2ui&& val, TypeTag<Vector2ui>)
|
||||
{
|
||||
state.PushInstance<Vector2d>("Vector2", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Vector2i&& val, TypeTag<Vector2i>)
|
||||
{
|
||||
state.PushInstance<Vector2d>("Vector2", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Vector3d&& val, TypeTag<Vector3d>)
|
||||
{
|
||||
state.PushInstance<Vector3d>("Vector3", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Vector3f&& val, TypeTag<Vector3f>)
|
||||
{
|
||||
state.PushInstance<Vector3d>("Vector3", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Vector3ui&& val, TypeTag<Vector3ui>)
|
||||
{
|
||||
state.PushInstance<Vector3d>("Vector3", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Vector3i&& val, TypeTag<Vector3i>)
|
||||
{
|
||||
state.PushInstance<Vector3d>("Vector3", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Ndk::Entity* ptr, TypeTag<Ndk::Entity*>)
|
||||
{
|
||||
state.PushInstance<Ndk::EntityHandle>("Entity", ptr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Ndk::Application* ptr, TypeTag<Ndk::Application*>)
|
||||
{
|
||||
state.PushInstance<Ndk::Application*>("Application", ptr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Ndk::EntityHandle&& handle, TypeTag<Ndk::EntityHandle>)
|
||||
{
|
||||
state.PushInstance<Ndk::EntityHandle>("Entity", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Ndk::NodeComponentHandle&& handle, TypeTag<Ndk::NodeComponentHandle>)
|
||||
{
|
||||
state.PushInstance<Ndk::NodeComponentHandle>("NodeComponent", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Ndk::VelocityComponentHandle&& handle, TypeTag<Ndk::VelocityComponentHandle>)
|
||||
{
|
||||
state.PushInstance<Ndk::VelocityComponentHandle>("VelocityComponent", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Ndk::World* ptr, TypeTag<Ndk::World*>)
|
||||
{
|
||||
state.PushInstance<Ndk::WorldHandle>("World", ptr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Ndk::WorldHandle&& handle, TypeTag<Ndk::WorldHandle>)
|
||||
{
|
||||
state.PushInstance<Ndk::WorldHandle>("World", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
inline int LuaImplReplyVal(const LuaState& state, MaterialRef&& handle, TypeTag<MaterialRef>)
|
||||
{
|
||||
state.PushInstance<MaterialRef>("Material", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, ModelRef&& handle, TypeTag<ModelRef>)
|
||||
{
|
||||
state.PushInstance<ModelRef>("Model", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, const SoundBuffer* val, TypeTag<const SoundBuffer*>)
|
||||
{
|
||||
state.PushInstance<SoundBufferConstRef>("SoundBuffer", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, SoundBufferRef&& handle, TypeTag<SoundBufferRef>)
|
||||
{
|
||||
state.PushInstance<SoundBufferRef>("SoundBuffer", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, SpriteRef&& handle, TypeTag<SpriteRef>)
|
||||
{
|
||||
state.PushInstance<SpriteRef>("Sprite", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, TextureRef&& handle, TypeTag<TextureRef>)
|
||||
{
|
||||
state.PushInstance<TextureRef>("Texture", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Ndk::CameraComponentHandle&& handle, TypeTag<Ndk::CameraComponentHandle>)
|
||||
{
|
||||
state.PushInstance<Ndk::CameraComponentHandle>("CameraComponent", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Ndk::ConsoleHandle&& handle, TypeTag<Ndk::ConsoleHandle>)
|
||||
{
|
||||
state.PushInstance<Ndk::ConsoleHandle>("Console", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaState& state, Ndk::GraphicsComponentHandle&& handle, TypeTag<Ndk::GraphicsComponentHandle>)
|
||||
{
|
||||
state.PushInstance<Ndk::GraphicsComponentHandle>("GraphicsComponent", handle);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
// This file was automatically generated
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_SYSTEMS_GLOBAL_HPP
|
||||
#define NDK_SYSTEMS_GLOBAL_HPP
|
||||
|
||||
#include <NDK/Systems/DebugSystem.hpp>
|
||||
#include <NDK/Systems/LifetimeSystem.hpp>
|
||||
#include <NDK/Systems/ListenerSystem.hpp>
|
||||
#include <NDK/Systems/ParticleSystem.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem2D.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem3D.hpp>
|
||||
#include <NDK/Systems/RenderSystem.hpp>
|
||||
#include <NDK/Systems/VelocitySystem.hpp>
|
||||
|
||||
#endif // NDK_SYSTEMS_GLOBAL_HPP
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
// This file was automatically generated
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_WIDGETS_GLOBAL_HPP
|
||||
#define NDK_WIDGETS_GLOBAL_HPP
|
||||
|
||||
#include <NDK/Widgets/AbstractTextAreaWidget.hpp>
|
||||
#include <NDK/Widgets/BoxLayout.hpp>
|
||||
#include <NDK/Widgets/ButtonWidget.hpp>
|
||||
#include <NDK/Widgets/CheckboxWidget.hpp>
|
||||
#include <NDK/Widgets/Enums.hpp>
|
||||
#include <NDK/Widgets/ImageWidget.hpp>
|
||||
#include <NDK/Widgets/LabelWidget.hpp>
|
||||
#include <NDK/Widgets/ProgressBarWidget.hpp>
|
||||
#include <NDK/Widgets/RichTextAreaWidget.hpp>
|
||||
#include <NDK/Widgets/ScrollAreaWidget.hpp>
|
||||
#include <NDK/Widgets/TextAreaWidget.hpp>
|
||||
|
||||
#endif // NDK_WIDGETS_GLOBAL_HPP
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
// This file was automatically generated on 26 May 2014 at 01:05:31
|
||||
|
||||
#include <NDK/Lua/LuaBinding.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
* \ingroup NDK
|
||||
* \class Ndk::LuaBinding
|
||||
* \brief NDK class that represents the binding between the engine & the SDK with the Lua scripting
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief Binds modules to Lua
|
||||
*/
|
||||
|
||||
LuaBinding::LuaBinding()
|
||||
{
|
||||
core = LuaBinding_Base::BindCore(*this);
|
||||
math = LuaBinding_Base::BindMath(*this);
|
||||
network = LuaBinding_Base::BindNetwork(*this);
|
||||
utility = LuaBinding_Base::BindUtility(*this);
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
audio = LuaBinding_Base::BindAudio(*this);
|
||||
renderer = LuaBinding_Base::BindRenderer(*this);
|
||||
graphics = LuaBinding_Base::BindGraphics(*this);
|
||||
platform = LuaBinding_Base::BindPlatform(*this);
|
||||
#endif
|
||||
|
||||
sdk = LuaBinding_Base::BindSDK(*this);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Registers the classes that will be used by the Lua instance
|
||||
*
|
||||
* \param instance Lua instance that will interact with the engine & SDK
|
||||
*/
|
||||
|
||||
void LuaBinding::RegisterClasses(Nz::LuaState& state)
|
||||
{
|
||||
core->Register(state);
|
||||
math->Register(state);
|
||||
network->Register(state);
|
||||
sdk->Register(state);
|
||||
utility->Register(state);
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
audio->Register(state);
|
||||
graphics->Register(state);
|
||||
renderer->Register(state);
|
||||
platform->Register(state);
|
||||
#endif
|
||||
|
||||
// ComponentType (fake enumeration to expose component indexes)
|
||||
state.PushTable(0, m_componentBinding.size());
|
||||
{
|
||||
for (const ComponentBinding& entry : m_componentBinding)
|
||||
{
|
||||
if (entry.name.IsEmpty())
|
||||
continue;
|
||||
|
||||
state.PushField(entry.name, entry.index);
|
||||
}
|
||||
}
|
||||
state.SetGlobal("ComponentType");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,198 +0,0 @@
|
|||
// This file was automatically generated on 26 May 2014 at 01:05:31
|
||||
|
||||
#include <NDK/Lua/LuaBinding_Audio.hpp>
|
||||
#include <Nazara/Core/MemoryHelper.hpp>
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindAudio(LuaBinding& binding)
|
||||
{
|
||||
return std::make_unique<LuaBinding_Audio>(binding);
|
||||
}
|
||||
|
||||
LuaBinding_Audio::LuaBinding_Audio(LuaBinding& binding) :
|
||||
LuaBinding_Base(binding)
|
||||
{
|
||||
/*********************************** Nz::SoundEmitter **********************************/
|
||||
soundEmitter.Reset("SoundEmitter");
|
||||
{
|
||||
soundEmitter.BindMethod("EnableLooping", &Nz::SoundEmitter::EnableLooping);
|
||||
soundEmitter.BindMethod("EnableSpatialization", &Nz::SoundEmitter::EnableSpatialization);
|
||||
|
||||
soundEmitter.BindMethod("GetAttenuation", &Nz::SoundEmitter::GetAttenuation);
|
||||
soundEmitter.BindMethod("GetDuration", &Nz::SoundEmitter::GetDuration);
|
||||
soundEmitter.BindMethod("GetMinDistance", &Nz::SoundEmitter::GetMinDistance);
|
||||
soundEmitter.BindMethod("GetPitch", &Nz::SoundEmitter::GetPitch);
|
||||
soundEmitter.BindMethod("GetPlayingOffset", &Nz::SoundEmitter::GetPlayingOffset);
|
||||
soundEmitter.BindMethod("GetPosition", &Nz::Sound::GetPosition);
|
||||
soundEmitter.BindMethod("GetStatus", &Nz::SoundEmitter::GetStatus);
|
||||
soundEmitter.BindMethod("GetVelocity", &Nz::Sound::GetVelocity);
|
||||
soundEmitter.BindMethod("GetVolume", &Nz::SoundEmitter::GetVolume);
|
||||
|
||||
soundEmitter.BindMethod("IsLooping", &Nz::SoundEmitter::IsLooping);
|
||||
soundEmitter.BindMethod("IsSpatialized", &Nz::SoundEmitter::IsSpatialized);
|
||||
|
||||
soundEmitter.BindMethod("Pause", &Nz::SoundEmitter::Pause);
|
||||
soundEmitter.BindMethod("Play", &Nz::SoundEmitter::Play);
|
||||
|
||||
soundEmitter.BindMethod("SetAttenuation", &Nz::SoundEmitter::SetAttenuation);
|
||||
soundEmitter.BindMethod("SetMinDistance", &Nz::SoundEmitter::SetMinDistance);
|
||||
soundEmitter.BindMethod("SetPitch", &Nz::SoundEmitter::SetPitch);
|
||||
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("SetVolume", &Nz::SoundEmitter::SetVolume);
|
||||
|
||||
soundEmitter.BindMethod("Stop", &Nz::SoundEmitter::Stop);
|
||||
}
|
||||
|
||||
/*********************************** Nz::Music **********************************/
|
||||
music.Reset("Music");
|
||||
{
|
||||
music.Inherit(soundEmitter);
|
||||
|
||||
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::SoundStreamParams());
|
||||
|
||||
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::LuaState& lua, Nz::Music& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
Nz::StringStream ss("Music(");
|
||||
ss << instance.GetFilePath() << ')';
|
||||
|
||||
lua.PushString(ss);
|
||||
return 1;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Nz::Sound **********************************/
|
||||
sound.Reset("Sound");
|
||||
{
|
||||
sound.Inherit(soundEmitter);
|
||||
|
||||
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::LuaState& 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 **********************************/
|
||||
soundBuffer.Reset("SoundBuffer");
|
||||
{
|
||||
soundBuffer.SetConstructor([] (Nz::LuaState& lua, Nz::SoundBufferRef* instance, std::size_t argumentCount)
|
||||
{
|
||||
NazaraUnused(lua);
|
||||
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.BindStaticMethod("LoadFromFile", &Nz::SoundBuffer::LoadFromFile, Nz::SoundBufferParams());
|
||||
|
||||
soundBuffer.BindStaticMethod("IsFormatSupported", &Nz::SoundBuffer::IsFormatSupported);
|
||||
|
||||
// Manual
|
||||
soundBuffer.BindMethod("Create", [] (Nz::LuaState& 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::LuaState& 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::LuaState& 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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Registers the classes that will be used by the Lua instance
|
||||
*
|
||||
* \param instance Lua instance that will interact with the Audio classes
|
||||
*/
|
||||
void LuaBinding_Audio::Register(Nz::LuaState& state)
|
||||
{
|
||||
music.Register(state);
|
||||
sound.Register(state);
|
||||
soundBuffer.Register(state);
|
||||
soundEmitter.Register(state);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
// This file was automatically generated on 26 May 2014 at 01:05:31
|
||||
|
||||
#include <NDK/Lua/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
LuaBinding_Base::LuaBinding_Base(LuaBinding& binding) :
|
||||
m_binding(binding)
|
||||
{
|
||||
}
|
||||
|
||||
LuaBinding_Base::~LuaBinding_Base() = default;
|
||||
}
|
||||
|
|
@ -1,355 +0,0 @@
|
|||
// This file was automatically generated on 26 May 2014 at 01:05:31
|
||||
|
||||
#include <NDK/Lua/LuaBinding_Core.hpp>
|
||||
#include <Nazara/Core/MemoryHelper.hpp>
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindCore(LuaBinding& binding)
|
||||
{
|
||||
return std::make_unique<LuaBinding_Core>(binding);
|
||||
}
|
||||
|
||||
LuaBinding_Core::LuaBinding_Core(LuaBinding& binding) :
|
||||
LuaBinding_Base(binding)
|
||||
{
|
||||
/*********************************** Nz::Stream ***********************************/
|
||||
stream.Reset("Stream");
|
||||
{
|
||||
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);
|
||||
|
||||
stream.BindMethod("Read", [] (Nz::LuaState& lua, Nz::Stream& instance, std::size_t /*argumentCount*/) -> int {
|
||||
int argIndex = 2;
|
||||
|
||||
std::size_t length = lua.Check<std::size_t>(&argIndex);
|
||||
|
||||
std::unique_ptr<char[]> buffer(new char[length]);
|
||||
std::size_t readLength = instance.Read(buffer.get(), length);
|
||||
|
||||
lua.PushString(Nz::String(buffer.get(), readLength));
|
||||
return 1;
|
||||
});
|
||||
|
||||
stream.BindMethod("Write", [] (Nz::LuaState& lua, Nz::Stream& instance, std::size_t /*argumentCount*/) -> int {
|
||||
int argIndex = 2;
|
||||
|
||||
std::size_t bufferSize = 0;
|
||||
const char* buffer = lua.CheckString(argIndex, &bufferSize);
|
||||
|
||||
if (instance.IsTextModeEnabled())
|
||||
lua.Push(instance.Write(Nz::String(buffer, bufferSize)));
|
||||
else
|
||||
lua.Push(instance.Write(buffer, bufferSize));
|
||||
return 1;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Nz::Clock **********************************/
|
||||
clock.Reset("Clock");
|
||||
{
|
||||
clock.SetConstructor([] (Nz::LuaState& lua, Nz::Clock* instance, std::size_t argumentCount)
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 2U);
|
||||
|
||||
int argIndex = 2;
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
Nz::PlacementNew(instance);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for Clock constructor");
|
||||
return false;
|
||||
});
|
||||
|
||||
clock.BindMethod("GetMicroseconds", &Nz::Clock::GetMicroseconds);
|
||||
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);
|
||||
|
||||
// Manual
|
||||
clock.BindMethod("__tostring", [] (Nz::LuaState& 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 ********************************/
|
||||
directory.Reset("Directory");
|
||||
{
|
||||
directory.SetConstructor([] (Nz::LuaState& lua, Nz::Directory* instance, std::size_t argumentCount)
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 1U);
|
||||
|
||||
int argIndex = 2;
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
Nz::PlacementNew(instance);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
Nz::PlacementNew(instance, lua.Check<Nz::String>(&argIndex));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
directory.BindMethod("Close", &Nz::Directory::Close);
|
||||
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.BindStaticMethod("Create", Nz::Directory::Create);
|
||||
directory.BindStaticMethod("Exists", Nz::Directory::Exists);
|
||||
directory.BindStaticMethod("GetCurrent", Nz::Directory::GetCurrent);
|
||||
directory.BindStaticMethod("Remove", Nz::Directory::Remove);
|
||||
directory.BindStaticMethod("SetCurrent", Nz::Directory::SetCurrent);
|
||||
|
||||
// Manual
|
||||
directory.BindMethod("__tostring", [] (Nz::LuaState& lua, Nz::Directory& instance, std::size_t /*argumentCount*/) -> int {
|
||||
Nz::StringStream ss("Directory(");
|
||||
ss << instance.GetPath();
|
||||
ss << ')';
|
||||
|
||||
lua.PushString(ss);
|
||||
return 1;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Nz::File ***********************************/
|
||||
file.Reset("File");
|
||||
{
|
||||
file.Inherit(stream);
|
||||
|
||||
file.SetConstructor([] (Nz::LuaState& lua, Nz::File* instance, std::size_t argumentCount)
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 1U);
|
||||
|
||||
int argIndex = 2;
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
Nz::PlacementNew(instance);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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::LuaState& 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)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
return lua.Push(instance.Open(lua.Check<Nz::UInt32>(&argIndex, Nz::OpenMode_NotOpen)));
|
||||
|
||||
case 2:
|
||||
{
|
||||
Nz::String filePath = lua.Check<Nz::String>(&argIndex);
|
||||
Nz::UInt32 openMode = lua.Check<Nz::UInt32>(&argIndex, Nz::OpenMode_NotOpen);
|
||||
return lua.Push(instance.Open(filePath, openMode));
|
||||
}
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for method Open");
|
||||
return 0;
|
||||
});
|
||||
|
||||
file.BindMethod("SetCursorPos", [] (Nz::LuaState& lua, Nz::File& instance, std::size_t argumentCount) -> int
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 2U);
|
||||
|
||||
int argIndex = 2;
|
||||
switch (argCount)
|
||||
{
|
||||
case 1:
|
||||
return lua.Push(instance.SetCursorPos(lua.Check<Nz::UInt64>(&argIndex)));
|
||||
|
||||
case 2:
|
||||
{
|
||||
Nz::CursorPosition curPos = lua.Check<Nz::CursorPosition>(&argIndex);
|
||||
Nz::Int64 offset = lua.Check<Nz::Int64>(&argIndex);
|
||||
return lua.Push(instance.SetCursorPos(curPos, offset));
|
||||
}
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for method SetCursorPos");
|
||||
return 0;
|
||||
});
|
||||
|
||||
file.BindMethod("__tostring", [] (Nz::LuaState& 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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Registers the classes that will be used by the Lua instance
|
||||
*
|
||||
* \param instance Lua instance that will interact with the Core classes
|
||||
*/
|
||||
void LuaBinding_Core::Register(Nz::LuaState& state)
|
||||
{
|
||||
// Classes
|
||||
clock.Register(state);
|
||||
directory.Register(state);
|
||||
file.Register(state);
|
||||
stream.Register(state);
|
||||
|
||||
// Enums
|
||||
|
||||
// Nz::CursorPosition
|
||||
static_assert(Nz::CursorPosition_Max + 1 == 3, "Nz::CursorPosition has been updated but change was not reflected to Lua binding");
|
||||
state.PushTable(0, 3);
|
||||
{
|
||||
state.PushField("AtBegin", Nz::CursorPosition_AtBegin);
|
||||
state.PushField("AtCurrent", Nz::CursorPosition_AtCurrent);
|
||||
state.PushField("AtEnd", Nz::CursorPosition_AtEnd);
|
||||
}
|
||||
state.SetGlobal("CursorPosition");
|
||||
|
||||
// Nz::HashType
|
||||
static_assert(Nz::HashType_Max + 1 == 10, "Nz::HashType has been updated but change was not reflected to Lua binding");
|
||||
state.PushTable(0, 10);
|
||||
{
|
||||
state.PushField("CRC32", Nz::HashType_CRC32);
|
||||
state.PushField("CRC64", Nz::HashType_CRC64);
|
||||
state.PushField("Fletcher16", Nz::HashType_Fletcher16);
|
||||
state.PushField("MD5", Nz::HashType_MD5);
|
||||
state.PushField("SHA1", Nz::HashType_SHA1);
|
||||
state.PushField("SHA224", Nz::HashType_SHA224);
|
||||
state.PushField("SHA256", Nz::HashType_SHA256);
|
||||
state.PushField("SHA384", Nz::HashType_SHA384);
|
||||
state.PushField("SHA512", Nz::HashType_SHA512);
|
||||
state.PushField("Whirlpool", Nz::HashType_Whirlpool);
|
||||
}
|
||||
state.SetGlobal("HashType");
|
||||
|
||||
// Nz::OpenMode
|
||||
static_assert(Nz::OpenMode_Max + 1 == 8, "Nz::OpenModeFlags has been updated but change was not reflected to Lua binding");
|
||||
state.PushTable(0, Nz::OpenMode_Max + 1);
|
||||
{
|
||||
state.PushField("Append", Nz::OpenMode_Append);
|
||||
state.PushField("NotOpen", Nz::OpenMode_NotOpen);
|
||||
state.PushField("Lock", Nz::OpenMode_Lock);
|
||||
state.PushField("ReadOnly", Nz::OpenMode_ReadOnly);
|
||||
state.PushField("ReadWrite", Nz::OpenMode_ReadWrite);
|
||||
state.PushField("Text", Nz::OpenMode_Text);
|
||||
state.PushField("Truncate", Nz::OpenMode_Truncate);
|
||||
state.PushField("WriteOnly", Nz::OpenMode_WriteOnly);
|
||||
}
|
||||
state.SetGlobal("OpenMode");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,498 +0,0 @@
|
|||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#include <NDK/Lua/LuaBinding_Graphics.hpp>
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindGraphics(LuaBinding& binding)
|
||||
{
|
||||
return std::make_unique<LuaBinding_Graphics>(binding);
|
||||
}
|
||||
|
||||
LuaBinding_Graphics::LuaBinding_Graphics(LuaBinding& binding) :
|
||||
LuaBinding_Base(binding)
|
||||
{
|
||||
/*********************************** Nz::AbstractViewer ***********************************/
|
||||
abstractViewer.Reset("AbstractViewer");
|
||||
{
|
||||
abstractViewer.BindMethod("GetAspectRatio", &Nz::AbstractViewer::GetAspectRatio);
|
||||
abstractViewer.BindMethod("GetEyePosition", &Nz::AbstractViewer::GetEyePosition);
|
||||
abstractViewer.BindMethod("GetForward", &Nz::AbstractViewer::GetForward);
|
||||
//abstractViewer.BindMethod("GetFrustum", &Nz::AbstractViewer::GetFrustum);
|
||||
abstractViewer.BindMethod("GetProjectionMatrix", &Nz::AbstractViewer::GetProjectionMatrix);
|
||||
//abstractViewer.BindMethod("GetTarget", &Nz::AbstractViewer::GetTarget);
|
||||
abstractViewer.BindMethod("GetViewMatrix", &Nz::AbstractViewer::GetViewMatrix);
|
||||
abstractViewer.BindMethod("GetViewport", &Nz::AbstractViewer::GetViewport);
|
||||
abstractViewer.BindMethod("GetZFar", &Nz::AbstractViewer::GetZFar);
|
||||
abstractViewer.BindMethod("GetZNear", &Nz::AbstractViewer::GetZNear);
|
||||
}
|
||||
|
||||
/*********************************** Nz::InstancedRenderable ***********************************/
|
||||
instancedRenderable.Reset("InstancedRenderable");
|
||||
{
|
||||
instancedRenderable.BindMethod("GetMaterial", [] (Nz::LuaState& lua, Nz::InstancedRenderable* instance, std::size_t argumentCount) -> int
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 2U);
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
{
|
||||
int argIndex = 2;
|
||||
std::size_t matIndex(lua.Check<std::size_t>(&argIndex, 0));
|
||||
|
||||
return lua.Push(instance->GetMaterial(matIndex));
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
int argIndex = 2;
|
||||
std::size_t skinIndex(lua.Check<std::size_t>(&argIndex));
|
||||
std::size_t matIndex(lua.Check<std::size_t>(&argIndex));
|
||||
|
||||
return lua.Push(instance->GetMaterial(skinIndex, matIndex));
|
||||
}
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for method GetMaterial");
|
||||
return 0;
|
||||
});
|
||||
|
||||
instancedRenderable.BindMethod("GetMaterialCount", &Nz::InstancedRenderable::GetMaterialCount);
|
||||
instancedRenderable.BindMethod("GetSkin", &Nz::InstancedRenderable::GetSkin);
|
||||
instancedRenderable.BindMethod("GetSkinCount", &Nz::InstancedRenderable::GetSkinCount);
|
||||
|
||||
instancedRenderable.BindMethod("SetSkin", &Nz::InstancedRenderable::SetSkin);
|
||||
instancedRenderable.BindMethod("SetSkinCount", &Nz::InstancedRenderable::SetSkinCount);
|
||||
}
|
||||
|
||||
/*********************************** Nz::Material ***********************************/
|
||||
material.Reset("Material");
|
||||
{
|
||||
material.SetConstructor([] (Nz::LuaState& lua, Nz::MaterialRef* instance, std::size_t argumentCount)
|
||||
{
|
||||
switch (argumentCount)
|
||||
{
|
||||
case 0:
|
||||
Nz::PlacementNew(instance, Nz::Material::New());
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
{
|
||||
int argIndex = 1;
|
||||
if (lua.IsOfType(argIndex, "MaterialPipeline"))
|
||||
{
|
||||
Nz::PlacementNew(instance, Nz::Material::New(*static_cast<Nz::MaterialPipelineRef*>(lua.ToUserdata(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");
|
||||
return false;
|
||||
});
|
||||
|
||||
material.BindMethod("Configure", [] (Nz::LuaState& 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)));
|
||||
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("EnableReflectionMapping", &Nz::Material::EnableReflectionMapping);
|
||||
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("GetReflectionMode", &Nz::Material::GetReflectionMode);
|
||||
//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("IsReflectionMappingEnabled", &Nz::Material::IsReflectionMappingEnabled);
|
||||
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("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("SetReflectionMode", &Nz::Material::SetReflectionMode);
|
||||
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.BindStaticMethod("LoadFromFile", &Nz::Material::LoadFromFile, Nz::MaterialParams());
|
||||
|
||||
material.BindMethod("SetAlphaMap", [] (Nz::LuaState& 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)));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return lua.Push(instance->SetAlphaMap(lua.Check<Nz::String>(&argIndex)));
|
||||
});
|
||||
|
||||
material.BindMethod("SetDiffuseMap", [] (Nz::LuaState& 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)));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return lua.Push(instance->SetDiffuseMap(lua.Check<Nz::String>(&argIndex)));
|
||||
});
|
||||
|
||||
material.BindMethod("SetEmissiveMap", [] (Nz::LuaState& 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)));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return lua.Push(instance->SetEmissiveMap(lua.Check<Nz::String>(&argIndex)));
|
||||
});
|
||||
|
||||
material.BindMethod("SetHeightMap", [] (Nz::LuaState& 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)));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return lua.Push(instance->SetHeightMap(lua.Check<Nz::String>(&argIndex)));
|
||||
});
|
||||
|
||||
material.BindMethod("SetNormalMap", [] (Nz::LuaState& 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)));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return lua.Push(instance->SetNormalMap(lua.Check<Nz::String>(&argIndex)));
|
||||
});
|
||||
|
||||
material.BindMethod("SetShader", [] (Nz::LuaState& 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)));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return lua.Push(instance->SetShader(lua.Check<Nz::String>(&argIndex)));
|
||||
});
|
||||
|
||||
material.BindMethod("SetSpecularMap", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
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 ***********************************/
|
||||
model.Reset("Model");
|
||||
{
|
||||
model.Inherit<Nz::InstancedRenderableRef>(instancedRenderable, [] (Nz::ModelRef* modelRef) -> Nz::InstancedRenderableRef*
|
||||
{
|
||||
return reinterpret_cast<Nz::InstancedRenderableRef*>(modelRef); //TODO: Make a ObjectRefCast
|
||||
});
|
||||
|
||||
model.SetConstructor([] (Nz::LuaState& /*lua*/, Nz::ModelRef* instance, std::size_t /*argumentCount*/)
|
||||
{
|
||||
Nz::PlacementNew(instance, Nz::Model::New());
|
||||
return true;
|
||||
});
|
||||
|
||||
//modelClass.SetMethod("GetMesh", &Nz::Model::GetMesh);
|
||||
|
||||
model.BindMethod("IsAnimated", &Nz::Model::IsAnimated);
|
||||
|
||||
model.BindMethod("SetMaterial", [] (Nz::LuaState& lua, Nz::Model* instance, std::size_t argumentCount) -> int
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 3U);
|
||||
switch (argCount)
|
||||
{
|
||||
case 2:
|
||||
{
|
||||
int argIndex = 2;
|
||||
if (lua.IsOfType(argIndex, Nz::LuaType_Number))
|
||||
{
|
||||
std::size_t matIndex(lua.Check<std::size_t>(&argIndex));
|
||||
Nz::MaterialRef mat(lua.Check<Nz::MaterialRef>(&argIndex));
|
||||
|
||||
instance->SetMaterial(matIndex, std::move(mat));
|
||||
return 0;
|
||||
}
|
||||
else if (lua.IsOfType(argIndex, Nz::LuaType_String))
|
||||
{
|
||||
Nz::String subMesh(lua.Check<Nz::String>(&argIndex));
|
||||
Nz::MaterialRef mat(lua.Check<Nz::MaterialRef>(&argIndex));
|
||||
|
||||
instance->SetMaterial(subMesh, std::move(mat));
|
||||
return 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 3:
|
||||
{
|
||||
int argIndex = 2;
|
||||
if (lua.IsOfType(argIndex, Nz::LuaType_Number))
|
||||
{
|
||||
std::size_t skinIndex(lua.Check<std::size_t>(&argIndex));
|
||||
std::size_t matIndex(lua.Check<std::size_t>(&argIndex));
|
||||
Nz::MaterialRef mat(lua.Check<Nz::MaterialRef>(&argIndex));
|
||||
|
||||
instance->SetMaterial(skinIndex, matIndex, std::move(mat));
|
||||
return 0;
|
||||
}
|
||||
else if (lua.IsOfType(argIndex, Nz::LuaType_String))
|
||||
{
|
||||
std::size_t skinIndex(lua.Check<std::size_t>(&argIndex));
|
||||
Nz::String subMesh(lua.Check<Nz::String>(&argIndex));
|
||||
Nz::MaterialRef materialRef(lua.Check<Nz::MaterialRef>(&argIndex));
|
||||
|
||||
instance->SetMaterial(skinIndex, subMesh, std::move(materialRef));
|
||||
return 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for method SetMaterial");
|
||||
return 0;
|
||||
});
|
||||
|
||||
//modelClass.SetMethod("SetMesh", &Nz::Model::SetMesh);
|
||||
//modelClass.SetMethod("SetSequence", &Nz::Model::SetSequence);
|
||||
|
||||
model.BindStaticMethod("LoadFromFile", &Nz::Model::LoadFromFile, Nz::ModelParameters());
|
||||
}
|
||||
|
||||
/*********************************** Nz::Sprite ***********************************/
|
||||
sprite.Reset("Sprite");
|
||||
{
|
||||
sprite.Inherit<Nz::InstancedRenderableRef>(instancedRenderable, [] (Nz::SpriteRef* spriteRef) -> Nz::InstancedRenderableRef*
|
||||
{
|
||||
return reinterpret_cast<Nz::InstancedRenderableRef*>(spriteRef); //TODO: Make a ObjectRefCast
|
||||
});
|
||||
|
||||
sprite.SetConstructor([] (Nz::LuaState& /*lua*/, Nz::SpriteRef* instance, std::size_t /*argumentCount*/)
|
||||
{
|
||||
Nz::PlacementNew(instance, Nz::Sprite::New());
|
||||
return true;
|
||||
});
|
||||
|
||||
sprite.BindMethod("GetColor", &Nz::Sprite::GetColor);
|
||||
sprite.BindMethod("GetCornerColor", &Nz::Sprite::GetCornerColor);
|
||||
sprite.BindMethod("GetOrigin", &Nz::Sprite::GetOrigin);
|
||||
sprite.BindMethod("GetSize", &Nz::Sprite::GetSize);
|
||||
sprite.BindMethod("GetTextureCoords", &Nz::Sprite::GetTextureCoords);
|
||||
|
||||
sprite.BindMethod("SetColor", &Nz::Sprite::SetColor);
|
||||
sprite.BindMethod("SetCornerColor", &Nz::Sprite::SetCornerColor);
|
||||
sprite.BindMethod("SetDefaultMaterial", &Nz::Sprite::SetDefaultMaterial);
|
||||
sprite.BindMethod("SetOrigin", &Nz::Sprite::SetOrigin);
|
||||
sprite.BindMethod("SetSize", (void(Nz::Sprite::*)(const Nz::Vector2f&)) &Nz::Sprite::SetSize);
|
||||
sprite.BindMethod("SetTextureCoords", &Nz::Sprite::SetTextureCoords);
|
||||
sprite.BindMethod("SetTextureRect", &Nz::Sprite::SetTextureRect);
|
||||
|
||||
sprite.BindMethod("SetMaterial", [] (Nz::LuaState& lua, Nz::SpriteRef& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
int argIndex = 2;
|
||||
if (lua.IsOfType(argIndex, "Material"))
|
||||
{
|
||||
bool resizeSprite = lua.CheckBoolean(argIndex + 1, true);
|
||||
|
||||
instance->SetMaterial(*static_cast<Nz::MaterialRef*>(lua.ToUserdata(argIndex)), resizeSprite);
|
||||
}
|
||||
else if (lua.IsOfType(argIndex, Nz::LuaType_String))
|
||||
{
|
||||
bool resizeSprite = lua.CheckBoolean(argIndex + 1, true);
|
||||
|
||||
instance->SetMaterial(lua.ToString(argIndex), resizeSprite);
|
||||
}
|
||||
else if (lua.IsOfType(argIndex, Nz::LuaType_Number))
|
||||
{
|
||||
std::size_t skinIndex(lua.Check<std::size_t>(&argIndex));
|
||||
bool resizeSprite = lua.CheckBoolean(argIndex + 1, true);
|
||||
|
||||
if (lua.IsOfType(argIndex, "Material"))
|
||||
instance->SetMaterial(skinIndex, *static_cast<Nz::MaterialRef*>(lua.ToUserdata(argIndex)), resizeSprite);
|
||||
else
|
||||
instance->SetMaterial(skinIndex, lua.Check<Nz::String>(&argIndex), resizeSprite);
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
|
||||
sprite.BindMethod("SetTexture", [] (Nz::LuaState& lua, Nz::SpriteRef& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
int argIndex = 2;
|
||||
if (lua.IsOfType(argIndex, "Texture"))
|
||||
{
|
||||
bool resizeSprite = lua.CheckBoolean(argIndex + 1, true);
|
||||
|
||||
instance->SetTexture(*static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)), resizeSprite);
|
||||
}
|
||||
else if (lua.IsOfType(argIndex, Nz::LuaType_String))
|
||||
{
|
||||
bool resizeSprite = lua.CheckBoolean(argIndex + 1, true);
|
||||
|
||||
instance->SetTexture(lua.ToString(argIndex), resizeSprite);
|
||||
}
|
||||
else if (lua.IsOfType(argIndex, Nz::LuaType_Number))
|
||||
{
|
||||
std::size_t skinIndex(lua.Check<std::size_t>(&argIndex));
|
||||
bool resizeSprite = lua.CheckBoolean(argIndex + 1, true);
|
||||
|
||||
if (lua.IsOfType(argIndex, "Texture"))
|
||||
instance->SetTexture(skinIndex, *static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)), resizeSprite);
|
||||
else
|
||||
instance->SetTexture(skinIndex, lua.Check<Nz::String>(&argIndex), resizeSprite);
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Nz::SpriteLibrary ***********************************/
|
||||
spriteLibrary.Reset("SpriteLibrary");
|
||||
{
|
||||
spriteLibrary.BindStaticMethod("Get", &Nz::SpriteLibrary::Get);
|
||||
spriteLibrary.BindStaticMethod("Has", &Nz::SpriteLibrary::Has);
|
||||
spriteLibrary.BindStaticMethod("Register", &Nz::SpriteLibrary::Register);
|
||||
spriteLibrary.BindStaticMethod("Query", &Nz::SpriteLibrary::Query);
|
||||
spriteLibrary.BindStaticMethod("Unregister", &Nz::SpriteLibrary::Unregister);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Registers the classes that will be used by the Lua instance
|
||||
*
|
||||
* \param instance Lua instance that will interact with the Graphics classes
|
||||
*/
|
||||
|
||||
void LuaBinding_Graphics::Register(Nz::LuaState& state)
|
||||
{
|
||||
abstractViewer.Register(state);
|
||||
instancedRenderable.Register(state);
|
||||
material.Register(state);
|
||||
model.Register(state);
|
||||
sprite.Register(state);
|
||||
spriteLibrary.Register(state);
|
||||
|
||||
// Nz::ReflectionMode
|
||||
static_assert(Nz::ReflectionMode_Max + 1 == 3, "Nz::ReflectionMode has been updated but change was not reflected to Lua binding");
|
||||
state.PushTable(0, 3);
|
||||
{
|
||||
state.PushField("Probe", Nz::ReflectionMode_Probe);
|
||||
state.PushField("RealTime", Nz::ReflectionMode_RealTime);
|
||||
state.PushField("Skybox", Nz::ReflectionMode_Skybox);
|
||||
}
|
||||
state.SetGlobal("ReflectionMode");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,986 +0,0 @@
|
|||
// This file was automatically generated on 26 May 2014 at 01:05:31
|
||||
|
||||
#include <NDK/Lua/LuaBinding_Math.hpp>
|
||||
#include <Nazara/Core/MemoryHelper.hpp>
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
#include <cstring>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindMath(LuaBinding& binding)
|
||||
{
|
||||
return std::make_unique<LuaBinding_Math>(binding);
|
||||
}
|
||||
|
||||
LuaBinding_Math::LuaBinding_Math(LuaBinding& binding) :
|
||||
LuaBinding_Base(binding)
|
||||
{
|
||||
/*********************************** Nz::EulerAngles **********************************/
|
||||
eulerAngles.Reset("EulerAngles");
|
||||
{
|
||||
eulerAngles.SetConstructor([] (Nz::LuaState& lua, Nz::EulerAnglesd* instance, std::size_t argumentCount)
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 3U);
|
||||
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
Nz::PlacementNew(instance, Nz::EulerAnglesd::Zero());
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
Nz::PlacementNew(instance, *static_cast<Nz::EulerAnglesd*>(lua.CheckUserdata(1, "EulerAngles")));
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
Nz::PlacementNew(instance, lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3));
|
||||
return true;
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for EulerAngles constructor");
|
||||
return false;
|
||||
});
|
||||
|
||||
eulerAngles.BindMethod("Normalize", &Nz::EulerAnglesd::Normalize);
|
||||
eulerAngles.BindMethod("ToQuaternion", &Nz::EulerAnglesd::ToQuaternion);
|
||||
|
||||
eulerAngles.BindMethod("__tostring", &Nz::EulerAnglesd::ToString);
|
||||
|
||||
eulerAngles.SetGetter([] (Nz::LuaState& lua, Nz::EulerAnglesd& instance)
|
||||
{
|
||||
std::size_t length;
|
||||
const char* ypr = lua.CheckString(2, &length);
|
||||
|
||||
switch (length)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
switch (ypr[0])
|
||||
{
|
||||
case 'p':
|
||||
lua.Push(instance.pitch);
|
||||
return true;
|
||||
|
||||
case 'y':
|
||||
lua.Push(instance.yaw);
|
||||
return true;
|
||||
|
||||
case 'r':
|
||||
lua.Push(instance.roll);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 3:
|
||||
{
|
||||
if (std::memcmp(ypr, "yaw", 3) != 0)
|
||||
break;
|
||||
|
||||
lua.Push(instance.yaw);
|
||||
return true;
|
||||
}
|
||||
|
||||
case 4:
|
||||
{
|
||||
if (std::memcmp(ypr, "roll", 4) != 0)
|
||||
break;
|
||||
|
||||
lua.Push(instance.roll);
|
||||
return true;
|
||||
}
|
||||
|
||||
case 5:
|
||||
{
|
||||
if (std::memcmp(ypr, "pitch", 5) != 0)
|
||||
break;
|
||||
|
||||
lua.Push(instance.pitch);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
eulerAngles.SetSetter([] (Nz::LuaState& lua, Nz::EulerAnglesd& instance)
|
||||
{
|
||||
std::size_t length;
|
||||
const char* ypr = lua.CheckString(2, &length);
|
||||
double value = lua.CheckNumber(3);
|
||||
|
||||
switch (length)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
switch (ypr[0])
|
||||
{
|
||||
case 'p':
|
||||
instance.pitch = value;
|
||||
return true;
|
||||
|
||||
case 'y':
|
||||
instance.yaw = value;
|
||||
return true;
|
||||
|
||||
case 'r':
|
||||
instance.roll = value;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 3:
|
||||
{
|
||||
if (std::memcmp(ypr, "yaw", 3) != 0)
|
||||
break;
|
||||
|
||||
instance.yaw = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
case 4:
|
||||
{
|
||||
if (std::memcmp(ypr, "roll", 4) != 0)
|
||||
break;
|
||||
|
||||
instance.roll = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
case 5:
|
||||
{
|
||||
if (std::memcmp(ypr, "pitch", 5) != 0)
|
||||
break;
|
||||
|
||||
instance.pitch = value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Nz::Matrix4 **********************************/
|
||||
matrix4d.Reset("Matrix4");
|
||||
{
|
||||
matrix4d.SetConstructor([] (Nz::LuaState& lua, Nz::Matrix4d* matrix, std::size_t argumentCount)
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 3U);
|
||||
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
Nz::PlacementNew(matrix, Nz::Matrix4d::Zero());
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (lua.IsOfType(1, "Matrix4"))
|
||||
Nz::PlacementNew(matrix, *static_cast<Nz::Matrix4d*>(lua.ToUserdata(1)));
|
||||
break;
|
||||
|
||||
case 16:
|
||||
{
|
||||
double values[16];
|
||||
for (int i = 0; i < 16; ++i)
|
||||
values[i] = lua.CheckNumber(i);
|
||||
|
||||
Nz::PlacementNew(matrix, values);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for constructor");
|
||||
return false;
|
||||
});
|
||||
|
||||
matrix4d.BindMethod("ApplyRotation", &Nz::Matrix4d::ApplyRotation);
|
||||
matrix4d.BindMethod("ApplyScale", &Nz::Matrix4d::ApplyScale);
|
||||
matrix4d.BindMethod("ApplyTranslation", &Nz::Matrix4d::ApplyTranslation);
|
||||
|
||||
matrix4d.BindMethod("Concatenate", &Nz::Matrix4d::Concatenate);
|
||||
matrix4d.BindMethod("ConcatenateAffine", &Nz::Matrix4d::ConcatenateAffine);
|
||||
|
||||
//matrix4d.BindMethod("GetColumn", &Nz::Matrix4d::GetColumn);
|
||||
matrix4d.BindMethod("GetDeterminant", &Nz::Matrix4d::GetDeterminant);
|
||||
matrix4d.BindMethod("GetDeterminantAffine", &Nz::Matrix4d::GetDeterminantAffine);
|
||||
|
||||
matrix4d.BindMethod("GetInverse", [] (Nz::LuaState& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
Nz::Matrix4d result;
|
||||
if (instance.GetInverse(&result))
|
||||
return lua.Push(true, result);
|
||||
else
|
||||
return lua.Push(false);
|
||||
});
|
||||
|
||||
matrix4d.BindMethod("GetInverseAffine", [] (Nz::LuaState& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
Nz::Matrix4d result;
|
||||
if (instance.GetInverseAffine(&result))
|
||||
return lua.Push(true, result);
|
||||
else
|
||||
return lua.Push(false);
|
||||
});
|
||||
|
||||
matrix4d.BindMethod("GetRotation", &Nz::Matrix4d::GetRotation);
|
||||
|
||||
//matrix4d.BindMethod("GetRow", &Nz::Matrix4d::GetRow);
|
||||
matrix4d.BindMethod("GetScale", &Nz::Matrix4d::GetScale);
|
||||
matrix4d.BindMethod("GetSquaredScale", &Nz::Matrix4d::GetSquaredScale);
|
||||
matrix4d.BindMethod("GetTranslation", &Nz::Matrix4d::GetTranslation);
|
||||
|
||||
matrix4d.BindMethod("GetTransposed", [] (Nz::LuaState& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
Nz::Matrix4d result;
|
||||
instance.GetTransposed(&result);
|
||||
|
||||
return lua.Push(result);
|
||||
});
|
||||
|
||||
matrix4d.BindMethod("HasNegativeScale", &Nz::Matrix4d::HasNegativeScale);
|
||||
matrix4d.BindMethod("HasScale", &Nz::Matrix4d::HasScale);
|
||||
|
||||
matrix4d.BindMethod("Inverse", [] (Nz::LuaState& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
bool succeeded;
|
||||
instance.Inverse(&succeeded);
|
||||
|
||||
return lua.Push(succeeded);
|
||||
});
|
||||
|
||||
matrix4d.BindMethod("InverseAffine", [] (Nz::LuaState& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
bool succeeded;
|
||||
instance.InverseAffine(&succeeded);
|
||||
|
||||
return lua.Push(succeeded);
|
||||
});
|
||||
|
||||
matrix4d.BindMethod("IsAffine", &Nz::Matrix4d::IsAffine);
|
||||
matrix4d.BindMethod("IsIdentity", &Nz::Matrix4d::IsIdentity);
|
||||
|
||||
matrix4d.BindMethod("MakeIdentity", &Nz::Matrix4d::MakeIdentity);
|
||||
matrix4d.BindMethod("MakeLookAt", &Nz::Matrix4d::MakeLookAt, Nz::Vector3d::Up());
|
||||
matrix4d.BindMethod("MakeOrtho", &Nz::Matrix4d::MakeOrtho, -1.0, 1.0);
|
||||
matrix4d.BindMethod("MakePerspective", &Nz::Matrix4d::MakePerspective);
|
||||
matrix4d.BindMethod("MakeRotation", &Nz::Matrix4d::MakeRotation);
|
||||
matrix4d.BindMethod("MakeScale", &Nz::Matrix4d::MakeScale);
|
||||
matrix4d.BindMethod("MakeTranslation", &Nz::Matrix4d::MakeTranslation);
|
||||
matrix4d.BindMethod("MakeTransform", (Nz::Matrix4d&(Nz::Matrix4d::*)(const Nz::Vector3d&, const Nz::Quaterniond&, const Nz::Vector3d&)) &Nz::Matrix4d::MakeTransform, Nz::Vector3d::Unit());
|
||||
matrix4d.BindMethod("MakeViewMatrix", &Nz::Matrix4d::MakeViewMatrix);
|
||||
matrix4d.BindMethod("MakeZero", &Nz::Matrix4d::MakeZero);
|
||||
|
||||
matrix4d.BindMethod("Set", [] (Nz::LuaState& lua, Nz::Matrix4d& instance, std::size_t argumentCount) -> int
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 3U);
|
||||
|
||||
int argIndex = 2;
|
||||
switch (argCount)
|
||||
{
|
||||
case 1:
|
||||
if (lua.IsOfType(argIndex, "Matrix4"))
|
||||
instance = *static_cast<Nz::Matrix4d*>(lua.ToUserdata(argIndex));
|
||||
break;
|
||||
|
||||
case 16:
|
||||
{
|
||||
double values[16];
|
||||
for (std::size_t i = 0; i < 16; ++i)
|
||||
values[i] = lua.CheckNumber(argIndex++);
|
||||
|
||||
instance = Nz::Matrix4d(values);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for method Set");
|
||||
return 0;
|
||||
});
|
||||
|
||||
matrix4d.BindMethod("SetRotation", &Nz::Matrix4d::SetRotation);
|
||||
matrix4d.BindMethod("SetScale", &Nz::Matrix4d::SetScale);
|
||||
matrix4d.BindMethod("SetTranslation", &Nz::Matrix4d::SetTranslation);
|
||||
|
||||
matrix4d.BindMethod("Transform", [] (Nz::LuaState& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
int argIndex = 2;
|
||||
if (lua.IsOfType(argIndex, "Vector2"))
|
||||
{
|
||||
double z(lua.CheckNumber(argIndex + 1, 0.0));
|
||||
double w(lua.CheckNumber(argIndex + 2, 1.0));
|
||||
|
||||
return lua.Push(instance.Transform(*static_cast<Nz::Vector2d*>(lua.ToUserdata(argIndex)), z, w));
|
||||
}
|
||||
else if (lua.IsOfType(argIndex, "Vector3"))
|
||||
{
|
||||
double w(lua.CheckNumber(argIndex + 1, 1.0));
|
||||
|
||||
return lua.Push(instance.Transform(*static_cast<Nz::Vector3d*>(lua.ToUserdata(argIndex)), w));
|
||||
}
|
||||
//else if (lua.IsOfType(2, "Vector4"))
|
||||
// return lua.Push(instance.Transform(*static_cast<Nz::Vector4d*>(lua.ToUserdata(1))));
|
||||
|
||||
lua.Error("No matching overload for method Transform");
|
||||
return 0;
|
||||
});
|
||||
|
||||
matrix4d.BindMethod("Transpose", &Nz::Matrix4d::Transpose);
|
||||
|
||||
matrix4d.BindMethod("__tostring", &Nz::Matrix4d::ToString);
|
||||
|
||||
matrix4d.BindStaticMethod("Concatenate", &Nz::Matrix4d::Concatenate);
|
||||
matrix4d.BindStaticMethod("ConcatenateAffine", &Nz::Matrix4d::ConcatenateAffine);
|
||||
matrix4d.BindStaticMethod("Identity", &Nz::Matrix4d::Identity);
|
||||
matrix4d.BindStaticMethod("LookAt", &Nz::Matrix4d::LookAt, Nz::Vector3d::Up());
|
||||
matrix4d.BindStaticMethod("Ortho", &Nz::Matrix4d::Ortho, -1.0, 1.0);
|
||||
matrix4d.BindStaticMethod("Perspective", &Nz::Matrix4d::Perspective);
|
||||
matrix4d.BindStaticMethod("Rotate", &Nz::Matrix4d::Rotate);
|
||||
matrix4d.BindStaticMethod("Scale", &Nz::Matrix4d::Scale);
|
||||
matrix4d.BindStaticMethod("Translate", &Nz::Matrix4d::Translate);
|
||||
matrix4d.BindStaticMethod("Transform", (Nz::Matrix4d(*)(const Nz::Vector3d&, const Nz::Quaterniond&, const Nz::Vector3d&)) &Nz::Matrix4d::Transform, Nz::Vector3d::Unit());
|
||||
matrix4d.BindStaticMethod("ViewMatrix", &Nz::Matrix4d::ViewMatrix);
|
||||
matrix4d.BindStaticMethod("Zero", &Nz::Matrix4d::Zero);
|
||||
|
||||
matrix4d.SetGetter([] (Nz::LuaState& lua, Nz::Matrix4d& instance)
|
||||
{
|
||||
bool succeeded = false;
|
||||
std::size_t index = static_cast<std::size_t>(lua.ToInteger(2, &succeeded));
|
||||
if (!succeeded || index < 1 || index > 16)
|
||||
return false;
|
||||
|
||||
lua.Push(instance[index - 1]);
|
||||
return true;
|
||||
});
|
||||
|
||||
matrix4d.SetSetter([] (Nz::LuaState& lua, Nz::Matrix4d& instance)
|
||||
{
|
||||
bool succeeded = false;
|
||||
std::size_t index = static_cast<std::size_t>(lua.ToInteger(2, &succeeded));
|
||||
if (!succeeded || index < 1 || index > 16)
|
||||
return false;
|
||||
|
||||
instance[index - 1] = lua.CheckNumber(3);
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Nz::Rect **********************************/
|
||||
rect.Reset("Rect");
|
||||
{
|
||||
rect.SetConstructor([] (Nz::LuaState& lua, Nz::Rectd* instance, std::size_t argumentCount)
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 4U);
|
||||
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
case 4:
|
||||
PlacementNew(instance, lua.CheckNumber(1, 0.0), lua.CheckNumber(2, 0.0), lua.CheckNumber(3, 0.0), lua.CheckNumber(4, 0.0));
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
{
|
||||
if (lua.IsOfType(1, "Rect"))
|
||||
PlacementNew(instance, *static_cast<Nz::Rectd*>(lua.ToUserdata(1)));
|
||||
else if (lua.IsOfType(1, Nz::LuaType_Table))
|
||||
{
|
||||
// TODO => Faire sans avoir à mettre de nom dans la table et prendre les éléments un à un pour créer le Rectd
|
||||
PlacementNew(instance, lua.CheckField<double>("x", 1),
|
||||
lua.CheckField<double>("y", 1),
|
||||
lua.CheckField<double>("width", 1),
|
||||
lua.CheckField<double>("height", 1));
|
||||
}
|
||||
else if (lua.IsOfType(1, "Vector2"))
|
||||
PlacementNew(instance, *static_cast<Nz::Vector2d*>(lua.ToUserdata(1)));
|
||||
else
|
||||
break;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
if (lua.IsOfType(1, Nz::LuaType_Number) && lua.IsOfType(2, Nz::LuaType_Number))
|
||||
PlacementNew(instance, lua.CheckNumber(1), lua.CheckNumber(2));
|
||||
else if (lua.IsOfType(1, "Vector2") && lua.IsOfType(2, "Vector2"))
|
||||
PlacementNew(instance, *static_cast<Nz::Vector2d*>(lua.ToUserdata(1)), *static_cast<Nz::Vector2d*>(lua.ToUserdata(2)));
|
||||
else
|
||||
break;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for Rect constructor");
|
||||
return false;
|
||||
});
|
||||
|
||||
rect.BindMethod("__tostring", &Nz::Rectd::ToString);
|
||||
|
||||
rect.SetGetter([] (Nz::LuaState& lua, Nz::Rectd& instance)
|
||||
{
|
||||
switch (lua.GetType(2))
|
||||
{
|
||||
case Nz::LuaType_Number:
|
||||
{
|
||||
auto index = lua.CheckBoundInteger<std::size_t>(2);
|
||||
if (index < 1 || index > 4)
|
||||
return false;
|
||||
|
||||
lua.Push(instance[index - 1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
case Nz::LuaType_String:
|
||||
{
|
||||
std::size_t length;
|
||||
const char* xywh = lua.CheckString(2, &length);
|
||||
|
||||
if (length != 1)
|
||||
break;
|
||||
|
||||
switch (xywh[0])
|
||||
{
|
||||
case 'x':
|
||||
lua.Push(instance.x);
|
||||
return true;
|
||||
|
||||
case 'y':
|
||||
lua.Push(instance.y);
|
||||
return true;
|
||||
|
||||
case 'w':
|
||||
lua.Push(instance.width);
|
||||
return true;
|
||||
|
||||
case 'h':
|
||||
lua.Push(instance.height);
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
rect.SetSetter([] (Nz::LuaState& lua, Nz::Rectd& instance)
|
||||
{
|
||||
switch (lua.GetType(2))
|
||||
{
|
||||
case Nz::LuaType_Number:
|
||||
{
|
||||
auto index = lua.CheckBoundInteger<std::size_t>(2);
|
||||
if (index < 1 || index > 4)
|
||||
return false;
|
||||
|
||||
instance[index - 1] = lua.CheckNumber(2);
|
||||
return true;
|
||||
}
|
||||
|
||||
case Nz::LuaType_String:
|
||||
{
|
||||
std::size_t length;
|
||||
const char* xywh = lua.CheckString(2, &length);
|
||||
|
||||
if (length != 1)
|
||||
break;
|
||||
|
||||
double value = lua.CheckNumber(3);
|
||||
|
||||
switch (xywh[0])
|
||||
{
|
||||
case 'x':
|
||||
instance.x = value;
|
||||
return true;
|
||||
|
||||
case 'y':
|
||||
instance.y = value;
|
||||
return true;
|
||||
|
||||
case 'w':
|
||||
instance.width = value;
|
||||
return true;
|
||||
|
||||
case 'h':
|
||||
instance.height = value;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Nz::Quaternion **********************************/
|
||||
quaternion.Reset("Quaternion");
|
||||
{
|
||||
quaternion.SetConstructor([] (Nz::LuaState& lua, Nz::Quaterniond* instance, std::size_t argumentCount)
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 4U);
|
||||
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
Nz::PlacementNew(instance, Nz::Quaterniond::Zero());
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
{
|
||||
if (lua.IsOfType(1, "EulerAngles"))
|
||||
Nz::PlacementNew(instance, *static_cast<Nz::EulerAnglesd*>(lua.ToUserdata(1)));
|
||||
else if (lua.IsOfType(1, "Quaternion"))
|
||||
Nz::PlacementNew(instance, *static_cast<Nz::Quaterniond*>(lua.ToUserdata(1)));
|
||||
else
|
||||
break;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
case 2:
|
||||
Nz::PlacementNew(instance, lua.CheckNumber(1), *static_cast<Nz::Vector3d*>(lua.CheckUserdata(2, "Vector3")));
|
||||
return true;
|
||||
|
||||
case 4:
|
||||
Nz::PlacementNew(instance, lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3), lua.CheckNumber(4));
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for Quaternion constructor");
|
||||
return false;
|
||||
});
|
||||
|
||||
quaternion.BindMethod("ComputeW", &Nz::Quaterniond::ComputeW);
|
||||
quaternion.BindMethod("Conjugate", &Nz::Quaterniond::Conjugate);
|
||||
quaternion.BindMethod("DotProduct", &Nz::Quaterniond::DotProduct);
|
||||
quaternion.BindMethod("GetConjugate", &Nz::Quaterniond::GetConjugate);
|
||||
quaternion.BindMethod("GetInverse", &Nz::Quaterniond::GetInverse);
|
||||
|
||||
quaternion.BindMethod("Inverse", &Nz::Quaterniond::Inverse);
|
||||
quaternion.BindMethod("Magnitude", &Nz::Quaterniond::Magnitude);
|
||||
|
||||
quaternion.BindMethod("SquaredMagnitude", &Nz::Quaterniond::SquaredMagnitude);
|
||||
quaternion.BindMethod("ToEulerAngles", &Nz::Quaterniond::ToEulerAngles);
|
||||
|
||||
quaternion.BindMethod("__tostring", &Nz::Quaterniond::ToString);
|
||||
|
||||
quaternion.BindStaticMethod("Lerp", &Nz::Quaterniond::Lerp);
|
||||
quaternion.BindStaticMethod("RotationBetween", &Nz::Quaterniond::RotationBetween);
|
||||
quaternion.BindStaticMethod("Slerp", &Nz::Quaterniond::Slerp);
|
||||
|
||||
quaternion.BindMethod("GetNormal", [] (Nz::LuaState& lua, Nz::Quaterniond& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
double length;
|
||||
|
||||
lua.Push(instance.GetNormal(&length));
|
||||
lua.Push(length);
|
||||
|
||||
return 2;
|
||||
});
|
||||
|
||||
quaternion.BindMethod("Normalize", [] (Nz::LuaState& lua, Nz::Quaterniond& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
double length;
|
||||
|
||||
instance.Normalize(&length);
|
||||
lua.Push(1); //< instance
|
||||
lua.Push(length);
|
||||
|
||||
return 2;
|
||||
});
|
||||
|
||||
quaternion.BindStaticMethod("Normalize", [] (Nz::LuaState& state) -> int
|
||||
{
|
||||
int argIndex = 1;
|
||||
Nz::Quaterniond quat = state.Check<Nz::Quaterniond>(&argIndex);
|
||||
|
||||
double length;
|
||||
|
||||
state.Push(Nz::Quaterniond::Normalize(quat, &length));
|
||||
state.Push(length);
|
||||
|
||||
return 2;
|
||||
});
|
||||
|
||||
quaternion.SetGetter([] (Nz::LuaState& lua, Nz::Quaterniond& instance)
|
||||
{
|
||||
std::size_t length;
|
||||
const char* wxyz = lua.CheckString(2, &length);
|
||||
|
||||
if (length != 1)
|
||||
return false;
|
||||
|
||||
switch (wxyz[0])
|
||||
{
|
||||
case 'w':
|
||||
lua.Push(instance.w);
|
||||
return true;
|
||||
|
||||
case 'x':
|
||||
lua.Push(instance.x);
|
||||
return true;
|
||||
|
||||
case 'y':
|
||||
lua.Push(instance.y);
|
||||
return true;
|
||||
|
||||
case 'z':
|
||||
lua.Push(instance.z);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
quaternion.SetSetter([] (Nz::LuaState& lua, Nz::Quaterniond& instance)
|
||||
{
|
||||
std::size_t length;
|
||||
const char* wxyz = lua.CheckString(2, &length);
|
||||
|
||||
if (length != 1)
|
||||
return false;
|
||||
|
||||
double value = lua.CheckNumber(3);
|
||||
|
||||
switch (wxyz[0])
|
||||
{
|
||||
case 'w':
|
||||
instance.w = value;
|
||||
return true;
|
||||
|
||||
case 'x':
|
||||
instance.x = value;
|
||||
return true;
|
||||
|
||||
case 'y':
|
||||
instance.y = value;
|
||||
return true;
|
||||
|
||||
case 'z':
|
||||
instance.z = value;
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Nz::Vector2 **********************************/
|
||||
vector2d.Reset("Vector2");
|
||||
{
|
||||
vector2d.SetConstructor([] (Nz::LuaState& lua, Nz::Vector2d* vector, std::size_t argumentCount)
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 2U);
|
||||
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
case 2:
|
||||
Nz::PlacementNew(vector, lua.CheckNumber(1, 0.0), lua.CheckNumber(2, 0.0));
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
{
|
||||
if (lua.IsOfType(1, Nz::LuaType_Number))
|
||||
Nz::PlacementNew(vector, lua.CheckNumber(1));
|
||||
else if (lua.IsOfType(1, "Vector2"))
|
||||
Nz::PlacementNew(vector, *static_cast<Nz::Vector2d*>(lua.ToUserdata(1)));
|
||||
else
|
||||
break;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for Vector2 constructor");
|
||||
return false;
|
||||
});
|
||||
|
||||
vector2d.BindMethod("__tostring", &Nz::Vector2d::ToString);
|
||||
|
||||
vector2d.SetGetter([] (Nz::LuaState& lua, Nz::Vector2d& instance)
|
||||
{
|
||||
switch (lua.GetType(2))
|
||||
{
|
||||
case Nz::LuaType_Number:
|
||||
{
|
||||
long long index = lua.CheckInteger(2);
|
||||
if (index < 1 || index > 2)
|
||||
return false;
|
||||
|
||||
lua.Push(instance[index - 1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
case Nz::LuaType_String:
|
||||
{
|
||||
std::size_t length;
|
||||
const char* xy = lua.CheckString(2, &length);
|
||||
|
||||
if (length != 1)
|
||||
break;
|
||||
|
||||
switch (xy[0])
|
||||
{
|
||||
case 'x':
|
||||
lua.Push(instance.x);
|
||||
return true;
|
||||
|
||||
case 'y':
|
||||
lua.Push(instance.y);
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
vector2d.SetSetter([] (Nz::LuaState& lua, Nz::Vector2d& instance)
|
||||
{
|
||||
switch (lua.GetType(2))
|
||||
{
|
||||
case Nz::LuaType_Number:
|
||||
{
|
||||
long long index = lua.CheckInteger(2);
|
||||
if (index < 1 || index > 2)
|
||||
return false;
|
||||
|
||||
instance[index - 1] = lua.CheckNumber(3);
|
||||
return true;
|
||||
}
|
||||
|
||||
case Nz::LuaType_String:
|
||||
{
|
||||
std::size_t length;
|
||||
const char* xy = lua.CheckString(2, &length);
|
||||
|
||||
if (length != 1)
|
||||
break;
|
||||
|
||||
double value = lua.CheckNumber(3);
|
||||
|
||||
switch (xy[0])
|
||||
{
|
||||
case 'x':
|
||||
instance.x = value;
|
||||
return true;
|
||||
|
||||
case 'y':
|
||||
instance.y = value;
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Nz::Vector3 **********************************/
|
||||
vector3d.Reset("Vector3");
|
||||
{
|
||||
vector3d.SetConstructor([] (Nz::LuaState& lua, Nz::Vector3d* vector, std::size_t argumentCount)
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 3U);
|
||||
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
case 3:
|
||||
Nz::PlacementNew(vector, lua.CheckNumber(1, 0.0), lua.CheckNumber(2, 0.0), lua.CheckNumber(3, 0.0));
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
{
|
||||
if (lua.IsOfType(1, Nz::LuaType_Number))
|
||||
Nz::PlacementNew(vector, lua.CheckNumber(1));
|
||||
else if (lua.IsOfType(1, "Vector2"))
|
||||
Nz::PlacementNew(vector, *static_cast<Nz::Vector2d*>(lua.ToUserdata(1)));
|
||||
else if (lua.IsOfType(1, "Vector3"))
|
||||
Nz::PlacementNew(vector, *static_cast<Nz::Vector3d*>(lua.ToUserdata(1)));
|
||||
else
|
||||
break;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
if (lua.IsOfType(1, Nz::LuaType_Number))
|
||||
Nz::PlacementNew(vector, lua.CheckNumber(1), *static_cast<Nz::Vector2d*>(lua.CheckUserdata(2, "Vector2")));
|
||||
else if (lua.IsOfType(1, "Vector2"))
|
||||
Nz::PlacementNew(vector, *static_cast<Nz::Vector2d*>(lua.ToUserdata(1)), lua.CheckNumber(2));
|
||||
else
|
||||
break;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for constructor");
|
||||
return false;
|
||||
});
|
||||
|
||||
vector3d.BindMethod("__tostring", &Nz::Vector3d::ToString);
|
||||
|
||||
vector3d.SetGetter([] (Nz::LuaState& lua, Nz::Vector3d& instance)
|
||||
{
|
||||
switch (lua.GetType(2))
|
||||
{
|
||||
case Nz::LuaType_Number:
|
||||
{
|
||||
long long index = lua.CheckInteger(2);
|
||||
if (index < 1 || index > 3)
|
||||
return false;
|
||||
|
||||
lua.Push(instance[index - 1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
case Nz::LuaType_String:
|
||||
{
|
||||
std::size_t length;
|
||||
const char* xyz = lua.CheckString(2, &length);
|
||||
|
||||
if (length != 1)
|
||||
break;
|
||||
|
||||
switch (xyz[0])
|
||||
{
|
||||
case 'x':
|
||||
lua.Push(instance.x);
|
||||
return true;
|
||||
|
||||
case 'y':
|
||||
lua.Push(instance.y);
|
||||
return true;
|
||||
|
||||
case 'z':
|
||||
lua.Push(instance.z);
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
vector3d.SetSetter([] (Nz::LuaState& lua, Nz::Vector3d& instance)
|
||||
{
|
||||
switch (lua.GetType(2))
|
||||
{
|
||||
case Nz::LuaType_Number:
|
||||
{
|
||||
long long index = lua.CheckInteger(2);
|
||||
if (index < 1 || index > 3)
|
||||
return false;
|
||||
|
||||
instance[index - 1] = lua.CheckNumber(3);
|
||||
return true;
|
||||
}
|
||||
|
||||
case Nz::LuaType_String:
|
||||
{
|
||||
std::size_t length;
|
||||
const char* xyz = lua.CheckString(2, &length);
|
||||
|
||||
if (length != 1)
|
||||
break;
|
||||
|
||||
double value = lua.CheckNumber(3);
|
||||
|
||||
switch (xyz[0])
|
||||
{
|
||||
case 'x':
|
||||
instance.x = value;
|
||||
return true;
|
||||
|
||||
case 'y':
|
||||
instance.y = value;
|
||||
return true;
|
||||
|
||||
case 'z':
|
||||
instance.z = value;
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Registers the classes that will be used by the Lua instance
|
||||
*
|
||||
* \param instance Lua instance that will interact with the Math classes
|
||||
*/
|
||||
void LuaBinding_Math::Register(Nz::LuaState& state)
|
||||
{
|
||||
eulerAngles.Register(state);
|
||||
matrix4d.Register(state);
|
||||
quaternion.Register(state);
|
||||
rect.Register(state);
|
||||
vector2d.Register(state);
|
||||
vector3d.Register(state);
|
||||
|
||||
quaternion.PushGlobalTable(state);
|
||||
{
|
||||
state.PushField("Identity", Nz::Quaterniond::Identity());
|
||||
state.PushField("Zero", Nz::Quaterniond::Zero());
|
||||
}
|
||||
state.Pop();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,314 +0,0 @@
|
|||
// This file was automatically generated on 26 May 2014 at 01:05:31
|
||||
|
||||
#include <NDK/Lua/LuaBinding_Network.hpp>
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindNetwork(LuaBinding& binding)
|
||||
{
|
||||
return std::make_unique<LuaBinding_Network>(binding);
|
||||
}
|
||||
|
||||
LuaBinding_Network::LuaBinding_Network(LuaBinding& binding) :
|
||||
LuaBinding_Base(binding)
|
||||
{
|
||||
/*********************************** Nz::AbstractSocket **********************************/
|
||||
abstractSocket.Reset("AbstractSocket");
|
||||
{
|
||||
abstractSocket.BindMethod("Close", &Nz::AbstractSocket::Close);
|
||||
abstractSocket.BindMethod("EnableBlocking", &Nz::AbstractSocket::EnableBlocking);
|
||||
abstractSocket.BindMethod("GetLastError", &Nz::AbstractSocket::GetLastError);
|
||||
abstractSocket.BindMethod("GetState", &Nz::AbstractSocket::GetState);
|
||||
abstractSocket.BindMethod("GetType", &Nz::AbstractSocket::GetType);
|
||||
abstractSocket.BindMethod("IsBlockingEnabled", &Nz::AbstractSocket::IsBlockingEnabled);
|
||||
abstractSocket.BindMethod("QueryAvailableBytes", &Nz::AbstractSocket::QueryAvailableBytes);
|
||||
}
|
||||
|
||||
/*********************************** Nz::IpAddress **********************************/
|
||||
ipAddress.Reset("IpAddress");
|
||||
{
|
||||
ipAddress.SetConstructor([] (Nz::LuaState& lua, Nz::IpAddress* instance, std::size_t argumentCount)
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 9U);
|
||||
|
||||
int argIndex = 1;
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
Nz::PlacementNew(instance);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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::LuaState& state) -> int
|
||||
{
|
||||
Nz::String service;
|
||||
Nz::ResolveError error = Nz::ResolveError_Unknown;
|
||||
|
||||
int argIndex = 2;
|
||||
Nz::String hostName = Nz::IpAddress::ResolveAddress(state.Check<Nz::IpAddress>(&argIndex), &service, &error);
|
||||
|
||||
if (error == Nz::ResolveError_NoError)
|
||||
{
|
||||
state.Push(hostName);
|
||||
state.Push(service);
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
state.PushBoolean(false);
|
||||
state.Push(error);
|
||||
return 2;
|
||||
}
|
||||
});
|
||||
|
||||
ipAddress.BindStaticMethod("ResolveHostname", [] (Nz::LuaState& state) -> int
|
||||
{
|
||||
Nz::ResolveError error = Nz::ResolveError_Unknown;
|
||||
|
||||
int argIndex = 2;
|
||||
Nz::NetProtocol protocol = state.Check<Nz::NetProtocol>(&argIndex);
|
||||
Nz::String hostname = state.Check<Nz::String>(&argIndex);
|
||||
Nz::String service = state.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;
|
||||
state.PushTable(addresses.size());
|
||||
for (Nz::HostnameInfo& info : addresses)
|
||||
{
|
||||
state.PushInteger(index++);
|
||||
state.PushTable(0, 4);
|
||||
state.PushField("Address", std::move(info.address));
|
||||
state.PushField("CanonicalName", std::move(info.canonicalName));
|
||||
state.PushField("Protocol", std::move(info.protocol));
|
||||
state.PushField("SocketType", std::move(info.socketType));
|
||||
state.SetTable();
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
state.PushBoolean(false);
|
||||
state.Push(error);
|
||||
return 2;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
udpSocket.Reset("UdpSocket");
|
||||
{
|
||||
udpSocket.Inherit<Nz::AbstractSocket>(abstractSocket);
|
||||
|
||||
udpSocket.BindDefaultConstructor();
|
||||
|
||||
udpSocket.BindMethod("Create", &Nz::UdpSocket::Create);
|
||||
udpSocket.BindMethod("EnableBroadcasting", &Nz::UdpSocket::EnableBroadcasting);
|
||||
udpSocket.BindMethod("GetBoundAddress", &Nz::UdpSocket::GetBoundAddress);
|
||||
udpSocket.BindMethod("GetBoundPort", &Nz::UdpSocket::GetBoundPort);
|
||||
udpSocket.BindMethod("IsBroadcastingEnabled", &Nz::UdpSocket::IsBroadcastingEnabled);
|
||||
udpSocket.BindMethod("QueryMaxDatagramSize", &Nz::UdpSocket::QueryMaxDatagramSize);
|
||||
|
||||
udpSocket.BindMethod("Bind", [](Nz::LuaState& lua, Nz::UdpSocket& socket, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
int argIndex = 2;
|
||||
if (lua.IsOfType(argIndex, "IpAddress"))
|
||||
return lua.Push(socket.Bind(*static_cast<Nz::IpAddress*>(lua.ToUserdata(argIndex))));
|
||||
else
|
||||
return lua.Push(socket.Bind(lua.Check<Nz::UInt16>(&argIndex)));
|
||||
});
|
||||
|
||||
udpSocket.BindMethod("Receive", [](Nz::LuaState& lua, Nz::UdpSocket& socket, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
Nz::IpAddress from;
|
||||
|
||||
std::array<char, 0xFFFF> buffer;
|
||||
std::size_t received;
|
||||
if (socket.Receive(buffer.data(), buffer.size(), &from, &received))
|
||||
{
|
||||
lua.PushBoolean(true);
|
||||
lua.PushString(from.ToString());
|
||||
lua.PushString(buffer.data(), received);
|
||||
return 3;
|
||||
}
|
||||
|
||||
lua.PushBoolean(false);
|
||||
return 1;
|
||||
});
|
||||
|
||||
udpSocket.BindMethod("Send", [](Nz::LuaState& lua, Nz::UdpSocket& socket, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
int argIndex = 2;
|
||||
Nz::String to = lua.Check<Nz::String>(&argIndex);
|
||||
|
||||
std::size_t bufferLength;
|
||||
const char* buffer = lua.CheckString(argIndex, &bufferLength);
|
||||
|
||||
std::size_t sent;
|
||||
bool ret;
|
||||
if ((ret = socket.Send(Nz::IpAddress(to), buffer, bufferLength, &sent)) != true)
|
||||
sent = 0;
|
||||
|
||||
return lua.Push(std::make_pair(ret, sent));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Registers the classes that will be used by the Lua instance
|
||||
*
|
||||
* \param instance Lua instance that will interact with the Network classes
|
||||
*/
|
||||
void LuaBinding_Network::Register(Nz::LuaState& state)
|
||||
{
|
||||
// Classes
|
||||
abstractSocket.Register(state);
|
||||
ipAddress.Register(state);
|
||||
udpSocket.Register(state);
|
||||
|
||||
// Enums
|
||||
|
||||
// Nz::NetProtocol
|
||||
static_assert(Nz::NetProtocol_Max + 1 == 4, "Nz::NetProtocol has been updated but change was not reflected to Lua binding");
|
||||
state.PushTable(0, 4);
|
||||
{
|
||||
state.PushField("Any", Nz::NetProtocol_Any);
|
||||
state.PushField("IPv4", Nz::NetProtocol_IPv4);
|
||||
state.PushField("IPv6", Nz::NetProtocol_IPv6);
|
||||
state.PushField("Unknown", Nz::NetProtocol_Unknown);
|
||||
}
|
||||
state.SetGlobal("NetProtocol");
|
||||
|
||||
// Nz::PacketPriority
|
||||
static_assert(Nz::PacketPriority_Max + 1 == 4, "Nz::PacketPriority has been updated but change was not reflected to Lua binding");
|
||||
state.PushTable(0, 6);
|
||||
{
|
||||
state.PushField("High", Nz::PacketPriority_High);
|
||||
state.PushField("Highest", Nz::PacketPriority_Highest);
|
||||
state.PushField("Immediate", Nz::PacketPriority_Immediate);
|
||||
state.PushField("Medium", Nz::PacketPriority_Medium);
|
||||
state.PushField("Low", Nz::PacketPriority_Low);
|
||||
state.PushField("Lowest", Nz::PacketPriority_Lowest);
|
||||
}
|
||||
state.SetGlobal("PacketPriority");
|
||||
|
||||
// Nz::PacketReliability
|
||||
static_assert(Nz::PacketReliability_Max + 1 == 3, "Nz::PacketReliability has been updated but change was not reflected to Lua binding");
|
||||
state.PushTable(0, 3);
|
||||
{
|
||||
state.PushField("Reliable", Nz::PacketReliability_Reliable);
|
||||
state.PushField("ReliableOrdered", Nz::PacketReliability_ReliableOrdered);
|
||||
state.PushField("Unreliable", Nz::PacketReliability_Unreliable);
|
||||
}
|
||||
state.SetGlobal("PacketReliability");
|
||||
|
||||
// Nz::ResolveError
|
||||
static_assert(Nz::ResolveError_Max + 1 == 9, "Nz::ResolveError has been updated but change was not reflected to Lua binding");
|
||||
state.PushTable(0, 9);
|
||||
{
|
||||
state.PushField("Internal", Nz::ResolveError_Internal);
|
||||
state.PushField("ResourceError", Nz::ResolveError_ResourceError);
|
||||
state.PushField("NoError", Nz::ResolveError_NoError);
|
||||
state.PushField("NonRecoverable", Nz::ResolveError_NonRecoverable);
|
||||
state.PushField("NotFound", Nz::ResolveError_NotFound);
|
||||
state.PushField("NotInitialized", Nz::ResolveError_NotInitialized);
|
||||
state.PushField("ProtocolNotSupported", Nz::ResolveError_ProtocolNotSupported);
|
||||
state.PushField("TemporaryFailure", Nz::ResolveError_TemporaryFailure);
|
||||
state.PushField("Unknown", Nz::ResolveError_Unknown);
|
||||
}
|
||||
state.SetGlobal("ResolveError");
|
||||
|
||||
// Nz::SocketError
|
||||
static_assert(Nz::SocketError_Max + 1 == 16, "Nz::SocketError has been updated but change was not reflected to Lua binding");
|
||||
state.PushTable(0, 16);
|
||||
{
|
||||
state.PushField("AddressNotAvailable", Nz::SocketError_AddressNotAvailable);
|
||||
state.PushField("ConnectionClosed", Nz::SocketError_ConnectionClosed);
|
||||
state.PushField("ConnectionRefused", Nz::SocketError_ConnectionRefused);
|
||||
state.PushField("DatagramSize", Nz::SocketError_DatagramSize);
|
||||
state.PushField("Internal", Nz::SocketError_Internal);
|
||||
state.PushField("Interrupted", Nz::SocketError_Interrupted);
|
||||
state.PushField("Packet", Nz::SocketError_Packet);
|
||||
state.PushField("NetworkError", Nz::SocketError_NetworkError);
|
||||
state.PushField("NoError", Nz::SocketError_NoError);
|
||||
state.PushField("NotInitialized", Nz::SocketError_NotInitialized);
|
||||
state.PushField("NotSupported", Nz::SocketError_NotSupported);
|
||||
state.PushField("ResolveError", Nz::SocketError_ResolveError);
|
||||
state.PushField("ResourceError", Nz::SocketError_ResourceError);
|
||||
state.PushField("TimedOut", Nz::SocketError_TimedOut);
|
||||
state.PushField("Unknown", Nz::SocketError_Unknown);
|
||||
state.PushField("UnreachableHost", Nz::SocketError_UnreachableHost);
|
||||
}
|
||||
state.SetGlobal("SocketError");
|
||||
|
||||
// Nz::SocketState
|
||||
static_assert(Nz::SocketState_Max + 1 == 5, "Nz::SocketState has been updated but change was not reflected to Lua binding");
|
||||
state.PushTable(0, 5);
|
||||
{
|
||||
state.PushField("Bound", Nz::SocketState_Bound);
|
||||
state.PushField("Connecting", Nz::SocketState_Connecting);
|
||||
state.PushField("Connected", Nz::SocketState_Connected);
|
||||
state.PushField("NotConnected", Nz::SocketState_NotConnected);
|
||||
state.PushField("Resolving", Nz::SocketState_Resolving);
|
||||
}
|
||||
state.SetGlobal("SocketState");
|
||||
|
||||
// Nz::SocketType
|
||||
static_assert(Nz::SocketType_Max + 1 == 4, "Nz::SocketState has been updated but change was not reflected to Lua binding");
|
||||
state.PushTable(0, 4);
|
||||
{
|
||||
state.PushField("Raw", Nz::SocketType_Raw);
|
||||
state.PushField("TCP", Nz::SocketType_TCP);
|
||||
state.PushField("UDP", Nz::SocketType_UDP);
|
||||
state.PushField("Unknown", Nz::SocketType_Unknown);
|
||||
}
|
||||
state.SetGlobal("SocketType");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,133 +0,0 @@
|
|||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#include <NDK/Lua/LuaBinding_Platform.hpp>
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindPlatform(LuaBinding& binding)
|
||||
{
|
||||
return std::make_unique<LuaBinding_Platform>(binding);
|
||||
}
|
||||
|
||||
LuaBinding_Platform::LuaBinding_Platform(LuaBinding& binding) :
|
||||
LuaBinding_Base(binding)
|
||||
{
|
||||
/*********************************** Nz::Keyboard **********************************/
|
||||
keyboard.Reset("Keyboard");
|
||||
{
|
||||
keyboard.BindStaticMethod("GetKeyName", &Nz::Keyboard::GetKeyName);
|
||||
keyboard.BindStaticMethod("IsKeyPressed", &Nz::Keyboard::IsKeyPressed);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Registers the classes that will be used by the Lua instance
|
||||
*
|
||||
* \param instance Lua instance that will interact with the Utility classes
|
||||
*/
|
||||
void LuaBinding_Platform::Register(Nz::LuaState& state)
|
||||
{
|
||||
keyboard.Register(state);
|
||||
|
||||
keyboard.PushGlobalTable(state);
|
||||
{
|
||||
static_assert(Nz::Keyboard::Count == 121, "Nz::Keyboard::Key has been updated but change was not reflected to Lua binding");
|
||||
|
||||
state.PushField("Undefined", Nz::Keyboard::Undefined);
|
||||
|
||||
// A-Z
|
||||
for (std::size_t i = 0; i < 26; ++i)
|
||||
state.PushField(Nz::String('A' + char(i)), Nz::Keyboard::A + i);
|
||||
|
||||
// Numerical
|
||||
for (std::size_t i = 0; i < 10; ++i)
|
||||
{
|
||||
state.PushField("Num" + Nz::String::Number(i), Nz::Keyboard::Num0 + i);
|
||||
state.PushField("Numpad" + Nz::String::Number(i), Nz::Keyboard::Numpad0 + i);
|
||||
}
|
||||
|
||||
// F1-F15
|
||||
for (std::size_t i = 0; i < 15; ++i)
|
||||
state.PushField('F' + Nz::String::Number(i+1), Nz::Keyboard::F1 + i);
|
||||
|
||||
// And all the others...
|
||||
state.PushField("Down", Nz::Keyboard::Down);
|
||||
state.PushField("Left", Nz::Keyboard::Left);
|
||||
state.PushField("Right", Nz::Keyboard::Right);
|
||||
state.PushField("Up", Nz::Keyboard::Up);
|
||||
|
||||
state.PushField("Add", Nz::Keyboard::Add);
|
||||
state.PushField("Decimal", Nz::Keyboard::Decimal);
|
||||
state.PushField("Divide", Nz::Keyboard::Divide);
|
||||
state.PushField("Multiply", Nz::Keyboard::Multiply);
|
||||
state.PushField("Subtract", Nz::Keyboard::Subtract);
|
||||
|
||||
state.PushField("Backslash", Nz::Keyboard::Backslash);
|
||||
state.PushField("Backspace", Nz::Keyboard::Backspace);
|
||||
state.PushField("Clear", Nz::Keyboard::Clear);
|
||||
state.PushField("Comma", Nz::Keyboard::Comma);
|
||||
state.PushField("Dash", Nz::Keyboard::Dash);
|
||||
state.PushField("Delete", Nz::Keyboard::Delete);
|
||||
state.PushField("End", Nz::Keyboard::End);
|
||||
state.PushField("Equal", Nz::Keyboard::Equal);
|
||||
state.PushField("Escape", Nz::Keyboard::Escape);
|
||||
state.PushField("Home", Nz::Keyboard::Home);
|
||||
state.PushField("Insert", Nz::Keyboard::Insert);
|
||||
state.PushField("LAlt", Nz::Keyboard::LAlt);
|
||||
state.PushField("LBracket", Nz::Keyboard::LBracket);
|
||||
state.PushField("LControl", Nz::Keyboard::LControl);
|
||||
state.PushField("LShift", Nz::Keyboard::LShift);
|
||||
state.PushField("LSystem", Nz::Keyboard::LSystem);
|
||||
state.PushField("PageDown", Nz::Keyboard::PageDown);
|
||||
state.PushField("PageUp", Nz::Keyboard::PageUp);
|
||||
state.PushField("Pause", Nz::Keyboard::Pause);
|
||||
state.PushField("Period", Nz::Keyboard::Period);
|
||||
state.PushField("Print", Nz::Keyboard::Print);
|
||||
state.PushField("PrintScreen", Nz::Keyboard::PrintScreen);
|
||||
state.PushField("Quote", Nz::Keyboard::Quote);
|
||||
state.PushField("RAlt", Nz::Keyboard::RAlt);
|
||||
state.PushField("RBracket", Nz::Keyboard::RBracket);
|
||||
state.PushField("RControl", Nz::Keyboard::RControl);
|
||||
state.PushField("Return", Nz::Keyboard::Return);
|
||||
state.PushField("RShift", Nz::Keyboard::RShift);
|
||||
state.PushField("RSystem", Nz::Keyboard::RSystem);
|
||||
state.PushField("Semicolon", Nz::Keyboard::Semicolon);
|
||||
state.PushField("Slash", Nz::Keyboard::Slash);
|
||||
state.PushField("Space", Nz::Keyboard::Space);
|
||||
state.PushField("Tab", Nz::Keyboard::Tab);
|
||||
state.PushField("Tilde", Nz::Keyboard::Tilde);
|
||||
state.PushField("Browser_Back", Nz::Keyboard::Browser_Back);
|
||||
state.PushField("Browser_Favorites", Nz::Keyboard::Browser_Favorites);
|
||||
state.PushField("Browser_Forward", Nz::Keyboard::Browser_Forward);
|
||||
state.PushField("Browser_Home", Nz::Keyboard::Browser_Home);
|
||||
state.PushField("Browser_Refresh", Nz::Keyboard::Browser_Refresh);
|
||||
state.PushField("Browser_Search", Nz::Keyboard::Browser_Search);
|
||||
state.PushField("Browser_Stop", Nz::Keyboard::Browser_Stop);
|
||||
state.PushField("Media_Next", Nz::Keyboard::Media_Next);
|
||||
state.PushField("Media_Play", Nz::Keyboard::Media_Play);
|
||||
state.PushField("Media_Previous", Nz::Keyboard::Media_Previous);
|
||||
state.PushField("Media_Stop", Nz::Keyboard::Media_Stop);
|
||||
state.PushField("Volume_Down", Nz::Keyboard::Volume_Down);
|
||||
state.PushField("Volume_Mute", Nz::Keyboard::Volume_Mute);
|
||||
state.PushField("Volume_Up", Nz::Keyboard::Volume_Up);
|
||||
state.PushField("CapsLock", Nz::Keyboard::CapsLock);
|
||||
state.PushField("NumLock", Nz::Keyboard::NumLock);
|
||||
state.PushField("ScrollLock", Nz::Keyboard::ScrollLock);
|
||||
}
|
||||
state.Pop();
|
||||
|
||||
static_assert(Nz::WindowStyle_Max + 1 == 6, "Nz::WindowStyle has been updated but change was not reflected to Lua binding");
|
||||
state.PushTable(0, Nz::WindowStyle_Max + 1);
|
||||
{
|
||||
state.PushField("None", Nz::WindowStyle_None);
|
||||
state.PushField("Fullscreen", Nz::WindowStyle_Fullscreen);
|
||||
state.PushField("Closable", Nz::WindowStyle_Closable);
|
||||
state.PushField("Resizable", Nz::WindowStyle_Resizable);
|
||||
state.PushField("Titlebar", Nz::WindowStyle_Titlebar);
|
||||
state.PushField("Threaded", Nz::WindowStyle_Threaded);
|
||||
}
|
||||
state.SetGlobal("WindowStyle");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,110 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq, Arnaud Cadot
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#include <NDK/Lua/LuaBinding_Renderer.hpp>
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
#include <NDK/Lua/LuaBinding.hpp>
|
||||
#include <NDK/Lua/LuaBinding_Utility.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindRenderer(LuaBinding& binding)
|
||||
{
|
||||
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 ***********************************/
|
||||
texture.Reset("Texture");
|
||||
{
|
||||
texture.Inherit<Nz::AbstractImageRef>(utility.abstractImage, [] (Nz::TextureRef* textureRef) -> Nz::AbstractImageRef*
|
||||
{
|
||||
return reinterpret_cast<Nz::AbstractImageRef*>(textureRef); //TODO: Make a ObjectRefCast
|
||||
});
|
||||
|
||||
texture.SetConstructor([] (Nz::LuaState& /*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("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);
|
||||
|
||||
texture.BindStaticMethod("LoadFromFile", &Nz::Texture::LoadFromFile, true, Nz::ImageParams());
|
||||
//TextureRef LoadFromImage(const Image& image, bool generateMipmaps = true);
|
||||
//TextureRef LoadFromMemory(const void* data, std::size_t size, const ImageParams& params = ImageParams(), bool generateMipmaps = true);
|
||||
//TextureRef LoadFromStream(Stream& stream, const ImageParams& params = ImageParams(), bool generateMipmaps = true);
|
||||
|
||||
texture.BindStaticMethod("LoadArrayFromFile", &Nz::Texture::LoadArrayFromFile, Nz::Vector2ui(2, 2), true, Nz::ImageParams());
|
||||
//TextureRef LoadArrayFromImage(const Image& image, bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
||||
//TextureRef LoadArrayFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
||||
//TextureRef LoadArrayFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
||||
|
||||
//TextureRef LoadCubemapFromFile(const String& filePath, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
|
||||
//TextureRef LoadCubemapFromImage(const Image& image, bool generateMipmaps = true, const CubemapParams& params = CubemapParams());
|
||||
//TextureRef LoadCubemapFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
|
||||
//TextureRef LoadCubemapFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
|
||||
}
|
||||
|
||||
/*********************************** Nz::TextureLibrary ***********************************/
|
||||
textureLibrary.Reset("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.Reset("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);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Registers the classes that will be used by the Lua instance
|
||||
*
|
||||
* \param instance Lua instance that will interact with the Renderer classes
|
||||
*/
|
||||
void LuaBinding_Renderer::Register(Nz::LuaState& state)
|
||||
{
|
||||
texture.Register(state);
|
||||
textureLibrary.Register(state);
|
||||
textureManager.Register(state);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,354 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq, Arnaud Cadot
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#include <NDK/Lua/LuaBinding_SDK.hpp>
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
#include <NDK/Lua/LuaBinding.hpp>
|
||||
#include <NDK/Lua/LuaBinding_Utility.hpp>
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
#include <NDK/Lua/LuaBinding_Graphics.hpp>
|
||||
#endif
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindSDK(LuaBinding& binding)
|
||||
{
|
||||
return std::make_unique<LuaBinding_SDK>(binding);
|
||||
}
|
||||
|
||||
LuaBinding_SDK::LuaBinding_SDK(LuaBinding& binding) :
|
||||
LuaBinding_Base(binding)
|
||||
{
|
||||
#ifndef NDK_SERVER
|
||||
LuaBinding_Graphics& graphics = static_cast<LuaBinding_Graphics&>(*m_binding.graphics);
|
||||
#endif
|
||||
|
||||
LuaBinding_Utility& utility = static_cast<LuaBinding_Utility&>(*m_binding.utility);
|
||||
|
||||
/*********************************** Ndk::Application **********************************/
|
||||
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::LuaState& 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 **********************************/
|
||||
#ifndef NDK_SERVER
|
||||
console.Reset("Console");
|
||||
{
|
||||
console.Inherit<Nz::Node>(utility.node, [] (ConsoleHandle* handle) -> Nz::Node*
|
||||
{
|
||||
return handle->GetObject();
|
||||
});
|
||||
|
||||
console.BindMethod("AddLine", &Console::AddLine, Nz::Color::White);
|
||||
console.BindMethod("Clear", &Console::Clear);
|
||||
console.BindMethod("GetCharacterSize", &Console::GetCharacterSize);
|
||||
//console.BindMethod("GetHistory", &Console::GetHistory);
|
||||
//console.BindMethod("GetInput", &Console::GetInput);
|
||||
console.BindMethod("GetTextFont", &Console::GetTextFont);
|
||||
|
||||
console.BindMethod("IsValidHandle", &ConsoleHandle::IsValid);
|
||||
|
||||
console.BindMethod("SetCharacterSize", &Console::SetCharacterSize);
|
||||
console.BindMethod("SetTextFont", &Console::SetTextFont);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************************** Ndk::Entity **********************************/
|
||||
entity.Reset("Entity");
|
||||
{
|
||||
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("IsValidHandle", &EntityHandle::IsValid);
|
||||
entity.BindMethod("RemoveAllComponents", &Entity::RemoveAllComponents);
|
||||
entity.BindMethod("__tostring", &EntityHandle::ToString);
|
||||
|
||||
entity.BindMethod("AddComponent", [this] (Nz::LuaState& state, EntityHandle& handle, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
LuaBinding::ComponentBinding* bindingComponent = m_binding.QueryComponentIndex(state);
|
||||
|
||||
return bindingComponent->adder(state, handle);
|
||||
});
|
||||
|
||||
entity.BindMethod("HasComponent", [this](Nz::LuaState& state, EntityHandle& handle, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
LuaBinding::ComponentBinding* bindingComponent = m_binding.QueryComponentIndex(state);
|
||||
|
||||
state.PushBoolean(handle->HasComponent(bindingComponent->index));
|
||||
return 1;
|
||||
});
|
||||
|
||||
entity.BindMethod("GetComponent", [this] (Nz::LuaState& state, EntityHandle& handle, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
LuaBinding::ComponentBinding* bindingComponent = m_binding.QueryComponentIndex(state);
|
||||
|
||||
return bindingComponent->getter(state, handle->GetComponent(bindingComponent->index));
|
||||
});
|
||||
|
||||
entity.BindMethod("RemoveComponent", [this] (Nz::LuaState& state, EntityHandle& handle, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
LuaBinding::ComponentBinding* bindingComponent = m_binding.QueryComponentIndex(state);
|
||||
|
||||
handle->RemoveComponent(bindingComponent->index);
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Ndk::NodeComponent **********************************/
|
||||
nodeComponent.Reset("NodeComponent");
|
||||
{
|
||||
nodeComponent.BindMethod("IsValidHandle", &NodeComponentHandle::IsValid);
|
||||
|
||||
nodeComponent.Inherit<Nz::Node>(utility.node, [] (NodeComponentHandle* handle) -> Nz::Node*
|
||||
{
|
||||
return handle->GetObject();
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Ndk::VelocityComponent **********************************/
|
||||
velocityComponent.Reset("VelocityComponent");
|
||||
{
|
||||
velocityComponent.BindMethod("IsValidHandle", &VelocityComponentHandle::IsValid);
|
||||
|
||||
velocityComponent.SetGetter([] (Nz::LuaState& lua, VelocityComponentHandle& instance)
|
||||
{
|
||||
std::size_t length;
|
||||
const char* member = lua.CheckString(2, &length);
|
||||
|
||||
if (std::strcmp(member, "Linear") == 0)
|
||||
{
|
||||
lua.Push(instance->linearVelocity);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
velocityComponent.SetSetter([] (Nz::LuaState& lua, VelocityComponentHandle& instance)
|
||||
{
|
||||
std::size_t length;
|
||||
const char* member = lua.CheckString(2, &length);
|
||||
|
||||
int argIndex = 3;
|
||||
if (std::strcmp(member, "Linear") == 0)
|
||||
{
|
||||
instance->linearVelocity = lua.Check<Nz::Vector3f>(&argIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Ndk::World **********************************/
|
||||
world.Reset("World");
|
||||
{
|
||||
world.BindMethod("CreateEntity", &World::CreateEntity);
|
||||
world.BindMethod("CreateEntities", &World::CreateEntities);
|
||||
world.BindMethod("Clear", &World::Clear);
|
||||
world.BindMethod("DisableProfiler", &World::DisableProfiler);
|
||||
world.BindMethod("EnableProfiler", &World::EnableProfiler);
|
||||
world.BindMethod("IsProfilerEnabled", &World::IsProfilerEnabled);
|
||||
world.BindMethod("Refresh", &World::Refresh);
|
||||
world.BindMethod("ResetProfiler", &World::ResetProfiler);
|
||||
world.BindMethod("Update", &World::Update);
|
||||
|
||||
world.BindMethod("IsValidHandle", &WorldHandle::IsValid);
|
||||
}
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
/*********************************** Ndk::CameraComponent **********************************/
|
||||
cameraComponent.Reset("CameraComponent");
|
||||
{
|
||||
cameraComponent.Inherit<Nz::AbstractViewer>(graphics.abstractViewer, [] (CameraComponentHandle* handle) -> Nz::AbstractViewer*
|
||||
{
|
||||
return handle->GetObject();
|
||||
});
|
||||
|
||||
cameraComponent.BindMethod("GetFOV", &CameraComponent::GetFOV);
|
||||
cameraComponent.BindMethod("GetLayer", &CameraComponent::GetLayer);
|
||||
|
||||
cameraComponent.BindMethod("IsValidHandle", &CameraComponentHandle::IsValid);
|
||||
|
||||
cameraComponent.BindMethod("SetFOV", &CameraComponent::SetFOV);
|
||||
cameraComponent.BindMethod("SetLayer", &CameraComponent::SetLayer);
|
||||
cameraComponent.BindMethod("SetProjectionType", &CameraComponent::SetProjectionType);
|
||||
cameraComponent.BindMethod("SetSize", (void(CameraComponent::*)(const Nz::Vector2f&)) &CameraComponent::SetSize);
|
||||
//cameraComponent.BindMethod("SetTarget", &CameraComponent::SetTarget);
|
||||
cameraComponent.BindMethod("SetTargetRegion", &CameraComponent::SetTargetRegion);
|
||||
cameraComponent.BindMethod("SetViewport", &CameraComponent::SetViewport);
|
||||
cameraComponent.BindMethod("SetZFar", &CameraComponent::SetZFar);
|
||||
cameraComponent.BindMethod("SetZNear", &CameraComponent::SetZNear);
|
||||
}
|
||||
|
||||
/*********************************** Ndk::GraphicsComponent **********************************/
|
||||
graphicsComponent.Reset("GraphicsComponent");
|
||||
{
|
||||
graphicsComponent.BindMethod("Attach", [] (Nz::LuaState& 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:
|
||||
{
|
||||
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);
|
||||
|
||||
instance->Attach(renderable, localMatrix, renderOrder);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for method GetMemoryUsage");
|
||||
return 0;
|
||||
});
|
||||
|
||||
graphicsComponent.BindMethod("IsValidHandle", &GraphicsComponentHandle::IsValid);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Components functions
|
||||
m_binding.BindComponent<NodeComponent>("Node");
|
||||
m_binding.BindComponent<VelocityComponent>("Velocity");
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
m_binding.BindComponent<CameraComponent>("Camera");
|
||||
m_binding.BindComponent<GraphicsComponent>("Graphics");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Registers the classes that will be used by the Lua instance
|
||||
*
|
||||
* \param instance Lua instance that will interact with the SDK classes
|
||||
*/
|
||||
void LuaBinding_SDK::Register(Nz::LuaState& state)
|
||||
{
|
||||
// Classes
|
||||
application.Register(state);
|
||||
entity.Register(state);
|
||||
nodeComponent.Register(state);
|
||||
velocityComponent.Register(state);
|
||||
world.Register(state);
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
cameraComponent.Register(state);
|
||||
console.Register(state);
|
||||
graphicsComponent.Register(state);
|
||||
#endif
|
||||
|
||||
// Enums
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the index of the component
|
||||
* \return A pointer to the binding linked to a component
|
||||
*
|
||||
* \param instance Lua instance that will interact with the component
|
||||
* \param argIndex Index of the component
|
||||
*/
|
||||
LuaBinding::ComponentBinding* LuaBinding::QueryComponentIndex(Nz::LuaState& state, int argIndex)
|
||||
{
|
||||
switch (state.GetType(argIndex))
|
||||
{
|
||||
case Nz::LuaType_Number:
|
||||
{
|
||||
ComponentIndex componentIndex = state.Check<ComponentIndex>(&argIndex);
|
||||
if (componentIndex > m_componentBinding.size())
|
||||
{
|
||||
state.Error("Invalid component index");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ComponentBinding& binding = m_componentBinding[componentIndex];
|
||||
if (binding.name.IsEmpty())
|
||||
{
|
||||
state.Error("Invalid component index");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return &binding;
|
||||
}
|
||||
|
||||
case Nz::LuaType_String:
|
||||
{
|
||||
const char* key = state.CheckString(argIndex);
|
||||
auto it = m_componentBindingByName.find(key);
|
||||
if (it == m_componentBindingByName.end())
|
||||
{
|
||||
state.Error("Invalid component name");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return &m_componentBinding[it->second];
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
state.Error("Invalid component index at #" + Nz::String::Number(argIndex));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,338 +0,0 @@
|
|||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#include <NDK/Lua/LuaBinding_Utility.hpp>
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindUtility(LuaBinding& binding)
|
||||
{
|
||||
return std::make_unique<LuaBinding_Utility>(binding);
|
||||
}
|
||||
|
||||
LuaBinding_Utility::LuaBinding_Utility(LuaBinding& binding) :
|
||||
LuaBinding_Base(binding)
|
||||
{
|
||||
/*********************************** Nz::AbstractImage **********************************/
|
||||
abstractImage.Reset("AbstractImage");
|
||||
{
|
||||
abstractImage.BindMethod("GetBytesPerPixel", &Nz::AbstractImage::GetBytesPerPixel);
|
||||
abstractImage.BindMethod("GetDepth", &Nz::AbstractImage::GetDepth, static_cast<Nz::UInt8>(0));
|
||||
abstractImage.BindMethod("GetFormat", &Nz::AbstractImage::GetFormat);
|
||||
abstractImage.BindMethod("GetHeight", &Nz::AbstractImage::GetHeight, static_cast<Nz::UInt8>(0));
|
||||
abstractImage.BindMethod("GetLevelCount", &Nz::AbstractImage::GetLevelCount);
|
||||
abstractImage.BindMethod("GetMaxLevel", &Nz::AbstractImage::GetMaxLevel);
|
||||
abstractImage.BindMethod("GetSize", &Nz::AbstractImage::GetSize, static_cast<Nz::UInt8>(0));
|
||||
abstractImage.BindMethod("GetType", &Nz::AbstractImage::GetType);
|
||||
abstractImage.BindMethod("GetWidth", &Nz::AbstractImage::GetWidth, static_cast<Nz::UInt8>(0));
|
||||
abstractImage.BindMethod("IsCompressed", &Nz::AbstractImage::IsCompressed);
|
||||
abstractImage.BindMethod("IsCubemap", &Nz::AbstractImage::IsCubemap);
|
||||
|
||||
abstractImage.BindMethod("GetMemoryUsage", [] (Nz::LuaState& lua, Nz::AbstractImage* instance, std::size_t argumentCount) -> int
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 1U);
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
return lua.Push(instance->GetMemoryUsage());
|
||||
|
||||
case 1:
|
||||
{
|
||||
int argIndex = 2;
|
||||
Nz::UInt8 level(lua.Check<Nz::UInt8>(&argIndex));
|
||||
|
||||
return lua.Push(instance->GetMemoryUsage(level));
|
||||
}
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for method GetMemoryUsage");
|
||||
return 0;
|
||||
});
|
||||
|
||||
abstractImage.BindMethod("Update", [] (Nz::LuaState& lua, Nz::AbstractImage* instance, std::size_t argumentCount) -> int
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 6U);
|
||||
int argIndex = 2;
|
||||
|
||||
std::size_t bufferSize = 0;
|
||||
const Nz::UInt8* pixels = reinterpret_cast<const Nz::UInt8*>(lua.CheckString(argIndex++, &bufferSize));
|
||||
|
||||
if (argCount < 2 || lua.IsOfType(2, Nz::LuaType_Number))
|
||||
{
|
||||
// bool Update(const UInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0)
|
||||
unsigned int srcWidth = lua.Check<unsigned int>(&argIndex, 0);
|
||||
unsigned int srcHeight = lua.Check<unsigned int>(&argIndex, 0);
|
||||
Nz::UInt8 level = lua.Check<Nz::UInt8>(&argIndex, 0);
|
||||
|
||||
///TODO: Buffer checks (Nz::ByteBufferView ?)
|
||||
return lua.Push(instance->Update(pixels, srcWidth, srcHeight, level));
|
||||
}
|
||||
/* Disabled until Box and Rect have been ported
|
||||
else if (lua.IsOfType(2, "Box"))
|
||||
{
|
||||
// bool Update(const UInt8* pixels, const Boxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0)
|
||||
Nz::Boxui box = lua.Check<Nz::Boxui>(&argIndex);
|
||||
unsigned int srcWidth = lua.Check<unsigned int>(&argIndex, 0);
|
||||
unsigned int srcHeight = lua.Check<unsigned int>(&argIndex, 0);
|
||||
Nz::UInt8 level = lua.Check<Nz::UInt8>(&argIndex, 0);
|
||||
|
||||
///TODO: Buffer checks (Nz::ByteBufferView ?)
|
||||
return lua.Push(abstractImage->Update(pixels, srcWidth, srcHeight, level));
|
||||
}
|
||||
else if (lua.IsOfType(2, "Rect"))
|
||||
{
|
||||
// bool Update(const UInt8* pixels, const Rectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0)
|
||||
Nz::Rectui box = lua.Check<Nz::Rectui>(&argIndex);
|
||||
unsigned int srcWidth = lua.Check<unsigned int>(&argIndex, 0);
|
||||
unsigned int srcHeight = lua.Check<unsigned int>(&argIndex, 0);
|
||||
Nz::UInt8 level = lua.Check<Nz::UInt8>(&argIndex, 0);
|
||||
|
||||
///TODO: Buffer checks (Nz::ByteBufferView ?)
|
||||
return lua.Push(abstractImage->Update(pixels, srcWidth, srcHeight, level));
|
||||
}*/
|
||||
|
||||
lua.Error("No matching overload for method Update");
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Nz::Font **********************************/
|
||||
font.Reset("Font");
|
||||
{
|
||||
font.SetConstructor([] (Nz::LuaState& /*lua*/, Nz::FontRef* instance, std::size_t /*argumentCount*/)
|
||||
{
|
||||
Nz::PlacementNew(instance, Nz::Font::New());
|
||||
return true;
|
||||
});
|
||||
|
||||
font.BindMethod("ClearGlyphCache", &Nz::Font::ClearGlyphCache);
|
||||
font.BindMethod("ClearKerningCache", &Nz::Font::ClearKerningCache);
|
||||
font.BindMethod("ClearSizeInfoCache", &Nz::Font::ClearSizeInfoCache);
|
||||
|
||||
font.BindMethod("Destroy", &Nz::Font::Destroy);
|
||||
|
||||
font.BindMethod("GetCachedGlyphCount", [] (Nz::LuaState& lua, Nz::FontRef& instance, std::size_t argumentCount) -> int
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 2U);
|
||||
|
||||
int argIndex = 2;
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
lua.Push(instance->GetCachedGlyphCount());
|
||||
return 1;
|
||||
|
||||
case 3:
|
||||
{
|
||||
unsigned int characterSize = lua.Check<unsigned int>(&argIndex);
|
||||
Nz::TextStyleFlags style = lua.Check<Nz::TextStyleFlags>(&argIndex);
|
||||
float outlineThickness = lua.Check<float>(&argIndex);
|
||||
|
||||
lua.Push(instance->GetCachedGlyphCount(characterSize, style, outlineThickness));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for method GetCachedGlyphCount");
|
||||
return 0;
|
||||
});
|
||||
|
||||
font.BindMethod("GetFamilyName", &Nz::Font::GetFamilyName);
|
||||
font.BindMethod("GetKerning", &Nz::Font::GetKerning);
|
||||
font.BindMethod("GetGlyphBorder", &Nz::Font::GetGlyphBorder);
|
||||
font.BindMethod("GetMinimumStepSize", &Nz::Font::GetMinimumStepSize);
|
||||
font.BindMethod("GetSizeInfo", &Nz::Font::GetSizeInfo);
|
||||
font.BindMethod("GetStyleName", &Nz::Font::GetStyleName);
|
||||
|
||||
font.BindMethod("IsValid", &Nz::Font::IsValid);
|
||||
|
||||
font.BindMethod("Precache", (bool(Nz::Font::*)(unsigned int, Nz::TextStyleFlags, float, const Nz::String&) const) &Nz::Font::Precache);
|
||||
|
||||
font.BindMethod("SetGlyphBorder", &Nz::Font::SetGlyphBorder);
|
||||
font.BindMethod("SetMinimumStepSize", &Nz::Font::SetMinimumStepSize);
|
||||
|
||||
font.BindStaticMethod("GetDefault", &Nz::Font::GetDefault);
|
||||
font.BindStaticMethod("GetDefaultGlyphBorder", &Nz::Font::GetDefaultGlyphBorder);
|
||||
font.BindStaticMethod("GetDefaultMinimumStepSize", &Nz::Font::GetDefaultMinimumStepSize);
|
||||
|
||||
font.BindStaticMethod("OpenFromFile", &Nz::Font::OpenFromFile, Nz::FontParams());
|
||||
|
||||
font.BindStaticMethod("SetDefaultGlyphBorder", &Nz::Font::SetDefaultGlyphBorder);
|
||||
font.BindStaticMethod("SetDefaultMinimumStepSize", &Nz::Font::SetDefaultMinimumStepSize);
|
||||
}
|
||||
|
||||
/*********************************** Nz::Node **********************************/
|
||||
node.Reset("Node");
|
||||
{
|
||||
node.BindMethod("GetBackward", &Nz::Node::GetBackward);
|
||||
//nodeClass.SetMethod("GetChilds", &Nz::Node::GetChilds);
|
||||
node.BindMethod("GetDown", &Nz::Node::GetDown);
|
||||
node.BindMethod("GetForward", &Nz::Node::GetForward);
|
||||
node.BindMethod("GetInheritPosition", &Nz::Node::GetInheritPosition);
|
||||
node.BindMethod("GetInheritRotation", &Nz::Node::GetInheritRotation);
|
||||
node.BindMethod("GetInheritScale", &Nz::Node::GetInheritScale);
|
||||
node.BindMethod("GetInitialPosition", &Nz::Node::GetInitialPosition);
|
||||
//nodeClass.SetMethod("GetInitialRotation", &Nz::Node::GetInitialRotation);
|
||||
node.BindMethod("GetInitialScale", &Nz::Node::GetInitialScale);
|
||||
node.BindMethod("GetLeft", &Nz::Node::GetLeft);
|
||||
node.BindMethod("GetNodeType", &Nz::Node::GetNodeType);
|
||||
//nodeClass.SetMethod("GetParent", &Nz::Node::GetParent);
|
||||
node.BindMethod("GetPosition", &Nz::Node::GetPosition, Nz::CoordSys_Global);
|
||||
node.BindMethod("GetRight", &Nz::Node::GetRight);
|
||||
//nodeClass.SetMethod("GetRotation", &Nz::Node::GetRotation, Nz::CoordSys_Global);
|
||||
node.BindMethod("GetScale", &Nz::Node::GetScale, Nz::CoordSys_Global);
|
||||
//nodeClass.SetMethod("GetTransformMatrix", &Nz::Node::GetTransformMatrix);
|
||||
node.BindMethod("GetUp", &Nz::Node::GetUp);
|
||||
|
||||
node.BindMethod("HasChilds", &Nz::Node::HasChilds);
|
||||
|
||||
node.BindMethod("GetBackward", &Nz::Node::GetBackward);
|
||||
node.BindMethod("GetDown", &Nz::Node::GetDown);
|
||||
node.BindMethod("GetForward", &Nz::Node::GetForward);
|
||||
node.BindMethod("GetInheritPosition", &Nz::Node::GetInheritPosition);
|
||||
node.BindMethod("GetInheritRotation", &Nz::Node::GetInheritRotation);
|
||||
node.BindMethod("GetInheritScale", &Nz::Node::GetInheritScale);
|
||||
node.BindMethod("GetInitialPosition", &Nz::Node::GetInitialPosition);
|
||||
node.BindMethod("GetInitialRotation", &Nz::Node::GetInitialRotation);
|
||||
node.BindMethod("GetInitialScale", &Nz::Node::GetInitialScale);
|
||||
node.BindMethod("GetLeft", &Nz::Node::GetLeft);
|
||||
node.BindMethod("GetNodeType", &Nz::Node::GetNodeType);
|
||||
node.BindMethod("GetPosition", &Nz::Node::GetPosition, Nz::CoordSys_Global);
|
||||
node.BindMethod("GetRight", &Nz::Node::GetRight);
|
||||
node.BindMethod("GetRotation", &Nz::Node::GetRotation, Nz::CoordSys_Global);
|
||||
node.BindMethod("GetScale", &Nz::Node::GetScale, Nz::CoordSys_Global);
|
||||
node.BindMethod("GetUp", &Nz::Node::GetUp);
|
||||
|
||||
node.BindMethod("SetInitialPosition", (void(Nz::Node::*)(const Nz::Vector3f&)) &Nz::Node::SetInitialPosition);
|
||||
node.BindMethod("SetInitialRotation", (void(Nz::Node::*)(const Nz::Quaternionf&)) &Nz::Node::SetInitialRotation);
|
||||
|
||||
node.BindMethod("SetPosition", (void(Nz::Node::*)(const Nz::Vector3f&, Nz::CoordSys)) &Nz::Node::SetPosition, Nz::CoordSys_Local);
|
||||
node.BindMethod("SetRotation", (void(Nz::Node::*)(const Nz::Quaternionf&, Nz::CoordSys)) &Nz::Node::SetRotation, Nz::CoordSys_Local);
|
||||
|
||||
node.BindMethod("Move", [] (Nz::LuaState& lua, Nz::Node& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
int argIndex = 2;
|
||||
|
||||
Nz::Vector3f offset = lua.Check<Nz::Vector3f>(&argIndex);
|
||||
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&argIndex, Nz::CoordSys_Local);
|
||||
instance.Move(offset, coordSys);
|
||||
|
||||
return 0;
|
||||
});
|
||||
|
||||
node.BindMethod("Rotate", [] (Nz::LuaState& lua, Nz::Node& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
int argIndex = 2;
|
||||
|
||||
Nz::Quaternionf rotation = lua.Check<Nz::Quaternionf>(&argIndex);
|
||||
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&argIndex, Nz::CoordSys_Local);
|
||||
instance.Rotate(rotation, coordSys);
|
||||
|
||||
return 0;
|
||||
});
|
||||
|
||||
node.BindMethod("Scale", [] (Nz::LuaState& lua, Nz::Node& instance, std::size_t argumentCount) -> int
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 4U);
|
||||
|
||||
int argIndex = 2;
|
||||
switch (argCount)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
if (lua.IsOfType(argIndex, Nz::LuaType_Number))
|
||||
instance.Scale(lua.Check<float>(&argIndex));
|
||||
else
|
||||
instance.Scale(lua.Check<Nz::Vector3f>(&argIndex));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
case 3:
|
||||
instance.Scale(lua.Check<Nz::Vector3f>(&argIndex));
|
||||
return 0;
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for method Scale");
|
||||
return 0;
|
||||
});
|
||||
|
||||
node.BindMethod("SetScale", [] (Nz::LuaState& lua, Nz::Node& instance, std::size_t argumentCount) -> int
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 4U);
|
||||
|
||||
int argIndex = 2;
|
||||
switch (argCount)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
{
|
||||
if (lua.IsOfType(argIndex, Nz::LuaType_Number))
|
||||
{
|
||||
float scale = lua.Check<float>(&argIndex);
|
||||
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&argIndex, Nz::CoordSys_Local);
|
||||
instance.SetScale(scale, coordSys);
|
||||
}
|
||||
else
|
||||
instance.SetScale(lua.Check<Nz::Vector3f>(&argIndex));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
case 3:
|
||||
case 4:
|
||||
{
|
||||
Nz::Vector3f scale = lua.Check<Nz::Vector3f>(&argIndex);
|
||||
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&argIndex, Nz::CoordSys_Local);
|
||||
|
||||
instance.SetScale(scale, coordSys);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for method SetScale");
|
||||
return 0;
|
||||
});
|
||||
|
||||
node.BindMethod("SetInitialScale", [] (Nz::LuaState& lua, Nz::Node& instance, std::size_t argumentCount) -> int
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 4U);
|
||||
|
||||
int argIndex = 2;
|
||||
switch (argCount)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
if (lua.IsOfType(argIndex, Nz::LuaType_Number))
|
||||
instance.SetInitialScale(lua.Check<float>(&argIndex));
|
||||
else
|
||||
instance.SetInitialScale(lua.Check<Nz::Vector2f>(&argIndex));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
instance.SetInitialScale(lua.Check<Nz::Vector3f>(&argIndex));
|
||||
return 0;
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for method SetInitialScale");
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Registers the classes that will be used by the Lua instance
|
||||
*
|
||||
* \param instance Lua instance that will interact with the Utility classes
|
||||
*/
|
||||
void LuaBinding_Utility::Register(Nz::LuaState& state)
|
||||
{
|
||||
abstractImage.Register(state);
|
||||
font.Register(state);
|
||||
node.Register(state);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
// This file was automatically generated on 26 May 2014 at 01:05:31
|
||||
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
#include <Nazara/Core/ErrorFlags.hpp>
|
||||
#include <NDK/Lua/LuaBinding.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
* \ingroup NDK
|
||||
* \class Ndk::LuaAPI
|
||||
* \brief NDK class that represents the api used for Lua
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief Gets the internal binding for Lua
|
||||
* \return A pointer to the binding
|
||||
*/
|
||||
LuaBinding* LuaAPI::GetBinding()
|
||||
{
|
||||
if (!s_binding && !Initialize())
|
||||
{
|
||||
NazaraError("Failed to initialize binding");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return s_binding;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Initializes the LuaAPI module
|
||||
* \return true if initialization is successful
|
||||
*/
|
||||
|
||||
bool LuaAPI::Initialize()
|
||||
{
|
||||
s_binding = new LuaBinding;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Registers the classes that will be used by the Lua instance
|
||||
*
|
||||
* \param instance Lua instance that will interact with the engine & SDK
|
||||
*/
|
||||
|
||||
void LuaAPI::RegisterClasses(Nz::LuaState& state)
|
||||
{
|
||||
Nz::ErrorFlags errFlags(Nz::ErrorFlag_ThrowException, true);
|
||||
GetBinding()->RegisterClasses(state);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Uninitializes the LuaAPI module
|
||||
*/
|
||||
|
||||
void LuaAPI::Uninitialize()
|
||||
{
|
||||
delete s_binding;
|
||||
}
|
||||
|
||||
LuaBinding* LuaAPI::s_binding = nullptr;
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ shallow_clone: true
|
|||
skip_commits:
|
||||
files:
|
||||
- .travis.yml
|
||||
- Dockerfile
|
||||
- Doxyfile
|
||||
- LICENSE
|
||||
- License-Cabin.txt
|
||||
|
|
@ -15,6 +16,7 @@ skip_commits:
|
|||
- 'writing style.md'
|
||||
- doc/*
|
||||
- NazaraModuleTemplate/*
|
||||
message: /\[Posix\]/
|
||||
|
||||
os:
|
||||
- Visual Studio 2017
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ function NazaraBuild:Execute()
|
|||
for k, libTable in ipairs(self.OrderedExtLibs) do
|
||||
project(libTable.Name)
|
||||
|
||||
self:PrepareGeneric()
|
||||
self:PreconfigGenericProject()
|
||||
|
||||
language(libTable.Language)
|
||||
location(_ACTION .. "/thirdparty")
|
||||
|
|
@ -97,6 +97,10 @@ function NazaraBuild:Execute()
|
|||
files(libTable.Files)
|
||||
excludes(libTable.FilesExcluded)
|
||||
|
||||
if (libTable.DisableWarnings) then
|
||||
warnings("Off")
|
||||
end
|
||||
|
||||
defines(libTable.Defines)
|
||||
flags(libTable.Flags)
|
||||
kind("StaticLib") -- Force them as static libs
|
||||
|
|
@ -122,6 +126,8 @@ function NazaraBuild:Execute()
|
|||
end
|
||||
|
||||
filter({})
|
||||
|
||||
self:PostconfigGenericProject()
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -131,14 +137,14 @@ function NazaraBuild:Execute()
|
|||
if (_OPTIONS["united"]) then
|
||||
project("NazaraEngine")
|
||||
|
||||
self:PrepareMainWorkspace()
|
||||
self:PreconfigNazaraProject()
|
||||
end
|
||||
|
||||
for k, moduleTable in ipairs(self.OrderedModules) do
|
||||
if (not _OPTIONS["united"]) then
|
||||
project("Nazara" .. moduleTable.Name)
|
||||
|
||||
self:PrepareMainWorkspace()
|
||||
self:PreconfigNazaraProject()
|
||||
end
|
||||
|
||||
location(_ACTION .. "/modules")
|
||||
|
|
@ -180,6 +186,14 @@ function NazaraBuild:Execute()
|
|||
end
|
||||
|
||||
filter({})
|
||||
|
||||
if (not _OPTIONS["united"]) then
|
||||
self:PostconfigNazaraProject()
|
||||
end
|
||||
end
|
||||
|
||||
if (_OPTIONS["united"]) then
|
||||
self:PostconfigNazaraProject()
|
||||
end
|
||||
|
||||
-- Tools
|
||||
|
|
@ -193,7 +207,7 @@ function NazaraBuild:Execute()
|
|||
|
||||
project(prefix .. toolTable.Name)
|
||||
|
||||
self:PrepareMainWorkspace()
|
||||
self:PreconfigNazaraProject()
|
||||
|
||||
location(_ACTION .. "/tools")
|
||||
|
||||
|
|
@ -251,6 +265,8 @@ function NazaraBuild:Execute()
|
|||
end
|
||||
|
||||
filter({})
|
||||
|
||||
self:PostconfigNazaraProject()
|
||||
end
|
||||
|
||||
group("Examples")
|
||||
|
|
@ -260,7 +276,7 @@ function NazaraBuild:Execute()
|
|||
|
||||
project("Demo" .. exampleTable.Name)
|
||||
|
||||
self:PrepareMainWorkspace()
|
||||
self:PreconfigNazaraProject()
|
||||
|
||||
location(_ACTION .. "/examples")
|
||||
|
||||
|
|
@ -301,6 +317,8 @@ function NazaraBuild:Execute()
|
|||
end
|
||||
|
||||
filter({})
|
||||
|
||||
self:PostconfigNazaraProject()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -802,7 +820,7 @@ function NazaraBuild:Process(infoTable)
|
|||
return true
|
||||
end
|
||||
|
||||
function NazaraBuild:PrepareGeneric()
|
||||
function NazaraBuild:PreconfigGenericProject()
|
||||
flags({
|
||||
"MultiProcessorCompile",
|
||||
"NoMinimalRebuild",
|
||||
|
|
@ -811,7 +829,8 @@ function NazaraBuild:PrepareGeneric()
|
|||
"UndefinedIdentifiers"
|
||||
})
|
||||
|
||||
cppdialect("C++14")
|
||||
cppdialect("C++17")
|
||||
warnings("Extra")
|
||||
|
||||
self:FilterLibDirectory("../thirdparty/genlib/", libdirs)
|
||||
self:FilterLibDirectory("../thirdparty/lib/", libdirs)
|
||||
|
|
@ -871,8 +890,17 @@ function NazaraBuild:PrepareGeneric()
|
|||
buildoptions(self.Config["AdditionalCompilationOptions"])
|
||||
end
|
||||
|
||||
function NazaraBuild:PrepareMainWorkspace()
|
||||
self:PrepareGeneric()
|
||||
function NazaraBuild:PostconfigGenericProject()
|
||||
-- Add options required for C++17 thread and filesystem (have to be linked last)
|
||||
filter("action:gmake*")
|
||||
links("stdc++fs")
|
||||
links("pthread")
|
||||
|
||||
filter({})
|
||||
end
|
||||
|
||||
function NazaraBuild:PreconfigNazaraProject()
|
||||
self:PreconfigGenericProject()
|
||||
|
||||
language("C++")
|
||||
|
||||
|
|
@ -906,6 +934,10 @@ function NazaraBuild:PrepareMainWorkspace()
|
|||
filter({})
|
||||
end
|
||||
|
||||
function NazaraBuild:PostconfigNazaraProject()
|
||||
self:PostconfigGenericProject()
|
||||
end
|
||||
|
||||
function NazaraBuild:RegisterAction(actionTable)
|
||||
if (not actionTable.Manual) then
|
||||
if (actionTable.Name == nil or type(actionTable.Name) ~= "string" or string.len(actionTable.Name) == 0) then
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
-- Quelle ironie
|
||||
MODULE.Name = "Lua"
|
||||
|
||||
MODULE.Libraries = {
|
||||
"lua",
|
||||
"NazaraCore"
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
MODULE.Name = "Noise"
|
||||
|
||||
MODULE.Libraries = {
|
||||
"NazaraCore"
|
||||
}
|
||||
|
|
@ -9,16 +9,16 @@ TOOL.Defines = {
|
|||
}
|
||||
|
||||
TOOL.Includes = {
|
||||
"../SDK/include",
|
||||
"../SDK/src"
|
||||
"../include",
|
||||
"../src"
|
||||
}
|
||||
|
||||
TOOL.Files = {
|
||||
"../SDK/include/NDK/**.hpp",
|
||||
"../SDK/include/NDK/**.inl",
|
||||
"../SDK/src/NDK/**.hpp",
|
||||
"../SDK/src/NDK/**.inl",
|
||||
"../SDK/src/NDK/**.cpp"
|
||||
"../include/NazaraSDK/**.hpp",
|
||||
"../include/NazaraSDK/**.inl",
|
||||
"../src/NazaraSDK/**.hpp",
|
||||
"../src/NazaraSDK/**.inl",
|
||||
"../src/NazaraSDK/**.cpp"
|
||||
}
|
||||
|
||||
TOOL.Libraries = function()
|
||||
|
|
|
|||
|
|
@ -10,46 +10,40 @@ TOOL.Defines = {
|
|||
}
|
||||
|
||||
TOOL.Includes = {
|
||||
"../SDK/include",
|
||||
"../SDK/src"
|
||||
"../include",
|
||||
"../src"
|
||||
}
|
||||
|
||||
TOOL.Files = {
|
||||
"../SDK/include/NDK/**.hpp",
|
||||
"../SDK/include/NDK/**.inl",
|
||||
"../SDK/src/NDK/**.hpp",
|
||||
"../SDK/src/NDK/**.inl",
|
||||
"../SDK/src/NDK/**.cpp"
|
||||
"../include/NazaraSDK/**.hpp",
|
||||
"../include/NazaraSDK/**.inl",
|
||||
"../src/NazaraSDK/**.hpp",
|
||||
"../src/NazaraSDK/**.inl",
|
||||
"../src/NazaraSDK/**.cpp"
|
||||
}
|
||||
|
||||
-- Excludes client-only files
|
||||
TOOL.FilesExcluded = {
|
||||
"../SDK/**/CameraComponent.*",
|
||||
"../SDK/**/Canvas.*",
|
||||
"../SDK/**/Console.*",
|
||||
"../SDK/**/DebugComponent.*",
|
||||
"../SDK/**/DebugSystem.*",
|
||||
"../SDK/**/GraphicsComponent.*",
|
||||
"../SDK/**/LightComponent.*",
|
||||
"../SDK/**/ListenerComponent.*",
|
||||
"../SDK/**/ListenerSystem.*",
|
||||
"../SDK/**/Particle*Component.*",
|
||||
"../SDK/**/ParticleSystem.*",
|
||||
"../SDK/**/RenderSystem.*",
|
||||
"../SDK/**/*Layout*.*",
|
||||
"../SDK/**/*Widget*.*",
|
||||
"../SDK/**/LuaBinding_Audio.*",
|
||||
"../SDK/**/LuaBinding_Graphics.*",
|
||||
"../SDK/**/LuaBinding_Renderer.*",
|
||||
"../SDK/**/LuaBinding_Platform.*"
|
||||
"../*/NazaraSDK/BaseWidget.*",
|
||||
"../*/NazaraSDK/Canvas.*",
|
||||
"../*/NazaraSDK/Console.*",
|
||||
"../*/NazaraSDK/**/CameraComponent.*",
|
||||
"../*/NazaraSDK/**/DebugComponent.*",
|
||||
"../*/NazaraSDK/**/DebugSystem.*",
|
||||
"../*/NazaraSDK/**/GraphicsComponent.*",
|
||||
"../*/NazaraSDK/**/LightComponent.*",
|
||||
"../*/NazaraSDK/**/ListenerComponent.*",
|
||||
"../*/NazaraSDK/**/ListenerSystem.*",
|
||||
"../*/NazaraSDK/**/Particle*Component.*",
|
||||
"../*/NazaraSDK/**/ParticleSystem.*",
|
||||
"../*/NazaraSDK/**/RenderSystem.*",
|
||||
"../*/NazaraSDK/**/*Layout*.*",
|
||||
"../*/NazaraSDK/**/*Widget*.*"
|
||||
}
|
||||
|
||||
|
||||
TOOL.Libraries = {
|
||||
"NazaraCore",
|
||||
"NazaraLua",
|
||||
"NazaraNetwork",
|
||||
"NazaraNoise",
|
||||
"NazaraPhysics2D",
|
||||
"NazaraPhysics3D",
|
||||
"NazaraUtility"
|
||||
|
|
|
|||
|
|
@ -10,11 +10,12 @@
|
|||
|
||||
#include <Nazara/Audio.hpp>
|
||||
#include <Nazara/Core/Clock.hpp>
|
||||
#include <Nazara/Core/Thread.hpp> // Thread::Sleep
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Platform/Keyboard.hpp>
|
||||
#include <Nazara/Platform/Platform.hpp>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
|
@ -61,7 +62,7 @@ int main()
|
|||
int sleepTime = int(1000/60 - clock.GetMilliseconds()); // 60 FPS
|
||||
|
||||
if (sleepTime > 0)
|
||||
Nz::Thread::Sleep(sleepTime);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(sleepTime));
|
||||
|
||||
// On bouge la source du son en fonction du temps depuis chaque mise à jour
|
||||
Nz::Vector3f pos = sound.GetPosition() + sound.GetVelocity()*clock.GetSeconds();
|
||||
|
|
|
|||
|
|
@ -13,18 +13,16 @@
|
|||
*/
|
||||
|
||||
#include <Nazara/Core/Clock.hpp> // Horloges
|
||||
#include <Nazara/Lua.hpp> // Module de scripting
|
||||
#include <Nazara/Graphics.hpp> // Module graphique
|
||||
#include <Nazara/Renderer.hpp> // Module de rendu
|
||||
#include <Nazara/Network.hpp> // Module utilitaire
|
||||
#include <Nazara/Utility.hpp> // Module utilitaire
|
||||
#include <NDK/Application.hpp>
|
||||
#include <NDK/Components.hpp>
|
||||
#include <NDK/Console.hpp>
|
||||
#include <NDK/Systems.hpp>
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
#include <NDK/Sdk.hpp>
|
||||
#include <NDK/World.hpp>
|
||||
#include <NazaraSDK/Application.hpp>
|
||||
#include <NazaraSDK/Components.hpp>
|
||||
#include <NazaraSDK/Console.hpp>
|
||||
#include <NazaraSDK/Systems.hpp>
|
||||
#include <NazaraSDK/Sdk.hpp>
|
||||
#include <NazaraSDK/World.hpp>
|
||||
#include <iostream>
|
||||
|
||||
// Petite fonction permettant de rendre le déplacement de la caméra moins ridige
|
||||
|
|
@ -264,10 +262,6 @@ int main()
|
|||
application.EnableConsole(true);
|
||||
application.EnableFPSCounter(true);
|
||||
|
||||
Ndk::Application::ConsoleOverlay& consoleOverlay = application.GetConsoleOverlay();
|
||||
consoleOverlay.lua.PushGlobal("Spaceship", spaceship->CreateHandle());
|
||||
consoleOverlay.lua.PushGlobal("World", world->CreateHandle());
|
||||
|
||||
|
||||
//Gestion des Evenements
|
||||
Nz::EventHandler& eventHandler = window.GetEventHandler();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
#include <Nazara/Core/Directory.hpp>
|
||||
#include <Nazara/Core/File.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Utility/Animation.hpp>
|
||||
|
|
@ -26,25 +25,17 @@ int main()
|
|||
|
||||
for (;;)
|
||||
{
|
||||
Nz::Directory resourceDirectory("resources");
|
||||
if (!resourceDirectory.Open())
|
||||
std::vector<std::filesystem::path> models;
|
||||
for (auto& p : std::filesystem::directory_iterator("resources"))
|
||||
{
|
||||
std::cerr << "Failed to open resource directory" << std::endl;
|
||||
std::getchar();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (!p.is_regular_file())
|
||||
continue;
|
||||
|
||||
std::vector<Nz::String> models;
|
||||
while (resourceDirectory.NextResult())
|
||||
{
|
||||
Nz::String path = resourceDirectory.GetResultName();
|
||||
Nz::String ext = path.SubStringFrom('.', -1, true); // Tout ce qui vient après le dernier '.' de la chaîne
|
||||
if (Nz::MeshLoader::IsExtensionSupported(ext)) // L'extension est-elle supportée par le MeshLoader ?
|
||||
models.push_back(path);
|
||||
const std::filesystem::path& filePath = p.path();
|
||||
if (Nz::MeshLoader::IsExtensionSupported(filePath.extension().generic_u8string())) // L'extension est-elle supportée par le MeshLoader ?
|
||||
models.push_back(filePath);
|
||||
}
|
||||
|
||||
resourceDirectory.Close();
|
||||
|
||||
if (models.empty())
|
||||
{
|
||||
std::cout << "No loadable mesh found in resource directory" << std::endl;
|
||||
|
|
@ -71,7 +62,7 @@ int main()
|
|||
if (iChoice == 0)
|
||||
break;
|
||||
|
||||
Nz::MeshRef mesh = Nz::Mesh::LoadFromFile(resourceDirectory.GetPath() + '/' + models[iChoice-1]);
|
||||
Nz::MeshRef mesh = Nz::Mesh::LoadFromFile(models[iChoice-1]);
|
||||
if (!mesh)
|
||||
{
|
||||
std::cout << "Failed to load mesh" << std::endl;
|
||||
|
|
@ -123,8 +114,8 @@ int main()
|
|||
}
|
||||
}
|
||||
|
||||
Nz::String animationPath = mesh->GetAnimation();
|
||||
if (!animationPath.IsEmpty())
|
||||
std::filesystem::path animationPath = mesh->GetAnimation();
|
||||
if (!animationPath.empty())
|
||||
{
|
||||
Nz::AnimationRef animation = Nz::Animation::LoadFromFile(animationPath);
|
||||
if (animation)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#include "Common.hpp"
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Utility/SimpleTextDrawer.hpp>
|
||||
#include <NDK/Components/ParticleGroupComponent.hpp>
|
||||
#include <NDK/Systems/RenderSystem.hpp>
|
||||
#include <NazaraSDK/Components/ParticleGroupComponent.hpp>
|
||||
#include <NazaraSDK/Systems/RenderSystem.hpp>
|
||||
|
||||
ParticleDemo::ParticleDemo(const Nz::String& name, const ExampleShared& exampleShared) :
|
||||
m_shared(exampleShared),
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@
|
|||
#include <Nazara/Graphics/AbstractBackground.hpp>
|
||||
#include <Nazara/Graphics/TextSprite.hpp>
|
||||
#include <Nazara/Renderer/RenderWindow.hpp>
|
||||
#include <NDK/Components/ParticleGroupComponent.hpp>
|
||||
#include <NDK/EntityOwner.hpp>
|
||||
#include <NDK/StateMachine.hpp>
|
||||
#include <NDK/World.hpp>
|
||||
#include <NazaraSDK/Components/ParticleGroupComponent.hpp>
|
||||
#include <NazaraSDK/EntityOwner.hpp>
|
||||
#include <NazaraSDK/StateMachine.hpp>
|
||||
#include <NazaraSDK/World.hpp>
|
||||
#include <memory>
|
||||
#include <random>
|
||||
#include <vector>
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
#include <Nazara/Core/OffsetOf.hpp>
|
||||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <NDK/Components.hpp>
|
||||
#include <NDK/Systems.hpp>
|
||||
#include <NazaraSDK/Components.hpp>
|
||||
#include <NazaraSDK/Systems.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace
|
||||
|
|
@ -126,7 +126,7 @@ ParticleDemo("Logo", sharedData)
|
|||
Nz::ImageParams params;
|
||||
params.loadFormat = Nz::PixelFormatType_RGBA8;
|
||||
|
||||
m_logo = Nz::Image::LoadFromFile("resources/Logo.png", params);
|
||||
m_logo = Nz::Image::LoadFromFile("E:/Twitch/avatar_interested.png", params);
|
||||
if (!m_logo)
|
||||
NazaraError("Failed to load logo!");
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Graphics/ParticleStruct.hpp>
|
||||
#include <NDK/State.hpp>
|
||||
#include <NazaraSDK/State.hpp>
|
||||
#include <vector>
|
||||
#include "Common.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Platform.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <NDK/Components.hpp>
|
||||
#include <NDK/Systems.hpp>
|
||||
#include <NazaraSDK/Components.hpp>
|
||||
#include <NazaraSDK/Systems.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
#include <Nazara/Graphics/SkyboxBackground.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Platform/EventHandler.hpp>
|
||||
#include <NDK/Entity.hpp>
|
||||
#include <NDK/State.hpp>
|
||||
#include <NazaraSDK/Entity.hpp>
|
||||
#include <NazaraSDK/State.hpp>
|
||||
#include <vector>
|
||||
#include "Common.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,14 @@
|
|||
#include <Nazara/Audio.hpp>
|
||||
#include <Nazara/Core.hpp>
|
||||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Lua.hpp>
|
||||
#include <Nazara/Network.hpp>
|
||||
#include <Nazara/Noise.hpp>
|
||||
#include <Nazara/Physics3D.hpp>
|
||||
#include <Nazara/Renderer.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <NDK/Application.hpp>
|
||||
#include <NDK/Components.hpp>
|
||||
#include <NDK/Systems.hpp>
|
||||
#include <NDK/StateMachine.hpp>
|
||||
#include <NazaraSDK/Application.hpp>
|
||||
#include <NazaraSDK/Components.hpp>
|
||||
#include <NazaraSDK/Systems.hpp>
|
||||
#include <NazaraSDK/StateMachine.hpp>
|
||||
#include "LogoDemo.hpp"
|
||||
#include "SpacebattleDemo.hpp"
|
||||
#include <iostream>
|
||||
|
|
@ -38,6 +36,8 @@ int main()
|
|||
Nz::RenderWindow& window = app.AddWindow<Nz::RenderWindow>(mode, "Nazara demo - Particles", Nz::WindowStyle_Closable, targetParams);
|
||||
//Nz::RenderWindow& window = app.AddWindow<Nz::RenderWindow>(Nz::VideoMode(1920, 1080), "Nazara demo - Particles", Nz::WindowStyle_Fullscreen, targetParams);
|
||||
|
||||
app.EnableFPSCounter(true);
|
||||
|
||||
Ndk::World& world3D = app.AddWorld();
|
||||
Ndk::World& world2D = app.AddWorld();
|
||||
|
||||
|
|
@ -173,7 +173,7 @@ int main()
|
|||
window.CopyToImage(&screenshot);
|
||||
|
||||
static unsigned int counter = 1;
|
||||
screenshot.SaveToFile("screenshot_" + Nz::String::Number(counter++) + ".png");
|
||||
screenshot.SaveToFile("screenshot_" + std::to_string(counter++) + ".png");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,9 +10,7 @@ EXAMPLE.Libraries = {
|
|||
"NazaraAudio",
|
||||
"NazaraCore",
|
||||
"NazaraGraphics",
|
||||
"NazaraLua",
|
||||
"NazaraNetwork",
|
||||
"NazaraNoise",
|
||||
"NazaraPhysics2D",
|
||||
"NazaraPhysics3D",
|
||||
"NazaraPlatform",
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
#include <Nazara/Audio.hpp>
|
||||
#include <Nazara/Audio.hpp>
|
||||
#include <Nazara/Core.hpp>
|
||||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Lua.hpp>
|
||||
#include <Nazara/Network.hpp>
|
||||
#include <Nazara/Noise.hpp>
|
||||
#include <Nazara/Physics2D.hpp>
|
||||
#include <Nazara/Physics3D.hpp>
|
||||
#include <Nazara/Renderer.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <NDK/Application.hpp>
|
||||
#include <NazaraSDK/Application.hpp>
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Renderer.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <NDK/Application.hpp>
|
||||
#include <NDK/Components.hpp>
|
||||
#include <NDK/Systems.hpp>
|
||||
#include <NDK/World.hpp>
|
||||
#include <NazaraSDK/Application.hpp>
|
||||
#include <NazaraSDK/Components.hpp>
|
||||
#include <NazaraSDK/Systems.hpp>
|
||||
#include <NazaraSDK/World.hpp>
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Renderer.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <NDK/Application.hpp>
|
||||
#include <NDK/Components.hpp>
|
||||
#include <NDK/Systems.hpp>
|
||||
#include <NDK/World.hpp>
|
||||
#include <NazaraSDK/Application.hpp>
|
||||
#include <NazaraSDK/Components.hpp>
|
||||
#include <NazaraSDK/Systems.hpp>
|
||||
#include <NazaraSDK/World.hpp>
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace Nz
|
|||
|
||||
bool IsLooping() const override;
|
||||
|
||||
bool OpenFromFile(const String& filePath, const SoundStreamParams& params = SoundStreamParams());
|
||||
bool OpenFromFile(const std::filesystem::path& filePath, const SoundStreamParams& params = SoundStreamParams());
|
||||
bool OpenFromMemory(const void* data, std::size_t size, const SoundStreamParams& params = SoundStreamParams());
|
||||
bool OpenFromStream(Stream& stream, const SoundStreamParams& params = SoundStreamParams());
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace Nz
|
|||
bool IsPlayable() const;
|
||||
bool IsPlaying() const;
|
||||
|
||||
bool LoadFromFile(const String& filePath, const SoundBufferParams& params = SoundBufferParams());
|
||||
bool LoadFromFile(const std::filesystem::path& filePath, const SoundBufferParams& params = SoundBufferParams());
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params = SoundBufferParams());
|
||||
bool LoadFromStream(Stream& stream, const SoundBufferParams& params = SoundBufferParams());
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ namespace Nz
|
|||
|
||||
static bool IsFormatSupported(AudioFormat format);
|
||||
|
||||
static SoundBufferRef LoadFromFile(const String& filePath, const SoundBufferParams& params = SoundBufferParams());
|
||||
static SoundBufferRef LoadFromFile(const std::filesystem::path& filePath, const SoundBufferParams& params = SoundBufferParams());
|
||||
static SoundBufferRef LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params = SoundBufferParams());
|
||||
static SoundBufferRef LoadFromStream(Stream& stream, const SoundBufferParams& params = SoundBufferParams());
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/ResourceParameters.hpp>
|
||||
#include <mutex>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
|
@ -40,7 +41,7 @@ namespace Nz
|
|||
|
||||
virtual UInt32 GetDuration() const = 0;
|
||||
virtual AudioFormat GetFormat() const = 0;
|
||||
virtual Mutex& GetMutex() = 0;
|
||||
virtual std::mutex& GetMutex() = 0;
|
||||
virtual UInt64 GetSampleCount() const = 0;
|
||||
virtual UInt32 GetSampleRate() const = 0;
|
||||
|
||||
|
|
@ -48,7 +49,7 @@ namespace Nz
|
|||
virtual void Seek(UInt64 offset) = 0;
|
||||
virtual UInt64 Tell() = 0;
|
||||
|
||||
static SoundStreamRef OpenFromFile(const String& filePath, const SoundStreamParams& params = SoundStreamParams());
|
||||
static SoundStreamRef OpenFromFile(const std::filesystem::path& filePath, const SoundStreamParams& params = SoundStreamParams());
|
||||
static SoundStreamRef OpenFromMemory(const void* data, std::size_t size, const SoundStreamParams& params = SoundStreamParams());
|
||||
static SoundStreamRef OpenFromStream(Stream& stream, const SoundStreamParams& params = SoundStreamParams());
|
||||
|
||||
|
|
|
|||
|
|
@ -34,14 +34,13 @@
|
|||
#include <Nazara/Core/Algorithm.hpp>
|
||||
#include <Nazara/Core/Bitset.hpp>
|
||||
#include <Nazara/Core/ByteArray.hpp>
|
||||
#include <Nazara/Core/ByteArrayPool.hpp>
|
||||
#include <Nazara/Core/ByteStream.hpp>
|
||||
#include <Nazara/Core/CallOnExit.hpp>
|
||||
#include <Nazara/Core/Clock.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Core/ConditionVariable.hpp>
|
||||
#include <Nazara/Core/Config.hpp>
|
||||
#include <Nazara/Core/Core.hpp>
|
||||
#include <Nazara/Core/Directory.hpp>
|
||||
#include <Nazara/Core/DynLib.hpp>
|
||||
#include <Nazara/Core/EmptyStream.hpp>
|
||||
#include <Nazara/Core/Endianness.hpp>
|
||||
|
|
@ -56,7 +55,6 @@
|
|||
#include <Nazara/Core/HandledObject.hpp>
|
||||
#include <Nazara/Core/HardwareInfo.hpp>
|
||||
#include <Nazara/Core/Initializer.hpp>
|
||||
#include <Nazara/Core/LockGuard.hpp>
|
||||
#include <Nazara/Core/Log.hpp>
|
||||
#include <Nazara/Core/MemoryHelper.hpp>
|
||||
#include <Nazara/Core/MemoryManager.hpp>
|
||||
|
|
@ -64,13 +62,13 @@
|
|||
#include <Nazara/Core/MemoryStream.hpp>
|
||||
#include <Nazara/Core/MemoryView.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
#include <Nazara/Core/Mutex.hpp>
|
||||
#include <Nazara/Core/ObjectHandle.hpp>
|
||||
#include <Nazara/Core/ObjectLibrary.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Core/OffsetOf.hpp>
|
||||
#include <Nazara/Core/ParameterList.hpp>
|
||||
#include <Nazara/Core/PluginManager.hpp>
|
||||
#include <Nazara/Core/PoolByteStream.hpp>
|
||||
#include <Nazara/Core/Primitive.hpp>
|
||||
#include <Nazara/Core/PrimitiveList.hpp>
|
||||
#include <Nazara/Core/RefCounted.hpp>
|
||||
|
|
@ -79,7 +77,6 @@
|
|||
#include <Nazara/Core/ResourceManager.hpp>
|
||||
#include <Nazara/Core/ResourceParameters.hpp>
|
||||
#include <Nazara/Core/ResourceSaver.hpp>
|
||||
#include <Nazara/Core/Semaphore.hpp>
|
||||
#include <Nazara/Core/SerializationContext.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Core/SparsePtr.hpp>
|
||||
|
|
@ -88,9 +85,9 @@
|
|||
#include <Nazara/Core/StdLogger.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Core/StringExt.hpp>
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <Nazara/Core/TaskScheduler.hpp>
|
||||
#include <Nazara/Core/Thread.hpp>
|
||||
#include <Nazara/Core/TypeTag.hpp>
|
||||
#include <Nazara/Core/Unicode.hpp>
|
||||
#include <Nazara/Core/Updatable.hpp>
|
||||
|
|
|
|||
|
|
@ -31,6 +31,33 @@ namespace Nz
|
|||
template<typename T> void HashCombine(std::size_t& seed, const T& v);
|
||||
template<typename T> T ReverseBits(T integer);
|
||||
|
||||
template<typename T>
|
||||
struct AlwaysFalse : std::false_type {};
|
||||
|
||||
template<typename... Args>
|
||||
struct OverloadResolver
|
||||
{
|
||||
template<typename R, typename T>
|
||||
constexpr auto operator()(R(T::* ptr)(Args...)) const noexcept
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
|
||||
template<typename R, typename T>
|
||||
constexpr auto operator()(R(T::* ptr)(Args...) const) const noexcept
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
|
||||
template<typename R>
|
||||
constexpr auto operator()(R(*ptr)(Args...)) const noexcept
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename... Args> constexpr OverloadResolver<Args...> Overload = {};
|
||||
|
||||
template<typename T>
|
||||
struct PointedType
|
||||
{
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ namespace Nz
|
|||
Bitset<Block, Allocator>::Bitset(T value) :
|
||||
Bitset()
|
||||
{
|
||||
if (sizeof(T) <= sizeof(Block))
|
||||
if constexpr (sizeof(T) <= sizeof(Block))
|
||||
{
|
||||
m_bitCount = BitCount<T>();
|
||||
m_blocks.push_back(static_cast<Block>(value));
|
||||
|
|
|
|||
|
|
@ -9,12 +9,6 @@
|
|||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
|
||||
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_CLOCK
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
#else
|
||||
#include <Nazara/Core/ThreadSafetyOff.hpp>
|
||||
#endif
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_CORE_API Clock
|
||||
|
|
@ -39,8 +33,6 @@ namespace Nz
|
|||
Clock& operator=(Clock&& clock) = default;
|
||||
|
||||
private:
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
UInt64 m_elapsedTime;
|
||||
UInt64 m_refTime;
|
||||
bool m_paused;
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CONDITIONVARIABLE_HPP
|
||||
#define NAZARA_CONDITIONVARIABLE_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class ConditionVariableImpl;
|
||||
class Mutex;
|
||||
|
||||
class NAZARA_CORE_API ConditionVariable
|
||||
{
|
||||
public:
|
||||
ConditionVariable();
|
||||
ConditionVariable(const ConditionVariable&) = delete;
|
||||
ConditionVariable(ConditionVariable&& condition) noexcept = default;
|
||||
~ConditionVariable();
|
||||
|
||||
void Signal();
|
||||
void SignalAll();
|
||||
|
||||
void Wait(Mutex* mutex);
|
||||
bool Wait(Mutex* mutex, UInt32 timeout);
|
||||
|
||||
ConditionVariable& operator=(const ConditionVariable&) = delete;
|
||||
ConditionVariable& operator=(ConditionVariable&& condition) noexcept = default;
|
||||
|
||||
private:
|
||||
MovablePtr<ConditionVariableImpl> m_impl;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Core/ConditionVariable.inl>
|
||||
|
||||
#endif // NAZARA_CONDITIONVARIABLE_HPP
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
/*!
|
||||
* \class Nz::ConditionVariable
|
||||
*/
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
|
@ -58,17 +58,6 @@
|
|||
// Activate the security tests based on the code (Advised for development)
|
||||
#define NAZARA_CORE_SAFE 1
|
||||
|
||||
// Protect the classes against data race
|
||||
#define NAZARA_CORE_THREADSAFE 1
|
||||
|
||||
// Classes to protect against data race
|
||||
#define NAZARA_THREADSAFETY_CLOCK 0 // Clock
|
||||
#define NAZARA_THREADSAFETY_DIRECTORY 1 // Directory
|
||||
#define NAZARA_THREADSAFETY_DYNLIB 1 // DynLib
|
||||
#define NAZARA_THREADSAFETY_FILE 1 // File
|
||||
#define NAZARA_THREADSAFETY_LOG 1 // Log
|
||||
#define NAZARA_THREADSAFETY_REFCOUNTED 1 // RefCounted
|
||||
|
||||
// Number of spinlocks to use with the Windows critical sections (0 to disable)
|
||||
#define NAZARA_CORE_WINDOWS_CS_SPINLOCKS 4096
|
||||
|
||||
|
|
|
|||
|
|
@ -1,82 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_DIRECTORY_HPP
|
||||
#define NAZARA_DIRECTORY_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
#define NAZARA_DIRECTORY_SEPARATOR '\\'
|
||||
#elif defined(NAZARA_PLATFORM_LINUX)
|
||||
#define NAZARA_DIRECTORY_SEPARATOR '/'
|
||||
#else
|
||||
#error OS not handled
|
||||
#define NAZARA_DIRECTORY_SEPARATOR '/'
|
||||
#endif
|
||||
|
||||
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_DIRECTORY
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
#else
|
||||
#include <Nazara/Core/ThreadSafetyOff.hpp>
|
||||
#endif
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class DirectoryImpl;
|
||||
|
||||
class NAZARA_CORE_API Directory
|
||||
{
|
||||
public:
|
||||
Directory();
|
||||
Directory(const String& dirPath);
|
||||
Directory(const Directory&) = delete;
|
||||
Directory(Directory&&) noexcept = default;
|
||||
~Directory();
|
||||
|
||||
void Close();
|
||||
|
||||
bool Exists() const;
|
||||
|
||||
String GetPath() const;
|
||||
String GetPattern() const;
|
||||
String GetResultName() const;
|
||||
String GetResultPath() const;
|
||||
UInt64 GetResultSize() const;
|
||||
|
||||
bool IsOpen() const;
|
||||
bool IsResultDirectory() const;
|
||||
|
||||
bool NextResult(bool skipDots = true);
|
||||
|
||||
bool Open();
|
||||
|
||||
void SetPath(const String& dirPath);
|
||||
void SetPattern(const String& pattern);
|
||||
|
||||
static bool Copy(const String& sourcePath, const String& destPath);
|
||||
static bool Create(const String& dirPath, bool recursive = false);
|
||||
static bool Exists(const String& dirPath);
|
||||
static String GetCurrent();
|
||||
static const char* GetCurrentFileRelativeToEngine(const char* currentFile);
|
||||
static bool Remove(const String& dirPath, bool emptyDirectory = false);
|
||||
static bool SetCurrent(const String& dirPath);
|
||||
|
||||
Directory& operator=(const Directory&) = delete;
|
||||
Directory& operator=(Directory&&) noexcept = delete;
|
||||
|
||||
private:
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
String m_dirPath;
|
||||
String m_pattern;
|
||||
MovablePtr<DirectoryImpl> m_impl;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_DIRECTORY_HPP
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
#define NAZARA_DYNLIB_EXTENSION ".dll"
|
||||
|
|
@ -21,12 +21,6 @@
|
|||
#error OS not handled
|
||||
#endif
|
||||
|
||||
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_DYNLIB
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
#else
|
||||
#include <Nazara/Core/ThreadSafetyOff.hpp>
|
||||
#endif
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
using DynLibFunc = int (*)(); // "Generic" type of pointer to function
|
||||
|
|
@ -38,25 +32,23 @@ namespace Nz
|
|||
public:
|
||||
DynLib();
|
||||
DynLib(const DynLib&) = delete;
|
||||
DynLib(DynLib&&) noexcept = default;
|
||||
DynLib(DynLib&&) noexcept;
|
||||
~DynLib();
|
||||
|
||||
String GetLastError() const;
|
||||
DynLibFunc GetSymbol(const String& symbol) const;
|
||||
std::string GetLastError() const;
|
||||
DynLibFunc GetSymbol(const char* symbol) const;
|
||||
|
||||
bool IsLoaded() const;
|
||||
|
||||
bool Load(const String& libraryPath);
|
||||
bool Load(const std::filesystem::path& libraryPath);
|
||||
void Unload();
|
||||
|
||||
DynLib& operator=(const DynLib&) = delete;
|
||||
DynLib& operator=(DynLib&& lib) noexcept = default;
|
||||
DynLib& operator=(DynLib&& lib) noexcept;
|
||||
|
||||
private:
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
mutable String m_lastError;
|
||||
MovablePtr<DynLibImpl> m_impl;
|
||||
mutable std::string m_lastError;
|
||||
std::unique_ptr<DynLibImpl> m_impl;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace Nz
|
|||
static UInt32 GetFlags();
|
||||
static String GetLastError(const char** file = nullptr, unsigned int* line = nullptr, const char** function = nullptr);
|
||||
static unsigned int GetLastSystemErrorCode();
|
||||
static String GetLastSystemError(unsigned int code = GetLastSystemErrorCode());
|
||||
static std::string GetLastSystemError(unsigned int code = GetLastSystemErrorCode());
|
||||
|
||||
static void SetFlags(UInt32 flags);
|
||||
|
||||
|
|
@ -41,6 +41,8 @@ namespace Nz
|
|||
static void Trigger(ErrorType type, const String& error, unsigned int line, const char* file, const char* function);
|
||||
|
||||
private:
|
||||
static const char* GetCurrentFileRelativeToEngine(const char* file);
|
||||
|
||||
static UInt32 s_flags;
|
||||
static String s_lastError;
|
||||
static const char* s_lastErrorFunction;
|
||||
|
|
|
|||
|
|
@ -13,14 +13,9 @@
|
|||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_FILE
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
#else
|
||||
#include <Nazara/Core/ThreadSafetyOff.hpp>
|
||||
#endif
|
||||
|
||||
#include <ctime>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
|
@ -30,13 +25,13 @@ namespace Nz
|
|||
{
|
||||
public:
|
||||
File();
|
||||
File(const String& filePath);
|
||||
File(const String& filePath, OpenModeFlags openMode);
|
||||
File(const std::filesystem::path& filePath);
|
||||
File(const std::filesystem::path& filePath, OpenModeFlags openMode);
|
||||
File(const File&) = delete;
|
||||
File(File&& file) noexcept = default;
|
||||
File(File&& file) noexcept;
|
||||
~File();
|
||||
|
||||
bool Copy(const String& newFilePath);
|
||||
void Copy(const std::filesystem::path& newFilePath);
|
||||
void Close();
|
||||
|
||||
bool Delete();
|
||||
|
|
@ -46,56 +41,35 @@ namespace Nz
|
|||
|
||||
bool Exists() const;
|
||||
|
||||
time_t GetCreationTime() const;
|
||||
UInt64 GetCursorPos() const override;
|
||||
String GetDirectory() const override;
|
||||
String GetFileName() const;
|
||||
time_t GetLastAccessTime() const;
|
||||
time_t GetLastWriteTime() const;
|
||||
String GetPath() const override;
|
||||
std::filesystem::path GetDirectory() const override;
|
||||
std::filesystem::path GetFileName() const;
|
||||
std::filesystem::path GetPath() const override;
|
||||
UInt64 GetSize() const override;
|
||||
|
||||
bool IsOpen() const;
|
||||
|
||||
bool Open(OpenModeFlags openMode = OpenMode_NotOpen);
|
||||
bool Open(const String& filePath, OpenModeFlags openMode = OpenMode_NotOpen);
|
||||
|
||||
bool Rename(const String& newFilePath);
|
||||
bool Open(const std::filesystem::path& filePath, OpenModeFlags openMode = OpenMode_NotOpen);
|
||||
|
||||
bool SetCursorPos(CursorPosition pos, Int64 offset = 0);
|
||||
bool SetCursorPos(UInt64 offset) override;
|
||||
bool SetFile(const String& filePath);
|
||||
bool SetFile(const std::filesystem::path& filePath);
|
||||
bool SetSize(UInt64 size);
|
||||
|
||||
File& operator=(const String& filePath);
|
||||
File& operator=(const File&) = delete;
|
||||
File& operator=(File&& file) noexcept = default;
|
||||
File& operator=(File&& file) noexcept;
|
||||
|
||||
static String AbsolutePath(const String& filePath);
|
||||
static inline ByteArray ComputeHash(HashType hash, const String& filePath);
|
||||
static inline ByteArray ComputeHash(AbstractHash* hash, const String& filePath);
|
||||
static bool Copy(const String& sourcePath, const String& targetPath);
|
||||
static bool Delete(const String& filePath);
|
||||
static bool Exists(const String& filePath);
|
||||
static time_t GetCreationTime(const String& filePath);
|
||||
static String GetDirectory(const String& filePath);
|
||||
static time_t GetLastAccessTime(const String& filePath);
|
||||
static time_t GetLastWriteTime(const String& filePath);
|
||||
static UInt64 GetSize(const String& filePath);
|
||||
static bool IsAbsolute(const String& filePath);
|
||||
static String NormalizePath(const String& filePath);
|
||||
static String NormalizeSeparators(const String& filePath);
|
||||
static bool Rename(const String& sourcePath, const String& targetPath);
|
||||
static inline ByteArray ComputeHash(HashType hash, const std::filesystem::path& filePath);
|
||||
static inline ByteArray ComputeHash(AbstractHash* hash, const std::filesystem::path& filePath);
|
||||
|
||||
private:
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
void FlushStream() override;
|
||||
std::size_t ReadBlock(void* buffer, std::size_t size) override;
|
||||
std::size_t WriteBlock(const void* buffer, std::size_t size) override;
|
||||
|
||||
String m_filePath;
|
||||
MovablePtr<FileImpl> m_impl;
|
||||
std::filesystem::path m_filePath;
|
||||
std::unique_ptr<FileImpl> m_impl;
|
||||
};
|
||||
|
||||
NAZARA_CORE_API bool HashAppend(AbstractHash* hash, const File& originalFile);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace Nz
|
|||
* \param filePath Path for the file
|
||||
*/
|
||||
|
||||
inline ByteArray File::ComputeHash(HashType hash, const String& filePath)
|
||||
inline ByteArray File::ComputeHash(HashType hash, const std::filesystem::path& filePath)
|
||||
{
|
||||
return ComputeHash(AbstractHash::Get(hash).get(), filePath);
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ namespace Nz
|
|||
* \param filePath Path for the file
|
||||
*/
|
||||
|
||||
inline ByteArray File::ComputeHash(AbstractHash* hash, const String& filePath)
|
||||
inline ByteArray File::ComputeHash(AbstractHash* hash, const std::filesystem::path& filePath)
|
||||
{
|
||||
return Nz::ComputeHash(hash, File(filePath));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,9 @@
|
|||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/AbstractLogger.hpp>
|
||||
#include <Nazara/Core/File.hpp>
|
||||
#include <Nazara/Core/StdLogger.hpp>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
|
@ -19,7 +20,7 @@ namespace Nz
|
|||
public:
|
||||
FileLogger(const String& logPath = "NazaraLog.log");
|
||||
FileLogger(const FileLogger&) = default;
|
||||
FileLogger(FileLogger&&) noexcept = default;
|
||||
FileLogger(FileLogger&&) = default;
|
||||
~FileLogger();
|
||||
|
||||
void EnableTimeLogging(bool enable);
|
||||
|
|
@ -32,10 +33,11 @@ namespace Nz
|
|||
void WriteError(ErrorType type, const String& error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr) override;
|
||||
|
||||
FileLogger& operator=(const FileLogger&) = default;
|
||||
FileLogger& operator=(FileLogger&&) noexcept = default;
|
||||
FileLogger& operator=(FileLogger&&) = default;
|
||||
|
||||
private:
|
||||
File m_outputFile;
|
||||
std::fstream m_outputFile;
|
||||
std::filesystem::path m_outputPath;
|
||||
StdLogger m_stdLogger;
|
||||
bool m_forceStdOutput;
|
||||
bool m_stdReplicationEnabled;
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_LOCKGUARD_HPP
|
||||
#define NAZARA_LOCKGUARD_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class Mutex;
|
||||
|
||||
class LockGuard
|
||||
{
|
||||
public:
|
||||
inline LockGuard(Mutex& mutex, bool lock = true);
|
||||
inline ~LockGuard();
|
||||
|
||||
inline void Lock();
|
||||
inline bool TryLock();
|
||||
inline void Unlock();
|
||||
|
||||
private:
|
||||
Mutex& m_mutex;
|
||||
bool m_locked;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Core/LockGuard.inl>
|
||||
|
||||
#endif // NAZARA_LOCKGUARD_HPP
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/LockGuard.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/Mutex.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
/*!
|
||||
* \ingroup core
|
||||
* \class Nz::LockGuard
|
||||
* \brief Core class that represents a mutex wrapper that provides a convenient RAII-style mechanism
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief Constructs a LockGuard object with a mutex
|
||||
*
|
||||
* \param mutex Mutex to lock
|
||||
* \param lock Should the mutex be locked by the constructor
|
||||
*/
|
||||
inline LockGuard::LockGuard(Mutex& mutex, bool lock) :
|
||||
m_mutex(mutex),
|
||||
m_locked(false)
|
||||
{
|
||||
if (lock)
|
||||
{
|
||||
m_mutex.Lock();
|
||||
m_locked = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Destructs a LockGuard object and unlocks the mutex if it was previously locked
|
||||
*/
|
||||
inline LockGuard::~LockGuard()
|
||||
{
|
||||
if (m_locked)
|
||||
m_mutex.Unlock();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Locks the underlying mutex
|
||||
*
|
||||
* \see Mutex::Lock
|
||||
*/
|
||||
inline void LockGuard::Lock()
|
||||
{
|
||||
NazaraAssert(!m_locked, "Mutex is already locked");
|
||||
|
||||
m_mutex.Lock();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Tries to lock the underlying mutex
|
||||
*
|
||||
* \see Mutex::TryLock
|
||||
*
|
||||
* \return true if the lock was acquired successfully
|
||||
*/
|
||||
inline bool LockGuard::TryLock()
|
||||
{
|
||||
NazaraAssert(!m_locked, "Mutex is already locked");
|
||||
|
||||
return m_mutex.TryLock();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Unlocks the underlying mutex
|
||||
*
|
||||
* \see Mutex::Unlock
|
||||
*/
|
||||
inline void LockGuard::Unlock()
|
||||
{
|
||||
NazaraAssert(m_locked, "Mutex is not locked");
|
||||
|
||||
m_mutex.Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
|
@ -11,12 +11,6 @@
|
|||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_LOG
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
#else
|
||||
#include <Nazara/Core/ThreadSafetyOff.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef NAZARA_DEBUG
|
||||
#define NazaraDebug(txt) NazaraNotice(txt)
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_MUTEX_HPP
|
||||
#define NAZARA_MUTEX_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class MutexImpl;
|
||||
|
||||
class NAZARA_CORE_API Mutex
|
||||
{
|
||||
friend class ConditionVariable;
|
||||
|
||||
public:
|
||||
Mutex();
|
||||
Mutex(const Mutex&) = delete;
|
||||
Mutex(Mutex&&) noexcept = default;
|
||||
~Mutex();
|
||||
|
||||
void Lock();
|
||||
bool TryLock();
|
||||
void Unlock();
|
||||
|
||||
Mutex& operator=(const Mutex&) = delete;
|
||||
Mutex& operator=(Mutex&&) noexcept = default;
|
||||
|
||||
private:
|
||||
MovablePtr<MutexImpl> m_impl;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Core/Mutex.inl>
|
||||
|
||||
#endif // NAZARA_MUTEX_HPP
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Mutex.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
/*!
|
||||
* \ingroup core
|
||||
* \class Nz::Mutex
|
||||
*/
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/Enums.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <filesystem>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
|
||||
|
|
@ -24,23 +24,32 @@ namespace Nz
|
|||
PluginManager() = delete;
|
||||
~PluginManager() = delete;
|
||||
|
||||
static void AddDirectory(const String& directoryPath);
|
||||
static void AddDirectory(const std::filesystem::path& directoryPath);
|
||||
|
||||
static bool Initialize();
|
||||
|
||||
static bool Mount(Plugin plugin);
|
||||
static bool Mount(const String& pluginPath, bool appendExtension = true);
|
||||
static bool Mount(const std::filesystem::path& pluginPath, bool appendExtension = true);
|
||||
|
||||
static void RemoveDirectory(const String& directoryPath);
|
||||
static void RemoveDirectory(const std::filesystem::path& directoryPath);
|
||||
|
||||
static void Unmount(Plugin plugin);
|
||||
static void Unmount(const String& pluginPath);
|
||||
static void Unmount(const std::filesystem::path& pluginPath);
|
||||
|
||||
static void Uninitialize();
|
||||
|
||||
private:
|
||||
static std::set<String> s_directories;
|
||||
static std::unordered_map<String, DynLib*> s_plugins;
|
||||
// https://stackoverflow.com/questions/51065244/is-there-no-standard-hash-for-stdfilesystempath
|
||||
struct PathHash
|
||||
{
|
||||
std::size_t operator()(const std::filesystem::path& p) const
|
||||
{
|
||||
return hash_value(p);
|
||||
}
|
||||
};
|
||||
|
||||
static std::set<std::filesystem::path> s_directories;
|
||||
static std::unordered_map<std::filesystem::path, std::unique_ptr<DynLib>, PathHash> s_plugins;
|
||||
static bool s_initialized;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,12 +10,6 @@
|
|||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <atomic>
|
||||
|
||||
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_REFCOUNTED
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
#else
|
||||
#include <Nazara/Core/ThreadSafetyOff.hpp>
|
||||
#endif
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_CORE_API RefCounted
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#define NAZARA_RESOURCE_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
|
@ -20,15 +20,15 @@ namespace Nz
|
|||
Resource(Resource&&) noexcept = default;
|
||||
virtual ~Resource();
|
||||
|
||||
const String& GetFilePath() const;
|
||||
const std::filesystem::path& GetFilePath() const;
|
||||
|
||||
void SetFilePath(const String& filePath);
|
||||
void SetFilePath(const std::filesystem::path& filePath);
|
||||
|
||||
Resource& operator=(const Resource&) = default;
|
||||
Resource& operator=(Resource&&) noexcept = default;
|
||||
|
||||
private:
|
||||
String m_filePath;
|
||||
std::filesystem::path m_filePath;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include <Nazara/Core/RefCounted.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceParameters.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <filesystem>
|
||||
#include <list>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
|
|
@ -29,8 +29,8 @@ namespace Nz
|
|||
friend Type;
|
||||
|
||||
public:
|
||||
using ExtensionGetter = bool (*)(const String& extension);
|
||||
using FileLoader = ObjectRef<Type> (*)(const String& filePath, const Parameters& parameters);
|
||||
using ExtensionGetter = bool (*)(const std::string& extension);
|
||||
using FileLoader = ObjectRef<Type> (*)(const std::filesystem::path& filePath, const Parameters& parameters);
|
||||
using MemoryLoader = ObjectRef<Type> (*)(const void* data, std::size_t size, const Parameters& parameters);
|
||||
using StreamChecker = Ternary (*)(Stream& stream, const Parameters& parameters);
|
||||
using StreamLoader = ObjectRef<Type> (*)(Stream& stream, const Parameters& parameters);
|
||||
|
|
@ -38,9 +38,9 @@ namespace Nz
|
|||
ResourceLoader() = delete;
|
||||
~ResourceLoader() = delete;
|
||||
|
||||
static bool IsExtensionSupported(const String& extension);
|
||||
static bool IsExtensionSupported(const std::string& extension);
|
||||
|
||||
static ObjectRef<Type> LoadFromFile(const String& filePath, const Parameters& parameters = Parameters());
|
||||
static ObjectRef<Type> LoadFromFile(const std::filesystem::path& filePath, const Parameters& parameters = Parameters());
|
||||
static ObjectRef<Type> LoadFromMemory(const void* data, std::size_t size, const Parameters& parameters = Parameters());
|
||||
static ObjectRef<Type> LoadFromStream(Stream& stream, const Parameters& parameters = Parameters());
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include <Nazara/Core/File.hpp>
|
||||
#include <Nazara/Core/MemoryView.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <Nazara/Core/StringExt.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
|
@ -24,7 +25,7 @@ namespace Nz
|
|||
* \param extension Extension of the file
|
||||
*/
|
||||
template<typename Type, typename Parameters>
|
||||
bool ResourceLoader<Type, Parameters>::IsExtensionSupported(const String& extension)
|
||||
bool ResourceLoader<Type, Parameters>::IsExtensionSupported(const std::string& extension)
|
||||
{
|
||||
for (Loader& loader : Type::s_loaders)
|
||||
{
|
||||
|
|
@ -53,19 +54,21 @@ namespace Nz
|
|||
* \remark Produces a NazaraError if all loaders failed or no loader was found
|
||||
*/
|
||||
template<typename Type, typename Parameters>
|
||||
ObjectRef<Type> ResourceLoader<Type, Parameters>::LoadFromFile(const String& filePath, const Parameters& parameters)
|
||||
ObjectRef<Type> ResourceLoader<Type, Parameters>::LoadFromFile(const std::filesystem::path& filePath, const Parameters& parameters)
|
||||
{
|
||||
NazaraAssert(parameters.IsValid(), "Invalid parameters");
|
||||
|
||||
String path = File::NormalizePath(filePath);
|
||||
String ext = path.SubStringFrom('.', -1, true).ToLower();
|
||||
if (ext.IsEmpty())
|
||||
std::string ext = ToLower(filePath.extension().generic_u8string());
|
||||
if (ext.empty())
|
||||
{
|
||||
NazaraError("Failed to get file extension from \"" + filePath + '"');
|
||||
NazaraError("Failed to get file extension from \"" + filePath.generic_u8string() + '"');
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
File file(path); // Open only if needed
|
||||
if (ext[0] == '.')
|
||||
ext.erase(ext.begin());
|
||||
|
||||
File file(filePath.generic_u8string()); // Open only if needed
|
||||
|
||||
bool found = false;
|
||||
for (Loader& loader : Type::s_loaders)
|
||||
|
|
@ -82,7 +85,7 @@ namespace Nz
|
|||
{
|
||||
if (!file.Open(OpenMode_ReadOnly))
|
||||
{
|
||||
NazaraError("Failed to load file: unable to open \"" + filePath + '"');
|
||||
NazaraError("Failed to load file: unable to open \"" + filePath.generic_u8string() + '"');
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,19 +25,28 @@ namespace Nz
|
|||
|
||||
static void Clear();
|
||||
|
||||
static ObjectRef<Type> Get(const String& filePath);
|
||||
static ObjectRef<Type> Get(const std::filesystem::path& filePath);
|
||||
static const Parameters& GetDefaultParameters();
|
||||
|
||||
static void Purge();
|
||||
static void Register(const String& filePath, ObjectRef<Type> resource);
|
||||
static void Register(const std::filesystem::path& filePath, ObjectRef<Type> resource);
|
||||
static void SetDefaultParameters(const Parameters& params);
|
||||
static void Unregister(const String& filePath);
|
||||
static void Unregister(const std::filesystem::path& filePath);
|
||||
|
||||
private:
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
using ManagerMap = std::unordered_map<String, ObjectRef<Type>>;
|
||||
// https://stackoverflow.com/questions/51065244/is-there-no-standard-hash-for-stdfilesystempath
|
||||
struct PathHash
|
||||
{
|
||||
std::size_t operator()(const std::filesystem::path& p) const
|
||||
{
|
||||
return hash_value(p);
|
||||
}
|
||||
};
|
||||
|
||||
using ManagerMap = std::unordered_map<std::filesystem::path, ObjectRef<Type>, PathHash>;
|
||||
using ManagerParams = Parameters;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,20 +31,20 @@ namespace Nz
|
|||
* \param filePath Path to the asset that will be loaded
|
||||
*/
|
||||
template<typename Type, typename Parameters>
|
||||
ObjectRef<Type> ResourceManager<Type, Parameters>::Get(const String& filePath)
|
||||
ObjectRef<Type> ResourceManager<Type, Parameters>::Get(const std::filesystem::path& filePath)
|
||||
{
|
||||
String absolutePath = File::AbsolutePath(filePath);
|
||||
std::filesystem::path absolutePath = std::filesystem::canonical(filePath);
|
||||
auto it = Type::s_managerMap.find(absolutePath);
|
||||
if (it == Type::s_managerMap.end())
|
||||
{
|
||||
ObjectRef<Type> resource = Type::LoadFromFile(absolutePath, GetDefaultParameters());
|
||||
if (!resource)
|
||||
{
|
||||
NazaraError("Failed to load resource from file: " + absolutePath);
|
||||
NazaraError("Failed to load resource from file: " + absolutePath.generic_u8string());
|
||||
return ObjectRef<Type>();
|
||||
}
|
||||
|
||||
NazaraDebug("Loaded resource from file " + absolutePath);
|
||||
NazaraDebug("Loaded resource from file " + absolutePath.generic_u8string());
|
||||
|
||||
it = Type::s_managerMap.insert(std::make_pair(absolutePath, resource)).first;
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ namespace Nz
|
|||
const ObjectRef<Type>& ref = it->second;
|
||||
if (ref->GetReferenceCount() == 1) // Are we the only ones to own the resource ?
|
||||
{
|
||||
NazaraDebug("Purging resource from file " + ref->GetFilePath());
|
||||
NazaraDebug("Purging resource from file " + ref->GetFilePath().generic_u8string());
|
||||
Type::s_managerMap.erase(it++); // Then we erase it
|
||||
}
|
||||
else
|
||||
|
|
@ -89,9 +89,9 @@ namespace Nz
|
|||
* \param resource Object to associate with
|
||||
*/
|
||||
template<typename Type, typename Parameters>
|
||||
void ResourceManager<Type, Parameters>::Register(const String& filePath, ObjectRef<Type> resource)
|
||||
void ResourceManager<Type, Parameters>::Register(const std::filesystem::path& filePath, ObjectRef<Type> resource)
|
||||
{
|
||||
String absolutePath = File::AbsolutePath(filePath);
|
||||
std::filesystem::path absolutePath = std::filesystem::canonical(filePath);
|
||||
|
||||
Type::s_managerMap[absolutePath] = resource;
|
||||
}
|
||||
|
|
@ -113,9 +113,9 @@ namespace Nz
|
|||
* \param filePath Path for the resource
|
||||
*/
|
||||
template<typename Type, typename Parameters>
|
||||
void ResourceManager<Type, Parameters>::Unregister(const String& filePath)
|
||||
void ResourceManager<Type, Parameters>::Unregister(const std::filesystem::path& filePath)
|
||||
{
|
||||
String absolutePath = File::AbsolutePath(filePath);
|
||||
std::filesystem::path absolutePath = std::filesystem::canonical(filePath);
|
||||
|
||||
Type::s_managerMap.erase(absolutePath);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceParameters.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <filesystem>
|
||||
#include <list>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
|
|
@ -27,18 +28,18 @@ namespace Nz
|
|||
friend Type;
|
||||
|
||||
public:
|
||||
using ExtensionGetter = bool (*)(const String& extension);
|
||||
using FormatQuerier = bool (*)(const String& format);
|
||||
using FileSaver = bool (*)(const Type& resource, const String& filePath, const Parameters& parameters);
|
||||
using StreamSaver = bool (*)(const Type& resource, const String& format, Stream& stream, const Parameters& parameters);
|
||||
using ExtensionGetter = bool (*)(const std::string& extension);
|
||||
using FormatQuerier = bool (*)(const std::string& format);
|
||||
using FileSaver = bool (*)(const Type& resource, const std::filesystem::path& filePath, const Parameters& parameters);
|
||||
using StreamSaver = bool (*)(const Type& resource, const std::string& format, Stream& stream, const Parameters& parameters);
|
||||
|
||||
ResourceSaver() = delete;
|
||||
~ResourceSaver() = delete;
|
||||
|
||||
static bool IsFormatSupported(const String& extension);
|
||||
static bool IsFormatSupported(const std::string& extension);
|
||||
|
||||
static bool SaveToFile(const Type& resource, const String& filePath, const Parameters& parameters = Parameters());
|
||||
static bool SaveToStream(const Type& resource, Stream& stream, const String& format, const Parameters& parameters = Parameters());
|
||||
static bool SaveToFile(const Type& resource, const std::filesystem::path& filePath, const Parameters& parameters = Parameters());
|
||||
static bool SaveToStream(const Type& resource, Stream& stream, const std::string& format, const Parameters& parameters = Parameters());
|
||||
|
||||
static void RegisterSaver(FormatQuerier formatQuerier, StreamSaver streamSaver, FileSaver fileSaver = nullptr);
|
||||
static void UnregisterSaver(FormatQuerier formatQuerier, StreamSaver streamSaver, FileSaver fileSaver = nullptr);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include <Nazara/Core/File.hpp>
|
||||
#include <Nazara/Core/MemoryView.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <Nazara/Core/StringExt.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
|
@ -24,7 +25,7 @@ namespace Nz
|
|||
* \param extension Extension of the file
|
||||
*/
|
||||
template<typename Type, typename Parameters>
|
||||
bool ResourceSaver<Type, Parameters>::IsFormatSupported(const String& extension)
|
||||
bool ResourceSaver<Type, Parameters>::IsFormatSupported(const std::string& extension)
|
||||
{
|
||||
for (Saver& saver : Type::s_savers)
|
||||
{
|
||||
|
|
@ -51,19 +52,18 @@ namespace Nz
|
|||
* \see SaveToStream
|
||||
*/
|
||||
template<typename Type, typename Parameters>
|
||||
bool ResourceSaver<Type, Parameters>::SaveToFile(const Type& resource, const String& filePath, const Parameters& parameters)
|
||||
bool ResourceSaver<Type, Parameters>::SaveToFile(const Type& resource, const std::filesystem::path& filePath, const Parameters& parameters)
|
||||
{
|
||||
NazaraAssert(parameters.IsValid(), "Invalid parameters");
|
||||
|
||||
String path = File::NormalizePath(filePath);
|
||||
String ext = path.SubStringFrom('.', -1, true).ToLower();
|
||||
if (ext.IsEmpty())
|
||||
std::string ext = ToLower(filePath.extension().generic_u8string());
|
||||
if (ext.empty())
|
||||
{
|
||||
NazaraError("Failed to get file extension from \"" + filePath + '"');
|
||||
NazaraError("Failed to get file extension from \"" + filePath.generic_u8string() + '"');
|
||||
return false;
|
||||
}
|
||||
|
||||
File file(path); // Opened only is required
|
||||
File file(filePath.generic_u8string()); // Opened only is required
|
||||
|
||||
bool found = false;
|
||||
for (Saver& saver : Type::s_savers)
|
||||
|
|
@ -86,7 +86,7 @@ namespace Nz
|
|||
{
|
||||
if (!file.Open(OpenMode_WriteOnly | OpenMode_Truncate))
|
||||
{
|
||||
NazaraError("Failed to save to file: unable to open \"" + filePath + "\" in write mode");
|
||||
NazaraError("Failed to save to file: unable to open \"" + filePath.generic_u8string() + "\" in write mode");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ namespace Nz
|
|||
* \see SaveToFile
|
||||
*/
|
||||
template<typename Type, typename Parameters>
|
||||
bool ResourceSaver<Type, Parameters>::SaveToStream(const Type& resource, Stream& stream, const String& format, const Parameters& parameters)
|
||||
bool ResourceSaver<Type, Parameters>::SaveToStream(const Type& resource, Stream& stream, const std::string& format, const Parameters& parameters)
|
||||
{
|
||||
NazaraAssert(stream.IsWritable(), "Stream is not writable");
|
||||
NazaraAssert(parameters.IsValid(), "Invalid parameters");
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_SEMAPHORE_HPP
|
||||
#define NAZARA_SEMAPHORE_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class SemaphoreImpl;
|
||||
|
||||
class NAZARA_CORE_API Semaphore
|
||||
{
|
||||
public:
|
||||
Semaphore(unsigned int count);
|
||||
Semaphore(const Semaphore&) = delete;
|
||||
Semaphore(Semaphore&&) noexcept = default;
|
||||
~Semaphore();
|
||||
|
||||
unsigned int GetCount() const;
|
||||
|
||||
void Post();
|
||||
|
||||
void Wait();
|
||||
bool Wait(UInt32 timeout);
|
||||
|
||||
Semaphore& operator=(const Semaphore&) = delete;
|
||||
Semaphore& operator=(Semaphore&&) noexcept = default;
|
||||
|
||||
private:
|
||||
MovablePtr<SemaphoreImpl> m_impl;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_SEMAPHORE_HPP
|
||||
|
|
@ -43,10 +43,10 @@ namespace Nz
|
|||
void SetStride(int stride);
|
||||
|
||||
explicit operator bool() const;
|
||||
operator T*() const;
|
||||
explicit operator T*() const;
|
||||
T& operator*() const;
|
||||
T* operator->() const;
|
||||
T& operator[](int index) const;
|
||||
T& operator[](std::size_t index) const;
|
||||
|
||||
SparsePtr& operator=(const SparsePtr& ptr) = default;
|
||||
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ namespace Nz
|
|||
*/
|
||||
|
||||
template<typename T>
|
||||
T& SparsePtr<T>::operator[](int index) const
|
||||
T& SparsePtr<T>::operator[](std::size_t index) const
|
||||
{
|
||||
return *reinterpret_cast<T*>(m_ptr + index * m_stride);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,12 @@
|
|||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/Endianness.hpp>
|
||||
#include <Nazara/Core/Enums.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class ByteArray;
|
||||
class String; //< Do not include String.hpp in this file
|
||||
|
||||
class NAZARA_CORE_API Stream
|
||||
{
|
||||
|
|
@ -30,15 +31,15 @@ namespace Nz
|
|||
inline void Flush();
|
||||
|
||||
virtual UInt64 GetCursorPos() const = 0;
|
||||
virtual String GetDirectory() const;
|
||||
virtual String GetPath() const;
|
||||
virtual std::filesystem::path GetDirectory() const;
|
||||
virtual std::filesystem::path GetPath() const;
|
||||
inline OpenModeFlags GetOpenMode() const;
|
||||
inline StreamOptionFlags GetStreamOptions() const;
|
||||
|
||||
virtual UInt64 GetSize() const = 0;
|
||||
|
||||
inline std::size_t Read(void* buffer, std::size_t size);
|
||||
virtual String ReadLine(unsigned int lineSize = 0);
|
||||
virtual std::string ReadLine(unsigned int lineSize = 0);
|
||||
|
||||
inline bool IsReadable() const;
|
||||
inline bool IsSequential() const;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CORE_STRING_EXT_HPP
|
||||
#define NAZARA_CORE_STRING_EXT_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/Unicode.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
struct CaseIndependent {};
|
||||
struct UnicodeAware {};
|
||||
|
||||
// std::string is assumed to contains UTF-8
|
||||
NAZARA_CORE_API std::string FromUtf16String(const char16_t* u16str);
|
||||
NAZARA_CORE_API std::string FromUtf16String(const std::u16string_view& u16str);
|
||||
|
||||
NAZARA_CORE_API std::string FromUtf32String(const char32_t* u32str);
|
||||
NAZARA_CORE_API std::string FromUtf32String(const std::u32string_view& u32str);
|
||||
|
||||
NAZARA_CORE_API std::string FromWideString(const wchar_t* wstr);
|
||||
NAZARA_CORE_API std::string FromWideString(const std::wstring_view& str);
|
||||
|
||||
inline bool IsNumber(const char* str);
|
||||
inline bool IsNumber(const std::string_view& str);
|
||||
|
||||
template<typename... Args> bool StartsWith(const std::string_view& str, const char* s, Args&&... args);
|
||||
inline bool StartsWith(const std::string_view& str, const std::string_view& s);
|
||||
NAZARA_CORE_API bool StartsWith(const std::string_view& str, const std::string_view& s, CaseIndependent);
|
||||
NAZARA_CORE_API bool StartsWith(const std::string_view& str, const std::string_view& s, CaseIndependent, UnicodeAware);
|
||||
|
||||
inline std::string ToLower(const char* str);
|
||||
NAZARA_CORE_API std::string ToLower(const std::string_view& str);
|
||||
|
||||
inline std::string ToLower(const char* str, UnicodeAware);
|
||||
NAZARA_CORE_API std::string ToLower(const std::string_view& str, UnicodeAware);
|
||||
|
||||
inline std::string ToUpper(const char* str);
|
||||
NAZARA_CORE_API std::string ToUpper(const std::string_view& str);
|
||||
|
||||
inline std::string ToUpper(const char* str, UnicodeAware);
|
||||
NAZARA_CORE_API std::string ToUpper(const std::string_view& str, UnicodeAware);
|
||||
|
||||
inline std::u16string ToUtf16String(const char* str);
|
||||
NAZARA_CORE_API std::u16string ToUtf16String(const std::string_view& str);
|
||||
|
||||
inline std::u32string ToUtf32String(const char* str);
|
||||
NAZARA_CORE_API std::u32string ToUtf32String(const std::string_view& str);
|
||||
|
||||
inline std::wstring ToWideString(const char* str);
|
||||
NAZARA_CORE_API std::wstring ToWideString(const std::string_view& str);
|
||||
}
|
||||
|
||||
#include <Nazara/Core/StringExt.inl>
|
||||
|
||||
#endif // NAZARA_ALGORITHM_CORE_HPP
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/StringExt.hpp>
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
bool IsNumber(const char* str)
|
||||
{
|
||||
std::size_t size = std::strlen(str);
|
||||
return IsNumber(std::string_view(str, size));
|
||||
}
|
||||
|
||||
bool IsNumber(const std::string_view& str)
|
||||
{
|
||||
return !str.empty() && std::find_if(str.begin(), str.end(), [](unsigned char c) { return !std::isdigit(c); }) == str.end();
|
||||
}
|
||||
|
||||
template<typename... Args> bool StartsWith(const std::string_view& str, const char* s, Args&&... args)
|
||||
{
|
||||
std::size_t size = std::strlen(s);
|
||||
return StartsWith(str, std::string_view(s, size), std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
bool StartsWith(const std::string_view& str, const std::string_view& s)
|
||||
{
|
||||
//FIXME: Replace with proper C++20 value once it's available
|
||||
#if __cplusplus > 201703L
|
||||
// C++20
|
||||
return str.starts_with(s);
|
||||
#else
|
||||
return str.compare(0, s.size(), s.data()) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline std::string ToLower(const char* str)
|
||||
{
|
||||
std::size_t size = std::strlen(str);
|
||||
return ToLower(std::string_view(str, size));
|
||||
}
|
||||
|
||||
inline std::string ToLower(const char* str, UnicodeAware)
|
||||
{
|
||||
std::size_t size = std::strlen(str);
|
||||
return ToLower(std::string_view(str, size), UnicodeAware{});
|
||||
}
|
||||
|
||||
inline std::string ToUpper(const char* str)
|
||||
{
|
||||
std::size_t size = std::strlen(str);
|
||||
return ToUpper(std::string_view(str, size));
|
||||
}
|
||||
|
||||
inline std::string ToUpper(const char* str, UnicodeAware)
|
||||
{
|
||||
std::size_t size = std::strlen(str);
|
||||
return ToUpper(std::string_view(str, size), UnicodeAware{});
|
||||
}
|
||||
|
||||
inline std::u16string ToUtf16String(const char* str)
|
||||
{
|
||||
std::size_t size = std::strlen(str);
|
||||
return ToUtf16String(std::string_view(str, size));
|
||||
}
|
||||
|
||||
inline std::u32string ToUtf32String(const char* str)
|
||||
{
|
||||
std::size_t size = std::strlen(str);
|
||||
return ToUtf32String(std::string_view(str, size));
|
||||
}
|
||||
|
||||
inline std::wstring ToWideString(const char* str)
|
||||
{
|
||||
std::size_t size = std::strlen(str);
|
||||
return ToWideString(std::string_view(str, size));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_THREAD_HPP
|
||||
#define NAZARA_THREAD_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/Functor.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
#include <iosfwd>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class String;
|
||||
class ThreadImpl;
|
||||
|
||||
class NAZARA_CORE_API Thread
|
||||
{
|
||||
public:
|
||||
class Id;
|
||||
|
||||
Thread();
|
||||
template<typename F> Thread(F function);
|
||||
template<typename F, typename... Args> Thread(F function, Args&&... args);
|
||||
template<typename C> Thread(void (C::*function)(), C* object);
|
||||
Thread(const Thread&) = delete;
|
||||
Thread(Thread&& other) noexcept = default;
|
||||
~Thread();
|
||||
|
||||
void Detach();
|
||||
Id GetId() const;
|
||||
bool IsJoinable() const;
|
||||
void Join();
|
||||
void SetName(const String& name);
|
||||
|
||||
Thread& operator=(const Thread&) = delete;
|
||||
Thread& operator=(Thread&& thread) noexcept = default;
|
||||
|
||||
static unsigned int HardwareConcurrency();
|
||||
static void SetCurrentThreadName(const String& name);
|
||||
static void Sleep(UInt32 milliseconds);
|
||||
|
||||
private:
|
||||
void CreateImpl(Functor* functor);
|
||||
|
||||
MovablePtr<ThreadImpl> m_impl;
|
||||
};
|
||||
|
||||
class NAZARA_CORE_API Thread::Id
|
||||
{
|
||||
friend Thread;
|
||||
|
||||
public:
|
||||
NAZARA_CORE_API friend bool operator==(const Id& lhs, const Id& rhs);
|
||||
NAZARA_CORE_API friend bool operator!=(const Id& lhs, const Id& rhs);
|
||||
NAZARA_CORE_API friend bool operator<(const Id& lhs, const Id& rhs);
|
||||
NAZARA_CORE_API friend bool operator<=(const Id& lhs, const Id& rhs);
|
||||
NAZARA_CORE_API friend bool operator>(const Id& lhs, const Id& rhs);
|
||||
NAZARA_CORE_API friend bool operator>=(const Id& lhs, const Id& rhs);
|
||||
|
||||
NAZARA_CORE_API friend std::ostream& operator<<(std::ostream& o, const Id& id);
|
||||
|
||||
private:
|
||||
explicit Id(ThreadImpl* thread);
|
||||
|
||||
ThreadImpl* m_id = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Core/Thread.inl>
|
||||
|
||||
#endif // NAZARA_THREAD_HPP
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <utility>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
/*!
|
||||
* \ingroup core
|
||||
* \class Nz::Thread
|
||||
* \brief Core class that represents a thread
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief Constructs a Thread object with a function
|
||||
*
|
||||
* \param function Task the thread will execute in parallel
|
||||
*/
|
||||
|
||||
template<typename F>
|
||||
Thread::Thread(F function)
|
||||
{
|
||||
CreateImpl(new FunctorWithoutArgs<F>(function));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructs a Thread object with a function and its parameters
|
||||
*
|
||||
* \param function Task the thread will execute in parallel
|
||||
* \param args Arguments of the function
|
||||
*/
|
||||
|
||||
template<typename F, typename... Args>
|
||||
Thread::Thread(F function, Args&&... args)
|
||||
{
|
||||
CreateImpl(new FunctorWithArgs<F, Args...>(function, std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructs a Thread object with a member function and its object
|
||||
*
|
||||
* \param function Task the thread will execute in parallel
|
||||
* \param object Object on which the method will be called
|
||||
*/
|
||||
|
||||
template<typename C>
|
||||
Thread::Thread(void (C::*function)(), C* object)
|
||||
{
|
||||
CreateImpl(new MemberWithoutArgs<C>(function, object));
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// No header guard
|
||||
|
||||
#include <Nazara/Core/LockGuard.hpp>
|
||||
#include <Nazara/Core/Mutex.hpp>
|
||||
|
||||
// These macroes can change for any file which uses it in the same unit of compilation
|
||||
#undef NazaraLock
|
||||
#undef NazaraMutex
|
||||
#undef NazaraMutexAttrib
|
||||
#undef NazaraMutexLock
|
||||
#undef NazaraMutexUnlock
|
||||
#undef NazaraNamedLock
|
||||
|
||||
#define NazaraLock(mutex) Nz::LockGuard lock_mutex(mutex);
|
||||
#define NazaraMutex(name) Nz::Mutex name;
|
||||
#define NazaraMutexAttrib(name, attribute) attribute Mutex name;
|
||||
#define NazaraMutexLock(mutex) mutex.Lock();
|
||||
#define NazaraMutexUnlock(mutex) mutex.Unlock();
|
||||
#define NazaraNamedLock(mutex, name) Nz::LockGuard lock_##name(mutex);
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// No header guard
|
||||
|
||||
// These macroes can change for any file which uses it in the same unit of compilation
|
||||
#undef NazaraLock
|
||||
#undef NazaraMutex
|
||||
#undef NazaraMutexAttrib
|
||||
#undef NazaraMutexLock
|
||||
#undef NazaraMutexUnlock
|
||||
#undef NazaraNamedLock
|
||||
|
||||
#define NazaraLock(mutex)
|
||||
#define NazaraMutex(name)
|
||||
#define NazaraMutexAttrib(name, attribute)
|
||||
#define NazaraMutexLock(mutex)
|
||||
#define NazaraMutexUnlock(mutex)
|
||||
#define NazaraNamedLock(mutex, name)
|
||||
|
||||
|
|
@ -17,7 +17,6 @@
|
|||
#include <Nazara/Core/ResourceManager.hpp>
|
||||
#include <Nazara/Core/ResourceParameters.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Graphics/Enums.hpp>
|
||||
#include <Nazara/Graphics/MaterialPipeline.hpp>
|
||||
|
|
@ -35,7 +34,7 @@ namespace Nz
|
|||
bool loadHeightMap = true;
|
||||
bool loadNormalMap = true;
|
||||
bool loadSpecularMap = true;
|
||||
String shaderName = "Basic";
|
||||
std::string shaderName = "Basic";
|
||||
|
||||
bool IsValid() const;
|
||||
};
|
||||
|
|
@ -59,7 +58,7 @@ namespace Nz
|
|||
inline Material();
|
||||
inline Material(const MaterialPipeline* pipeline);
|
||||
inline Material(const MaterialPipelineInfo& pipelineInfo);
|
||||
inline Material(const String& pipelineName);
|
||||
inline Material(const std::string& pipelineName);
|
||||
inline Material(const Material& material);
|
||||
inline ~Material();
|
||||
|
||||
|
|
@ -69,7 +68,7 @@ namespace Nz
|
|||
|
||||
inline void Configure(const MaterialPipeline* pipeline);
|
||||
inline void Configure(const MaterialPipelineInfo& pipelineInfo);
|
||||
inline bool Configure(const String& pipelineName);
|
||||
inline bool Configure(const std::string& pipelineName);
|
||||
|
||||
inline void EnableAlphaTest(bool alphaTest);
|
||||
inline void EnableBlending(bool blending);
|
||||
|
|
@ -141,33 +140,33 @@ namespace Nz
|
|||
|
||||
void SaveToParameters(ParameterList* matData);
|
||||
|
||||
inline bool SetAlphaMap(const String& textureName);
|
||||
inline bool SetAlphaMap(const std::string& textureName);
|
||||
inline void SetAlphaMap(TextureRef alphaMap);
|
||||
inline void SetAlphaThreshold(float alphaThreshold);
|
||||
inline void SetAmbientColor(const Color& ambient);
|
||||
inline void SetDepthFunc(RendererComparison depthFunc);
|
||||
inline void SetDepthMaterial(MaterialRef depthMaterial);
|
||||
inline void SetDiffuseColor(const Color& diffuse);
|
||||
inline bool SetDiffuseMap(const String& textureName);
|
||||
inline bool SetDiffuseMap(const std::string& textureName);
|
||||
inline void SetDiffuseMap(TextureRef diffuseMap);
|
||||
inline void SetDiffuseSampler(const TextureSampler& sampler);
|
||||
inline void SetDstBlend(BlendFunc func);
|
||||
inline bool SetEmissiveMap(const String& textureName);
|
||||
inline bool SetEmissiveMap(const std::string& textureName);
|
||||
inline void SetEmissiveMap(TextureRef textureName);
|
||||
inline void SetFaceCulling(FaceSide faceSide);
|
||||
inline void SetFaceFilling(FaceFilling filling);
|
||||
inline bool SetHeightMap(const String& textureName);
|
||||
inline bool SetHeightMap(const std::string& textureName);
|
||||
inline void SetHeightMap(TextureRef textureName);
|
||||
inline void SetLineWidth(float lineWidth);
|
||||
inline bool SetNormalMap(const String& textureName);
|
||||
inline bool SetNormalMap(const std::string& textureName);
|
||||
inline void SetNormalMap(TextureRef textureName);
|
||||
inline void SetPointSize(float pointSize);
|
||||
inline void SetReflectionMode(ReflectionMode reflectionMode);
|
||||
inline void SetShader(UberShaderConstRef uberShader);
|
||||
inline bool SetShader(const String& uberShaderName);
|
||||
inline bool SetShader(const std::string& uberShaderName);
|
||||
inline void SetShininess(float shininess);
|
||||
inline void SetSpecularColor(const Color& specular);
|
||||
inline bool SetSpecularMap(const String& textureName);
|
||||
inline bool SetSpecularMap(const std::string& textureName);
|
||||
inline void SetSpecularMap(TextureRef specularMap);
|
||||
inline void SetSpecularSampler(const TextureSampler& sampler);
|
||||
inline void SetSrcBlend(BlendFunc func);
|
||||
|
|
@ -177,7 +176,7 @@ namespace Nz
|
|||
inline static MaterialRef GetDefault();
|
||||
inline static int GetTextureUnit(TextureMap textureMap);
|
||||
|
||||
static inline MaterialRef LoadFromFile(const String& filePath, const MaterialParams& params = MaterialParams());
|
||||
static inline MaterialRef LoadFromFile(const std::filesystem::path& filePath, const MaterialParams& params = MaterialParams());
|
||||
static inline MaterialRef LoadFromMemory(const void* data, std::size_t size, const MaterialParams& params = MaterialParams());
|
||||
static inline MaterialRef LoadFromStream(Stream& stream, const MaterialParams& params = MaterialParams());
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ namespace Nz
|
|||
*
|
||||
* \see Configure
|
||||
*/
|
||||
inline Material::Material(const String& pipelineName)
|
||||
inline Material::Material(const std::string& pipelineName)
|
||||
{
|
||||
ErrorFlags errFlags(ErrorFlag_ThrowException, true);
|
||||
|
||||
|
|
@ -139,7 +139,7 @@ namespace Nz
|
|||
*
|
||||
* \see Configure
|
||||
*/
|
||||
inline bool Material::Configure(const String& pipelineName)
|
||||
inline bool Material::Configure(const std::string& pipelineName)
|
||||
{
|
||||
MaterialPipelineRef pipeline = MaterialPipelineLibrary::Query(pipelineName);
|
||||
if (!pipeline)
|
||||
|
|
@ -909,7 +909,7 @@ namespace Nz
|
|||
*
|
||||
* \param textureName Named texture
|
||||
*/
|
||||
inline bool Material::SetAlphaMap(const String& textureName)
|
||||
inline bool Material::SetAlphaMap(const std::string& textureName)
|
||||
{
|
||||
TextureRef texture = TextureLibrary::Query(textureName);
|
||||
if (!texture)
|
||||
|
|
@ -1005,7 +1005,7 @@ namespace Nz
|
|||
*
|
||||
* \remark Invalidates the pipeline
|
||||
*/
|
||||
inline bool Material::SetDiffuseMap(const String& textureName)
|
||||
inline bool Material::SetDiffuseMap(const std::string& textureName)
|
||||
{
|
||||
TextureRef texture = TextureLibrary::Query(textureName);
|
||||
if (!texture)
|
||||
|
|
@ -1071,7 +1071,7 @@ namespace Nz
|
|||
*
|
||||
* \see GetEmissiveMap
|
||||
*/
|
||||
inline bool Material::SetEmissiveMap(const String& textureName)
|
||||
inline bool Material::SetEmissiveMap(const std::string& textureName)
|
||||
{
|
||||
TextureRef texture = TextureLibrary::Query(textureName);
|
||||
if (!texture)
|
||||
|
|
@ -1140,7 +1140,7 @@ namespace Nz
|
|||
*
|
||||
* \see GetHeightMap
|
||||
*/
|
||||
inline bool Material::SetHeightMap(const String& textureName)
|
||||
inline bool Material::SetHeightMap(const std::string& textureName)
|
||||
{
|
||||
TextureRef texture = TextureLibrary::Query(textureName);
|
||||
if (!texture)
|
||||
|
|
@ -1202,7 +1202,7 @@ namespace Nz
|
|||
*
|
||||
* \see GetNormalMap
|
||||
*/
|
||||
inline bool Material::SetNormalMap(const String& textureName)
|
||||
inline bool Material::SetNormalMap(const std::string& textureName)
|
||||
{
|
||||
TextureRef texture = TextureLibrary::Query(textureName);
|
||||
if (!texture)
|
||||
|
|
@ -1305,7 +1305,7 @@ namespace Nz
|
|||
*
|
||||
* \param uberShaderName Named shader
|
||||
*/
|
||||
inline bool Material::SetShader(const String& uberShaderName)
|
||||
inline bool Material::SetShader(const std::string& uberShaderName)
|
||||
{
|
||||
UberShaderConstRef uberShader = UberShaderLibrary::Get(uberShaderName);
|
||||
if (!uberShader)
|
||||
|
|
@ -1343,7 +1343,7 @@ namespace Nz
|
|||
*
|
||||
* \remark Invalidates the pipeline
|
||||
*/
|
||||
inline bool Material::SetSpecularMap(const String& textureName)
|
||||
inline bool Material::SetSpecularMap(const std::string& textureName)
|
||||
{
|
||||
TextureRef texture = TextureLibrary::Query(textureName);
|
||||
if (!texture)
|
||||
|
|
@ -1444,7 +1444,7 @@ namespace Nz
|
|||
* \param filePath Path to the file
|
||||
* \param params Parameters for the material
|
||||
*/
|
||||
inline MaterialRef Material::LoadFromFile(const String& filePath, const MaterialParams& params)
|
||||
inline MaterialRef Material::LoadFromFile(const std::filesystem::path& filePath, const MaterialParams& params)
|
||||
{
|
||||
return MaterialLoader::LoadFromFile(filePath, params);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,22 +59,22 @@ namespace Nz
|
|||
std::unique_ptr<InstancedRenderable> Clone() const override;
|
||||
|
||||
using InstancedRenderable::GetMaterial;
|
||||
const MaterialRef& GetMaterial(const String& subMeshName) const;
|
||||
const MaterialRef& GetMaterial(std::size_t skinIndex, const String& subMeshName) const;
|
||||
const MaterialRef& GetMaterial(const std::string& subMeshName) const;
|
||||
const MaterialRef& GetMaterial(std::size_t skinIndex, const std::string& subMeshName) const;
|
||||
Mesh* GetMesh() const;
|
||||
|
||||
virtual bool IsAnimated() const;
|
||||
|
||||
using InstancedRenderable::SetMaterial;
|
||||
bool SetMaterial(const String& subMeshName, MaterialRef material);
|
||||
bool SetMaterial(std::size_t skinIndex, const String& subMeshName, MaterialRef material);
|
||||
bool SetMaterial(const std::string& subMeshName, MaterialRef material);
|
||||
bool SetMaterial(std::size_t skinIndex, const std::string& subMeshName, MaterialRef material);
|
||||
|
||||
virtual void SetMesh(Mesh* mesh);
|
||||
|
||||
Model& operator=(const Model& node) = default;
|
||||
Model& operator=(Model&& node) = delete;
|
||||
|
||||
static ModelRef LoadFromFile(const String& filePath, const ModelParameters& params = ModelParameters());
|
||||
static ModelRef LoadFromFile(const std::filesystem::path& filePath, const ModelParameters& params = ModelParameters());
|
||||
static ModelRef LoadFromMemory(const void* data, std::size_t size, const ModelParameters& params = ModelParameters());
|
||||
static ModelRef LoadFromStream(Stream& stream, const ModelParameters& params = ModelParameters());
|
||||
|
||||
|
|
|
|||
|
|
@ -47,15 +47,15 @@ namespace Nz
|
|||
inline void SetCornerColor(RectCorner corner, const Color& color);
|
||||
inline void SetDefaultMaterial();
|
||||
inline void SetMaterial(MaterialRef material, bool resizeSprite = true);
|
||||
bool SetMaterial(String materialName, bool resizeSprite = true);
|
||||
bool SetMaterial(std::string materialName, bool resizeSprite = true);
|
||||
inline void SetMaterial(std::size_t skinIndex, MaterialRef material, bool resizeSprite = true);
|
||||
bool SetMaterial(std::size_t skinIndex, String materialName, bool resizeSprite = true);
|
||||
bool SetMaterial(std::size_t skinIndex, std::string materialName, bool resizeSprite = true);
|
||||
inline void SetOrigin(const Vector3f& origin);
|
||||
inline void SetSize(const Vector2f& size);
|
||||
inline void SetSize(float sizeX, float sizeY);
|
||||
bool SetTexture(String textureName, bool resizeSprite = true);
|
||||
bool SetTexture(std::string textureName, bool resizeSprite = true);
|
||||
inline void SetTexture(TextureRef texture, bool resizeSprite = true);
|
||||
bool SetTexture(std::size_t skinIndex, String textureName, bool resizeSprite = true);
|
||||
bool SetTexture(std::size_t skinIndex, std::string textureName, bool resizeSprite = true);
|
||||
inline void SetTexture(std::size_t skinIndex, TextureRef texture, bool resizeSprite = true);
|
||||
inline void SetTextureCoords(const Rectf& coords);
|
||||
inline void SetTextureRect(const Rectui& rect);
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
// This file was automatically generated
|
||||
|
||||
/*
|
||||
Nazara Engine - Lua scripting module
|
||||
|
||||
Copyright (C) 2015 Jérôme Leclercq (lynix680@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_GLOBAL_LUA_HPP
|
||||
#define NAZARA_GLOBAL_LUA_HPP
|
||||
|
||||
#include <Nazara/Lua/Config.hpp>
|
||||
#include <Nazara/Lua/Enums.hpp>
|
||||
#include <Nazara/Lua/Lua.hpp>
|
||||
#include <Nazara/Lua/LuaClass.hpp>
|
||||
#include <Nazara/Lua/LuaCoroutine.hpp>
|
||||
#include <Nazara/Lua/LuaInstance.hpp>
|
||||
#include <Nazara/Lua/LuaState.hpp>
|
||||
|
||||
#endif // NAZARA_GLOBAL_LUA_HPP
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
Nazara Engine - Lua scripting module
|
||||
|
||||
Copyright (C) 2015 Jérôme Leclercq (lynix680@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CONFIG_LUA_HPP
|
||||
#define NAZARA_CONFIG_LUA_HPP
|
||||
|
||||
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
|
||||
|
||||
// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes)
|
||||
#define NAZARA_LUA_MANAGE_MEMORY 0
|
||||
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
#define NAZARA_LUA_SAFE 1
|
||||
|
||||
/// Vérification des valeurs et types de certaines constantes
|
||||
#include <Nazara/Lua/ConfigCheck.hpp>
|
||||
|
||||
#if defined(NAZARA_STATIC)
|
||||
#define NAZARA_LUA_API
|
||||
#else
|
||||
#ifdef NAZARA_LUA_BUILD
|
||||
#define NAZARA_LUA_API NAZARA_EXPORT
|
||||
#else
|
||||
#define NAZARA_LUA_API NAZARA_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // NAZARA_CONFIG_LUA_HPP
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Lua module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CONFIG_CHECK_LUA_HPP
|
||||
#define NAZARA_CONFIG_CHECK_LUA_HPP
|
||||
|
||||
/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp
|
||||
|
||||
// On force la valeur de MANAGE_MEMORY en mode debug
|
||||
#if defined(NAZARA_DEBUG) && !NAZARA_LUA_MANAGE_MEMORY
|
||||
#undef NAZARA_LUA_MANAGE_MEMORY
|
||||
#define NAZARA_LUA_MANAGE_MEMORY 0
|
||||
#endif
|
||||
|
||||
#endif // NAZARA_CONFIG_CHECK_LUA_HPP
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Lua scripting module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Lua/Config.hpp>
|
||||
#if NAZARA_LUA_MANAGE_MEMORY
|
||||
#include <Nazara/Core/Debug/NewRedefinition.hpp>
|
||||
#endif
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Lua scripting module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp
|
||||
#if NAZARA_LUA_MANAGE_MEMORY
|
||||
#undef delete
|
||||
#undef new
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue