diff --git a/changelog.txt b/changelog.txt index af409165e..18bb88c42 100644 --- a/changelog.txt +++ b/changelog.txt @@ -35,6 +35,7 @@ Template for new versions: ## Misc Improvements - `immortal-cravings`: goblins and other naturally non-eating/non-drinking races will now also satisfy their needs for eating and drinking +- `caravan`: add filter for written works in display furniture assignment dialog ## Removed diff --git a/docs/caravan.rst b/docs/caravan.rst index 320851463..17cb2ed07 100644 --- a/docs/caravan.rst +++ b/docs/caravan.rst @@ -156,5 +156,9 @@ assignment GUI. The dialog allows you to sort by name, value, or where the item is currently assigned for display. -You can search by name, and you can filter by item quality and by whether the -item is forbidden. +You can search by name, and you can filter by: + +- item quality +- whether the item is forbidden +- whether the item is reachable from the display furniture +- whether the item is a written work (book or scroll) diff --git a/internal/caravan/pedestal.lua b/internal/caravan/pedestal.lua index d5ccfc3e1..cd188914c 100644 --- a/internal/caravan/pedestal.lua +++ b/internal/caravan/pedestal.lua @@ -25,6 +25,7 @@ local filters = { max_quality=6, hide_unreachable=true, hide_forbidden=false, + hide_written=false, inside_containers=true, } @@ -288,7 +289,7 @@ function AssignItems:init() }, widgets.ToggleHotkeyLabel{ view_id='hide_forbidden', - frame={t=2, l=40, w=30}, + frame={t=1, l=40, w=30}, label='Hide forbidden items:', key='CUSTOM_SHIFT_F', options={ @@ -302,6 +303,22 @@ function AssignItems:init() self:refresh_list() end, }, + widgets.ToggleHotkeyLabel{ + view_id='hide_written', + frame={t=3, l=40, w=30}, + label='Hide written items:', + key='CUSTOM_SHIFT_W', + options={ + {label='Yes', value=true, pen=COLOR_GREEN}, + {label='No', value=false} + }, + option_gap=5, + initial_option=filters.hide_written, + on_change=function(val) + filters.hide_written = val + self:refresh_list() + end, + }, }, }, widgets.Panel{ @@ -553,17 +570,24 @@ function AssignItems:cache_choices(inside_containers, display_bld) return choices end +local function is_written_work(item) + if df.item_bookst:is_instance(item) then return true end + return df.item_toolst:is_instance(item) and item:hasToolUse(df.tool_uses.CONTAIN_WRITING) +end + function AssignItems:get_choices() local raw_choices = self:cache_choices(self.subviews.inside_containers:getOptionValue(), self.bld) local choices = {} local include_unreachable = not self.subviews.hide_unreachable:getOptionValue() local include_forbidden = not self.subviews.hide_forbidden:getOptionValue() + local include_written = not self.subviews.hide_written:getOptionValue() local min_quality = self.subviews.min_quality:getOptionValue() local max_quality = self.subviews.max_quality:getOptionValue() for _,choice in ipairs(raw_choices) do local data = choice.data if not include_unreachable and not data.reachable then goto continue end if not include_forbidden and data.item.flags.forbid then goto continue end + if not include_written and is_written_work(data.item) then goto continue end if min_quality > data.quality then goto continue end if max_quality < data.quality then goto continue end table.insert(choices, choice)