Almost entirely moved ImGui dependency (and settings) from Engine to Editor

This commit is contained in:
Simon Lübeß
2026-08-09 16:49:54 +02:00
parent faa3040471
commit f8e533f28d
19 changed files with 98 additions and 55 deletions
+8 -1
View File
@@ -4,13 +4,16 @@ FileVersion = 1
Name = "GlitchyEditor"
TargetType = "BeefGUIApplication"
StartupObject = "GlitchyEngine.Program"
ProcessorMacros = ["GE_EDITOR_IMGUI_DEMO"]
ProcessorMacros = ["GE_EDITOR_IMGUI_DEMO", "GE_GRAPHICS_DX11"]
[Dependencies]
corlib = "*"
GlitchLog = "*"
GlitchyEngine = "*"
Xml-Beef = "*"
ImGuiImplDX11 = "*"
ImGuiImplWin32 = "*"
ImGuizmo = "*"
[Platform.Windows]
IconFile = "$(ProjectDir)/Resources/Textures/GlitchyEngineIcon.ico"
@@ -18,9 +21,13 @@ IconFile = "$(ProjectDir)/Resources/Textures/GlitchyEngineIcon.ico"
[Configs.Debug.Win64]
PostBuildCmds = ["CopyFilesIfNewer(\"$(WorkspaceDir)/bin/vswhere.exe\", \"$(TargetDir)\")"]
DebugCommandArguments = "\"D:\\Development\\Git\\SingleStateToOrbit\""
PreprocessorMacros = ["DEBUG", "IMGUI"]
[Configs.Release.Win64]
TargetDirectory = "$(BuildDir)/dist"
PostBuildCmds = ["CopyFilesIfNewer(\"$(WorkspaceDir)/bin/vswhere.exe\", \"$(TargetDir)\")"]
DebugCommandArguments = "\"D:\\Development\\Git\\SingleStateToOrbit\""
PreprocessorMacros = ["RELEASE", "IMGUI"]
[Configs.Paranoid.Win64]
PostBuildCmds = ["CopyFilesIfNewer(\"$(WorkspaceDir)/bin/vswhere.exe\", \"$(TargetDir)\")"]
@@ -22,7 +22,7 @@ class RiderIdeAdapter : IIdeAdapter
Editor.Instance.CurrentProject.GetPathToScriptSolutionFile(solutionPath);
ProcessStartInfo startInfo = scope .();
startInfo.SetFileName(Application.Instance.Settings.ScriptSettings.RiderPath);
startInfo.SetFileName(EditorApp.Instance.Settings.ScriptSettings.RiderPath);
startInfo.SetArguments(scope $"{solutionPath} --line {lineNumber} {fileName}");
scope SpawnedProcess().Start(startInfo);
@@ -39,7 +39,7 @@ class RiderIdeAdapter : IIdeAdapter
return;
}
if (!File.Exists(Application.Instance.Settings.ScriptSettings.RiderPath))
if (!File.Exists(EditorApp.Instance.Settings.ScriptSettings.RiderPath))
{
Editor.Instance.ShowSettings();
Editor.Instance.SettingsWindow.HighlightSetting("Tools", "Rider path");
@@ -51,7 +51,7 @@ class RiderIdeAdapter : IIdeAdapter
}
ProcessStartInfo startInfo = scope .();
startInfo.SetFileName(Application.Instance.Settings.ScriptSettings.RiderPath);
startInfo.SetFileName(EditorApp.Instance.Settings.ScriptSettings.RiderPath);
startInfo.SetArguments(solutionPath);
scope SpawnedProcess().Start(startInfo);
@@ -31,7 +31,7 @@ class VisualStudioIdeAdapter : IIdeAdapter
if (IsRunning())
{
ProcessStartInfo startInfo = scope .();
startInfo.SetFileName(Application.Instance.Settings.ScriptSettings.VisualStudioPath);
startInfo.SetFileName(EditorApp.Instance.Settings.ScriptSettings.VisualStudioPath);
startInfo.SetArguments(scope $"/Edit {fileName}");
scope SpawnedProcess().Start(startInfo);
@@ -39,7 +39,7 @@ class VisualStudioIdeAdapter : IIdeAdapter
else
{
ProcessStartInfo startInfo = scope .();
startInfo.SetFileName(Application.Instance.Settings.ScriptSettings.VisualStudioPath);
startInfo.SetFileName(EditorApp.Instance.Settings.ScriptSettings.VisualStudioPath);
startInfo.SetArguments(scope $"/Edit {fileName}");
scope SpawnedProcess().Start(startInfo);
@@ -604,7 +604,7 @@ namespace GlitchyEditor.EditWindows
if (ImGui.MenuItem("Open C# Project..."))
{
switch (Application.Instance.Settings.ScriptSettings.SelectedIde)
switch (EditorApp.Instance.Settings.ScriptSettings.SelectedIde)
{
case .VisualStudio:
VisualStudioIdeAdapter.OpenScriptProject();
+28 -1
View File
@@ -11,6 +11,8 @@ using GlitchyEditor.Multithreading;
using System.Threading;
using GlitchyEditor.Platform;
using System.Diagnostics;
using GlitchyEditor.ImGui;
using GlitchyEngine.Events;
namespace GlitchyEditor
{
@@ -23,6 +25,14 @@ namespace GlitchyEditor
private append BackgroundTaskManager _backgroundTaskManager = .();
public BackgroundTaskManager BackgroundTaskManager => _backgroundTaskManager;
#if IMGUI
private ImGuiLayer _imGuiLayer;
#endif
private EditorLayer _editorLayer;
public Settings Settings { get; private set; } = new .() ~ delete _;
public this(String[] args)
{
@@ -38,11 +48,28 @@ namespace GlitchyEditor
DragDropManager.Init();
PushLayer(new EditorLayer(args, _contentManager));
#if IMGUI
_imGuiLayer = new ImGuiLayer();
PushOverlay(_imGuiLayer);
#endif
_editorLayer = new EditorLayer(args, _contentManager);
PushLayer(_editorLayer);
GlitchyEditor.Settings.Load();
Settings.OnApplySettings.Add(new (s, e) => {
OnEvent(scope SettingsAppliedEvent());
});
Settings.Apply();
}
public ~this()
{
// TODO: We should clear the queue of _backgroundTaskManager
// TODO: We should maybe also notify the user that that would happen!
PopLayer(_editorLayer);
DragDropManager.Deinit();
_backgroundTaskManager.Deinit();
+13 -10
View File
@@ -4,7 +4,6 @@ using ImGui;
using GlitchyEngine;
using GlitchyEditor.EditWindows;
using GlitchyEngine.Events;
using GlitchyEngine.ImGui;
using GlitchyEngine.Math;
using GlitchyEngine.Renderer;
using GlitchyEngine.World;
@@ -17,6 +16,7 @@ using GlitchyEngine.Core;
using GlitchyEditor.Assets;
using GlitchyEngine.Scripting;
using GlitchyEditor.Platform.Windows;
using GlitchyEditor.ImGui;
namespace GlitchyEditor
{
@@ -777,8 +777,8 @@ namespace GlitchyEditor
if (Directory.Exists(project.WorkspacePath))
{
Application.Instance.Settings.EditorSettings.LastOpenedProject = project.WorkspacePath;
Application.Instance.Settings.Save();
EditorApp.Instance.Settings.EditorSettings.LastOpenedProject = project.WorkspacePath;
EditorApp.Instance.Settings.Save();
}
return .Ok;
@@ -811,7 +811,7 @@ namespace GlitchyEditor
Log.EngineLogger.AssertDebug(_scriptSerializer.SerializedObjectCount == 0, "Somehow some entities are serialized.");
if (Application.Instance.Settings.EditorSettings.ClearLogOnPlay)
if (EditorApp.Instance.Settings.EditorSettings.ClearLogOnPlay)
Editor.Instance.LogWindow.ClearLog();
_scriptSerializer.SerializeScriptInstances();
@@ -830,7 +830,7 @@ namespace GlitchyEditor
_editor.CurrentScene = _activeScene;
if (Application.Instance.Settings.EditorSettings.SwitchToPlayerOnPlay)
if (EditorApp.Instance.Settings.EditorSettings.SwitchToPlayerOnPlay)
SwitchToPlayWindow();
}
@@ -887,7 +887,7 @@ namespace GlitchyEditor
_editor.CurrentScene = _activeScene;
if (Application.Instance.Settings.EditorSettings.SwitchToPlayerOnSimulate)
if (EditorApp.Instance.Settings.EditorSettings.SwitchToPlayerOnSimulate)
SwitchToPlayWindow();
}
@@ -896,7 +896,7 @@ namespace GlitchyEditor
{
_isPaused = true;
if (Application.Instance.Settings.EditorSettings.SwitchToEditorOnPause)
if (EditorApp.Instance.Settings.EditorSettings.SwitchToEditorOnPause)
SwitchToEditorWindow();
}
@@ -905,7 +905,7 @@ namespace GlitchyEditor
{
_isPaused = false;
if (Application.Instance.Settings.EditorSettings.SwitchToPlayerOnResume)
if (EditorApp.Instance.Settings.EditorSettings.SwitchToPlayerOnResume)
SwitchToPlayWindow();
}
@@ -918,6 +918,9 @@ namespace GlitchyEditor
/// Stops the simulation or game and returns to edit mode.
private void OnSceneStop()
{
if (_activeScene == null)
return;
SetActiveScene(_editorScene, startRuntime: true, startSimulation: false, newPlayMode: .Editor);
// TODO: _editorScene.DeserializeScripts(scriptData);
@@ -939,7 +942,7 @@ namespace GlitchyEditor
GameViewportSizeChanged(null, _editor.GameViewportWindow.RenderedViewportSize);
}
if (Application.Instance.Settings.EditorSettings.SwitchToEditorOnStop)
if (EditorApp.Instance.Settings.EditorSettings.SwitchToEditorOnStop)
SwitchToEditorWindow();
// Reconstruct state before play
@@ -1394,7 +1397,7 @@ namespace GlitchyEditor
private void ShowOpenRecentProjectMenu()
{
let recentProjects = Application.Instance.Settings.EditorSettings.RecentProjects;
let recentProjects = EditorApp.Instance.Settings.EditorSettings.RecentProjects;
if (recentProjects == null)
return;
+1 -1
View File
@@ -8,7 +8,7 @@ using System.IO;
using System.Diagnostics;
using System.Threading;
namespace GlitchyEngine
namespace GlitchyEditor
{
extension Settings
{
@@ -2,9 +2,10 @@
using System;
using ImGui;
using GlitchyEngine;
using GlitchyEngine.Events;
using ImGuizmo;
using GlitchyEngine.Renderer;
using ImGuizmo;
using System.IO;
using internal ImGui;
@@ -17,7 +18,7 @@ using internal GlitchyEngine.Platform.DX11;
#endif
namespace GlitchyEngine.ImGui
namespace GlitchyEditor.ImGui
{
public class ImGuiLayer : Layer
{
@@ -91,7 +92,7 @@ namespace GlitchyEngine.ImGui
private void LoadFont()
{
var settings = Application.Instance.Settings.ImGuiSettings;
var settings = EditorApp.Instance.Settings.ImGuiSettings;
ImGui.GetIO().Fonts.Clear();
@@ -256,6 +257,11 @@ namespace GlitchyEngine.ImGui
ImGui.RenderPlatformWindowsDefault();
}
}
public override void Update(GameTime gameTime)
{
ImGuiRender();
}
}
}
@@ -8,7 +8,7 @@ namespace GlitchyEngine.Events
}
}
namespace GlitchyEngine.ImGui
namespace GlitchyEditor.ImGui
{
public class ImGuiRenderEvent : Event, IEvent
{
+1 -1
View File
@@ -461,7 +461,7 @@ class Project
bool referenceScriptCoreProject = false;
#if DEBUG
Settings settings = Application.Instance.Settings;
Settings settings = EditorApp.Instance.Settings;
referenceScriptCoreProject = settings.DevSettings.UseScriptCoreDll;
#endif
@@ -3,8 +3,9 @@ using ImGui;
using System.Collections;
using System.IO;
using Bon;
using GlitchyEngine;
namespace GlitchyEngine
namespace GlitchyEditor
{
interface ISettings
{
@@ -84,7 +85,7 @@ namespace GlitchyEngine
public static void Load()
{
Settings settings = Application.Get().Settings;
Settings settings = EditorApp.Instance.Settings;
if (!File.Exists("./settings.bon"))
{
@@ -96,7 +97,7 @@ namespace GlitchyEngine
if (result case .Err)
Log.EngineLogger.Error("Failed to deserialze settings.");
Application.Get().Settings.Apply();
settings.Apply();
}
public void Save()
@@ -138,7 +139,7 @@ namespace GlitchyEngine
public void Apply()
{
Application.Instance.[Friend]_imGuiLayer.SettingsInvalid = true;
EditorApp.Instance.[Friend]_imGuiLayer.SettingsInvalid = true;
}
}
#endif
+1 -1
View File
@@ -59,7 +59,7 @@ namespace GlitchyEditor
{
_open = false;
_settings = Application.Instance.Settings;
_settings = EditorApp.Instance.Settings;
Create();
}
+3 -6
View File
@@ -11,10 +11,6 @@ DirectX = "*"
FreeType = "*"
cgltf-beef = "*"
msdfgen-beef = "*"
ImGui = "*"
ImGuiImplDX11 = "*"
ImGuiImplWin32 = "*"
ImGuizmo = "*"
Beefy2D = "*"
LodePng = "*"
GlitchyEngineHelper = "*"
@@ -22,6 +18,7 @@ bon = "*"
box2d-beef = "*"
"Beef.Linq" = "*"
NetHostBeef = "*"
ImGuiImplWin32 = "*"
[Configs.Paranoid.Win32]
PreprocessorMacros = ["DEBUG", "PARANOID", "GE_WINDOWS"]
@@ -33,7 +30,7 @@ PreprocessorMacros = ["DEBUG", "PARANOID", "GE_WINDOWS"]
PreprocessorMacros = ["RELEASE", "GE_WINDOWS"]
[Configs.Release.Win64]
PreprocessorMacros = ["IMGUI", "RELEASE", "GE_PROFILE"]
PreprocessorMacros = ["RELEASE", "GE_PROFILE", "GE_PROFILE_RENDERER", "GE_PROFILE_RESOURCES", "GE_RESOURCE_DEBUG_NAMES"]
[Configs.Test.Win32]
PreprocessorMacros = ["TEST", "GE_WINDOWS"]
@@ -42,4 +39,4 @@ PreprocessorMacros = ["TEST", "GE_WINDOWS"]
PreprocessorMacros = ["TEST", "GE_PROFILE", "GE_PROFILE_RENDERER", "GE_PROFILE_RESOURCES", "IMGUI", "GE_RESOURCE_DEBUG_NAMES"]
[Configs.Debug.Win64]
PreprocessorMacros = ["DEBUG", "GE_PROFILE", "GE_PROFILE_RENDERER", "GE_PROFILE_RESOURCES", "IMGUI", "GE_RESOURCE_DEBUG_NAMES"]
PreprocessorMacros = ["DEBUG", "GE_PROFILE", "GE_PROFILE_RENDERER", "GE_PROFILE_RESOURCES", "GE_RESOURCE_DEBUG_NAMES"]
+15 -18
View File
@@ -1,6 +1,5 @@
using System;
using GlitchyEngine.Events;
using GlitchyEngine.ImGui;
using GlitchyEngine.Renderer;
using GlitchyEngine.Debug;
using GlitchyEngine.Content;
@@ -22,9 +21,6 @@ namespace GlitchyEngine
private append LayerStack _layerStack = .();
#if IMGUI
private ImGuiLayer _imGuiLayer;
#endif
private append GameTime _gameTime = .();
@@ -47,8 +43,6 @@ namespace GlitchyEngine
public static Application Instance => s_Instance;
public Settings Settings {get; private set;} = new .() ~ delete _;
public this()
{
Profiler.ProfileFunction!();
@@ -77,17 +71,6 @@ namespace GlitchyEngine
Renderer.Init();
ScriptEngine.Init();
#if IMGUI
_imGuiLayer = new ImGuiLayer();
PushOverlay(_imGuiLayer);
#endif
GlitchyEngine.Settings.Load();
Settings.OnApplySettings.Add(new (s, e) => {
OnEvent(scope SettingsAppliedEvent());
});
Settings.Apply();
}
/// Initializes the content manager.
@@ -184,7 +167,7 @@ namespace GlitchyEngine
if(allowFrame)
{
#if IMGUI
_imGuiLayer.ImGuiRender();
//_imGuiLayer.ImGuiRender();
#endif
_window.Context.SwapChain.Present();
@@ -214,6 +197,20 @@ namespace GlitchyEngine
ownOverlay.OnAttach();
}
public void PopLayer(Layer layer)
{
Profiler.ProfileFunction!();
_layerStack.PopLayer(layer);
}
public void PopOverlay(Layer layer)
{
Profiler.ProfileFunction!();
_layerStack.PopOverlay(layer);
}
public bool OnWindowClose(WindowCloseEvent e)
{
_running = false;
+2 -2
View File
@@ -66,7 +66,7 @@ namespace GlitchyEngine
public static extern void Impl_NewFrame();
public static extern void Impl_EndFrame();
public static void ImGuiDebugDraw()
/*public static void ImGuiDebugDraw()
{
if (ImGui.Begin("Input"))
{
@@ -116,7 +116,7 @@ namespace GlitchyEngine
}
ImGui.End();
}
}*/
}
public static class Mouse
+2
View File
@@ -58,6 +58,7 @@ namespace GlitchyEngine
{
_insertIndex--;
layer.OnDetach();
delete layer;
}
}
@@ -70,6 +71,7 @@ namespace GlitchyEngine
if(_layers.Remove(overlay))
{
overlay.OnDetach();
delete overlay;
}
}
@@ -275,7 +275,10 @@ namespace GlitchyEngine
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
}
// TODO: This line is the reason why GlitchyEngine depends on ImGui...
#if IMGUI
ImGui.ImGuiImplWin32.WndProcHandler(hwnd, uMsg, wParam, lParam);
#endif
switch (uMsg)
{