@@ -9,8 +9,9 @@ local widgets = require('gui.widgets')
99Sitemap = defclass (Sitemap , widgets .Window )
1010Sitemap .ATTRS {
1111 frame_title = ' Sitemap' ,
12- frame = {w = 47 , r = 2 , t = 18 , h = 23 },
12+ frame = {w = 57 , r = 2 , t = 18 , h = 25 },
1313 resizable = true ,
14+ resize_min = {w = 43 , h = 20 },
1415}
1516
1617local function to_title_case (str )
@@ -99,23 +100,41 @@ local function zoom_to_next_zone(_, choice)
99100 data .next_idx = data .next_idx % # data .zones + 1
100101end
101102
102- local function get_unit_disposition_and_pen (unit )
103+ local function get_affiliation (unit )
104+ local he = df .historical_entity .find (unit .civ_id )
105+ if not he then return ' Unknown affiliation' end
106+ local et_name = dfhack .TranslateName (he .name , true )
107+ local et_type = df .historical_entity_type [he .type ]:gsub (' (%l)(%u)' , ' %1 %2' )
108+ return (' %s%s %s' ):format (# et_name > 0 and et_name or ' Unknown' , # et_name > 0 and ' ,' or ' ' , et_type )
109+ end
110+
111+ local function get_unit_disposition_and_pen_and_affiliation (unit )
103112 local prefix = unit .flags1 .caged and ' caged ' or ' '
104113 if dfhack .units .isDanger (unit ) then
114+ if dfhack .units .isInvader (unit ) then
115+ return prefix .. ' invader' , COLOR_RED , get_affiliation (unit )
116+ end
105117 return prefix .. ' hostile' , COLOR_LIGHTRED
106- end
107- if not dfhack .units .isFortControlled (unit ) and dfhack .units .isWildlife (unit ) then
118+ elseif dfhack .units .isFortControlled (unit ) then
119+ return prefix .. ' fort ' .. (dfhack .units .isAnimal (unit ) and ' animal' or ' member' ), COLOR_LIGHTBLUE
120+ elseif dfhack .units .isWildlife (unit ) then
108121 return prefix .. ' wildlife' , COLOR_GREEN
122+ elseif dfhack .units .isVisitor (unit ) or dfhack .units .isDiplomat (unit ) then
123+ return prefix .. ' visitor' , COLOR_MAGENTA , get_affiliation (unit )
124+ elseif dfhack .units .isMerchant (unit ) or dfhack .units .isForest (unit ) then
125+ return prefix .. ' merchant' .. (dfhack .units .isAnimal (unit ) and ' animal' or ' ' ), COLOR_BROWN , get_affiliation (unit )
109126 end
110127 return prefix .. ' friendly' , COLOR_LIGHTGREEN
111128end
112129
113130local function get_unit_choice_text (unit )
114- local disposition , disposition_pen = get_unit_disposition_and_pen (unit )
131+ local disposition , disposition_pen , affiliation = get_unit_disposition_and_pen_and_affiliation (unit )
115132 return {
116133 dfhack .units .getReadableName (unit ),
117134 ' (' ,
118135 {text = disposition , pen = disposition_pen },
136+ affiliation and ' : ' or ' ' ,
137+ {text = affiliation , pen = COLOR_YELLOW },
119138 ' )' ,
120139 }
121140end
0 commit comments