@@ -95,6 +95,12 @@ function ColumnMenu:init()
95
95
text = ' Hide group' ,
96
96
fn = self .col :callback (' hide_group' ),
97
97
})
98
+ if self .col .zoom_fn then
99
+ table.insert (choices , {
100
+ text = ' Zoom to' ,
101
+ fn = self .col .zoom_fn ,
102
+ })
103
+ end
98
104
99
105
self :addviews {
100
106
widgets .List {
@@ -148,6 +154,7 @@ Column.ATTRS{
148
154
count_fn = DEFAULT_NIL ,
149
155
cmp_fn = DEFAULT_NIL ,
150
156
choice_fn = DEFAULT_NIL ,
157
+ zoom_fn = DEFAULT_NIL ,
151
158
}
152
159
153
160
local CH_DOT = string.char (15 )
@@ -233,7 +240,7 @@ function Column:init()
233
240
},
234
241
ColumnMenu {
235
242
view_id = ' col_menu' ,
236
- frame = {l = 0 , t = 1 , h = 5 },
243
+ frame = {l = 0 , t = 1 , h = self . zoom_fn and 6 or 5 },
237
244
col = self ,
238
245
},
239
246
},
@@ -647,19 +654,23 @@ function Spreadsheet:init()
647
654
end
648
655
649
656
local function add_workshops (vec , type_enum , type_defs )
650
- for _ , workshop in ipairs (vec ) do
657
+ for _ , bld in ipairs (vec ) do
651
658
cols :addviews {
652
659
ToggleColumn {
653
660
group = ' workshops' ,
654
- label = get_workshop_label (workshop , type_enum , type_defs ),
661
+ label = get_workshop_label (bld , type_enum , type_defs ),
655
662
shared = self .shared ,
656
- data_fn = curry (toggle_sorted_vec_data , workshop .profile .permitted_workers ),
663
+ data_fn = curry (toggle_sorted_vec_data , bld .profile .permitted_workers ),
657
664
toggle_fn = function (unit_id , prev_val )
658
665
if not prev_val then
659
666
-- there can be only one
660
- workshop .profile .permitted_workers :resize (0 )
667
+ bld .profile .permitted_workers :resize (0 )
661
668
end
662
- toggle_sorted_vec (workshop .profile .permitted_workers , unit_id , prev_val )
669
+ toggle_sorted_vec (bld .profile .permitted_workers , unit_id , prev_val )
670
+ end ,
671
+ zoom_fn = function ()
672
+ dfhack .gui .revealInDwarfmodeMap (
673
+ xyz2pos (bld .centerx , bld .centery , bld .z ), true , true )
663
674
end ,
664
675
}
665
676
}
@@ -717,6 +728,19 @@ function Spreadsheet:init()
717
728
self .namelist :setFocus (true )
718
729
end
719
730
731
+ function Spreadsheet :zoom_to_unit ()
732
+ local idx = self .namelist :getSelected ()
733
+ if not idx then return end
734
+ local unit = df .unit .find (self .subviews .name :get_sorted_unit_id (idx ))
735
+ if not unit then return end
736
+ dfhack .gui .revealInDwarfmodeMap (
737
+ xyz2pos (dfhack .units .getPosition (unit )), true , true )
738
+ end
739
+
740
+ function Spreadsheet :zoom_to_col_source ()
741
+ -- TODO
742
+ end
743
+
720
744
function Spreadsheet :sort_by_current_col ()
721
745
-- TODO
722
746
end
@@ -1091,6 +1115,20 @@ function Manipulator:init()
1091
1115
widgets .HotkeyLabel {
1092
1116
frame = {b = 0 , l = 0 },
1093
1117
auto_width = true ,
1118
+ label = ' Zoom to unit' ,
1119
+ key = ' CUSTOM_SHIFT_Z' ,
1120
+ on_activate = function () self .subviews .sheet :zoom_to_unit () end ,
1121
+ },
1122
+ widgets .HotkeyLabel {
1123
+ frame = {b = 0 , l = 22 },
1124
+ auto_width = true ,
1125
+ label = ' Zoom to col source' ,
1126
+ key = ' CUSTOM_CTRL_Z' ,
1127
+ on_activate = function () self .subviews .sheet :zoom_to_col_source () end ,
1128
+ },
1129
+ widgets .HotkeyLabel {
1130
+ frame = {b = 0 , l = 46 },
1131
+ auto_width = true ,
1094
1132
label = function ()
1095
1133
return self .needs_refresh and ' Refresh units (new units have arrived)' or ' Refresh units'
1096
1134
end ,
0 commit comments