gui/unit_recruit: Add alignment and race hints for filtering
This adds the human-readable version of each unit's alignment and their (gendered) race name and plural race name as hints for the filter box functionality, so that players can enter keywords such as "liminal", "dwarves", "mermaid" and get what they expect even if those words are not literally part of the unit type names.
This commit is contained in:
parent
3a8c234df7
commit
df4039d593
1 changed files with 8 additions and 1 deletions
|
@ -79,11 +79,18 @@ void unit_recruit::filter_text_changed(const std::string& text)
|
|||
const unit_type* type = recruit_list_[i];
|
||||
if(!type) continue;
|
||||
|
||||
auto default_gender = !type->genders().empty()
|
||||
? type->genders().front() : unit_race::MALE;
|
||||
const auto* race = type->race();
|
||||
|
||||
// List of possible match criteria for this unit type. Empty values will
|
||||
// never match.
|
||||
auto criteria = std::make_tuple(
|
||||
(game_config::debug ? type->id() : ""),
|
||||
type->type_name()
|
||||
type->type_name(),
|
||||
unit_type::alignment_description(type->alignment(), default_gender),
|
||||
(race ? race->name(default_gender) : ""),
|
||||
(race ? race->plural_name() : "")
|
||||
);
|
||||
|
||||
bool found = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue