updated font and lua bindings
This commit is contained in:
@@ -395,7 +395,14 @@ void wiFont::SetText(const wstring& text)
|
||||
{
|
||||
this->text = text;
|
||||
}
|
||||
|
||||
wstring wiFont::GetText()
|
||||
{
|
||||
return text;
|
||||
}
|
||||
string wiFont::GetTextA()
|
||||
{
|
||||
return string(text.begin(),text.end());
|
||||
}
|
||||
|
||||
wiFont::wiFontStyle::wiFontStyle(const string& newName){
|
||||
|
||||
|
||||
@@ -111,6 +111,8 @@ public:
|
||||
|
||||
void SetText(const string& text);
|
||||
void SetText(const wstring& text);
|
||||
wstring GetText();
|
||||
string GetTextA();
|
||||
|
||||
void CleanUp();
|
||||
};
|
||||
|
||||
@@ -7,6 +7,8 @@ const char wiFont_BindLua::className[] = "Font";
|
||||
Luna<wiFont_BindLua>::FunctionType wiFont_BindLua::methods[] = {
|
||||
lunamethod(wiFont_BindLua, GetProperties),
|
||||
lunamethod(wiFont_BindLua, SetProperties),
|
||||
lunamethod(wiFont_BindLua, GetText),
|
||||
lunamethod(wiFont_BindLua, SetText),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<wiFont_BindLua>::PropertyType wiFont_BindLua::properties[] = {
|
||||
@@ -18,7 +20,7 @@ wiFont_BindLua::wiFont_BindLua(wiFont* font)
|
||||
if (font != nullptr)
|
||||
this->font = new wiFont(*font);
|
||||
else
|
||||
this->font = nullptr;
|
||||
this->font = new wiFont();
|
||||
}
|
||||
wiFont_BindLua::wiFont_BindLua(lua_State* L)
|
||||
{
|
||||
@@ -29,7 +31,7 @@ wiFont_BindLua::wiFont_BindLua(lua_State* L)
|
||||
font = new wiFont(text);
|
||||
}
|
||||
else
|
||||
font = nullptr;
|
||||
font = new wiFont();
|
||||
}
|
||||
wiFont_BindLua::~wiFont_BindLua()
|
||||
{
|
||||
@@ -39,12 +41,26 @@ wiFont_BindLua::~wiFont_BindLua()
|
||||
|
||||
int wiFont_BindLua::GetProperties(lua_State* L)
|
||||
{
|
||||
//TODO
|
||||
return 0;
|
||||
}
|
||||
int wiFont_BindLua::SetProperties(lua_State* L)
|
||||
{
|
||||
//TODO
|
||||
return 0;
|
||||
}
|
||||
int wiFont_BindLua::SetText(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
font->SetText(wiLua::SGetString(L, 1));
|
||||
return 0;
|
||||
}
|
||||
int wiFont_BindLua::GetText(lua_State* L)
|
||||
{
|
||||
wiLua::SSetString(L, font->GetTextA());
|
||||
return 1;
|
||||
}
|
||||
|
||||
void wiFont_BindLua::Bind()
|
||||
{
|
||||
|
||||
@@ -19,6 +19,9 @@ public:
|
||||
|
||||
int GetProperties(lua_State* L);
|
||||
int SetProperties(lua_State* L);
|
||||
int SetText(lua_State* L);
|
||||
int GetText(lua_State* L);
|
||||
|
||||
|
||||
static void Bind();
|
||||
};
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace wiLoader_BindLua
|
||||
Object_BindLua::Bind();
|
||||
Armature_BindLua::Bind();
|
||||
Ray_BindLua::Bind();
|
||||
AABB_BindLua::Bind();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,6 +368,8 @@ const char Cullable_BindLua::className[] = "Cullable";
|
||||
|
||||
Luna<Cullable_BindLua>::FunctionType Cullable_BindLua::methods[] = {
|
||||
lunamethod(Cullable_BindLua, Intersects),
|
||||
lunamethod(Cullable_BindLua, GetAABB),
|
||||
lunamethod(Cullable_BindLua, SetAABB),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<Cullable_BindLua>::PropertyType Cullable_BindLua::properties[] = {
|
||||
@@ -433,6 +436,28 @@ int Cullable_BindLua::Intersects(lua_State* L)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int Cullable_BindLua::GetAABB(lua_State* L)
|
||||
{
|
||||
Luna<AABB_BindLua>::push(L, new AABB_BindLua(cullable->bounds));
|
||||
return 1;
|
||||
}
|
||||
int Cullable_BindLua::SetAABB(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc < 0)
|
||||
{
|
||||
AABB_BindLua* box = Luna<AABB_BindLua>::lightcheck(L, 1);
|
||||
if (box)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "SetAABB(AABB aabb) argument is not an AABB!");
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "SetAABB(AABB aabb) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Cullable_BindLua::Bind()
|
||||
{
|
||||
@@ -453,6 +478,8 @@ Luna<Object_BindLua>::FunctionType Object_BindLua::methods[] = {
|
||||
lunamethod(Node_BindLua, SetName),
|
||||
|
||||
lunamethod(Cullable_BindLua, Intersects),
|
||||
lunamethod(Cullable_BindLua, GetAABB),
|
||||
lunamethod(Cullable_BindLua, SetAABB),
|
||||
|
||||
lunamethod(Transform_BindLua, AttachTo),
|
||||
lunamethod(Transform_BindLua, Detach),
|
||||
@@ -842,3 +869,103 @@ void Ray_BindLua::Bind()
|
||||
Luna<Ray_BindLua>::Register(wiLua::GetGlobal()->GetLuaState());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const char AABB_BindLua::className[] = "AABB";
|
||||
|
||||
Luna<AABB_BindLua>::FunctionType AABB_BindLua::methods[] = {
|
||||
lunamethod(AABB_BindLua, Intersects),
|
||||
lunamethod(AABB_BindLua, Transform),
|
||||
lunamethod(AABB_BindLua, GetMin),
|
||||
lunamethod(AABB_BindLua, GetMax),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<AABB_BindLua>::PropertyType AABB_BindLua::properties[] = {
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
AABB_BindLua::AABB_BindLua(const AABB& aabb) :aabb(aabb)
|
||||
{
|
||||
}
|
||||
AABB_BindLua::AABB_BindLua(lua_State *L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
Vector_BindLua* min = Luna<Vector_BindLua>::lightcheck(L, 1);
|
||||
Vector_BindLua* max = Luna<Vector_BindLua>::lightcheck(L, 2);
|
||||
if (min && max)
|
||||
{
|
||||
XMFLOAT3 fmin, fmax;
|
||||
XMStoreFloat3(&fmin, min->vector);
|
||||
XMStoreFloat3(&fmax, max->vector);
|
||||
aabb = AABB(wiMath::Min(fmin, fmax), wiMath::Max(fmin, fmax));
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "AABB(Vector min,max) one of the arguments is not an AABB!");
|
||||
}
|
||||
else
|
||||
aabb = AABB(XMFLOAT3(0, 0, 0), XMFLOAT3(0, 0, 0));
|
||||
}
|
||||
AABB_BindLua::~AABB_BindLua()
|
||||
{
|
||||
}
|
||||
|
||||
int AABB_BindLua::Intersects(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
AABB_BindLua* box = Luna<AABB_BindLua>::lightcheck(L, 1);
|
||||
if (box)
|
||||
{
|
||||
wiLua::SSetBool(L, aabb.intersects(box->aabb) != AABB::INTERSECTION_TYPE::OUTSIDE);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "Intersects(AABB aabb) argument is not an AABB!");
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "Intersects(AABB aabb) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
int AABB_BindLua::Transform(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
Matrix_BindLua* mat = Luna<Matrix_BindLua>::lightcheck(L, 1);
|
||||
if (mat)
|
||||
{
|
||||
Luna<AABB_BindLua>::push(L, new AABB_BindLua(aabb.get(mat->matrix)));
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "Transform(Matrix mat) argument is not a Matrix!");
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "Transform(Matrix mat) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
int AABB_BindLua::GetMin(lua_State* L)
|
||||
{
|
||||
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&aabb.getMin())));
|
||||
return 1;
|
||||
}
|
||||
int AABB_BindLua::GetMax(lua_State* L)
|
||||
{
|
||||
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&aabb.getMax())));
|
||||
return 1;
|
||||
}
|
||||
|
||||
void AABB_BindLua::Bind()
|
||||
{
|
||||
static bool initialized = false;
|
||||
if (!initialized)
|
||||
{
|
||||
initialized = true;
|
||||
Luna<AABB_BindLua>::Register(wiLua::GetGlobal()->GetLuaState());
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,8 @@ public:
|
||||
~Cullable_BindLua();
|
||||
|
||||
int Intersects(lua_State *L);
|
||||
int GetAABB(lua_State* L);
|
||||
int SetAABB(lua_State* L);
|
||||
|
||||
static void Bind();
|
||||
};
|
||||
@@ -147,3 +149,24 @@ public:
|
||||
static void Bind();
|
||||
};
|
||||
|
||||
class AABB_BindLua
|
||||
{
|
||||
public:
|
||||
AABB aabb;
|
||||
|
||||
static const char className[];
|
||||
static Luna<AABB_BindLua>::FunctionType methods[];
|
||||
static Luna<AABB_BindLua>::PropertyType properties[];
|
||||
|
||||
AABB_BindLua(const AABB& ray);
|
||||
AABB_BindLua(lua_State* L);
|
||||
~AABB_BindLua();
|
||||
|
||||
int Intersects(lua_State* L);
|
||||
int Transform(lua_State* L);
|
||||
int GetMin(lua_State* L);
|
||||
int GetMax(lua_State* L);
|
||||
|
||||
static void Bind();
|
||||
};
|
||||
|
||||
|
||||
@@ -337,6 +337,15 @@ namespace wiRenderer_BindLua
|
||||
wiLua::SError(L, "SetSpotLightShadowProps(int shadowMapCount, int resolution) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
int SetDebugBoxesEnabled(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
wiRenderer::SetToDrawDebugBoxes(wiLua::SGetBool(L, 1));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Pick(lua_State* L)
|
||||
{
|
||||
@@ -451,6 +460,7 @@ namespace wiRenderer_BindLua
|
||||
wiLua::GetGlobal()->RegisterFunc("SetDirectionalLightShadowProps", SetDirectionalLightShadowProps);
|
||||
wiLua::GetGlobal()->RegisterFunc("SetPointLightShadowProps", SetPointLightShadowProps);
|
||||
wiLua::GetGlobal()->RegisterFunc("SetSpotLightShadowProps", SetSpotLightShadowProps);
|
||||
wiLua::GetGlobal()->RegisterFunc("SetDebugBoxesEnabled", SetDebugBoxesEnabled);
|
||||
|
||||
wiLua::GetGlobal()->RegisterFunc("Pick", Pick);
|
||||
wiLua::GetGlobal()->RegisterFunc("DrawLine", DrawLine);
|
||||
|
||||
Reference in New Issue
Block a user