Sdk/Binding: Bind Font class
Former-commit-id: 63726c649af7b95f01d283bfd08206cf214172da
This commit is contained in:
parent
ab8e851f6f
commit
cfef9988ae
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ namespace Ndk
|
||||||
|
|
||||||
// Utility
|
// Utility
|
||||||
abstractImage("AbstractImage"),
|
abstractImage("AbstractImage"),
|
||||||
|
fontClass("Font"),
|
||||||
nodeClass("Node"),
|
nodeClass("Node"),
|
||||||
|
|
||||||
// SDK
|
// SDK
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,65 @@ 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("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 +309,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue