summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalkierian <malkierian@gmail.com>2025-06-11 14:35:57 -0700
committerGitHub <noreply@github.com>2025-06-11 14:35:57 -0700
commit0b9fe2d9b967737d643cca55de936547d6749c18 (patch)
treedf6d12c5c7f1131f5c2e6d60ed281460a9fdbd29
parentad850e50b10f75df541dad5e8bf1ff506be5befa (diff)
Fix Search Crash from Scrolling (#5571)
* Fix search crashing when section child scrolled too far. * clang
-rw-r--r--soh/soh/SohGui/Menu.cpp54
1 files changed, 28 insertions, 26 deletions
diff --git a/soh/soh/SohGui/Menu.cpp b/soh/soh/SohGui/Menu.cpp
index 87c362496..5a609a935 100644
--- a/soh/soh/SohGui/Menu.cpp
+++ b/soh/soh/SohGui/Menu.cpp
@@ -185,33 +185,35 @@ bool ModernMenuHeaderEntry(std::string label) {
}
uint32_t Menu::DrawSearchResults(std::string& menuSearchText) {
- ImGui::BeginChild("Search Results");
int searchCount = 0;
- for (auto& menuLabel : menuOrder) {
- auto& menuEntry = menuEntries.at(menuLabel);
- for (auto& sidebarLabel : menuEntry.sidebarOrder) {
- auto& sidebar = menuEntry.sidebars[sidebarLabel];
- for (int i = 0; i < sidebar.columnWidgets.size(); i++) {
- 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) {
- continue;
- }
- const char* tooltip = info.options->tooltip;
- std::string widgetStr = std::string(info.name) + std::string(tooltip != NULL ? tooltip : "");
- std::transform(menuSearchText.begin(), menuSearchText.end(), menuSearchText.begin(), ::tolower);
- menuSearchText.erase(std::remove(menuSearchText.begin(), menuSearchText.end(), ' '),
- menuSearchText.end());
- std::transform(widgetStr.begin(), widgetStr.end(), widgetStr.begin(), ::tolower);
- widgetStr.erase(std::remove(widgetStr.begin(), widgetStr.end(), ' '), widgetStr.end());
- if (widgetStr.find(menuSearchText) != std::string::npos) {
- MenuDrawItem(info, 90 / sidebar.columnCount, menuThemeIndex);
- ImGui::PushStyleColor(ImGuiCol_Text, UIWidgets::ColorValues.at(UIWidgets::Colors::Gray));
- std::string origin = fmt::format(" ({} -> {}, Col {})", menuEntry.label, sidebarLabel, i + 1);
- ImGui::Text("%s", origin.c_str());
- ImGui::PopStyleColor();
- searchCount++;
+ if (ImGui::BeginChild("Search Results")) {
+ for (auto& menuLabel : menuOrder) {
+ auto& menuEntry = menuEntries.at(menuLabel);
+ for (auto& sidebarLabel : menuEntry.sidebarOrder) {
+ auto& sidebar = menuEntry.sidebars[sidebarLabel];
+ for (int i = 0; i < sidebar.columnWidgets.size(); i++) {
+ 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) {
+ continue;
+ }
+ const char* tooltip = info.options->tooltip;
+ std::string widgetStr = std::string(info.name) + std::string(tooltip != NULL ? tooltip : "");
+ std::transform(menuSearchText.begin(), menuSearchText.end(), menuSearchText.begin(), ::tolower);
+ menuSearchText.erase(std::remove(menuSearchText.begin(), menuSearchText.end(), ' '),
+ menuSearchText.end());
+ std::transform(widgetStr.begin(), widgetStr.end(), widgetStr.begin(), ::tolower);
+ widgetStr.erase(std::remove(widgetStr.begin(), widgetStr.end(), ' '), widgetStr.end());
+ if (widgetStr.find(menuSearchText) != std::string::npos) {
+ MenuDrawItem(info, 90 / sidebar.columnCount, menuThemeIndex);
+ ImGui::PushStyleColor(ImGuiCol_Text, UIWidgets::ColorValues.at(UIWidgets::Colors::Gray));
+ std::string origin =
+ fmt::format(" ({} -> {}, Col {})", menuEntry.label, sidebarLabel, i + 1);
+ ImGui::Text("%s", origin.c_str());
+ ImGui::PopStyleColor();
+ searchCount++;
+ }
}
}
}