@@ -25,6 +25,7 @@ local filters = {
2525 max_quality = 6 ,
2626 hide_unreachable = true ,
2727 hide_forbidden = false ,
28+ hide_written = false ,
2829 inside_containers = true ,
2930}
3031
@@ -288,7 +289,7 @@ function AssignItems:init()
288289 },
289290 widgets .ToggleHotkeyLabel {
290291 view_id = ' hide_forbidden' ,
291- frame = {t = 2 , l = 40 , w = 30 },
292+ frame = {t = 1 , l = 40 , w = 30 },
292293 label = ' Hide forbidden items:' ,
293294 key = ' CUSTOM_SHIFT_F' ,
294295 options = {
@@ -302,6 +303,22 @@ function AssignItems:init()
302303 self :refresh_list ()
303304 end ,
304305 },
306+ widgets .ToggleHotkeyLabel {
307+ view_id = ' hide_written' ,
308+ frame = {t = 3 , l = 40 , w = 30 },
309+ label = ' Hide written items:' ,
310+ key = ' CUSTOM_SHIFT_W' ,
311+ options = {
312+ {label = ' Yes' , value = true , pen = COLOR_GREEN },
313+ {label = ' No' , value = false }
314+ },
315+ option_gap = 5 ,
316+ initial_option = filters .hide_written ,
317+ on_change = function (val )
318+ filters .hide_written = val
319+ self :refresh_list ()
320+ end ,
321+ },
305322 },
306323 },
307324 widgets .Panel {
@@ -553,17 +570,24 @@ function AssignItems:cache_choices(inside_containers, display_bld)
553570 return choices
554571end
555572
573+ local function is_written_work (item )
574+ if df .item_bookst :is_instance (item ) then return true end
575+ return df .item_toolst :is_instance (item ) and item :hasToolUse (df .tool_uses .CONTAIN_WRITING )
576+ end
577+
556578function AssignItems :get_choices ()
557579 local raw_choices = self :cache_choices (self .subviews .inside_containers :getOptionValue (), self .bld )
558580 local choices = {}
559581 local include_unreachable = not self .subviews .hide_unreachable :getOptionValue ()
560582 local include_forbidden = not self .subviews .hide_forbidden :getOptionValue ()
583+ local include_written = not self .subviews .hide_written :getOptionValue ()
561584 local min_quality = self .subviews .min_quality :getOptionValue ()
562585 local max_quality = self .subviews .max_quality :getOptionValue ()
563586 for _ ,choice in ipairs (raw_choices ) do
564587 local data = choice .data
565588 if not include_unreachable and not data .reachable then goto continue end
566589 if not include_forbidden and data .item .flags .forbid then goto continue end
590+ if not include_written and is_written_work (data .item ) then goto continue end
567591 if min_quality > data .quality then goto continue end
568592 if max_quality < data .quality then goto continue end
569593 table.insert (choices , choice )
0 commit comments