From 8f1458902acb53e9613c6c0a3d00408957b21ae2 Mon Sep 17 00:00:00 2001 From: MegaMech Date: Thu, 6 Mar 2025 20:58:33 -0700 Subject: [PATCH] Docking Windows works here --- src/port/ui/EditorWindow.cpp | 106 +++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 src/port/ui/EditorWindow.cpp diff --git a/src/port/ui/EditorWindow.cpp b/src/port/ui/EditorWindow.cpp new file mode 100644 index 000000000..665f247f0 --- /dev/null +++ b/src/port/ui/EditorWindow.cpp @@ -0,0 +1,106 @@ +#include "EditorWindow.h" +#include "port/ui/PortMenu.h" +#include "UIWidgets.h" +#include "libultraship/src/Context.h" + +#include +#include +#include +#include +#include "spdlog/formatter.h" +#include +#include + +namespace GameUI { + + extern std::shared_ptr mPortMenu; + + void RegisterEditorWidgets() { + mPortMenu->AddSidebarEntry("Enhancements", "HM64 Lab", 4); + WidgetPath path = { "Enhancements", "HM64 Lab", SECTION_COLUMN_1 }; + mPortMenu->AddWidget(path, "Enable HM64 Labs", WIDGET_CVAR_CHECKBOX) + .CVar("gEditor") + .Options(UIWidgets::CheckboxOptions({{ .tooltip = "Edit the universe!"}})); + } + +static RegisterMenuInitFunc initFunc(RegisterEditorWidgets); + +} // namespace GameUI + +namespace EditorWin { + + EditorWindow::~EditorWindow() { + SPDLOG_TRACE("destruct editor window"); + } + + void EditorWindow::DrawElement() { + auto viewport = ImGui::GetMainViewport(); + ImGuiID mainDock = ImGui::GetID("main_dock"); + + EditorWindow::SetupLayout(); + EditorWindow::DrawContentBrowser(viewport, mainDock); + EditorWindow::DrawSceneExplorer(viewport, mainDock); + + + } + + void EditorWindow::SetupLayout() { + + } + + void EditorWindow::DrawContentBrowser(ImGuiViewport* viewport, ImGuiID mainDock) { + ImGuiID bottomId = 0; + + if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_DockingEnable) { + + if (!ImGui::DockBuilderGetNode(mainDock)) { + bottomId = ImGui::DockBuilderSplitNode(mainDock, ImGuiDir_Down, 0.25f, nullptr, nullptr); + ImGui::DockBuilderSetNodeSize(bottomId, ImVec2(viewport->Size.x * 0.2f, viewport->Size.y)); + + + + + + ImGui::DockBuilderDockWindow("Content Browser", bottomId); + ImGui::DockBuilderFinish(mainDock); + } + } + + if (ImGui::Begin("Content Browser", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove)) { + + ImGui::Text("This is your Content browser Lab editor window!"); + if (ImGui::Button("Click Me")) { + // Handle button click (example) + } + ImGui::End(); + } + } + + void EditorWindow::DrawSceneExplorer(ImGuiViewport* viewport, ImGuiID mainDock) { + ImGuiID rightId = 0; + + if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_DockingEnable) { + + if (!ImGui::DockBuilderGetNode(mainDock)) { + rightId = ImGui::DockBuilderSplitNode(mainDock, ImGuiDir_Right, 0.25f, nullptr, nullptr); + ImGui::DockBuilderSetNodeSize(rightId, ImVec2(viewport->Size.x * 0.2f, viewport->Size.y)); + + + + + + ImGui::DockBuilderDockWindow("HM64 Lab", rightId); + ImGui::DockBuilderFinish(mainDock); + } + } + + if (ImGui::Begin("HM64 Lab", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove)) { + + ImGui::Text("This is your HM64 Lab editor window!"); + if (ImGui::Button("Click Me")) { + // Handle button click (example) + } + ImGui::End(); + } + } +}