Nerfed/Nerfed.Editor/Editor/EditorGui.cs
max 2c84e650d6 Combined transform systems
Profiler window calls count
Parallel transform system is now in the normal transform system
Removed unused parent system
2024-10-20 03:51:59 +02:00

77 lines
2.1 KiB
C#

using ImGuiNET;
using Nerfed.Runtime;
using Nerfed.Runtime.Graphics;
using Nerfed.Runtime.Gui;
namespace Nerfed.Editor
{
internal static class EditorGui
{
private static GuiController guiController;
internal static void Initialize()
{
// Create GuiController.
guiController = new GuiController(Engine.GraphicsDevice, Engine.MainWindow, Color.DimGray);
// Subscribe to GUI update.
// GuiController.OnGui call => UpdateDock;
// GuiController.OnGui call => UpdateEditorWindows;
// GuiController.OnGui call => ...;
guiController.OnGui += HandleOnGui;
}
internal static void Update()
{
// Update GuiController.
guiController.Update(Engine.Timestep.TotalSeconds);
}
internal static void Render()
{
// Reneder GuiController.
guiController.Render();
}
internal static void Quit()
{
guiController.Dispose();
}
private static void UpdateDock()
{
// Setup default dockspace for the main window.
uint id = ImGui.GetID("MainDockSpace");
ImGui.DockSpaceOverViewport(id, ImGui.GetMainViewport(), ImGuiDockNodeFlags.None);
}
private static void UpdateMainMenu()
{
if (ImGui.BeginMainMenuBar())
{
if (ImGui.BeginMenu("File"))
{
if (ImGui.MenuItem("Exit"))
{
Engine.Quit();
}
ImGui.EndMenu();
}
ImGui.EndMainMenuBar();
}
}
private static void HandleOnGui()
{
UpdateMainMenu();
UpdateDock();
ImGui.ShowDemoWindow();
foreach (MoonTools.ECS.System system in Program.editorSystems)
{
using ProfilerScope scope = new(system.GetType().Name);
system.Update(Engine.Timestep);
}
}
}
}