Files

110 lines
3.5 KiB
C++
Raw Permalink Normal View History

#include "BenGui.hpp"
2024-01-05 10:15:41 -06:00
#include <spdlog/spdlog.h>
#include <imgui.h>
2024-01-05 10:15:41 -06:00
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui_internal.h>
2024-01-05 10:15:41 -06:00
#include <libultraship/libultraship.h>
#include <Fast3D/gfx_pc.h>
#include "UIWidgets.hpp"
2024-01-29 00:15:21 +00:00
#include "HudEditor.h"
2024-01-05 10:15:41 -06:00
#ifdef __APPLE__
#include "graphic/Fast3D/gfx_metal.h"
#endif
#ifdef __SWITCH__
#include <port/switch/SwitchImpl.h>
#endif
#include "include/global.h"
#include "include/z64audio.h"
bool ShouldClearTextureCacheAtEndOfFrame = false;
namespace BenGui {
2024-05-22 09:52:56 -04:00
// MARK: - Delegates
2024-01-05 10:15:41 -06:00
2024-05-22 09:52:56 -04:00
std::shared_ptr<BenMenuBar> mBenMenuBar;
2024-01-05 10:15:41 -06:00
2024-05-22 09:52:56 -04:00
std::shared_ptr<Ship::GuiWindow> mConsoleWindow;
std::shared_ptr<Ship::GuiWindow> mStatsWindow;
std::shared_ptr<Ship::GuiWindow> mInputEditorWindow;
std::shared_ptr<Ship::GuiWindow> mGfxDebuggerWindow;
2024-01-05 10:15:41 -06:00
2024-05-22 09:52:56 -04:00
std::shared_ptr<SaveEditorWindow> mSaveEditorWindow;
std::shared_ptr<HudEditorWindow> mHudEditorWindow;
std::shared_ptr<ActorViewerWindow> mActorViewerWindow;
std::shared_ptr<CollisionViewerWindow> mCollisionViewerWindow;
std::shared_ptr<EventLogWindow> mEventLogWindow;
2024-01-05 10:15:41 -06:00
2024-05-22 09:52:56 -04:00
void SetupGuiElements() {
auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui();
2024-01-05 10:15:41 -06:00
2024-05-22 09:52:56 -04:00
auto& style = ImGui::GetStyle();
style.FramePadding = ImVec2(4.0f, 6.0f);
style.ItemSpacing = ImVec2(8.0f, 6.0f);
style.Colors[ImGuiCol_MenuBarBg] = UIWidgets::Colors::DarkGray;
mBenMenuBar = std::make_shared<BenMenuBar>(CVAR_MENU_BAR_OPEN, CVarGetInteger(CVAR_MENU_BAR_OPEN, 0));
2024-05-22 09:52:56 -04:00
gui->SetMenuBar(std::reinterpret_pointer_cast<Ship::GuiMenuBar>(mBenMenuBar));
2024-01-05 10:15:41 -06:00
2024-05-22 09:52:56 -04:00
if (gui->GetMenuBar() && !gui->GetMenuBar()->IsVisible()) {
2024-01-05 10:15:41 -06:00
#if defined(__SWITCH__) || defined(__WIIU__)
2024-05-22 09:52:56 -04:00
gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Press - to access enhancements menu");
2024-01-05 10:15:41 -06:00
#else
2024-05-22 09:52:56 -04:00
gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Press F1 to access enhancements menu");
2024-01-05 10:15:41 -06:00
#endif
}
2024-05-22 09:52:56 -04:00
mStatsWindow = gui->GetGuiWindow("Stats");
if (mStatsWindow == nullptr) {
SPDLOG_ERROR("Could not find stats window");
2024-01-05 10:15:41 -06:00
}
2024-05-22 09:52:56 -04:00
mConsoleWindow = gui->GetGuiWindow("Console");
if (mConsoleWindow == nullptr) {
SPDLOG_ERROR("Could not find console window");
}
mInputEditorWindow = gui->GetGuiWindow("Input Editor");
if (mInputEditorWindow == nullptr) {
SPDLOG_ERROR("Could not find input editor window");
}
mGfxDebuggerWindow = gui->GetGuiWindow("GfxDebuggerWindow");
if (mGfxDebuggerWindow == nullptr) {
SPDLOG_ERROR("Could not find input GfxDebuggerWindow");
}
mSaveEditorWindow = std::make_shared<SaveEditorWindow>("gWindows.SaveEditor", "Save Editor");
gui->AddGuiWindow(mSaveEditorWindow);
mHudEditorWindow = std::make_shared<HudEditorWindow>("gWindows.HudEditor", "Hud Editor");
gui->AddGuiWindow(mHudEditorWindow);
mActorViewerWindow = std::make_shared<ActorViewerWindow>("gWindows.ActorViewer", "Actor Viewer");
gui->AddGuiWindow(mActorViewerWindow);
mCollisionViewerWindow = std::make_shared<CollisionViewerWindow>("gWindows.CollisionViewer", "Collision Viewer");
gui->AddGuiWindow(mCollisionViewerWindow);
mEventLogWindow = std::make_shared<EventLogWindow>("gWindows.EventLog", "Event Log");
gui->AddGuiWindow(mEventLogWindow);
2024-01-05 10:15:41 -06:00
}
2024-05-22 09:52:56 -04:00
void Destroy() {
mBenMenuBar = nullptr;
mStatsWindow = nullptr;
mConsoleWindow = nullptr;
mInputEditorWindow = nullptr;
mGfxDebuggerWindow = nullptr;
mCollisionViewerWindow = nullptr;
mEventLogWindow = nullptr;
mSaveEditorWindow = nullptr;
mHudEditorWindow = nullptr;
mActorViewerWindow = nullptr;
}
} // namespace BenGui