summaryrefslogtreecommitdiff
path: root/Editor/EditorMain.cpp
blob: 182a2c4c36418fe149c7733d4cb91118226d2e6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#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;

void ErrorHandle(cc8* msg)
{
	log_error(std::string("[Lua] ") + msg);
}

void InitLuaState() 
{
	LuaBind::VM vm;
	vm.Setup();
	vm.OpenLibs();
	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);

    state.DoFile("./boot.lua", ErrorHandle);
	state.DoFile("./Scripts/EditorApplication.lua", ErrorHandle);
}

#ifdef GAMELAB_DEBUG
int main()
#else 
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
#endif
{
    WindowUtil::RegisterClasses();

	InitLuaState();

	return 0;
}