diff --git a/changelog.md b/changelog.md index 96c5f32d671e..50684ad84a42 100644 --- a/changelog.md +++ b/changelog.md @@ -65,6 +65,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 bd8088eb8705..cb0bf83d41d4 100644 --- a/src/gui/dialogs/unit_create.cpp +++ b/src/gui/dialogs/unit_create.cpp @@ -205,6 +205,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(); @@ -227,16 +239,14 @@ void unit_create::filter_text_changed(text_box_base* textbox, const std::string& grid::iterator it = row->begin(); label& type_label = find_widget