diff --git a/WickedEngine/DeferredRenderableComponent_BindLua.cpp b/WickedEngine/DeferredRenderableComponent_BindLua.cpp index 92019d78b..0e27bf24f 100644 --- a/WickedEngine/DeferredRenderableComponent_BindLua.cpp +++ b/WickedEngine/DeferredRenderableComponent_BindLua.cpp @@ -4,6 +4,7 @@ const char DeferredRenderableComponent_BindLua::className[] = "DeferredRenderabl Luna::FunctionType DeferredRenderableComponent_BindLua::methods[] = { lunamethod(DeferredRenderableComponent_BindLua, GetContent), + lunamethod(DeferredRenderableComponent_BindLua, Initialize), { NULL, NULL } }; Luna::PropertyType DeferredRenderableComponent_BindLua::properties[] = { diff --git a/WickedEngine/ForwardRenderableComponent_BindLua.cpp b/WickedEngine/ForwardRenderableComponent_BindLua.cpp index 927246ea3..f47b33c18 100644 --- a/WickedEngine/ForwardRenderableComponent_BindLua.cpp +++ b/WickedEngine/ForwardRenderableComponent_BindLua.cpp @@ -4,6 +4,7 @@ const char ForwardRenderableComponent_BindLua::className[] = "ForwardRenderableC Luna::FunctionType ForwardRenderableComponent_BindLua::methods[] = { lunamethod(ForwardRenderableComponent_BindLua, GetContent), + lunamethod(ForwardRenderableComponent_BindLua, Initialize), { NULL, NULL } }; Luna::PropertyType ForwardRenderableComponent_BindLua::properties[] = { diff --git a/WickedEngine/LoadingScreenComponent_BindLua.cpp b/WickedEngine/LoadingScreenComponent_BindLua.cpp index fcbb98c1b..0042b3391 100644 --- a/WickedEngine/LoadingScreenComponent_BindLua.cpp +++ b/WickedEngine/LoadingScreenComponent_BindLua.cpp @@ -5,6 +5,7 @@ const char LoadingScreenComponent_BindLua::className[] = "LoadingScreenComponent Luna::FunctionType LoadingScreenComponent_BindLua::methods[] = { lunamethod(LoadingScreenComponent_BindLua, GetContent), lunamethod(LoadingScreenComponent_BindLua, AddSprite), + lunamethod(LoadingScreenComponent_BindLua, Initialize), { NULL, NULL } }; Luna::PropertyType LoadingScreenComponent_BindLua::properties[] = { diff --git a/WickedEngine/Renderable2DComponent_BindLua.cpp b/WickedEngine/Renderable2DComponent_BindLua.cpp index bf7b87358..e81630764 100644 --- a/WickedEngine/Renderable2DComponent_BindLua.cpp +++ b/WickedEngine/Renderable2DComponent_BindLua.cpp @@ -7,14 +7,16 @@ const char Renderable2DComponent_BindLua::className[] = "Renderable2DComponent"; Luna::FunctionType Renderable2DComponent_BindLua::methods[] = { lunamethod(Renderable2DComponent_BindLua, GetContent), lunamethod(Renderable2DComponent_BindLua, AddSprite), + lunamethod(Renderable2DComponent_BindLua, Initialize), { NULL, NULL } }; Luna::PropertyType Renderable2DComponent_BindLua::properties[] = { { NULL, NULL } }; -Renderable2DComponent_BindLua::Renderable2DComponent_BindLua(Renderable2DComponent* component) :component(component) +Renderable2DComponent_BindLua::Renderable2DComponent_BindLua(Renderable2DComponent* component) { + this->component = component; } Renderable2DComponent_BindLua::Renderable2DComponent_BindLua(lua_State *L) @@ -27,17 +29,6 @@ Renderable2DComponent_BindLua::~Renderable2DComponent_BindLua() { } -int Renderable2DComponent_BindLua::GetContent(lua_State *L) -{ - if (component == nullptr) - { - wiLua::SError(L, "GetContent() component is empty!"); - return 0; - } - Luna::push(L, new wiResourceManager_BindLua(&component->Content)); - return 1; -} - int Renderable2DComponent_BindLua::AddSprite(lua_State *L) { if (component == nullptr) @@ -51,7 +42,15 @@ int Renderable2DComponent_BindLua::AddSprite(lua_State *L) wiSprite_BindLua* sprite = Luna::check(L, 2); if (sprite != nullptr) { - component->addSprite(sprite->sprite); + Renderable2DComponent* ccomp = dynamic_cast(component); + if (ccomp != nullptr) + { + ccomp->addSprite(sprite->sprite); + } + else + { + wiLua::SError(L, "AddSprite(Sprite sprite) not a Renderable2DComponent!"); + } } } else diff --git a/WickedEngine/Renderable2DComponent_BindLua.h b/WickedEngine/Renderable2DComponent_BindLua.h index 0cad01eba..d73380d24 100644 --- a/WickedEngine/Renderable2DComponent_BindLua.h +++ b/WickedEngine/Renderable2DComponent_BindLua.h @@ -7,8 +7,6 @@ class Renderable2DComponent_BindLua : public RenderableComponent_BindLua { public: - Renderable2DComponent* component; - static const char className[]; static Luna::FunctionType methods[]; static Luna::PropertyType properties[]; @@ -17,7 +15,6 @@ public: Renderable2DComponent_BindLua(lua_State *L); ~Renderable2DComponent_BindLua(); - virtual int GetContent(lua_State *L); virtual int AddSprite(lua_State *L); static void Bind(); diff --git a/WickedEngine/Renderable3DComponent_BindLua.cpp b/WickedEngine/Renderable3DComponent_BindLua.cpp index e22edfbf7..57ed2f3e6 100644 --- a/WickedEngine/Renderable3DComponent_BindLua.cpp +++ b/WickedEngine/Renderable3DComponent_BindLua.cpp @@ -4,15 +4,17 @@ const char Renderable3DComponent_BindLua::className[] = "Renderable3DComponent"; Luna::FunctionType Renderable3DComponent_BindLua::methods[] = { - lunamethod(Renderable3DComponent_BindLua,GetContent), + lunamethod(Renderable3DComponent_BindLua, GetContent), + lunamethod(Renderable3DComponent_BindLua, Initialize), { NULL, NULL } }; Luna::PropertyType Renderable3DComponent_BindLua::properties[] = { { NULL, NULL } }; -Renderable3DComponent_BindLua::Renderable3DComponent_BindLua(Renderable3DComponent* component) :component(component) +Renderable3DComponent_BindLua::Renderable3DComponent_BindLua(Renderable3DComponent* component) { + this->component = component; } Renderable3DComponent_BindLua::Renderable3DComponent_BindLua(lua_State* L) @@ -24,17 +26,6 @@ Renderable3DComponent_BindLua::~Renderable3DComponent_BindLua() { } -int Renderable3DComponent_BindLua::GetContent(lua_State *L) -{ - if (component == nullptr) - { - wiLua::SError(L, "GetContent() component is empty!"); - return 0; - } - Luna::push(L, new wiResourceManager_BindLua(&component->Content)); - return 1; -} - void Renderable3DComponent_BindLua::Bind() { static bool initialized = false; diff --git a/WickedEngine/Renderable3DComponent_BindLua.h b/WickedEngine/Renderable3DComponent_BindLua.h index 3773ddc29..0c09a3dda 100644 --- a/WickedEngine/Renderable3DComponent_BindLua.h +++ b/WickedEngine/Renderable3DComponent_BindLua.h @@ -7,8 +7,6 @@ class Renderable3DComponent_BindLua : public RenderableComponent_BindLua { public: - Renderable3DComponent* component; - static const char className[]; static Luna::FunctionType methods[]; static Luna::PropertyType properties[]; @@ -17,8 +15,6 @@ public: Renderable3DComponent_BindLua(lua_State* L); ~Renderable3DComponent_BindLua(); - int GetContent(lua_State *L); - static void Bind(); }; diff --git a/WickedEngine/RenderableComponent_BindLua.cpp b/WickedEngine/RenderableComponent_BindLua.cpp index be4697fbe..8fdf58d9c 100644 --- a/WickedEngine/RenderableComponent_BindLua.cpp +++ b/WickedEngine/RenderableComponent_BindLua.cpp @@ -1,8 +1,11 @@ #include "RenderableComponent_BindLua.h" +#include "wiResourceManager_BindLua.h" const char RenderableComponent_BindLua::className[] = "RenderableComponent"; Luna::FunctionType RenderableComponent_BindLua::methods[] = { + lunamethod(RenderableComponent_BindLua, GetContent), + lunamethod(RenderableComponent_BindLua, Initialize), { NULL, NULL } }; Luna::PropertyType RenderableComponent_BindLua::properties[] = { @@ -15,7 +18,7 @@ RenderableComponent_BindLua::RenderableComponent_BindLua(RenderableComponent* co RenderableComponent_BindLua::RenderableComponent_BindLua(lua_State *L) { - component = nullptr; + component = new RenderableComponent(); } @@ -23,6 +26,28 @@ RenderableComponent_BindLua::~RenderableComponent_BindLua() { } +int RenderableComponent_BindLua::GetContent(lua_State *L) +{ + if (component == nullptr) + { + wiLua::SError(L, "GetContent() component is empty!"); + return 0; + } + Luna::push(L, new wiResourceManager_BindLua(&component->Content)); + return 1; +} + +int RenderableComponent_BindLua::Initialize(lua_State* L) +{ + if (component == nullptr) + { + wiLua::SError(L, "Initialize() component is null!"); + return 0; + } + component->Initialize(); + return 0; +} + void RenderableComponent_BindLua::Bind() { diff --git a/WickedEngine/RenderableComponent_BindLua.h b/WickedEngine/RenderableComponent_BindLua.h index 1a0bd5d28..da8530479 100644 --- a/WickedEngine/RenderableComponent_BindLua.h +++ b/WickedEngine/RenderableComponent_BindLua.h @@ -15,6 +15,9 @@ public: RenderableComponent_BindLua(lua_State *L); ~RenderableComponent_BindLua(); + virtual int GetContent(lua_State* L); + virtual int Initialize(lua_State* L); + static void Bind(); }; diff --git a/WickedEngine/WickedEngine.vcxproj b/WickedEngine/WickedEngine.vcxproj index 572f2966d..23607bbe1 100644 --- a/WickedEngine/WickedEngine.vcxproj +++ b/WickedEngine/WickedEngine.vcxproj @@ -385,6 +385,7 @@ + @@ -429,6 +430,7 @@ + diff --git a/WickedEngine/WickedEngine.vcxproj.filters b/WickedEngine/WickedEngine.vcxproj.filters index 43d62dbee..50c08deac 100644 --- a/WickedEngine/WickedEngine.vcxproj.filters +++ b/WickedEngine/WickedEngine.vcxproj.filters @@ -779,6 +779,9 @@ Lua Bindings + + Lua Bindings + @@ -1735,6 +1738,9 @@ Header Files + + Lua Bindings + diff --git a/WickedEngine/wiInputManager_BindLua.cpp b/WickedEngine/wiInputManager_BindLua.cpp new file mode 100644 index 000000000..a2262c9f0 --- /dev/null +++ b/WickedEngine/wiInputManager_BindLua.cpp @@ -0,0 +1,10 @@ +#include "wiInputManager_BindLua.h" + +namespace wiInputManager_BindLua +{ + void Bind() + { + + } +} + diff --git a/WickedEngine/wiInputManager_BindLua.h b/WickedEngine/wiInputManager_BindLua.h new file mode 100644 index 000000000..752c62a4f --- /dev/null +++ b/WickedEngine/wiInputManager_BindLua.h @@ -0,0 +1,9 @@ +#pragma once +#include "wiLua.h" + +namespace wiInputManager_BindLua +{ + void Bind(); + + +} diff --git a/WickedEngine/wiLua.cpp b/WickedEngine/wiLua.cpp index 8d36be115..ee8322853 100644 --- a/WickedEngine/wiLua.cpp +++ b/WickedEngine/wiLua.cpp @@ -197,6 +197,13 @@ void wiLua::SetDeltaTime(double dt) lua_call(m_luaState, 1, 0); } +void wiLua::Signal(const string& name) +{ + lua_getglobal(m_luaState, "signal"); + SSetString(m_luaState, name.c_str()); + lua_call(m_luaState, 1, 0); +} + int wiLua::DebugOut(lua_State* L) { int argc = lua_gettop(L); diff --git a/WickedEngine/wiLua.h b/WickedEngine/wiLua.h index d39b57a3b..ddce38d56 100644 --- a/WickedEngine/wiLua.h +++ b/WickedEngine/wiLua.h @@ -60,6 +60,9 @@ public: //set delta time to use with lua void SetDeltaTime(double dt); + //send a signal to lua + void Signal(const string& name); + //Static function wrappers from here on //get string from lua on stack position