diff --git a/changelog.md b/changelog.md index c3b3158e0e7f..5f70c73e0fb6 100644 --- a/changelog.md +++ b/changelog.md @@ -68,6 +68,7 @@ * Fixed the debug mode Create Unit dialog crashing when changing the gender of the previous selection after causing the list to come up empty using the filter box. + * Allow searching by race with the Create Unit filter box as well. ## Version 1.14.4 ### Security Fixes diff --git a/src/gui/dialogs/unit_create.cpp b/src/gui/dialogs/unit_create.cpp index 7a41edff99c1..974619aa649e 100644 --- a/src/gui/dialogs/unit_create.cpp +++ b/src/gui/dialogs/unit_create.cpp @@ -201,6 +201,18 @@ void unit_create::list_item_clicked(window& window) }); } +namespace +{ + +bool ci_search(const std::string& a, const std::string& b) +{ + return std::search(a.begin(), a.end(), + b.begin(), b.end(), + chars_equal_insensitive) != a.end(); +} + +} // end unnamed namespace + void unit_create::filter_text_changed(text_box_base* textbox, const std::string& text) { window& window = *textbox->get_window(); @@ -223,16 +235,14 @@ void unit_create::filter_text_changed(text_box_base* textbox, const std::string& grid::iterator it = row->begin(); label& type_label = find_widget