#include "dl_lua_register.h" #include "dl_io.h" #include "render/dl_graphics.h" #include "system/dl_system.h" #include "script/dl_lua.h" #include namespace dl { void lua_log(std::string_view str) { log(str); } void lua_register_base(lua_State* L) { luabridge::getGlobalNamespace(L). addFunction("log", lua_log); } void lua_register_system(lua_State* L) { luabridge::getGlobalNamespace(L) .beginClass("ParamWindow") .addConstructor() // 忽略这个构造会出错…… .addProperty("title", &ParamWindow::_strTitle) .endClass(); luabridge::getGlobalNamespace(L) .beginClass("System") .addFunction("SetFuncRun", &System::lua_SetFuncUpdate) .addFunction("Start", (void(System::*)(const ParamWindow&)) & System::Start) .endClass(); auto result = luabridge::push(L, g_system); lua_setglobal(L, "system"); } void lua_register_gfx(lua_State* L) { luabridge::getGlobalNamespace(L) .beginClass("Graphics") .addFunction("Rectangle2D", &Graphics::Rectangle2D) .endClass(); auto result = luabridge::push(L, g_gfx); lua_setglobal(L, "gfx"); } }