#include "BenGui.hpp" #include #include #define IMGUI_DEFINE_MATH_OPERATORS #include #include #include #include "UIWidgets.hpp" #include "HudEditor.h" #include "Notification.h" #ifdef __APPLE__ #include "graphic/Fast3D/gfx_metal.h" #endif #ifdef __SWITCH__ #include #endif #include "include/global.h" #include "include/z64audio.h" #include "Enhancements/Trackers/ItemTracker.h" #include "Enhancements/Trackers/ItemTrackerSettings.h" namespace BenGui { // MARK: - Delegates std::shared_ptr mBenMenuBar; std::shared_ptr mConsoleWindow; std::shared_ptr mStatsWindow; std::shared_ptr mGfxDebuggerWindow; std::shared_ptr mSaveEditorWindow; std::shared_ptr mHudEditorWindow; std::shared_ptr mActorViewerWindow; std::shared_ptr mCollisionViewerWindow; std::shared_ptr mEventLogWindow; std::shared_ptr mBenMenu; std::shared_ptr mBenInputEditorWindow; std::shared_ptr mNotificationWindow; std::shared_ptr mItemTrackerWindow; std::shared_ptr mItemTrackerSettingsWindow; void SetupGuiElements() { auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui(); 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(CVAR_MENU_BAR_OPEN, CVarGetInteger(CVAR_MENU_BAR_OPEN, 0)); gui->SetMenuBar(std::reinterpret_pointer_cast(mBenMenuBar)); if (!gui->GetMenuBar() && !CVarGetInteger("gSettings.DisableMenuShortcutNotify", 0)) { #if defined(__SWITCH__) || defined(__WIIU__) || defined(__ANDROID__) gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Press - to access enhancements menu"); #else gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Press F1 to access enhancements menu"); #endif } mBenMenu = std::make_shared("gWindows.Menu", "Settings Menu"); gui->SetMenu(mBenMenu); mStatsWindow = gui->GetGuiWindow("Stats"); if (mStatsWindow == nullptr) { SPDLOG_ERROR("Could not find stats window"); } mConsoleWindow = gui->GetGuiWindow("Console"); if (mConsoleWindow == nullptr) { SPDLOG_ERROR("Could not find console window"); } mGfxDebuggerWindow = gui->GetGuiWindow("GfxDebuggerWindow"); if (mGfxDebuggerWindow == nullptr) { SPDLOG_ERROR("Could not find input GfxDebuggerWindow"); } mBenInputEditorWindow = std::make_shared("gWindows.BenInputEditor", "2S2H Input Editor"); gui->AddGuiWindow(mBenInputEditorWindow); mSaveEditorWindow = std::make_shared("gWindows.SaveEditor", "Save Editor", ImVec2(480, 600)); gui->AddGuiWindow(mSaveEditorWindow); mHudEditorWindow = std::make_shared("gWindows.HudEditor", "HUD Editor", ImVec2(480, 600)); gui->AddGuiWindow(mHudEditorWindow); mActorViewerWindow = std::make_shared("gWindows.ActorViewer", "Actor Viewer", ImVec2(520, 600)); gui->AddGuiWindow(mActorViewerWindow); mCollisionViewerWindow = std::make_shared("gWindows.CollisionViewer", "Collision Viewer", ImVec2(390, 475)); gui->AddGuiWindow(mCollisionViewerWindow); mEventLogWindow = std::make_shared("gWindows.EventLog", "Event Log", ImVec2(520, 600)); gui->AddGuiWindow(mEventLogWindow); mItemTrackerWindow = std::make_shared("gWindows.ItemTracker", "Item Tracker"); gui->AddGuiWindow(mItemTrackerWindow); mItemTrackerSettingsWindow = std::make_shared("gWindows.ItemTrackerSettings", "Item Tracker Settings", ImVec2(800, 400)); gui->AddGuiWindow(mItemTrackerSettingsWindow); gui->SetPadBtnTogglesMenu(); mNotificationWindow = std::make_shared("gWindows.Notifications", "Notifications Window"); gui->AddGuiWindow(mNotificationWindow); mNotificationWindow->Show(); } void Destroy() { auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui(); gui->RemoveAllGuiWindows(); mBenMenuBar = nullptr; mBenMenu = nullptr; mStatsWindow = nullptr; mConsoleWindow = nullptr; mBenInputEditorWindow = nullptr; mGfxDebuggerWindow = nullptr; mCollisionViewerWindow = nullptr; mEventLogWindow = nullptr; mNotificationWindow = nullptr; mSaveEditorWindow = nullptr; mHudEditorWindow = nullptr; mActorViewerWindow = nullptr; mItemTrackerWindow = nullptr; mItemTrackerSettingsWindow = nullptr; } } // namespace BenGui