cfg: active only filter for options search (#879)

Requested by a sea creature
This commit is contained in:
bicarus
2026-08-20 22:38:30 -07:00
committed by GitHub
parent b23640222c
commit 46f76597fc
2 changed files with 20 additions and 6 deletions
+18 -5
View File
@@ -450,6 +450,8 @@ namespace overlay::windows {
ImGuiInputTextFlags_EscapeClearsAll)) { ImGuiInputTextFlags_EscapeClearsAll)) {
this->search_filter_in_lower_case = strtolower(this->search_filter); this->search_filter_in_lower_case = strtolower(this->search_filter);
} }
// clear search terms
if (!this->search_filter.empty()) { if (!this->search_filter.empty()) {
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("Clear")) { if (ImGui::Button("Clear")) {
@@ -457,15 +459,22 @@ namespace overlay::windows {
this->search_filter_in_lower_case.clear(); this->search_filter_in_lower_case.clear();
} }
} }
// active only checkbox
ImGui::SameLine();
ImGui::Checkbox("Active Only", &this->search_active_only);
ImGui::Spacing(); ImGui::Spacing();
// draw matching options // draw matching options
if (!this->search_filter.empty()) { if (!this->search_filter.empty() || this->search_active_only) {
for (auto category : launcher::get_categories(launcher::Options::OptionsCategory::Everything)) { for (auto category : launcher::get_categories(launcher::Options::OptionsCategory::Everything)) {
this->build_options( this->build_options(
options, options,
category, category,
const_cast<std::string *>(&this->search_filter_in_lower_case)); const_cast<std::string *>(&this->search_filter_in_lower_case),
false,
this->search_active_only);
} }
} }
} else if (this->options_group_selected == OPTIONS_TAB_QUICK) { } else if (this->options_group_selected == OPTIONS_TAB_QUICK) {
@@ -5041,7 +5050,8 @@ namespace overlay::windows {
} }
void Config::build_options( void Config::build_options(
std::vector<Option> *options, const std::string &category, const std::string *filter, bool quick_only) { std::vector<Option> *options, const std::string &category, const std::string *filter,
bool quick_only, bool active_only) {
// collect the options that match the current filters. doing this once lets us // collect the options that match the current filters. doing this once lets us
// skip rendering an empty header + table for categories with no matches, and // skip rendering an empty header + table for categories with no matches, and
@@ -5066,8 +5076,11 @@ namespace overlay::windows {
if (!definition.game_name.empty() && definition.game_name != this->games_selected_name) { if (!definition.game_name.empty() && definition.game_name != this->games_selected_name) {
continue; continue;
} }
if (filter != nullptr) { if (active_only && !option.is_active()) {
if (filter->empty() || !option.search_match(*filter)) { continue;
}
if (filter != nullptr && !filter->empty()) {
if (!option.search_match(*filter)) {
continue; continue;
} }
// limit to 30 results // limit to 30 results
+2 -1
View File
@@ -141,6 +141,7 @@ namespace overlay::windows {
int options_category = 0; int options_category = 0;
std::string search_filter = ""; std::string search_filter = "";
std::string search_filter_in_lower_case = ""; std::string search_filter_in_lower_case = "";
bool search_active_only = false;
// Options tab left-nav: selected group, currently highlighted category, and a pending scroll // Options tab left-nav: selected group, currently highlighted category, and a pending scroll
std::string options_group_selected = ""; std::string options_group_selected = "";
@@ -216,7 +217,7 @@ namespace overlay::windows {
void build_option_value_picker(Option& option); void build_option_value_picker(Option& option);
void build_options( void build_options(
std::vector<Option> *options, const std::string &category, const std::string *filter=nullptr, std::vector<Option> *options, const std::string &category, const std::string *filter=nullptr,
bool quick_only=false); bool quick_only=false, bool active_only=false);
void build_options_tab(float page_offset); void build_options_tab(float page_offset);
void build_controller_tab(float page_offset, ControllerPage *page_selected_new); void build_controller_tab(float page_offset, ControllerPage *page_selected_new);
bool build_nav_header(const char *label, bool active); bool build_nav_header(const char *label, bool active);