From 36014bb347443893af4f48ff69d72bb11ac278a8 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Tue, 1 Jul 2025 19:45:43 -0700 Subject: [PATCH] Implement widget search exclusion. Exclude all external windows from the search. --- soh/soh/SohGui/Menu.cpp | 3 +- soh/soh/SohGui/MenuTypes.h | 89 +++++++++++++++----------- soh/soh/SohGui/SohMenuDevTools.cpp | 10 +++ soh/soh/SohGui/SohMenuEnhancements.cpp | 4 ++ soh/soh/SohGui/SohMenuRandomizer.cpp | 8 +++ soh/soh/SohGui/SohMenuSettings.cpp | 3 + 6 files changed, 80 insertions(+), 37 deletions(-) diff --git a/soh/soh/SohGui/Menu.cpp b/soh/soh/SohGui/Menu.cpp index 5a609a935..c3e6e27da 100644 --- a/soh/soh/SohGui/Menu.cpp +++ b/soh/soh/SohGui/Menu.cpp @@ -195,7 +195,8 @@ uint32_t Menu::DrawSearchResults(std::string& menuSearchText) { auto& column = sidebar.columnWidgets.at(i); for (auto& info : column) { if (info.type == WIDGET_SEARCH || info.type == WIDGET_SEPARATOR || - info.type == WIDGET_SEPARATOR_TEXT || info.isHidden) { + info.type == WIDGET_SEPARATOR_TEXT || info.isHidden || + info.hideInSearch) { continue; } const char* tooltip = info.options->tooltip; diff --git a/soh/soh/SohGui/MenuTypes.h b/soh/soh/SohGui/MenuTypes.h index e96d015ef..5a22104fa 100644 --- a/soh/soh/SohGui/MenuTypes.h +++ b/soh/soh/SohGui/MenuTypes.h @@ -111,11 +111,13 @@ struct WidgetInfo { bool isHidden = false; bool sameLine = false; bool raceDisable = true; + bool hideInSearch = false; WidgetInfo& CVar(const char* cVar_) { cVar = cVar_; return *this; } + WidgetInfo& Options(OptionsVariant options_) { switch (type) { case WIDGET_AUDIO_BACKEND: @@ -155,48 +157,63 @@ struct WidgetInfo { } return *this; } + + WidgetInfo& Options(std::shared_ptr options_) { + options = options_; + return *this; + } + + WidgetInfo& Callback(WidgetFunc callback_) { + callback = callback_; + return *this; + } + + WidgetInfo& PreFunc(WidgetFunc preFunc_) { + preFunc = preFunc_; + return *this; + } + + WidgetInfo& PostFunc(WidgetFunc postFunc_) { + postFunc = postFunc_; + return *this; + } + + WidgetInfo& WindowName(const char* windowName_) { + windowName = windowName_; + return *this; + } + + WidgetInfo& ValuePointer(std::variant valuePointer_) { + valuePointer = valuePointer_; + return *this; + } + + WidgetInfo& SameLine(bool sameLine_) { + sameLine = sameLine_; + return *this; + } + + WidgetInfo& CustomFunction(WidgetFunc customFunction_) { + customFunction = customFunction_; + return *this; + } + + WidgetInfo& RaceDisable(bool disable) { + raceDisable = disable; + return *this; + } + + WidgetInfo& HideInSearch(bool hide) { + hideInSearch = hide; + return *this; + } + void ResetDisables() { isHidden = false; options->disabled = false; options->disabledTooltip = ""; activeDisables.clear(); } - WidgetInfo& Options(std::shared_ptr options_) { - options = options_; - return *this; - } - WidgetInfo& Callback(WidgetFunc callback_) { - callback = callback_; - return *this; - } - WidgetInfo& PreFunc(WidgetFunc preFunc_) { - preFunc = preFunc_; - return *this; - } - WidgetInfo& PostFunc(WidgetFunc postFunc_) { - postFunc = postFunc_; - return *this; - } - WidgetInfo& WindowName(const char* windowName_) { - windowName = windowName_; - return *this; - } - WidgetInfo& ValuePointer(std::variant valuePointer_) { - valuePointer = valuePointer_; - return *this; - } - WidgetInfo& SameLine(bool sameLine_) { - sameLine = sameLine_; - return *this; - } - WidgetInfo& CustomFunction(WidgetFunc customFunction_) { - customFunction = customFunction_; - return *this; - } - WidgetInfo& RaceDisable(bool disable) { - raceDisable = disable; - return *this; - } }; struct WidgetPath { diff --git a/soh/soh/SohGui/SohMenuDevTools.cpp b/soh/soh/SohGui/SohMenuDevTools.cpp index 2a0fcd62a..f9e113b55 100644 --- a/soh/soh/SohGui/SohMenuDevTools.cpp +++ b/soh/soh/SohGui/SohMenuDevTools.cpp @@ -124,6 +124,7 @@ void SohMenu::AddMenuDevTools() { .CVar(CVAR_WINDOW("SohStats")) .RaceDisable(false) .WindowName("Stats##Soh") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Enables the separate Stats Window.")); // Console @@ -132,6 +133,7 @@ void SohMenu::AddMenuDevTools() { AddWidget(path, "Popout Console", WIDGET_WINDOW_BUTTON) .CVar(CVAR_WINDOW("SohConsole")) .WindowName("Console##SoH") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Enables the separate Console Window.")); // Save Editor @@ -140,6 +142,7 @@ void SohMenu::AddMenuDevTools() { AddWidget(path, "Popout Save Editor", WIDGET_WINDOW_BUTTON) .CVar(CVAR_WINDOW("SaveEditor")) .WindowName("Save Editor") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Enables the separate Save Editor Window.")); // Hook Debugger @@ -148,6 +151,7 @@ void SohMenu::AddMenuDevTools() { AddWidget(path, "Popout Hook Debugger", WIDGET_WINDOW_BUTTON) .CVar(CVAR_WINDOW("HookDebugger")) .WindowName("Hook Debugger") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Enables the separate Hook Debugger Window.")); // Collision Viewer @@ -156,6 +160,7 @@ void SohMenu::AddMenuDevTools() { AddWidget(path, "Popout Collision Viewer", WIDGET_WINDOW_BUTTON) .CVar(CVAR_WINDOW("CollisionViewer")) .WindowName("Collision Viewer") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Enables the separate Collision Viewer Window.")); // Actor Viewer @@ -164,6 +169,7 @@ void SohMenu::AddMenuDevTools() { AddWidget(path, "Popout Actor Viewer", WIDGET_WINDOW_BUTTON) .CVar(CVAR_WINDOW("ActorViewer")) .WindowName("Actor Viewer") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Enables the separate Actor Viewer Window.")); // Display List Viewer @@ -172,6 +178,7 @@ void SohMenu::AddMenuDevTools() { AddWidget(path, "Popout Display List Viewer", WIDGET_WINDOW_BUTTON) .CVar(CVAR_WINDOW("DisplayListViewer")) .WindowName("Display List Viewer") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Enables the separate Display List Viewer Window.")); // Value Viewer @@ -180,6 +187,7 @@ void SohMenu::AddMenuDevTools() { AddWidget(path, "Popout Value Viewer", WIDGET_WINDOW_BUTTON) .CVar(CVAR_WINDOW("ValueViewer")) .WindowName("Value Viewer") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Enables the separate Value Viewer Window.")); // Message Viewer @@ -188,6 +196,7 @@ void SohMenu::AddMenuDevTools() { AddWidget(path, "Popout Message Viewer", WIDGET_WINDOW_BUTTON) .CVar(CVAR_WINDOW("MessageViewer")) .WindowName("Message Viewer") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Enables the separate Message Viewer Window.")); // Gfx Debugger @@ -196,6 +205,7 @@ void SohMenu::AddMenuDevTools() { AddWidget(path, "Popout Gfx Debugger", WIDGET_WINDOW_BUTTON) .CVar(CVAR_WINDOW("SohGfxDebugger")) .WindowName("GfxDebugger##SoH") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Enables the separate Gfx Debugger Window.")); } diff --git a/soh/soh/SohGui/SohMenuEnhancements.cpp b/soh/soh/SohGui/SohMenuEnhancements.cpp index eda3d85bb..4f6d449fe 100644 --- a/soh/soh/SohGui/SohMenuEnhancements.cpp +++ b/soh/soh/SohGui/SohMenuEnhancements.cpp @@ -1826,6 +1826,7 @@ void SohMenu::AddMenuEnhancements() { .CVar(CVAR_WINDOW("CosmeticsEditor")) .RaceDisable(false) .WindowName("Cosmetics Editor") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Enables the separate Cosmetics Editor Window.")); // Audio Editor @@ -1835,6 +1836,7 @@ void SohMenu::AddMenuEnhancements() { .CVar(CVAR_WINDOW("AudioEditor")) .RaceDisable(false) .WindowName("Audio Editor") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Enables the separate Audio Editor Window.")); // Gameplay Stats @@ -1844,6 +1846,7 @@ void SohMenu::AddMenuEnhancements() { .CVar(CVAR_WINDOW("GameplayStats")) .RaceDisable(false) .WindowName("Gameplay Stats") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Enables the separate Gameplay Stats Window.")); // Time Splits @@ -1853,6 +1856,7 @@ void SohMenu::AddMenuEnhancements() { .CVar(CVAR_WINDOW("TimeSplits")) .RaceDisable(false) .WindowName("Time Splits") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Enables the separate Time Splits Window.")); // Timers diff --git a/soh/soh/SohGui/SohMenuRandomizer.cpp b/soh/soh/SohGui/SohMenuRandomizer.cpp index 47e651408..ad688740a 100644 --- a/soh/soh/SohGui/SohMenuRandomizer.cpp +++ b/soh/soh/SohGui/SohMenuRandomizer.cpp @@ -22,6 +22,7 @@ void SohMenu::AddMenuRandomizer() { AddWidget(path, "Popout Randomizer Settings Window", WIDGET_WINDOW_BUTTON) .CVar(CVAR_WINDOW("RandomizerSettings")) .WindowName("Randomizer Settings") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Enables the separate Randomizer Settings Window.")); // Enhancements @@ -104,6 +105,7 @@ void SohMenu::AddMenuRandomizer() { .CVar(CVAR_WINDOW("PlandomizerEditor")) .RaceDisable(false) .WindowName("Plandomizer Editor") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Enables the separate Randomizer Settings Window.")); // Item Tracker @@ -115,6 +117,7 @@ void SohMenu::AddMenuRandomizer() { .CVar(CVAR_WINDOW("ItemTracker")) .RaceDisable(false) .WindowName("Item Tracker") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Toggles the Item Tracker.").EmbedWindow(false)); AddWidget(path, "Item Tracker Settings", WIDGET_SEPARATOR_TEXT); @@ -122,6 +125,7 @@ void SohMenu::AddMenuRandomizer() { .CVar(CVAR_WINDOW("ItemTrackerSettings")) .RaceDisable(false) .WindowName("Item Tracker Settings") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Enables the separate Item Tracker Settings Window.")); // Entrance Tracker @@ -133,6 +137,7 @@ void SohMenu::AddMenuRandomizer() { .CVar(CVAR_WINDOW("EntranceTracker")) .RaceDisable(false) .WindowName("Entrance Tracker") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Toggles the Entrance Tracker.").EmbedWindow(false)); AddWidget(path, "Entrance Tracker Settings", WIDGET_SEPARATOR_TEXT); @@ -140,6 +145,7 @@ void SohMenu::AddMenuRandomizer() { .CVar(CVAR_WINDOW("EntranceTrackerSettings")) .RaceDisable(false) .WindowName("Entrance Tracker Settings") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Enables the separate Entrance Tracker Settings Window.")); // Check Tracker @@ -151,6 +157,7 @@ void SohMenu::AddMenuRandomizer() { .CVar(CVAR_WINDOW("CheckTracker")) .RaceDisable(false) .WindowName("Check Tracker") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Toggles the Check Tracker.").EmbedWindow(false)); AddWidget(path, "Check Tracker Settings", WIDGET_SEPARATOR_TEXT); @@ -158,6 +165,7 @@ void SohMenu::AddMenuRandomizer() { .CVar(CVAR_WINDOW("CheckTrackerSettings")) .RaceDisable(false) .WindowName("Check Tracker Settings") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Enables the separate Check Tracker Settings Window.")); } diff --git a/soh/soh/SohGui/SohMenuSettings.cpp b/soh/soh/SohGui/SohMenuSettings.cpp index bb7c82574..52d1a53c4 100644 --- a/soh/soh/SohGui/SohMenuSettings.cpp +++ b/soh/soh/SohGui/SohMenuSettings.cpp @@ -416,6 +416,7 @@ void SohMenu::AddMenuSettings() { .CVar(CVAR_WINDOW("ControllerConfiguration")) .RaceDisable(false) .WindowName("Configure Controller") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Enables the separate Bindings Window.")); // Input Viewer @@ -426,6 +427,7 @@ void SohMenu::AddMenuSettings() { .CVar(CVAR_WINDOW("InputViewer")) .RaceDisable(false) .WindowName("Input Viewer") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Toggles the Input Viewer.").EmbedWindow(false)); AddWidget(path, "Input Viewer Settings", WIDGET_SEPARATOR_TEXT); @@ -433,6 +435,7 @@ void SohMenu::AddMenuSettings() { .CVar(CVAR_WINDOW("InputViewerSettings")) .RaceDisable(false) .WindowName("Input Viewer Settings") + .HideInSearch(true) .Options(WindowButtonOptions().Tooltip("Enables the separate Input Viewer Settings Window.")); // Notifications