#include "MainComponent_BindLua.h" #include "RenderableComponent_BindLua.h" #include "Renderable3DComponent_BindLua.h" #include "Renderable2DComponent_BindLua.h" #include "DeferredRenderableComponent_BindLua.h" #include "ForwardRenderableComponent_BindLua.h" #include "LoadingScreenComponent_BindLua.h" #include "wiResourceManager_BindLua.h" const char MainComponent_BindLua::className[] = "MainComponent"; Luna::FunctionType MainComponent_BindLua::methods[] = { lunamethod(MainComponent_BindLua, GetContent), lunamethod(MainComponent_BindLua, GetActiveComponent), lunamethod(MainComponent_BindLua, SetActiveComponent), lunamethod(MainComponent_BindLua, SetFrameSkip), lunamethod(MainComponent_BindLua, SetInfoDisplay), lunamethod(MainComponent_BindLua, SetWatermarkDisplay), lunamethod(MainComponent_BindLua, SetFPSDisplay), lunamethod(MainComponent_BindLua, SetCPUDisplay), lunamethod(MainComponent_BindLua, SetResolutionDisplay), lunamethod(MainComponent_BindLua, SetColorGradePaletteDisplay), { NULL, NULL } }; Luna::PropertyType MainComponent_BindLua::properties[] = { { NULL, NULL } }; MainComponent_BindLua::MainComponent_BindLua(MainComponent* component) :component(component) { } MainComponent_BindLua::MainComponent_BindLua(lua_State *L) { component = nullptr; } MainComponent_BindLua::~MainComponent_BindLua() { } int MainComponent_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 MainComponent_BindLua::GetActiveComponent(lua_State *L) { if (component == nullptr) { wiLua::SError(L, "GetActiveComponent() component is empty!"); return 0; } //return deferred 3d component if the active one is of that type DeferredRenderableComponent* compDef3D = dynamic_cast(component->getActiveComponent()); if (compDef3D != nullptr) { Luna::push(L, new DeferredRenderableComponent_BindLua(compDef3D)); return 1; } //return forward 3d component if the active one is of that type ForwardRenderableComponent* compFwd3D = dynamic_cast(component->getActiveComponent()); if (compFwd3D != nullptr) { Luna::push(L, new ForwardRenderableComponent_BindLua(compFwd3D)); return 1; } //return 3d component if the active one is of that type Renderable3DComponent* comp3D = dynamic_cast(component->getActiveComponent()); if (comp3D != nullptr) { Luna::push(L, new Renderable3DComponent_BindLua(comp3D)); return 1; } //return loading component if the active one is of that type LoadingScreenComponent* compLoad = dynamic_cast(component->getActiveComponent()); if (compLoad != nullptr) { Luna::push(L, new LoadingScreenComponent_BindLua(compLoad)); return 1; } //return 2d component if the active one is of that type Renderable2DComponent* comp2D = dynamic_cast(component->getActiveComponent()); if (comp2D != nullptr) { Luna::push(L, new Renderable2DComponent_BindLua(comp2D)); return 1; } //return component if the active one is of that type RenderableComponent* comp = dynamic_cast(component->getActiveComponent()); if (comp != nullptr) { Luna::push(L, new RenderableComponent_BindLua(comp)); return 1; } wiLua::SError(L, "GetActiveComponent() Warning: type of active component not registered!"); return 0; } int MainComponent_BindLua::SetActiveComponent(lua_State *L) { if (component == nullptr) { wiLua::SError(L, "SetActiveComponent(RenderableComponent component) component is empty!"); return 0; } int argc = wiLua::SGetArgCount(L); if (argc > 0) { int fadeFrames = 0; wiColor fadeColor = wiColor(0, 0, 0, 255); if (argc > 1) { fadeFrames = wiLua::SGetInt(L, 2); if (argc > 2) { fadeColor.r = wiLua::SGetInt(L, 3); if (argc > 3) { fadeColor.g = wiLua::SGetInt(L, 4); if (argc > 4) { fadeColor.b = wiLua::SGetInt(L, 5); } } } } ForwardRenderableComponent_BindLua* compFwd3D = Luna::lightcheck(L, 1); if (compFwd3D != nullptr) { component->activateComponent(compFwd3D->component, fadeFrames, fadeColor); return 0; } DeferredRenderableComponent_BindLua* compDef3D = Luna::lightcheck(L, 1); if (compDef3D != nullptr) { component->activateComponent(compDef3D->component, fadeFrames, fadeColor); return 0; } Renderable3DComponent_BindLua* comp3D = Luna::lightcheck(L, 1); if (comp3D != nullptr) { component->activateComponent(comp3D->component, fadeFrames, fadeColor); return 0; } LoadingScreenComponent_BindLua* compLoad = Luna::lightcheck(L, 1); if (compLoad != nullptr) { component->activateComponent(compLoad->component, fadeFrames, fadeColor); return 0; } Renderable2DComponent_BindLua* comp2D = Luna::lightcheck(L, 1); if (comp2D != nullptr) { component->activateComponent(comp2D->component, fadeFrames, fadeColor); return 0; } RenderableComponent_BindLua* comp = Luna::lightcheck(L, 1); if (comp != nullptr) { component->activateComponent(comp->component, fadeFrames, fadeColor); return 0; } } else { wiLua::SError(L, "SetActiveComponent(RenderableComponent component, opt int fadeFrames,fadeColorR,fadeColorG,fadeColorB) not enought arguments!"); return 0; } return 0; } int MainComponent_BindLua::SetFrameSkip(lua_State *L) { if (component == nullptr) { wiLua::SError(L, "SetFrameSkip(bool enabled) component is empty!"); return 0; } int argc = wiLua::SGetArgCount(L); if (argc > 0) { component->setFrameSkip(wiLua::SGetBool(L, 1)); } else wiLua::SError(L, "SetFrameSkip(bool enabled) not enought arguments!"); return 0; } int MainComponent_BindLua::SetInfoDisplay(lua_State *L) { if (component == nullptr) { wiLua::SError(L, "SetInfoDisplay() component is empty!"); return 0; } int argc = wiLua::SGetArgCount(L); if (argc > 0) { component->infoDisplay.active = wiLua::SGetBool(L, 1); } else wiLua::SError(L, "SetInfoDisplay(bool active) not enough arguments!"); return 0; } int MainComponent_BindLua::SetWatermarkDisplay(lua_State *L) { if (component == nullptr) { wiLua::SError(L, "SetWatermarkDisplay() component is empty!"); return 0; } int argc = wiLua::SGetArgCount(L); if (argc > 0) { component->infoDisplay.watermark = wiLua::SGetBool(L, 1); } else wiLua::SError(L, "SetWatermarkDisplay(bool active) not enough arguments!"); return 0; } int MainComponent_BindLua::SetFPSDisplay(lua_State *L) { if (component == nullptr) { wiLua::SError(L, "SetFPSDisplay() component is empty!"); return 0; } int argc = wiLua::SGetArgCount(L); if (argc > 0) { component->infoDisplay.fpsinfo = wiLua::SGetBool(L, 1); } else wiLua::SError(L, "SetFPSDisplay(bool active) not enough arguments!"); return 0; } int MainComponent_BindLua::SetCPUDisplay(lua_State *L) { if (component == nullptr) { wiLua::SError(L, "SetCPUDisplay() component is empty!"); return 0; } int argc = wiLua::SGetArgCount(L); if (argc > 0) { component->infoDisplay.cpuinfo = wiLua::SGetBool(L, 1); } else wiLua::SError(L, "SetCPUDisplay(bool active) not enough arguments!"); return 0; } int MainComponent_BindLua::SetResolutionDisplay(lua_State *L) { if (component == nullptr) { wiLua::SError(L, "SetResolutionDisplay() component is empty!"); return 0; } int argc = wiLua::SGetArgCount(L); if (argc > 0) { component->infoDisplay.resolution = wiLua::SGetBool(L, 1); } else wiLua::SError(L, "SetResolutionDisplay(bool active) not enough arguments!"); return 0; } int MainComponent_BindLua::SetColorGradePaletteDisplay(lua_State* L) { if (component == nullptr) { wiLua::SError(L, "SetColorGradePaletteDisplay() component is empty!"); return 0; } int argc = wiLua::SGetArgCount(L); if (argc > 0) { component->colorGradingPaletteDisplayEnabled = wiLua::SGetBool(L, 1); } else wiLua::SError(L, "SetColorGradePaletteDisplay(bool active) not enough arguments!"); return 0; } void MainComponent_BindLua::Bind() { static bool initialized = false; if (!initialized) { initialized = true; Luna::Register(wiLua::GetGlobal()->GetLuaState()); } }