Merge pull request #4049 from myk002/myk_sort_tasks

[sort] search associated building in tasks tab
develop
Myk 2023-11-20 17:45:28 -08:00 committed by GitHub
commit 121106dd04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 1 deletions

@ -65,6 +65,7 @@ Template for new versions:
- `buildingplan`: save magma safe mechanisms for when magma safety is requested when linking levers and pressure plates to targets
- `buildingplan`: when choosing mechanisms for linking levers/pressure plates, filter out unreachable mechanisms
- `tailor`: corrected a corner case that resulted in existing stock being ignored in some circumstances
- `sort`: when searching on the Tasks tab, also search the names of the things the task is associated with, such as the name of the stockpile that an item will be stored in
## Documentation

@ -104,6 +104,34 @@ local function get_cri_unit_search_key(cri_unit)
cri_unit.job_sort_name)
end
local function get_task_search_key(cri_unit)
local result = {get_cri_unit_search_key(cri_unit)}
if cri_unit.jb then
local bld = dfhack.job.getHolder(cri_unit.jb)
if bld then
table.insert(result, bld.name)
local btype = bld:getType()
if btype == df.building_type.Workshop then
table.insert(result, df.workshop_type.attrs[bld.type].name or '')
table.insert(result, df.workshop_type[bld.type])
elseif btype == df.building_type.Furnace then
table.insert(result, df.furnace_type[bld.type])
elseif btype == df.building_type.Construction then
table.insert(result, df.construction_type[bld.type])
elseif btype == df.building_type.Trap then
table.insert(result, df.trap_type[bld.trap_type])
elseif btype == df.building_type.SiegeEngine then
table.insert(result, df.siegeengine_type[bld.type])
else
table.insert(result, df.building_type.attrs[btype].name)
end
end
end
return table.concat(result, ' ')
end
local function get_race_name(raw_id)
local raw = df.creature_raw.find(raw_id)
if not raw then return end
@ -317,7 +345,7 @@ function InfoOverlay:init()
end
self:register_handler('JOBS', tasks.cri_job,
curry(sortoverlay.single_vector_search, {get_search_key_fn=get_cri_unit_search_key}),
curry(sortoverlay.single_vector_search, {get_search_key_fn=get_task_search_key}),
free_allocated_data)
self:register_handler('PET_OT', creatures.atk_index,
curry(sortoverlay.single_vector_search, {get_search_key_fn=get_race_name}))