summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-11-20 20:29:08 +0800
committerchai <chaifix@163.com>2021-11-20 20:29:08 +0800
commit0944b2f95b9971d62f35b9dcc38d28a27e278249 (patch)
tree3cd71eff172b394655bf69bf23ec3eb6eb471256
parentbb452bba78dc1870d6316b383180472fe3a8a06a (diff)
* mv gui to editor
-rw-r--r--Data/BuiltIn/Libraries/GameLab/Engine/GUI/init.lua3
-rw-r--r--Data/Libraries/GameLab/Editor/GUI/GUIState.lua (renamed from Data/BuiltIn/Libraries/GameLab/Engine/GUI/GUIState.lua)2
-rw-r--r--Data/Libraries/GameLab/Editor/GUI/IMGUI.lua (renamed from Data/BuiltIn/Libraries/GameLab/Engine/GUI/IMGUI.lua)49
-rw-r--r--Data/Libraries/GameLab/Editor/GUI/init.lua4
-rw-r--r--Data/Libraries/GameLab/Editor/Window/GUIWindow.lua11
-rw-r--r--Data/Libraries/GameLab/Editor/Window/SplitWindow.lua3
-rw-r--r--Data/boot.lua3
-rw-r--r--Runtime/Scripting/GL/GL.bind.cpp6
-rw-r--r--Runtime/Scripting/RuntimeScriptGlobals.cpp8
9 files changed, 48 insertions, 41 deletions
diff --git a/Data/BuiltIn/Libraries/GameLab/Engine/GUI/init.lua b/Data/BuiltIn/Libraries/GameLab/Engine/GUI/init.lua
index 3012551..2eb8ac2 100644
--- a/Data/BuiltIn/Libraries/GameLab/Engine/GUI/init.lua
+++ b/Data/BuiltIn/Libraries/GameLab/Engine/GUI/init.lua
@@ -1,7 +1,4 @@
local GUI = GameLab.Package("GameLab.Engine.GUI")
local import = GameLab.Import(...)
-import "GUIState"
-import "imgui"
-
return GUI \ No newline at end of file
diff --git a/Data/BuiltIn/Libraries/GameLab/Engine/GUI/GUIState.lua b/Data/Libraries/GameLab/Editor/GUI/GUIState.lua
index bb4884e..b45dc6b 100644
--- a/Data/BuiltIn/Libraries/GameLab/Engine/GUI/GUIState.lua
+++ b/Data/Libraries/GameLab/Editor/GUI/GUIState.lua
@@ -1,4 +1,4 @@
-local GUIState = GameLab.GlobalStaticClass("GameLab.Engine.GUI.GUIState")
+local GUIState = GameLab.GlobalStaticClass("GameLab.Editor.GUI.GUIState")
local hotControl = 0
local currentId = 0 -- 当前可分配的controlID
diff --git a/Data/BuiltIn/Libraries/GameLab/Engine/GUI/IMGUI.lua b/Data/Libraries/GameLab/Editor/GUI/IMGUI.lua
index 3c99622..2f47c80 100644
--- a/Data/BuiltIn/Libraries/GameLab/Engine/GUI/IMGUI.lua
+++ b/Data/Libraries/GameLab/Editor/GUI/IMGUI.lua
@@ -1,13 +1,12 @@
-local GUI = GameLab.Package("GameLab.Engine.GUI")
+local EditorGUI = GameLab.Package("GameLab.Editor.GUI")
local find = GameLab.Find
-local EditorGUI = GameLab.Editor.GUI
-
local Debug = GameLab.Debug
-local GUIState = GUI.GUIState
+local GUIState = EditorGUI.GUIState
local Event = GameLab.Events.Event
local GL = GameLab.Engine.GL
+local GUI = GameLab.Engine.GUI
local Matrix44 = find "GameLab.Engine.Math.Matrix44"
local Rendering = GameLab.Engine.Rendering
local EEventType = GameLab.Events.EEventType
@@ -23,19 +22,19 @@ if GAMELAB_EDITOR then
elseif GAMELAB_RUNNER then
end
-GUI.BeginOnGUI = function()
+EditorGUI.BeginOnGUI = function()
GUIState.ResetControlID()
end
-GUI.EndOnGUI = function()
+EditorGUI.EndOnGUI = function()
GUIState.ResetControlID()
end
-GUI.BeginFrame = function()
+EditorGUI.BeginFrame = function()
GUIState.ResetControlID()
end
-GUI.EndFrame = function()
+EditorGUI.EndFrame = function()
GUIState.ResetControlID()
end
@@ -43,19 +42,19 @@ end
-- Controls
------------------------------------------------------------------------------------------------
-GUI.Button = function(rect, content )
+EditorGUI.Button = function(rect, content )
end
-GUI.Toggle = function()
+EditorGUI.Toggle = function()
end
-GUI.Label = function()
+EditorGUI.Label = function()
end
-GUI.Box = function(rect, color)
+EditorGUI.Box = function(rect, color)
if Event.current.type == EEventType.Repaint then
Rendering.UseShader(editor_res.shaders["EditorShape"])
Rendering.SetVector2("gamelab_ui_position", rect.position)
@@ -64,44 +63,44 @@ GUI.Box = function(rect, color)
end
end
-GUI.BoxFrame = function(rect, color)
+EditorGUI.BoxFrame = function(rect, color)
if Event.current.type == EEventType.Repaint then
- GUI.Line(Vector2(rect.x, rect.y), Vector2(rect.x + rect.w, rect.y), color)
- GUI.Line(Vector2(rect.x + rect.w, rect.y), Vector2(rect.x + rect.w, rect.y + rect.h), color)
- GUI.Line(Vector2(rect.x + rect.w, rect.y + rect.h), Vector2(rect.x, rect.y + rect.h), color)
- GUI.Line(Vector2(rect.x, rect.y + rect.h), Vector2(rect.x, rect.y), color)
+ EditorGUI.Line(Vector2(rect.x, rect.y), Vector2(rect.x + rect.w, rect.y), color)
+ EditorGUI.Line(Vector2(rect.x + rect.w, rect.y), Vector2(rect.x + rect.w, rect.y + rect.h), color)
+ EditorGUI.Line(Vector2(rect.x + rect.w, rect.y + rect.h), Vector2(rect.x, rect.y + rect.h), color)
+ EditorGUI.Line(Vector2(rect.x, rect.y + rect.h), Vector2(rect.x, rect.y), color)
end
end
-GUI.HorizontalSlider = function()
+EditorGUI.HorizontalSlider = function()
end
-GUI.VerticalSlider = function()
+EditorGUI.VerticalSlider = function()
end
-GUI.TextField = function()
+EditorGUI.TextField = function()
end
-GUI.TextArea = function()
+EditorGUI.TextArea = function()
end
-GUI.Toolbar = function()
+EditorGUI.Toolbar = function()
end
-GUI.VerticalScrollbar = function()
+EditorGUI.VerticalScrollbar = function()
end
-GUI.HorizontalScrollbar = function()
+EditorGUI.HorizontalScrollbar = function()
end
-GUI.Line = function(from, to, color)
+EditorGUI.Line = function(from, to, color)
if Event.current.type ~= EEventType.Repaint then
return
end
diff --git a/Data/Libraries/GameLab/Editor/GUI/init.lua b/Data/Libraries/GameLab/Editor/GUI/init.lua
index 0f01d9f..4c715b5 100644
--- a/Data/Libraries/GameLab/Editor/GUI/init.lua
+++ b/Data/Libraries/GameLab/Editor/GUI/init.lua
@@ -1,5 +1,7 @@
local GUI = GameLab.Package("GameLab.Editor.GUI")
+local import = GameLab.Import(...)
-
+import "GUIState"
+import "imgui"
return GUI \ 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 9290b1e..ceb026e 100644
--- a/Data/Libraries/GameLab/Editor/Window/GUIWindow.lua
+++ b/Data/Libraries/GameLab/Editor/Window/GUIWindow.lua
@@ -7,7 +7,7 @@ local Math = require "GameLab.Engine.Math"
local Rendering = require "GameLab.Engine.Rendering"
local Utils = require "GameLab.Utils"
local Events = require "GameLab.Events"
-local GUI = require "GameLab.Engine.GUI"
+local GUI = require "GameLab.Editor.GUI"
local Rect = Math.Rect
local Event = Events.Event
@@ -29,6 +29,7 @@ local col = {
local kSideBorders = 2 -- GUIView的右边距
local kTabHeight = 17 -- 标题栏高度
local kBottomBorders = 2 -- 底部边距
+local kEditorSpace = 2
local GUIWindow = GameLab.GlobalClass("GameLab.Editor.Window.GUIWindow", function(self)
self.m_Native = NativeGUIWindow.New(self) -- native guiwindow
@@ -121,12 +122,18 @@ GUIWindow.OnGUI = function(self)
ortho:SetOrtho(0, windowSize.x, windowSize.y, 0, 0.1, 10)
Rendering.SetMatrix44("gamelab_mat_mvp", ortho)
- --
+ -- 框架
local guiSize = Vector2(windowSize.x - kSideBorders*2, windowSize.y - kSideBorders*2)
local bgRect = Rect(kSideBorders, kSideBorders, guiSize.x, guiSize.y)
GUI.Box(bgRect, Color(0.22, 0.22, 0.22, 1))
GUI.BoxFrame(bgRect, Color(0.13, 0.13, 0.13, 1))
+ -- 编辑器
+ local editorPos = Vector2(kSideBorders + kEditorSpace, kSideBorders + kEditorSpace + kTabHeight)
+ local editorRect = Rect(editorPos.x, editorPos.y, windowSize.x - editorPos.x * 2, windowSize.y - editorPos.y)
+ GL.Viewport(editorRect.x, windowSize.y - editorRect.height - editorPos.y, editorRect.width, editorRect.height)
+ GUI.Line(Vector2(0,0), Vector2(100, 100), Color(1,0,0,1))
+
end
GUIWindow.GetContainerWindow = function(self)
diff --git a/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua b/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua
index cd8d3a3..a06fee8 100644
--- a/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua
+++ b/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua
@@ -8,9 +8,10 @@ local ECursor = GameLab.Editor.Window.ECursor
local Window = GameLab.Editor.Window
local Vector2 = GameLab.Engine.Math.Vector2
local Utils = GameLab.Utils
+local EditorGUI = GameLab.Editor.GUI
local Rect = Math.Rect
-local GUIState = GUI.GUIState
+local GUIState = EditorGUI.GUIState
local Splitter = GameLab.Class("GameLab.Editor.Window.Internal.Splitter")
diff --git a/Data/boot.lua b/Data/boot.lua
index 6807de6..d1261c3 100644
--- a/Data/boot.lua
+++ b/Data/boot.lua
@@ -39,10 +39,11 @@ require "GameLab.Engine.Rendering"
require "GameLab.Engine.Resource"
require "GameLab.Engine.GL"
require "GameLab.Editor"
+require "GameLab.Editor.GUI"
require "GameLab.Editor.Window"
-- debugging
---require("LuaPanda").start("127.0.0.1",8818)
+require("LuaPanda").start("127.0.0.1",8818)
-- launch editor
dofile("./Scripts/EditorApplication.lua")
diff --git a/Runtime/Scripting/GL/GL.bind.cpp b/Runtime/Scripting/GL/GL.bind.cpp
index caf3877..5260378 100644
--- a/Runtime/Scripting/GL/GL.bind.cpp
+++ b/Runtime/Scripting/GL/GL.bind.cpp
@@ -180,12 +180,12 @@ int Viewport(lua_State* L)
{
LUA_BIND_STATE(L);
- float left = state.GetValue<float>(1, 0);
- float right = state.GetValue<float>(2, 0);
+ float x = state.GetValue<float>(1, 0);
+ float y = state.GetValue<float>(2, 0);
float width = state.GetValue<float>(3, 0);
float height = state.GetValue<float>(4, 0);
- glViewport(left, right, width, height);
+ glViewport(x, y, width, height);
return 0;
}
diff --git a/Runtime/Scripting/RuntimeScriptGlobals.cpp b/Runtime/Scripting/RuntimeScriptGlobals.cpp
index bb3139c..76de265 100644
--- a/Runtime/Scripting/RuntimeScriptGlobals.cpp
+++ b/Runtime/Scripting/RuntimeScriptGlobals.cpp
@@ -7,9 +7,9 @@ namespace Scripting
{
globals.setCurrentEvent = "GameLab.Events.Event.SetCurrentEvent";
- globals.guiBeginFrame = "GameLab.Engine.GUI.BeginFrame";
- globals.guiEndFrame = "GameLab.Engine.GUI.EndFrame";
- globals.guiBeginOnGUI = "GameLab.Engine.GUI.BeginOnGUI";
- globals.guiEndOnGUI = "GameLab.Engine.GUI.EndOnGUI";
+ globals.guiBeginFrame = "GameLab.Editor.GUI.BeginFrame";
+ globals.guiEndFrame = "GameLab.Editor.GUI.EndFrame";
+ globals.guiBeginOnGUI = "GameLab.Editor.GUI.BeginOnGUI";
+ globals.guiEndOnGUI = "GameLab.Editor.GUI.EndOnGUI";
}
} \ No newline at end of file