From b0befbc2b20ec1b8b962e7628a15a82c37175e76 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Thu, 3 Jul 2025 09:08:11 -0700 Subject: [PATCH] Add second column to search results for non-widget results. --- soh/soh/Enhancements/Presets/Presets.cpp | 3 ++- soh/soh/SohGui/Menu.cpp | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/soh/soh/Enhancements/Presets/Presets.cpp b/soh/soh/Enhancements/Presets/Presets.cpp index b84cb95ca..5ab8813d0 100644 --- a/soh/soh/Enhancements/Presets/Presets.cpp +++ b/soh/soh/Enhancements/Presets/Presets.cpp @@ -437,7 +437,8 @@ void PresetsCustomWidget(WidgetInfo& info) { void RegisterPresetsWidgets() { SohGui::mSohMenu->AddSidebarEntry("Settings", "Presets", 1); WidgetPath path = { "Settings", "Presets", SECTION_COLUMN_1 }; - SohGui::mSohMenu->AddWidget(path, "PresetsWidget", WIDGET_CUSTOM).CustomFunction(PresetsCustomWidget); + SohGui::mSohMenu->AddWidget(path, "PresetsWidget", WIDGET_CUSTOM).CustomFunction(PresetsCustomWidget) + .HideInSearch(true); presetFolder = Ship::Context::GetInstance()->GetPathRelativeToAppDirectory("presets"); std::fill_n(saveSection, PRESET_SECTION_MAX, true); LoadPresets(); diff --git a/soh/soh/SohGui/Menu.cpp b/soh/soh/SohGui/Menu.cpp index c3e6e27da..dc74ab7fd 100644 --- a/soh/soh/SohGui/Menu.cpp +++ b/soh/soh/SohGui/Menu.cpp @@ -186,7 +186,9 @@ bool ModernMenuHeaderEntry(std::string label) { uint32_t Menu::DrawSearchResults(std::string& menuSearchText) { int searchCount = 0; - if (ImGui::BeginChild("Search Results")) { + ImGui::SetNextWindowSizeConstraints({ ImGui::GetContentRegionAvail().x / 2, 0}, {ImGui::GetContentRegionAvail().x / 2, ImGui::GetContentRegionAvail().y}); + if (ImGui::BeginChild("Search Results Col 1", { ImGui::GetContentRegionAvail().x / 2, windowHeight * 4 }, ImGuiChildFlags_AutoResizeY, + ImGuiWindowFlags_NoTitleBar)) { for (auto& menuLabel : menuOrder) { auto& menuEntry = menuEntries.at(menuLabel); for (auto& sidebarLabel : menuEntry.sidebarOrder) { @@ -195,7 +197,7 @@ 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; } @@ -219,6 +221,7 @@ uint32_t Menu::DrawSearchResults(std::string& menuSearchText) { } } } + ImGui::EndChild(); } return searchCount; } @@ -474,7 +477,6 @@ void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors me return; } DrawSearchResults(menuSearchText); - ImGui::EndChild(); } break; default: break; @@ -798,12 +800,6 @@ void Menu::DrawElement() { ImGuiWindowFlags_NoTitleBar); } if (headerSearch && menuSearchText.length() > 0) { - uint32_t searchCount = DrawSearchResults(menuSearchText); - if (searchCount == 0) { - ImGui::SetCursorPosX((ImGui::GetWindowWidth() - ImGui::CalcTextSize("No results found").x) / 2); - ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10.0f); - ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 0.4f), "No results found"); - } ImGui::SetCursorPosX((ImGui::GetWindowWidth() - ImGui::CalcTextSize("Clear Search").x) / 2 - 10.0f); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10.0f); UIWidgets::ButtonOptions clearBtnOpts = {}; @@ -811,8 +807,12 @@ void Menu::DrawElement() { if (UIWidgets::Button("Clear Search", clearBtnOpts)) { menuSearch.Clear(); } - - ImGui::EndChild(); + uint32_t searchCount = DrawSearchResults(menuSearchText); + if (searchCount == 0) { + ImGui::SetCursorPosX((ImGui::GetWindowWidth() - ImGui::CalcTextSize("No results found").x) / 2); + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10.0f); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 0.4f), "No results found"); + } } else { std::string menuLabel = menuEntries.at(headerIndex).label; if (MenuInit::GetUpdateFuncs().contains(menuLabel)) {