Merge branch 'master' into vulkan

Former-commit-id: 8e5cf8f5c93203818a1939df269593f8556019f0
This commit is contained in:
Lynix 2016-04-23 22:57:14 +02:00
commit 4a948dfaa9
15 changed files with 252 additions and 127 deletions

View File

@ -64,6 +64,33 @@ namespace Nz
return ret; return ret;
} }
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, FontRef* fontRef, TypeTag<FontRef>)
{
*fontRef = *(*static_cast<FontRef**>(instance.CheckUserdata(index, "Font")));
return 1;
}
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, FontParams* params, TypeTag<FontParams>)
{
instance.CheckType(index, Nz::LuaType_Table);
return 1;
}
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, MeshParams* params, TypeTag<MeshParams>)
{
instance.CheckType(index, Nz::LuaType_Table);
params->animated = instance.CheckField<bool>("Animated", params->animated);
params->center = instance.CheckField<bool>("Center", params->center);
params->flipUVs = instance.CheckField<bool>("FlipUVs", params->flipUVs);
params->optimizeIndexBuffers = instance.CheckField<bool>("OptimizeIndexBuffers", params->optimizeIndexBuffers);
params->scale = instance.CheckField<Vector3f>("Scale", params->scale);
return 1;
}
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Quaterniond* quat, TypeTag<Quaterniond>) inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Quaterniond* quat, TypeTag<Quaterniond>)
{ {
switch (instance.GetType(index)) switch (instance.GetType(index))
@ -209,19 +236,6 @@ namespace Nz
return 1; return 1;
} }
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, MeshParams* params, TypeTag<MeshParams>)
{
instance.CheckType(index, Nz::LuaType_Table);
params->animated = instance.CheckField<bool>("Animated", params->animated);
params->center = instance.CheckField<bool>("Center", params->center);
params->flipUVs = instance.CheckField<bool>("FlipUVs", params->flipUVs);
params->optimizeIndexBuffers = instance.CheckField<bool>("OptimizeIndexBuffers", params->optimizeIndexBuffers);
params->scale = instance.CheckField<Vector3f>("Scale", params->scale);
return 1;
}
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, ModelParameters* params, TypeTag<ModelParameters>) inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, ModelParameters* params, TypeTag<ModelParameters>)
{ {
instance.CheckType(index, Nz::LuaType_Table); instance.CheckType(index, Nz::LuaType_Table);
@ -267,6 +281,23 @@ namespace Nz
return 1; return 1;
} }
inline int LuaImplReplyVal(const LuaInstance& instance, FontRef val, TypeTag<FontRef>)
{
instance.PushInstance<FontRef>("Font", val);
return 1;
}
inline int LuaImplReplyVal(const LuaInstance& instance, Font::SizeInfo val, TypeTag<Font::SizeInfo>)
{
instance.PushTable();
instance.PushField("LineHeight", val.lineHeight);
instance.PushField("SpaceAdvance", val.spaceAdvance);
instance.PushField("UnderlinePosition", val.underlinePosition);
instance.PushField("UnderlineThickness", val.underlineThickness);
return 1;
}
inline int LuaImplReplyVal(const LuaInstance& instance, Quaterniond val, TypeTag<Quaterniond>) inline int LuaImplReplyVal(const LuaInstance& instance, Quaterniond val, TypeTag<Quaterniond>)
{ {
instance.PushInstance<Quaterniond>("Quaternion", val); instance.PushInstance<Quaterniond>("Quaternion", val);

View File

@ -78,6 +78,7 @@ namespace Ndk
// Utility // Utility
Nz::LuaClass<Nz::AbstractImage*> abstractImage; Nz::LuaClass<Nz::AbstractImage*> abstractImage;
Nz::LuaClass<Nz::FontRef> fontClass;
Nz::LuaClass<Nz::Node> nodeClass; Nz::LuaClass<Nz::Node> nodeClass;
// SDK // SDK

View File

@ -186,6 +186,12 @@ namespace Ndk
void Console::SetTextFont(Nz::FontRef font) void Console::SetTextFont(Nz::FontRef font)
{ {
NazaraAssert(font && font->IsValid(), "Invalid font");
m_defaultFont = std::move(font);
m_historyDrawer.SetFont(m_defaultFont);
m_inputDrawer.SetFont(m_defaultFont);
Layout(); Layout();
} }

View File

@ -23,6 +23,7 @@ namespace Ndk
// Utility // Utility
abstractImage("AbstractImage"), abstractImage("AbstractImage"),
fontClass("Font"),
nodeClass("Node"), nodeClass("Node"),
// SDK // SDK

View File

@ -141,7 +141,11 @@ namespace Ndk
return new Nz::File(lua.Check<Nz::String>(&argIndex)); return new Nz::File(lua.Check<Nz::String>(&argIndex));
case 2: case 2:
return new Nz::File(lua.Check<Nz::String>(&argIndex), lua.Check<Nz::UInt32>(&argIndex)); {
Nz::String filePath = lua.Check<Nz::String>(&argIndex);
Nz::UInt32 openMode = lua.Check<Nz::UInt32>(&argIndex);
return new Nz::File(filePath, openMode);
}
} }
return nullptr; return nullptr;
@ -189,7 +193,11 @@ namespace Ndk
return lua.Push(file.Open(lua.Check<Nz::UInt32>(&argIndex, Nz::OpenMode_NotOpen))); return lua.Push(file.Open(lua.Check<Nz::UInt32>(&argIndex, Nz::OpenMode_NotOpen)));
case 2: case 2:
return lua.Push(file.Open(lua.Check<Nz::String>(&argIndex), lua.Check<Nz::UInt32>(&argIndex, Nz::OpenMode_NotOpen))); {
Nz::String filePath = lua.Check<Nz::String>(&argIndex);
Nz::UInt32 openMode = lua.Check<Nz::UInt32>(&argIndex, Nz::OpenMode_NotOpen);
return lua.Push(file.Open(filePath, openMode));
}
} }
lua.Error("No matching overload for method Open"); lua.Error("No matching overload for method Open");
@ -207,7 +215,11 @@ namespace Ndk
return lua.Push(file.SetCursorPos(lua.Check<Nz::UInt64>(&argIndex))); return lua.Push(file.SetCursorPos(lua.Check<Nz::UInt64>(&argIndex)));
case 2: case 2:
return lua.Push(file.SetCursorPos(lua.Check<Nz::CursorPosition>(&argIndex), lua.Check<Nz::Int64>(&argIndex))); {
Nz::CursorPosition curPos = lua.Check<Nz::CursorPosition>(&argIndex);
Nz::Int64 offset = lua.Check<Nz::Int64>(&argIndex);
return lua.Push(file.SetCursorPos(curPos, offset));
}
} }
lua.Error("No matching overload for method SetCursorPos"); lua.Error("No matching overload for method SetCursorPos");
@ -240,9 +252,9 @@ namespace Ndk
static_assert(Nz::CursorPosition_Max + 1 == 3, "Nz::CursorPosition has been updated but change was not reflected to Lua binding"); static_assert(Nz::CursorPosition_Max + 1 == 3, "Nz::CursorPosition has been updated but change was not reflected to Lua binding");
instance.PushTable(0, 3); instance.PushTable(0, 3);
{ {
instance.SetField("AtBegin", Nz::CursorPosition_AtBegin); instance.PushField("AtBegin", Nz::CursorPosition_AtBegin);
instance.SetField("AtCurrent", Nz::CursorPosition_AtCurrent); instance.PushField("AtCurrent", Nz::CursorPosition_AtCurrent);
instance.SetField("AtEnd", Nz::CursorPosition_AtEnd); instance.PushField("AtEnd", Nz::CursorPosition_AtEnd);
} }
instance.SetGlobal("CursorPosition"); instance.SetGlobal("CursorPosition");
@ -250,15 +262,15 @@ namespace Ndk
static_assert(Nz::HashType_Max + 1 == 9, "Nz::HashType has been updated but change was not reflected to Lua binding"); static_assert(Nz::HashType_Max + 1 == 9, "Nz::HashType has been updated but change was not reflected to Lua binding");
instance.PushTable(0, 9); instance.PushTable(0, 9);
{ {
instance.SetField("CRC32", Nz::HashType_CRC32); instance.PushField("CRC32", Nz::HashType_CRC32);
instance.SetField("Fletcher16", Nz::HashType_Fletcher16); instance.PushField("Fletcher16", Nz::HashType_Fletcher16);
instance.SetField("MD5", Nz::HashType_MD5); instance.PushField("MD5", Nz::HashType_MD5);
instance.SetField("SHA1", Nz::HashType_SHA1); instance.PushField("SHA1", Nz::HashType_SHA1);
instance.SetField("SHA224", Nz::HashType_SHA224); instance.PushField("SHA224", Nz::HashType_SHA224);
instance.SetField("SHA256", Nz::HashType_SHA256); instance.PushField("SHA256", Nz::HashType_SHA256);
instance.SetField("SHA384", Nz::HashType_SHA384); instance.PushField("SHA384", Nz::HashType_SHA384);
instance.SetField("SHA512", Nz::HashType_SHA512); instance.PushField("SHA512", Nz::HashType_SHA512);
instance.SetField("Whirlpool", Nz::HashType_Whirlpool); instance.PushField("Whirlpool", Nz::HashType_Whirlpool);
} }
instance.SetGlobal("HashType"); instance.SetGlobal("HashType");
@ -266,14 +278,14 @@ namespace Ndk
static_assert(Nz::OpenMode_Max + 1 == 2 * (64), "Nz::OpenModeFlags has been updated but change was not reflected to Lua binding"); static_assert(Nz::OpenMode_Max + 1 == 2 * (64), "Nz::OpenModeFlags has been updated but change was not reflected to Lua binding");
instance.PushTable(0, 8); instance.PushTable(0, 8);
{ {
instance.SetField("Append", Nz::OpenMode_Append); instance.PushField("Append", Nz::OpenMode_Append);
instance.SetField("NotOpen", Nz::OpenMode_NotOpen); instance.PushField("NotOpen", Nz::OpenMode_NotOpen);
instance.SetField("Lock", Nz::OpenMode_Lock); instance.PushField("Lock", Nz::OpenMode_Lock);
instance.SetField("ReadOnly", Nz::OpenMode_ReadOnly); instance.PushField("ReadOnly", Nz::OpenMode_ReadOnly);
instance.SetField("ReadWrite", Nz::OpenMode_ReadWrite); instance.PushField("ReadWrite", Nz::OpenMode_ReadWrite);
instance.SetField("Text", Nz::OpenMode_Text); instance.PushField("Text", Nz::OpenMode_Text);
instance.SetField("Truncate", Nz::OpenMode_Truncate); instance.PushField("Truncate", Nz::OpenMode_Truncate);
instance.SetField("WriteOnly", Nz::OpenMode_WriteOnly); instance.PushField("WriteOnly", Nz::OpenMode_WriteOnly);
} }
instance.SetGlobal("OpenMode"); instance.SetGlobal("OpenMode");
} }

View File

@ -90,10 +90,10 @@ namespace Ndk
{ {
instance.PushInteger(index++); instance.PushInteger(index++);
instance.PushTable(0, 4); instance.PushTable(0, 4);
instance.SetField("Address", std::move(info.address)); instance.PushField("Address", std::move(info.address));
instance.SetField("CanonicalName", std::move(info.canonicalName)); instance.PushField("CanonicalName", std::move(info.canonicalName));
instance.SetField("Protocol", std::move(info.protocol)); instance.PushField("Protocol", std::move(info.protocol));
instance.SetField("SocketType", std::move(info.socketType)); instance.PushField("SocketType", std::move(info.socketType));
instance.SetTable(); instance.SetTable();
} }
@ -120,10 +120,10 @@ namespace Ndk
static_assert(Nz::NetProtocol_Max + 1 == 4, "Nz::NetProtocol has been updated but change was not reflected to Lua binding"); static_assert(Nz::NetProtocol_Max + 1 == 4, "Nz::NetProtocol has been updated but change was not reflected to Lua binding");
instance.PushTable(0, 4); instance.PushTable(0, 4);
{ {
instance.SetField("Any", Nz::NetProtocol_Any); instance.PushField("Any", Nz::NetProtocol_Any);
instance.SetField("IPv4", Nz::NetProtocol_IPv4); instance.PushField("IPv4", Nz::NetProtocol_IPv4);
instance.SetField("IPv6", Nz::NetProtocol_IPv6); instance.PushField("IPv6", Nz::NetProtocol_IPv6);
instance.SetField("Unknown", Nz::NetProtocol_Unknown); instance.PushField("Unknown", Nz::NetProtocol_Unknown);
} }
instance.SetGlobal("NetProtocol"); instance.SetGlobal("NetProtocol");
@ -131,12 +131,12 @@ namespace Ndk
static_assert(Nz::PacketPriority_Max + 1 == 4, "Nz::PacketPriority has been updated but change was not reflected to Lua binding"); static_assert(Nz::PacketPriority_Max + 1 == 4, "Nz::PacketPriority has been updated but change was not reflected to Lua binding");
instance.PushTable(0, 6); instance.PushTable(0, 6);
{ {
instance.SetField("High", Nz::PacketPriority_High); instance.PushField("High", Nz::PacketPriority_High);
instance.SetField("Highest", Nz::PacketPriority_Highest); instance.PushField("Highest", Nz::PacketPriority_Highest);
instance.SetField("Immediate", Nz::PacketPriority_Immediate); instance.PushField("Immediate", Nz::PacketPriority_Immediate);
instance.SetField("Medium", Nz::PacketPriority_Medium); instance.PushField("Medium", Nz::PacketPriority_Medium);
instance.SetField("Low", Nz::PacketPriority_Low); instance.PushField("Low", Nz::PacketPriority_Low);
instance.SetField("Lowest", Nz::PacketPriority_Lowest); instance.PushField("Lowest", Nz::PacketPriority_Lowest);
} }
instance.SetGlobal("PacketPriority"); instance.SetGlobal("PacketPriority");
@ -144,9 +144,9 @@ namespace Ndk
static_assert(Nz::PacketReliability_Max + 1 == 3, "Nz::PacketReliability has been updated but change was not reflected to Lua binding"); static_assert(Nz::PacketReliability_Max + 1 == 3, "Nz::PacketReliability has been updated but change was not reflected to Lua binding");
instance.PushTable(0, 3); instance.PushTable(0, 3);
{ {
instance.SetField("Reliable", Nz::PacketReliability_Reliable); instance.PushField("Reliable", Nz::PacketReliability_Reliable);
instance.SetField("ReliableOrdered", Nz::PacketReliability_ReliableOrdered); instance.PushField("ReliableOrdered", Nz::PacketReliability_ReliableOrdered);
instance.SetField("Unreliable", Nz::PacketReliability_Unreliable); instance.PushField("Unreliable", Nz::PacketReliability_Unreliable);
} }
instance.SetGlobal("PacketReliability"); instance.SetGlobal("PacketReliability");
@ -154,15 +154,15 @@ namespace Ndk
static_assert(Nz::ResolveError_Max + 1 == 9, "Nz::ResolveError has been updated but change was not reflected to Lua binding"); static_assert(Nz::ResolveError_Max + 1 == 9, "Nz::ResolveError has been updated but change was not reflected to Lua binding");
instance.PushTable(0, 9); instance.PushTable(0, 9);
{ {
instance.SetField("Internal", Nz::ResolveError_Internal); instance.PushField("Internal", Nz::ResolveError_Internal);
instance.SetField("ResourceError", Nz::ResolveError_ResourceError); instance.PushField("ResourceError", Nz::ResolveError_ResourceError);
instance.SetField("NoError", Nz::ResolveError_NoError); instance.PushField("NoError", Nz::ResolveError_NoError);
instance.SetField("NonRecoverable", Nz::ResolveError_NonRecoverable); instance.PushField("NonRecoverable", Nz::ResolveError_NonRecoverable);
instance.SetField("NotFound", Nz::ResolveError_NotFound); instance.PushField("NotFound", Nz::ResolveError_NotFound);
instance.SetField("NotInitialized", Nz::ResolveError_NotInitialized); instance.PushField("NotInitialized", Nz::ResolveError_NotInitialized);
instance.SetField("ProtocolNotSupported", Nz::ResolveError_ProtocolNotSupported); instance.PushField("ProtocolNotSupported", Nz::ResolveError_ProtocolNotSupported);
instance.SetField("TemporaryFailure", Nz::ResolveError_TemporaryFailure); instance.PushField("TemporaryFailure", Nz::ResolveError_TemporaryFailure);
instance.SetField("Unknown", Nz::ResolveError_Unknown); instance.PushField("Unknown", Nz::ResolveError_Unknown);
} }
instance.SetGlobal("ResolveError"); instance.SetGlobal("ResolveError");
@ -170,21 +170,21 @@ namespace Ndk
static_assert(Nz::SocketError_Max + 1 == 15, "Nz::ResolveError has been updated but change was not reflected to Lua binding"); static_assert(Nz::SocketError_Max + 1 == 15, "Nz::ResolveError has been updated but change was not reflected to Lua binding");
instance.PushTable(0, 15); instance.PushTable(0, 15);
{ {
instance.SetField("AddressNotAvailable", Nz::SocketError_AddressNotAvailable); instance.PushField("AddressNotAvailable", Nz::SocketError_AddressNotAvailable);
instance.SetField("ConnectionClosed", Nz::SocketError_ConnectionClosed); instance.PushField("ConnectionClosed", Nz::SocketError_ConnectionClosed);
instance.SetField("ConnectionRefused", Nz::SocketError_ConnectionRefused); instance.PushField("ConnectionRefused", Nz::SocketError_ConnectionRefused);
instance.SetField("DatagramSize", Nz::SocketError_DatagramSize); instance.PushField("DatagramSize", Nz::SocketError_DatagramSize);
instance.SetField("Internal", Nz::SocketError_Internal); instance.PushField("Internal", Nz::SocketError_Internal);
instance.SetField("Packet", Nz::SocketError_Packet); instance.PushField("Packet", Nz::SocketError_Packet);
instance.SetField("NetworkError", Nz::SocketError_NetworkError); instance.PushField("NetworkError", Nz::SocketError_NetworkError);
instance.SetField("NoError", Nz::SocketError_NoError); instance.PushField("NoError", Nz::SocketError_NoError);
instance.SetField("NotInitialized", Nz::SocketError_NotInitialized); instance.PushField("NotInitialized", Nz::SocketError_NotInitialized);
instance.SetField("NotSupported", Nz::SocketError_NotSupported); instance.PushField("NotSupported", Nz::SocketError_NotSupported);
instance.SetField("ResolveError", Nz::SocketError_ResolveError); instance.PushField("ResolveError", Nz::SocketError_ResolveError);
instance.SetField("ResourceError", Nz::SocketError_ResourceError); instance.PushField("ResourceError", Nz::SocketError_ResourceError);
instance.SetField("TimedOut", Nz::SocketError_TimedOut); instance.PushField("TimedOut", Nz::SocketError_TimedOut);
instance.SetField("Unknown", Nz::SocketError_Unknown); instance.PushField("Unknown", Nz::SocketError_Unknown);
instance.SetField("UnreachableHost", Nz::SocketError_UnreachableHost); instance.PushField("UnreachableHost", Nz::SocketError_UnreachableHost);
} }
instance.SetGlobal("SocketError"); instance.SetGlobal("SocketError");
@ -192,11 +192,11 @@ namespace Ndk
static_assert(Nz::SocketState_Max + 1 == 5, "Nz::SocketState has been updated but change was not reflected to Lua binding"); static_assert(Nz::SocketState_Max + 1 == 5, "Nz::SocketState has been updated but change was not reflected to Lua binding");
instance.PushTable(0, 5); instance.PushTable(0, 5);
{ {
instance.SetField("Bound", Nz::SocketState_Bound); instance.PushField("Bound", Nz::SocketState_Bound);
instance.SetField("Connecting", Nz::SocketState_Connecting); instance.PushField("Connecting", Nz::SocketState_Connecting);
instance.SetField("Connected", Nz::SocketState_Connected); instance.PushField("Connected", Nz::SocketState_Connected);
instance.SetField("NotConnected", Nz::SocketState_NotConnected); instance.PushField("NotConnected", Nz::SocketState_NotConnected);
instance.SetField("Resolving", Nz::SocketState_Resolving); instance.PushField("Resolving", Nz::SocketState_Resolving);
} }
instance.SetGlobal("SocketState"); instance.SetGlobal("SocketState");
@ -204,10 +204,10 @@ namespace Ndk
static_assert(Nz::SocketType_Max + 1 == 4, "Nz::SocketState has been updated but change was not reflected to Lua binding"); static_assert(Nz::SocketType_Max + 1 == 4, "Nz::SocketState has been updated but change was not reflected to Lua binding");
instance.PushTable(0, 4); instance.PushTable(0, 4);
{ {
instance.SetField("Raw", Nz::SocketType_Raw); instance.PushField("Raw", Nz::SocketType_Raw);
instance.SetField("TCP", Nz::SocketType_TCP); instance.PushField("TCP", Nz::SocketType_TCP);
instance.SetField("UDP", Nz::SocketType_UDP); instance.PushField("UDP", Nz::SocketType_UDP);
instance.SetField("Unknown", Nz::SocketType_Unknown); instance.PushField("Unknown", Nz::SocketType_Unknown);
} }
instance.SetGlobal("SocketType"); instance.SetGlobal("SocketType");
} }

View File

@ -38,7 +38,7 @@ namespace Ndk
consoleClass.BindMethod("GetInput", &Console::GetInput); consoleClass.BindMethod("GetInput", &Console::GetInput);
consoleClass.BindMethod("GetInputBackground", &Console::GetInputBackground); consoleClass.BindMethod("GetInputBackground", &Console::GetInputBackground);
consoleClass.BindMethod("GetSize", &Console::GetSize); consoleClass.BindMethod("GetSize", &Console::GetSize);
//consoleClass.SetMethod("GetTextFont", &Console::GetTextFont); consoleClass.BindMethod("GetTextFont", &Console::GetTextFont);
consoleClass.BindMethod("IsVisible", &Console::IsVisible); consoleClass.BindMethod("IsVisible", &Console::IsVisible);
@ -47,7 +47,7 @@ namespace Ndk
consoleClass.BindMethod("SetCharacterSize", &Console::SetCharacterSize); consoleClass.BindMethod("SetCharacterSize", &Console::SetCharacterSize);
consoleClass.BindMethod("SetSize", &Console::SetSize); consoleClass.BindMethod("SetSize", &Console::SetSize);
//consoleClass.SetMethod("SetTextFont", &Console::SetTextFont); consoleClass.BindMethod("SetTextFont", &Console::SetTextFont);
consoleClass.BindMethod("Show", &Console::Show, true); consoleClass.BindMethod("Show", &Console::Show, true);
#endif #endif
@ -194,8 +194,7 @@ namespace Ndk
if (entry.name.IsEmpty()) if (entry.name.IsEmpty())
continue; continue;
instance.PushInteger(entry.index); instance.PushField(entry.name, entry.index);
instance.SetField(entry.name);
} }
} }
instance.SetGlobal("ComponentType"); instance.SetGlobal("ComponentType");

View File

@ -88,6 +88,66 @@ namespace Ndk
return 0; return 0;
}); });
/*********************************** Nz::Font **********************************/
fontClass.SetConstructor([] (Nz::LuaInstance& lua) -> Nz::FontRef*
{
return new Nz::FontRef(new Nz::Font);
});
fontClass.BindMethod("ClearGlyphCache", &Nz::Font::ClearGlyphCache);
fontClass.BindMethod("ClearKerningCache", &Nz::Font::ClearKerningCache);
fontClass.BindMethod("ClearSizeInfoCache", &Nz::Font::ClearSizeInfoCache);
fontClass.BindMethod("Destroy", &Nz::Font::Destroy);
fontClass.BindMethod("GetCachedGlyphCount", [] (Nz::LuaInstance& lua, Nz::FontRef& instance) -> int
{
unsigned int argCount = std::min(lua.GetStackTop(), 2U);
int argIndex = 1;
switch (argCount)
{
case 0:
lua.Push(instance->GetCachedGlyphCount());
return 1;
case 2:
{
unsigned int characterSize = lua.Check<unsigned int>(&argIndex);
Nz::UInt32 style = lua.Check<Nz::UInt32>(&argIndex);
lua.Push(instance->GetCachedGlyphCount(characterSize, style));
return 1;
}
}
lua.Error("No matching overload for method GetCachedGlyphCount");
return 0;
});
fontClass.BindMethod("GetFamilyName", &Nz::Font::GetFamilyName);
fontClass.BindMethod("GetKerning", &Nz::Font::GetKerning);
fontClass.BindMethod("GetGlyphBorder", &Nz::Font::GetGlyphBorder);
fontClass.BindMethod("GetMinimumStepSize", &Nz::Font::GetMinimumStepSize);
fontClass.BindMethod("GetSizeInfo", &Nz::Font::GetSizeInfo);
fontClass.BindMethod("GetStyleName", &Nz::Font::GetStyleName);
fontClass.BindMethod("IsValid", &Nz::Font::IsValid);
fontClass.BindMethod("Precache", (bool(Nz::Font::*)(unsigned int, Nz::UInt32, const Nz::String&) const) &Nz::Font::Precache);
fontClass.BindMethod("OpenFromFile", &Nz::Font::OpenFromFile, Nz::FontParams());
fontClass.BindMethod("SetGlyphBorder", &Nz::Font::SetGlyphBorder);
fontClass.BindMethod("SetMinimumStepSize", &Nz::Font::SetMinimumStepSize);
fontClass.BindStaticMethod("GetDefault", &Nz::Font::GetDefault);
fontClass.BindStaticMethod("GetDefaultGlyphBorder", &Nz::Font::GetDefaultGlyphBorder);
fontClass.BindStaticMethod("GetDefaultMinimumStepSize", &Nz::Font::GetDefaultMinimumStepSize);
fontClass.BindStaticMethod("SetDefaultGlyphBorder", &Nz::Font::SetDefaultGlyphBorder);
fontClass.BindStaticMethod("SetDefaultMinimumStepSize", &Nz::Font::SetDefaultMinimumStepSize);
/*********************************** Nz::Node **********************************/ /*********************************** Nz::Node **********************************/
nodeClass.BindMethod("GetBackward", &Nz::Node::GetBackward); nodeClass.BindMethod("GetBackward", &Nz::Node::GetBackward);
//nodeClass.SetMethod("GetChilds", &Nz::Node::GetChilds); //nodeClass.SetMethod("GetChilds", &Nz::Node::GetChilds);
@ -250,6 +310,7 @@ namespace Ndk
void LuaBinding::RegisterUtility(Nz::LuaInstance& instance) void LuaBinding::RegisterUtility(Nz::LuaInstance& instance)
{ {
abstractImage.Register(instance); abstractImage.Register(instance);
fontClass.Register(instance);
nodeClass.Register(instance); nodeClass.Register(instance);
} }
} }

View File

@ -24,9 +24,10 @@ TOOL.Libraries = {
"NazaraCore", "NazaraCore",
"NazaraAudio", "NazaraAudio",
"NazaraLua", "NazaraLua",
"NazaraNetwork",
"NazaraNoise", "NazaraNoise",
"NazaraPhysics", "NazaraPhysics",
"NazaraUtility", "NazaraUtility",
"NazaraRenderer", "NazaraRenderer",
"NazaraGraphics", "NazaraGraphics"
} }

View File

@ -38,6 +38,7 @@ TOOL.FilesExclusion = {
TOOL.Libraries = { TOOL.Libraries = {
"NazaraCore", "NazaraCore",
"NazaraLua", "NazaraLua",
"NazaraNetwork",
"NazaraNoise", "NazaraNoise",
"NazaraPhysics", "NazaraPhysics",
"NazaraUtility" "NazaraUtility"

View File

@ -125,8 +125,12 @@ namespace Nz
template<typename T> int Push(T arg) const; template<typename T> int Push(T arg) const;
void PushBoolean(bool value) const; void PushBoolean(bool value) const;
void PushCFunction(LuaCFunction func, unsigned int upvalueCount = 0) const; void PushCFunction(LuaCFunction func, unsigned int upvalueCount = 0) const;
template<typename T> void PushField(const char* name, T&& arg, int tableIndex = -2) const;
template<typename T> void PushField(const String& name, T&& arg, int tableIndex = -2) const;
void PushFunction(LuaFunction func) const; void PushFunction(LuaFunction func) const;
template<typename R, typename... Args, typename... DefArgs> void PushFunction(R(*func)(Args...), DefArgs&&... defArgs) const; template<typename R, typename... Args, typename... DefArgs> void PushFunction(R(*func)(Args...), DefArgs&&... defArgs) const;
template<typename T> void PushGlobal(const char* name, T&& arg);
template<typename T> void PushGlobal(const String& name, T&& arg);
template<typename T> void PushInstance(const char* tname, T* instance) const; template<typename T> void PushInstance(const char* tname, T* instance) const;
template<typename T, typename... Args> void PushInstance(const char* tname, Args&&... args) const; template<typename T, typename... Args> void PushInstance(const char* tname, Args&&... args) const;
void PushInteger(long long value) const; void PushInteger(long long value) const;
@ -146,12 +150,8 @@ namespace Nz
void Remove(int index) const; void Remove(int index) const;
void Replace(int index) const; void Replace(int index) const;
template<typename T> void SetField(const char* name, T&& arg, int tableIndex = -2); void SetField(const char* name, int tableIndex = -2) const;
template<typename T> void SetField(const String& name, T&& arg, int tableIndex = -2); void SetField(const String& name, int tableIndex = -2) const;
void SetField(const char* name, int tableIndex = -2);
void SetField(const String& name, int tableIndex = -2);
template<typename T> void SetGlobal(const char* name, T&& arg);
template<typename T> void SetGlobal(const String& name, T&& arg);
void SetGlobal(const char* name); void SetGlobal(const char* name);
void SetGlobal(const String& name); void SetGlobal(const String& name);
void SetMetatable(const char* tname) const; void SetMetatable(const char* tname) const;

View File

@ -144,6 +144,18 @@ namespace Nz
return 1; return 1;
} }
template<typename T>
std::enable_if_t<std::is_arithmetic<T>::value || std::is_enum<T>::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag<T&>)
{
return LuaImplReplyVal(instance, val, TypeTag<T>());
}
template<typename T>
std::enable_if_t<std::is_arithmetic<T>::value || std::is_enum<T>::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag<const T&>)
{
return LuaImplReplyVal(instance, val, TypeTag<T>());
}
inline int LuaImplReplyVal(const LuaInstance& instance, std::string val, TypeTag<std::string>) inline int LuaImplReplyVal(const LuaInstance& instance, std::string val, TypeTag<std::string>)
{ {
instance.PushString(val.c_str(), val.size()); instance.PushString(val.c_str(), val.size());
@ -541,6 +553,19 @@ namespace Nz
return LuaImplReplyVal(*this, std::move(arg), TypeTag<T>()); return LuaImplReplyVal(*this, std::move(arg), TypeTag<T>());
} }
template<typename T>
void LuaInstance::PushField(const char* name, T&& arg, int tableIndex) const
{
Push<T>(std::forward<T>(arg));
SetField(name, tableIndex);
}
template<typename T>
void LuaInstance::PushField(const String& name, T&& arg, int tableIndex) const
{
PushField(name.GetConstBuffer(), std::forward<T>(arg), tableIndex);
}
template<typename R, typename... Args, typename... DefArgs> template<typename R, typename... Args, typename... DefArgs>
void LuaInstance::PushFunction(R(*func)(Args...), DefArgs&&... defArgs) const void LuaInstance::PushFunction(R(*func)(Args...), DefArgs&&... defArgs) const
{ {
@ -554,6 +579,19 @@ namespace Nz
}); });
} }
template<typename T>
void LuaInstance::PushGlobal(const char* name, T&& arg)
{
Push<T>(std::forward<T>(arg));
SetGlobal(name);
}
template<typename T>
void LuaInstance::PushGlobal(const String& name, T&& arg)
{
PushGlobal(name.GetConstBuffer(), std::forward<T>(arg));
}
template<typename T> template<typename T>
void LuaInstance::PushInstance(const char* tname, T* instance) const void LuaInstance::PushInstance(const char* tname, T* instance) const
{ {
@ -568,32 +606,6 @@ namespace Nz
PushInstance(tname, new T(std::forward<Args>(args)...)); PushInstance(tname, new T(std::forward<Args>(args)...));
} }
template<typename T>
void LuaInstance::SetField(const char* name, T&& arg, int tableIndex)
{
Push<T>(std::forward<T>(arg));
SetField(name, tableIndex);
}
template<typename T>
void LuaInstance::SetField(const String& name, T&& arg, int tableIndex)
{
SetField(name.GetConstBuffer(), std::forward<T>(arg), tableIndex);
}
template<typename T>
void LuaInstance::SetGlobal(const char* name, T&& arg)
{
Push<T>(std::forward<T>(arg));
SetGlobal(name);
}
template<typename T>
void LuaInstance::SetGlobal(const String& name, T&& arg)
{
SetGlobal(name.GetConstBuffer(), std::forward<T>(arg));
}
template<typename T> template<typename T>
T LuaInstance::CheckBounds(int index, long long value) const T LuaInstance::CheckBounds(int index, long long value) const
{ {

View File

@ -89,7 +89,7 @@ namespace Nz
Font& operator=(Font&&) = delete; Font& operator=(Font&&) = delete;
static std::shared_ptr<AbstractAtlas> GetDefaultAtlas(); static std::shared_ptr<AbstractAtlas> GetDefaultAtlas();
static Font* GetDefault(); static const FontRef& GetDefault();
static unsigned int GetDefaultGlyphBorder(); static unsigned int GetDefaultGlyphBorder();
static unsigned int GetDefaultMinimumStepSize(); static unsigned int GetDefaultMinimumStepSize();

View File

@ -714,12 +714,12 @@ namespace Nz
lua_replace(m_state, index); lua_replace(m_state, index);
} }
void LuaInstance::SetField(const char* name, int tableIndex) void LuaInstance::SetField(const char* name, int tableIndex) const
{ {
lua_setfield(m_state, tableIndex, name); lua_setfield(m_state, tableIndex, name);
} }
void LuaInstance::SetField(const String& name, int tableIndex) void LuaInstance::SetField(const String& name, int tableIndex) const
{ {
lua_setfield(m_state, tableIndex, name.GetConstBuffer()); lua_setfield(m_state, tableIndex, name.GetConstBuffer());
} }

View File

@ -350,7 +350,7 @@ namespace Nz
return s_defaultAtlas; return s_defaultAtlas;
} }
Font* Font::GetDefault() const FontRef& Font::GetDefault()
{ {
// Nous n'initialisons la police par défaut qu'à la demande pour qu'elle prenne // Nous n'initialisons la police par défaut qu'à la demande pour qu'elle prenne
// les paramètres par défaut (qui peuvent avoir étés changés par l'utilisateur), // les paramètres par défaut (qui peuvent avoir étés changés par l'utilisateur),