From 998a13b08c43b0813d1d4d38692ea7f8bd31c936 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 21 Oct 2021 16:11:45 +0800 Subject: *misc --- Editor/EditorMain.cpp | 20 ++++++++++++++++++-- Editor/GUI/GUIWindow.cpp | 5 +---- Editor/GUI/IMGUI/GUIButton.cpp | 0 Editor/IMGUI/GUIButton.cpp | 0 4 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 Editor/GUI/IMGUI/GUIButton.cpp delete mode 100644 Editor/IMGUI/GUIButton.cpp (limited to 'Editor') 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 diff --git a/Editor/GUI/GUIWindow.cpp b/Editor/GUI/GUIWindow.cpp index 107a298..0502b21 100644 --- a/Editor/GUI/GUIWindow.cpp +++ b/Editor/GUI/GUIWindow.cpp @@ -45,10 +45,7 @@ LRESULT CALLBACK GUIWindow::GUIViewWndProc(HWND hWnd, UINT message, WPARAM wPara { log_info("WndProc", "WM_PAINT"); self->SetAsRenderContext(); - glEnable(GL_BLEND); - glClearColor(1,0,0,1); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glFlush(); + BeginPaint(self->m_Handle, &ps); EndPaint(self->m_Handle, &ps); UpdateWindow(self->m_Handle); diff --git a/Editor/GUI/IMGUI/GUIButton.cpp b/Editor/GUI/IMGUI/GUIButton.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Editor/IMGUI/GUIButton.cpp b/Editor/IMGUI/GUIButton.cpp deleted file mode 100644 index e69de29..0000000 -- cgit v1.1-26-g67d0