diff options
author | chai <chaifix@163.com> | 2021-11-17 00:46:58 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-11-17 00:46:58 +0800 |
commit | 9421ca53788e51a92b28056e06af3d9dd6b4d92c (patch) | |
tree | 045519df1b7eacbadd8af5df79c1367869514dc8 | |
parent | 1f5b75d39721ad40483f1b188af2e965fbe205ac (diff) |
*rename
22 files changed, 161 insertions, 55 deletions
diff --git a/Data/BuiltIn/Libraries/GameLab/Class.lua b/Data/BuiltIn/Libraries/GameLab/Class.lua index db8e2b2..e30aab7 100644 --- a/Data/BuiltIn/Libraries/GameLab/Class.lua +++ b/Data/BuiltIn/Libraries/GameLab/Class.lua @@ -5,6 +5,7 @@ local TRACKCLASSINSTANCES = false
local PROPERTY = true
+local METADATA = true
local index = function(self, key)
local c = getmetatable(self)
@@ -43,13 +44,15 @@ local newclass = function (name, ctor) pkg = string.match(name, "^(.+)%.%w+$")
short = string.match(name, "%.*(%w+)$")
end
-
- c._type = {
- mode = "lua",
- name = short,
- package = pkg,
- fullName = name
- }
+
+ if METADATA then
+ c._type = {
+ mode = "lua",
+ name = short,
+ package = pkg,
+ fullName = name
+ }
+ end
if PROPERTY then
c.__index = index
diff --git a/Data/BuiltIn/Libraries/GameLab/Containers/init.lua b/Data/BuiltIn/Libraries/GameLab/Containers/init.lua index 685c95a..a121278 100644 --- a/Data/BuiltIn/Libraries/GameLab/Containers/init.lua +++ b/Data/BuiltIn/Libraries/GameLab/Containers/init.lua @@ -1,7 +1,7 @@ local m = GameLab.Package("GameLab.Containers")
local import = GameLab.Import(...)
-import("Tuple")
-import("Array")
+import "Tuple"
+import "Array"
return m
\ No newline at end of file diff --git a/Data/BuiltIn/Libraries/GameLab/Engine/Math/init.lua b/Data/BuiltIn/Libraries/GameLab/Engine/Math/init.lua index e7c0164..71523d5 100644 --- a/Data/BuiltIn/Libraries/GameLab/Engine/Math/init.lua +++ b/Data/BuiltIn/Libraries/GameLab/Engine/Math/init.lua @@ -2,14 +2,14 @@ local math = GameLab.Package("GameLab.Engine.Math") local import = GameLab.Import(...)
-import("Math")
-import("Vector2")
-import("Vector3")
-import("Vector4")
-import("Matrix44")
-import("Matrix33")
-import("Quaternion")
-import("Rect")
+import "Math"
+import "Vector2"
+import "Vector3"
+import "Vector4"
+import "Matrix44"
+import "Matrix33"
+import "Quaternion"
+import "Rect"
GameLab.Debug.Log("GameLab.Engine.Math loaded")
diff --git a/Data/BuiltIn/Libraries/GameLab/Engine/Rendering/init.lua b/Data/BuiltIn/Libraries/GameLab/Engine/Rendering/init.lua index 68441ab..9966ea2 100644 --- a/Data/BuiltIn/Libraries/GameLab/Engine/Rendering/init.lua +++ b/Data/BuiltIn/Libraries/GameLab/Engine/Rendering/init.lua @@ -4,9 +4,9 @@ local import = GameLab.Import(...) local Shader = GameLab.Engine.Rendering.Shader -m.Color = import("Color") -m.Color32 = import("Color32") -m.Shader = import("Shader") +m.Color = import "Color" +m.Color32 = import "Color32" +m.Shader = import "Shader" m.LoadTexture = function(path) diff --git a/Data/BuiltIn/Libraries/GameLab/Engine/Resource/init.lua b/Data/BuiltIn/Libraries/GameLab/Engine/Resource/init.lua index feff63f..63eb9b6 100644 --- a/Data/BuiltIn/Libraries/GameLab/Engine/Resource/init.lua +++ b/Data/BuiltIn/Libraries/GameLab/Engine/Resource/init.lua @@ -13,7 +13,7 @@ local import = GameLab.Import(...) ---------------------------------------------------------------------------------- -- classes ---------------------------------------------------------------------------------- -m.ImageDataRequest = import("ImageDataRequest") +m.ImageDataRequest = import "ImageDataRequest" ---------------------------------------------------------------------------------- -- methods diff --git a/Data/BuiltIn/Libraries/GameLab/Events/init.lua b/Data/BuiltIn/Libraries/GameLab/Events/init.lua index 7bfb648..54c2612 100644 --- a/Data/BuiltIn/Libraries/GameLab/Events/init.lua +++ b/Data/BuiltIn/Libraries/GameLab/Events/init.lua @@ -1,6 +1,6 @@ local Events = GameLab.Package("GameLab.Events")
local import = GameLab.Import(...)
-import("Event")
+import "Event"
return Events
\ No newline at end of file diff --git a/Data/BuiltIn/Libraries/GameLab/init.lua b/Data/BuiltIn/Libraries/GameLab/init.lua index 7305b9d..b0c3780 100644 --- a/Data/BuiltIn/Libraries/GameLab/init.lua +++ b/Data/BuiltIn/Libraries/GameLab/init.lua @@ -29,15 +29,15 @@ end local import = GameLab.Import(...)
-import("Package")
-import("Class")
-import("GlobalClass")
-import("Enum")
-import("GlobalEnum")
-import("GlobalTable")
-import("Delegate")
-import("EventListener")
-import("StaticClass")
-import("GlobalStaticClass")
+import "Package"
+import "Class"
+import "GlobalClass"
+import "Enum"
+import "GlobalEnum"
+import "GlobalTable"
+import "Delegate"
+import "EventListener"
+import "StaticClass"
+import "GlobalStaticClass"
return GameLab
\ No newline at end of file diff --git a/Data/Libraries/GameLab/Editor/Window/GUIWindow.lua b/Data/Libraries/GameLab/Editor/Window/GUIWindow.lua index 483f2b3..2df0e49 100644 --- a/Data/Libraries/GameLab/Editor/Window/GUIWindow.lua +++ b/Data/Libraries/GameLab/Editor/Window/GUIWindow.lua @@ -14,6 +14,8 @@ local Rect = Math.Rect local Event = Events.Event
local Vector2 = Math.Vector2
+local clone = Utils.Clone
+
local i = 0
local col = {
{1, 0, 0, 1},
@@ -28,18 +30,44 @@ GUIWindow.Ctor = function(self) self.m_SplitWindow = nil -- parent window
self.m_Position = Rect(0,0,0,0) -- 在父ContainerWindow中的位置和大小
self.m_EditorWindows = {} -- 编辑器脚本
+ self.m_CurEditor = nil
i = i + 1
self.m_ClearColor = col[i]
end
+GUIWindow.get_editorWindows = function(self)
+ return self.m_EditorWindows
+end
+
+GUIWindow.get_containerWindow = function(self)
+ return self.m_ContainerWindow
+end
+
+GUIWindow.get_splitWindow = function(self)
+ return self.m_SplitWindow
+end
+
+GUIWindow.get_currentEditorWindow = function(self)
+ return self.m_CurEditor
+end
+
+GUIWindow.get_position = function(self)
+ return self.m_Position
+end
+
+GUIWindow.set_position = function(self, position)
+ self.m_Position:Set(position)
+ self.m_Native:SetPosition({position.x, position.y, position.width, position.height})
+end
+
GUIWindow.SetContainerWindow = function(self, containerWindow)
self.m_ContainerWindow = containerWindow
self.m_Native:SetContainerWindow(containerWindow:GetNative())
end
-GUIWindow.AddEditorWindow = function(self)
-
+GUIWindow.AddEditorWindow = function(self, editorWindow)
+ table.insert(self.m_EditorWindows, editorWindow)
end
GUIWindow.SetPosition = function(self, pos)
@@ -55,15 +83,16 @@ GUIWindow.GetNative = function(self) return self.m_Native
end
+-- 最主要的回调函数,同时处理窗口管理、事件、布局、渲染
GUIWindow.OnGUI = function(self)
self:ClearBackground()
local event = Event.current
- if self.m_SplitWindow ~= nil and event ~= nil then
- local e = Events.CopyEvent(event)
+ if self.splitWindow ~= nil and event ~= nil then
+ local e = clone(event)
e.mousePosition:Add(self.m_Position:GetPosition()) -- 坐标转换到全局containerWindow的坐标
- self.m_SplitWindow:DoSplit(e)
+ self.splitWindow:DoSplit(e)
end
end
diff --git a/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua b/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua index 2a01e53..fea443d 100644 --- a/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua +++ b/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua @@ -66,6 +66,16 @@ SplitWindow.set_containerWindow = function(self, wnd) self.m_ContainerWindow = wnd end +SplitWindow.get_position = function(self) + return self.m_Position +end + +SplitWindow.set_position = function(self, position) + if position:Is(Rect) then + self:SetPosition(position) + end +end + -- 布局,设置GUIWindow的大小 SplitWindow.DoSplit = function(self, event) if self.m_Parent ~= nil then @@ -112,7 +122,7 @@ SplitWindow.DoSplit = function(self, event) splitter.value = mousePos.y / self.m_Position.height end splitter.value = Math.Clamp(splitter.value, 0, 1) - self:SetPosition(self.m_Position) + self.position = self.m_Position end end elseif event.type == EEventType.MouseUp then @@ -138,7 +148,7 @@ SplitWindow.SetPosition = function(self, position) pos.y = pos.y + prev * position.height pos.height = position.height * (next - prev) end - subWindow:SetPosition(pos) + subWindow.position = pos end end diff --git a/Data/Libraries/GameLab/Editor/Window/init.lua b/Data/Libraries/GameLab/Editor/Window/init.lua index ff99dd9..84cb46d 100644 --- a/Data/Libraries/GameLab/Editor/Window/init.lua +++ b/Data/Libraries/GameLab/Editor/Window/init.lua @@ -1,9 +1,9 @@ local m = GameLab.Package("GameLab.Editor.Window")
local import = GameLab.Import(...)
-import("ContainerWindow")
-import("GUIWindow")
-import("SplitWindow")
+import "ContainerWindow"
+import "GUIWindow"
+import "SplitWindow"
--[[
GameLab编辑器窗口
diff --git a/Data/Libraries/GameLab/Editor/init.lua b/Data/Libraries/GameLab/Editor/init.lua index b33a9e1..94486f8 100644 --- a/Data/Libraries/GameLab/Editor/init.lua +++ b/Data/Libraries/GameLab/Editor/init.lua @@ -1,7 +1,7 @@ local m = GameLab.Package("GameLab.Editor")
local import = GameLab.Import(...)
-m.AssetManager = import("AssetManager")
-m.EditorWindow = import("EditorWindow")
+m.AssetManager = import "AssetManager"
+m.EditorWindow = import "EditorWindow"
return m
\ No newline at end of file diff --git a/Data/Scripts/EditorGUI/EditorWindowManager.lua b/Data/Scripts/EditorGUI/EditorWindowManager.lua index c28379a..2c5b21c 100644 --- a/Data/Scripts/EditorGUI/EditorWindowManager.lua +++ b/Data/Scripts/EditorGUI/EditorWindowManager.lua @@ -71,7 +71,7 @@ EditorWindowManager.TestGUIWindow = function() position.width = mainWindowSize.x
position.height = mainWindowSize.y
- splitWnd:SetPosition(position)
+ splitWnd.position = position
EditorWindowManager.mainWindow:SetRootSplitWindow(splitWnd)
diff --git a/Documents/Lua.xlsx b/Documents/Lua.xlsx Binary files differindex 3911a16..a32ac9b 100644 --- a/Documents/Lua.xlsx +++ b/Documents/Lua.xlsx diff --git a/Editor/GUI/GUIWindow.cpp b/Editor/GUI/GUIWindow.cpp index 19ceb85..028a654 100644 --- a/Editor/GUI/GUIWindow.cpp +++ b/Editor/GUI/GUIWindow.cpp @@ -8,6 +8,32 @@ #include "Editor/Scripting/EditorScriptingManager.h" using namespace LuaBind; +using namespace std; + +GUIWindowProxy::GUIWindowProxy(GUIWindow *owner, LuaBind::MemberRef script) +{ + +} + +void GUIWindowProxy::OnGUI(LuaBind::State& state) +{ + MemberInvoker invoker = MemberInvoker(state, owner); + invoker.member = script; + invoker.method = "OnGUI"; + invoker.AddMember(script); + invoker.Invoke(0); +} + +void GUIWindowProxy::DoGUI() +{ + LuaBind::State state = owner->GetVM()->GetCurThread(); + + + + OnGUI(state); +} + +//------------------------------------------------------------------------------------ static bool RedirectMouseWheel(HWND window, WPARAM wParam, LPARAM lParam) { @@ -210,7 +236,6 @@ void GUIWindow::RepaintAll() GUIWindow::GUIWindow(LuaBind::VM* vm, std::string name) : LuaBind::NativeClass<GUIWindow>(vm) - , m_Script() { log_info("Init GUIWindow"); diff --git a/Editor/GUI/GUIWindow.h b/Editor/GUI/GUIWindow.h index aed38d9..bbf2687 100644 --- a/Editor/GUI/GUIWindow.h +++ b/Editor/GUI/GUIWindow.h @@ -14,6 +14,25 @@ #include "Runtime/Utilities/Exception.h" #include "WindowUtil.h" +class GUIWindow; + +class GUIWindowProxy : public LuaObjectProxy +{ +public: + GUIWindow * owner; + LuaBind::MemberRef script; + + GUIWindowProxy() {} + GUIWindowProxy(GUIWindow *owner, LuaBind::MemberRef script); + + void DoGUI(); + void DoClean(); + +private: + void OnGUI(LuaBind::State& state); + +}; + // GUIڣ¼ӦơֵĵԪ class GUIWindow : public WindowBase @@ -47,6 +66,7 @@ private: std::string m_Name; LuaBind::MemberRef m_Script; + GUIWindowProxy m_Instance; BOOL m_MouseTracking; DWORD m_MouseHoverTime; diff --git a/Editor/Scripting/Window/GUIWindow.bind.cpp b/Editor/Scripting/Window/GUIWindow.bind.cpp index 604c26a..7fc0d4d 100644 --- a/Editor/Scripting/Window/GUIWindow.bind.cpp +++ b/Editor/Scripting/Window/GUIWindow.bind.cpp @@ -22,12 +22,20 @@ LUA_BIND_IMPL_METHOD(GUIWindow, _New) LUA_BIND_STATE(L, GUIWindow); LUA_BIND_CHECK(L, "T"); + if (!LuaHelper::IsType(state, "GameLab.Editor.Window.GUIWindow", -1)) + { + state.ErrorType(-1, "GameLab.Editor.Window.GUIWindow"); + return 0; + } + GUIWindow* wnd = new GUIWindow(state.GetVM()); - if (LuaHelper::IsType(state, "GameLab.Editor.Window.GUIWindow", -1)) - wnd->SetMemberRef(state, wnd->m_Script, -1); + wnd->SetMemberRef(state, wnd->m_Script, -1); + wnd->m_Instance.owner = wnd; + wnd->m_Instance.script = wnd->m_Script; wnd->PushUserdata(state); + return 1; } diff --git a/Projects/VisualStudio/Editor/Editor.vcxproj b/Projects/VisualStudio/Editor/Editor.vcxproj index bdf16ca..f9f04eb 100644 --- a/Projects/VisualStudio/Editor/Editor.vcxproj +++ b/Projects/VisualStudio/Editor/Editor.vcxproj @@ -328,6 +328,7 @@ <ClInclude Include="..\..\..\Runtime\Lua\LuaBind\LuaBindVM.h" />
<ClInclude Include="..\..\..\Runtime\Lua\LuaBind\LuaBindWatchDog.h" />
<ClInclude Include="..\..\..\Runtime\Lua\LuaHelper.h" />
+ <ClInclude Include="..\..\..\Runtime\Lua\LuaObjectProxy.h" />
<ClInclude Include="..\..\..\Runtime\Math\AABB.h" />
<ClInclude Include="..\..\..\Runtime\Math\FloatConversion.h" />
<ClInclude Include="..\..\..\Runtime\Math\Math.h" />
diff --git a/Projects/VisualStudio/Editor/Editor.vcxproj.filters b/Projects/VisualStudio/Editor/Editor.vcxproj.filters index 5d837a3..9873bca 100644 --- a/Projects/VisualStudio/Editor/Editor.vcxproj.filters +++ b/Projects/VisualStudio/Editor/Editor.vcxproj.filters @@ -756,6 +756,9 @@ <ClInclude Include="..\..\..\Editor\EditorGlobals.h">
<Filter>Editor\Scripting</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\Runtime\Lua\LuaObjectProxy.h">
+ <Filter>Runtime\Lua</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\Runtime\Lua\LuaBind\LuaBindClass.inc">
diff --git a/Runtime/Graphics/ShaderCompiler.cpp b/Runtime/Graphics/ShaderCompiler.cpp index 20b19f5..bc601a8 100644 --- a/Runtime/Graphics/ShaderCompiler.cpp +++ b/Runtime/Graphics/ShaderCompiler.cpp @@ -21,11 +21,11 @@ std::string s_CompileError = ""; void GLSLCompiler::Compile(std::string& src, std::string& vsh, std::string& fsh, RenderCommandGroup& group)/*throw GLSLCompileException*/
{
#define CheckLabel(label) {\
-int pos = src.find(label);\
-if(pos == string::npos || !IsLabelActive(src, label)) {\
- s_CompileError = std::string("Compile Shader Error: No ") + #label + " label";\
- throw GLSLCompileException(s_CompileError.c_str());\
-}}
+ int pos = src.find(label);\
+ if(pos == string::npos || !IsLabelActive(src, label)) {\
+ s_CompileError = std::string("Compile Shader Error: No ") + #label + " label";\
+ throw GLSLCompileException(s_CompileError.c_str());\
+ }}
CheckLabel(VSH_BEGIN);
CheckLabel(VSH_END);
diff --git a/Runtime/Lua/LuaBind/LuaBindClass.hpp b/Runtime/Lua/LuaBind/LuaBindClass.hpp index a5ac978..27b3261 100644 --- a/Runtime/Lua/LuaBind/LuaBindClass.hpp +++ b/Runtime/Lua/LuaBind/LuaBindClass.hpp @@ -60,6 +60,8 @@ namespace LuaBind // userdataһref tableԳԻuserdata template<class DATATYPE> void Release(State& state, DATATYPE* userdata); + LuaBind::VM* GetVM() { return mOwner; } + // userdata pushջûгʼmUserdataʼúԪѳʼõ // userdataջһáһnativeȨƽluaƵķ bool PushUserdata(State& state) override; @@ -87,8 +89,6 @@ namespace LuaBind NativeClass(LuaBind::VM* vm); virtual ~NativeClass(); - LuaBind::VM* GetVM() { return mOwner; } - // Աùʵref tableáȡ void SetMemberRef(State& state, MemberRef& memRef, int idx); bool PushMemberRef(State& state, MemberRef& memRef); diff --git a/Runtime/Lua/LuaHelper.h b/Runtime/Lua/LuaHelper.h index 1c18620..04fc3ef 100644 --- a/Runtime/Lua/LuaHelper.h +++ b/Runtime/Lua/LuaHelper.h @@ -1,5 +1,6 @@ #pragma once
#include "./LuaBind/LuaBind.h"
+#include "LuaObjectProxy.h"
// lua 5.1 doc: https://www.lua.org/manual/5.1/
diff --git a/Runtime/Lua/LuaObjectProxy.h b/Runtime/Lua/LuaObjectProxy.h new file mode 100644 index 0000000..e5d1b41 --- /dev/null +++ b/Runtime/Lua/LuaObjectProxy.h @@ -0,0 +1,6 @@ +#pragma once + +// access lua side object's field and methods +class LuaObjectProxy +{ +};
\ No newline at end of file |