mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Editor window
This commit is contained in:
@@ -5,32 +5,19 @@ using GlitchyEngine.Math;
|
||||
|
||||
namespace GlitchyEditor.EditWindows
|
||||
{
|
||||
class ComponentEditWindow
|
||||
class ComponentEditWindow : EditorWindow
|
||||
{
|
||||
public const String s_WindowTitle = "Components";
|
||||
|
||||
private Editor _editor;
|
||||
|
||||
private bool _open = true;
|
||||
|
||||
public Editor Editor => _editor;
|
||||
|
||||
public bool Open
|
||||
{
|
||||
get => _open;
|
||||
set => _open = value;
|
||||
}
|
||||
|
||||
public this(Editor editor)
|
||||
{
|
||||
_editor = editor;
|
||||
}
|
||||
|
||||
public void Show()
|
||||
protected override void InternalShow()
|
||||
{
|
||||
if(!_open)
|
||||
return;
|
||||
|
||||
if(!ImGui.Begin(s_WindowTitle, &_open, .None))
|
||||
{
|
||||
ImGui.End();
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
namespace GlitchyEditor.EditWindows
|
||||
{
|
||||
abstract class EditorWindow
|
||||
{
|
||||
protected Editor _editor;
|
||||
|
||||
protected bool _open = true;
|
||||
protected bool _hasFocus;
|
||||
|
||||
public bool Open
|
||||
{
|
||||
get => _open;
|
||||
set => _open = value;
|
||||
}
|
||||
|
||||
public bool HasFocus
|
||||
{
|
||||
get => _hasFocus;
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
if(!_open)
|
||||
return;
|
||||
|
||||
InternalShow();
|
||||
}
|
||||
|
||||
protected abstract void InternalShow();
|
||||
}
|
||||
}
|
||||
@@ -10,35 +10,22 @@ namespace GlitchyEditor.EditWindows
|
||||
using internal GlitchyEditor;
|
||||
|
||||
/// A window for viewing and editing the scene hierarchy
|
||||
class EntityHierarchyWindow
|
||||
class EntityHierarchyWindow : EditorWindow
|
||||
{
|
||||
public const String s_WindowTitle = "Entity Hierarchy";
|
||||
|
||||
private Editor _editor;
|
||||
|
||||
/// Buffer for the entity search string.
|
||||
private char8[64] _entitySearchChars;
|
||||
|
||||
private bool _open = true;
|
||||
|
||||
public Editor Editor => _editor;
|
||||
|
||||
public bool Open
|
||||
{
|
||||
get => _open;
|
||||
set => _open = value;
|
||||
}
|
||||
|
||||
public this(Editor editor)
|
||||
{
|
||||
_editor = editor;
|
||||
}
|
||||
|
||||
public void Show()
|
||||
protected override void InternalShow()
|
||||
{
|
||||
if(!_open)
|
||||
return;
|
||||
|
||||
if(!ImGui.Begin(s_WindowTitle, &_open, .MenuBar))
|
||||
{
|
||||
ImGui.End();
|
||||
|
||||
@@ -8,32 +8,16 @@ using ImGuizmo;
|
||||
|
||||
namespace GlitchyEditor.EditWindows
|
||||
{
|
||||
class SceneViewportWindow
|
||||
class SceneViewportWindow : EditorWindow
|
||||
{
|
||||
private Editor _editor;
|
||||
public Camera _camera;
|
||||
|
||||
public const String s_WindowTitle = "Scene";
|
||||
|
||||
private bool _open = true;
|
||||
|
||||
private RenderTarget2D _renderTarget ~ _?.ReleaseRef();
|
||||
|
||||
private bool _hasFocus;
|
||||
|
||||
public Event<EventHandler<Vector2>> ViewportSizeChangedEvent ~ _.Dispose();
|
||||
|
||||
public bool Open
|
||||
{
|
||||
get => _open;
|
||||
set => _open = value;
|
||||
}
|
||||
|
||||
public bool HasFocus
|
||||
{
|
||||
get => _hasFocus;
|
||||
}
|
||||
|
||||
public RenderTarget2D RenderTarget
|
||||
{
|
||||
get => _renderTarget;
|
||||
@@ -54,11 +38,8 @@ namespace GlitchyEditor.EditWindows
|
||||
private ImGui.Vec2 oldViewportSize;
|
||||
private bool viewPortChanged;
|
||||
|
||||
public void Show()
|
||||
protected override void InternalShow()
|
||||
{
|
||||
if(!_open)
|
||||
return;
|
||||
|
||||
ImGui.PushStyleVar(.WindowPadding, ImGui.Vec2(1, 1));
|
||||
defer ImGui.PopStyleVar();
|
||||
|
||||
@@ -83,6 +64,20 @@ namespace GlitchyEditor.EditWindows
|
||||
ImGui.Image(_renderTarget, viewportSize);
|
||||
}
|
||||
|
||||
DrawImGuizmo(viewportSize);
|
||||
|
||||
ImGui.End();
|
||||
|
||||
if(oldViewportSize != viewportSize)
|
||||
{
|
||||
ViewportSizeChangedEvent.Invoke(this, (Vector2)viewportSize);
|
||||
viewPortChanged = true;
|
||||
oldViewportSize = viewportSize;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawImGuizmo(ImGui.Vec2 viewportSize)
|
||||
{
|
||||
ImGuizmo.SetDrawlist();
|
||||
|
||||
var topLeft = ImGui.GetWindowPos();
|
||||
@@ -112,15 +107,6 @@ namespace GlitchyEditor.EditWindows
|
||||
|
||||
transformCmp.LocalTransform = transform;
|
||||
}
|
||||
|
||||
ImGui.End();
|
||||
|
||||
if(oldViewportSize != viewportSize)
|
||||
{
|
||||
ViewportSizeChangedEvent.Invoke(this, (Vector2)viewportSize);
|
||||
viewPortChanged = true;
|
||||
oldViewportSize = viewportSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user