2024-07-12 23:10:44 +02:00
|
|
|
|
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();
|
2024-10-15 00:41:45 +02:00
|
|
|
|
|
|
|
|
|
foreach (MoonTools.ECS.System system in Program.editorSystems)
|
|
|
|
|
{
|
2024-10-20 03:51:59 +02:00
|
|
|
|
using ProfilerScope scope = new(system.GetType().Name);
|
2024-10-15 00:41:45 +02:00
|
|
|
|
system.Update(Engine.Timestep);
|
|
|
|
|
}
|
2024-07-12 23:10:44 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|