|
|
|
@ -410,12 +410,19 @@ function AssignAnimal:refresh_list(sort_widget, sort_fn)
|
|
|
|
|
list:setFilter(saved_filter)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function make_search_key(desc)
|
|
|
|
|
local out = ''
|
|
|
|
|
for c in dfhack.toSearchNormalized(desc):gmatch("[%w%s]") do
|
|
|
|
|
out = out .. c:lower()
|
|
|
|
|
function add_words(words, str)
|
|
|
|
|
for word in dfhack.toSearchNormalized(str):gmatch("[%w-]+") do
|
|
|
|
|
table.insert(words, word:lower())
|
|
|
|
|
end
|
|
|
|
|
return out
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function make_search_key(desc, race_raw)
|
|
|
|
|
local words = {}
|
|
|
|
|
add_words(words, desc)
|
|
|
|
|
if race_raw then
|
|
|
|
|
add_words(words, race_raw.name[0])
|
|
|
|
|
end
|
|
|
|
|
return table.concat(words, ' ')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function AssignAnimal:make_choice_text(data)
|
|
|
|
@ -551,7 +558,7 @@ function AssignAnimal:cache_choices()
|
|
|
|
|
graze=dfhack.units.isGrazer(unit),
|
|
|
|
|
}
|
|
|
|
|
local choice = {
|
|
|
|
|
search_key=make_search_key(data.desc),
|
|
|
|
|
search_key=make_search_key(data.desc, raw),
|
|
|
|
|
data=data,
|
|
|
|
|
text=self:make_choice_text(data),
|
|
|
|
|
}
|
|
|
|
@ -570,7 +577,7 @@ function AssignAnimal:cache_choices()
|
|
|
|
|
disposition=get_item_disposition(vermin),
|
|
|
|
|
}
|
|
|
|
|
local choice = {
|
|
|
|
|
search_key=make_search_key(data.desc),
|
|
|
|
|
search_key=make_search_key(data.desc, raw),
|
|
|
|
|
data=data,
|
|
|
|
|
text=self:make_choice_text(data),
|
|
|
|
|
}
|
|
|
|
@ -589,7 +596,7 @@ function AssignAnimal:cache_choices()
|
|
|
|
|
disposition=get_item_disposition(small_pet),
|
|
|
|
|
}
|
|
|
|
|
local choice = {
|
|
|
|
|
search_key=make_search_key(data.desc),
|
|
|
|
|
search_key=make_search_key(data.desc, raw),
|
|
|
|
|
data=data,
|
|
|
|
|
text=self:make_choice_text(data),
|
|
|
|
|
}
|
|
|
|
|