Skip to content

Commit

Permalink
gui2/unit_create: Use unit type ids as filtering criteria as well
Browse files Browse the repository at this point in the history
  • Loading branch information
irydacea committed Sep 4, 2018
1 parent 1b9bf71 commit b6f2bea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Expand Up @@ -34,7 +34,8 @@
* 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.
* Allow searching by race and internal unit type id with the Create Unit
filter box as well.

## Version 1.14.4
### Security Fixes
Expand Down
6 changes: 5 additions & 1 deletion src/gui/dialogs/unit_create.cpp
Expand Up @@ -247,11 +247,15 @@ void unit_create::filter_text_changed(text_box_base* textbox, const std::string&
label& race_label
= find_widget<label>(*it, "race", false);

assert(i < units_.size());
const std::string& unit_type_id = units_[i] ? units_[i]->id() : "";

bool found = false;
for(const auto & word : words)
{
found = ci_search(type_label.get_label().str(), word) ||
ci_search(race_label.get_label().str(), word);
ci_search(race_label.get_label().str(), word) ||
ci_search(unit_type_id, word);

if(!found) {
// one word doesn't match, we don't reach words.end()
Expand Down

0 comments on commit b6f2bea

Please sign in to comment.