Skip to content

Commit

Permalink
Merge pull request #45 from Malkierian/modern-menu
Browse files Browse the repository at this point in the history
Fix search function not looking past first columns.
  • Loading branch information
aMannus authored Jan 31, 2025
2 parents 82a7875 + 55ce63a commit 46c15fb
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions soh/soh/SohGui/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,29 +179,30 @@ uint32_t Menu::DrawSearchResults(std::string& menuSearchText) {
auto& menuEntry = menuEntries.at(menuLabel);
for (auto& sidebarLabel : menuEntry.sidebarOrder) {
auto& sidebar = menuEntry.sidebars[sidebarLabel];
int column = 1;
for (auto& info : sidebar.columnWidgets[column - 1]) {
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, UIWidgets2::ColorValues.at(UIWidgets2::Colors::Gray));
std::string origin = fmt::format(" ({} -> {}, Col {})", menuEntry.label, sidebarLabel, column);
ImGui::Text("%s", origin.c_str());
ImGui::PopStyleColor();
searchCount++;
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, UIWidgets2::ColorValues.at(UIWidgets2::Colors::Gray));
std::string origin = fmt::format(" ({} -> {}, Col {})", menuEntry.label, sidebarLabel, i + 1);
ImGui::Text("%s", origin.c_str());
ImGui::PopStyleColor();
searchCount++;
}
}
}
column++;
}
}
return searchCount;
Expand Down

0 comments on commit 46c15fb

Please sign in to comment.