diff options
Diffstat (limited to 'Editor/EditorMain.cpp')
-rw-r--r-- | Editor/EditorMain.cpp | 20 |
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
|