2024-07-12 19:09:59 +02:00
|
|
|
|
using ImGuiNET;
|
|
|
|
|
using Nerfed.Runtime;
|
|
|
|
|
using Nerfed.Runtime.Graphics;
|
|
|
|
|
using Nerfed.Runtime.Gui;
|
|
|
|
|
|
|
|
|
|
namespace Nerfed.Editor
|
2024-07-12 17:27:01 +02:00
|
|
|
|
{
|
|
|
|
|
internal static class EditorGui
|
|
|
|
|
{
|
2024-07-12 19:09:59 +02:00
|
|
|
|
private static GuiController guiController;
|
|
|
|
|
|
2024-07-12 17:27:01 +02:00
|
|
|
|
internal static void Initialize()
|
|
|
|
|
{
|
|
|
|
|
// Create GuiController.
|
2024-07-12 19:09:59 +02:00
|
|
|
|
guiController = new GuiController(Engine.GraphicsDevice, Engine.MainWindow, Color.DimGray);
|
2024-07-12 17:27:01 +02:00
|
|
|
|
// Subscribe to GUI update.
|
|
|
|
|
// GuiController.OnGui call => UpdateDock;
|
|
|
|
|
// GuiController.OnGui call => UpdateEditorWindows;
|
|
|
|
|
// GuiController.OnGui call => ...;
|
2024-07-12 19:09:59 +02:00
|
|
|
|
guiController.OnGui += HandleOnGui;
|
2024-07-12 17:27:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal static void Update()
|
|
|
|
|
{
|
|
|
|
|
// Update GuiController.
|
2024-07-12 19:09:59 +02:00
|
|
|
|
guiController.Update(Engine.Timestep.TotalSeconds);
|
2024-07-12 17:27:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal static void Render()
|
|
|
|
|
{
|
|
|
|
|
// Reneder GuiController.
|
2024-07-12 19:09:59 +02:00
|
|
|
|
guiController.Render();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal static void Quit()
|
|
|
|
|
{
|
|
|
|
|
guiController.Dispose();
|
2024-07-12 17:27:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void UpdateDock()
|
|
|
|
|
{
|
|
|
|
|
// Setup default dockspace for the main window.
|
2024-07-12 19:09:59 +02:00
|
|
|
|
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-07-12 17:27:01 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|