summaryrefslogtreecommitdiff
path: root/Editor
diff options
context:
space:
mode:
Diffstat (limited to 'Editor')
-rw-r--r--Editor/EditorMain.cpp42
-rw-r--r--Editor/Path.cpp0
-rw-r--r--Editor/Path.h0
-rw-r--r--Editor/Win/Win.cpp18
-rw-r--r--Editor/Win/Win.h14
5 files changed, 46 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
diff --git a/Editor/Path.cpp b/Editor/Path.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Editor/Path.cpp
diff --git a/Editor/Path.h b/Editor/Path.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Editor/Path.h
diff --git a/Editor/Win/Win.cpp b/Editor/Win/Win.cpp
new file mode 100644
index 0000000..f6310e2
--- /dev/null
+++ b/Editor/Win/Win.cpp
@@ -0,0 +1,18 @@
+#include "win.h"
+
+namespace Win
+{
+
+ std::string GetCurrentWorkingDirectory()
+ {
+ char path[MAX_PATH];
+ GetCurrentDirectory(MAX_PATH, path);
+ return path;
+ }
+
+ void SetDllSearchDirectory(std::string path)
+ {
+ SetDllDirectory(path.c_str());
+ }
+
+} \ No newline at end of file
diff --git a/Editor/Win/Win.h b/Editor/Win/Win.h
new file mode 100644
index 0000000..cbbba4c
--- /dev/null
+++ b/Editor/Win/Win.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#include <windows.h>
+#include <string>
+
+// windows 辅助函数
+
+namespace Win
+{
+
+ std::string GetCurrentWorkingDirectory();
+ void SetDllSearchDirectory(std::string path);
+
+}