Merge pull request #4019 from ToxicBananaParty/placesort

Add search to remaining Places pages
develop
Myk 2023-11-13 22:16:29 -08:00 committed by GitHub
commit f081bda853
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 7 deletions

@ -71,6 +71,7 @@ Template for new versions:
- `buildingplan`: display how many items are available on the planner panel - `buildingplan`: display how many items are available on the planner panel
- `buildingplan`: make it easier to build single-tile staircases of any shape (up, down, or up/down) - `buildingplan`: make it easier to build single-tile staircases of any shape (up, down, or up/down)
- `sort`: allow searching by profession on the squad assignment page - `sort`: allow searching by profession on the squad assignment page
- `sort`: add search for places screens
- `sort`: add search for work animal assignment screen; allow filtering by miltary/squad/civilian/burrow - `sort`: add search for work animal assignment screen; allow filtering by miltary/squad/civilian/burrow
- `sort`: on the squad assignment screen, make effectiveness and potential ratings use the same scale so effectiveness is always less than or equal to potential for a given unit. this way you can also tell when units are approaching their maximum potential - `sort`: on the squad assignment screen, make effectiveness and potential ratings use the same scale so effectiveness is always less than or equal to potential for a given unit. this way you can also tell when units are approaching their maximum potential
- `sort`: new overlay on the animal assignment screen that shows how many work animals each visible unit already has assigned to them - `sort`: new overlay on the animal assignment screen that shows how many work animals each visible unit already has assigned to them

@ -111,6 +111,36 @@ local function get_location_search_key(zone)
return table.concat(result, ' ') return table.concat(result, ' ')
end end
local function get_stockpile_search_key(stockpile)
if #stockpile.name ~= 0 then return stockpile.name
else return ('Stockpile #%s'):format(stockpile.stockpile_number) end
end
local function get_workshop_search_key(workshop)
local result = {}
for _, unit_id in ipairs(workshop.profile.permitted_workers) do
local unit = df.unit.find(unit_id)
if unit then table.insert(result, sortoverlay.get_unit_search_key(unit)) end
end
table.insert(result, workshop.name)
table.insert(result, df.workshop_type.attrs[workshop.type].name or '')
table.insert(result, df.workshop_type[workshop.type])
return table.concat(result, ' ')
end
local function get_farmplot_search_key(farmplot)
local result = {}
if #farmplot.name ~= 0 then table.insert(result, farmplot.name) else table.insert(result, 'Farm Plot') end
local plant = df.plant_raw.find(farmplot.plant_id[farmplot.last_season])
if plant then table.insert(result, plant.name_plural) end
return table.concat(result, ' ')
end
-- ---------------------- -- ----------------------
-- PlacesOverlay -- PlacesOverlay
-- --
@ -142,17 +172,14 @@ function PlacesOverlay:init()
self:register_handler('ZONES', buildings.list[df.buildings_mode_type.ZONES], curry(sortoverlay.single_vector_search, {get_search_key_fn=get_zone_search_key})) self:register_handler('ZONES', buildings.list[df.buildings_mode_type.ZONES], curry(sortoverlay.single_vector_search, {get_search_key_fn=get_zone_search_key}))
self:register_handler('LOCATIONS', buildings.list[df.buildings_mode_type.LOCATIONS], curry(sortoverlay.single_vector_search, {get_search_key_fn=get_location_search_key})) self:register_handler('LOCATIONS', buildings.list[df.buildings_mode_type.LOCATIONS], curry(sortoverlay.single_vector_search, {get_search_key_fn=get_location_search_key}))
self:register_handler('STOCKPILES', buildings.list[df.buildings_mode_type.STOCKPILES], curry(sortoverlay.single_vector_search, {get_search_key_fn=get_stockpile_search_key}))
self:register_handler('WORKSHOPS', buildings.list[df.buildings_mode_type.WORKSHOPS], curry(sortoverlay.single_vector_search, {get_search_key_fn=get_workshop_search_key}))
self:register_handler('FARMPLOTS', buildings.list[df.buildings_mode_type.FARMPLOTS], curry(sortoverlay.single_vector_search, {get_search_key_fn=get_farmplot_search_key}))
end end
function PlacesOverlay:get_key() function PlacesOverlay:get_key()
if info.current_mode == df.info_interface_mode_type.BUILDINGS then if info.current_mode == df.info_interface_mode_type.BUILDINGS then
-- TODO: Replace nested if with 'return df.buildings_mode_type[buildings.mode]' once other handlers are written return df.buildings_mode_type[buildings.mode]
-- Not there right now so it doesn't render a search bar on unsupported Places subpages
if buildings.mode == df.buildings_mode_type.ZONES then
return 'ZONES'
elseif buildings.mode == df.buildings_mode_type.LOCATIONS then
return 'LOCATIONS'
end
end end
end end