Skip to content

Commit

Permalink
Show geld status and custom profession in animal zone assignment window
Browse files Browse the repository at this point in the history
  • Loading branch information
neumond committed Jan 17, 2024
1 parent 29ab47d commit c6ee5cb
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions plugins/lua/zone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,24 @@ end

local function sort_by_gender_desc(a, b)
if a.data.gender == b.data.gender then
return sort_by_race_desc(a, b)
local ag = a.data.gelded or false
local bg = b.data.gelded or false
if ag == bg then
return sort_by_race_desc(a, b)
end
return bg
end
return a.data.gender < b.data.gender
end

local function sort_by_gender_asc(a, b)
if a.data.gender == b.data.gender then
return sort_by_race_desc(a, b)
local ag = a.data.gelded or false
local bg = b.data.gelded or false
if ag == bg then
return sort_by_race_desc(a, b)
end
return ag
end
return a.data.gender > b.data.gender
end
Expand Down Expand Up @@ -447,6 +457,7 @@ function AssignAnimal:make_choice_text(data)
elseif data.gender == df.pronoun_type.he then
gender_ch = CH_MALE
end
gender_ch = string.format(data.gelded and 'x%sx' or ' %s ', gender_ch)
return {
{width=STATUS_COL_WIDTH, text=function() return self.status[self.status_revmap[data.status]].label end},
{gap=2, width=DISPOSITION_COL_WIDTH, text=function() return DISPOSITION[DISPOSITION_REVMAP[data.disposition]].label end},
Expand Down Expand Up @@ -562,16 +573,21 @@ function AssignAnimal:cache_choices()
for _, unit in ipairs(df.global.world.units.active) do
if not is_assignable_unit(unit) then goto continue end
local raw = df.creature_raw.find(unit.race)
local desc = dfhack.units.getReadableName(unit)
if #unit.custom_profession > 0 then
desc = unit.custom_profession .. ', ' .. desc
end
local data = {
unit=unit,
desc=dfhack.units.getReadableName(unit),
desc=desc,
gender=unit.sex,
race=raw and raw.creature_id or '',
status=self.get_status(unit, bld_assignments),
disposition=get_unit_disposition(unit),
egg=dfhack.units.isEggLayerRace(unit),
graze=dfhack.units.isGrazer(unit),
juvenile=not dfhack.units.isAdult(unit),
gelded=dfhack.units.isGelded(unit),
}
local choice = {
search_key=make_search_key(data.desc, raw),
Expand Down

0 comments on commit c6ee5cb

Please sign in to comment.