mirror of
https://github.com/HarbourMasters/SpaghettiKart
synced 2026-07-08 14:37:09 -04:00
Setup imgui layout for editor
This commit is contained in:
@@ -23,10 +23,12 @@ FVector ScreenRayTrace() {
|
||||
Camera* camera = &cameras[0];
|
||||
|
||||
Ship::Coords mouse = wnd->GetMousePos();
|
||||
mouse.x -= gfx_current_game_window_viewport.x;
|
||||
mouse.y -= gfx_current_game_window_viewport.y;
|
||||
|
||||
// Get screen dimensions
|
||||
uint32_t width = wnd->GetWidth();
|
||||
uint32_t height = wnd->GetHeight();
|
||||
uint32_t width = OTRGetGameRenderWidth();
|
||||
uint32_t height = OTRGetGameRenderHeight();
|
||||
|
||||
// Convert mouse to NDS screen coordinates
|
||||
float x = (2.0f * mouse.x) / width - 1.0f; // Normalized X: -1 to 1
|
||||
|
||||
@@ -21,6 +21,7 @@ extern "C" {
|
||||
#include "math_util_2.h"
|
||||
#include "camera.h"
|
||||
#include "courses/harbour/ship_model.h"
|
||||
#include "src/racing/collision.h"
|
||||
}
|
||||
|
||||
Gizmo::Gizmo() {
|
||||
@@ -93,6 +94,10 @@ void Gizmo::Translate() {
|
||||
break;
|
||||
}
|
||||
|
||||
if (CVarGetInteger("gEditorSnapToGround", false) == true) {
|
||||
_selected->Pos->y = spawn_actor_on_surface(_selected->Pos->x, 2000.0f, _selected->Pos->z);
|
||||
}
|
||||
|
||||
Pos = FVector(
|
||||
_selected->Pos->x,
|
||||
_selected->Pos->y,
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "ContentBrowser.h"
|
||||
#include "port/ui/PortMenu.h"
|
||||
#include "UIWidgets.h"
|
||||
#include "libultraship/src/Context.h"
|
||||
|
||||
#include <imgui.h>
|
||||
#include <map>
|
||||
#include <libultraship/libultraship.h>
|
||||
#include <spdlog/fmt/fmt.h>
|
||||
#include "spdlog/formatter.h"
|
||||
#include <common_structs.h>
|
||||
#include <defines.h>
|
||||
|
||||
namespace Editor {
|
||||
|
||||
ContentBrowserWindow::~ContentBrowserWindow() {
|
||||
SPDLOG_TRACE("destruct editor window");
|
||||
}
|
||||
|
||||
void ContentBrowserWindow::DrawElement() {
|
||||
ImGui::Text("This is your Content browser Lab editor window!");
|
||||
if (ImGui::Button("Click Me")) {
|
||||
// Handle button click (example)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <libultraship/libultraship.h>
|
||||
|
||||
namespace Editor {
|
||||
class ContentBrowserWindow : public Ship::GuiWindow {
|
||||
public:
|
||||
using Ship::GuiWindow::GuiWindow;
|
||||
~ContentBrowserWindow();
|
||||
protected:
|
||||
void InitElement() override {};
|
||||
void DrawElement() override;
|
||||
void UpdateElement() override {};
|
||||
};
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
#include "EditorWindow.h"
|
||||
#include "port/ui/PortMenu.h"
|
||||
#include "UIWidgets.h"
|
||||
#include "libultraship/src/Context.h"
|
||||
|
||||
#include <imgui.h>
|
||||
#include <map>
|
||||
#include <libultraship/libultraship.h>
|
||||
#include <spdlog/fmt/fmt.h>
|
||||
#include "spdlog/formatter.h"
|
||||
#include <common_structs.h>
|
||||
#include <defines.h>
|
||||
|
||||
namespace GameUI {
|
||||
|
||||
extern std::shared_ptr<PortMenu> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,9 @@
|
||||
#include "GameInfoWindow.h"
|
||||
#include "MultiplayerWindow.h"
|
||||
#include "FreecamWindow.h"
|
||||
#include "Tools.h"
|
||||
#include "SceneExplorer.h"
|
||||
#include "ContentBrowser.h"
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <imgui.h>
|
||||
@@ -32,6 +35,9 @@ std::shared_ptr<Ship::GuiWindow> mInputEditorWindow;
|
||||
std::shared_ptr<Ship::GuiWindow> mGfxDebuggerWindow;
|
||||
std::shared_ptr<Ship::GuiWindow> mGameInfoWindow;
|
||||
std::shared_ptr<Ship::GuiWindow> mMultiplayerWindow;
|
||||
std::shared_ptr<Ship::GuiWindow> mToolsWindow;
|
||||
std::shared_ptr<Ship::GuiWindow> mSceneExplorerWindow;
|
||||
std::shared_ptr<Ship::GuiWindow> mContentBrowserWindow;
|
||||
|
||||
void SetupGuiElements() {
|
||||
auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui();
|
||||
@@ -73,6 +79,15 @@ void SetupGuiElements() {
|
||||
SPDLOG_ERROR("Could not find input GfxDebuggerWindow");
|
||||
}
|
||||
|
||||
mToolsWindow = std::make_shared<Editor::ToolsWindow>("gEditorEnabled", true, "Tools", ImVec2(100, 100), (ImGuiWindowFlags_NoTitleBar));
|
||||
gui->AddGuiWindow(mToolsWindow);
|
||||
|
||||
mSceneExplorerWindow = std::make_shared<Editor::SceneExplorerWindow>("gEditorEnabled", "Scene Explorer");
|
||||
gui->AddGuiWindow(mSceneExplorerWindow);
|
||||
|
||||
mContentBrowserWindow = std::make_shared<Editor::ContentBrowserWindow>("gEditorEnabled", "Content Browser");
|
||||
gui->AddGuiWindow(mContentBrowserWindow);
|
||||
|
||||
mGameInfoWindow = std::make_shared<GameInfo::GameInfoWindow>("gGameInfoEnabled", "Game Info");
|
||||
gui->AddGuiWindow(mGameInfoWindow);
|
||||
}
|
||||
@@ -82,6 +97,9 @@ void Destroy() {
|
||||
mConsoleWindow = nullptr;
|
||||
mStatsWindow = nullptr;
|
||||
mInputEditorWindow = nullptr;
|
||||
mToolsWindow = nullptr;
|
||||
mSceneExplorerWindow = nullptr;
|
||||
mContentBrowserWindow = nullptr;
|
||||
}
|
||||
|
||||
std::string GetWindowButtonText(const char* text, bool menuOpen) {
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
typedef enum {
|
||||
DISABLE_FOR_FREE_CAM_ON,
|
||||
DISABLE_FOR_FREE_CAM_OFF,
|
||||
DISABLE_FOR_EDITOR_ON,
|
||||
DISABLE_FOR_EDITOR_OFF,
|
||||
DISABLE_FOR_DEBUG_MODE_OFF,
|
||||
DISABLE_FOR_NO_VSYNC,
|
||||
DISABLE_FOR_NO_WINDOWED_FULLSCREEN,
|
||||
|
||||
@@ -360,6 +360,17 @@ void PortMenu::AddEnhancements() {
|
||||
.CVar("gMinHeight")
|
||||
.Options(FloatSliderOptions().Min(-50.0f).Max(50.0f).DefaultValue(0.0f)
|
||||
.Tooltip("When Disable Wall Collision are enable what is the minimal height you can get."));
|
||||
|
||||
path = { "Enhancements", "HM64 Lab", SECTION_COLUMN_1 };
|
||||
AddSidebarEntry("Enhancements", "HM64 Lab", 4);
|
||||
AddWidget(path, "Enable HM64 Labs", WIDGET_CVAR_CHECKBOX)
|
||||
.CVar("gEditorEnabled")
|
||||
.Callback([](WidgetInfo& info) {
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Tools")->ToggleVisibility();
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Scene Explorer")->ToggleVisibility();
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Content Browser")->ToggleVisibility();
|
||||
})
|
||||
.Options(UIWidgets::CheckboxOptions({{ .tooltip = "Edit the universe!"}}));
|
||||
}
|
||||
|
||||
void PortMenu::AddDevTools() {
|
||||
@@ -432,9 +443,13 @@ void PortMenu::InitElement() {
|
||||
|
||||
disabledMap = {
|
||||
{ DISABLE_FOR_FREE_CAM_ON,
|
||||
{ [](disabledInfo& info) -> bool { return CVarGetInteger("gFreecam", 0); }, "Free Cam is Enabled" } },
|
||||
{ [](disabledInfo& info) -> bool { return CVarGetInteger("gFreecam", 0); }, "Freecam is Enabled" } },
|
||||
{ DISABLE_FOR_FREE_CAM_OFF,
|
||||
{ [](disabledInfo& info) -> bool { return !CVarGetInteger("gFreecam", 0); }, "Free Cam is Disabled" } },
|
||||
{ [](disabledInfo& info) -> bool { return !CVarGetInteger("gFreecam", 0); }, "Freecam is Disabled" } },
|
||||
{ DISABLE_FOR_EDITOR_ON,
|
||||
{ [](disabledInfo& info) -> bool { return CVarGetInteger("gEditorEnabled", 0); }, "Editor is Enabled" } },
|
||||
{ DISABLE_FOR_EDITOR_OFF,
|
||||
{ [](disabledInfo& info) -> bool { return !CVarGetInteger("gEditorEnabled", 0); }, "Editor is Disabled" } },
|
||||
{ DISABLE_FOR_DEBUG_MODE_OFF,
|
||||
{ [](disabledInfo& info) -> bool { return !CVarGetInteger("gEnableDebugMode", 0); },
|
||||
"Debug Mode is Disabled" } },
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#include "SceneExplorer.h"
|
||||
#include "port/ui/PortMenu.h"
|
||||
#include "UIWidgets.h"
|
||||
#include "libultraship/src/Context.h"
|
||||
|
||||
#include <imgui.h>
|
||||
#include <map>
|
||||
#include <libultraship/libultraship.h>
|
||||
#include <spdlog/fmt/fmt.h>
|
||||
#include "spdlog/formatter.h"
|
||||
#include <common_structs.h>
|
||||
#include <defines.h>
|
||||
|
||||
namespace Editor {
|
||||
|
||||
SceneExplorerWindow::~SceneExplorerWindow() {
|
||||
SPDLOG_TRACE("destruct editor window");
|
||||
}
|
||||
|
||||
void SceneExplorerWindow::DrawElement() {
|
||||
ImGui::Text("This is your Scene Explorer window!");
|
||||
if (ImGui::Button("Click Me")) {
|
||||
// Handle button click (example)
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <libultraship/libultraship.h>
|
||||
|
||||
namespace Editor {
|
||||
class SceneExplorerWindow : public Ship::GuiWindow {
|
||||
public:
|
||||
using Ship::GuiWindow::GuiWindow;
|
||||
~SceneExplorerWindow();
|
||||
protected:
|
||||
void InitElement() override {};
|
||||
void DrawElement() override;
|
||||
void UpdateElement() override {};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "Tools.h"
|
||||
#include "port/ui/PortMenu.h"
|
||||
#include "UIWidgets.h"
|
||||
#include "libultraship/src/Context.h"
|
||||
|
||||
#include <imgui.h>
|
||||
#include <map>
|
||||
#include <libultraship/libultraship.h>
|
||||
#include <spdlog/fmt/fmt.h>
|
||||
#include "spdlog/formatter.h"
|
||||
#include <common_structs.h>
|
||||
#include <defines.h>
|
||||
|
||||
namespace Editor {
|
||||
|
||||
ToolsWindow::~ToolsWindow() {
|
||||
SPDLOG_TRACE("destruct editor window");
|
||||
}
|
||||
|
||||
void ToolsWindow::InitElement() {
|
||||
|
||||
}
|
||||
|
||||
void ToolsWindow::DrawElement() {
|
||||
static bool toggleState = false;
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, toggleState ? ImVec4(0.2f, 0.8f, 0.2f, 1.0f) : ImVec4(0.8f, 0.2f, 0.2f, 1.0f));
|
||||
if (ImGui::Button(toggleState ? "v" : "v", ImVec2(50, 25))) {
|
||||
toggleState = !toggleState;
|
||||
|
||||
CVarSetInteger("gEditorSnapToGround", toggleState);
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <libultraship/libultraship.h>
|
||||
|
||||
namespace Editor {
|
||||
class ToolsWindow : public Ship::GuiWindow {
|
||||
public:
|
||||
using Ship::GuiWindow::GuiWindow;
|
||||
|
||||
~ToolsWindow();
|
||||
protected:
|
||||
void InitElement() override;
|
||||
void DrawElement() override;
|
||||
void UpdateElement() override {};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user