@@ -13,7 +13,8 @@ Sitemap.ATTRS {
1313 frame_title = ' Sitemap' ,
1414 frame = {w = 57 , r = 2 , t = 18 , h = 25 },
1515 resizable = true ,
16- resize_min = {w = 43 , h = 20 },
16+ resize_min = {w = 44 , h = 20 },
17+ frame_inset = {l = 1 , t = 1 , r = 0 , b = 0 },
1718}
1819
1920local function to_title_case (str )
@@ -169,6 +170,19 @@ local function zoom_to_unit(_, choice)
169170 if not unit then return end
170171 dfhack .gui .revealInDwarfmodeMap (
171172 xyz2pos (dfhack .units .getPosition (unit )), true , true )
173+ return unit .id
174+ end
175+
176+ local function follow_unit (idx , choice )
177+ local unit_id = zoom_to_unit (idx , choice )
178+ if not unit_id or not dfhack .world .isFortressMode () then return end
179+ df .global .plotinfo .follow_item = - 1
180+ df .global .plotinfo .follow_unit = unit_id
181+ pcall (function ()
182+ -- if spectate is available, add the unit to the follow history
183+ local spectate = require (' plugins.spectate' )
184+ spectate .spectate_addToHistory (unit_id )
185+ end )
172186end
173187
174188local function get_artifact_choices ()
@@ -192,6 +206,33 @@ local function zoom_to_item(_, choice)
192206 if not item then return end
193207 dfhack .gui .revealInDwarfmodeMap (
194208 xyz2pos (dfhack .items .getPosition (item )), true , true )
209+ return item .id
210+ end
211+
212+ local function follow_item (idx , choice )
213+ local item_id = zoom_to_item (idx , choice )
214+ if not item_id or not dfhack .world .isFortressMode () then return end
215+ df .global .plotinfo .follow_item = item_id
216+ df .global .plotinfo .follow_unit = - 1
217+ end
218+
219+ local function get_bottom_text ()
220+ local text = {
221+ ' Click on a name or hit ' , {text = ' Enter' , pen = COLOR_LIGHTGREEN }, ' to zoom to' , NEWLINE ,
222+ ' the selected target.' ,
223+ }
224+
225+ if not dfhack .world .isFortressMode () then
226+ table.insert (text , NEWLINE )
227+ table.insert (text , NEWLINE )
228+ return text
229+ end
230+
231+ table.insert (text , ' Shift-click or' )
232+ table.insert (text , NEWLINE )
233+ table.insert (text , {text = ' Shift-Enter' , pen = COLOR_LIGHTGREEN })
234+ table.insert (text , ' to zoom and follow unit/item.' )
235+ return text
195236end
196237
197238function Sitemap :init ()
@@ -217,7 +258,7 @@ function Sitemap:init()
217258 },
218259 widgets .Pages {
219260 view_id = ' pages' ,
220- frame = {t = 3 , l = 0 , b = 5 , r = 0 },
261+ frame = {t = 3 , l = 0 , b = 6 , r = 0 },
221262 subviews = {
222263 widgets .Panel {
223264 subviews = {
@@ -230,6 +271,7 @@ function Sitemap:init()
230271 widgets .FilteredList {
231272 view_id = ' list' ,
232273 on_submit = zoom_to_unit ,
274+ on_submit2 = follow_unit ,
233275 choices = unit_choices ,
234276 visible =# unit_choices > 0 ,
235277 },
@@ -255,6 +297,7 @@ function Sitemap:init()
255297 widgets .FilteredList {
256298 view_id = ' list' ,
257299 on_submit = zoom_to_next_zone ,
300+ on_submit2 = zoom_to_next_zone ,
258301 choices = location_choices ,
259302 visible =# location_choices > 0 ,
260303 },
@@ -271,6 +314,7 @@ function Sitemap:init()
271314 widgets .FilteredList {
272315 view_id = ' list' ,
273316 on_submit = zoom_to_item ,
317+ on_submit2 = follow_item ,
274318 choices = artifact_choices ,
275319 visible =# artifact_choices > 0 ,
276320 },
@@ -279,17 +323,14 @@ function Sitemap:init()
279323 },
280324 },
281325 widgets .Divider {
282- frame = {b = 3 , h = 1 },
326+ frame = {b = 4 , h = 1 , l = 0 , r = 1 },
283327 frame_style = gui .FRAME_THIN ,
284328 frame_style_l = false ,
285329 frame_style_r = false ,
286330 },
287331 widgets .Label {
288332 frame = {b = 0 , l = 0 },
289- text = {
290- ' Click on a name or hit ' , {text = ' Enter' , pen = COLOR_LIGHTGREEN }, NEWLINE ,
291- ' to zoom to the selected target.'
292- },
333+ text = get_bottom_text (),
293334 },
294335 }
295336end
0 commit comments