mirror of
https://github.com/HarbourMasters/Shipwright
synced 2026-08-04 17:30:05 -04:00
7e392e63a8
* Add menu files, hook menu up to window system. Temporarily rename new menu's UIWidgets to UIWidgets2 to allow both menu systems to coexist temporarily. * Finish implementing new menu. Rename 2ship UIWidgets to UIWidgets2 to complete facilitation of both menus working for now. * More preliminary setup * More prepwork, begin on settings options * Finish settings, add enhancements windows * Fix search function not looking past first columns. * Add dev tool windows * Finish dev tools * Add about window * Fully replace about window * Remove moved menu items from menubar, add more windows to new menu * Implement WindowButtonOptions. Add ability to not embed popout windows when not popped out. Add ability to hide the button for WindowButtons. Fix Entrance Tracker from showing when not enabled. * Fix entrance tracker settings embedded display. Fix entrance tracker settings window original size declaration. * Initial implementation of themed radio button widget. * Move "About" section to second column of general. Fix sidebar sections starting in second column. * Restore Entrance Tracker `Draw()` to allow for custom styling. * Fix combobox positioning formatting. Fix color picker end spacing. Convert everything in check tracker settings to UIWidgets2 (except color pickers and section headers). Make all tracker windows not embed. * Minor cleanup * Fix main volume defaults & mirror jitter fix removal on dev * Improve color picker with RGB/RGBA options. Not finished. * Finish creating CVarColorPicker and implement for Check Tracker background color. Fix tracker and network prefixes. * Finish check tracker settings and convert check tracker. * Port all Cheats menu except for Beta Quest * Port over Beta Quest to new menu * Remove old cheats menu * Port cutscene skips to modern menu * Port Timesaver Enhancements to new menu * Port the Items and Item Count Messages submenu * Port Difficulty Options to new Menu * Removes options that have been ported thus far. * Port "Reduced Clutter" options to new menu * Add forgotten callbacks to Hyper Enemies/Bosses * Copy StateButton to UIWidgets2, and implement custom padding for them in the tracker. * Ports some pause menu related settinga * Change tracker window active title color. Make state buttons smaller in tracker to get more info on screen. * Convert window title active theming to all windows. * Port the rest of Enhancements->Gameplay to new menu * Port the "Graphics" Enhancements to new menu * Ports Fixes over to the Modern Menu * Ported Restorations to Modern Menu * Ported Extra Modes to new menu * Port Autosave and Boot Sequence to modern menu * Cleans up some leftover data for ported buttons * Ports Enhancement Presets to new menu * Port Additional timers to new menu. Removes Enhancements from old menu * Cleans up some unused stuff * Ports Randomizer Enhancements to modern menu * Convert Item Tracker Settings. Something's wrong with the comboboxes in a second column of a table. * Fix combobox alignment and label position calculations. * Convert Entrance Tracker window. * Save Editor Info tab finished. Added `PushStyleInput` and `PushStyleTabs` for Info tab. Fixed some indentation in entrance tracker source. Added font push to tracker windows. * Increase size of all icons in save editor. * Convert flag groups to child windows for automatic sizing and border drawing. * Flags tab completed. Finished inventory tab. * Convert save editor help hover to UIWidgets2. * Various fixes and corrections * Start cosmetics editor, fix theme colors not updating * Cosmetics editor conversion progress * Remove Mac internal resolution restrictions. * Copy over advanced resolution partial and enable most options as a custom widget. * Add size to float sliders, more cosmetics editor progress * Fix incorrect cvar for notifications * Radio button & header color options, more cosmetics editor progress * Finish cosmetics editor conversion * Create and apply THEME_COLOR macro. Resides in SohGui for easy access to mSohMenu. * Move ResolutionEditor to SohGui directory. * Add labels to build info. Fix slider width calculations. * Fix some advanced resolution widget hiding. * Fully implement Advanced Resolution options. Fix graphics settings formatting. Improve slider label position calculations. Implement Clamp options on sliders. * Finish save editor. Convert save editor code to `using namespace UIWidgets2`. Fix search crashing on time splits window. Remove `SetLastItemHoverText` from `UIWidgets2`. * Unify cvar sectioning in time splits. * Add InputString and InputInt widgets, and corresponding CVar Widgets * Adds Widget Type for Inputs, not currently used. * Convert Sail to modern menu * Add Combobox that takes a vector of std::strings * Convert checkbox and combobx to new widgets * Add Tristate checkbox * Convert sliders and tristate checkboxes * Convert top half of Rando window * remove/replace remainder of UIWidgets usage in option.cpp * Converts tricks, locations, and removes old UIWidgets refs * Fix windows build errors * Remove Tri-State checkboxes * Use PushStyleInput instead of PushStyleSlider lol oops didn't realize it was a thing in Ship. * Rebase and address review comments * Convert Crowd Control to modern menu. * Fix build error * Audio editor progress * Re-add CVar SaveOnNextFrame calls to Resolution Editor. Remove old Resolution Editor files. * Convert TimeSplits to new menu. Fix a few enum warnings. * Decrease padding on Arrow Buttons * Audio editor + gameplay stats done * Give Randomizer Menu more screen real-estate * Port plandomizer menu * Fix slider width calculation and allow combobox LabelPosition::None * Fix None labelPos and slider width for inline labels * Fix all slider value label insertions. Convert Collision Viewer. * Minor Collision Viewer enum change. Convert Actor Viewer. * Theme/convert Message Viewer. * Add font to Message Viewer. Theme Value Viewer. * DL Viewer and SohModals themed. * Convert Input Viewer. * Missed some color settings in Input Viewer. Removed UIWidgets references from Controller Config, and restored SoH version. * Remove UIWidgets.hpp include from multiple files. * Completely remove old UIWidgets. Rename UIWidgets2 to UIWidgets. Move Accessibility and Language options to new menu. * Fix Gfx Debugger not showing up. Remove menubar registration. * Fix clearCvars references. * Fix passing std::string to const char* argument. * enum name spacing --------- Co-authored-by: aMannus <mannusmenting@gmail.com> Co-authored-by: Christopher Leggett <chris@leggett.dev>
237 lines
11 KiB
C++
237 lines
11 KiB
C++
//
|
|
// SohGui.cpp
|
|
// soh
|
|
//
|
|
// Created by David Chavez on 24.08.22.
|
|
//
|
|
|
|
#include "SohGui.hpp"
|
|
|
|
#include <spdlog/spdlog.h>
|
|
#include <imgui.h>
|
|
#include <imgui_internal.h>
|
|
#include <libultraship/libultraship.h>
|
|
#include <Fast3D/gfx_pc.h>
|
|
|
|
#ifdef __APPLE__
|
|
#include "graphic/Fast3D/gfx_metal.h"
|
|
#endif
|
|
|
|
#ifdef __SWITCH__
|
|
#include <port/switch/SwitchImpl.h>
|
|
#endif
|
|
#include "SohMenu.h"
|
|
#include "include/global.h"
|
|
#include "include/z64audio.h"
|
|
#include "soh/SaveManager.h"
|
|
#include "soh/OTRGlobals.h"
|
|
#include "soh/Enhancements/presets.h"
|
|
#include "soh/resource/type/Skeleton.h"
|
|
#include "libultraship/libultraship.h"
|
|
|
|
#include "soh/Enhancements/game-interactor/GameInteractor.h"
|
|
#include "soh/Enhancements/cosmetics/authenticGfxPatches.h"
|
|
#include "soh/Enhancements/debugger/MessageViewer.h"
|
|
#include "soh/Notification/Notification.h"
|
|
#include "soh/Enhancements/TimeDisplay/TimeDisplay.h"
|
|
|
|
namespace SohGui {
|
|
|
|
// MARK: - Properties
|
|
static const char* bunnyHoodOptions[3] = { "Disabled", "Faster Run & Longer Jump", "Faster Run" };
|
|
|
|
static const inline std::vector<std::pair<const char*, const char*>> audioBackends = {
|
|
#ifdef _WIN32
|
|
{ "wasapi", "Windows Audio Session API" },
|
|
#endif
|
|
#if defined(__linux)
|
|
{ "pulse", "PulseAudio" },
|
|
#endif
|
|
{ "sdl", "SDL Audio" }
|
|
};
|
|
|
|
|
|
// MARK: - Helpers
|
|
|
|
std::string GetWindowButtonText(const char* text, bool menuOpen) {
|
|
char buttonText[100] = "";
|
|
if (menuOpen) {
|
|
strcat(buttonText, ICON_FA_CHEVRON_RIGHT " ");
|
|
}
|
|
strcat(buttonText, text);
|
|
if (!menuOpen) { strcat(buttonText, " "); }
|
|
return buttonText;
|
|
}
|
|
|
|
// MARK: - Delegates
|
|
|
|
std::shared_ptr<SohMenuBar> mSohMenuBar;
|
|
|
|
std::shared_ptr<Ship::GuiWindow> mConsoleWindow;
|
|
std::shared_ptr<Ship::GuiWindow> mStatsWindow;
|
|
std::shared_ptr<Ship::GuiWindow> mGfxDebuggerWindow;
|
|
std::shared_ptr<Ship::GuiWindow> mInputEditorWindow;
|
|
|
|
std::shared_ptr<SohMenu> mSohMenu;
|
|
std::shared_ptr<AudioEditor> mAudioEditorWindow;
|
|
std::shared_ptr<InputViewer> mInputViewer;
|
|
std::shared_ptr<InputViewerSettingsWindow> mInputViewerSettings;
|
|
std::shared_ptr<CosmeticsEditorWindow> mCosmeticsEditorWindow;
|
|
std::shared_ptr<ActorViewerWindow> mActorViewerWindow;
|
|
std::shared_ptr<ColViewerWindow> mColViewerWindow;
|
|
std::shared_ptr<SaveEditorWindow> mSaveEditorWindow;
|
|
std::shared_ptr<HookDebuggerWindow> mHookDebuggerWindow;
|
|
std::shared_ptr<DLViewerWindow> mDLViewerWindow;
|
|
std::shared_ptr<ValueViewerWindow> mValueViewerWindow;
|
|
std::shared_ptr<MessageViewer> mMessageViewerWindow;
|
|
std::shared_ptr<GameplayStatsWindow> mGameplayStatsWindow;
|
|
std::shared_ptr<CheckTracker::CheckTrackerSettingsWindow> mCheckTrackerSettingsWindow;
|
|
std::shared_ptr<CheckTracker::CheckTrackerWindow> mCheckTrackerWindow;
|
|
std::shared_ptr<EntranceTrackerSettingsWindow> mEntranceTrackerSettingsWindow;
|
|
std::shared_ptr<EntranceTrackerWindow> mEntranceTrackerWindow;
|
|
std::shared_ptr<ItemTrackerSettingsWindow> mItemTrackerSettingsWindow;
|
|
std::shared_ptr<ItemTrackerWindow> mItemTrackerWindow;
|
|
std::shared_ptr<TimeSplitWindow> mTimeSplitWindow;
|
|
std::shared_ptr<PlandomizerWindow> mPlandomizerWindow;
|
|
std::shared_ptr<RandomizerSettingsWindow> mRandomizerSettingsWindow;
|
|
std::shared_ptr<SohModalWindow> mModalWindow;
|
|
std::shared_ptr<Notification::Window> mNotificationWindow;
|
|
std::shared_ptr<TimeDisplayWindow> mTimeDisplayWindow;
|
|
|
|
UIWidgets::Colors GetMenuThemeColor() {
|
|
return mSohMenu->GetMenuThemeColor();
|
|
}
|
|
|
|
void SetupGuiElements() {
|
|
auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui();
|
|
|
|
/*mSohMenuBar = std::make_shared<SohMenuBar>(CVAR_MENU_BAR_OPEN, CVarGetInteger(CVAR_MENU_BAR_OPEN, 0));
|
|
gui->SetMenuBar(std::reinterpret_pointer_cast<Ship::GuiMenuBar>(mSohMenuBar));
|
|
|
|
if (!gui->GetMenuBar() && !CVarGetInteger("gSettings.DisableMenuShortcutNotify", 0)) {
|
|
#if defined(__SWITCH__) || defined(__WIIU__)
|
|
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
|
|
}*/
|
|
|
|
mSohMenu = std::make_shared<SohMenu>(CVAR_WINDOW("Menu"), "Port Menu");
|
|
gui->SetMenu(mSohMenu);
|
|
|
|
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("Gfx Debugger");
|
|
if (mGfxDebuggerWindow == nullptr) {
|
|
SPDLOG_ERROR("Could not find Gfx Debugger window");
|
|
}
|
|
|
|
mInputEditorWindow = gui->GetGuiWindow("Controller Configuration");
|
|
if (mInputEditorWindow == nullptr) {
|
|
SPDLOG_ERROR("Could not find input editor window");
|
|
}
|
|
|
|
mAudioEditorWindow = std::make_shared<AudioEditor>(CVAR_WINDOW("AudioEditor"), "Audio Editor", ImVec2(820, 630));
|
|
gui->AddGuiWindow(mAudioEditorWindow);
|
|
mInputViewer = std::make_shared<InputViewer>(CVAR_WINDOW("InputViewer"), "Input Viewer");
|
|
gui->AddGuiWindow(mInputViewer);
|
|
mInputViewerSettings = std::make_shared<InputViewerSettingsWindow>(CVAR_WINDOW("InputViewerSettings"), "Input Viewer Settings", ImVec2(500, 525));
|
|
gui->AddGuiWindow(mInputViewerSettings);
|
|
mCosmeticsEditorWindow = std::make_shared<CosmeticsEditorWindow>(CVAR_WINDOW("CosmeticsEditor"), "Cosmetics Editor", ImVec2(550, 520));
|
|
gui->AddGuiWindow(mCosmeticsEditorWindow);
|
|
mActorViewerWindow = std::make_shared<ActorViewerWindow>(CVAR_WINDOW("ActorViewer"), "Actor Viewer", ImVec2(520, 600));
|
|
gui->AddGuiWindow(mActorViewerWindow);
|
|
mColViewerWindow = std::make_shared<ColViewerWindow>(CVAR_WINDOW("CollisionViewer"), "Collision Viewer", ImVec2(520, 600));
|
|
gui->AddGuiWindow(mColViewerWindow);
|
|
mSaveEditorWindow = std::make_shared<SaveEditorWindow>(CVAR_WINDOW("SaveEditor"), "Save Editor", ImVec2(520, 600));
|
|
gui->AddGuiWindow(mSaveEditorWindow);
|
|
mHookDebuggerWindow = std::make_shared<HookDebuggerWindow>(CVAR_WINDOW("HookDebugger"), "Hook Debugger", ImVec2(1250, 850));
|
|
gui->AddGuiWindow(mHookDebuggerWindow);
|
|
mDLViewerWindow = std::make_shared<DLViewerWindow>(CVAR_WINDOW("DisplayListViewer"), "Display List Viewer", ImVec2(520, 600));
|
|
gui->AddGuiWindow(mDLViewerWindow);
|
|
mValueViewerWindow = std::make_shared<ValueViewerWindow>(CVAR_WINDOW("ValueViewer"), "Value Viewer", ImVec2(520, 600));
|
|
gui->AddGuiWindow(mValueViewerWindow);
|
|
mMessageViewerWindow = std::make_shared<MessageViewer>(CVAR_WINDOW("MessageViewer"), "Message Viewer", ImVec2(520, 600));
|
|
gui->AddGuiWindow(mMessageViewerWindow);
|
|
mGameplayStatsWindow = std::make_shared<GameplayStatsWindow>(CVAR_WINDOW("GameplayStats"), "Gameplay Stats", ImVec2(480, 550));
|
|
gui->AddGuiWindow(mGameplayStatsWindow);
|
|
mCheckTrackerWindow = std::make_shared<CheckTracker::CheckTrackerWindow>(CVAR_WINDOW("CheckTracker"), "Check Tracker", ImVec2(400, 540));
|
|
gui->AddGuiWindow(mCheckTrackerWindow);
|
|
mCheckTrackerSettingsWindow = std::make_shared<CheckTracker::CheckTrackerSettingsWindow>(CVAR_WINDOW("CheckTrackerSettings"), "Check Tracker Settings", ImVec2(600, 375));
|
|
gui->AddGuiWindow(mCheckTrackerSettingsWindow);
|
|
mEntranceTrackerWindow = std::make_shared<EntranceTrackerWindow>(CVAR_WINDOW("EntranceTracker"), "Entrance Tracker", ImVec2(500, 750));
|
|
gui->AddGuiWindow(mEntranceTrackerWindow);
|
|
mEntranceTrackerSettingsWindow = std::make_shared<EntranceTrackerSettingsWindow>(CVAR_WINDOW("EntranceTrackerSettings"), "Entrance Tracker Settings", ImVec2(600, 375));
|
|
gui->AddGuiWindow(mEntranceTrackerSettingsWindow);
|
|
mItemTrackerWindow = std::make_shared<ItemTrackerWindow>(CVAR_WINDOW("ItemTracker"), "Item Tracker", ImVec2(350, 600));
|
|
gui->AddGuiWindow(mItemTrackerWindow);
|
|
mItemTrackerSettingsWindow = std::make_shared<ItemTrackerSettingsWindow>(CVAR_WINDOW("ItemTrackerSettings"), "Item Tracker Settings", ImVec2(733, 472));
|
|
gui->AddGuiWindow(mItemTrackerSettingsWindow);
|
|
mRandomizerSettingsWindow = std::make_shared<RandomizerSettingsWindow>(CVAR_WINDOW("RandomizerSettings"), "Randomizer Settings", ImVec2(920, 600));
|
|
gui->AddGuiWindow(mRandomizerSettingsWindow);
|
|
mTimeSplitWindow = std::make_shared<TimeSplitWindow>(CVAR_WINDOW("TimeSplits"), "Time Splits", ImVec2(450, 660));
|
|
gui->AddGuiWindow(mTimeSplitWindow);
|
|
mPlandomizerWindow = std::make_shared<PlandomizerWindow>(CVAR_WINDOW("PlandomizerEditor"), "Plandomizer Editor", ImVec2(850, 760));
|
|
gui->AddGuiWindow(mPlandomizerWindow);
|
|
mModalWindow = std::make_shared<SohModalWindow>(CVAR_WINDOW("ModalWindow"), "Modal Window");
|
|
gui->AddGuiWindow(mModalWindow);
|
|
mModalWindow->Show();
|
|
mNotificationWindow = std::make_shared<Notification::Window>(CVAR_WINDOW("Notifications"), "Notifications Window");
|
|
gui->AddGuiWindow(mNotificationWindow);
|
|
mNotificationWindow->Show();
|
|
mTimeDisplayWindow = std::make_shared<TimeDisplayWindow>(CVAR_WINDOW("TimeDisplayEnabled"), "Additional Timers");
|
|
gui->AddGuiWindow(mTimeDisplayWindow);
|
|
}
|
|
|
|
void Destroy() {
|
|
auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui();
|
|
gui->RemoveAllGuiWindows();
|
|
|
|
mNotificationWindow = nullptr;
|
|
mModalWindow = nullptr;
|
|
mRandomizerSettingsWindow = nullptr;
|
|
mItemTrackerWindow = nullptr;
|
|
mItemTrackerSettingsWindow = nullptr;
|
|
mEntranceTrackerWindow = nullptr;
|
|
mEntranceTrackerSettingsWindow = nullptr;
|
|
mCheckTrackerWindow = nullptr;
|
|
mCheckTrackerSettingsWindow = nullptr;
|
|
mGameplayStatsWindow = nullptr;
|
|
mDLViewerWindow = nullptr;
|
|
mValueViewerWindow = nullptr;
|
|
mMessageViewerWindow = nullptr;
|
|
mSaveEditorWindow = nullptr;
|
|
mHookDebuggerWindow = nullptr;
|
|
mColViewerWindow = nullptr;
|
|
mActorViewerWindow = nullptr;
|
|
mCosmeticsEditorWindow = nullptr;
|
|
mAudioEditorWindow = nullptr;
|
|
mInputEditorWindow = nullptr;
|
|
mStatsWindow = nullptr;
|
|
mConsoleWindow = nullptr;
|
|
mGfxDebuggerWindow = nullptr;
|
|
mSohMenuBar = nullptr;
|
|
mInputViewer = nullptr;
|
|
mInputViewerSettings = nullptr;
|
|
mTimeSplitWindow = nullptr;
|
|
mPlandomizerWindow = nullptr;
|
|
mTimeDisplayWindow = nullptr;
|
|
}
|
|
|
|
void RegisterPopup(std::string title, std::string message, std::string button1, std::string button2, std::function<void()> button1callback, std::function<void()> button2callback) {
|
|
mModalWindow->RegisterPopup(title, message, button1, button2, button1callback, button2callback);
|
|
}
|
|
|
|
void ShowRandomizerSettingsMenu() {
|
|
mRandomizerSettingsWindow->Show();
|
|
}
|
|
}
|