diff options
author | chai <chaifix@163.com> | 2021-10-17 23:05:01 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-17 23:05:01 +0800 |
commit | 7c8c68d79343d04be382334c15a73d079450857c (patch) | |
tree | 9aaacc042f0b7eeb4123c07dcc5f49c14fd8026c /Editor | |
parent | 6e73ca6ada8a41692809dae5db89c8db0675ce1e (diff) |
*misc
Diffstat (limited to 'Editor')
-rw-r--r-- | Editor/EditorMain.cpp | 24 | ||||
-rw-r--r-- | Editor/GUI/EditorWindows.h | 11 | ||||
-rw-r--r-- | Editor/GUI/GUIWindow.cpp | 14 | ||||
-rw-r--r-- | Editor/Scripting/EditorGUI/ContainerWindow.bind.cpp | 29 | ||||
-rw-r--r-- | Editor/Scripting/EditorGUI/EditorGUI.bind.cpp | 19 | ||||
-rw-r--r-- | Editor/Scripting/EditorScripting.cpp | 17 | ||||
-rw-r--r-- | Editor/Scripting/EditorScripting.h | 3 | ||||
-rw-r--r-- | Editor/Scripts/EditorApplication.lua | 15 | ||||
-rw-r--r-- | Editor/Shaders/BuiltinShaders.cpp | 2 | ||||
-rw-r--r-- | Editor/Shaders/BuiltinShaders.h | 3 |
10 files changed, 102 insertions, 35 deletions
diff --git a/Editor/EditorMain.cpp b/Editor/EditorMain.cpp index 8fea1df..9745598 100644 --- a/Editor/EditorMain.cpp +++ b/Editor/EditorMain.cpp @@ -1,11 +1,13 @@ #include <windows.h>
#include <vector>
#include "GUI/EditorWindows.h"
-#include "Runtime/Scripting/LuaBind.h"
+#include "Runtime/LuaBind/LuaBind.h"
#include "EditorManager.h"
#include "Runtime/Graphics/OpenGL.h"
#include "Editor/Scripting/EditorScripting.h"
+using namespace LuaBind;
+
static int MainLoop() {
BOOL returnValue; @@ -37,6 +39,20 @@ void OpenLogTags() {
//log_open_tag("WndProc");
//log_open_tag("Menu");
+ log_open_tag("Scripting");
+}
+
+void InitLuaState()
+{
+ LuaBind::VM vm;
+ vm.Setup();
+ vm.OpenLibs();
+ if (!SetupGameLabEditorScripting(vm.GetMainThread()))
+ {
+ log_error("Can't setup scripting.");
+ }
+ LuaBind::State state = vm.GetMainState();
+ state.DoFile("./Scripts/EditorApplication.lua");
}
#ifdef GAMELAB_DEBUG
@@ -48,11 +64,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) OpenLogTags();
WindowUtil::Init();
- if (!SetupGameLabEditorScripting())
- {
- log_error("Can't setup scripting.");
- return 0;
- }
+ InitLuaState();
ContainnerWindow* wnd = new ContainnerWindow();
Vector2f min = Vector2f(100, 100);
diff --git a/Editor/GUI/EditorWindows.h b/Editor/GUI/EditorWindows.h index 8a146e2..42d2623 100644 --- a/Editor/GUI/EditorWindows.h +++ b/Editor/GUI/EditorWindows.h @@ -4,13 +4,15 @@ #include <windows.h> #include <vector> #include "Runtime/Math/Rect.h" -#include "Runtime/Scripting/LuaBind.h" +#include "Runtime/LuaBind/LuaBind.h" #include "Runtime/Utilities/Singleton.h" #include "Editor/Utils/Log.h" #include "Runtime/Graphics/OpenGL.h" #include "Runtime/Utilities/UtilMacros.h" #include "Editor/Utils/HelperFuncs.h" +using namespace LuaBind; + class GUIWindow; class WindowUtil @@ -35,7 +37,8 @@ private: }; // 一个containner window中有多个viewport -class ContainnerWindow +class ContainnerWindow + : public LuaBind::NativeClass<ContainnerWindow> { public: static LRESULT CALLBACK ContainerWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); @@ -85,6 +88,10 @@ private: POINT m_MinSize; POINT m_MaxSize; + LUA_BIND_DECL_FACTORY(ContainnerWindow); + LUA_BIND_DECL_METHOD(_SetTitle); + LUA_BIND_DECL_METHOD(_DoPaint); + }; // 窗口基类 diff --git a/Editor/GUI/GUIWindow.cpp b/Editor/GUI/GUIWindow.cpp index 1fe88ca..e58b620 100644 --- a/Editor/GUI/GUIWindow.cpp +++ b/Editor/GUI/GUIWindow.cpp @@ -4,18 +4,18 @@ static bool RedirectMouseWheel(HWND window, WPARAM wParam, LPARAM lParam) { - //// prevent reentrancy + /// prevent reentrancy //static bool s_ReentrancyCheck = false; //if (s_ReentrancyCheck) // return false; - //// 找到对应的子窗口 + /// 找到对应的子窗口 //GUIWindow* view = GetMouseOverWindow(); //if (!view) // return false; - //// 将鼠标滚轮事件派发到子窗口上去 - //// send mouse wheel to view under mouse + /// 将鼠标滚轮事件派发到子窗口上去 + /// send mouse wheel to view under mouse //s_ReentrancyCheck = true; //::SendMessage(view->GetWindowHandle(), WM_MOUSEWHEEL, wParam, lParam); //s_ReentrancyCheck = false; @@ -56,6 +56,8 @@ LRESULT CALLBACK GUIWindow::GUIViewWndProc(HWND hWnd, UINT message, WPARAM wPara case WM_MOUSEWHEEL: // 在这个子窗口滚动 { + log_info("WM_MOUSEWHEEL"); + // quick check if mouse is in our window RECT rc; POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; @@ -68,7 +70,7 @@ LRESULT CALLBACK GUIWindow::GUIViewWndProc(HWND hWnd, UINT message, WPARAM wPara return 0; } - Assert(self->m_Handle != hWnd); + //Assert(self->m_Handle != hWnd); //self->ProcessEventMessages(message, wParam, lParam); return 0; } @@ -172,7 +174,7 @@ void GUIWindow::RepaintAll() { } -////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////// void GUIWindow::ProcessEventMessages(UINT message, WPARAM wParam, LPARAM lParam) { diff --git a/Editor/Scripting/EditorGUI/ContainerWindow.bind.cpp b/Editor/Scripting/EditorGUI/ContainerWindow.bind.cpp index e69de29..f51b6b4 100644 --- a/Editor/Scripting/EditorGUI/ContainerWindow.bind.cpp +++ b/Editor/Scripting/EditorGUI/ContainerWindow.bind.cpp @@ -0,0 +1,29 @@ +#include "Editor/GUI/EditorWindows.h" + +LUA_BIND_REGISTRY(ContainnerWindow) +{ + LUA_BIND_REGISTER_METHODS(state, + { "SetTitle", _SetTitle }, + { "DoPaint", _DoPaint } + ); +} + +LUA_BIND_POSTPROCESS(ContainnerWindow) +{ +} + +LUA_BIND_IMPL_METHOD(ContainnerWindow, _SetTitle) +{ + LUA_BIND_PREPARE(L, ContainnerWindow); + + + + return 0; +} + +LUA_BIND_IMPL_METHOD(ContainnerWindow, _DoPaint) +{ + LUA_BIND_PREPARE(L, ContainnerWindow); + self->DoPaint(); + return 0; +}
\ No newline at end of file diff --git a/Editor/Scripting/EditorGUI/EditorGUI.bind.cpp b/Editor/Scripting/EditorGUI/EditorGUI.bind.cpp index 139597f..be97638 100644 --- a/Editor/Scripting/EditorGUI/EditorGUI.bind.cpp +++ b/Editor/Scripting/EditorGUI/EditorGUI.bind.cpp @@ -1,2 +1,21 @@ +#include "Editor/GUI/EditorWindows.h" +// GameLab.Editor.GUI +void luaopen_GameLab_Editor_GUI(lua_State* L) +{ + LUA_BIND_STATE(L); + state.PushGlobalNamespace(); + + state.PushNamespace("GameLab"); + state.PushNamespace("Editor"); + state.PushNamespace("GUI"); + + state.RegisterFactory<ContainnerWindow>(); + + state.PopNamespace();// EditorGUI + state.PopNamespace();// GameLab + state.PopNamespace();// Editor + state.PopNamespace();// Global + +}
\ No newline at end of file diff --git a/Editor/Scripting/EditorScripting.cpp b/Editor/Scripting/EditorScripting.cpp index 7f1d90c..235636a 100644 --- a/Editor/Scripting/EditorScripting.cpp +++ b/Editor/Scripting/EditorScripting.cpp @@ -1,15 +1,22 @@ #include "EditorScripting.h" #include "Editor/Utils/Log.h" -extern void SetupEditorGUI(); -extern void SetupEditorGUILayout(); -extern void SetupEditorIMGUI(); -extern void SetupEditorResource(); +// GameLab.Editor +extern void luaopen_GameLab_Editor_GUI(lua_State* L); // GameLab.Editor.GUI +extern void luaopen_GameLab_Editor_GUILayout(lua_State* L); // GameLab.Editor.GUILayout +extern void luaopen_GameLab_Editor_IMGUI(lua_State* L); // GameLab.Editor.IMGUI +extern void luaopen_GameLab_Editor_Resource(lua_State* L); // GameLab.Editor.Resource -bool SetupGameLabEditorScripting() +// GameLab.Engine + +// GameLab +extern void luaopen_GameLab_Debug(lua_State* L); + +bool SetupGameLabEditorScripting(lua_State* L) { log_info("Scripting", "SetupGameLabEditorScripting()"); + luaopen_GameLab_Editor_GUI(L); return true; } diff --git a/Editor/Scripting/EditorScripting.h b/Editor/Scripting/EditorScripting.h index 8d32a9d..2ed2233 100644 --- a/Editor/Scripting/EditorScripting.h +++ b/Editor/Scripting/EditorScripting.h @@ -1,3 +1,4 @@ #pragma once +#include "Runtime/LuaBind/LuaBind.h" -bool SetupGameLabEditorScripting(); +bool SetupGameLabEditorScripting(lua_State* L); diff --git a/Editor/Scripts/EditorApplication.lua b/Editor/Scripts/EditorApplication.lua deleted file mode 100644 index fb37d69..0000000 --- a/Editor/Scripts/EditorApplication.lua +++ /dev/null @@ -1,15 +0,0 @@ -local Editor = GameLab.Editor -local Engine = GameLab.Engine - -local ViewEditor = {} - -function ViewEditor:OnGUI() - -end - - --- Editor - -local view = Editor.ContainnerWindow.New(ViewEditor) - - diff --git a/Editor/Shaders/BuiltinShaders.cpp b/Editor/Shaders/BuiltinShaders.cpp new file mode 100644 index 0000000..139597f --- /dev/null +++ b/Editor/Shaders/BuiltinShaders.cpp @@ -0,0 +1,2 @@ + + diff --git a/Editor/Shaders/BuiltinShaders.h b/Editor/Shaders/BuiltinShaders.h new file mode 100644 index 0000000..45dcbb0 --- /dev/null +++ b/Editor/Shaders/BuiltinShaders.h @@ -0,0 +1,3 @@ +#pragma once + + |