Skip to content

Commit b742930

Browse files
authored
Merge pull request #1442 from myk002/myk_english_v2
refine display of readable names
2 parents 6c24dc1 + 90581ce commit b742930

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

gui/sitemap.lua

+4-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ end
1818
Sitemap = defclass(Sitemap, widgets.Window)
1919
Sitemap.ATTRS {
2020
frame_title='Sitemap',
21-
frame={w=67, r=2, t=18, h=25},
21+
frame={w=67, r=2, t=18, h=26},
2222
resizable=true,
2323
resize_min={w=44, h=20},
2424
frame_inset={l=1, t=1, r=0, b=0},
@@ -141,12 +141,10 @@ end
141141
local function get_unit_choice_text(unit)
142142
local disposition, disposition_pen, affiliation = get_unit_disposition_and_pen_and_affiliation(unit)
143143
return {
144-
dfhack.units.getReadableName(unit),
145-
' (',
146-
{text=disposition, pen=disposition_pen},
144+
dfhack.units.getReadableName(unit), NEWLINE,
145+
{gap=2, text=disposition, pen=disposition_pen},
147146
affiliation and ': ' or '',
148147
{text=affiliation, pen=COLOR_YELLOW},
149-
')',
150148
}
151149
end
152150

@@ -277,6 +275,7 @@ function Sitemap:init()
277275
},
278276
widgets.FilteredList{
279277
view_id='list',
278+
row_height=2,
280279
on_submit=zoom_to_unit,
281280
on_submit2=follow_unit,
282281
choices=unit_choices,

gui/unit-info-viewer.lua

+14-2
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,17 @@ end
174174

175175
local function get_name_chunk(unit)
176176
return {
177-
text=dfhack.units.getReadableName(unit),
177+
text=dfhack.units.getReadableName(unit, true),
178178
pen=dfhack.units.getProfessionColor(unit)
179179
}
180180
end
181181

182+
local function get_translated_name_chunk(unit)
183+
local tname = dfhack.translation.translateName(dfhack.units.getVisibleName(unit), true)
184+
if #tname == 0 then return '' end
185+
return ('"%s"'):format(tname)
186+
end
187+
182188
local function get_description_chunk(unit)
183189
local desc = dfhack.units.getCasteRaw(unit).description
184190
if #desc == 0 then return end
@@ -455,9 +461,14 @@ function UnitInfo:init()
455461
frame={t=0, l=0, h=1},
456462
auto_height=false,
457463
},
464+
widgets.Label{
465+
view_id='translated_name',
466+
frame={t=1, l=0, h=1},
467+
auto_height=false,
468+
},
458469
widgets.Label{
459470
view_id='chunks',
460-
frame={t=2, l=0, b=0, r=0},
471+
frame={t=3, l=0, b=0, r=0},
461472
auto_height=false,
462473
text='Please select a unit.',
463474
},
@@ -483,6 +494,7 @@ end
483494
function UnitInfo:refresh(unit, width)
484495
self.unit_id = unit.id
485496
self.subviews.nameprof:setText{get_name_chunk(unit)}
497+
self.subviews.translated_name:setText{get_translated_name_chunk(unit)}
486498

487499
local chunks = {}
488500
add_chunk(chunks, get_description_chunk(unit), width)

prioritize.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ end
703703

704704
function EnRouteOverlay:get_builder_name()
705705
if not self.builder then return 'N/A' end
706-
return dfhack.units.getReadableName(self.builder)
706+
return dfhack.units.getReadableName(self.builder, true)
707707
end
708708

709709
function EnRouteOverlay:get_builder_name_pen()

0 commit comments

Comments
 (0)