Skip to content

Commit ba581c4

Browse files
authored
Merge pull request #1362 from myk002/myk_sitemap_affiliation
[gui/sitemap] show visitor and invader affiliations
2 parents 4a7afa2 + b95028c commit ba581c4

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Template for new versions:
4242
- `caravan`: add filter for written works in display furniture assignment dialog
4343
- `fix/wildlife`: don't vaporize stuck wildlife that is onscreen -- kill them instead (as if they died from old age)
4444
- `gui/gm-unit`: refresh unit sprite when profession is changed
45+
- `gui/sitemap`: show primary group affiliation for visitors and invaders (e.g. civilization name or performance troupe)
4546

4647
## Removed
4748

gui/sitemap.lua

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ local widgets = require('gui.widgets')
99
Sitemap = defclass(Sitemap, widgets.Window)
1010
Sitemap.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

1617
local 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
100101
end
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
111128
end
112129

113130
local 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
}
121140
end

0 commit comments

Comments
 (0)