summaryrefslogtreecommitdiff
path: root/Editor/EditorMain.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-10-21 16:11:45 +0800
committerchai <chaifix@163.com>2021-10-21 16:11:45 +0800
commit998a13b08c43b0813d1d4d38692ea7f8bd31c936 (patch)
tree20ce144f9897c47d5840e34929ca32be8f2cc2c6 /Editor/EditorMain.cpp
parentf2dcd16fc72e2f10c9504897bacf5c4c2ecff516 (diff)
*misc
Diffstat (limited to 'Editor/EditorMain.cpp')
-rw-r--r--Editor/EditorMain.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/Editor/EditorMain.cpp b/Editor/EditorMain.cpp
index 182a2c4..95937a7 100644
--- a/Editor/EditorMain.cpp
+++ b/Editor/EditorMain.cpp
@@ -15,24 +15,40 @@ void ErrorHandle(cc8* msg)
log_error(std::string("[Lua] ") + msg);
}
+void OnRegisterFactoryClass(LuaBind::State& state, int cls, std::string clsName, std::string pkgName)
+{
+ // 填充类型的元数据
+ lua_newtable(state);
+ int typeIdx = state.GetTop();
+ state.Push("native");
+ state.SetField(typeIdx, "mode");
+ state.Push(clsName);
+ state.SetField(typeIdx, "name");
+ state.Push(pkgName);
+ state.SetField(typeIdx, "package");
+ lua_setfield(state, cls, "_type");
+}
+
void InitLuaState()
{
LuaBind::VM vm;
vm.Setup();
vm.OpenLibs();
+
+ LuaBind::onRegisterFactoryClass = OnRegisterFactoryClass;
+
if (!SetupGameLabEditorScripting(vm.GetMainThread()))
{
log_error("Can't setup scripting.");
}
- LuaBind::State state = vm.GetMainState();
// https://stackoverflow.com/questions/21495901/loadlibrarya-and-relative-path/21495971
// ll_load装载dll,路径需要设置搜索路径
std::string workingDir = Win::GetCurrentWorkingDirectory();
Win::SetDllSearchDirectory(workingDir);
+ LuaBind::State state = vm.GetMainState();
state.DoFile("./boot.lua", ErrorHandle);
- state.DoFile("./Scripts/EditorApplication.lua", ErrorHandle);
}
#ifdef GAMELAB_DEBUG