@@ -1029,12 +1029,29 @@ function SquadFilterOverlay:init()
10291029
10301030 local left_panel = widgets .Panel {
10311031 view_id = ' left_panel' ,
1032- frame = {t = 1 , b = 0 , l = 0 , w = NARROW_WIDTH - 4 },
1032+ frame = {t = 0 , b = 0 , l = 0 , w = NARROW_WIDTH - 4 },
10331033 visible = true ,
10341034 subviews = {
1035+ widgets .HotkeyLabel {
1036+ view_id = ' toggle_all' ,
1037+ frame = {t = 0 , l = 0 },
1038+ key = ' CUSTOM_SHIFT_A' ,
1039+ label = ' Toggle all' ,
1040+ on_activate = function ()
1041+ local target = self .subviews .military :getOptionValue () == ' exclude' and ' include' or ' exclude'
1042+ self .subviews .military :setOption (target )
1043+ self .subviews .officials :setOption (target )
1044+ self .subviews .nobles :setOption (target )
1045+ self .subviews .infant :setOption (target )
1046+ self .subviews .unstable :setOption (target )
1047+ self .subviews .maimed :setOption (target )
1048+ self .subviews .labor_conflict :setOption (target )
1049+ poke_list ()
1050+ end ,
1051+ },
10351052 widgets .CycleHotkeyLabel {
10361053 view_id = ' military' ,
1037- frame = {t = 0 , l = 0 },
1054+ frame = {t = 1 , l = 0 },
10381055 key = ' CUSTOM_SHIFT_Q' ,
10391056 label = ' Other squads:' ,
10401057 options = {
@@ -1047,7 +1064,7 @@ function SquadFilterOverlay:init()
10471064 },
10481065 widgets .CycleHotkeyLabel {
10491066 view_id = ' officials' ,
1050- frame = {t = 1 , l = 0 },
1067+ frame = {t = 2 , l = 0 },
10511068 key = ' CUSTOM_SHIFT_O' ,
10521069 label = ' Officials:' ,
10531070 options = {
@@ -1060,7 +1077,7 @@ function SquadFilterOverlay:init()
10601077 },
10611078 widgets .CycleHotkeyLabel {
10621079 view_id = ' nobles' ,
1063- frame = {t = 2 , l = 0 },
1080+ frame = {t = 3 , l = 0 },
10641081 key = ' CUSTOM_SHIFT_N' ,
10651082 label = ' Nobility:' ,
10661083 options = {
@@ -1076,12 +1093,25 @@ function SquadFilterOverlay:init()
10761093
10771094 local right_panel = widgets .Panel {
10781095 view_id = ' right_panel' ,
1079- frame = {t = 1 , b = 0 , r = 2 , w = NARROW_WIDTH - 4 },
1096+ frame = {t = 0 , b = 0 , r = 2 , w = NARROW_WIDTH - 4 },
10801097 visible = false ,
10811098 subviews = {
10821099 widgets .CycleHotkeyLabel {
1083- view_id = ' infant ' ,
1100+ view_id = ' labor_conflict ' ,
10841101 frame = {t = 0 , l = 0 },
1102+ key = ' CUSTOM_SHIFT_U' ,
1103+ label = ' Uniformed:' ,
1104+ options = {
1105+ {label = ' Include' , value = ' include' , pen = COLOR_GREEN },
1106+ {label = ' Only' , value = ' only' , pen = COLOR_YELLOW },
1107+ {label = ' Exclude' , value = ' exclude' , pen = COLOR_LIGHTRED },
1108+ },
1109+ initial_option = ' include' ,
1110+ on_change = poke_list ,
1111+ },
1112+ widgets .CycleHotkeyLabel {
1113+ view_id = ' infant' ,
1114+ frame = {t = 1 , l = 0 },
10851115 key = ' CUSTOM_SHIFT_M' ,
10861116 label = ' With infants:' ,
10871117 options = {
@@ -1094,7 +1124,7 @@ function SquadFilterOverlay:init()
10941124 },
10951125 widgets .CycleHotkeyLabel {
10961126 view_id = ' unstable' ,
1097- frame = {t = 1 , l = 0 },
1127+ frame = {t = 2 , l = 0 },
10981128 key = ' CUSTOM_SHIFT_D' ,
10991129 label = ' Hates combat:' ,
11001130 options = {
@@ -1107,7 +1137,7 @@ function SquadFilterOverlay:init()
11071137 },
11081138 widgets .CycleHotkeyLabel {
11091139 view_id = ' maimed' ,
1110- frame = {t = 2 , l = 0 },
1140+ frame = {t = 3 , l = 0 },
11111141 key = ' CUSTOM_SHIFT_I' ,
11121142 label = ' Maimed:' ,
11131143 options = {
@@ -1125,21 +1155,6 @@ function SquadFilterOverlay:init()
11251155 frame_style = gui .FRAME_MEDIUM ,
11261156 frame_background = gui .CLEAR_PEN ,
11271157 subviews = {
1128- widgets .HotkeyLabel {
1129- frame = {t = 0 , w = NARROW_WIDTH - 3 },
1130- key = ' CUSTOM_SHIFT_A' ,
1131- label = ' Toggle all filters' ,
1132- on_activate = function ()
1133- local target = self .subviews .military :getOptionValue () == ' exclude' and ' include' or ' exclude'
1134- self .subviews .military :setOption (target )
1135- self .subviews .officials :setOption (target )
1136- self .subviews .nobles :setOption (target )
1137- self .subviews .infant :setOption (target )
1138- self .subviews .unstable :setOption (target )
1139- self .subviews .maimed :setOption (target )
1140- poke_list ()
1141- end ,
1142- },
11431158 left_panel ,
11441159 widgets .Label {
11451160 view_id = ' shifter' ,
@@ -1167,9 +1182,8 @@ function SquadFilterOverlay:init()
11671182 main_panel ,
11681183 widgets .Divider {
11691184 view_id = ' divider' ,
1170- frame = {l = NARROW_WIDTH - 1 , w = 1 , t = 2 },
1185+ frame = {l = NARROW_WIDTH - 1 , w = 1 , t = 0 },
11711186 frame_style = gui .FRAME_MEDIUM ,
1172- frame_style_t = false ,
11731187 visible = false ,
11741188 },
11751189 widgets .HelpButton {
@@ -1253,6 +1267,12 @@ local function is_maimed(unit)
12531267 unit .status2 .limbs_stand_count == 0
12541268end
12551269
1270+ local function has_labor_conflict (unit )
1271+ return unit .status .labors [df .unit_labor .MINE ] or
1272+ unit .status .labors [df .unit_labor .CUTWOOD ] or
1273+ unit .status .labors [df .unit_labor .HUNT ]
1274+ end
1275+
12561276local function filter_matches (unit , filter )
12571277 if filter .military == ' only' and not is_in_military (unit ) then return false end
12581278 if filter .military == ' exclude' and is_in_military (unit ) then return false end
@@ -1266,6 +1286,8 @@ local function filter_matches(unit, filter)
12661286 if filter .unstable == ' exclude' and is_unstable (unit ) then return false end
12671287 if filter .maimed == ' only' and not is_maimed (unit ) then return false end
12681288 if filter .maimed == ' exclude' and is_maimed (unit ) then return false end
1289+ if filter .labor_conflict == ' only' and not has_labor_conflict (unit ) then return false end
1290+ if filter .labor_conflict == ' exclude' and has_labor_conflict (unit ) then return false end
12691291 return true
12701292end
12711293
@@ -1281,6 +1303,7 @@ function do_squad_filter(unit)
12811303 infant = self .subviews .infant :getOptionValue (),
12821304 unstable = self .subviews .unstable :getOptionValue (),
12831305 maimed = self .subviews .maimed :getOptionValue (),
1306+ labor_conflict = self .subviews .labor_conflict :getOptionValue (),
12841307 }
12851308 return filter_matches (unit , filter )
12861309end
0 commit comments