From 8446078851f5430e8315d6618d8d5dd9d6e3d1ab Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 19 Oct 2021 02:21:47 +0800 Subject: +LuaPanda --- Editor/EditorMain.cpp | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) (limited to 'Editor/EditorMain.cpp') diff --git a/Editor/EditorMain.cpp b/Editor/EditorMain.cpp index f8ee4ef..5e0cf99 100644 --- a/Editor/EditorMain.cpp +++ b/Editor/EditorMain.cpp @@ -1,40 +1,15 @@ #include #include + #include "GUI/EditorWindows.h" #include "Runtime/Lua/LuaBind/LuaBind.h" #include "EditorManager.h" #include "Runtime/Graphics/OpenGL.h" #include "Editor/Scripting/EditorScripting.h" +#include "Editor/Win/Win.h" using namespace LuaBind; -static int MainLoop() -{ - BOOL returnValue; - MSG msg, lastMsg; - msg.message = WM_NULL; - std::vector messages; - PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE); - bool isQuitSignaled = msg.message == WM_QUIT; - - while (!isQuitSignaled) - { - MSG msg; - while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE) != 0) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - - if (msg.message == WM_QUIT) - isQuitSignaled = true; - - } - - } - - return (INT)msg.wParam; -} - void ErrorHandle(cc8* msg) { log_error(std::string("[Lua] ") + msg); @@ -50,7 +25,18 @@ void InitLuaState() log_error("Can't setup scripting."); } LuaBind::State state = vm.GetMainState(); - state.DoFile("./Scripts/EditorApplication.lua", ErrorHandle); + + // https://stackoverflow.com/questions/21495901/loadlibrarya-and-relative-path/21495971 + // ll_load装载dll,路径需要设置搜索路径 + //log_info(Win::GetCurrentWorkingDirectory()); + std::string workingDir = Win::GetCurrentWorkingDirectory(); + Win::SetDllSearchDirectory(workingDir); + + // set cpath + state.DoString(R"(package.path=package.path .. ";" .. ".\\Libraries\\?.lua")"); + state.DoString(R"(package.cpath=package.cpath .. ";" .. ".\\Libraries\\?.dll")"); + + state.DoFile(".\\Scripts\\EditorApplication.lua", ErrorHandle); } #ifdef GAMELAB_DEBUG -- cgit v1.1-26-g67d0