summaryrefslogtreecommitdiff
path: root/Editor/EditorMain.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-10-19 02:21:47 +0800
committerchai <chaifix@163.com>2021-10-19 02:21:47 +0800
commit8446078851f5430e8315d6618d8d5dd9d6e3d1ab (patch)
treeecbbd9ae71367eebf3a4e414373f92a3f0a2cd44 /Editor/EditorMain.cpp
parent45c05ac5610416e75a123995af649681d43adf7f (diff)
+LuaPanda
Diffstat (limited to 'Editor/EditorMain.cpp')
-rw-r--r--Editor/EditorMain.cpp42
1 files changed, 14 insertions, 28 deletions
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 <windows.h>
#include <vector>
+
#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<MSG> 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