Files

136 lines
4.9 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"
#include "Notification.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"
2024-11-08 11:51:58 -05:00
#include "Enhancements/Trackers/ItemTracker.h"
#include "Enhancements/Trackers/ItemTrackerSettings.h"
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> 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-10-02 17:25:26 -07:00
std::shared_ptr<BenMenu> mBenMenu;
std::shared_ptr<BenInputEditorWindow> mBenInputEditorWindow;
std::shared_ptr<Notification::Window> mNotificationWindow;
2024-11-08 11:51:58 -05:00
std::shared_ptr<ItemTrackerWindow> mItemTrackerWindow;
std::shared_ptr<ItemTrackerSettingsWindow> mItemTrackerSettingsWindow;
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-10-02 17:25:26 -07:00
if (!gui->GetMenuBar() && !CVarGetInteger("gSettings.DisableMenuShortcutNotify", 0)) {
2024-05-29 09:33:20 -07:00
#if defined(__SWITCH__) || defined(__WIIU__) || defined(__ANDROID__)
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-10-02 17:25:26 -07:00
mBenMenu = std::make_shared<BenMenu>("gWindows.Menu", "Settings Menu");
gui->SetMenu(mBenMenu);
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");
}
mGfxDebuggerWindow = gui->GetGuiWindow("GfxDebuggerWindow");
if (mGfxDebuggerWindow == nullptr) {
SPDLOG_ERROR("Could not find input GfxDebuggerWindow");
}
2024-10-02 17:25:26 -07:00
mBenInputEditorWindow = std::make_shared<BenInputEditorWindow>("gWindows.BenInputEditor", "2S2H Input Editor");
gui->AddGuiWindow(mBenInputEditorWindow);
mSaveEditorWindow = std::make_shared<SaveEditorWindow>("gWindows.SaveEditor", "Save Editor", ImVec2(480, 600));
2024-05-22 09:52:56 -04:00
gui->AddGuiWindow(mSaveEditorWindow);
2024-10-02 17:25:26 -07:00
mHudEditorWindow = std::make_shared<HudEditorWindow>("gWindows.HudEditor", "HUD Editor", ImVec2(480, 600));
2024-05-22 09:52:56 -04:00
gui->AddGuiWindow(mHudEditorWindow);
2024-10-02 17:25:26 -07:00
mActorViewerWindow = std::make_shared<ActorViewerWindow>("gWindows.ActorViewer", "Actor Viewer", ImVec2(520, 600));
2024-05-22 09:52:56 -04:00
gui->AddGuiWindow(mActorViewerWindow);
2024-10-02 17:25:26 -07:00
mCollisionViewerWindow =
std::make_shared<CollisionViewerWindow>("gWindows.CollisionViewer", "Collision Viewer", ImVec2(390, 475));
2024-05-22 09:52:56 -04:00
gui->AddGuiWindow(mCollisionViewerWindow);
2024-10-02 17:25:26 -07:00
mEventLogWindow = std::make_shared<EventLogWindow>("gWindows.EventLog", "Event Log", ImVec2(520, 600));
2024-05-22 09:52:56 -04:00
gui->AddGuiWindow(mEventLogWindow);
2024-11-08 11:51:58 -05:00
mItemTrackerWindow = std::make_shared<ItemTrackerWindow>("gWindows.ItemTracker", "Item Tracker");
gui->AddGuiWindow(mItemTrackerWindow);
mItemTrackerSettingsWindow = std::make_shared<ItemTrackerSettingsWindow>("gWindows.ItemTrackerSettings",
"Item Tracker Settings", ImVec2(800, 400));
gui->AddGuiWindow(mItemTrackerSettingsWindow);
2024-10-02 17:25:26 -07:00
gui->SetPadBtnTogglesMenu();
mNotificationWindow = std::make_shared<Notification::Window>("gWindows.Notifications", "Notifications Window");
gui->AddGuiWindow(mNotificationWindow);
mNotificationWindow->Show();
2024-01-05 10:15:41 -06:00
}
2024-05-22 09:52:56 -04:00
void Destroy() {
2024-11-08 11:51:58 -05:00
auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui();
gui->RemoveAllGuiWindows();
2024-05-22 09:52:56 -04:00
mBenMenuBar = nullptr;
2024-10-02 17:25:26 -07:00
mBenMenu = nullptr;
2024-05-22 09:52:56 -04:00
mStatsWindow = nullptr;
mConsoleWindow = nullptr;
2024-10-02 17:25:26 -07:00
mBenInputEditorWindow = nullptr;
2024-05-22 09:52:56 -04:00
mGfxDebuggerWindow = nullptr;
mCollisionViewerWindow = nullptr;
mEventLogWindow = nullptr;
mNotificationWindow = nullptr;
2024-05-22 09:52:56 -04:00
mSaveEditorWindow = nullptr;
mHudEditorWindow = nullptr;
mActorViewerWindow = nullptr;
2024-11-08 11:51:58 -05:00
mItemTrackerWindow = nullptr;
mItemTrackerSettingsWindow = nullptr;
2024-05-22 09:52:56 -04:00
}
} // namespace BenGui