summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Data/BuiltIn/Libraries/GameLab/Engine/Math/Vector2.lua8
-rw-r--r--Data/Libraries/GameLab/Editor/GUI/IMGUI.lua10
-rw-r--r--Data/Libraries/GameLab/Editor/Window/GUIWindow.lua24
-rw-r--r--Data/Resources/Shaders/Editor-Text.glsl7
-rw-r--r--Data/Scripts/EditorResources.lua10
5 files changed, 48 insertions, 11 deletions
diff --git a/Data/BuiltIn/Libraries/GameLab/Engine/Math/Vector2.lua b/Data/BuiltIn/Libraries/GameLab/Engine/Math/Vector2.lua
index 24aa233..0fd66c9 100644
--- a/Data/BuiltIn/Libraries/GameLab/Engine/Math/Vector2.lua
+++ b/Data/BuiltIn/Libraries/GameLab/Engine/Math/Vector2.lua
@@ -26,6 +26,14 @@ function Vector2:get_yx()
return v
end
+function Vector2:get_height()
+ return self.y
+end
+
+function Vector2:get_width()
+ return self.x
+end
+
function Vector2:Set(other)
self.x = other.x
self.y = other.y
diff --git a/Data/Libraries/GameLab/Editor/GUI/IMGUI.lua b/Data/Libraries/GameLab/Editor/GUI/IMGUI.lua
index 2f47c80..f76dc38 100644
--- a/Data/Libraries/GameLab/Editor/GUI/IMGUI.lua
+++ b/Data/Libraries/GameLab/Editor/GUI/IMGUI.lua
@@ -50,8 +50,14 @@ EditorGUI.Toggle = function()
end
-EditorGUI.Label = function()
-
+EditorGUI.Label = function(rect, content, color)
+ if Event.current.type ~= EEventType.Repaint then
+ return
+ end
+ Rendering.UseShader(editor_res.shaders["EditorShape"])
+ Rendering.SetVector2("gamelab_ui_position", rect.position)
+ Rendering.SetColor("gamelab_color", color)
+ GUI.DrawText(editor_res.fonts["Default"], content, rect.size.height)
end
EditorGUI.Box = function(rect, color)
diff --git a/Data/Libraries/GameLab/Editor/Window/GUIWindow.lua b/Data/Libraries/GameLab/Editor/Window/GUIWindow.lua
index ceb026e..b7f373d 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.Editor.GUI"
+local EditorGUI = require "GameLab.Editor.GUI"
local Rect = Math.Rect
local Event = Events.Event
@@ -125,17 +125,33 @@ GUIWindow.OnGUI = function(self)
-- 框架
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))
+ EditorGUI.Box(bgRect, Color(0.22, 0.22, 0.22, 1))
+ EditorGUI.BoxFrame(bgRect, Color(0.13, 0.13, 0.13, 1))
+
+ -- title
+ local titleRect = Rect(kSideBorders, kSideBorders, windowSize.width - kSideBorders*2, kTabHeight)
+ EditorGUI.Label(titleRect, "hello", Color(1,1,1,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))
+ EditorGUI.Line(Vector2(0,0), Vector2(100, 100), Color(1,0,0,1))
end
+GUIWindow.DoTitle = function(self)
+
+end
+
+GUIWindow.DoTab = function(self)
+
+end
+
+GUIWindow.DoEditorWindows = function(self)
+
+end
+
GUIWindow.GetContainerWindow = function(self)
return self.m_ContainerWindow
end
diff --git a/Data/Resources/Shaders/Editor-Text.glsl b/Data/Resources/Shaders/Editor-Text.glsl
index 7db820c..79f4d5d 100644
--- a/Data/Resources/Shaders/Editor-Text.glsl
+++ b/Data/Resources/Shaders/Editor-Text.glsl
@@ -9,14 +9,13 @@ CMD_END
uniform mat4 gamelab_mat_mvp;
uniform sampler2D gamelab_main_tex;
uniform vec2 gamelab_ui_position;
+uniform vec4 gamelab_color;
VSH_BEGIN
layout (location = 0) in vec2 vPos;
layout (location = 1) in vec2 vUV;
-layout (location = 2) in vec4 vColor;
out vec2 uv;
-out vec4 color;
void main()
{
@@ -24,20 +23,18 @@ void main()
vec4 clip = gamelab_mat_mvp * vec4(pos, -1, 1.0);
gl_Position = clip;
uv = vUV;
- color = vColor;
}
VSH_END
FSH_BEGIN
in vec2 uv;
-in vec4 color;
out vec4 FragColor;
void main()
{
vec4 sampled = vec4(1,1,1,texture(gamelab_main_tex, uv).r);
- sampled *= color;
+ sampled *= gamelab_color;
FragColor = sampled;
}
FSH_END
diff --git a/Data/Scripts/EditorResources.lua b/Data/Scripts/EditorResources.lua
index bcefec4..63e8069 100644
--- a/Data/Scripts/EditorResources.lua
+++ b/Data/Scripts/EditorResources.lua
@@ -3,6 +3,7 @@ local find = GameLab.Find
local Shader = find "GameLab.Engine.Rendering.Shader"
local Texture = find "GameLab.Engine.Rendering.Texture"
local Rendering = find "GameLab.Engine.Rendering"
+local GUI = find "GameLab.Engine.GUI"
local SHADER = function(path)
local file = 'Resources/Shaders/' .. path
@@ -14,6 +15,11 @@ local TEXTURE = function(path)
-- return Rendering.CreateShaderFromFile(file)
end
+local FONT = function(path)
+ local file = 'Resources/Font/' .. path
+ return GUI.Font.New(file, {512, 512}, 5, 5)
+end
+
local res = {}
local loadRes = function()
@@ -22,6 +28,10 @@ local loadRes = function()
["EditorText"] = SHADER "Editor-Text.glsl",
["EditorUI"] = SHADER "Editor-UI.glsl",
}
+
+ res.fonts = {
+ ["Default"] = FONT "msyh.ttc"
+ }
end
GameLab.onApplicationStart:Add(loadRes)